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_errors.h"
26 #include "lib/zclient.h"
41 #include "bgpd/bgpd.h"
42 #include "bgpd/bgp_attr_evpn.h"
43 #include "bgpd/bgp_advertise.h"
44 #include "bgpd/bgp_attr.h"
45 #include "bgpd/bgp_aspath.h"
46 #include "bgpd/bgp_community.h"
47 #include "bgpd/bgp_ecommunity.h"
48 #include "bgpd/bgp_lcommunity.h"
49 #include "bgpd/bgp_damp.h"
50 #include "bgpd/bgp_debug.h"
51 #include "bgpd/bgp_errors.h"
52 #include "bgpd/bgp_fsm.h"
53 #include "bgpd/bgp_nexthop.h"
54 #include "bgpd/bgp_open.h"
55 #include "bgpd/bgp_regex.h"
56 #include "bgpd/bgp_route.h"
57 #include "bgpd/bgp_mplsvpn.h"
58 #include "bgpd/bgp_zebra.h"
59 #include "bgpd/bgp_table.h"
60 #include "bgpd/bgp_vty.h"
61 #include "bgpd/bgp_mpath.h"
62 #include "bgpd/bgp_packet.h"
63 #include "bgpd/bgp_updgrp.h"
64 #include "bgpd/bgp_bfd.h"
65 #include "bgpd/bgp_io.h"
66 #include "bgpd/bgp_evpn.h"
67 #include "bgpd/bgp_evpn_vty.h"
68 #include "bgpd/bgp_evpn_mh.h"
69 #include "bgpd/bgp_addpath.h"
70 #include "bgpd/bgp_mac.h"
71 #include "bgpd/bgp_flowspec.h"
73 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
76 #include "northbound.h"
77 #include "northbound_cli.h"
78 #include "bgpd/bgp_nb.h"
81 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
84 .match_profile
= "traditional",
85 .match_version
= "< 7.4",
89 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
90 { .val_bool
= true, .match_profile
= "datacenter", },
91 { .val_bool
= false },
93 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
94 { .val_bool
= true, .match_profile
= "datacenter", },
95 { .val_bool
= false },
97 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
98 { .val_bool
= true, .match_profile
= "datacenter", },
99 { .val_bool
= false },
101 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
102 { .val_bool
= true, .match_profile
= "datacenter", },
103 { .val_bool
= false },
105 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
106 { .val_ulong
= 10, .match_profile
= "datacenter", },
107 { .val_ulong
= 120 },
109 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
110 { .val_ulong
= 9, .match_profile
= "datacenter", },
111 { .val_ulong
= 180 },
113 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
114 { .val_ulong
= 3, .match_profile
= "datacenter", },
117 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
118 { .val_bool
= false, .match_profile
= "datacenter", },
119 { .val_bool
= false, .match_version
= "< 7.4", },
120 { .val_bool
= true },
122 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
123 { .val_bool
= false, .match_version
= "< 7.6", },
124 { .val_bool
= true },
127 DEFINE_HOOK(bgp_inst_config_write
,
128 (struct bgp
*bgp
, struct vty
*vty
),
132 "The Graceful Restart No Operation was executed as cmd same as previous one."
134 "The Graceful Restart command used is not valid at this moment."
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
;
473 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
474 enum bgp_instance_type inst_type
)
476 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
478 if (ret
== BGP_CREATED
) {
479 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
480 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
482 if (DFLT_BGP_IMPORT_CHECK
)
483 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
484 if (DFLT_BGP_SHOW_HOSTNAME
)
485 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
486 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
487 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
488 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
489 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
490 if (DFLT_BGP_DETERMINISTIC_MED
)
491 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
492 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
493 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
494 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
495 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
503 * bgp_vty_find_and_parse_afi_safi_bgp
505 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
506 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
507 * to appropriate values for the calling function. This is to allow the
508 * calling function to make decisions appropriate for the show command
509 * that is being parsed.
511 * The show commands are generally of the form:
512 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
513 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
515 * Since we use argv_find if the show command in particular doesn't have:
517 * [<view|vrf> VIEWVRFNAME]
518 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
519 * The command parsing should still be ok.
521 * vty -> The vty for the command so we can output some useful data in
522 * the event of a parse error in the vrf.
523 * argv -> The command tokens
524 * argc -> How many command tokens we have
525 * idx -> The current place in the command, generally should be 0 for this
527 * afi -> The parsed afi if it was included in the show command, returned here
528 * safi -> The parsed safi if it was included in the show command, returned here
529 * bgp -> Pointer to the bgp data structure we need to fill in.
530 * use_json -> json is configured or not
532 * The function returns the correct location in the parse tree for the
535 * Returns 0 for failure to parse correctly, else the idx position of where
536 * it found the last token.
538 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
539 struct cmd_token
**argv
, int argc
,
540 int *idx
, afi_t
*afi
, safi_t
*safi
,
541 struct bgp
**bgp
, bool use_json
)
543 char *vrf_name
= NULL
;
549 if (argv_find(argv
, argc
, "ip", idx
))
552 if (argv_find(argv
, argc
, "view", idx
))
553 vrf_name
= argv
[*idx
+ 1]->arg
;
554 else if (argv_find(argv
, argc
, "vrf", idx
)) {
555 vrf_name
= argv
[*idx
+ 1]->arg
;
556 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
560 if (strmatch(vrf_name
, "all"))
563 *bgp
= bgp_lookup_by_name(vrf_name
);
566 json_object
*json
= NULL
;
567 json
= json_object_new_object();
568 json_object_string_add(
570 "View/Vrf is unknown");
572 json_object_to_json_string_ext(json
,
573 JSON_C_TO_STRING_PRETTY
));
574 json_object_free(json
);
577 vty_out(vty
, "View/Vrf %s is unknown\n",
584 *bgp
= bgp_get_default();
587 json_object
*json
= NULL
;
588 json
= json_object_new_object();
589 json_object_string_add(
591 "Default BGP instance not found");
593 json_object_to_json_string_ext(json
,
594 JSON_C_TO_STRING_PRETTY
));
595 json_object_free(json
);
599 "Default BGP instance not found\n");
605 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
606 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
612 bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
614 struct interface
*ifp
= NULL
;
616 if (su
->sa
.sa_family
== AF_INET
)
617 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
618 else if (su
->sa
.sa_family
== AF_INET6
)
619 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
620 su
->sin6
.sin6_scope_id
,
629 /* Utility function for looking up peer or peer group. */
630 /* This is used only for configuration, so disallow if attempted on
631 * a dynamic neighbor.
633 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
635 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
638 struct peer
*peer
= NULL
;
639 struct peer_group
*group
= NULL
;
645 ret
= str2sockunion(peer_str
, &su
);
647 /* IP address, locate peer. */
648 peer
= peer_lookup(bgp
, &su
);
650 /* Not IP, could match either peer configured on interface or a
652 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
654 group
= peer_group_lookup(bgp
, peer_str
);
658 if (peer_dynamic_neighbor(peer
)) {
660 "%% Operation not allowed on a dynamic neighbor\n");
670 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
675 int bgp_nb_errmsg_return(char *errmsg
, size_t errmsg_len
, int ret
)
677 const char *str
= NULL
;
680 case BGP_ERR_INVALID_VALUE
:
681 str
= "Invalid value";
683 case BGP_ERR_INVALID_FLAG
:
684 str
= "Invalid flag";
686 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
687 str
= "Peer-group has been shutdown. Activate the peer-group first";
689 case BGP_ERR_PEER_FLAG_CONFLICT
:
690 str
= "Can't set override-capability and strict-capability-match at the same time";
692 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
693 str
= "Specify remote-as or peer-group remote AS first";
695 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
696 str
= "Cannot change the peer-group. Deconfigure first";
698 case BGP_ERR_PEER_GROUP_MISMATCH
:
699 str
= "Peer is not a member of this peer-group";
701 case BGP_ERR_PEER_FILTER_CONFLICT
:
702 str
= "Prefix/distribute list can not co-exist";
704 case BGP_ERR_NOT_INTERNAL_PEER
:
705 str
= "Invalid command. Not an internal neighbor";
707 case BGP_ERR_REMOVE_PRIVATE_AS
:
708 str
= "remove-private-AS cannot be configured for IBGP peers";
710 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
711 str
= "Local-AS allowed only for EBGP peers";
713 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
714 str
= "Cannot have local-as same as BGP AS number";
716 case BGP_ERR_TCPSIG_FAILED
:
717 str
= "Error while applying TCP-Sig to session(s)";
719 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
720 str
= "ebgp-multihop and ttl-security cannot be configured together";
722 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
723 str
= "ttl-security only allowed for EBGP peers";
725 case BGP_ERR_AS_OVERRIDE
:
726 str
= "as-override cannot be configured for IBGP peers";
728 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
729 str
= "Invalid limit for number of dynamic neighbors";
731 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
732 str
= "Dynamic neighbor listen range already exists";
734 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
735 str
= "Operation not allowed on a dynamic neighbor";
737 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
738 str
= "Operation not allowed on a directly connected neighbor";
740 case BGP_ERR_PEER_SAFI_CONFLICT
:
743 case BGP_ERR_GR_INVALID_CMD
:
744 str
= "The Graceful Restart command used is not valid at this moment.";
746 case BGP_ERR_GR_OPERATION_FAILED
:
747 str
= "The Graceful Restart Operation failed due to an err.";
749 case BGP_GR_NO_OPERATION
:
752 case BGP_ERR_PEER_GROUP_MEMBER
:
753 str
= "Peer-group member cannot override remote-as of peer-group";
755 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
756 str
= "Peer-group members must be all internal or all external";
760 snprintf(errmsg
, errmsg_len
, "%s", str
);
767 int bgp_vty_return(struct vty
*vty
, int ret
)
769 const char *str
= NULL
;
772 case BGP_ERR_INVALID_VALUE
:
773 str
= "Invalid value";
775 case BGP_ERR_INVALID_FLAG
:
776 str
= "Invalid flag";
778 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
779 str
= "Peer-group has been shutdown. Activate the peer-group first";
781 case BGP_ERR_PEER_FLAG_CONFLICT
:
782 str
= "Can't set override-capability and strict-capability-match at the same time";
784 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
785 str
= "Specify remote-as or peer-group remote AS first";
787 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
788 str
= "Cannot change the peer-group. Deconfigure first";
790 case BGP_ERR_PEER_GROUP_MISMATCH
:
791 str
= "Peer is not a member of this peer-group";
793 case BGP_ERR_PEER_FILTER_CONFLICT
:
794 str
= "Prefix/distribute list can not co-exist";
796 case BGP_ERR_NOT_INTERNAL_PEER
:
797 str
= "Invalid command. Not an internal neighbor";
799 case BGP_ERR_REMOVE_PRIVATE_AS
:
800 str
= "remove-private-AS cannot be configured for IBGP peers";
802 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
803 str
= "Local-AS allowed only for EBGP peers";
805 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
806 str
= "Cannot have local-as same as BGP AS number";
808 case BGP_ERR_TCPSIG_FAILED
:
809 str
= "Error while applying TCP-Sig to session(s)";
811 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
812 str
= "ebgp-multihop and ttl-security cannot be configured together";
814 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
815 str
= "ttl-security only allowed for EBGP peers";
817 case BGP_ERR_AS_OVERRIDE
:
818 str
= "as-override cannot be configured for IBGP peers";
820 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
821 str
= "Invalid limit for number of dynamic neighbors";
823 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
824 str
= "Dynamic neighbor listen range already exists";
826 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
827 str
= "Operation not allowed on a dynamic neighbor";
829 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
830 str
= "Operation not allowed on a directly connected neighbor";
832 case BGP_ERR_PEER_SAFI_CONFLICT
:
835 case BGP_ERR_GR_INVALID_CMD
:
836 str
= "The Graceful Restart command used is not valid at this moment.";
838 case BGP_ERR_GR_OPERATION_FAILED
:
839 str
= "The Graceful Restart Operation failed due to an err.";
841 case BGP_GR_NO_OPERATION
:
846 vty_out(vty
, "%% %s\n", str
);
847 return CMD_WARNING_CONFIG_FAILED
;
852 /* BGP clear sort. */
861 static void bgp_clear_vty_error(struct peer
*peer
, afi_t afi
, safi_t safi
,
862 int error
, char *errmsg
, size_t errmsg_len
)
865 case BGP_ERR_AF_UNCONFIGURED
:
866 snprintf(errmsg
, errmsg_len
,
867 "%%BGP: Enable %s address family for the neighbor %s",
868 get_afi_safi_str(afi
, safi
, false), peer
->host
);
870 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
873 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig",
881 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
882 struct listnode
**nnode
, enum bgp_clear_type stype
)
887 /* if afi/.safi not specified, spin thru all of them */
888 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
892 FOREACH_AFI_SAFI (tmp_afi
, tmp_safi
) {
893 paf
= peer_af_find(peer
, tmp_afi
, tmp_safi
);
894 if (paf
&& paf
->subgroup
)
895 SET_FLAG(paf
->subgroup
->sflags
,
896 SUBGRP_STATUS_FORCE_UPDATES
);
898 if (!peer
->afc
[tmp_afi
][tmp_safi
])
901 if (stype
== BGP_CLEAR_SOFT_NONE
)
902 ret
= peer_clear(peer
, nnode
);
904 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
907 /* if afi specified and safi not, spin thru safis on this afi */
908 } else if (safi
== SAFI_UNSPEC
) {
911 for (tmp_safi
= SAFI_UNICAST
;
912 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
913 if (!peer
->afc
[afi
][tmp_safi
])
916 paf
= peer_af_find(peer
, afi
, tmp_safi
);
917 if (paf
&& paf
->subgroup
)
918 SET_FLAG(paf
->subgroup
->sflags
,
919 SUBGRP_STATUS_FORCE_UPDATES
);
921 if (stype
== BGP_CLEAR_SOFT_NONE
)
922 ret
= peer_clear(peer
, nnode
);
924 ret
= peer_clear_soft(peer
, afi
,
927 /* both afi/safi specified, let the caller know if not defined */
929 if (!peer
->afc
[afi
][safi
])
932 paf
= peer_af_find(peer
, afi
, safi
);
933 if (paf
&& paf
->subgroup
)
934 SET_FLAG(paf
->subgroup
->sflags
,
935 SUBGRP_STATUS_FORCE_UPDATES
);
937 if (stype
== BGP_CLEAR_SOFT_NONE
)
938 ret
= peer_clear(peer
, nnode
);
940 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
946 /* `clear ip bgp' functions. */
947 static int bgp_clear(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
948 enum clear_sort sort
, enum bgp_clear_type stype
,
949 const char *arg
, char *errmsg
, size_t errmsg_len
)
955 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
957 /* Clear all neighbors. */
959 * Pass along pointer to next node to peer_clear() when walking all
960 * nodes on the BGP instance as that may get freed if it is a
963 if (sort
== clear_all
) {
964 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
966 bgp_peer_gr_flags_update(peer
);
968 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
969 gr_router_detected
= true;
971 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
975 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
979 if (gr_router_detected
980 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
981 bgp_zebra_send_capabilities(bgp
, false);
982 } else if (!gr_router_detected
983 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
984 bgp_zebra_send_capabilities(bgp
, true);
987 /* This is to apply read-only mode on this clear. */
988 if (stype
== BGP_CLEAR_SOFT_NONE
)
989 bgp
->update_delay_over
= 0;
994 /* Clear specified neighbor. */
995 if (sort
== clear_peer
) {
998 /* Make sockunion for lookup. */
999 ret
= str2sockunion(arg
, &su
);
1001 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1003 peer
= peer_lookup_by_hostname(bgp
, arg
);
1007 "Malformed address or name: %s",
1013 peer
= peer_lookup(bgp
, &su
);
1015 snprintf(errmsg
, errmsg_len
,
1016 "%%BGP: Unknown neighbor - \"%s\"",
1022 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1023 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1025 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1027 /* if afi/safi not defined for this peer, let caller know */
1029 ret
= BGP_ERR_AF_UNCONFIGURED
;
1032 bgp_clear_vty_error(peer
, afi
, safi
, ret
, errmsg
,
1038 /* Clear all neighbors belonging to a specific peer-group. */
1039 if (sort
== clear_group
) {
1040 struct peer_group
*group
;
1042 group
= peer_group_lookup(bgp
, arg
);
1044 snprintf(errmsg
, errmsg_len
,
1045 "%%BGP: No such peer-group %s", arg
);
1049 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1050 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1053 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1054 errmsg
, errmsg_len
);
1062 "%%BGP: No %s peer belonging to peer-group %s is configured",
1063 get_afi_safi_str(afi
, safi
, false), arg
);
1068 /* Clear all external (eBGP) neighbors. */
1069 if (sort
== clear_external
) {
1070 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1071 if (peer
->sort
== BGP_PEER_IBGP
)
1074 bgp_peer_gr_flags_update(peer
);
1076 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1077 gr_router_detected
= true;
1079 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1082 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1083 errmsg
, errmsg_len
);
1088 if (gr_router_detected
1089 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1090 bgp_zebra_send_capabilities(bgp
, false);
1091 } else if (!gr_router_detected
1092 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1093 bgp_zebra_send_capabilities(bgp
, true);
1097 snprintf(errmsg
, errmsg_len
,
1098 "%%BGP: No external %s peer is configured",
1099 get_afi_safi_str(afi
, safi
, false));
1104 /* Clear all neighbors belonging to a specific AS. */
1105 if (sort
== clear_as
) {
1106 as_t as
= strtoul(arg
, NULL
, 10);
1108 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1112 bgp_peer_gr_flags_update(peer
);
1114 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1115 gr_router_detected
= true;
1117 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1120 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1121 errmsg
, errmsg_len
);
1126 if (gr_router_detected
1127 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1128 bgp_zebra_send_capabilities(bgp
, false);
1129 } else if (!gr_router_detected
1130 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1131 bgp_zebra_send_capabilities(bgp
, true);
1135 snprintf(errmsg
, errmsg_len
,
1136 "%%BGP: No %s peer is configured with AS %s",
1137 get_afi_safi_str(afi
, safi
, false), arg
);
1145 static int bgp_clear_vty(const char *name
, afi_t afi
, safi_t safi
,
1146 enum clear_sort sort
, enum bgp_clear_type stype
,
1147 const char *arg
, char *errmsg
, size_t errmsg_len
)
1151 /* BGP structure lookup. */
1153 bgp
= bgp_lookup_by_name(name
);
1155 snprintf(errmsg
, errmsg_len
,
1156 "Can't find BGP instance %s", name
);
1160 bgp
= bgp_get_default();
1162 snprintf(errmsg
, errmsg_len
,
1163 "No BGP process is configured");
1168 return bgp_clear(bgp
, afi
, safi
, sort
, stype
, arg
, errmsg
, errmsg_len
);
1171 /* clear soft inbound */
1172 int bgp_clear_star_soft_in(const char *name
, char *errmsg
, size_t errmsg_len
)
1178 FOREACH_AFI_SAFI (afi
, safi
) {
1179 ret
= bgp_clear_vty(name
, afi
, safi
, clear_all
,
1180 BGP_CLEAR_SOFT_IN
, NULL
, errmsg
,
1182 if (ret
!= CMD_SUCCESS
)
1189 /* clear soft outbound */
1190 int bgp_clear_star_soft_out(const char *name
, char *errmsg
, size_t errmsg_len
)
1196 FOREACH_AFI_SAFI (afi
, safi
) {
1197 ret
= bgp_clear_vty(name
, afi
, safi
, clear_all
,
1198 BGP_CLEAR_SOFT_OUT
, NULL
, errmsg
,
1200 if (ret
!= CMD_SUCCESS
)
1208 #ifndef VTYSH_EXTRACT_PL
1209 #include "bgpd/bgp_vty_clippy.c"
1212 DEFUN_HIDDEN (bgp_local_mac
,
1214 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1216 "Local MAC config\n"
1217 "VxLAN Network Identifier\n"
1221 "mac-mobility sequence\n"
1231 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1232 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1233 vty_out(vty
, "%% Malformed MAC address\n");
1236 memset(&ip
, 0, sizeof(ip
));
1237 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1239 bgp
= bgp_get_default();
1241 vty_out(vty
, "Default BGP instance is not there\n");
1245 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1248 vty_out(vty
, "Internal error\n");
1255 DEFUN_HIDDEN (no_bgp_local_mac
,
1256 no_bgp_local_mac_cmd
,
1257 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1260 "Local MAC config\n"
1261 "VxLAN Network Identifier\n"
1272 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1273 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1274 vty_out(vty
, "%% Malformed MAC address\n");
1277 memset(&ip
, 0, sizeof(ip
));
1279 bgp
= bgp_get_default();
1281 vty_out(vty
, "Default BGP instance is not there\n");
1285 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1287 vty_out(vty
, "Internal error\n");
1294 DEFUN (no_synchronization
,
1295 no_synchronization_cmd
,
1296 "no synchronization",
1298 "Perform IGP synchronization\n")
1303 DEFUN (no_auto_summary
,
1304 no_auto_summary_cmd
,
1307 "Enable automatic network number summarization\n")
1312 /* "router bgp" commands. */
1313 DEFUN_YANG_NOSH(router_bgp
,
1315 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1316 ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR
)
1319 int idx_view_vrf
= 3;
1321 int ret
= CMD_SUCCESS
;
1324 const char *name
= NULL
;
1325 char as_str
[12] = {'\0'};
1326 enum bgp_instance_type inst_type
;
1327 char base_xpath
[XPATH_MAXLEN
];
1329 // "router bgp" without an ASN
1331 // Pending: Make VRF option available for ASN less config
1332 bgp
= bgp_get_default();
1335 vty_out(vty
, "%% No BGP process is configured\n");
1336 return CMD_WARNING_CONFIG_FAILED
;
1339 if (listcount(bm
->bgp
) > 1) {
1340 vty_out(vty
, "%% Please specify ASN and VRF\n");
1341 return CMD_WARNING_CONFIG_FAILED
;
1344 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1345 "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME
);
1347 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
1348 snprintf(as_str
, 12, "%d", bgp
->as
);
1349 nb_cli_enqueue_change(vty
, "./global/local-as", NB_OP_MODIFY
,
1351 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
) {
1352 nb_cli_enqueue_change(vty
,
1353 "./global/instance-type-view",
1354 NB_OP_MODIFY
, "true");
1357 nb_cli_pending_commit_check(vty
);
1358 ret
= nb_cli_apply_changes(vty
, base_xpath
);
1359 if (ret
== CMD_SUCCESS
) {
1360 VTY_PUSH_XPATH(BGP_NODE
, base_xpath
);
1363 * For backward compatibility with old commands we still
1364 * need to use the qobj infrastructure.
1366 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1374 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1375 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1377 name
= argv
[idx_vrf
]->arg
;
1379 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1380 if (strmatch(name
, VRF_DEFAULT_NAME
))
1383 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1384 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view")) {
1385 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1388 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1389 "frr-bgp:bgp", "bgp", name
? name
: VRF_DEFAULT_NAME
);
1391 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
1392 nb_cli_enqueue_change(vty
, "./global/local-as", NB_OP_MODIFY
,
1393 argv
[idx_asn
]->arg
);
1394 if (inst_type
== BGP_INSTANCE_TYPE_VIEW
) {
1395 nb_cli_enqueue_change(vty
,
1396 "./global/instance-type-view",
1397 NB_OP_MODIFY
, "true");
1400 nb_cli_pending_commit_check(vty
);
1401 ret
= nb_cli_apply_changes(vty
, base_xpath
);
1402 if (ret
== CMD_SUCCESS
) {
1403 VTY_PUSH_XPATH(BGP_NODE
, base_xpath
);
1406 * For backward compatibility with old commands we still
1407 * need to use the qobj infrastructure.
1409 bgp
= bgp_lookup(as
, name
);
1411 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1418 /* "no router bgp" commands. */
1419 DEFUN_YANG(no_router_bgp
,
1421 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1422 NO_STR ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR
)
1428 const char *name
= NULL
;
1429 char base_xpath
[XPATH_MAXLEN
];
1430 const struct lyd_node
*bgp_glb_dnode
;
1432 // "no router bgp" without an ASN
1434 // Pending: Make VRF option available for ASN less config
1435 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1436 "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME
);
1438 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
1440 if (!bgp_glb_dnode
) {
1441 vty_out(vty
, "%% No BGP process is configured\n");
1442 return CMD_WARNING_CONFIG_FAILED
;
1445 if (listcount(bm
->bgp
) > 1) {
1446 vty_out(vty
, "%% Please specify ASN and VRF\n");
1447 return CMD_WARNING_CONFIG_FAILED
;
1450 /* tcli mode bgp would not be set until apply stage. */
1451 bgp
= nb_running_get_entry(bgp_glb_dnode
, NULL
, false);
1456 vty_out(vty
, "%% Please unconfigure l3vni %u",
1458 return CMD_WARNING_CONFIG_FAILED
;
1461 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1464 name
= argv
[idx_vrf
]->arg
;
1466 /* Lookup bgp structure. */
1467 bgp
= bgp_lookup(as
, name
);
1469 vty_out(vty
, "%% Can't find BGP instance\n");
1470 return CMD_WARNING_CONFIG_FAILED
;
1474 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1476 return CMD_WARNING_CONFIG_FAILED
;
1479 /* Cannot delete default instance if vrf instances exist */
1480 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1481 struct listnode
*node
;
1482 struct bgp
*tmp_bgp
;
1484 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1485 if (tmp_bgp
->inst_type
1486 == BGP_INSTANCE_TYPE_VRF
) {
1488 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1489 return CMD_WARNING_CONFIG_FAILED
;
1494 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1495 "frr-bgp:bgp", "bgp",
1496 bgp
->name
? bgp
->name
: VRF_DEFAULT_NAME
);
1498 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
1500 return nb_cli_apply_changes(vty
, base_xpath
);
1503 void cli_show_router_bgp(struct vty
*vty
, struct lyd_node
*dnode
,
1506 const struct lyd_node
*vrf_dnode
;
1507 const char *vrf_name
;
1510 vrf_dnode
= yang_dnode_get_parent(dnode
, "control-plane-protocol");
1511 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
1512 as
= yang_dnode_get_uint32(dnode
, "./global/local-as");
1514 vty_out(vty
, "!\n");
1515 vty_out(vty
, "router bgp %u", as
);
1516 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
))
1517 vty_out(vty
, " vrf %s", vrf_name
);
1521 /* BGP router-id. */
1523 DEFPY_YANG(bgp_router_id
, bgp_router_id_cmd
, "bgp router-id A.B.C.D",
1525 "Override configured router identifier\n"
1526 "Manually configured router identifier\n")
1528 nb_cli_enqueue_change(vty
, "./global/router-id", NB_OP_MODIFY
,
1531 return nb_cli_apply_changes(vty
, NULL
);
1534 DEFPY_YANG(no_bgp_router_id
, no_bgp_router_id_cmd
, "no bgp router-id [A.B.C.D]",
1536 "Override configured router identifier\n"
1537 "Manually configured router identifier\n")
1539 nb_cli_enqueue_change(vty
, "./global/router-id", NB_OP_DESTROY
,
1540 router_id_str
? router_id_str
: NULL
);
1542 return nb_cli_apply_changes(vty
, NULL
);
1545 void cli_show_router_bgp_router_id(struct vty
*vty
, struct lyd_node
*dnode
,
1548 vty_out(vty
, " bgp router-id %s\n", yang_dnode_get_string(dnode
, NULL
));
1551 DEFPY (bgp_global_suppress_fib_pending
,
1552 bgp_global_suppress_fib_pending_cmd
,
1553 "[no] bgp suppress-fib-pending",
1556 "Advertise only routes that are programmed in kernel to peers globally\n")
1558 bm_wait_for_fib_set(!no
);
1563 DEFPY (bgp_suppress_fib_pending
,
1564 bgp_suppress_fib_pending_cmd
,
1565 "[no] bgp suppress-fib-pending",
1568 "Advertise only routes that are programmed in kernel to peers\n")
1570 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1572 bgp_suppress_fib_pending_set(bgp
, !no
);
1577 /* BGP Cluster ID. */
1578 DEFUN_YANG(bgp_cluster_id
,
1580 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1582 "Configure Route-Reflector Cluster-id\n"
1583 "Route-Reflector Cluster-id in IP address format\n"
1584 "Route-Reflector Cluster-id as 32 bit quantity\n")
1588 nb_cli_enqueue_change(
1589 vty
, "./global/route-reflector/route-reflector-cluster-id",
1590 NB_OP_MODIFY
, argv
[idx_ipv4
]->arg
);
1592 return nb_cli_apply_changes(vty
, NULL
);
1595 DEFUN_YANG(no_bgp_cluster_id
,
1596 no_bgp_cluster_id_cmd
,
1597 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1599 "Configure Route-Reflector Cluster-id\n"
1600 "Route-Reflector Cluster-id in IP address format\n"
1601 "Route-Reflector Cluster-id as 32 bit quantity\n")
1603 nb_cli_enqueue_change(
1604 vty
, "./global/route-reflector/route-reflector-cluster-id",
1605 NB_OP_DESTROY
, NULL
);
1607 return nb_cli_apply_changes(vty
, NULL
);
1614 "Disable BGP route installation to RIB (Zebra)\n")
1616 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1618 "%% No-RIB option is already set, nothing to do here.\n");
1622 bgp_option_norib_set_runtime();
1627 DEFPY (no_bgp_norib
,
1632 "Disable BGP route installation to RIB (Zebra)\n")
1634 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1636 "%% No-RIB option is not set, nothing to do here.\n");
1640 bgp_option_norib_unset_runtime();
1645 DEFPY (no_bgp_send_extra_data
,
1646 no_bgp_send_extra_data_cmd
,
1647 "[no] bgp send-extra-data zebra",
1650 "Extra data to Zebra for display/use\n"
1654 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1656 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1661 DEFUN_YANG(bgp_confederation_identifier
,
1662 bgp_confederation_identifier_cmd
,
1663 "bgp confederation identifier (1-4294967295)",
1664 "BGP specific commands\n"
1665 "AS confederation parameters\n"
1667 "Set routing domain confederation AS\n")
1671 nb_cli_enqueue_change(vty
, "./global/confederation/identifier",
1672 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
1674 return nb_cli_apply_changes(vty
, NULL
);
1677 DEFUN_YANG(no_bgp_confederation_identifier
,
1678 no_bgp_confederation_identifier_cmd
,
1679 "no bgp confederation identifier [(1-4294967295)]",
1681 "BGP specific commands\n"
1682 "AS confederation parameters\n"
1684 "Set routing domain confederation AS\n")
1686 nb_cli_enqueue_change(vty
, "./global/confederation/identifier",
1687 NB_OP_DESTROY
, NULL
);
1689 return nb_cli_apply_changes(vty
, NULL
);
1692 void cli_show_router_bgp_confederation_identifier(struct vty
*vty
,
1693 struct lyd_node
*dnode
,
1696 vty_out(vty
, " bgp confederation identifier %u\n",
1697 yang_dnode_get_uint32(dnode
, NULL
));
1700 DEFUN_YANG(bgp_confederation_peers
,
1701 bgp_confederation_peers_cmd
,
1702 "bgp confederation peers (1-4294967295)...",
1703 "BGP specific commands\n"
1704 "AS confederation parameters\n"
1705 "Peer ASs in BGP confederation\n" AS_STR
)
1710 for (i
= idx_asn
; i
< argc
; i
++)
1711 nb_cli_enqueue_change(vty
, "./global/confederation/member-as",
1712 NB_OP_CREATE
, argv
[i
]->arg
);
1714 return nb_cli_apply_changes(vty
, NULL
);
1717 DEFUN_YANG(no_bgp_confederation_peers
,
1718 no_bgp_confederation_peers_cmd
,
1719 "no bgp confederation peers (1-4294967295)...",
1721 "BGP specific commands\n"
1722 "AS confederation parameters\n"
1723 "Peer ASs in BGP confederation\n" AS_STR
)
1728 for (i
= idx_asn
; i
< argc
; i
++)
1729 nb_cli_enqueue_change(vty
, "./global/confederation/member-as",
1730 NB_OP_DESTROY
, argv
[i
]->arg
);
1732 return nb_cli_apply_changes(vty
, NULL
);
1735 void cli_show_router_bgp_confederation_member_as(struct vty
*vty
,
1736 struct lyd_node
*dnode
,
1739 vty_out(vty
, " bgp confederation peers %u \n",
1740 yang_dnode_get_uint32(dnode
, NULL
));
1744 * Central routine for maximum-paths configuration.
1745 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1746 * @set: 1 for setting values, 0 for removing the max-paths config.
1748 int bgp_maxpaths_config_vty(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1749 int peer_type
, uint16_t maxpaths
, uint16_t options
,
1750 int set
, char *errmsg
, size_t errmsg_len
)
1755 if (maxpaths
> multipath_num
) {
1758 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1759 maxpaths
, multipath_num
);
1760 return CMD_WARNING_CONFIG_FAILED
;
1762 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1765 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1770 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1771 (set
== 1) ? "" : "un",
1772 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1773 maxpaths
, afi
, safi
);
1774 return CMD_WARNING_CONFIG_FAILED
;
1777 bgp_recalculate_all_bestpaths(bgp
);
1782 void cli_show_router_bgp_med_config(struct vty
*vty
, struct lyd_node
*dnode
,
1785 if (yang_dnode_get_bool(dnode
, "./enable-med-admin")) {
1786 uint32_t med_admin_val
;
1788 vty_out(vty
, " bgp max-med administrative");
1789 if ((med_admin_val
=
1790 yang_dnode_get_uint32(dnode
, "./max-med-admin"))
1791 != BGP_MAXMED_VALUE_DEFAULT
)
1792 vty_out(vty
, " %u", med_admin_val
);
1796 if (yang_dnode_exists(dnode
, "./max-med-onstart-up-time")) {
1797 uint32_t onstartup_val
;
1799 vty_out(vty
, " bgp max-med on-startup %u",
1800 yang_dnode_get_uint32(dnode
,
1801 "./max-med-onstart-up-time"));
1802 onstartup_val
= yang_dnode_get_uint32(
1803 dnode
, "./max-med-onstart-up-value");
1804 if (onstartup_val
!= BGP_MAXMED_VALUE_DEFAULT
)
1805 vty_out(vty
, " %u", onstartup_val
);
1811 DEFUN_YANG(bgp_maxmed_admin
,
1812 bgp_maxmed_admin_cmd
,
1813 "bgp max-med administrative ",
1815 "Advertise routes with max-med\n"
1816 "Administratively applied, for an indefinite period\n")
1818 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1819 NB_OP_MODIFY
, "true");
1821 return nb_cli_apply_changes(vty
, NULL
);
1824 DEFUN_YANG(bgp_maxmed_admin_medv
,
1825 bgp_maxmed_admin_medv_cmd
,
1826 "bgp max-med administrative (0-4294967295)",
1828 "Advertise routes with max-med\n"
1829 "Administratively applied, for an indefinite period\n"
1830 "Max MED value to be used\n")
1834 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1835 NB_OP_MODIFY
, "true");
1837 nb_cli_enqueue_change(vty
, "./global/med-config/max-med-admin",
1838 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
1840 return nb_cli_apply_changes(vty
, NULL
);
1843 DEFUN_YANG(no_bgp_maxmed_admin
,
1844 no_bgp_maxmed_admin_cmd
,
1845 "no bgp max-med administrative [(0-4294967295)]",
1847 "Advertise routes with max-med\n"
1848 "Administratively applied, for an indefinite period\n"
1849 "Max MED value to be used\n")
1851 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1852 NB_OP_MODIFY
, "false");
1854 nb_cli_enqueue_change(vty
, "./global/med-config/max-med-admin",
1855 NB_OP_MODIFY
, NULL
);
1857 return nb_cli_apply_changes(vty
, NULL
);
1860 DEFUN_YANG (bgp_maxmed_onstartup
,
1861 bgp_maxmed_onstartup_cmd
,
1862 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1864 "Advertise routes with max-med\n"
1865 "Effective on a startup\n"
1866 "Time (seconds) period for max-med\n"
1867 "Max MED value to be used\n")
1871 argv_find(argv
, argc
, "(5-86400)", &idx
);
1872 nb_cli_enqueue_change(vty
,
1873 "./global/med-config/max-med-onstart-up-time",
1874 NB_OP_MODIFY
, argv
[idx
]->arg
);
1876 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1877 nb_cli_enqueue_change(
1878 vty
, "./global/med-config/max-med-onstart-up-value",
1879 NB_OP_MODIFY
, argv
[idx
]->arg
);
1881 nb_cli_enqueue_change(
1882 vty
, "./global/med-config/max-med-onstart-up-value",
1883 NB_OP_MODIFY
, NULL
);
1885 return nb_cli_apply_changes(vty
, NULL
);
1888 DEFUN_YANG (no_bgp_maxmed_onstartup
,
1889 no_bgp_maxmed_onstartup_cmd
,
1890 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1892 "Advertise routes with max-med\n"
1893 "Effective on a startup\n"
1894 "Time (seconds) period for max-med\n"
1895 "Max MED value to be used\n")
1897 nb_cli_enqueue_change(vty
,
1898 "./global/med-config/max-med-onstart-up-time",
1899 NB_OP_DESTROY
, NULL
);
1901 nb_cli_enqueue_change(vty
,
1902 "./global/med-config/max-med-onstart-up-value",
1903 NB_OP_MODIFY
, NULL
);
1905 return nb_cli_apply_changes(vty
, NULL
);
1908 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
1909 uint16_t update_delay
,
1910 uint16_t establish_wait
)
1912 struct listnode
*node
, *nnode
;
1914 bool vrf_cfg
= false;
1917 * See if update-delay is set per-vrf and warn user to delete it
1918 * Note that we only need to check this if this is the first time
1919 * setting the global config.
1921 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
1922 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1923 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1925 "%% update-delay configuration found in vrf %s\n",
1926 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
1936 "%%Failed: global update-delay config not permitted\n");
1940 if (!establish_wait
) { /* update-delay <delay> */
1941 bm
->v_update_delay
= update_delay
;
1942 bm
->v_establish_wait
= bm
->v_update_delay
;
1944 /* update-delay <delay> <establish-wait> */
1945 if (update_delay
< establish_wait
) {
1947 "%%Failed: update-delay less than the establish-wait!\n");
1948 return CMD_WARNING_CONFIG_FAILED
;
1951 bm
->v_update_delay
= update_delay
;
1952 bm
->v_establish_wait
= establish_wait
;
1955 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1956 bgp
->v_update_delay
= bm
->v_update_delay
;
1957 bgp
->v_establish_wait
= bm
->v_establish_wait
;
1963 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
1965 struct listnode
*node
, *nnode
;
1968 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1969 bm
->v_establish_wait
= bm
->v_update_delay
;
1971 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1972 bgp
->v_update_delay
= bm
->v_update_delay
;
1973 bgp
->v_establish_wait
= bm
->v_establish_wait
;
1979 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
1980 uint16_t establish_wait
)
1982 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1984 /* if configured globally, per-instance config is not allowed */
1985 if (bm
->v_update_delay
) {
1987 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
1988 return CMD_WARNING_CONFIG_FAILED
;
1992 if (!establish_wait
) /* update-delay <delay> */
1994 bgp
->v_update_delay
= update_delay
;
1995 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1999 /* update-delay <delay> <establish-wait> */
2000 if (update_delay
< establish_wait
) {
2002 "%%Failed: update-delay less than the establish-wait!\n");
2003 return CMD_WARNING_CONFIG_FAILED
;
2006 bgp
->v_update_delay
= update_delay
;
2007 bgp
->v_establish_wait
= establish_wait
;
2012 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2014 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2016 /* If configured globally, cannot remove from one bgp instance */
2017 if (bm
->v_update_delay
) {
2019 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2020 return CMD_WARNING_CONFIG_FAILED
;
2022 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2023 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2028 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2030 /* If configured globally, no need to display per-instance value */
2031 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2032 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2033 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2034 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2039 /* Global update-delay configuration */
2040 DEFPY (bgp_global_update_delay
,
2041 bgp_global_update_delay_cmd
,
2042 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2044 "Force initial delay for best-path and updates for all bgp instances\n"
2045 "Max delay in seconds\n"
2046 "Establish wait in seconds\n")
2048 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2051 /* Global update-delay deconfiguration */
2052 DEFPY (no_bgp_global_update_delay
,
2053 no_bgp_global_update_delay_cmd
,
2054 "no bgp update-delay [(0-3600) [(1-3600)]]",
2057 "Force initial delay for best-path and updates\n"
2058 "Max delay in seconds\n"
2059 "Establish wait in seconds\n")
2061 return bgp_global_update_delay_deconfig_vty(vty
);
2064 /* Update-delay configuration */
2066 DEFPY (bgp_update_delay
,
2067 bgp_update_delay_cmd
,
2068 "update-delay (0-3600)$delay [(1-3600)$wait]",
2069 "Force initial delay for best-path and updates\n"
2070 "Max delay in seconds\n"
2071 "Establish wait in seconds\n")
2073 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2076 /* Update-delay deconfiguration */
2077 DEFPY (no_bgp_update_delay
,
2078 no_bgp_update_delay_cmd
,
2079 "no update-delay [(0-3600) [(1-3600)]]",
2081 "Force initial delay for best-path and updates\n"
2082 "Max delay in seconds\n"
2083 "Establish wait in seconds\n")
2085 return bgp_update_delay_deconfig_vty(vty
);
2089 int bgp_wpkt_quanta_config_vty(struct bgp
*bgp
, uint32_t quanta
, bool set
)
2091 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2092 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2097 int bgp_rpkt_quanta_config_vty(struct bgp
*bgp
, uint32_t quanta
, bool set
)
2099 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2100 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2105 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2108 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2109 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2110 vty_out(vty
, " write-quanta %d\n", quanta
);
2113 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2116 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2117 if (quanta
!= BGP_READ_PACKET_MAX
)
2118 vty_out(vty
, " read-quanta %d\n", quanta
);
2121 /* Packet quanta configuration
2123 * XXX: The value set here controls the size of a stack buffer in the IO
2124 * thread. When changing these limits be careful to prevent stack overflow.
2126 * Furthermore, the maximums used here should correspond to
2127 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2129 DEFPY_YANG (bgp_wpkt_quanta
,
2130 bgp_wpkt_quanta_cmd
,
2131 "[no] write-quanta (1-64)$quanta",
2133 "How many packets to write to peer socket per run\n"
2134 "Number of packets\n")
2137 nb_cli_enqueue_change(
2139 "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta",
2140 NB_OP_MODIFY
, quanta_str
);
2142 nb_cli_enqueue_change(
2144 "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta",
2145 NB_OP_MODIFY
, NULL
);
2147 return nb_cli_apply_changes(vty
, NULL
);
2150 DEFPY_YANG (bgp_rpkt_quanta
,
2151 bgp_rpkt_quanta_cmd
,
2152 "[no] read-quanta (1-10)$quanta",
2154 "How many packets to read from peer socket per I/O cycle\n"
2155 "Number of packets\n")
2158 nb_cli_enqueue_change(
2160 "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta",
2161 NB_OP_MODIFY
, quanta_str
);
2163 nb_cli_enqueue_change(
2165 "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta",
2166 NB_OP_MODIFY
, NULL
);
2168 return nb_cli_apply_changes(vty
, NULL
);
2171 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2173 if (!bgp
->heuristic_coalesce
)
2174 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2177 void cli_show_router_global_update_group_config_coalesce_time(
2178 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2180 vty_out(vty
, " coalesce-time %u\n", yang_dnode_get_uint32(dnode
, NULL
));
2184 DEFUN_YANG (bgp_coalesce_time
,
2185 bgp_coalesce_time_cmd
,
2186 "coalesce-time (0-4294967295)",
2187 "Subgroup coalesce timer\n"
2188 "Subgroup coalesce timer value (in ms)\n")
2192 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
2193 nb_cli_enqueue_change(
2194 vty
, "./global/global-update-group-config/coalesce-time",
2195 NB_OP_MODIFY
, argv
[idx
]->arg
);
2197 return nb_cli_apply_changes(vty
, NULL
);
2200 DEFUN_YANG(no_bgp_coalesce_time
,
2201 no_bgp_coalesce_time_cmd
,
2202 "no coalesce-time (0-4294967295)",
2204 "Subgroup coalesce timer\n"
2205 "Subgroup coalesce timer value (in ms)\n")
2207 nb_cli_enqueue_change(
2208 vty
, "./global/global-update-group-config/coalesce-time",
2209 NB_OP_MODIFY
, NULL
);
2211 return nb_cli_apply_changes(vty
, NULL
);
2214 /* Maximum-paths configuration */
2215 DEFUN_YANG (bgp_maxpaths
,
2217 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2218 "Forward packets over multiple paths\n"
2219 "Number of paths\n")
2222 char base_xpath
[XPATH_MAXLEN
];
2226 afi
= bgp_node_afi(vty
);
2227 safi
= bgp_node_safi(vty
);
2230 base_xpath
, sizeof(base_xpath
),
2231 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ebgp/maximum-paths",
2232 yang_afi_safi_value2identity(afi
, safi
),
2233 bgp_afi_safi_get_container_str(afi
, safi
));
2235 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2236 argv
[idx_number
]->arg
);
2238 return nb_cli_apply_changes(vty
, NULL
);
2241 void cli_show_bgp_global_afi_safi_unicast_use_multiple_paths_ebgp_maximum_paths(
2242 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2244 vty_out(vty
, " maximum-paths %d\n",
2245 yang_dnode_get_uint16(dnode
, NULL
));
2248 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2249 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2250 "Forward packets over multiple paths\n"
2251 "Number of paths\n")
2253 DEFUN_YANG (bgp_maxpaths_ibgp
,
2254 bgp_maxpaths_ibgp_cmd
,
2255 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2256 "Forward packets over multiple paths\n"
2258 "Number of paths\n")
2261 char base_xpath
[XPATH_MAXLEN
];
2265 afi
= bgp_node_afi(vty
);
2266 safi
= bgp_node_safi(vty
);
2269 base_xpath
, sizeof(base_xpath
),
2270 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2271 yang_afi_safi_value2identity(afi
, safi
),
2272 bgp_afi_safi_get_container_str(afi
, safi
));
2274 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2275 argv
[idx_number
]->arg
);
2277 return nb_cli_apply_changes(vty
, NULL
);
2280 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2281 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2282 "Forward packets over multiple paths\n"
2284 "Number of paths\n")
2286 DEFUN_YANG (bgp_maxpaths_ibgp_cluster
,
2287 bgp_maxpaths_ibgp_cluster_cmd
,
2288 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2289 "Forward packets over multiple paths\n"
2292 "Match the cluster length\n")
2295 char base_xpath
[XPATH_MAXLEN
];
2299 afi
= bgp_node_afi(vty
);
2300 safi
= bgp_node_safi(vty
);
2303 base_xpath
, sizeof(base_xpath
),
2304 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2305 yang_afi_safi_value2identity(afi
, safi
),
2306 bgp_afi_safi_get_container_str(afi
, safi
));
2308 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2309 argv
[idx_number
]->arg
);
2312 base_xpath
, sizeof(base_xpath
),
2313 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/cluster-length-list",
2314 yang_afi_safi_value2identity(afi
, safi
),
2315 bgp_afi_safi_get_container_str(afi
, safi
));
2317 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, "true");
2319 return nb_cli_apply_changes(vty
, NULL
);
2322 void cli_show_bgp_global_afi_safi_ip_unicast_use_multiple_paths_ibgp_maximum_paths(
2323 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2325 vty_out(vty
, " maximum-paths ibgp %d",
2326 yang_dnode_get_uint16(dnode
, "./maximum-paths"));
2327 if (yang_dnode_get_bool(dnode
, "./cluster-length-list"))
2328 vty_out(vty
, " equal-cluster-length");
2332 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2333 "maximum-paths ibgp " CMD_RANGE_STR(
2334 1, MULTIPATH_NUM
) " equal-cluster-length",
2335 "Forward packets over multiple paths\n"
2338 "Match the cluster length\n")
2340 DEFUN_YANG (no_bgp_maxpaths
,
2341 no_bgp_maxpaths_cmd
,
2342 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2344 "Forward packets over multiple paths\n"
2345 "Number of paths\n")
2347 char base_xpath
[XPATH_MAXLEN
];
2351 afi
= bgp_node_afi(vty
);
2352 safi
= bgp_node_safi(vty
);
2355 base_xpath
, sizeof(base_xpath
),
2356 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ebgp/maximum-paths",
2357 yang_afi_safi_value2identity(afi
, safi
),
2358 bgp_afi_safi_get_container_str(afi
, safi
));
2360 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, NULL
);
2362 return nb_cli_apply_changes(vty
, NULL
);
2365 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2366 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2367 "Forward packets over multiple paths\n"
2368 "Number of paths\n")
2370 DEFUN_YANG (no_bgp_maxpaths_ibgp
,
2371 no_bgp_maxpaths_ibgp_cmd
,
2372 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2374 "Forward packets over multiple paths\n"
2377 "Match the cluster length\n")
2379 char base_xpath
[XPATH_MAXLEN
];
2383 afi
= bgp_node_afi(vty
);
2384 safi
= bgp_node_safi(vty
);
2387 base_xpath
, sizeof(base_xpath
),
2388 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2389 yang_afi_safi_value2identity(afi
, safi
),
2390 bgp_afi_safi_get_container_str(afi
, safi
));
2392 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, NULL
);
2395 base_xpath
, sizeof(base_xpath
),
2396 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/cluster-length-list",
2397 yang_afi_safi_value2identity(afi
, safi
),
2398 bgp_afi_safi_get_container_str(afi
, safi
));
2400 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, "false");
2402 return nb_cli_apply_changes(vty
, NULL
);
2405 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2406 "no maximum-paths ibgp [" CMD_RANGE_STR(
2407 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2409 "Forward packets over multiple paths\n"
2412 "Match the cluster length\n")
2414 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2415 afi_t afi
, safi_t safi
)
2417 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2418 vty_out(vty
, " maximum-paths %d\n",
2419 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2422 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2423 vty_out(vty
, " maximum-paths ibgp %d",
2424 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2425 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
2426 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
2427 vty_out(vty
, " equal-cluster-length");
2434 DEFUN_YANG (bgp_timers
,
2436 "timers bgp (0-65535) (0-65535)",
2437 "Adjust routing timers\n"
2439 "Keepalive interval\n"
2443 int idx_number_2
= 3;
2445 nb_cli_enqueue_change(vty
, "./global/global-config-timers/keepalive",
2446 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
2447 nb_cli_enqueue_change(vty
, "./global/global-config-timers/hold-time",
2448 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
2450 return nb_cli_apply_changes(vty
, NULL
);
2453 DEFUN_YANG (no_bgp_timers
,
2455 "no timers bgp [(0-65535) (0-65535)]",
2457 "Adjust routing timers\n"
2459 "Keepalive interval\n"
2462 nb_cli_enqueue_change(vty
, "./global/global-config-timers/keepalive",
2463 NB_OP_DESTROY
, NULL
);
2464 nb_cli_enqueue_change(vty
, "./global/global-config-timers/hold-time",
2465 NB_OP_DESTROY
, NULL
);
2467 return nb_cli_apply_changes(vty
, NULL
);
2470 void cli_show_router_bgp_route_reflector(struct vty
*vty
,
2471 struct lyd_node
*dnode
,
2474 if (yang_dnode_get_bool(dnode
, "./no-client-reflect"))
2475 vty_out(vty
, " no bgp client-to-client reflection\n");
2477 if (yang_dnode_get_bool(dnode
, "./allow-outbound-policy"))
2478 vty_out(vty
, " bgp route-reflector allow-outbound-policy\n");
2480 if (yang_dnode_exists(dnode
, "./route-reflector-cluster-id"))
2481 vty_out(vty
, " bgp cluster-id %s\n",
2482 yang_dnode_get_string(dnode
,
2483 "./route-reflector-cluster-id"));
2486 DEFUN_YANG(bgp_client_to_client_reflection
,
2487 bgp_client_to_client_reflection_cmd
,
2488 "bgp client-to-client reflection",
2489 "BGP specific commands\n"
2490 "Configure client to client route reflection\n"
2491 "reflection of routes allowed\n")
2493 nb_cli_enqueue_change(vty
, "./global/route-reflector/no-client-reflect",
2494 NB_OP_MODIFY
, "false");
2496 return nb_cli_apply_changes(vty
, NULL
);
2499 DEFUN_YANG(no_bgp_client_to_client_reflection
,
2500 no_bgp_client_to_client_reflection_cmd
,
2501 "no bgp client-to-client reflection",
2503 "BGP specific commands\n"
2504 "Configure client to client route reflection\n"
2505 "reflection of routes allowed\n")
2507 nb_cli_enqueue_change(vty
, "./global/route-reflector/no-client-reflect",
2508 NB_OP_MODIFY
, "true");
2510 return nb_cli_apply_changes(vty
, NULL
);
2513 void cli_show_router_bgp_route_selection(struct vty
*vty
,
2514 struct lyd_node
*dnode
,
2518 if (yang_dnode_get_bool(dnode
, "./always-compare-med"))
2519 vty_out(vty
, " bgp always-compare-med\n");
2521 if (yang_dnode_get_bool(dnode
, "./ignore-as-path-length"))
2522 vty_out(vty
, " bgp bestpath as-path ignore\n");
2524 if (yang_dnode_get_bool(dnode
, "./aspath-confed"))
2525 vty_out(vty
, " bgp bestpath as-path confed\n");
2527 if (yang_dnode_get_bool(dnode
, "./external-compare-router-id"))
2528 vty_out(vty
, " bgp bestpath compare-routerid\n");
2530 if (yang_dnode_get_bool(dnode
, "./allow-multiple-as")) {
2531 if (yang_dnode_get_bool(dnode
, "./multi-path-as-set"))
2533 " bgp bestpath as-path multipath-relax as-set\n");
2535 vty_out(vty
, " bgp bestpath as-path multipath-relax\n");
2538 if (yang_dnode_get_bool(dnode
, "./deterministic-med"))
2539 vty_out(vty
, " bgp deterministic-med\n");
2541 if (yang_dnode_get_bool(dnode
, "./confed-med")
2542 || yang_dnode_get_bool(dnode
, "./missing-as-worst-med")) {
2543 vty_out(vty
, " bgp bestpath med");
2544 if (yang_dnode_get_bool(dnode
, "./confed-med"))
2545 vty_out(vty
, " confed");
2546 if (yang_dnode_get_bool(dnode
, "./missing-as-worst-med"))
2547 vty_out(vty
, " missing-as-worst");
2552 /* "bgp always-compare-med" configuration. */
2553 DEFUN_YANG(bgp_always_compare_med
,
2554 bgp_always_compare_med_cmd
,
2555 "bgp always-compare-med",
2556 "BGP specific commands\n"
2557 "Allow comparing MED from different neighbors\n")
2559 nb_cli_enqueue_change(
2560 vty
, "./global/route-selection-options/always-compare-med",
2561 NB_OP_MODIFY
, "true");
2563 return nb_cli_apply_changes(vty
, NULL
);
2566 DEFUN_YANG(no_bgp_always_compare_med
,
2567 no_bgp_always_compare_med_cmd
,
2568 "no bgp always-compare-med",
2570 "BGP specific commands\n"
2571 "Allow comparing MED from different neighbors\n")
2573 nb_cli_enqueue_change(
2574 vty
, "./global/route-selection-options/always-compare-med",
2575 NB_OP_MODIFY
, "false");
2577 return nb_cli_apply_changes(vty
, NULL
);
2580 DEFUN_YANG(bgp_suppress_duplicates
,
2581 bgp_suppress_duplicates_cmd
,
2582 "bgp suppress-duplicates",
2583 "BGP specific commands\n"
2584 "Suppress duplicate updates if the route actually not changed\n")
2586 nb_cli_enqueue_change(vty
, "./global/suppress-duplicates",
2587 NB_OP_MODIFY
, "true");
2588 return nb_cli_apply_changes(vty
, NULL
);
2591 DEFUN_YANG(no_bgp_suppress_duplicates
,
2592 no_bgp_suppress_duplicates_cmd
,
2593 "no bgp suppress-duplicates",
2595 "BGP specific commands\n"
2596 "Suppress duplicate updates if the route actually not changed\n")
2598 nb_cli_enqueue_change(vty
, "./global/suppress-duplicates",
2599 NB_OP_MODIFY
, "false");
2600 return nb_cli_apply_changes(vty
, NULL
);
2603 void cli_show_router_bgp_suppress_duplicates(struct vty
*vty
,
2604 struct lyd_node
*dnode
,
2607 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SUPPRESS_DUPLICATES
)
2608 vty_out(vty
, " bgp suppress-duplicates\n");
2611 DEFUN_YANG(bgp_ebgp_requires_policy
,
2612 bgp_ebgp_requires_policy_cmd
,
2613 "bgp ebgp-requires-policy",
2614 "BGP specific commands\n"
2615 "Require in and out policy for eBGP peers (RFC8212)\n")
2617 nb_cli_enqueue_change(vty
, "./global/ebgp-requires-policy",
2618 NB_OP_MODIFY
, "true");
2619 return nb_cli_apply_changes(vty
, NULL
);
2622 DEFUN_YANG(no_bgp_ebgp_requires_policy
,
2623 no_bgp_ebgp_requires_policy_cmd
,
2624 "no bgp ebgp-requires-policy",
2626 "BGP specific commands\n"
2627 "Require in and out policy for eBGP peers (RFC8212)\n")
2629 nb_cli_enqueue_change(vty
, "./global/ebgp-requires-policy",
2630 NB_OP_MODIFY
, "false");
2631 return nb_cli_apply_changes(vty
, NULL
);
2634 void cli_show_router_bgp_ebgp_requires_policy(struct vty
*vty
,
2635 struct lyd_node
*dnode
,
2638 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_EBGP_REQUIRES_POLICY
)
2639 vty_out(vty
, " bgp ebgp-requires-policy\n");
2642 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2643 "bgp reject-as-sets",
2644 "BGP specific commands\n"
2645 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2647 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2648 struct listnode
*node
, *nnode
;
2651 bgp
->reject_as_sets
= true;
2653 /* Reset existing BGP sessions to reject routes
2654 * with aspath containing AS_SET or AS_CONFED_SET.
2656 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2657 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2658 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2659 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2660 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2667 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2668 "no bgp reject-as-sets",
2670 "BGP specific commands\n"
2671 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2673 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2674 struct listnode
*node
, *nnode
;
2677 bgp
->reject_as_sets
= false;
2679 /* Reset existing BGP sessions to reject routes
2680 * with aspath containing AS_SET or AS_CONFED_SET.
2682 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2683 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2684 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2685 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2686 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2693 /* "bgp deterministic-med" configuration. */
2694 DEFUN_YANG (bgp_deterministic_med
,
2695 bgp_deterministic_med_cmd
,
2696 "bgp deterministic-med",
2697 "BGP specific commands\n"
2698 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2700 nb_cli_enqueue_change(
2701 vty
, "./global/route-selection-options/deterministic-med",
2702 NB_OP_MODIFY
, "true");
2704 return nb_cli_apply_changes(vty
, NULL
);
2707 DEFUN_YANG (no_bgp_deterministic_med
,
2708 no_bgp_deterministic_med_cmd
,
2709 "no bgp deterministic-med",
2711 "BGP specific commands\n"
2712 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2714 nb_cli_enqueue_change(
2715 vty
, "./global/route-selection-options/deterministic-med",
2716 NB_OP_MODIFY
, "false");
2718 return nb_cli_apply_changes(vty
, NULL
);
2721 /* "bgp graceful-restart mode" configuration. */
2722 DEFUN (bgp_graceful_restart
,
2723 bgp_graceful_restart_cmd
,
2724 "bgp graceful-restart",
2725 "BGP specific commands\n"
2729 int ret
= BGP_GR_FAILURE
;
2731 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2732 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2734 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2736 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2738 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2741 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2742 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2744 "Graceful restart configuration changed, reset all peers to take effect\n");
2745 return bgp_vty_return(vty
, ret
);
2748 DEFUN (no_bgp_graceful_restart
,
2749 no_bgp_graceful_restart_cmd
,
2750 "no bgp graceful-restart",
2752 "BGP specific commands\n"
2756 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2758 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2759 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2761 int ret
= BGP_GR_FAILURE
;
2763 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2765 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2768 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2769 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2771 "Graceful restart configuration changed, reset all peers to take effect\n");
2773 return bgp_vty_return(vty
, ret
);
2776 DEFUN (bgp_graceful_restart_stalepath_time
,
2777 bgp_graceful_restart_stalepath_time_cmd
,
2778 "bgp graceful-restart stalepath-time (1-4095)",
2779 "BGP specific commands\n"
2780 "Graceful restart capability parameters\n"
2781 "Set the max time to hold onto restarting peer's stale paths\n"
2782 "Delay value (seconds)\n")
2784 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2788 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2789 bgp
->stalepath_time
= stalepath
;
2793 DEFUN (bgp_graceful_restart_restart_time
,
2794 bgp_graceful_restart_restart_time_cmd
,
2795 "bgp graceful-restart restart-time (1-4095)",
2796 "BGP specific commands\n"
2797 "Graceful restart capability parameters\n"
2798 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2799 "Delay value (seconds)\n")
2801 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2805 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2806 bgp
->restart_time
= restart
;
2810 DEFUN (bgp_graceful_restart_select_defer_time
,
2811 bgp_graceful_restart_select_defer_time_cmd
,
2812 "bgp graceful-restart select-defer-time (0-3600)",
2813 "BGP specific commands\n"
2814 "Graceful restart capability parameters\n"
2815 "Set the time to defer the BGP route selection after restart\n"
2816 "Delay value (seconds, 0 - disable)\n")
2818 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2820 uint32_t defer_time
;
2822 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2823 bgp
->select_defer_time
= defer_time
;
2824 if (defer_time
== 0)
2825 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2827 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2832 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2833 no_bgp_graceful_restart_stalepath_time_cmd
,
2834 "no bgp graceful-restart stalepath-time [(1-4095)]",
2836 "BGP specific commands\n"
2837 "Graceful restart capability parameters\n"
2838 "Set the max time to hold onto restarting peer's stale paths\n"
2839 "Delay value (seconds)\n")
2841 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2843 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2847 DEFUN (no_bgp_graceful_restart_restart_time
,
2848 no_bgp_graceful_restart_restart_time_cmd
,
2849 "no bgp graceful-restart restart-time [(1-4095)]",
2851 "BGP specific commands\n"
2852 "Graceful restart capability parameters\n"
2853 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2854 "Delay value (seconds)\n")
2856 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2858 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2862 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2863 no_bgp_graceful_restart_select_defer_time_cmd
,
2864 "no bgp graceful-restart select-defer-time [(0-3600)]",
2866 "BGP specific commands\n"
2867 "Graceful restart capability parameters\n"
2868 "Set the time to defer the BGP route selection after restart\n"
2869 "Delay value (seconds)\n")
2871 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2873 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2874 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2879 DEFUN (bgp_graceful_restart_preserve_fw
,
2880 bgp_graceful_restart_preserve_fw_cmd
,
2881 "bgp graceful-restart preserve-fw-state",
2882 "BGP specific commands\n"
2883 "Graceful restart capability parameters\n"
2884 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2886 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2887 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2891 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2892 no_bgp_graceful_restart_preserve_fw_cmd
,
2893 "no bgp graceful-restart preserve-fw-state",
2895 "BGP specific commands\n"
2896 "Graceful restart capability parameters\n"
2897 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2899 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2900 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2904 DEFUN (bgp_graceful_restart_disable
,
2905 bgp_graceful_restart_disable_cmd
,
2906 "bgp graceful-restart-disable",
2907 "BGP specific commands\n"
2910 int ret
= BGP_GR_FAILURE
;
2912 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2914 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
2916 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2918 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
2920 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
2923 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2925 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
2927 "Graceful restart configuration changed, reset all peers to take effect\n");
2929 return bgp_vty_return(vty
, ret
);
2932 DEFUN (no_bgp_graceful_restart_disable
,
2933 no_bgp_graceful_restart_disable_cmd
,
2934 "no bgp graceful-restart-disable",
2936 "BGP specific commands\n"
2940 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2942 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2944 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
2946 int ret
= BGP_GR_FAILURE
;
2948 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
2950 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2953 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2955 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
2957 "Graceful restart configuration changed, reset all peers to take effect\n");
2959 return bgp_vty_return(vty
, ret
);
2962 DEFUN (bgp_neighbor_graceful_restart_set
,
2963 bgp_neighbor_graceful_restart_set_cmd
,
2964 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
2972 int ret
= BGP_GR_FAILURE
;
2974 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2976 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2978 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
2980 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2982 return CMD_WARNING_CONFIG_FAILED
;
2984 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
2986 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2987 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2989 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2991 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
2993 "Graceful restart configuration changed, reset this peer to take effect\n");
2995 return bgp_vty_return(vty
, ret
);
2998 DEFUN (no_bgp_neighbor_graceful_restart
,
2999 no_bgp_neighbor_graceful_restart_set_cmd
,
3000 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3008 int ret
= BGP_GR_FAILURE
;
3011 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3013 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3015 return CMD_WARNING_CONFIG_FAILED
;
3017 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3019 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3021 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
3023 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3024 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3026 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3028 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3030 "Graceful restart configuration changed, reset this peer to take effect\n");
3032 return bgp_vty_return(vty
, ret
);
3035 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3036 bgp_neighbor_graceful_restart_helper_set_cmd
,
3037 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3040 GR_NEIGHBOR_HELPER_CMD
3045 int ret
= BGP_GR_FAILURE
;
3047 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3049 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3051 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3053 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3056 return CMD_WARNING_CONFIG_FAILED
;
3059 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3061 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3062 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3064 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3066 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3068 "Graceful restart configuration changed, reset this peer to take effect\n");
3070 return bgp_vty_return(vty
, ret
);
3073 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3074 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3075 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3079 NO_GR_NEIGHBOR_HELPER_CMD
3083 int ret
= BGP_GR_FAILURE
;
3086 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3088 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3090 return CMD_WARNING_CONFIG_FAILED
;
3092 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3094 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3096 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3098 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3099 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3101 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3103 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3105 "Graceful restart configuration changed, reset this peer to take effect\n");
3107 return bgp_vty_return(vty
, ret
);
3110 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3111 bgp_neighbor_graceful_restart_disable_set_cmd
,
3112 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3115 GR_NEIGHBOR_DISABLE_CMD
3120 int ret
= BGP_GR_FAILURE
;
3122 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3124 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3126 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3128 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3130 return CMD_WARNING_CONFIG_FAILED
;
3132 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3134 if (peer
->bgp
->t_startup
)
3135 bgp_peer_gr_flags_update(peer
);
3137 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3138 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3140 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3142 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3144 "Graceful restart configuration changed, reset this peer to take effect\n");
3146 return bgp_vty_return(vty
, ret
);
3149 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3150 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3151 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3155 NO_GR_NEIGHBOR_DISABLE_CMD
3159 int ret
= BGP_GR_FAILURE
;
3162 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3164 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3166 return CMD_WARNING_CONFIG_FAILED
;
3168 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3170 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3172 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3174 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3175 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3177 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3179 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3181 "Graceful restart configuration changed, reset this peer to take effect\n");
3183 return bgp_vty_return(vty
, ret
);
3186 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3187 bgp_graceful_restart_disable_eor_cmd
,
3188 "bgp graceful-restart disable-eor",
3189 "BGP specific commands\n"
3190 "Graceful restart configuration parameters\n"
3191 "Disable EOR Check\n")
3193 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3194 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3199 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3200 no_bgp_graceful_restart_disable_eor_cmd
,
3201 "no bgp graceful-restart disable-eor",
3203 "BGP specific commands\n"
3204 "Graceful restart configuration parameters\n"
3205 "Disable EOR Check\n")
3207 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3208 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3213 DEFUN (bgp_graceful_restart_rib_stale_time
,
3214 bgp_graceful_restart_rib_stale_time_cmd
,
3215 "bgp graceful-restart rib-stale-time (1-3600)",
3216 "BGP specific commands\n"
3217 "Graceful restart configuration parameters\n"
3218 "Specify the stale route removal timer in rib\n"
3219 "Delay value (seconds)\n")
3221 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3223 uint32_t stale_time
;
3225 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3226 bgp
->rib_stale_time
= stale_time
;
3227 /* Send the stale timer update message to RIB */
3228 if (bgp_zebra_stale_timer_update(bgp
))
3234 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3235 no_bgp_graceful_restart_rib_stale_time_cmd
,
3236 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3238 "BGP specific commands\n"
3239 "Graceful restart configuration parameters\n"
3240 "Specify the stale route removal timer in rib\n"
3241 "Delay value (seconds)\n")
3243 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3245 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3246 /* Send the stale timer update message to RIB */
3247 if (bgp_zebra_stale_timer_update(bgp
))
3253 static inline int bgp_initiate_graceful_shut_unshut(struct bgp
*bgp
,
3257 bgp_static_redo_import_check(bgp
);
3258 bgp_redistribute_redo(bgp
);
3259 if (bgp_clear_star_soft_out(bgp
->name
, errmsg
, errmsg_len
) < 0)
3261 if (bgp_clear_star_soft_in(bgp
->name
, errmsg
, errmsg_len
) < 0)
3267 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3269 struct listnode
*node
, *nnode
;
3271 bool vrf_cfg
= false;
3272 char errmsg
[BUFSIZ
] = {'\0'};
3274 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3277 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3278 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3279 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3281 "%% graceful-shutdown configuration found in vrf %s\n",
3282 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3283 VRF_DEFAULT_NAME
: bgp
->name
);
3290 "%%Failed: global graceful-shutdown not permitted\n");
3294 /* Set flag globally */
3295 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3297 /* Initiate processing for all BGP instances. */
3298 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3299 if (bgp_initiate_graceful_shut_unshut(bgp
, errmsg
,
3303 vty_out(vty
, "%s\n", errmsg
);
3309 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3311 struct listnode
*node
, *nnode
;
3313 char errmsg
[BUFSIZ
] = {'\0'};
3315 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3318 /* Unset flag globally */
3319 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3321 /* Initiate processing for all BGP instances. */
3322 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3323 if (bgp_initiate_graceful_shut_unshut(bgp
, errmsg
,
3327 vty_out(vty
, "%s\n", errmsg
);
3333 /* "bgp graceful-shutdown" configuration */
3334 DEFUN (bgp_graceful_shutdown
,
3335 bgp_graceful_shutdown_cmd
,
3336 "bgp graceful-shutdown",
3338 "Graceful shutdown parameters\n")
3340 if (vty
->node
== CONFIG_NODE
)
3341 return bgp_global_graceful_shutdown_config_vty(vty
);
3343 nb_cli_enqueue_change(vty
, "./global/graceful-shutdown/enable",
3344 NB_OP_MODIFY
, "true");
3346 return nb_cli_apply_changes(vty
, NULL
);
3349 DEFUN_YANG (no_bgp_graceful_shutdown
,
3350 no_bgp_graceful_shutdown_cmd
,
3351 "no bgp graceful-shutdown",
3354 "Graceful shutdown parameters\n")
3356 if (vty
->node
== CONFIG_NODE
)
3357 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3359 nb_cli_enqueue_change(vty
, "./global/graceful-shutdown/enable",
3360 NB_OP_MODIFY
, "false");
3362 return nb_cli_apply_changes(vty
, NULL
);
3365 void cli_show_router_bgp_graceful_shutdown(struct vty
*vty
,
3366 struct lyd_node
*dnode
,
3369 if (yang_dnode_get_bool(dnode
, NULL
))
3370 vty_out(vty
, " bgp graceful-shutdown\n");
3373 /* "bgp fast-external-failover" configuration. */
3374 DEFUN_YANG (bgp_fast_external_failover
,
3375 bgp_fast_external_failover_cmd
,
3376 "bgp fast-external-failover",
3378 "Immediately reset session if a link to a directly connected external peer goes down\n")
3380 nb_cli_enqueue_change(vty
, "./global/fast-external-failover",
3381 NB_OP_MODIFY
, "false");
3383 return nb_cli_apply_changes(vty
, NULL
);
3386 DEFUN_YANG (no_bgp_fast_external_failover
,
3387 no_bgp_fast_external_failover_cmd
,
3388 "no bgp fast-external-failover",
3391 "Immediately reset session if a link to a directly connected external peer goes down\n")
3393 nb_cli_enqueue_change(vty
, "./global/fast-external-failover",
3394 NB_OP_MODIFY
, "true");
3396 return nb_cli_apply_changes(vty
, NULL
);
3399 void cli_show_router_bgp_fast_external_failover(struct vty
*vty
,
3400 struct lyd_node
*dnode
,
3403 if (!yang_dnode_get_bool(dnode
, NULL
))
3404 vty_out(vty
, " no bgp fast-external-failover\n");
3407 /* "bgp bestpath compare-routerid" configuration. */
3408 DEFUN_YANG(bgp_bestpath_compare_router_id
,
3409 bgp_bestpath_compare_router_id_cmd
,
3410 "bgp bestpath compare-routerid",
3411 "BGP specific commands\n"
3412 "Change the default bestpath selection\n"
3413 "Compare router-id for identical EBGP paths\n")
3415 nb_cli_enqueue_change(
3417 "./global/route-selection-options/external-compare-router-id",
3418 NB_OP_MODIFY
, "true");
3420 return nb_cli_apply_changes(vty
, NULL
);
3423 DEFUN_YANG(no_bgp_bestpath_compare_router_id
,
3424 no_bgp_bestpath_compare_router_id_cmd
,
3425 "no bgp bestpath compare-routerid",
3427 "BGP specific commands\n"
3428 "Change the default bestpath selection\n"
3429 "Compare router-id for identical EBGP paths\n")
3431 nb_cli_enqueue_change(
3433 "./global/route-selection-options/external-compare-router-id",
3434 NB_OP_MODIFY
, "false");
3436 return nb_cli_apply_changes(vty
, NULL
);
3439 /* "bgp bestpath as-path ignore" configuration. */
3440 DEFUN_YANG(bgp_bestpath_aspath_ignore
,
3441 bgp_bestpath_aspath_ignore_cmd
,
3442 "bgp bestpath as-path ignore",
3443 "BGP specific commands\n"
3444 "Change the default bestpath selection\n"
3445 "AS-path attribute\n"
3446 "Ignore as-path length in selecting a route\n")
3448 nb_cli_enqueue_change(
3449 vty
, "./global/route-selection-options/ignore-as-path-length",
3450 NB_OP_MODIFY
, "true");
3452 return nb_cli_apply_changes(vty
, NULL
);
3455 DEFUN_YANG(no_bgp_bestpath_aspath_ignore
,
3456 no_bgp_bestpath_aspath_ignore_cmd
,
3457 "no bgp bestpath as-path ignore",
3459 "BGP specific commands\n"
3460 "Change the default bestpath selection\n"
3461 "AS-path attribute\n"
3462 "Ignore as-path length in selecting a route\n")
3464 nb_cli_enqueue_change(
3465 vty
, "./global/route-selection-options/ignore-as-path-length",
3466 NB_OP_MODIFY
, "false");
3468 return nb_cli_apply_changes(vty
, NULL
);
3471 /* "bgp bestpath as-path confed" configuration. */
3472 DEFUN_YANG (bgp_bestpath_aspath_confed
,
3473 bgp_bestpath_aspath_confed_cmd
,
3474 "bgp bestpath as-path confed",
3475 "BGP specific commands\n"
3476 "Change the default bestpath selection\n"
3477 "AS-path attribute\n"
3478 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3480 nb_cli_enqueue_change(vty
,
3481 "./global/route-selection-options/aspath-confed",
3482 NB_OP_MODIFY
, "true");
3484 return nb_cli_apply_changes(vty
, NULL
);
3487 DEFUN_YANG (no_bgp_bestpath_aspath_confed
,
3488 no_bgp_bestpath_aspath_confed_cmd
,
3489 "no bgp bestpath as-path confed",
3491 "BGP specific commands\n"
3492 "Change the default bestpath selection\n"
3493 "AS-path attribute\n"
3494 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3496 nb_cli_enqueue_change(vty
,
3497 "./global/route-selection-options/aspath-confed",
3498 NB_OP_MODIFY
, "false");
3500 return nb_cli_apply_changes(vty
, NULL
);
3503 /* "bgp bestpath as-path multipath-relax" configuration. */
3504 DEFUN_YANG (bgp_bestpath_aspath_multipath_relax
,
3505 bgp_bestpath_aspath_multipath_relax_cmd
,
3506 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3507 "BGP specific commands\n"
3508 "Change the default bestpath selection\n"
3509 "AS-path attribute\n"
3510 "Allow load sharing across routes that have different AS paths (but same length)\n"
3511 "Generate an AS_SET\n"
3512 "Do not generate an AS_SET\n")
3516 nb_cli_enqueue_change(
3517 vty
, "./global/route-selection-options/allow-multiple-as",
3518 NB_OP_MODIFY
, "true");
3519 if (argv_find(argv
, argc
, "as-set", &idx
))
3520 nb_cli_enqueue_change(
3522 "./global/route-selection-options/multi-path-as-set",
3523 NB_OP_MODIFY
, "true");
3525 nb_cli_enqueue_change(
3527 "./global/route-selection-options/multi-path-as-set",
3528 NB_OP_MODIFY
, "false");
3530 return nb_cli_apply_changes(vty
, NULL
);
3533 DEFUN_YANG (no_bgp_bestpath_aspath_multipath_relax
,
3534 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3535 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3537 "BGP specific commands\n"
3538 "Change the default bestpath selection\n"
3539 "AS-path attribute\n"
3540 "Allow load sharing across routes that have different AS paths (but same length)\n"
3541 "Generate an AS_SET\n"
3542 "Do not generate an AS_SET\n")
3544 nb_cli_enqueue_change(
3545 vty
, "./global/route-selection-options/allow-multiple-as",
3546 NB_OP_MODIFY
, "false");
3547 nb_cli_enqueue_change(
3548 vty
, "./global/route-selection-options/multi-path-as-set",
3549 NB_OP_MODIFY
, "false");
3551 return nb_cli_apply_changes(vty
, NULL
);
3554 /* "bgp log-neighbor-changes" configuration. */
3555 DEFUN_YANG(bgp_log_neighbor_changes
,
3556 bgp_log_neighbor_changes_cmd
,
3557 "bgp log-neighbor-changes",
3558 "BGP specific commands\n"
3559 "Log neighbor up/down and reset reason\n")
3561 nb_cli_enqueue_change(
3562 vty
, "./global/global-neighbor-config/log-neighbor-changes",
3563 NB_OP_MODIFY
, "true");
3565 return nb_cli_apply_changes(vty
, NULL
);
3568 DEFUN_YANG(no_bgp_log_neighbor_changes
,
3569 no_bgp_log_neighbor_changes_cmd
,
3570 "no bgp log-neighbor-changes",
3572 "BGP specific commands\n"
3573 "Log neighbor up/down and reset reason\n")
3575 nb_cli_enqueue_change(
3576 vty
, "./global/global-neighbor-config/log-neighbor-changes",
3577 NB_OP_MODIFY
, "false");
3579 return nb_cli_apply_changes(vty
, NULL
);
3582 /* "bgp bestpath med" configuration. */
3583 DEFUN_YANG (bgp_bestpath_med
,
3584 bgp_bestpath_med_cmd
,
3585 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3586 "BGP specific commands\n"
3587 "Change the default bestpath selection\n"
3589 "Compare MED among confederation paths\n"
3590 "Treat missing MED as the least preferred one\n"
3591 "Treat missing MED as the least preferred one\n"
3592 "Compare MED among confederation paths\n")
3595 bool confed
= false;
3596 bool worst_med
= false;
3599 if (argv_find(argv
, argc
, "confed", &idx
))
3602 nb_cli_enqueue_change(vty
,
3603 "./global/route-selection-options/confed-med",
3604 NB_OP_MODIFY
, confed
? "true" : "false");
3607 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3610 nb_cli_enqueue_change(
3611 vty
, "./global/route-selection-options/missing-as-worst-med",
3612 NB_OP_MODIFY
, worst_med
? "true" : "false");
3614 return nb_cli_apply_changes(vty
, NULL
);
3617 DEFUN_YANG (no_bgp_bestpath_med
,
3618 no_bgp_bestpath_med_cmd
,
3619 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3621 "BGP specific commands\n"
3622 "Change the default bestpath selection\n"
3624 "Compare MED among confederation paths\n"
3625 "Treat missing MED as the least preferred one\n"
3626 "Treat missing MED as the least preferred one\n"
3627 "Compare MED among confederation paths\n")
3631 if (argv_find(argv
, argc
, "confed", &idx
))
3632 nb_cli_enqueue_change(
3633 vty
, "./global/route-selection-options/confed-med",
3634 NB_OP_MODIFY
, "false");
3637 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3638 nb_cli_enqueue_change(
3640 "./global/route-selection-options/missing-as-worst-med",
3641 NB_OP_MODIFY
, "false");
3643 return nb_cli_apply_changes(vty
, NULL
);
3646 /* "bgp bestpath bandwidth" configuration. */
3647 DEFPY (bgp_bestpath_bw
,
3648 bgp_bestpath_bw_cmd
,
3649 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3650 "BGP specific commands\n"
3651 "Change the default bestpath selection\n"
3652 "Link Bandwidth attribute\n"
3653 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3654 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3655 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3657 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3662 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3663 return CMD_ERR_INCOMPLETE
;
3665 if (!strcmp(bw_cfg
, "ignore"))
3666 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3667 else if (!strcmp(bw_cfg
, "skip-missing"))
3668 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3669 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3670 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3672 return CMD_ERR_NO_MATCH
;
3674 /* This config is used in route install, so redo that. */
3675 FOREACH_AFI_SAFI (afi
, safi
) {
3676 if (!bgp_fibupd_safi(safi
))
3678 bgp_zebra_announce_table(bgp
, afi
, safi
);
3684 DEFPY (no_bgp_bestpath_bw
,
3685 no_bgp_bestpath_bw_cmd
,
3686 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3688 "BGP specific commands\n"
3689 "Change the default bestpath selection\n"
3690 "Link Bandwidth attribute\n"
3691 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3692 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3693 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3695 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3699 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3701 /* This config is used in route install, so redo that. */
3702 FOREACH_AFI_SAFI (afi
, safi
) {
3703 if (!bgp_fibupd_safi(safi
))
3705 bgp_zebra_announce_table(bgp
, afi
, safi
);
3710 /* "no bgp default ipv4-unicast". */
3711 DEFUN (no_bgp_default_ipv4_unicast
,
3712 no_bgp_default_ipv4_unicast_cmd
,
3713 "no bgp default ipv4-unicast",
3715 "BGP specific commands\n"
3716 "Configure BGP defaults\n"
3717 "Activate ipv4-unicast for a peer by default\n")
3719 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3720 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
);
3724 DEFUN (bgp_default_ipv4_unicast
,
3725 bgp_default_ipv4_unicast_cmd
,
3726 "bgp default ipv4-unicast",
3727 "BGP specific commands\n"
3728 "Configure BGP defaults\n"
3729 "Activate ipv4-unicast for a peer by default\n")
3731 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3732 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
);
3736 /* Display hostname in certain command outputs */
3737 DEFUN_YANG (bgp_default_show_hostname
,
3738 bgp_default_show_hostname_cmd
,
3739 "bgp default show-hostname",
3740 "BGP specific commands\n"
3741 "Configure BGP defaults\n"
3742 "Show hostname in certain command outputs\n")
3744 nb_cli_enqueue_change(vty
, "./global/show-hostname", NB_OP_MODIFY
,
3747 return nb_cli_apply_changes(vty
, NULL
);
3750 DEFUN_YANG(no_bgp_default_show_hostname
,
3751 no_bgp_default_show_hostname_cmd
,
3752 "no bgp default show-hostname",
3754 "BGP specific commands\n"
3755 "Configure BGP defaults\n"
3756 "Show hostname in certain command outputs\n")
3758 nb_cli_enqueue_change(vty
, "./global/show-hostname", NB_OP_MODIFY
,
3761 return nb_cli_apply_changes(vty
, NULL
);
3764 void cli_show_router_bgp_show_hostname(struct vty
*vty
, struct lyd_node
*dnode
,
3767 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SHOW_HOSTNAME
)
3768 vty_out(vty
, " bgp default show-hostname\n");
3771 /* Display hostname in certain command outputs */
3772 DEFUN_YANG(bgp_default_show_nexthop_hostname
,
3773 bgp_default_show_nexthop_hostname_cmd
,
3774 "bgp default show-nexthop-hostname",
3775 "BGP specific commands\n"
3776 "Configure BGP defaults\n"
3777 "Show hostname for nexthop in certain command outputs\n")
3779 nb_cli_enqueue_change(vty
, "./global/show-nexthop-hostname",
3780 NB_OP_MODIFY
, "true");
3782 return nb_cli_apply_changes(vty
, NULL
);
3785 DEFUN (no_bgp_default_show_nexthop_hostname
,
3786 no_bgp_default_show_nexthop_hostname_cmd
,
3787 "no bgp default show-nexthop-hostname",
3789 "BGP specific commands\n"
3790 "Configure BGP defaults\n"
3791 "Show hostname for nexthop in certain command outputs\n")
3793 nb_cli_enqueue_change(vty
, "./global/show-nexthop-hostname",
3794 NB_OP_MODIFY
, "false");
3796 return nb_cli_apply_changes(vty
, NULL
);
3799 void cli_show_router_bgp_show_nexthop_hostname(struct vty
*vty
,
3800 struct lyd_node
*dnode
,
3803 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SHOW_HOSTNAME
)
3804 vty_out(vty
, " bgp default show-nexthop-hostname\n");
3807 /* "bgp network import-check" configuration. */
3808 DEFUN_YANG(bgp_network_import_check
,
3809 bgp_network_import_check_cmd
,
3810 "bgp network import-check",
3811 "BGP specific commands\n"
3812 "BGP network command\n"
3813 "Check BGP network route exists in IGP\n")
3815 nb_cli_enqueue_change(vty
, "./global/import-check", NB_OP_MODIFY
,
3818 return nb_cli_apply_changes(vty
, NULL
);
3821 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
3822 "bgp network import-check exact",
3823 "BGP specific commands\n"
3824 "BGP network command\n"
3825 "Check BGP network route exists in IGP\n"
3826 "Match route precisely\n")
3828 DEFUN_YANG(no_bgp_network_import_check
,
3829 no_bgp_network_import_check_cmd
,
3830 "no bgp network import-check",
3832 "BGP specific commands\n"
3833 "BGP network command\n"
3834 "Check BGP network route exists in IGP\n")
3836 nb_cli_enqueue_change(vty
, "./global/import-check", NB_OP_MODIFY
,
3839 return nb_cli_apply_changes(vty
, NULL
);
3842 void cli_show_router_bgp_import_check(struct vty
*vty
, struct lyd_node
*dnode
,
3845 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_IMPORT_CHECK
)
3846 vty_out(vty
, " bgp network import-check\n");
3849 DEFUN_YANG(bgp_default_local_preference
,
3850 bgp_default_local_preference_cmd
,
3851 "bgp default local-preference (0-4294967295)",
3852 "BGP specific commands\n"
3853 "Configure BGP defaults\n"
3854 "local preference (higher=more preferred)\n"
3855 "Configure default local preference value\n")
3859 nb_cli_enqueue_change(vty
, "./global/local-pref", NB_OP_MODIFY
,
3860 argv
[idx_number
]->arg
);
3862 return nb_cli_apply_changes(vty
, NULL
);
3865 DEFUN_YANG(no_bgp_default_local_preference
,
3866 no_bgp_default_local_preference_cmd
,
3867 "no bgp default local-preference [(0-4294967295)]",
3869 "BGP specific commands\n"
3870 "Configure BGP defaults\n"
3871 "local preference (higher=more preferred)\n"
3872 "Configure default local preference value\n")
3874 nb_cli_enqueue_change(vty
, "./global/local-pref", NB_OP_MODIFY
, NULL
);
3876 return nb_cli_apply_changes(vty
, NULL
);
3879 void cli_show_router_bgp_local_pref(struct vty
*vty
, struct lyd_node
*dnode
,
3882 vty_out(vty
, " bgp default local-preference %u\n",
3883 yang_dnode_get_uint32(dnode
, NULL
));
3887 DEFUN_YANG(bgp_default_subgroup_pkt_queue_max
,
3888 bgp_default_subgroup_pkt_queue_max_cmd
,
3889 "bgp default subgroup-pkt-queue-max (20-100)",
3890 "BGP specific commands\n"
3891 "Configure BGP defaults\n"
3892 "subgroup-pkt-queue-max\n"
3893 "Configure subgroup packet queue max\n")
3897 nb_cli_enqueue_change(
3899 "./global/global-update-group-config/subgroup-pkt-queue-size",
3900 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
3902 return nb_cli_apply_changes(vty
, NULL
);
3905 DEFUN_YANG(no_bgp_default_subgroup_pkt_queue_max
,
3906 no_bgp_default_subgroup_pkt_queue_max_cmd
,
3907 "no bgp default subgroup-pkt-queue-max [(20-100)]",
3909 "BGP specific commands\n"
3910 "Configure BGP defaults\n"
3911 "subgroup-pkt-queue-max\n"
3912 "Configure subgroup packet queue max\n")
3914 nb_cli_enqueue_change(
3916 "./global/global-update-group-config/subgroup-pkt-queue-size",
3917 NB_OP_MODIFY
, NULL
);
3919 return nb_cli_apply_changes(vty
, NULL
);
3922 void cli_show_router_global_update_group_config_subgroup_pkt_queue_size(
3923 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
3925 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
3926 yang_dnode_get_uint32(dnode
, NULL
));
3929 DEFUN_YANG(bgp_rr_allow_outbound_policy
,
3930 bgp_rr_allow_outbound_policy_cmd
,
3931 "bgp route-reflector allow-outbound-policy",
3932 "BGP specific commands\n"
3933 "Allow modifications made by out route-map\n"
3934 "on ibgp neighbors\n")
3936 nb_cli_enqueue_change(vty
,
3937 "./global/route-reflector/allow-outbound-policy",
3938 NB_OP_MODIFY
, "true");
3940 return nb_cli_apply_changes(vty
, NULL
);
3943 DEFUN_YANG(no_bgp_rr_allow_outbound_policy
,
3944 no_bgp_rr_allow_outbound_policy_cmd
,
3945 "no bgp route-reflector allow-outbound-policy",
3947 "BGP specific commands\n"
3948 "Allow modifications made by out route-map\n"
3949 "on ibgp neighbors\n")
3951 nb_cli_enqueue_change(vty
,
3952 "./global/route-reflector/allow-outbound-policy",
3953 NB_OP_MODIFY
, "false");
3955 return nb_cli_apply_changes(vty
, NULL
);
3959 void cli_show_router_global_neighbor_config(struct vty
*vty
,
3960 struct lyd_node
*dnode
,
3963 uint32_t write_quanta
, read_quanta
;
3965 if (yang_dnode_get_bool(dnode
, "./log-neighbor-changes"))
3966 vty_out(vty
, " bgp log-neighbor-changes\n");
3968 if (yang_dnode_exists(dnode
, "./dynamic-neighbors-limit")) {
3969 uint32_t listen_limit
= yang_dnode_get_uint32(
3970 dnode
, "./dynamic-neighbors-limit");
3971 vty_out(vty
, " bgp listen limit %u\n", listen_limit
);
3974 write_quanta
= yang_dnode_get_uint32(
3975 dnode
, "./packet-quanta-config/wpkt-quanta");
3976 if (write_quanta
!= BGP_WRITE_PACKET_MAX
)
3977 vty_out(vty
, " write-quanta %d\n", write_quanta
);
3979 read_quanta
= yang_dnode_get_uint32(
3980 dnode
, "./packet-quanta-config/rpkt-quanta");
3982 if (read_quanta
!= BGP_READ_PACKET_MAX
)
3983 vty_out(vty
, " read-quanta %d\n", read_quanta
);
3986 DEFUN_YANG(bgp_listen_limit
,
3987 bgp_listen_limit_cmd
,
3988 "bgp listen limit (1-5000)",
3989 "BGP specific commands\n"
3990 "BGP Dynamic Neighbors listen commands\n"
3991 "Maximum number of BGP Dynamic Neighbors that can be created\n"
3992 "Configure Dynamic Neighbors listen limit value\n")
3996 nb_cli_enqueue_change(
3997 vty
, "./global/global-neighbor-config/dynamic-neighbors-limit",
3998 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
4000 return nb_cli_apply_changes(vty
, NULL
);
4003 DEFUN_YANG(no_bgp_listen_limit
,
4004 no_bgp_listen_limit_cmd
,
4005 "no bgp listen limit [(1-5000)]",
4007 "BGP specific commands\n"
4008 "BGP Dynamic Neighbors listen commands\n"
4009 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4010 "Configure Dynamic Neighbors listen limit value\n")
4012 nb_cli_enqueue_change(
4013 vty
, "./global/global-neighbor-config/dynamic-neighbors-limit",
4014 NB_OP_DESTROY
, NULL
);
4016 return nb_cli_apply_changes(vty
, NULL
);
4021 * Check if this listen range is already configured. Check for exact
4022 * match or overlap based on input.
4024 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4025 struct prefix
*range
, int exact
)
4027 struct listnode
*node
, *nnode
;
4028 struct listnode
*node1
, *nnode1
;
4029 struct peer_group
*group
;
4034 afi
= family2afi(range
->family
);
4035 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4036 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4039 match
= prefix_same(range
, lr
);
4041 match
= (prefix_match(range
, lr
)
4042 || prefix_match(lr
, range
));
4051 DEFUN (bgp_listen_range
,
4052 bgp_listen_range_cmd
,
4053 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4054 "BGP specific commands\n"
4055 "Configure BGP dynamic neighbors listen range\n"
4056 "Configure BGP dynamic neighbors listen range\n"
4058 "Member of the peer-group\n"
4059 "Peer-group name\n")
4061 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4062 struct prefix range
;
4063 struct peer_group
*group
, *existing_group
;
4068 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4069 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4070 char *prefix
= argv
[idx
]->arg
;
4071 argv_find(argv
, argc
, "PGNAME", &idx
);
4072 char *peergroup
= argv
[idx
]->arg
;
4074 /* Convert IP prefix string to struct prefix. */
4075 ret
= str2prefix(prefix
, &range
);
4077 vty_out(vty
, "%% Malformed listen range\n");
4078 return CMD_WARNING_CONFIG_FAILED
;
4081 afi
= family2afi(range
.family
);
4083 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4085 "%% Malformed listen range (link-local address)\n");
4086 return CMD_WARNING_CONFIG_FAILED
;
4091 /* Check if same listen range is already configured. */
4092 existing_group
= listen_range_exists(bgp
, &range
, 1);
4093 if (existing_group
) {
4094 if (strcmp(existing_group
->name
, peergroup
) == 0)
4098 "%% Same listen range is attached to peer-group %s\n",
4099 existing_group
->name
);
4100 return CMD_WARNING_CONFIG_FAILED
;
4104 /* Check if an overlapping listen range exists. */
4105 if (listen_range_exists(bgp
, &range
, 0)) {
4107 "%% Listen range overlaps with existing listen range\n");
4108 return CMD_WARNING_CONFIG_FAILED
;
4111 group
= peer_group_lookup(bgp
, peergroup
);
4113 vty_out(vty
, "%% Configure the peer-group first\n");
4114 return CMD_WARNING_CONFIG_FAILED
;
4117 ret
= peer_group_listen_range_add(group
, &range
);
4118 return bgp_vty_return(vty
, ret
);
4121 DEFUN (no_bgp_listen_range
,
4122 no_bgp_listen_range_cmd
,
4123 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4125 "BGP specific commands\n"
4126 "Unconfigure BGP dynamic neighbors listen range\n"
4127 "Unconfigure BGP dynamic neighbors listen range\n"
4129 "Member of the peer-group\n"
4130 "Peer-group name\n")
4132 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4133 struct prefix range
;
4134 struct peer_group
*group
;
4139 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4140 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4141 char *prefix
= argv
[idx
]->arg
;
4142 argv_find(argv
, argc
, "PGNAME", &idx
);
4143 char *peergroup
= argv
[idx
]->arg
;
4145 /* Convert IP prefix string to struct prefix. */
4146 ret
= str2prefix(prefix
, &range
);
4148 vty_out(vty
, "%% Malformed listen range\n");
4149 return CMD_WARNING_CONFIG_FAILED
;
4152 afi
= family2afi(range
.family
);
4154 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4156 "%% Malformed listen range (link-local address)\n");
4157 return CMD_WARNING_CONFIG_FAILED
;
4162 group
= peer_group_lookup(bgp
, peergroup
);
4164 vty_out(vty
, "%% Peer-group does not exist\n");
4165 return CMD_WARNING_CONFIG_FAILED
;
4168 ret
= peer_group_listen_range_del(group
, &range
);
4169 return bgp_vty_return(vty
, ret
);
4172 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4174 struct peer_group
*group
;
4175 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4176 struct prefix
*range
;
4179 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4180 vty_out(vty
, " bgp listen limit %d\n",
4181 bgp
->dynamic_neighbors_limit
);
4183 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4184 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4185 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4188 " bgp listen range %pFX peer-group %s\n",
4189 range
, group
->name
);
4196 DEFUN_YANG(bgp_disable_connected_route_check
,
4197 bgp_disable_connected_route_check_cmd
,
4198 "bgp disable-ebgp-connected-route-check",
4199 "BGP specific commands\n"
4200 "Disable checking if nexthop is connected on ebgp sessions\n")
4202 nb_cli_enqueue_change(vty
,
4203 "./global/ebgp-multihop-connected-route-check",
4204 NB_OP_MODIFY
, "true");
4206 return nb_cli_apply_changes(vty
, NULL
);
4209 DEFUN_YANG(no_bgp_disable_connected_route_check
,
4210 no_bgp_disable_connected_route_check_cmd
,
4211 "no bgp disable-ebgp-connected-route-check",
4213 "BGP specific commands\n"
4214 "Disable checking if nexthop is connected on ebgp sessions\n")
4216 nb_cli_enqueue_change(vty
,
4217 "./global/ebgp-multihop-connected-route-check",
4218 NB_OP_MODIFY
, "false");
4220 return nb_cli_apply_changes(vty
, NULL
);
4223 void cli_show_router_global_ebgp_multihop_connected_route_check(
4224 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
4226 if (yang_dnode_get_bool(dnode
, NULL
))
4227 vty_out(vty
, " bgp disable-ebgp-connected-route-check\n");
4230 DEFUN_YANG(bgp_default_shutdown
,
4231 bgp_default_shutdown_cmd
,
4232 "[no] bgp default shutdown",
4234 "Configure BGP defaults\n"
4235 "Apply administrative shutdown to newly configured peers\n")
4237 nb_cli_enqueue_change(vty
, "./global/default-shutdown", NB_OP_MODIFY
,
4238 strmatch(argv
[0]->text
, "no") ? "false" : "true");
4240 return nb_cli_apply_changes(vty
, NULL
);
4243 void cli_show_router_bgp_default_shutdown(struct vty
*vty
,
4244 struct lyd_node
*dnode
,
4247 if (yang_dnode_get_bool(dnode
, NULL
))
4248 vty_out(vty
, " bgp default shutdown\n");
4251 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4253 "Administrative shutdown of the BGP instance\n"
4254 "Add a shutdown message (RFC 8203)\n"
4255 "Shutdown message\n")
4257 char *msgstr
= NULL
;
4259 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4262 msgstr
= argv_concat(argv
, argc
, 3);
4264 bgp_shutdown_enable(bgp
, msgstr
);
4265 XFREE(MTYPE_TMP
, msgstr
);
4270 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4271 BGP_STR
"Administrative shutdown of the BGP instance\n")
4273 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4275 bgp_shutdown_enable(bgp
, NULL
);
4280 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4281 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4283 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4285 bgp_shutdown_disable(bgp
);
4290 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4291 "no bgp shutdown message MSG...", NO_STR BGP_STR
4292 "Administrative shutdown of the BGP instance\n"
4293 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4295 DEFUN_YANG(neighbor_remote_as
,
4296 neighbor_remote_as_cmd
,
4297 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4298 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4299 "Specify a BGP neighbor\n" AS_STR
4300 "Internal BGP peer\n"
4301 "External BGP peer\n")
4304 int idx_remote_as
= 3;
4305 char base_xpath
[XPATH_MAXLEN
];
4306 char unnbr_xpath
[XPATH_MAXLEN
];
4307 char prgrp_xpath
[XPATH_MAXLEN
];
4309 const char *as_type_str
= "as-specified";
4311 if (str2sockunion(argv
[idx_peer
]->arg
, &su
) < 0) {
4312 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
4313 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, argv
[idx_peer
]->arg
, "");
4315 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
4316 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
, "");
4318 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4319 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4320 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4321 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
,
4322 "%s%s", VTY_CURR_XPATH
,
4324 snprintf(base_xpath
, sizeof(base_xpath
),
4325 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
,
4329 "%% Create the peer-group or interface first\n");
4330 return CMD_WARNING_CONFIG_FAILED
;
4333 snprintf(base_xpath
, sizeof(base_xpath
),
4334 FRR_BGP_NEIGHBOR_NUM_XPATH
, argv
[idx_peer
]->arg
, "");
4337 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4338 as_type_str
= "internal";
4339 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4340 as_type_str
= "external";
4342 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4343 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4345 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4346 NB_OP_MODIFY
, as_type_str
);
4348 return nb_cli_apply_changes(vty
, base_xpath
);
4351 int peer_conf_interface_create(struct bgp
*bgp
, const char *conf_if
, afi_t afi
,
4352 safi_t safi
, bool v6only
,
4353 const char *peer_group_name
, int as_type
,
4354 as_t as
, char *errmsg
, size_t errmsg_len
)
4357 struct peer_group
*group
;
4360 group
= peer_group_lookup(bgp
, conf_if
);
4363 snprintf(errmsg
, errmsg_len
,
4364 "Name conflict with peer-group \n");
4368 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4370 if (as_type
!= AS_UNSPECIFIED
)
4371 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
4374 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
)
4375 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
4376 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
4377 as_type
, 0, 0, NULL
);
4379 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
4380 as_type
, afi
, safi
, NULL
);
4383 snprintf(errmsg
, errmsg_len
,
4384 "BGP failed to create peer\n");
4389 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4391 /* Request zebra to initiate IPv6 RAs on this interface. We do
4393 * any unnumbered peer in order to not worry about run-time
4395 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4397 * gets deleted later etc.)
4400 bgp_zebra_initiate_radv(bgp
, peer
);
4403 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4404 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4406 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4408 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4410 /* v6only flag changed. Reset bgp seesion */
4411 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4412 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4413 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4414 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4416 bgp_session_reset(peer
);
4419 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4420 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4421 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4422 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4425 if (peer_group_name
) {
4426 group
= peer_group_lookup(bgp
, peer_group_name
);
4428 snprintf(errmsg
, errmsg_len
,
4429 "Configure the peer-group first\n");
4433 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4436 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
4439 DEFUN_YANG(neighbor_interface_config
,
4440 neighbor_interface_config_cmd
,
4441 "neighbor WORD interface [peer-group PGNAME]",
4443 "Interface name or neighbor tag\n"
4444 "Enable BGP on interface\n"
4445 "Member of the peer-group\n"
4446 "Peer-group name\n")
4449 int idx_peer_group_word
= 4;
4450 char base_xpath
[XPATH_MAXLEN
];
4452 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4453 argv
[idx_word
]->arg
, "");
4455 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4456 if (argc
> idx_peer_group_word
)
4457 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_MODIFY
,
4458 argv
[idx_peer_group_word
]->arg
);
4460 return nb_cli_apply_changes(vty
, base_xpath
);
4463 DEFUN_YANG(neighbor_interface_config_v6only
,
4464 neighbor_interface_config_v6only_cmd
,
4465 "neighbor WORD interface v6only [peer-group PGNAME]",
4467 "Interface name or neighbor tag\n"
4468 "Enable BGP on interface\n"
4469 "Enable BGP with v6 link-local only\n"
4470 "Member of the peer-group\n"
4471 "Peer-group name\n")
4474 int idx_peer_group_word
= 5;
4475 char base_xpath
[XPATH_MAXLEN
];
4477 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4478 argv
[idx_word
]->arg
, "");
4480 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4481 if (argc
> idx_peer_group_word
)
4482 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_MODIFY
,
4483 argv
[idx_peer_group_word
]->arg
);
4485 nb_cli_enqueue_change(vty
, "./v6only", NB_OP_MODIFY
, "true");
4487 return nb_cli_apply_changes(vty
, base_xpath
);
4492 neighbor_interface_config_remote_as
,
4493 neighbor_interface_config_remote_as_cmd
,
4494 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4496 "Interface name or neighbor tag\n"
4497 "Enable BGP on interface\n"
4498 "Specify a BGP neighbor\n" AS_STR
4499 "Internal BGP peer\n"
4500 "External BGP peer\n")
4503 int idx_remote_as
= 4;
4504 char base_xpath
[XPATH_MAXLEN
];
4505 const char *as_type_str
= "as-specified";
4507 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4508 argv
[idx_word
]->arg
, "");
4510 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4512 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4513 as_type_str
= "internal";
4514 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4515 as_type_str
= "external";
4517 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4518 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4520 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4521 NB_OP_MODIFY
, as_type_str
);
4523 return nb_cli_apply_changes(vty
, base_xpath
);
4527 neighbor_interface_v6only_config_remote_as
,
4528 neighbor_interface_v6only_config_remote_as_cmd
,
4529 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4531 "Interface name or neighbor tag\n"
4532 "Enable BGP with v6 link-local only\n"
4533 "Enable BGP on interface\n"
4534 "Specify a BGP neighbor\n" AS_STR
4535 "Internal BGP peer\n"
4536 "External BGP peer\n")
4539 int idx_remote_as
= 5;
4540 char base_xpath
[XPATH_MAXLEN
];
4541 const char *as_type_str
= "as-specified";
4543 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4544 argv
[idx_word
]->arg
, "");
4546 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4548 nb_cli_enqueue_change(vty
, "./v6only", NB_OP_MODIFY
, "true");
4550 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4551 as_type_str
= "internal";
4552 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4553 as_type_str
= "external";
4555 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4556 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4558 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4559 NB_OP_MODIFY
, as_type_str
);
4561 return nb_cli_apply_changes(vty
, base_xpath
);
4564 DEFUN_YANG(neighbor_peer_group
, neighbor_peer_group_cmd
,
4565 "neighbor WORD peer-group",
4567 "Interface name or neighbor tag\n"
4568 "Configure peer-group\n")
4570 char base_xpath
[XPATH_MAXLEN
];
4573 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4574 argv
[idx_word
]->arg
, "");
4576 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4578 return nb_cli_apply_changes(vty
, base_xpath
);
4581 DEFUN_YANG(no_neighbor
,
4583 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4586 "Specify a BGP neighbor\n" AS_STR
4587 "Internal BGP peer\n"
4588 "External BGP peer\n")
4591 char base_xpath
[XPATH_MAXLEN
];
4592 char num_xpath
[XPATH_MAXLEN
];
4593 char unnbr_xpath
[XPATH_MAXLEN
];
4594 char prgrp_xpath
[XPATH_MAXLEN
];
4597 if (str2sockunion(argv
[idx_peer
]->arg
, &su
) == 0) {
4598 snprintf(num_xpath
, sizeof(num_xpath
),
4599 FRR_BGP_NEIGHBOR_NUM_XPATH
, argv
[idx_peer
]->arg
, "");
4600 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4601 VTY_CURR_XPATH
, num_xpath
+ 1)) {
4602 strlcpy(base_xpath
, num_xpath
, sizeof(base_xpath
));
4605 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
4606 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, argv
[idx_peer
]->arg
, "");
4608 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
4609 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
, "");
4611 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4612 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4613 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4614 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
,
4615 "%s%s", VTY_CURR_XPATH
,
4617 strlcpy(base_xpath
, prgrp_xpath
, sizeof(base_xpath
));
4620 "%% Create the peer-group or interface first\n");
4621 return CMD_WARNING_CONFIG_FAILED
;
4625 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_DESTROY
, NULL
);
4627 return nb_cli_apply_changes(vty
, NULL
);
4630 DEFUN_YANG(no_neighbor_interface_config
,
4631 no_neighbor_interface_config_cmd
,
4632 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4635 "Configure BGP on interface\n"
4636 "Enable BGP with v6 link-local only\n"
4637 "Member of the peer-group\n"
4639 "Specify a BGP neighbor\n" AS_STR
4640 "Internal BGP peer\n"
4641 "External BGP peer\n")
4644 char base_xpath
[XPATH_MAXLEN
];
4646 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4647 argv
[idx_word
]->arg
, "");
4649 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
4651 return nb_cli_apply_changes(vty
, base_xpath
);
4654 DEFUN_YANG(no_neighbor_peer_group
,
4655 no_neighbor_peer_group_cmd
,
4656 "no neighbor WORD peer-group",
4659 "Configure peer-group\n")
4661 char base_xpath
[XPATH_MAXLEN
];
4664 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4665 argv
[idx_word
]->arg
, "");
4667 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
4669 return nb_cli_apply_changes(vty
, base_xpath
);
4672 DEFUN_YANG(no_neighbor_interface_peer_group_remote_as
,
4673 no_neighbor_interface_peer_group_remote_as_cmd
,
4674 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4676 "Interface name or neighbor tag\n"
4677 "Specify a BGP neighbor\n" AS_STR
4678 "Internal BGP peer\n"
4679 "External BGP peer\n")
4682 char base_xpath
[XPATH_MAXLEN
];
4683 char unnbr_xpath
[XPATH_MAXLEN
];
4684 char prgrp_xpath
[XPATH_MAXLEN
];
4686 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4687 argv
[idx_peer
]->arg
, "");
4689 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4690 argv
[idx_peer
]->arg
, "");
4692 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4693 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4694 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4695 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4696 VTY_CURR_XPATH
, prgrp_xpath
+ 1)) {
4697 strlcpy(base_xpath
, prgrp_xpath
, sizeof(base_xpath
));
4699 vty_out(vty
, "%% Create the peer-group or interface first\n");
4700 return CMD_WARNING_CONFIG_FAILED
;
4703 strlcat(base_xpath
, "/neighbor-remote-as/remote-as-type",
4704 sizeof(base_xpath
));
4706 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_DESTROY
, NULL
);
4708 return nb_cli_apply_changes(vty
, NULL
);
4711 DEFUN_YANG(neighbor_local_as
,
4712 neighbor_local_as_cmd
,
4713 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4714 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4715 "Specify a local-as number\n"
4716 "AS number used as local AS\n")
4720 char base_xpath
[XPATH_MAXLEN
];
4722 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4723 sizeof(base_xpath
), NULL
)
4725 return CMD_WARNING_CONFIG_FAILED
;
4727 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4728 argv
[idx_number
]->arg
);
4730 return nb_cli_apply_changes(vty
, base_xpath
);
4734 neighbor_local_as_no_prepend
, neighbor_local_as_no_prepend_cmd
,
4735 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4736 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4737 "Specify a local-as number\n"
4738 "AS number used as local AS\n"
4739 "Do not prepend local-as to updates from ebgp peers\n")
4743 char base_xpath
[XPATH_MAXLEN
];
4745 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4746 sizeof(base_xpath
), NULL
)
4748 return CMD_WARNING_CONFIG_FAILED
;
4750 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4751 argv
[idx_number
]->arg
);
4752 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4755 return nb_cli_apply_changes(vty
, base_xpath
);
4759 neighbor_local_as_no_prepend_replace_as
,
4760 neighbor_local_as_no_prepend_replace_as_cmd
,
4761 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4762 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4763 "Specify a local-as number\n"
4764 "AS number used as local AS\n"
4765 "Do not prepend local-as to updates from ebgp peers\n"
4766 "Do not prepend local-as to updates from ibgp peers\n")
4770 char base_xpath
[XPATH_MAXLEN
];
4772 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4773 sizeof(base_xpath
), NULL
)
4775 return CMD_WARNING_CONFIG_FAILED
;
4777 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4778 argv
[idx_number
]->arg
);
4779 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4781 nb_cli_enqueue_change(vty
, "./local-as/no-replace-as", NB_OP_MODIFY
,
4784 return nb_cli_apply_changes(vty
, base_xpath
);
4787 DEFUN_YANG(no_neighbor_local_as
,
4788 no_neighbor_local_as_cmd
,
4789 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4790 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4791 "Specify a local-as number\n"
4792 "AS number used as local AS\n"
4793 "Do not prepend local-as to updates from ebgp peers\n"
4794 "Do not prepend local-as to updates from ibgp peers\n")
4797 char base_xpath
[XPATH_MAXLEN
];
4799 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4800 sizeof(base_xpath
), NULL
)
4802 return CMD_WARNING_CONFIG_FAILED
;
4804 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_DESTROY
, NULL
);
4805 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4807 nb_cli_enqueue_change(vty
, "./local-as/no-replace-as", NB_OP_MODIFY
,
4810 return nb_cli_apply_changes(vty
, base_xpath
);
4814 DEFUN (neighbor_solo
,
4816 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4819 "Solo peer - part of its own update group\n")
4825 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4827 return CMD_WARNING_CONFIG_FAILED
;
4829 ret
= update_group_adjust_soloness(peer
, 1);
4830 return bgp_vty_return(vty
, ret
);
4833 DEFUN (no_neighbor_solo
,
4834 no_neighbor_solo_cmd
,
4835 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4839 "Solo peer - part of its own update group\n")
4845 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4847 return CMD_WARNING_CONFIG_FAILED
;
4849 ret
= update_group_adjust_soloness(peer
, 0);
4850 return bgp_vty_return(vty
, ret
);
4853 DEFUN_YANG(neighbor_password
,
4854 neighbor_password_cmd
,
4855 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
4856 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
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
, "./password", NB_OP_MODIFY
,
4870 argv
[idx_line
]->arg
);
4872 return nb_cli_apply_changes(vty
, base_xpath
);
4875 DEFUN_YANG(no_neighbor_password
,
4876 no_neighbor_password_cmd
,
4877 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
4878 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4883 char base_xpath
[XPATH_MAXLEN
];
4885 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4886 sizeof(base_xpath
), NULL
)
4888 return CMD_WARNING_CONFIG_FAILED
;
4890 nb_cli_enqueue_change(vty
, "./password", NB_OP_DESTROY
, NULL
);
4892 return nb_cli_apply_changes(vty
, base_xpath
);
4895 DEFUN_YANG(neighbor_activate
,
4896 neighbor_activate_cmd
,
4897 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4898 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4899 "Enable the Address Family for this Neighbor\n")
4902 char base_xpath
[XPATH_MAXLEN
];
4903 char af_xpath
[XPATH_MAXLEN
];
4904 afi_t afi
= bgp_node_afi(vty
);
4905 safi_t safi
= bgp_node_safi(vty
);
4907 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
4908 yang_afi_safi_value2identity(afi
, safi
));
4909 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4910 sizeof(base_xpath
), af_xpath
)
4912 return CMD_WARNING_CONFIG_FAILED
;
4914 nb_cli_enqueue_change(vty
, "./enabled", NB_OP_MODIFY
, "true");
4916 return nb_cli_apply_changes(vty
, base_xpath
);
4919 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
4920 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4921 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4922 "Enable the Address Family for this Neighbor\n")
4924 DEFUN_YANG(no_neighbor_activate
,
4925 no_neighbor_activate_cmd
,
4926 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4929 "Enable the Address Family for this Neighbor\n")
4932 char base_xpath
[XPATH_MAXLEN
];
4933 char af_xpath
[XPATH_MAXLEN
];
4934 afi_t afi
= bgp_node_afi(vty
);
4935 safi_t safi
= bgp_node_safi(vty
);
4937 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
4938 yang_afi_safi_value2identity(afi
, safi
));
4940 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4941 sizeof(base_xpath
), af_xpath
)
4943 return CMD_WARNING_CONFIG_FAILED
;
4945 nb_cli_enqueue_change(vty
, "./enabled", NB_OP_MODIFY
, "false");
4947 return nb_cli_apply_changes(vty
, base_xpath
);
4950 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
4951 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4952 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4953 "Enable the Address Family for this Neighbor\n")
4955 DEFUN_YANG (neighbor_set_peer_group
,
4956 neighbor_set_peer_group_cmd
,
4957 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4960 "Member of the peer-group\n"
4961 "Peer-group name\n")
4965 char base_xpath
[XPATH_MAXLEN
];
4967 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4968 sizeof(base_xpath
), NULL
)
4970 return CMD_WARNING_CONFIG_FAILED
;
4972 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_MODIFY
,
4973 argv
[idx_word
]->arg
);
4975 return nb_cli_apply_changes(vty
, base_xpath
);
4978 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
4979 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4980 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4981 "Member of the peer-group\n"
4982 "Peer-group name\n")
4984 DEFUN_YANG (no_neighbor_set_peer_group
,
4985 no_neighbor_set_peer_group_cmd
,
4986 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4990 "Member of the peer-group\n"
4991 "Peer-group name\n")
4994 char base_xpath
[XPATH_MAXLEN
];
4996 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4997 sizeof(base_xpath
), NULL
)
4999 return CMD_WARNING_CONFIG_FAILED
;
5001 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_DESTROY
, NULL
);
5003 return nb_cli_apply_changes(vty
, base_xpath
);
5006 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5007 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5008 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5009 "Member of the peer-group\n"
5010 "Peer-group name\n")
5012 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
5013 uint32_t flag
, int set
)
5018 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5020 return CMD_WARNING_CONFIG_FAILED
;
5023 * If 'neighbor <interface>', then this is for directly connected peers,
5024 * we should not accept disable-connected-check.
5026 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5028 "%s is directly connected peer, cannot accept disable-connected-check\n",
5030 return CMD_WARNING_CONFIG_FAILED
;
5033 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5034 peer_tx_shutdown_message_unset(peer
);
5037 ret
= peer_flag_set(peer
, flag
);
5039 ret
= peer_flag_unset(peer
, flag
);
5041 return bgp_vty_return(vty
, ret
);
5044 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
5046 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
5049 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
5052 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
5055 int peer_flag_modify_nb(struct bgp
*bgp
, const char *ip_str
, struct peer
*peer
,
5056 uint32_t flag
, bool set
, char *errmsg
,
5062 * If 'neighbor <interface>', then this is for directly connected peers,
5063 * we should not accept disable-connected-check.
5065 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5068 "%s is directly connected peer, cannot accept disable-connected-check\n",
5073 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5074 peer_tx_shutdown_message_unset(peer
);
5077 ret
= peer_flag_set(peer
, flag
);
5079 ret
= peer_flag_unset(peer
, flag
);
5081 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
5084 /* neighbor passive. */
5085 DEFUN_YANG(neighbor_passive
,
5086 neighbor_passive_cmd
,
5087 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5090 "Don't send open messages to this neighbor\n")
5093 char base_xpath
[XPATH_MAXLEN
];
5095 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5096 sizeof(base_xpath
), NULL
)
5098 return CMD_WARNING_CONFIG_FAILED
;
5100 nb_cli_enqueue_change(vty
, "./passive-mode", NB_OP_MODIFY
, "true");
5102 return nb_cli_apply_changes(vty
, base_xpath
);
5105 DEFUN_YANG(no_neighbor_passive
,
5106 no_neighbor_passive_cmd
,
5107 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5110 "Don't send open messages to this neighbor\n")
5113 char base_xpath
[XPATH_MAXLEN
];
5115 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5116 sizeof(base_xpath
), NULL
)
5118 return CMD_WARNING_CONFIG_FAILED
;
5120 nb_cli_enqueue_change(vty
, "./passive-mode", NB_OP_MODIFY
, "false");
5122 return nb_cli_apply_changes(vty
, base_xpath
);
5125 /* neighbor shutdown. */
5126 DEFUN_YANG(neighbor_shutdown_msg
,
5127 neighbor_shutdown_msg_cmd
,
5128 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5129 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5130 "Administratively shut down this neighbor\n"
5131 "Add a shutdown message (RFC 8203)\n"
5132 "Shutdown message\n")
5135 char base_xpath
[XPATH_MAXLEN
];
5137 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5138 sizeof(base_xpath
), NULL
)
5140 return CMD_WARNING_CONFIG_FAILED
;
5145 message
= argv_concat(argv
, argc
, 4);
5146 nb_cli_enqueue_change(vty
, "./admin-shutdown/message",
5147 NB_OP_MODIFY
, message
);
5150 nb_cli_enqueue_change(vty
, "./admin-shutdown/enable", NB_OP_MODIFY
,
5153 return nb_cli_apply_changes(vty
, base_xpath
);
5156 ALIAS_YANG(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5157 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5158 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5159 "Administratively shut down this neighbor\n")
5161 DEFUN_YANG(no_neighbor_shutdown_msg
,
5162 no_neighbor_shutdown_msg_cmd
,
5163 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5166 "Administratively shut down this neighbor\n"
5167 "Remove a shutdown message (RFC 8203)\n"
5168 "Shutdown message\n")
5171 char base_xpath
[XPATH_MAXLEN
];
5173 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5174 sizeof(base_xpath
), NULL
)
5176 return CMD_WARNING_CONFIG_FAILED
;
5178 nb_cli_enqueue_change(vty
, "./admin-shutdown/enable", NB_OP_MODIFY
,
5181 return nb_cli_apply_changes(vty
, base_xpath
);
5184 ALIAS_YANG(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5185 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5186 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5187 "Administratively shut down this neighbor\n")
5189 DEFUN(neighbor_shutdown_rtt
,
5190 neighbor_shutdown_rtt_cmd
,
5191 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5194 "Administratively shut down this neighbor\n"
5195 "Shutdown if round-trip-time is higher than expected\n"
5196 "Round-trip-time in milliseconds\n"
5197 "Specify the number of keepalives before shutdown\n"
5198 "The number of keepalives with higher RTT to shutdown\n")
5205 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5208 return CMD_WARNING_CONFIG_FAILED
;
5210 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5212 if (argv_find(argv
, argc
, "count", &idx_count
))
5213 peer
->rtt_keepalive_conf
=
5214 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5216 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5217 PEER_FLAG_RTT_SHUTDOWN
);
5220 DEFUN(no_neighbor_shutdown_rtt
,
5221 no_neighbor_shutdown_rtt_cmd
,
5222 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5226 "Administratively shut down this neighbor\n"
5227 "Shutdown if round-trip-time is higher than expected\n"
5228 "Round-trip-time in milliseconds\n"
5229 "Specify the number of keepalives before shutdown\n"
5230 "The number of keepalives with higher RTT to shutdown\n")
5235 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5238 return CMD_WARNING_CONFIG_FAILED
;
5240 peer
->rtt_expected
= 0;
5241 peer
->rtt_keepalive_conf
= 1;
5243 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5244 PEER_FLAG_RTT_SHUTDOWN
);
5247 /* neighbor capability dynamic. */
5248 DEFUN_YANG (neighbor_capability_dynamic
,
5249 neighbor_capability_dynamic_cmd
,
5250 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5253 "Advertise capability to the peer\n"
5254 "Advertise dynamic capability to this neighbor\n")
5257 char base_xpath
[XPATH_MAXLEN
];
5259 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5260 sizeof(base_xpath
), NULL
)
5262 return CMD_WARNING_CONFIG_FAILED
;
5264 nb_cli_enqueue_change(vty
, "./capability-options/dynamic-capability",
5265 NB_OP_MODIFY
, "true");
5267 return nb_cli_apply_changes(vty
, base_xpath
);
5270 DEFUN_YANG (no_neighbor_capability_dynamic
,
5271 no_neighbor_capability_dynamic_cmd
,
5272 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5276 "Advertise capability to the peer\n"
5277 "Advertise dynamic capability to this neighbor\n")
5280 char base_xpath
[XPATH_MAXLEN
];
5282 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5283 sizeof(base_xpath
), NULL
)
5285 return CMD_WARNING_CONFIG_FAILED
;
5287 nb_cli_enqueue_change(vty
, "./capability-options/dynamic-capability",
5288 NB_OP_MODIFY
, "false");
5290 return nb_cli_apply_changes(vty
, base_xpath
);
5293 /* neighbor dont-capability-negotiate */
5294 DEFUN (neighbor_dont_capability_negotiate
,
5295 neighbor_dont_capability_negotiate_cmd
,
5296 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5299 "Do not perform capability negotiation\n")
5302 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5303 PEER_FLAG_DONT_CAPABILITY
);
5306 DEFUN (no_neighbor_dont_capability_negotiate
,
5307 no_neighbor_dont_capability_negotiate_cmd
,
5308 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5312 "Do not perform capability negotiation\n")
5315 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5316 PEER_FLAG_DONT_CAPABILITY
);
5319 /* neighbor capability extended next hop encoding */
5320 DEFUN_YANG (neighbor_capability_enhe
,
5321 neighbor_capability_enhe_cmd
,
5322 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5325 "Advertise capability to the peer\n"
5326 "Advertise extended next-hop capability to the peer\n")
5329 char base_xpath
[XPATH_MAXLEN
];
5331 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5332 sizeof(base_xpath
), NULL
)
5334 return CMD_WARNING_CONFIG_FAILED
;
5336 nb_cli_enqueue_change(
5337 vty
, "./capability-options/extended-nexthop-capability",
5338 NB_OP_MODIFY
, "true");
5340 return nb_cli_apply_changes(vty
, base_xpath
);
5343 DEFUN_YANG (no_neighbor_capability_enhe
,
5344 no_neighbor_capability_enhe_cmd
,
5345 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5349 "Advertise capability to the peer\n"
5350 "Advertise extended next-hop capability to the peer\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(
5361 vty
, "./capability-options/extended-nexthop-capability",
5362 NB_OP_MODIFY
, "false");
5364 return nb_cli_apply_changes(vty
, base_xpath
);
5367 int peer_af_flag_modify_nb(struct peer
*peer
, afi_t afi
, safi_t safi
,
5368 uint32_t flag
, int set
, char *errmsg
,
5374 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5376 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5378 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
5381 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5382 afi_t afi
, safi_t safi
, uint32_t flag
,
5388 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5390 return CMD_WARNING_CONFIG_FAILED
;
5393 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5395 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5397 return bgp_vty_return(vty
, ret
);
5400 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5401 afi_t afi
, safi_t safi
, uint32_t flag
)
5403 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5406 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5407 afi_t afi
, safi_t safi
, uint32_t flag
)
5409 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5412 /* neighbor capability orf prefix-list. */
5413 DEFUN (neighbor_capability_orf_prefix
,
5414 neighbor_capability_orf_prefix_cmd
,
5415 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5418 "Advertise capability to the peer\n"
5419 "Advertise ORF capability to the peer\n"
5420 "Advertise prefixlist ORF capability to this neighbor\n"
5421 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5422 "Capability to RECEIVE the ORF from this neighbor\n"
5423 "Capability to SEND the ORF to this neighbor\n")
5425 int idx_send_recv
= 5;
5426 char *peer_str
= argv
[1]->arg
;
5428 afi_t afi
= bgp_node_afi(vty
);
5429 safi_t safi
= bgp_node_safi(vty
);
5431 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5433 return CMD_WARNING_CONFIG_FAILED
;
5435 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5436 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5437 PEER_FLAG_ORF_PREFIX_SM
);
5439 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5440 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5441 PEER_FLAG_ORF_PREFIX_RM
);
5443 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5444 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5445 PEER_FLAG_ORF_PREFIX_SM
)
5446 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5447 PEER_FLAG_ORF_PREFIX_RM
);
5449 return CMD_WARNING_CONFIG_FAILED
;
5453 neighbor_capability_orf_prefix
,
5454 neighbor_capability_orf_prefix_hidden_cmd
,
5455 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5456 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5457 "Advertise capability to the peer\n"
5458 "Advertise ORF capability to the peer\n"
5459 "Advertise prefixlist ORF capability to this neighbor\n"
5460 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5461 "Capability to RECEIVE the ORF from this neighbor\n"
5462 "Capability to SEND the ORF to this neighbor\n")
5464 DEFUN (no_neighbor_capability_orf_prefix
,
5465 no_neighbor_capability_orf_prefix_cmd
,
5466 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5470 "Advertise capability to the peer\n"
5471 "Advertise ORF capability to the peer\n"
5472 "Advertise prefixlist ORF capability to this neighbor\n"
5473 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5474 "Capability to RECEIVE the ORF from this neighbor\n"
5475 "Capability to SEND the ORF to this neighbor\n")
5477 int idx_send_recv
= 6;
5478 char *peer_str
= argv
[2]->arg
;
5480 afi_t afi
= bgp_node_afi(vty
);
5481 safi_t safi
= bgp_node_safi(vty
);
5483 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5485 return CMD_WARNING_CONFIG_FAILED
;
5487 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5488 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5489 PEER_FLAG_ORF_PREFIX_SM
);
5491 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5492 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5493 PEER_FLAG_ORF_PREFIX_RM
);
5495 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5496 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5497 PEER_FLAG_ORF_PREFIX_SM
)
5498 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5499 PEER_FLAG_ORF_PREFIX_RM
);
5501 return CMD_WARNING_CONFIG_FAILED
;
5505 no_neighbor_capability_orf_prefix
,
5506 no_neighbor_capability_orf_prefix_hidden_cmd
,
5507 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5508 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5509 "Advertise capability to the peer\n"
5510 "Advertise ORF capability to the peer\n"
5511 "Advertise prefixlist ORF capability to this neighbor\n"
5512 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5513 "Capability to RECEIVE the ORF from this neighbor\n"
5514 "Capability to SEND the ORF to this neighbor\n")
5516 /* neighbor next-hop-self. */
5517 DEFUN_YANG (neighbor_nexthop_self
,
5518 neighbor_nexthop_self_cmd
,
5519 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5522 "Disable the next hop calculation for this neighbor\n")
5525 char base_xpath
[XPATH_MAXLEN
];
5526 char af_xpath
[XPATH_MAXLEN
];
5527 char attr_xpath
[XPATH_MAXLEN
];
5528 afi_t afi
= bgp_node_afi(vty
);
5529 safi_t safi
= bgp_node_safi(vty
);
5532 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5533 yang_afi_safi_value2identity(afi
, safi
));
5535 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5536 sizeof(base_xpath
), af_xpath
)
5538 return CMD_WARNING_CONFIG_FAILED
;
5540 snprintf(attr_xpath
, sizeof(attr_xpath
),
5541 "./%s/nexthop-self/next-hop-self",
5542 bgp_afi_safi_get_container_str(afi
, safi
));
5544 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5546 return nb_cli_apply_changes(vty
, base_xpath
);
5549 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5550 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5551 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5552 "Disable the next hop calculation for this neighbor\n")
5554 /* neighbor next-hop-self. */
5555 DEFUN_YANG(neighbor_nexthop_self_force
,
5556 neighbor_nexthop_self_force_cmd
,
5557 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5560 "Disable the next hop calculation for this neighbor\n"
5561 "Set the next hop to self for reflected routes\n")
5564 char base_xpath
[XPATH_MAXLEN
];
5565 char af_xpath
[XPATH_MAXLEN
];
5566 char attr_xpath
[XPATH_MAXLEN
];
5567 afi_t afi
= bgp_node_afi(vty
);
5568 safi_t safi
= bgp_node_safi(vty
);
5571 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5572 yang_afi_safi_value2identity(afi
, safi
));
5574 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5575 sizeof(base_xpath
), af_xpath
)
5577 return CMD_WARNING_CONFIG_FAILED
;
5579 snprintf(attr_xpath
, sizeof(attr_xpath
),
5580 "./%s/nexthop-self/next-hop-self-force",
5581 bgp_afi_safi_get_container_str(afi
, safi
));
5583 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5585 return nb_cli_apply_changes(vty
, base_xpath
);
5588 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5589 neighbor_nexthop_self_force_hidden_cmd
,
5590 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5591 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5592 "Disable the next hop calculation for this neighbor\n"
5593 "Set the next hop to self for reflected routes\n")
5595 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5596 neighbor_nexthop_self_all_hidden_cmd
,
5597 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5598 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5599 "Disable the next hop calculation for this neighbor\n"
5600 "Set the next hop to self for reflected routes\n")
5602 DEFUN_YANG (no_neighbor_nexthop_self
,
5603 no_neighbor_nexthop_self_cmd
,
5604 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5608 "Disable the next hop calculation for this neighbor\n")
5611 char base_xpath
[XPATH_MAXLEN
];
5612 char af_xpath
[XPATH_MAXLEN
];
5613 char attr_xpath
[XPATH_MAXLEN
];
5614 afi_t afi
= bgp_node_afi(vty
);
5615 safi_t safi
= bgp_node_safi(vty
);
5617 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5618 yang_afi_safi_value2identity(afi
, safi
));
5620 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5621 sizeof(base_xpath
), af_xpath
)
5623 return CMD_WARNING_CONFIG_FAILED
;
5625 snprintf(attr_xpath
, sizeof(attr_xpath
),
5626 "./%s/nexthop-self/next-hop-self",
5627 bgp_afi_safi_get_container_str(afi
, safi
));
5629 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5631 return nb_cli_apply_changes(vty
, base_xpath
);
5634 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5635 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5636 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5637 "Disable the next hop calculation for this neighbor\n")
5639 DEFUN_YANG (no_neighbor_nexthop_self_force
,
5640 no_neighbor_nexthop_self_force_cmd
,
5641 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5645 "Disable the next hop calculation for this neighbor\n"
5646 "Set the next hop to self for reflected routes\n")
5649 char base_xpath
[XPATH_MAXLEN
];
5650 char af_xpath
[XPATH_MAXLEN
];
5651 char attr_xpath
[XPATH_MAXLEN
];
5652 afi_t afi
= bgp_node_afi(vty
);
5653 safi_t safi
= bgp_node_safi(vty
);
5656 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5657 yang_afi_safi_value2identity(afi
, safi
));
5659 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5660 sizeof(base_xpath
), af_xpath
)
5662 return CMD_WARNING_CONFIG_FAILED
;
5664 snprintf(attr_xpath
, sizeof(attr_xpath
),
5665 "./%s/nexthop-self/next-hop-self-force",
5666 bgp_afi_safi_get_container_str(afi
, safi
));
5668 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5670 return nb_cli_apply_changes(vty
, base_xpath
);
5673 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5674 no_neighbor_nexthop_self_force_hidden_cmd
,
5675 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5676 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5677 "Disable the next hop calculation for this neighbor\n"
5678 "Set the next hop to self for reflected routes\n")
5680 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5681 no_neighbor_nexthop_self_all_hidden_cmd
,
5682 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5683 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5684 "Disable the next hop calculation for this neighbor\n"
5685 "Set the next hop to self for reflected routes\n")
5687 /* neighbor as-override */
5688 DEFUN_YANG (neighbor_as_override
,
5689 neighbor_as_override_cmd
,
5690 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5693 "Override ASNs in outbound updates if aspath equals remote-as\n")
5696 char base_xpath
[XPATH_MAXLEN
];
5697 char af_xpath
[XPATH_MAXLEN
];
5698 char attr_xpath
[XPATH_MAXLEN
];
5699 afi_t afi
= bgp_node_afi(vty
);
5700 safi_t safi
= bgp_node_safi(vty
);
5702 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5703 yang_afi_safi_value2identity(afi
, safi
));
5705 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5706 sizeof(base_xpath
), af_xpath
)
5708 return CMD_WARNING_CONFIG_FAILED
;
5710 snprintf(attr_xpath
, sizeof(attr_xpath
),
5711 "./%s/as-path-options/replace-peer-as",
5712 bgp_afi_safi_get_container_str(afi
, safi
));
5714 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5716 return nb_cli_apply_changes(vty
, base_xpath
);
5719 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5720 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5721 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5722 "Override ASNs in outbound updates if aspath equals remote-as\n")
5724 DEFUN_YANG (no_neighbor_as_override
,
5725 no_neighbor_as_override_cmd
,
5726 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5730 "Override ASNs in outbound updates if aspath equals remote-as\n")
5733 char base_xpath
[XPATH_MAXLEN
];
5734 char af_xpath
[XPATH_MAXLEN
];
5735 char attr_xpath
[XPATH_MAXLEN
];
5736 afi_t afi
= bgp_node_afi(vty
);
5737 safi_t safi
= bgp_node_safi(vty
);
5739 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5740 yang_afi_safi_value2identity(afi
, safi
));
5742 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5743 sizeof(base_xpath
), af_xpath
)
5745 return CMD_WARNING_CONFIG_FAILED
;
5747 snprintf(attr_xpath
, sizeof(attr_xpath
),
5748 "./%s/as-path-options/replace-peer-as",
5749 bgp_afi_safi_get_container_str(afi
, safi
));
5751 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5753 return nb_cli_apply_changes(vty
, base_xpath
);
5756 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5757 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5758 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5759 "Override ASNs in outbound updates if aspath equals remote-as\n")
5761 /* neighbor remove-private-AS. */
5762 DEFUN_YANG (neighbor_remove_private_as
,
5763 neighbor_remove_private_as_cmd
,
5764 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5767 "Remove private ASNs in outbound updates\n")
5770 char base_xpath
[XPATH_MAXLEN
];
5771 char af_xpath
[XPATH_MAXLEN
];
5772 char attr_xpath
[XPATH_MAXLEN
];
5773 afi_t afi
= bgp_node_afi(vty
);
5774 safi_t safi
= bgp_node_safi(vty
);
5776 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5777 yang_afi_safi_value2identity(afi
, safi
));
5779 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5780 sizeof(base_xpath
), af_xpath
)
5782 return CMD_WARNING_CONFIG_FAILED
;
5784 snprintf(attr_xpath
, sizeof(attr_xpath
),
5785 "./%s/private-as/remove-private-as",
5786 bgp_afi_safi_get_container_str(afi
, safi
));
5788 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5790 return nb_cli_apply_changes(vty
, base_xpath
);
5793 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5794 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5795 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5796 "Remove private ASNs in outbound updates\n")
5798 DEFUN_YANG (neighbor_remove_private_as_all
,
5799 neighbor_remove_private_as_all_cmd
,
5800 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5803 "Remove private ASNs in outbound updates\n"
5804 "Apply to all AS numbers\n")
5807 char base_xpath
[XPATH_MAXLEN
];
5808 char af_xpath
[XPATH_MAXLEN
];
5809 char attr_xpath
[XPATH_MAXLEN
];
5810 afi_t afi
= bgp_node_afi(vty
);
5811 safi_t safi
= bgp_node_safi(vty
);
5814 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5815 yang_afi_safi_value2identity(afi
, safi
));
5817 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5818 sizeof(base_xpath
), af_xpath
)
5820 return CMD_WARNING_CONFIG_FAILED
;
5822 snprintf(attr_xpath
, sizeof(attr_xpath
),
5823 "./%s/private-as/remove-private-as-all",
5824 bgp_afi_safi_get_container_str(afi
, safi
));
5826 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5828 return nb_cli_apply_changes(vty
, base_xpath
);
5831 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5832 neighbor_remove_private_as_all_hidden_cmd
,
5833 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5834 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5835 "Remove private ASNs in outbound updates\n"
5836 "Apply to all AS numbers")
5838 DEFUN_YANG (neighbor_remove_private_as_replace_as
,
5839 neighbor_remove_private_as_replace_as_cmd
,
5840 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5843 "Remove private ASNs in outbound updates\n"
5844 "Replace private ASNs with our ASN in outbound updates\n")
5847 char base_xpath
[XPATH_MAXLEN
];
5848 char af_xpath
[XPATH_MAXLEN
];
5849 char attr_xpath
[XPATH_MAXLEN
];
5850 afi_t afi
= bgp_node_afi(vty
);
5851 safi_t safi
= bgp_node_safi(vty
);
5854 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5855 yang_afi_safi_value2identity(afi
, safi
));
5857 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5858 sizeof(base_xpath
), af_xpath
)
5860 return CMD_WARNING_CONFIG_FAILED
;
5862 snprintf(attr_xpath
, sizeof(attr_xpath
),
5863 "./%s/private-as/remove-private-as-replace",
5864 bgp_afi_safi_get_container_str(afi
, safi
));
5866 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5868 return nb_cli_apply_changes(vty
, base_xpath
);
5871 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5872 neighbor_remove_private_as_replace_as_hidden_cmd
,
5873 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5874 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5875 "Remove private ASNs in outbound updates\n"
5876 "Replace private ASNs with our ASN in outbound updates\n")
5878 DEFUN_YANG (neighbor_remove_private_as_all_replace_as
,
5879 neighbor_remove_private_as_all_replace_as_cmd
,
5880 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5883 "Remove private ASNs in outbound updates\n"
5884 "Apply to all AS numbers\n"
5885 "Replace private ASNs with our ASN in outbound updates\n")
5888 char base_xpath
[XPATH_MAXLEN
];
5889 char af_xpath
[XPATH_MAXLEN
];
5890 char attr_xpath
[XPATH_MAXLEN
];
5891 afi_t afi
= bgp_node_afi(vty
);
5892 safi_t safi
= bgp_node_safi(vty
);
5895 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5896 yang_afi_safi_value2identity(afi
, safi
));
5898 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5899 sizeof(base_xpath
), af_xpath
)
5901 return CMD_WARNING_CONFIG_FAILED
;
5903 snprintf(attr_xpath
, sizeof(attr_xpath
),
5904 "./%s/private-as/remove-private-as-all-replace",
5905 bgp_afi_safi_get_container_str(afi
, safi
));
5907 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5909 return nb_cli_apply_changes(vty
, base_xpath
);
5913 neighbor_remove_private_as_all_replace_as
,
5914 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5915 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5916 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5917 "Remove private ASNs in outbound updates\n"
5918 "Apply to all AS numbers\n"
5919 "Replace private ASNs with our ASN in outbound updates\n")
5921 DEFUN_YANG (no_neighbor_remove_private_as
,
5922 no_neighbor_remove_private_as_cmd
,
5923 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5927 "Remove private ASNs in outbound updates\n")
5930 char base_xpath
[XPATH_MAXLEN
];
5931 char af_xpath
[XPATH_MAXLEN
];
5932 char attr_xpath
[XPATH_MAXLEN
];
5933 afi_t afi
= bgp_node_afi(vty
);
5934 safi_t safi
= bgp_node_safi(vty
);
5936 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5937 yang_afi_safi_value2identity(afi
, safi
));
5939 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5940 sizeof(base_xpath
), af_xpath
)
5942 return CMD_WARNING_CONFIG_FAILED
;
5944 snprintf(attr_xpath
, sizeof(attr_xpath
),
5945 "./%s/private-as/remove-private-as",
5946 bgp_afi_safi_get_container_str(afi
, safi
));
5948 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5950 return nb_cli_apply_changes(vty
, base_xpath
);
5953 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5954 no_neighbor_remove_private_as_hidden_cmd
,
5955 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5956 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5957 "Remove private ASNs in outbound updates\n")
5959 DEFUN_YANG (no_neighbor_remove_private_as_all
,
5960 no_neighbor_remove_private_as_all_cmd
,
5961 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5965 "Remove private ASNs in outbound updates\n"
5966 "Apply to all AS numbers\n")
5969 char base_xpath
[XPATH_MAXLEN
];
5970 char af_xpath
[XPATH_MAXLEN
];
5971 char attr_xpath
[XPATH_MAXLEN
];
5972 afi_t afi
= bgp_node_afi(vty
);
5973 safi_t safi
= bgp_node_safi(vty
);
5976 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5977 yang_afi_safi_value2identity(afi
, safi
));
5979 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5980 sizeof(base_xpath
), af_xpath
)
5982 return CMD_WARNING_CONFIG_FAILED
;
5984 snprintf(attr_xpath
, sizeof(attr_xpath
),
5985 "./%s/private-as/remove-private-as-all",
5986 bgp_afi_safi_get_container_str(afi
, safi
));
5988 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5990 return nb_cli_apply_changes(vty
, base_xpath
);
5993 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5994 no_neighbor_remove_private_as_all_hidden_cmd
,
5995 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5996 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5997 "Remove private ASNs in outbound updates\n"
5998 "Apply to all AS numbers\n")
6000 DEFUN_YANG (no_neighbor_remove_private_as_replace_as
,
6001 no_neighbor_remove_private_as_replace_as_cmd
,
6002 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
6006 "Remove private ASNs in outbound updates\n"
6007 "Replace private ASNs with our ASN in outbound updates\n")
6010 char base_xpath
[XPATH_MAXLEN
];
6011 char af_xpath
[XPATH_MAXLEN
];
6012 char attr_xpath
[XPATH_MAXLEN
];
6013 afi_t afi
= bgp_node_afi(vty
);
6014 safi_t safi
= bgp_node_safi(vty
);
6017 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6018 yang_afi_safi_value2identity(afi
, safi
));
6020 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6021 sizeof(base_xpath
), af_xpath
)
6023 return CMD_WARNING_CONFIG_FAILED
;
6025 snprintf(attr_xpath
, sizeof(attr_xpath
),
6026 "./%s/private-as/remove-private-as-replace",
6027 bgp_afi_safi_get_container_str(afi
, safi
));
6029 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6031 return nb_cli_apply_changes(vty
, base_xpath
);
6034 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
6035 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
6036 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
6037 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6038 "Remove private ASNs in outbound updates\n"
6039 "Replace private ASNs with our ASN in outbound updates\n")
6041 DEFUN_YANG (no_neighbor_remove_private_as_all_replace_as
,
6042 no_neighbor_remove_private_as_all_replace_as_cmd
,
6043 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6047 "Remove private ASNs in outbound updates\n"
6048 "Apply to all AS numbers\n"
6049 "Replace private ASNs with our ASN in outbound updates\n")
6052 char base_xpath
[XPATH_MAXLEN
];
6053 char af_xpath
[XPATH_MAXLEN
];
6054 char attr_xpath
[XPATH_MAXLEN
];
6055 afi_t afi
= bgp_node_afi(vty
);
6056 safi_t safi
= bgp_node_safi(vty
);
6059 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6060 yang_afi_safi_value2identity(afi
, safi
));
6062 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6063 sizeof(base_xpath
), af_xpath
)
6065 return CMD_WARNING_CONFIG_FAILED
;
6067 snprintf(attr_xpath
, sizeof(attr_xpath
),
6068 "./%s/private-as/remove-private-as-all-replace",
6069 bgp_afi_safi_get_container_str(afi
, safi
));
6071 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6073 return nb_cli_apply_changes(vty
, base_xpath
);
6077 no_neighbor_remove_private_as_all_replace_as
,
6078 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
6079 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6080 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6081 "Remove private ASNs in outbound updates\n"
6082 "Apply to all AS numbers\n"
6083 "Replace private ASNs with our ASN in outbound updates\n")
6086 /* neighbor send-community. */
6087 DEFUN_YANG (neighbor_send_community
,
6088 neighbor_send_community_cmd
,
6089 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6092 "Send Community attribute to this neighbor\n")
6096 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6098 PEER_FLAG_SEND_COMMUNITY
);
6101 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
6102 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6103 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6104 "Send Community attribute to this neighbor\n")
6106 DEFUN_YANG (no_neighbor_send_community
,
6107 no_neighbor_send_community_cmd
,
6108 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6112 "Send Community attribute to this neighbor\n")
6116 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6117 bgp_node_afi(vty
), bgp_node_safi(vty
),
6118 PEER_FLAG_SEND_COMMUNITY
);
6121 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
6122 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6123 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6124 "Send Community attribute to this neighbor\n")
6126 /* neighbor send-community extended. */
6127 DEFUN_YANG (neighbor_send_community_type
,
6128 neighbor_send_community_type_cmd
,
6129 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6132 "Send Community attribute to this neighbor\n"
6133 "Send Standard and Extended Community attributes\n"
6134 "Send Standard, Large and Extended Community attributes\n"
6135 "Send Extended Community attributes\n"
6136 "Send Standard Community attributes\n"
6137 "Send Large Community attributes\n")
6139 const char *type
= argv
[argc
- 1]->text
;
6140 char *peer_str
= argv
[1]->arg
;
6141 char base_xpath
[XPATH_MAXLEN
];
6142 char af_xpath
[XPATH_MAXLEN
];
6143 char std_xpath
[XPATH_MAXLEN
];
6144 char ext_xpath
[XPATH_MAXLEN
];
6145 char lrg_xpath
[XPATH_MAXLEN
];
6146 afi_t afi
= bgp_node_afi(vty
);
6147 safi_t safi
= bgp_node_safi(vty
);
6149 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6150 yang_afi_safi_value2identity(afi
, safi
));
6152 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6153 sizeof(base_xpath
), af_xpath
)
6155 return CMD_WARNING_CONFIG_FAILED
;
6157 if (strmatch(type
, "standard")) {
6158 snprintf(std_xpath
, sizeof(std_xpath
),
6159 "./%s/send-community/send-community",
6160 bgp_afi_safi_get_container_str(afi
, safi
));
6162 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6165 if (strmatch(type
, "extended")) {
6166 snprintf(ext_xpath
, sizeof(ext_xpath
),
6167 "./%s/send-community/send-ext-community",
6168 bgp_afi_safi_get_container_str(afi
, safi
));
6170 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6173 if (strmatch(type
, "large")) {
6174 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6175 "./%s/send-community/send-large-community",
6176 bgp_afi_safi_get_container_str(afi
, safi
));
6178 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "true");
6181 if (strmatch(type
, "both")) {
6182 snprintf(std_xpath
, sizeof(std_xpath
),
6183 "./%s/send-community/send-community",
6184 bgp_afi_safi_get_container_str(afi
, safi
));
6186 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6188 snprintf(ext_xpath
, sizeof(ext_xpath
),
6189 "./%s/send-community/send-ext-community",
6190 bgp_afi_safi_get_container_str(afi
, safi
));
6192 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6195 if (strmatch(type
, "all")) {
6196 snprintf(std_xpath
, sizeof(std_xpath
),
6197 "./%s/send-community/send-community",
6198 bgp_afi_safi_get_container_str(afi
, safi
));
6200 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6202 snprintf(ext_xpath
, sizeof(ext_xpath
),
6203 "./%s/send-community/send-ext-community",
6204 bgp_afi_safi_get_container_str(afi
, safi
));
6206 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6208 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6209 "./%s/send-community/send-large-community",
6210 bgp_afi_safi_get_container_str(afi
, safi
));
6212 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "true");
6215 return nb_cli_apply_changes(vty
, base_xpath
);
6219 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6220 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6221 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6222 "Send Community attribute to this neighbor\n"
6223 "Send Standard and Extended Community attributes\n"
6224 "Send Standard, Large and Extended Community attributes\n"
6225 "Send Extended Community attributes\n"
6226 "Send Standard Community attributes\n"
6227 "Send Large Community attributes\n")
6229 DEFUN_YANG (no_neighbor_send_community_type
,
6230 no_neighbor_send_community_type_cmd
,
6231 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6235 "Send Community attribute to this neighbor\n"
6236 "Send Standard and Extended Community attributes\n"
6237 "Send Standard, Large and Extended Community attributes\n"
6238 "Send Extended Community attributes\n"
6239 "Send Standard Community attributes\n"
6240 "Send Large Community attributes\n")
6242 const char *type
= argv
[argc
- 1]->text
;
6243 char *peer_str
= argv
[2]->arg
;
6244 char base_xpath
[XPATH_MAXLEN
];
6245 char af_xpath
[XPATH_MAXLEN
];
6246 char std_xpath
[XPATH_MAXLEN
];
6247 char ext_xpath
[XPATH_MAXLEN
];
6248 char lrg_xpath
[XPATH_MAXLEN
];
6249 afi_t afi
= bgp_node_afi(vty
);
6250 safi_t safi
= bgp_node_safi(vty
);
6252 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6253 yang_afi_safi_value2identity(afi
, safi
));
6255 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6256 sizeof(base_xpath
), af_xpath
)
6258 return CMD_WARNING_CONFIG_FAILED
;
6260 if (strmatch(type
, "standard")) {
6261 snprintf(std_xpath
, sizeof(std_xpath
),
6262 "./%s/send-community/send-community",
6263 bgp_afi_safi_get_container_str(afi
, safi
));
6265 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6268 if (strmatch(type
, "extended")) {
6269 snprintf(ext_xpath
, sizeof(ext_xpath
),
6270 "./%s/send-community/send-ext-community",
6271 bgp_afi_safi_get_container_str(afi
, safi
));
6273 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6276 if (strmatch(type
, "large")) {
6277 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6278 "./%s/send-community/send-large-community",
6279 bgp_afi_safi_get_container_str(afi
, safi
));
6281 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "false");
6284 if (strmatch(type
, "both")) {
6285 snprintf(std_xpath
, sizeof(std_xpath
),
6286 "./%s/send-community/send-community",
6287 bgp_afi_safi_get_container_str(afi
, safi
));
6289 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6291 snprintf(ext_xpath
, sizeof(ext_xpath
),
6292 "./%s/send-community/send-ext-community",
6293 bgp_afi_safi_get_container_str(afi
, safi
));
6295 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6298 if (strmatch(type
, "all")) {
6299 snprintf(std_xpath
, sizeof(std_xpath
),
6300 "./%s/send-community/send-community",
6301 bgp_afi_safi_get_container_str(afi
, safi
));
6303 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6305 snprintf(ext_xpath
, sizeof(ext_xpath
),
6306 "./%s/send-community/send-ext-community",
6307 bgp_afi_safi_get_container_str(afi
, safi
));
6309 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6311 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6312 "./%s/send-community/send-large-community",
6313 bgp_afi_safi_get_container_str(afi
, safi
));
6315 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "false");
6318 return nb_cli_apply_changes(vty
, base_xpath
);
6322 no_neighbor_send_community_type
,
6323 no_neighbor_send_community_type_hidden_cmd
,
6324 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6325 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6326 "Send Community attribute to this neighbor\n"
6327 "Send Standard and Extended Community attributes\n"
6328 "Send Standard, Large and Extended Community attributes\n"
6329 "Send Extended Community attributes\n"
6330 "Send Standard Community attributes\n"
6331 "Send Large Community attributes\n")
6333 /* neighbor soft-reconfig. */
6334 DEFUN_YANG (neighbor_soft_reconfiguration
,
6335 neighbor_soft_reconfiguration_cmd
,
6336 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6337 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6338 "Per neighbor soft reconfiguration\n"
6339 "Allow inbound soft reconfiguration for this neighbor\n")
6342 char base_xpath
[XPATH_MAXLEN
];
6343 char af_xpath
[XPATH_MAXLEN
];
6344 char soft_xpath
[XPATH_MAXLEN
];
6345 afi_t afi
= bgp_node_afi(vty
);
6346 safi_t safi
= bgp_node_safi(vty
);
6349 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6350 yang_afi_safi_value2identity(afi
, safi
));
6352 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6353 sizeof(base_xpath
), af_xpath
)
6355 return CMD_WARNING_CONFIG_FAILED
;
6357 snprintf(soft_xpath
, sizeof(soft_xpath
), "./%s/soft-reconfiguration",
6358 bgp_afi_safi_get_container_str(afi
, safi
));
6360 nb_cli_enqueue_change(vty
, soft_xpath
, NB_OP_MODIFY
, "true");
6362 return nb_cli_apply_changes(vty
, base_xpath
);
6365 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6366 neighbor_soft_reconfiguration_hidden_cmd
,
6367 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6368 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6369 "Per neighbor soft reconfiguration\n"
6370 "Allow inbound soft reconfiguration for this neighbor\n")
6372 DEFUN_YANG (no_neighbor_soft_reconfiguration
,
6373 no_neighbor_soft_reconfiguration_cmd
,
6374 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6375 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6376 "Per neighbor soft reconfiguration\n"
6377 "Allow inbound soft reconfiguration for this neighbor\n")
6380 char base_xpath
[XPATH_MAXLEN
];
6381 char af_xpath
[XPATH_MAXLEN
];
6382 char soft_xpath
[XPATH_MAXLEN
];
6383 afi_t afi
= bgp_node_afi(vty
);
6384 safi_t safi
= bgp_node_safi(vty
);
6386 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6387 yang_afi_safi_value2identity(afi
, safi
));
6389 snprintf(soft_xpath
, sizeof(soft_xpath
), "./%s/soft-reconfiguration",
6390 bgp_afi_safi_get_container_str(afi
, safi
));
6392 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6393 sizeof(base_xpath
), af_xpath
)
6395 return CMD_WARNING_CONFIG_FAILED
;
6397 nb_cli_enqueue_change(vty
, soft_xpath
, NB_OP_MODIFY
, "false");
6399 return nb_cli_apply_changes(vty
, base_xpath
);
6402 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6403 no_neighbor_soft_reconfiguration_hidden_cmd
,
6404 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6405 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6406 "Per neighbor soft reconfiguration\n"
6407 "Allow inbound soft reconfiguration for this neighbor\n")
6409 DEFUN_YANG (neighbor_route_reflector_client
,
6410 neighbor_route_reflector_client_cmd
,
6411 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6414 "Configure a neighbor as Route Reflector client\n")
6417 char base_xpath
[XPATH_MAXLEN
];
6418 char af_xpath
[XPATH_MAXLEN
];
6419 char attr_xpath
[XPATH_MAXLEN
];
6420 afi_t afi
= bgp_node_afi(vty
);
6421 safi_t safi
= bgp_node_safi(vty
);
6423 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6424 yang_afi_safi_value2identity(afi
, safi
));
6426 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6427 sizeof(base_xpath
), af_xpath
)
6429 return CMD_WARNING_CONFIG_FAILED
;
6431 snprintf(attr_xpath
, sizeof(attr_xpath
),
6432 "./%s/route-reflector/route-reflector-client",
6433 bgp_afi_safi_get_container_str(afi
, safi
));
6435 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6437 return nb_cli_apply_changes(vty
, base_xpath
);
6440 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6441 neighbor_route_reflector_client_hidden_cmd
,
6442 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6443 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6444 "Configure a neighbor as Route Reflector client\n")
6446 DEFUN_YANG (no_neighbor_route_reflector_client
,
6447 no_neighbor_route_reflector_client_cmd
,
6448 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6452 "Configure a neighbor as Route Reflector client\n")
6455 char base_xpath
[XPATH_MAXLEN
];
6456 char af_xpath
[XPATH_MAXLEN
];
6457 char attr_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
, argv
[idx_peer
]->arg
, base_xpath
,
6465 sizeof(base_xpath
), af_xpath
)
6467 return CMD_WARNING_CONFIG_FAILED
;
6469 snprintf(attr_xpath
, sizeof(attr_xpath
),
6470 "./%s/route-reflector/route-reflector-client",
6471 bgp_afi_safi_get_container_str(afi
, safi
));
6473 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6475 return nb_cli_apply_changes(vty
, base_xpath
);
6478 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6479 no_neighbor_route_reflector_client_hidden_cmd
,
6480 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6481 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6482 "Configure a neighbor as Route Reflector client\n")
6484 /* neighbor route-server-client. */
6485 DEFUN_YANG (neighbor_route_server_client
,
6486 neighbor_route_server_client_cmd
,
6487 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6490 "Configure a neighbor as Route Server client\n")
6493 char base_xpath
[XPATH_MAXLEN
];
6494 char af_xpath
[XPATH_MAXLEN
];
6495 char attr_xpath
[XPATH_MAXLEN
];
6496 afi_t afi
= bgp_node_afi(vty
);
6497 safi_t safi
= bgp_node_safi(vty
);
6499 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6500 yang_afi_safi_value2identity(afi
, safi
));
6502 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6503 sizeof(base_xpath
), af_xpath
)
6505 return CMD_WARNING_CONFIG_FAILED
;
6507 snprintf(attr_xpath
, sizeof(attr_xpath
),
6508 "./%s/route-server/route-server-client",
6509 bgp_afi_safi_get_container_str(afi
, safi
));
6511 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6513 return nb_cli_apply_changes(vty
, base_xpath
);
6516 ALIAS_HIDDEN(neighbor_route_server_client
,
6517 neighbor_route_server_client_hidden_cmd
,
6518 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6519 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6520 "Configure a neighbor as Route Server client\n")
6522 DEFUN_YANG (no_neighbor_route_server_client
,
6523 no_neighbor_route_server_client_cmd
,
6524 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6528 "Configure a neighbor as Route Server client\n")
6531 char base_xpath
[XPATH_MAXLEN
];
6532 char af_xpath
[XPATH_MAXLEN
];
6533 char attr_xpath
[XPATH_MAXLEN
];
6534 afi_t afi
= bgp_node_afi(vty
);
6535 safi_t safi
= bgp_node_safi(vty
);
6537 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6538 yang_afi_safi_value2identity(afi
, safi
));
6540 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6541 sizeof(base_xpath
), af_xpath
)
6543 return CMD_WARNING_CONFIG_FAILED
;
6545 snprintf(attr_xpath
, sizeof(attr_xpath
),
6546 "./%s/route-server/route-server-client",
6547 bgp_afi_safi_get_container_str(afi
, safi
));
6549 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6551 return nb_cli_apply_changes(vty
, base_xpath
);
6554 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6555 no_neighbor_route_server_client_hidden_cmd
,
6556 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6557 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6558 "Configure a neighbor as Route Server client\n")
6560 DEFUN (neighbor_nexthop_local_unchanged
,
6561 neighbor_nexthop_local_unchanged_cmd
,
6562 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6565 "Configure treatment of outgoing link-local nexthop attribute\n"
6566 "Leave link-local nexthop unchanged for this peer\n")
6569 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6571 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6574 DEFUN (no_neighbor_nexthop_local_unchanged
,
6575 no_neighbor_nexthop_local_unchanged_cmd
,
6576 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6580 "Configure treatment of outgoing link-local-nexthop attribute\n"
6581 "Leave link-local nexthop unchanged for this peer\n")
6584 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6585 bgp_node_afi(vty
), bgp_node_safi(vty
),
6586 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6589 DEFUN_YANG (neighbor_attr_unchanged
,
6590 neighbor_attr_unchanged_cmd
,
6591 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6594 "BGP attribute is propagated unchanged to this neighbor\n"
6595 "As-path attribute\n"
6596 "Nexthop attribute\n"
6600 char *peer_str
= argv
[1]->arg
;
6601 bool aspath
= false;
6602 bool nexthop
= false;
6604 afi_t afi
= bgp_node_afi(vty
);
6605 safi_t safi
= bgp_node_safi(vty
);
6606 char base_xpath
[XPATH_MAXLEN
];
6607 char af_xpath
[XPATH_MAXLEN
];
6608 char as_xpath
[XPATH_MAXLEN
];
6609 char nxthop_xpath
[XPATH_MAXLEN
];
6610 char med_xpath
[XPATH_MAXLEN
];
6612 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6613 yang_afi_safi_value2identity(afi
, safi
));
6615 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6616 sizeof(base_xpath
), af_xpath
)
6618 return CMD_WARNING_CONFIG_FAILED
;
6620 if (argv_find(argv
, argc
, "as-path", &idx
))
6624 if (argv_find(argv
, argc
, "next-hop", &idx
))
6628 if (argv_find(argv
, argc
, "med", &idx
))
6631 snprintf(as_xpath
, sizeof(as_xpath
),
6632 "./%s/attr-unchanged/as-path-unchanged",
6633 bgp_afi_safi_get_container_str(afi
, safi
));
6634 snprintf(nxthop_xpath
, sizeof(nxthop_xpath
),
6635 "./%s/attr-unchanged/next-hop-unchanged",
6636 bgp_afi_safi_get_container_str(afi
, safi
));
6637 snprintf(med_xpath
, sizeof(med_xpath
),
6638 "./%s/attr-unchanged/med-unchanged",
6639 bgp_afi_safi_get_container_str(afi
, safi
));
6641 /* no flags means all of them! */
6642 if (!aspath
&& !nexthop
&& !med
) {
6643 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "true");
6644 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "true");
6645 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "true");
6648 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
,
6651 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
,
6655 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
,
6658 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
,
6662 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
,
6665 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
,
6669 return nb_cli_apply_changes(vty
, base_xpath
);
6673 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6674 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6675 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6676 "BGP attribute is propagated unchanged to this neighbor\n"
6677 "As-path attribute\n"
6678 "Nexthop attribute\n"
6681 DEFUN_YANG (no_neighbor_attr_unchanged
,
6682 no_neighbor_attr_unchanged_cmd
,
6683 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6687 "BGP attribute is propagated unchanged to this neighbor\n"
6688 "As-path attribute\n"
6689 "Nexthop attribute\n"
6693 char *peer_str
= argv
[2]->arg
;
6694 bool aspath
= false;
6695 bool nexthop
= false;
6697 afi_t afi
= bgp_node_afi(vty
);
6698 safi_t safi
= bgp_node_safi(vty
);
6699 char base_xpath
[XPATH_MAXLEN
];
6700 char af_xpath
[XPATH_MAXLEN
];
6701 char as_xpath
[XPATH_MAXLEN
];
6702 char nxthop_xpath
[XPATH_MAXLEN
];
6703 char med_xpath
[XPATH_MAXLEN
];
6705 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6706 yang_afi_safi_value2identity(afi
, safi
));
6708 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6709 sizeof(base_xpath
), af_xpath
)
6711 return CMD_WARNING_CONFIG_FAILED
;
6713 if (argv_find(argv
, argc
, "as-path", &idx
))
6717 if (argv_find(argv
, argc
, "next-hop", &idx
))
6721 if (argv_find(argv
, argc
, "med", &idx
))
6724 snprintf(as_xpath
, sizeof(as_xpath
),
6725 "./%s/attr-unchanged/as-path-unchanged",
6726 bgp_afi_safi_get_container_str(afi
, safi
));
6727 snprintf(nxthop_xpath
, sizeof(nxthop_xpath
),
6728 "./%s/attr-unchanged/next-hop-unchanged",
6729 bgp_afi_safi_get_container_str(afi
, safi
));
6730 snprintf(med_xpath
, sizeof(med_xpath
),
6731 "./%s/attr-unchanged/med-unchanged",
6732 bgp_afi_safi_get_container_str(afi
, safi
));
6734 /* no flags means all of them! */
6735 if (!aspath
&& !nexthop
&& !med
) {
6736 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "false");
6737 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "false");
6738 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "false");
6742 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "false");
6745 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "false");
6748 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "false");
6750 return nb_cli_apply_changes(vty
, base_xpath
);
6754 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6755 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6756 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6757 "BGP attribute is propagated unchanged to this neighbor\n"
6758 "As-path attribute\n"
6759 "Nexthop attribute\n"
6762 /* neighbor ebgp-multihop. */
6763 DEFUN_YANG (neighbor_ebgp_multihop
,
6764 neighbor_ebgp_multihop_cmd
,
6765 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6766 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6767 "Allow EBGP neighbors not on directly connected networks\n")
6770 char base_xpath
[XPATH_MAXLEN
];
6772 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6773 sizeof(base_xpath
), NULL
)
6775 return CMD_WARNING_CONFIG_FAILED
;
6777 nb_cli_enqueue_change(vty
, "./ebgp-multihop/enabled", NB_OP_MODIFY
,
6780 return nb_cli_apply_changes(vty
, base_xpath
);
6783 DEFUN_YANG (neighbor_ebgp_multihop_ttl
,
6784 neighbor_ebgp_multihop_ttl_cmd
,
6785 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6786 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6787 "Allow EBGP neighbors not on directly connected networks\n"
6788 "maximum hop count\n")
6792 char base_xpath
[XPATH_MAXLEN
];
6794 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6795 sizeof(base_xpath
), NULL
)
6797 return CMD_WARNING_CONFIG_FAILED
;
6799 nb_cli_enqueue_change(vty
, "./ebgp-multihop/multihop-ttl", NB_OP_MODIFY
,
6800 argv
[idx_number
]->arg
);
6802 return nb_cli_apply_changes(vty
, base_xpath
);
6805 DEFUN_YANG (no_neighbor_ebgp_multihop
,
6806 no_neighbor_ebgp_multihop_cmd
,
6807 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6808 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6809 "Allow EBGP neighbors not on directly connected networks\n"
6810 "maximum hop count\n")
6813 char base_xpath
[XPATH_MAXLEN
];
6815 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6816 sizeof(base_xpath
), NULL
)
6818 return CMD_WARNING_CONFIG_FAILED
;
6821 nb_cli_enqueue_change(vty
, "./ebgp-multihop/multihop-ttl",
6822 NB_OP_DESTROY
, NULL
);
6824 nb_cli_enqueue_change(vty
, "./ebgp-multihop/enabled",
6825 NB_OP_MODIFY
, "false");
6827 return nb_cli_apply_changes(vty
, base_xpath
);
6831 /* disable-connected-check */
6832 DEFUN_YANG (neighbor_disable_connected_check
,
6833 neighbor_disable_connected_check_cmd
,
6834 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6835 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6836 "one-hop away EBGP peer using loopback address\n"
6837 "Enforce EBGP neighbors perform multihop\n")
6840 char base_xpath
[XPATH_MAXLEN
];
6842 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6843 sizeof(base_xpath
), NULL
)
6845 return CMD_WARNING_CONFIG_FAILED
;
6847 nb_cli_enqueue_change(vty
, "./ebgp-multihop/disable-connected-check",
6848 NB_OP_MODIFY
, "true");
6850 return nb_cli_apply_changes(vty
, base_xpath
);
6853 DEFUN_YANG (no_neighbor_disable_connected_check
,
6854 no_neighbor_disable_connected_check_cmd
,
6855 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6856 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6857 "one-hop away EBGP peer using loopback address\n"
6858 "Enforce EBGP neighbors perform multihop\n")
6861 char base_xpath
[XPATH_MAXLEN
];
6863 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6864 sizeof(base_xpath
), NULL
)
6866 return CMD_WARNING_CONFIG_FAILED
;
6868 nb_cli_enqueue_change(vty
, "./ebgp-multihop/disable-connected-check",
6869 NB_OP_MODIFY
, "false");
6871 return nb_cli_apply_changes(vty
, base_xpath
);
6875 /* enforce-first-as */
6876 DEFUN_YANG (neighbor_enforce_first_as
,
6877 neighbor_enforce_first_as_cmd
,
6878 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6879 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6880 "Enforce the first AS for EBGP routes\n")
6883 char base_xpath
[XPATH_MAXLEN
];
6885 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6886 sizeof(base_xpath
), NULL
)
6888 return CMD_WARNING_CONFIG_FAILED
;
6890 nb_cli_enqueue_change(vty
, "./enforce-first-as", NB_OP_MODIFY
, "true");
6892 return nb_cli_apply_changes(vty
, base_xpath
);
6895 DEFUN_YANG (no_neighbor_enforce_first_as
,
6896 no_neighbor_enforce_first_as_cmd
,
6897 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6898 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6899 "Enforce the first AS for EBGP routes\n")
6902 char base_xpath
[XPATH_MAXLEN
];
6904 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6905 sizeof(base_xpath
), NULL
)
6907 return CMD_WARNING_CONFIG_FAILED
;
6909 nb_cli_enqueue_change(vty
, "./enforce-first-as", NB_OP_MODIFY
, "false");
6911 return nb_cli_apply_changes(vty
, base_xpath
);
6914 static int peer_and_group_lookup_nb(struct vty
*vty
, const char *peer_str
,
6915 char *base_xpath
, int xpath_len
,
6919 char num_xpath
[XPATH_MAXLEN
];
6920 char unnbr_xpath
[XPATH_MAXLEN
];
6921 char prgrp_xpath
[XPATH_MAXLEN
];
6923 if (str2sockunion(peer_str
, &su
) == 0) {
6924 snprintf(num_xpath
, sizeof(num_xpath
),
6925 "/neighbors/neighbor[remote-address='%s']", peer_str
);
6926 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
6927 VTY_CURR_XPATH
, num_xpath
)) {
6928 snprintf(base_xpath
, xpath_len
,
6929 FRR_BGP_NEIGHBOR_NUM_XPATH
, peer_str
,
6930 xpath
? xpath
: "");
6933 "%% Specify remote-as or peer-group commands first\n");
6938 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
6939 "/neighbors/unnumbered-neighbor[interface='%s']",
6942 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
6943 "/peer-groups/peer-group[peer-group-name='%s']",
6946 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
6947 VTY_CURR_XPATH
, unnbr_xpath
)) {
6948 snprintf(base_xpath
, xpath_len
,
6949 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, peer_str
,
6950 xpath
? xpath
: "");
6951 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
,
6952 "%s%s", VTY_CURR_XPATH
,
6954 snprintf(base_xpath
, xpath_len
,
6955 FRR_BGP_PEER_GROUP_XPATH
, peer_str
,
6956 xpath
? xpath
: "");
6959 "%% Create the peer-group or interface first\n");
6967 DEFUN_YANG (neighbor_description
,
6968 neighbor_description_cmd
,
6969 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6970 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6971 "Neighbor specific description\n"
6972 "Up to 80 characters describing this neighbor\n")
6977 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 str
= argv_concat(argv
, argc
, idx_line
);
6987 nb_cli_enqueue_change(vty
, "./description", NB_OP_MODIFY
, str
);
6989 ret
= nb_cli_apply_changes(vty
, base_xpath
);
6991 XFREE(MTYPE_TMP
, str
);
6996 DEFUN_YANG (no_neighbor_description
,
6997 no_neighbor_description_cmd
,
6998 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6999 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7000 "Neighbor specific description\n")
7003 char base_xpath
[XPATH_MAXLEN
];
7005 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7006 sizeof(base_xpath
), NULL
)
7008 return CMD_WARNING_CONFIG_FAILED
;
7010 nb_cli_enqueue_change(vty
, "./description", NB_OP_DESTROY
, NULL
);
7012 return nb_cli_apply_changes(vty
, base_xpath
);
7015 ALIAS_YANG(no_neighbor_description
, no_neighbor_description_comment_cmd
,
7016 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
7017 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7018 "Neighbor specific description\n"
7019 "Up to 80 characters describing this neighbor\n")
7021 #define BGP_UPDATE_SOURCE_HELP_STR \
7024 "Interface name (requires zebra to be running)\n"
7026 DEFUN_YANG (neighbor_update_source
,
7027 neighbor_update_source_cmd
,
7028 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
7029 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7030 "Source of routing updates\n"
7031 BGP_UPDATE_SOURCE_HELP_STR
)
7036 char base_xpath
[XPATH_MAXLEN
];
7038 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7039 sizeof(base_xpath
), NULL
)
7041 return CMD_WARNING_CONFIG_FAILED
;
7043 if (str2sockunion(argv
[idx_peer_2
]->arg
, &su
) == 0)
7044 nb_cli_enqueue_change(vty
, "./update-source/ip", NB_OP_MODIFY
,
7045 argv
[idx_peer_2
]->arg
);
7047 nb_cli_enqueue_change(vty
, "./update-source/interface",
7048 NB_OP_MODIFY
, argv
[idx_peer_2
]->arg
);
7050 return nb_cli_apply_changes(vty
, base_xpath
);
7053 DEFUN_YANG (no_neighbor_update_source
,
7054 no_neighbor_update_source_cmd
,
7055 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
7058 "Source of routing updates\n"
7059 BGP_UPDATE_SOURCE_HELP_STR
)
7062 char base_xpath
[XPATH_MAXLEN
];
7064 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7065 sizeof(base_xpath
), NULL
)
7067 return CMD_WARNING_CONFIG_FAILED
;
7069 nb_cli_enqueue_change(vty
, "./update-source/ip", NB_OP_DESTROY
, NULL
);
7070 nb_cli_enqueue_change(vty
, "./update-source/interface", NB_OP_DESTROY
,
7073 return nb_cli_apply_changes(vty
, base_xpath
);
7076 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
7077 afi_t afi
, safi_t safi
,
7078 const char *rmap
, int set
)
7082 struct route_map
*route_map
= NULL
;
7084 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
7086 return CMD_WARNING_CONFIG_FAILED
;
7090 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
7091 ret
= peer_default_originate_set(peer
, afi
, safi
,
7094 ret
= peer_default_originate_unset(peer
, afi
, safi
);
7096 return bgp_vty_return(vty
, ret
);
7099 /* neighbor default-originate. */
7100 DEFUN (neighbor_default_originate
,
7101 neighbor_default_originate_cmd
,
7102 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
7105 "Originate default route to this neighbor\n")
7108 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
7110 bgp_node_safi(vty
), NULL
, 1);
7113 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
7114 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
7115 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7116 "Originate default route to this neighbor\n")
7118 DEFUN (neighbor_default_originate_rmap
,
7119 neighbor_default_originate_rmap_cmd
,
7120 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
7123 "Originate default route to this neighbor\n"
7124 "Route-map to specify criteria to originate default\n"
7129 return peer_default_originate_set_vty(
7130 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7131 argv
[idx_word
]->arg
, 1);
7135 neighbor_default_originate_rmap
,
7136 neighbor_default_originate_rmap_hidden_cmd
,
7137 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
7138 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7139 "Originate default route to this neighbor\n"
7140 "Route-map to specify criteria to originate default\n"
7143 DEFUN (no_neighbor_default_originate
,
7144 no_neighbor_default_originate_cmd
,
7145 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
7149 "Originate default route to this neighbor\n"
7150 "Route-map to specify criteria to originate default\n"
7154 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
7156 bgp_node_safi(vty
), NULL
, 0);
7160 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
7161 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
7162 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7163 "Originate default route to this neighbor\n"
7164 "Route-map to specify criteria to originate default\n"
7168 /* Set specified peer's BGP port. */
7169 DEFUN_YANG (neighbor_port
,
7171 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
7174 "Neighbor's BGP port\n"
7175 "TCP port number\n")
7179 char base_xpath
[XPATH_MAXLEN
];
7181 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7182 argv
[idx_ip
]->arg
, "");
7184 nb_cli_enqueue_change(vty
, "./local-port", NB_OP_MODIFY
,
7185 argv
[idx_number
]->arg
);
7187 return nb_cli_apply_changes(vty
, base_xpath
);
7190 DEFUN_YANG (no_neighbor_port
,
7191 no_neighbor_port_cmd
,
7192 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
7193 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR
7194 "Neighbor's BGP port\n"
7195 "TCP port number\n")
7198 char base_xpath
[XPATH_MAXLEN
];
7200 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7201 argv
[idx_ip
]->arg
, "");
7203 nb_cli_enqueue_change(vty
, "./local-port", NB_OP_DESTROY
, NULL
);
7205 return nb_cli_apply_changes(vty
, base_xpath
);
7208 DEFUN_YANG (neighbor_weight
,
7209 neighbor_weight_cmd
,
7210 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7211 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7212 "Set default weight for routes from this neighbor\n"
7217 char base_xpath
[XPATH_MAXLEN
];
7218 char af_xpath
[XPATH_MAXLEN
];
7219 char attr_xpath
[XPATH_MAXLEN
];
7220 afi_t afi
= bgp_node_afi(vty
);
7221 safi_t safi
= bgp_node_safi(vty
);
7223 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
7224 yang_afi_safi_value2identity(afi
, safi
));
7226 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7227 sizeof(base_xpath
), af_xpath
)
7229 return CMD_WARNING_CONFIG_FAILED
;
7231 snprintf(attr_xpath
, sizeof(attr_xpath
), "./%s/weight/weight-attribute",
7232 bgp_afi_safi_get_container_str(afi
, safi
));
7234 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
,
7235 argv
[idx_number
]->arg
);
7237 return nb_cli_apply_changes(vty
, base_xpath
);
7240 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
7241 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7242 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7243 "Set default weight for routes from this neighbor\n"
7246 DEFUN_YANG (no_neighbor_weight
,
7247 no_neighbor_weight_cmd
,
7248 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7249 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7250 "Set default weight for routes from this neighbor\n"
7254 char base_xpath
[XPATH_MAXLEN
];
7255 char af_xpath
[XPATH_MAXLEN
];
7256 char attr_xpath
[XPATH_MAXLEN
];
7257 afi_t afi
= bgp_node_afi(vty
);
7258 safi_t safi
= bgp_node_safi(vty
);
7260 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
7261 yang_afi_safi_value2identity(afi
, safi
));
7263 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7264 sizeof(base_xpath
), af_xpath
)
7266 return CMD_WARNING_CONFIG_FAILED
;
7268 snprintf(attr_xpath
, sizeof(attr_xpath
), "./%s/weight/weight-attribute",
7269 bgp_afi_safi_get_container_str(afi
, safi
));
7271 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_DESTROY
, NULL
);
7273 return nb_cli_apply_changes(vty
, base_xpath
);
7276 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
7277 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7278 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7279 "Set default weight for routes from this neighbor\n"
7283 /* Override capability negotiation. */
7284 DEFUN_YANG (neighbor_override_capability
,
7285 neighbor_override_capability_cmd
,
7286 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7289 "Override capability negotiation result\n")
7292 char base_xpath
[XPATH_MAXLEN
];
7294 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7295 sizeof(base_xpath
), NULL
)
7297 return CMD_WARNING_CONFIG_FAILED
;
7299 nb_cli_enqueue_change(
7300 vty
, "./capability-options/override-capability",
7301 NB_OP_MODIFY
, "true");
7303 return nb_cli_apply_changes(vty
, base_xpath
);
7306 DEFUN_YANG (no_neighbor_override_capability
,
7307 no_neighbor_override_capability_cmd
,
7308 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7312 "Override capability negotiation result\n")
7315 char base_xpath
[XPATH_MAXLEN
];
7317 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7318 sizeof(base_xpath
), NULL
)
7320 return CMD_WARNING_CONFIG_FAILED
;
7322 nb_cli_enqueue_change(
7323 vty
, "./capability-options/override-capability",
7324 NB_OP_MODIFY
, "false");
7326 return nb_cli_apply_changes(vty
, base_xpath
);
7329 DEFUN_YANG (neighbor_strict_capability
,
7330 neighbor_strict_capability_cmd
,
7331 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7334 "Strict capability negotiation match\n")
7337 char base_xpath
[XPATH_MAXLEN
];
7339 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7340 sizeof(base_xpath
), NULL
)
7342 return CMD_WARNING_CONFIG_FAILED
;
7344 nb_cli_enqueue_change(
7345 vty
, "./capability-options/strict-capability",
7346 NB_OP_MODIFY
, "true");
7348 return nb_cli_apply_changes(vty
, base_xpath
);
7351 DEFUN_YANG (no_neighbor_strict_capability
,
7352 no_neighbor_strict_capability_cmd
,
7353 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7357 "Strict capability negotiation match\n")
7360 char base_xpath
[XPATH_MAXLEN
];
7362 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7363 sizeof(base_xpath
), NULL
)
7365 return CMD_WARNING_CONFIG_FAILED
;
7367 nb_cli_enqueue_change(
7368 vty
, "./capability-options/strict-capability",
7369 NB_OP_MODIFY
, "false");
7371 return nb_cli_apply_changes(vty
, base_xpath
);
7374 DEFUN_YANG (neighbor_timers
,
7375 neighbor_timers_cmd
,
7376 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7377 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7378 "BGP per neighbor timers\n"
7379 "Keepalive interval\n"
7384 int idx_number_2
= 4;
7385 char base_xpath
[XPATH_MAXLEN
];
7387 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7388 sizeof(base_xpath
), NULL
)
7390 return CMD_WARNING_CONFIG_FAILED
;
7392 nb_cli_enqueue_change(vty
, "./timers/keepalive", NB_OP_MODIFY
,
7393 argv
[idx_number
]->arg
);
7395 nb_cli_enqueue_change(vty
, "./timers/hold-time", NB_OP_MODIFY
,
7396 argv
[idx_number_2
]->arg
);
7398 return nb_cli_apply_changes(vty
, base_xpath
);
7401 DEFUN_YANG (no_neighbor_timers
,
7402 no_neighbor_timers_cmd
,
7403 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7404 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7405 "BGP per neighbor timers\n"
7406 "Keepalive interval\n"
7410 char base_xpath
[XPATH_MAXLEN
];
7412 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7413 sizeof(base_xpath
), NULL
)
7415 return CMD_WARNING_CONFIG_FAILED
;
7417 nb_cli_enqueue_change(vty
, "./timers/hold-time", NB_OP_DESTROY
, NULL
);
7419 nb_cli_enqueue_change(vty
, "./timers/keepalive", NB_OP_DESTROY
, NULL
);
7421 return nb_cli_apply_changes(vty
, base_xpath
);
7424 DEFUN_YANG (neighbor_timers_connect
,
7425 neighbor_timers_connect_cmd
,
7426 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7427 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7428 "BGP per neighbor timers\n"
7429 "BGP connect timer\n"
7434 char base_xpath
[XPATH_MAXLEN
];
7436 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7437 sizeof(base_xpath
), NULL
)
7439 return CMD_WARNING_CONFIG_FAILED
;
7441 nb_cli_enqueue_change(vty
, "./timers/connect-time", NB_OP_MODIFY
,
7442 argv
[idx_number
]->arg
);
7444 return nb_cli_apply_changes(vty
, base_xpath
);
7447 DEFUN_YANG (no_neighbor_timers_connect
,
7448 no_neighbor_timers_connect_cmd
,
7449 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7450 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7451 "BGP per neighbor timers\n"
7452 "BGP connect timer\n"
7456 char base_xpath
[XPATH_MAXLEN
];
7458 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7459 sizeof(base_xpath
), NULL
)
7461 return CMD_WARNING_CONFIG_FAILED
;
7463 nb_cli_enqueue_change(vty
, "./timers/connect-time", NB_OP_DESTROY
,
7466 return nb_cli_apply_changes(vty
, base_xpath
);
7469 DEFPY (neighbor_timers_delayopen
,
7470 neighbor_timers_delayopen_cmd
,
7471 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7474 "BGP per neighbor timers\n"
7475 "RFC 4271 DelayOpenTimer\n"
7476 "DelayOpenTime timer interval\n")
7480 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7482 return CMD_WARNING_CONFIG_FAILED
;
7485 if (peer_timers_delayopen_unset(peer
))
7486 return CMD_WARNING_CONFIG_FAILED
;
7488 if (peer_timers_delayopen_set(peer
, interval
))
7489 return CMD_WARNING_CONFIG_FAILED
;
7495 DEFPY (no_neighbor_timers_delayopen
,
7496 no_neighbor_timers_delayopen_cmd
,
7497 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7501 "BGP per neighbor timers\n"
7502 "RFC 4271 DelayOpenTimer\n"
7503 "DelayOpenTime timer interval\n")
7507 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7509 return CMD_WARNING_CONFIG_FAILED
;
7511 if (peer_timers_delayopen_unset(peer
))
7512 return CMD_WARNING_CONFIG_FAILED
;
7517 DEFUN_YANG (neighbor_advertise_interval
,
7518 neighbor_advertise_interval_cmd
,
7519 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7520 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7521 "Minimum interval between sending BGP routing updates\n"
7522 "time in seconds\n")
7526 char base_xpath
[XPATH_MAXLEN
];
7528 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7529 sizeof(base_xpath
), NULL
)
7531 return CMD_WARNING_CONFIG_FAILED
;
7533 nb_cli_enqueue_change(vty
, "./timers/advertise-interval", NB_OP_MODIFY
,
7534 argv
[idx_number
]->arg
);
7536 return nb_cli_apply_changes(vty
, base_xpath
);
7539 DEFUN_YANG (no_neighbor_advertise_interval
,
7540 no_neighbor_advertise_interval_cmd
,
7541 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7542 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7543 "Minimum interval between sending BGP routing updates\n"
7544 "time in seconds\n")
7547 char base_xpath
[XPATH_MAXLEN
];
7549 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7550 sizeof(base_xpath
), NULL
)
7552 return CMD_WARNING_CONFIG_FAILED
;
7554 nb_cli_enqueue_change(vty
, "./timers/advertise-interval", NB_OP_DESTROY
,
7557 return nb_cli_apply_changes(vty
, base_xpath
);
7561 /* Time to wait before processing route-map updates */
7562 DEFUN (bgp_set_route_map_delay_timer
,
7563 bgp_set_route_map_delay_timer_cmd
,
7564 "bgp route-map delay-timer (0-600)",
7566 "BGP route-map delay timer\n"
7567 "Time in secs to wait before processing route-map changes\n"
7568 "0 disables the timer, no route updates happen when route-maps change\n")
7571 uint32_t rmap_delay_timer
;
7573 if (argv
[idx_number
]->arg
) {
7574 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7575 bm
->rmap_update_timer
= rmap_delay_timer
;
7577 /* if the dynamic update handling is being disabled, and a timer
7579 * running, stop the timer and act as if the timer has already
7582 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7583 BGP_TIMER_OFF(bm
->t_rmap_update
);
7584 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7589 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7590 return CMD_WARNING_CONFIG_FAILED
;
7594 DEFUN (no_bgp_set_route_map_delay_timer
,
7595 no_bgp_set_route_map_delay_timer_cmd
,
7596 "no bgp route-map delay-timer [(0-600)]",
7599 "Default BGP route-map delay timer\n"
7600 "Reset to default time to wait for processing route-map changes\n"
7601 "0 disables the timer, no route updates happen when route-maps change\n")
7604 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7609 DEFUN_YANG (neighbor_interface
,
7610 neighbor_interface_cmd
,
7611 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7612 NEIGHBOR_STR NEIGHBOR_ADDR_STR
7618 char base_xpath
[XPATH_MAXLEN
];
7620 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7621 argv
[idx_ip
]->arg
, "");
7623 nb_cli_enqueue_change(vty
, "./local-interface", NB_OP_MODIFY
,
7624 argv
[idx_word
]->arg
);
7626 return nb_cli_apply_changes(vty
, base_xpath
);
7629 DEFUN_YANG (no_neighbor_interface
,
7630 no_neighbor_interface_cmd
,
7631 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
7632 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7637 char base_xpath
[XPATH_MAXLEN
];
7639 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7640 argv
[idx_peer
]->arg
, "");
7642 nb_cli_enqueue_change(vty
, "./local-interface", NB_OP_DESTROY
, NULL
);
7644 return nb_cli_apply_changes(vty
, base_xpath
);
7647 DEFUN (neighbor_distribute_list
,
7648 neighbor_distribute_list_cmd
,
7649 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7652 "Filter updates to/from this neighbor\n"
7653 "IP access-list number\n"
7654 "IP access-list number (expanded range)\n"
7655 "IP Access-list name\n"
7656 "Filter incoming updates\n"
7657 "Filter outgoing updates\n")
7664 const char *pstr
= argv
[idx_peer
]->arg
;
7665 const char *acl
= argv
[idx_acl
]->arg
;
7666 const char *inout
= argv
[argc
- 1]->text
;
7668 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7670 return CMD_WARNING_CONFIG_FAILED
;
7672 /* Check filter direction. */
7673 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7674 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7677 return bgp_vty_return(vty
, ret
);
7681 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7682 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7683 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7684 "Filter updates to/from this neighbor\n"
7685 "IP access-list number\n"
7686 "IP access-list number (expanded range)\n"
7687 "IP Access-list name\n"
7688 "Filter incoming updates\n"
7689 "Filter outgoing updates\n")
7691 DEFUN (no_neighbor_distribute_list
,
7692 no_neighbor_distribute_list_cmd
,
7693 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7697 "Filter updates to/from this neighbor\n"
7698 "IP access-list number\n"
7699 "IP access-list number (expanded range)\n"
7700 "IP Access-list name\n"
7701 "Filter incoming updates\n"
7702 "Filter outgoing updates\n")
7708 const char *pstr
= argv
[idx_peer
]->arg
;
7709 const char *inout
= argv
[argc
- 1]->text
;
7711 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7713 return CMD_WARNING_CONFIG_FAILED
;
7715 /* Check filter direction. */
7716 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7717 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7720 return bgp_vty_return(vty
, ret
);
7724 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7725 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7726 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7727 "Filter updates to/from this neighbor\n"
7728 "IP access-list number\n"
7729 "IP access-list number (expanded range)\n"
7730 "IP Access-list name\n"
7731 "Filter incoming updates\n"
7732 "Filter outgoing updates\n")
7734 /* Set prefix list to the peer. */
7735 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7736 afi_t afi
, safi_t safi
,
7737 const char *name_str
,
7738 const char *direct_str
)
7741 int direct
= FILTER_IN
;
7744 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7746 return CMD_WARNING_CONFIG_FAILED
;
7748 /* Check filter direction. */
7749 if (strncmp(direct_str
, "i", 1) == 0)
7751 else if (strncmp(direct_str
, "o", 1) == 0)
7752 direct
= FILTER_OUT
;
7754 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7756 return bgp_vty_return(vty
, ret
);
7759 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7760 afi_t afi
, safi_t safi
,
7761 const char *direct_str
)
7765 int direct
= FILTER_IN
;
7767 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7769 return CMD_WARNING_CONFIG_FAILED
;
7771 /* Check filter direction. */
7772 if (strncmp(direct_str
, "i", 1) == 0)
7774 else if (strncmp(direct_str
, "o", 1) == 0)
7775 direct
= FILTER_OUT
;
7777 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7779 return bgp_vty_return(vty
, ret
);
7782 DEFUN (neighbor_prefix_list
,
7783 neighbor_prefix_list_cmd
,
7784 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7787 "Filter updates to/from this neighbor\n"
7788 "Name of a prefix list\n"
7789 "Filter incoming updates\n"
7790 "Filter outgoing updates\n")
7795 return peer_prefix_list_set_vty(
7796 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7797 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7800 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7801 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7802 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7803 "Filter updates to/from this neighbor\n"
7804 "Name of a prefix list\n"
7805 "Filter incoming updates\n"
7806 "Filter outgoing updates\n")
7808 DEFUN (no_neighbor_prefix_list
,
7809 no_neighbor_prefix_list_cmd
,
7810 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7814 "Filter updates to/from this neighbor\n"
7815 "Name of a prefix list\n"
7816 "Filter incoming updates\n"
7817 "Filter outgoing updates\n")
7821 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7822 bgp_node_afi(vty
), bgp_node_safi(vty
),
7823 argv
[idx_in_out
]->arg
);
7826 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7827 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7828 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7829 "Filter updates to/from this neighbor\n"
7830 "Name of a prefix list\n"
7831 "Filter incoming updates\n"
7832 "Filter outgoing updates\n")
7834 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7835 safi_t safi
, const char *name_str
,
7836 const char *direct_str
)
7840 int direct
= FILTER_IN
;
7842 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7844 return CMD_WARNING_CONFIG_FAILED
;
7846 /* Check filter direction. */
7847 if (strncmp(direct_str
, "i", 1) == 0)
7849 else if (strncmp(direct_str
, "o", 1) == 0)
7850 direct
= FILTER_OUT
;
7852 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7854 return bgp_vty_return(vty
, ret
);
7857 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7858 safi_t safi
, const char *direct_str
)
7862 int direct
= FILTER_IN
;
7864 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7866 return CMD_WARNING_CONFIG_FAILED
;
7868 /* Check filter direction. */
7869 if (strncmp(direct_str
, "i", 1) == 0)
7871 else if (strncmp(direct_str
, "o", 1) == 0)
7872 direct
= FILTER_OUT
;
7874 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7876 return bgp_vty_return(vty
, ret
);
7879 DEFUN (neighbor_filter_list
,
7880 neighbor_filter_list_cmd
,
7881 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7884 "Establish BGP filters\n"
7885 "AS path access-list name\n"
7886 "Filter incoming routes\n"
7887 "Filter outgoing routes\n")
7892 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7893 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7894 argv
[idx_in_out
]->arg
);
7897 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7898 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7899 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7900 "Establish BGP filters\n"
7901 "AS path access-list name\n"
7902 "Filter incoming routes\n"
7903 "Filter outgoing routes\n")
7905 DEFUN (no_neighbor_filter_list
,
7906 no_neighbor_filter_list_cmd
,
7907 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7911 "Establish BGP filters\n"
7912 "AS path access-list name\n"
7913 "Filter incoming routes\n"
7914 "Filter outgoing routes\n")
7918 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7919 bgp_node_afi(vty
), bgp_node_safi(vty
),
7920 argv
[idx_in_out
]->arg
);
7923 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7924 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7925 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7926 "Establish BGP filters\n"
7927 "AS path access-list name\n"
7928 "Filter incoming routes\n"
7929 "Filter outgoing routes\n")
7931 /* Set advertise-map to the peer. */
7932 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7933 afi_t afi
, safi_t safi
,
7934 const char *advertise_str
,
7935 const char *condition_str
, bool condition
,
7938 int ret
= CMD_WARNING_CONFIG_FAILED
;
7940 struct route_map
*advertise_map
;
7941 struct route_map
*condition_map
;
7943 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7947 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7948 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7951 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7952 advertise_map
, condition_str
,
7953 condition_map
, condition
);
7955 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7956 advertise_map
, condition_str
,
7957 condition_map
, condition
);
7959 return bgp_vty_return(vty
, ret
);
7962 DEFPY (neighbor_advertise_map
,
7963 neighbor_advertise_map_cmd
,
7964 "[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",
7968 "Route-map to conditionally advertise routes\n"
7969 "Name of advertise map\n"
7970 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7971 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7972 "Name of the exist or non exist map\n")
7974 bool condition
= CONDITION_EXIST
;
7976 if (!strcmp(exist
, "non-exist-map"))
7977 condition
= CONDITION_NON_EXIST
;
7979 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7980 bgp_node_safi(vty
), advertise_str
,
7981 condition_str
, condition
, !no
);
7984 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7985 "[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",
7986 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7987 "Route-map to conditionally advertise routes\n"
7988 "Name of advertise map\n"
7989 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7990 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7991 "Name of the exist or non exist map\n")
7993 /* Set route-map to the peer. */
7994 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7995 afi_t afi
, safi_t safi
, const char *name_str
,
7996 const char *direct_str
)
8000 int direct
= RMAP_IN
;
8001 struct route_map
*route_map
;
8003 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8005 return CMD_WARNING_CONFIG_FAILED
;
8007 /* Check filter direction. */
8008 if (strncmp(direct_str
, "in", 2) == 0)
8010 else if (strncmp(direct_str
, "o", 1) == 0)
8013 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
8014 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
8016 return bgp_vty_return(vty
, ret
);
8019 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
8020 afi_t afi
, safi_t safi
,
8021 const char *direct_str
)
8025 int direct
= RMAP_IN
;
8027 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8029 return CMD_WARNING_CONFIG_FAILED
;
8031 /* Check filter direction. */
8032 if (strncmp(direct_str
, "in", 2) == 0)
8034 else if (strncmp(direct_str
, "o", 1) == 0)
8037 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
8039 return bgp_vty_return(vty
, ret
);
8042 DEFUN (neighbor_route_map
,
8043 neighbor_route_map_cmd
,
8044 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
8047 "Apply route map to neighbor\n"
8048 "Name of route map\n"
8049 "Apply map to incoming routes\n"
8050 "Apply map to outbound routes\n")
8055 return peer_route_map_set_vty(
8056 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8057 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
8060 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
8061 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
8062 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8063 "Apply route map to neighbor\n"
8064 "Name of route map\n"
8065 "Apply map to incoming routes\n"
8066 "Apply map to outbound routes\n")
8068 DEFUN (no_neighbor_route_map
,
8069 no_neighbor_route_map_cmd
,
8070 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
8074 "Apply route map to neighbor\n"
8075 "Name of route map\n"
8076 "Apply map to incoming routes\n"
8077 "Apply map to outbound routes\n")
8081 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
8082 bgp_node_afi(vty
), bgp_node_safi(vty
),
8083 argv
[idx_in_out
]->arg
);
8086 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
8087 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
8088 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8089 "Apply route map to neighbor\n"
8090 "Name of route map\n"
8091 "Apply map to incoming routes\n"
8092 "Apply map to outbound routes\n")
8094 /* Set unsuppress-map to the peer. */
8095 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
8096 afi_t afi
, safi_t safi
,
8097 const char *name_str
)
8101 struct route_map
*route_map
;
8103 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8105 return CMD_WARNING_CONFIG_FAILED
;
8107 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
8108 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
8110 return bgp_vty_return(vty
, ret
);
8113 /* Unset route-map from the peer. */
8114 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
8115 afi_t afi
, safi_t safi
)
8120 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8122 return CMD_WARNING_CONFIG_FAILED
;
8124 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
8126 return bgp_vty_return(vty
, ret
);
8129 DEFUN (neighbor_unsuppress_map
,
8130 neighbor_unsuppress_map_cmd
,
8131 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8134 "Route-map to selectively unsuppress suppressed routes\n"
8135 "Name of route map\n")
8139 return peer_unsuppress_map_set_vty(
8140 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8141 argv
[idx_word
]->arg
);
8144 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
8145 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8146 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8147 "Route-map to selectively unsuppress suppressed routes\n"
8148 "Name of route map\n")
8150 DEFUN (no_neighbor_unsuppress_map
,
8151 no_neighbor_unsuppress_map_cmd
,
8152 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8156 "Route-map to selectively unsuppress suppressed routes\n"
8157 "Name of route map\n")
8160 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
8162 bgp_node_safi(vty
));
8165 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
8166 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8167 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8168 "Route-map to selectively unsuppress suppressed routes\n"
8169 "Name of route map\n")
8171 /* Maximum number of prefix to be sent to the neighbor. */
8172 DEFUN_YANG(neighbor_maximum_prefix_out
,
8173 neighbor_maximum_prefix_out_cmd
,
8174 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
8175 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8176 "Maximum number of prefixes to be sent to this peer\n"
8177 "Maximum no. of prefix limit\n")
8179 char base_xpath
[XPATH_MAXLEN
];
8180 char af_xpath
[XPATH_MAXLEN
];
8181 char attr_xpath
[XPATH_MAXLEN
];
8184 afi_t afi
= bgp_node_afi(vty
);
8185 safi_t safi
= bgp_node_safi(vty
);
8187 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8188 yang_afi_safi_value2identity(afi
, safi
));
8189 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8190 sizeof(base_xpath
), af_xpath
)
8192 return CMD_WARNING_CONFIG_FAILED
;
8194 snprintf(attr_xpath
, sizeof(attr_xpath
),
8195 "/%s/prefix-limit/direction-list[direction='out']",
8196 bgp_afi_safi_get_container_str(afi
, safi
));
8197 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8199 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8201 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8202 argv
[idx_number
]->arg
);
8204 return nb_cli_apply_changes(vty
, base_xpath
);
8207 DEFUN_YANG(no_neighbor_maximum_prefix_out
,
8208 no_neighbor_maximum_prefix_out_cmd
,
8209 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out",
8210 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8211 "Maximum number of prefixes to be sent to this peer\n")
8213 char base_xpath
[XPATH_MAXLEN
];
8214 char af_xpath
[XPATH_MAXLEN
];
8215 char attr_xpath
[XPATH_MAXLEN
];
8217 afi_t afi
= bgp_node_afi(vty
);
8218 safi_t safi
= bgp_node_safi(vty
);
8220 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8221 yang_afi_safi_value2identity(afi
, safi
));
8222 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8223 sizeof(base_xpath
), af_xpath
)
8225 return CMD_WARNING_CONFIG_FAILED
;
8227 snprintf(attr_xpath
, sizeof(attr_xpath
),
8228 "/%s/prefix-limit/direction-list[direction='out']",
8229 bgp_afi_safi_get_container_str(afi
, safi
));
8230 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8232 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
8234 return nb_cli_apply_changes(vty
, base_xpath
);
8237 /* Maximum number of prefix configuration. Prefix count is different
8238 for each peer configuration. So this configuration can be set for
8239 each peer configuration. */
8240 DEFUN_YANG(neighbor_maximum_prefix
,
8241 neighbor_maximum_prefix_cmd
,
8242 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8243 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8244 "Maximum number of prefix accept from this peer\n"
8245 "maximum no. of prefix limit\n"
8246 "Force checking all received routes not only accepted\n")
8251 char base_xpath
[XPATH_MAXLEN
];
8252 char af_xpath
[XPATH_MAXLEN
];
8253 char attr_xpath
[XPATH_MAXLEN
];
8254 afi_t afi
= bgp_node_afi(vty
);
8255 safi_t safi
= bgp_node_safi(vty
);
8257 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8258 yang_afi_safi_value2identity(afi
, safi
));
8259 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8260 sizeof(base_xpath
), af_xpath
)
8262 return CMD_WARNING_CONFIG_FAILED
;
8264 snprintf(attr_xpath
, sizeof(attr_xpath
),
8265 "/%s/prefix-limit/direction-list[direction='in']",
8266 bgp_afi_safi_get_container_str(afi
, safi
));
8267 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8269 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8271 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8272 argv
[idx_number
]->arg
);
8273 if (argv_find(argv
, argc
, "force", &idx_force
))
8274 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8277 return nb_cli_apply_changes(vty
, base_xpath
);
8280 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8281 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8282 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8283 "Maximum number of prefix accept from this peer\n"
8284 "maximum no. of prefix limit\n"
8285 "Force checking all received routes not only accepted\n")
8287 DEFUN_YANG(neighbor_maximum_prefix_threshold
,
8288 neighbor_maximum_prefix_threshold_cmd
,
8289 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8290 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8291 "Maximum number of prefix accept from this peer\n"
8292 "maximum no. of prefix limit\n"
8293 "Threshold value (%) at which to generate a warning msg\n"
8294 "Force checking all received routes not only accepted\n")
8298 int idx_number_2
= 4;
8300 char base_xpath
[XPATH_MAXLEN
];
8301 char af_xpath
[XPATH_MAXLEN
];
8302 char attr_xpath
[XPATH_MAXLEN
];
8303 afi_t afi
= bgp_node_afi(vty
);
8304 safi_t safi
= bgp_node_safi(vty
);
8306 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8307 yang_afi_safi_value2identity(afi
, safi
));
8308 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8309 sizeof(base_xpath
), af_xpath
)
8311 return CMD_WARNING_CONFIG_FAILED
;
8313 snprintf(attr_xpath
, sizeof(attr_xpath
),
8314 "/%s/prefix-limit/direction-list[direction='in']",
8315 bgp_afi_safi_get_container_str(afi
, safi
));
8316 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8318 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8320 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8321 argv
[idx_number
]->arg
);
8323 nb_cli_enqueue_change(vty
, "./options/shutdown-threshold-pct",
8324 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8326 if (argv_find(argv
, argc
, "force", &idx_force
))
8327 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8330 return nb_cli_apply_changes(vty
, base_xpath
);
8334 neighbor_maximum_prefix_threshold
,
8335 neighbor_maximum_prefix_threshold_hidden_cmd
,
8336 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8337 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8338 "Maximum number of prefix accept from this peer\n"
8339 "maximum no. of prefix limit\n"
8340 "Threshold value (%) at which to generate a warning msg\n"
8341 "Force checking all received routes not only accepted\n")
8343 DEFUN_YANG(neighbor_maximum_prefix_warning
,
8344 neighbor_maximum_prefix_warning_cmd
,
8345 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8346 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8347 "Maximum number of prefix accept from this peer\n"
8348 "maximum no. of prefix limit\n"
8349 "Only give warning message when limit is exceeded\n"
8350 "Force checking all received routes not only accepted\n")
8355 char base_xpath
[XPATH_MAXLEN
];
8356 char af_xpath
[XPATH_MAXLEN
];
8357 char attr_xpath
[XPATH_MAXLEN
];
8358 afi_t afi
= bgp_node_afi(vty
);
8359 safi_t safi
= bgp_node_safi(vty
);
8361 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8362 yang_afi_safi_value2identity(afi
, safi
));
8363 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8364 sizeof(base_xpath
), af_xpath
)
8366 return CMD_WARNING_CONFIG_FAILED
;
8368 snprintf(attr_xpath
, sizeof(attr_xpath
),
8369 "/%s/prefix-limit/direction-list[direction='in']",
8370 bgp_afi_safi_get_container_str(afi
, safi
));
8371 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8373 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8375 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8376 argv
[idx_number
]->arg
);
8378 nb_cli_enqueue_change(vty
, "./options/warning-only", NB_OP_MODIFY
,
8380 if (argv_find(argv
, argc
, "force", &idx_force
))
8381 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8384 return nb_cli_apply_changes(vty
, base_xpath
);
8388 neighbor_maximum_prefix_warning
,
8389 neighbor_maximum_prefix_warning_hidden_cmd
,
8390 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8391 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8392 "Maximum number of prefix accept from this peer\n"
8393 "maximum no. of prefix limit\n"
8394 "Only give warning message when limit is exceeded\n"
8395 "Force checking all received routes not only accepted\n")
8397 DEFUN_YANG(neighbor_maximum_prefix_threshold_warning
,
8398 neighbor_maximum_prefix_threshold_warning_cmd
,
8399 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8400 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8401 "Maximum number of prefix accept from this peer\n"
8402 "maximum no. of prefix limit\n"
8403 "Threshold value (%) at which to generate a warning msg\n"
8404 "Only give warning message when limit is exceeded\n"
8405 "Force checking all received routes not only accepted\n")
8409 int idx_number_2
= 4;
8411 char base_xpath
[XPATH_MAXLEN
];
8412 char af_xpath
[XPATH_MAXLEN
];
8413 char attr_xpath
[XPATH_MAXLEN
];
8414 afi_t afi
= bgp_node_afi(vty
);
8415 safi_t safi
= bgp_node_safi(vty
);
8417 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8418 yang_afi_safi_value2identity(afi
, safi
));
8419 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8420 sizeof(base_xpath
), af_xpath
)
8422 return CMD_WARNING_CONFIG_FAILED
;
8424 snprintf(attr_xpath
, sizeof(attr_xpath
),
8425 "/%s/prefix-limit/direction-list[direction='in']",
8426 bgp_afi_safi_get_container_str(afi
, safi
));
8427 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8429 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8431 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8432 argv
[idx_number
]->arg
);
8433 nb_cli_enqueue_change(vty
, "./options/tw-shutdown-threshold-pct",
8434 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8435 nb_cli_enqueue_change(vty
, "./options/tw-warning-only", NB_OP_MODIFY
,
8437 if (argv_find(argv
, argc
, "force", &idx_force
))
8438 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8441 return nb_cli_apply_changes(vty
, base_xpath
);
8445 neighbor_maximum_prefix_threshold_warning
,
8446 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8447 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8448 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8449 "Maximum number of prefix accept from this peer\n"
8450 "maximum no. of prefix limit\n"
8451 "Threshold value (%) at which to generate a warning msg\n"
8452 "Only give warning message when limit is exceeded\n"
8453 "Force checking all received routes not only accepted\n")
8455 DEFUN_YANG(neighbor_maximum_prefix_restart
,
8456 neighbor_maximum_prefix_restart_cmd
,
8457 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8458 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8459 "Maximum number of prefix accept from this peer\n"
8460 "maximum no. of prefix limit\n"
8461 "Restart bgp connection after limit is exceeded\n"
8462 "Restart interval in minutes\n"
8463 "Force checking all received routes not only accepted\n")
8467 int idx_number_2
= 5;
8469 char base_xpath
[XPATH_MAXLEN
];
8470 char af_xpath
[XPATH_MAXLEN
];
8471 char attr_xpath
[XPATH_MAXLEN
];
8472 afi_t afi
= bgp_node_afi(vty
);
8473 safi_t safi
= bgp_node_safi(vty
);
8475 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8476 yang_afi_safi_value2identity(afi
, safi
));
8477 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8478 sizeof(base_xpath
), af_xpath
)
8480 return CMD_WARNING_CONFIG_FAILED
;
8482 snprintf(attr_xpath
, sizeof(attr_xpath
),
8483 "/%s/prefix-limit/direction-list[direction='in']",
8484 bgp_afi_safi_get_container_str(afi
, safi
));
8485 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8487 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8489 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8490 argv
[idx_number
]->arg
);
8491 nb_cli_enqueue_change(vty
, "./options/restart-timer", NB_OP_MODIFY
,
8492 argv
[idx_number_2
]->arg
);
8493 if (argv_find(argv
, argc
, "force", &idx_force
))
8494 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8497 return nb_cli_apply_changes(vty
, base_xpath
);
8501 neighbor_maximum_prefix_restart
,
8502 neighbor_maximum_prefix_restart_hidden_cmd
,
8503 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8504 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8505 "Maximum number of prefix accept from this peer\n"
8506 "maximum no. of prefix limit\n"
8507 "Restart bgp connection after limit is exceeded\n"
8508 "Restart interval in minutes\n"
8509 "Force checking all received routes not only accepted\n")
8511 DEFUN_YANG(neighbor_maximum_prefix_threshold_restart
,
8512 neighbor_maximum_prefix_threshold_restart_cmd
,
8513 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8514 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8515 "Maximum number of prefixes to accept from this peer\n"
8516 "maximum no. of prefix limit\n"
8517 "Threshold value (%) at which to generate a warning msg\n"
8518 "Restart bgp connection after limit is exceeded\n"
8519 "Restart interval in minutes\n"
8520 "Force checking all received routes not only accepted\n")
8524 int idx_number_2
= 4;
8525 int idx_number_3
= 6;
8527 char base_xpath
[XPATH_MAXLEN
];
8528 char af_xpath
[XPATH_MAXLEN
];
8529 char attr_xpath
[XPATH_MAXLEN
];
8530 afi_t afi
= bgp_node_afi(vty
);
8531 safi_t safi
= bgp_node_safi(vty
);
8533 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8534 yang_afi_safi_value2identity(afi
, safi
));
8535 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8536 sizeof(base_xpath
), af_xpath
)
8538 return CMD_WARNING_CONFIG_FAILED
;
8540 snprintf(attr_xpath
, sizeof(attr_xpath
),
8541 "/%s/prefix-limit/direction-list[direction='in']",
8542 bgp_afi_safi_get_container_str(afi
, safi
));
8543 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8545 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8547 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8548 argv
[idx_number
]->arg
);
8549 nb_cli_enqueue_change(vty
, "./options/tr-shutdown-threshold-pct",
8550 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8551 nb_cli_enqueue_change(vty
, "./options/tr-restart-timer", NB_OP_MODIFY
,
8552 argv
[idx_number_3
]->arg
);
8553 if (argv_find(argv
, argc
, "force", &idx_force
))
8554 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8557 return nb_cli_apply_changes(vty
, base_xpath
);
8561 neighbor_maximum_prefix_threshold_restart
,
8562 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8563 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8564 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8565 "Maximum number of prefixes to accept from this peer\n"
8566 "maximum no. of prefix limit\n"
8567 "Threshold value (%) at which to generate a warning msg\n"
8568 "Restart bgp connection after limit is exceeded\n"
8569 "Restart interval in minutes\n"
8570 "Force checking all received routes not only accepted\n")
8572 DEFUN_YANG(no_neighbor_maximum_prefix
,
8573 no_neighbor_maximum_prefix_cmd
,
8574 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8575 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8576 "Maximum number of prefixes to accept from this peer\n"
8577 "maximum no. of prefix limit\n"
8578 "Threshold value (%) at which to generate a warning msg\n"
8579 "Restart bgp connection after limit is exceeded\n"
8580 "Restart interval in minutes\n"
8581 "Only give warning message when limit is exceeded\n"
8582 "Force checking all received routes not only accepted\n")
8585 char base_xpath
[XPATH_MAXLEN
];
8586 char af_xpath
[XPATH_MAXLEN
];
8587 char attr_xpath
[XPATH_MAXLEN
];
8588 afi_t afi
= bgp_node_afi(vty
);
8589 safi_t safi
= bgp_node_safi(vty
);
8591 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8592 yang_afi_safi_value2identity(afi
, safi
));
8593 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8594 sizeof(base_xpath
), af_xpath
)
8596 return CMD_WARNING_CONFIG_FAILED
;
8598 snprintf(attr_xpath
, sizeof(attr_xpath
),
8599 "/%s/prefix-limit/direction-list[direction='in']",
8600 bgp_afi_safi_get_container_str(afi
, safi
));
8601 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8603 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
8605 return nb_cli_apply_changes(vty
, base_xpath
);
8609 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8610 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8611 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8612 "Maximum number of prefixes to accept from this peer\n"
8613 "maximum no. of prefix limit\n"
8614 "Threshold value (%) at which to generate a warning msg\n"
8615 "Restart bgp connection after limit is exceeded\n"
8616 "Restart interval in minutes\n"
8617 "Only give warning message when limit is exceeded\n"
8618 "Force checking all received routes not only accepted\n")
8621 /* "neighbor allowas-in" */
8622 DEFUN (neighbor_allowas_in
,
8623 neighbor_allowas_in_cmd
,
8624 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8627 "Accept as-path with my AS present in it\n"
8628 "Number of occurrences of AS number\n"
8629 "Only accept my AS in the as-path if the route was originated in my AS\n")
8632 int idx_number_origin
= 3;
8638 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8640 return CMD_WARNING_CONFIG_FAILED
;
8642 if (argc
<= idx_number_origin
)
8645 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8648 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8651 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8654 return bgp_vty_return(vty
, ret
);
8658 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8659 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8660 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8661 "Accept as-path with my AS present in it\n"
8662 "Number of occurrences of AS number\n"
8663 "Only accept my AS in the as-path if the route was originated in my AS\n")
8665 DEFUN (no_neighbor_allowas_in
,
8666 no_neighbor_allowas_in_cmd
,
8667 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8671 "allow local ASN appears in aspath attribute\n"
8672 "Number of occurrences of AS number\n"
8673 "Only accept my AS in the as-path if the route was originated in my AS\n")
8679 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8681 return CMD_WARNING_CONFIG_FAILED
;
8683 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8684 bgp_node_safi(vty
));
8686 return bgp_vty_return(vty
, ret
);
8690 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8691 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8692 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8693 "allow local ASN appears in aspath attribute\n"
8694 "Number of occurrences of AS number\n"
8695 "Only accept my AS in the as-path if the route was originated in my AS\n")
8697 DEFUN_YANG (neighbor_ttl_security
,
8698 neighbor_ttl_security_cmd
,
8699 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8702 "BGP ttl-security parameters\n"
8703 "Specify the maximum number of hops to the BGP peer\n"
8704 "Number of hops to BGP peer\n")
8708 char base_xpath
[XPATH_MAXLEN
];
8710 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8711 sizeof(base_xpath
), NULL
)
8713 return CMD_WARNING_CONFIG_FAILED
;
8715 nb_cli_enqueue_change(vty
, "./ttl-security", NB_OP_MODIFY
,
8716 argv
[idx_number
]->arg
);
8718 return nb_cli_apply_changes(vty
, base_xpath
);
8721 DEFUN_YANG(no_neighbor_ttl_security
,
8722 no_neighbor_ttl_security_cmd
,
8723 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8724 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8725 "BGP ttl-security parameters\n"
8726 "Specify the maximum number of hops to the BGP peer\n"
8727 "Number of hops to BGP peer\n")
8730 char base_xpath
[XPATH_MAXLEN
];
8732 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8733 sizeof(base_xpath
), NULL
)
8735 return CMD_WARNING_CONFIG_FAILED
;
8737 nb_cli_enqueue_change(vty
, "./ttl-security", NB_OP_DESTROY
, NULL
);
8739 return nb_cli_apply_changes(vty
, base_xpath
);
8742 DEFUN (neighbor_addpath_tx_all_paths
,
8743 neighbor_addpath_tx_all_paths_cmd
,
8744 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8747 "Use addpath to advertise all paths to a neighbor\n")
8752 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8754 return CMD_WARNING_CONFIG_FAILED
;
8756 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8761 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8762 neighbor_addpath_tx_all_paths_hidden_cmd
,
8763 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8764 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8765 "Use addpath to advertise all paths to a neighbor\n")
8767 DEFUN (no_neighbor_addpath_tx_all_paths
,
8768 no_neighbor_addpath_tx_all_paths_cmd
,
8769 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8773 "Use addpath to advertise all paths to a neighbor\n")
8778 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8780 return CMD_WARNING_CONFIG_FAILED
;
8782 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8783 != BGP_ADDPATH_ALL
) {
8785 "%% Peer not currently configured to transmit all paths.");
8786 return CMD_WARNING_CONFIG_FAILED
;
8789 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8795 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8796 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8797 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8798 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8799 "Use addpath to advertise all paths to a neighbor\n")
8801 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8802 neighbor_addpath_tx_bestpath_per_as_cmd
,
8803 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8806 "Use addpath to advertise the bestpath per each neighboring AS\n")
8811 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8813 return CMD_WARNING_CONFIG_FAILED
;
8815 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8816 BGP_ADDPATH_BEST_PER_AS
);
8821 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8822 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8823 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8824 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8825 "Use addpath to advertise the bestpath per each neighboring AS\n")
8827 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8828 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8829 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8833 "Use addpath to advertise the bestpath per each neighboring AS\n")
8838 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8840 return CMD_WARNING_CONFIG_FAILED
;
8842 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8843 != BGP_ADDPATH_BEST_PER_AS
) {
8845 "%% Peer not currently configured to transmit all best path per as.");
8846 return CMD_WARNING_CONFIG_FAILED
;
8849 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8855 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8856 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8857 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8858 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8859 "Use addpath to advertise the bestpath per each neighboring AS\n")
8862 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8863 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8866 "Detect AS loops before sending to neighbor\n")
8870 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8872 return CMD_WARNING_CONFIG_FAILED
;
8874 peer
->as_path_loop_detection
= true;
8880 no_neighbor_aspath_loop_detection
,
8881 no_neighbor_aspath_loop_detection_cmd
,
8882 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8886 "Detect AS loops before sending to neighbor\n")
8890 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8892 return CMD_WARNING_CONFIG_FAILED
;
8894 peer
->as_path_loop_detection
= false;
8899 DEFPY(neighbor_damp
,
8901 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor dampening [(1-45)$half [(1-20000)$reuse (1-20000)$suppress (1-255)$max]]",
8904 "Enable neighbor route-flap dampening\n"
8905 "Half-life time for the penalty\n"
8906 "Value to start reusing a route\n"
8907 "Value to start suppressing a route\n"
8908 "Maximum duration to suppress a stable route\n")
8910 struct peer
*peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8913 return CMD_WARNING_CONFIG_FAILED
;
8915 half
= DEFAULT_HALF_LIFE
;
8917 reuse
= DEFAULT_REUSE
;
8918 suppress
= DEFAULT_SUPPRESS
;
8921 if (suppress
< reuse
) {
8923 "Suppress value cannot be less than reuse value\n");
8924 return CMD_WARNING_CONFIG_FAILED
;
8926 bgp_peer_damp_enable(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8927 half
* 60, reuse
, suppress
, max
* 60);
8931 DEFPY(no_neighbor_damp
,
8932 no_neighbor_damp_cmd
,
8933 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor dampening [HALF [REUSE SUPPRESS MAX]]",
8937 "Enable neighbor route-flap dampening\n"
8938 "Half-life time for the penalty\n"
8939 "Value to start reusing a route\n"
8940 "Value to start suppressing a route\n"
8941 "Maximum duration to suppress a stable route\n")
8943 struct peer
*peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8946 return CMD_WARNING_CONFIG_FAILED
;
8947 bgp_peer_damp_disable(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
8951 DEFPY (show_ip_bgp_neighbor_damp_param
,
8952 show_ip_bgp_neighbor_damp_param_cmd
,
8953 "show [ip] bgp [<ipv4|ipv6> [unicast]] neighbors <A.B.C.D|X:X::X:X|WORD>$neighbor dampening parameters [json]$json",
8958 "Address Family modifier\n"
8961 "Neighbor route-flap dampening information\n"
8962 "Display detail of configured dampening parameters\n"
8965 bool use_json
= false;
8968 safi_t safi
= SAFI_UNICAST
;
8971 if (argv_find(argv
, argc
, "ip", &idx
))
8973 if (argv_find(argv
, argc
, "ipv4", &idx
))
8975 if (argv_find(argv
, argc
, "ipv6", &idx
))
8977 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8982 bgp_show_peer_dampening_parameters(vty
, peer
, afi
, safi
, use_json
);
8986 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8987 struct ecommunity
**list
, bool is_rt6
)
8989 struct ecommunity
*ecom
= NULL
;
8990 struct ecommunity
*ecomadd
;
8992 for (; argc
; --argc
, ++argv
) {
8994 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8995 ECOMMUNITY_ROUTE_TARGET
,
8998 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8999 ECOMMUNITY_ROUTE_TARGET
,
9002 vty_out(vty
, "Malformed community-list value\n");
9004 ecommunity_free(&ecom
);
9005 return CMD_WARNING_CONFIG_FAILED
;
9009 ecommunity_merge(ecom
, ecomadd
);
9010 ecommunity_free(&ecomadd
);
9017 ecommunity_free(&*list
);
9024 bool vpn_policy_check_import(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
9025 bool v2vimport
, char *errmsg
, size_t errmsg_len
)
9028 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9029 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
9030 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9031 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
9033 errmsg
, errmsg_len
, "%s",
9034 "%% error: Please unconfigure import vrf commands before using vpn commands");
9038 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9039 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
9040 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9041 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
9043 errmsg
, errmsg_len
, "%s",
9044 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands");
9052 * v2vimport is true if we are handling a `import vrf ...` command
9054 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
9058 switch (vty
->node
) {
9067 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
9072 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9073 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
9074 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9075 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
9077 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
9081 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9082 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
9083 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9084 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
9086 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
9095 af_rd_vpn_export_cmd
,
9096 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
9098 "Specify route distinguisher\n"
9099 "Between current address-family and vpn\n"
9100 "For routes leaked from current address-family to vpn\n"
9101 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
9103 char base_xpath
[XPATH_MAXLEN
];
9108 afi
= bgp_node_afi(vty
);
9109 safi
= bgp_node_safi(vty
);
9112 base_xpath
, sizeof(base_xpath
),
9113 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9114 yang_afi_safi_value2identity(afi
, safi
),
9115 bgp_afi_safi_get_container_str(afi
, safi
));
9117 if (argv_find(argv
, argc
, "no", &idx
))
9118 nb_cli_enqueue_change(vty
, "./rd", NB_OP_DESTROY
, NULL
);
9120 nb_cli_enqueue_change(vty
, "./rd", NB_OP_MODIFY
, rd_str
);
9122 return nb_cli_apply_changes(vty
, base_xpath
);
9125 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rd(
9126 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9130 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
9131 yang_dnode_get_string(dnode
, NULL
));
9134 ALIAS (af_rd_vpn_export
,
9135 af_no_rd_vpn_export_cmd
,
9138 "Specify route distinguisher\n"
9139 "Between current address-family and vpn\n"
9140 "For routes leaked from current address-family to vpn\n")
9142 DEFPY (af_label_vpn_export
,
9143 af_label_vpn_export_cmd
,
9144 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
9146 "label value for VRF\n"
9147 "Between current address-family and vpn\n"
9148 "For routes leaked from current address-family to vpn\n"
9149 "Label Value <0-1048575>\n"
9150 "Automatically assign a label\n")
9152 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9153 mpls_label_t label
= MPLS_LABEL_NONE
;
9158 if (argv_find(argv
, argc
, "no", &idx
))
9161 /* If "no ...", squash trailing parameter */
9167 label
= label_val
; /* parser should force unsigned */
9170 afi
= vpn_policy_getafi(vty
, bgp
, false);
9172 return CMD_WARNING_CONFIG_FAILED
;
9175 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9176 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
9181 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9183 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9184 bgp_get_default(), bgp
);
9186 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9187 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
9189 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
9192 * label has previously been automatically
9193 * assigned by labelpool: release it
9195 * NB if tovpn_label == MPLS_LABEL_NONE it
9196 * means the automatic assignment is in flight
9197 * and therefore the labelpool callback must
9198 * detect that the auto label is not needed.
9201 bgp_lp_release(LP_TYPE_VRF
,
9202 &bgp
->vpn_policy
[afi
],
9203 bgp
->vpn_policy
[afi
].tovpn_label
);
9205 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9206 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9209 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
9211 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9212 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9213 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
9214 vpn_leak_label_callback
);
9217 /* post-change: re-export vpn routes */
9218 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9219 bgp_get_default(), bgp
);
9224 ALIAS (af_label_vpn_export
,
9225 af_no_label_vpn_export_cmd
,
9226 "no label vpn export",
9228 "label value for VRF\n"
9229 "Between current address-family and vpn\n"
9230 "For routes leaked from current address-family to vpn\n")
9232 DEFPY_YANG (af_nexthop_vpn_export
,
9233 af_nexthop_vpn_export_cmd
,
9234 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
9236 "Specify next hop to use for VRF advertised prefixes\n"
9237 "Between current address-family and vpn\n"
9238 "For routes leaked from current address-family to vpn\n"
9242 char base_xpath
[XPATH_MAXLEN
];
9250 vty_out(vty
, "%% Nexthop required\n");
9251 return CMD_WARNING_CONFIG_FAILED
;
9253 if (!sockunion2hostprefix(nexthop_su
, &p
))
9254 return CMD_WARNING_CONFIG_FAILED
;
9257 afi
= bgp_node_afi(vty
);
9258 safi
= bgp_node_safi(vty
);
9261 base_xpath
, sizeof(base_xpath
),
9262 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9263 yang_afi_safi_value2identity(afi
, safi
),
9264 bgp_afi_safi_get_container_str(afi
, safi
));
9266 if (argv_find(argv
, argc
, "no", &idx
))
9267 nb_cli_enqueue_change(vty
, "./nexthop", NB_OP_DESTROY
, NULL
);
9269 nb_cli_enqueue_change(vty
, "./nexthop", NB_OP_MODIFY
,
9272 return nb_cli_apply_changes(vty
, base_xpath
);
9275 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_nexthop(
9276 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9280 vty_out(vty
, "%*snexthop vpn export %s\n", indent
, "",
9281 yang_dnode_get_string(dnode
, NULL
));
9284 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9286 if (!strcmp(dstr
, "import")) {
9287 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9288 } else if (!strcmp(dstr
, "export")) {
9289 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9290 } else if (!strcmp(dstr
, "both")) {
9291 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9292 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9294 vty_out(vty
, "%% direction parse error\n");
9295 return CMD_WARNING_CONFIG_FAILED
;
9300 DEFPY (af_rt_vpn_imexport
,
9301 af_rt_vpn_imexport_cmd
,
9302 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9304 "Specify route target list\n"
9305 "Specify route target list\n"
9306 "Between current address-family and vpn\n"
9307 "For routes leaked from vpn to current address-family: match any\n"
9308 "For routes leaked from current address-family to vpn: set\n"
9309 "both import: match any and export: set\n"
9310 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9312 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9314 struct ecommunity
*ecom
= NULL
;
9315 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9316 vpn_policy_direction_t dir
;
9321 if (argv_find(argv
, argc
, "no", &idx
))
9324 afi
= vpn_policy_getafi(vty
, bgp
, false);
9326 return CMD_WARNING_CONFIG_FAILED
;
9328 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9329 if (ret
!= CMD_SUCCESS
)
9333 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9334 vty_out(vty
, "%% Missing RTLIST\n");
9335 return CMD_WARNING_CONFIG_FAILED
;
9337 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9338 if (ret
!= CMD_SUCCESS
) {
9343 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9347 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9350 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9352 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9353 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9354 ecommunity_dup(ecom
);
9356 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9358 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9359 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9362 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9366 ecommunity_free(&ecom
);
9371 ALIAS (af_rt_vpn_imexport
,
9372 af_no_rt_vpn_imexport_cmd
,
9373 "no <rt|route-target> vpn <import|export|both>$direction_str",
9375 "Specify route target list\n"
9376 "Specify route target list\n"
9377 "Between current address-family and vpn\n"
9378 "For routes leaked from vpn to current address-family\n"
9379 "For routes leaked from current address-family to vpn\n"
9380 "both import and export\n")
9382 DEFPY_YANG (af_route_map_vpn_imexport
,
9383 af_route_map_vpn_imexport_cmd
,
9384 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9385 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9387 "Specify route map\n"
9388 "Between current address-family and vpn\n"
9389 "For routes leaked from vpn to current address-family\n"
9390 "For routes leaked from current address-family to vpn\n"
9391 "name of route-map\n")
9393 char base_xpath
[XPATH_MAXLEN
];
9398 afi
= bgp_node_afi(vty
);
9399 safi
= bgp_node_safi(vty
);
9402 base_xpath
, sizeof(base_xpath
),
9403 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9404 yang_afi_safi_value2identity(afi
, safi
),
9405 bgp_afi_safi_get_container_str(afi
, safi
));
9407 if (argv_find(argv
, argc
, "no", &idx
)) {
9408 if (!strcmp(direction_str
, "import"))
9409 nb_cli_enqueue_change(vty
, "./rmap-import",
9410 NB_OP_DESTROY
, NULL
);
9411 else if (!strcmp(direction_str
, "export"))
9412 nb_cli_enqueue_change(vty
, "./rmap-export",
9413 NB_OP_DESTROY
, NULL
);
9415 if (!strcmp(direction_str
, "import"))
9416 nb_cli_enqueue_change(vty
, "./rmap-import",
9417 NB_OP_MODIFY
, rmap_str
);
9418 if (!strcmp(direction_str
, "export"))
9419 nb_cli_enqueue_change(vty
, "./rmap-export",
9420 NB_OP_MODIFY
, rmap_str
);
9422 return nb_cli_apply_changes(vty
, base_xpath
);
9425 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_import(
9426 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9430 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
9431 yang_dnode_get_string(dnode
, NULL
));
9434 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_export(
9435 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9439 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
9440 yang_dnode_get_string(dnode
, NULL
));
9443 ALIAS (af_route_map_vpn_imexport
,
9444 af_no_route_map_vpn_imexport_cmd
,
9445 "no route-map vpn <import|export>$direction_str",
9447 "Specify route map\n"
9448 "Between current address-family and vpn\n"
9449 "For routes leaked from vpn to current address-family\n"
9450 "For routes leaked from current address-family to vpn\n")
9452 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9453 "import vrf route-map RMAP$rmap_str",
9454 "Import routes from another VRF\n"
9455 "Vrf routes being filtered\n"
9456 "Specify route map\n"
9457 "name of route-map\n")
9459 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9460 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9462 struct bgp
*bgp_default
;
9464 afi
= vpn_policy_getafi(vty
, bgp
, true);
9466 return CMD_WARNING_CONFIG_FAILED
;
9468 bgp_default
= bgp_get_default();
9473 /* Auto-create assuming the same AS */
9474 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9475 BGP_INSTANCE_TYPE_DEFAULT
);
9479 "VRF default is not configured as a bgp instance\n");
9484 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9486 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9487 XFREE(MTYPE_ROUTE_MAP_NAME
,
9488 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9489 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9490 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9491 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9492 route_map_lookup_warn_noexist(vty
, rmap_str
);
9493 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9496 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9497 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9499 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9504 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9505 "no import vrf route-map [RMAP$rmap_str]",
9507 "Import routes from another VRF\n"
9508 "Vrf routes being filtered\n"
9509 "Specify route map\n"
9510 "name of route-map\n")
9512 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9513 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9516 afi
= vpn_policy_getafi(vty
, bgp
, true);
9518 return CMD_WARNING_CONFIG_FAILED
;
9520 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9522 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9523 XFREE(MTYPE_ROUTE_MAP_NAME
,
9524 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9525 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9526 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9528 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9529 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9530 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9532 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9537 DEFPY_YANG(bgp_imexport_vrf
,
9538 bgp_imexport_vrf_cmd
,
9539 "[no] import vrf VIEWVRFNAME$import_name",
9541 "Import routes from another VRF\n"
9542 "VRF to import from\n"
9543 "The name of the VRF\n")
9545 char base_xpath
[XPATH_MAXLEN
];
9550 if (import_name
== NULL
) {
9551 vty_out(vty
, "%% Missing import name\n");
9555 if (strcmp(import_name
, "route-map") == 0) {
9556 vty_out(vty
, "%% Must include route-map name\n");
9560 afi
= bgp_node_afi(vty
);
9561 safi
= bgp_node_safi(vty
);
9564 base_xpath
, sizeof(base_xpath
),
9565 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vrf-list[vrf='%s']",
9566 yang_afi_safi_value2identity(afi
, safi
),
9567 bgp_afi_safi_get_container_str(afi
, safi
), import_name
);
9569 if (argv_find(argv
, argc
, "no", &idx
))
9570 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
9572 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
9574 return nb_cli_apply_changes(vty
, base_xpath
);
9577 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vrfs(
9578 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9580 vty_out(vty
, " import vrf %s\n",
9581 yang_dnode_get_string(dnode
, "./vrf"));
9584 /* This command is valid only in a bgp vrf instance or the default instance */
9585 DEFPY_YANG (bgp_imexport_vpn
,
9586 bgp_imexport_vpn_cmd
,
9587 "[no] <import|export>$direction_str vpn",
9589 "Import routes to this address-family\n"
9590 "Export routes from this address-family\n"
9591 "to/from default instance VPN RIB\n")
9593 char base_xpath
[XPATH_MAXLEN
];
9598 afi
= bgp_node_afi(vty
);
9599 safi
= bgp_node_safi(vty
);
9601 if (!strcmp(direction_str
, "import")) {
9603 base_xpath
, sizeof(base_xpath
),
9604 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vpn",
9605 yang_afi_safi_value2identity(afi
, safi
),
9606 bgp_afi_safi_get_container_str(afi
, safi
));
9607 } else if (!strcmp(direction_str
, "export")) {
9609 base_xpath
, sizeof(base_xpath
),
9610 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/export-vpn",
9611 yang_afi_safi_value2identity(afi
, safi
),
9612 bgp_afi_safi_get_container_str(afi
, safi
));
9614 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9615 return CMD_WARNING_CONFIG_FAILED
;
9618 if (argv_find(argv
, argc
, "no", &idx
))
9619 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
9621 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, "true");
9623 return nb_cli_apply_changes(vty
, base_xpath
);
9626 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vpn(
9627 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9629 if (yang_dnode_get_bool(dnode
, NULL
))
9630 vty_out(vty
, " import vpn\n");
9633 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_export_vpn(
9634 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9636 if (yang_dnode_get_bool(dnode
, NULL
))
9637 vty_out(vty
, " export vpn\n");
9640 DEFPY (af_routetarget_import
,
9641 af_routetarget_import_cmd
,
9642 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9644 "Specify route target list\n"
9645 "Specify route target list\n"
9646 "Specify route target list\n"
9647 "Specify route target list\n"
9648 "Flow-spec redirect type route target\n"
9649 "Import routes to this address-family\n"
9650 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9652 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9654 struct ecommunity
*ecom
= NULL
;
9656 int idx
= 0, idx_unused
= 0;
9660 if (argv_find(argv
, argc
, "no", &idx
))
9663 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9664 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9667 afi
= vpn_policy_getafi(vty
, bgp
, false);
9669 return CMD_WARNING_CONFIG_FAILED
;
9671 if (rt6
&& afi
!= AFI_IP6
)
9672 return CMD_WARNING_CONFIG_FAILED
;
9675 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9676 vty_out(vty
, "%% Missing RTLIST\n");
9677 return CMD_WARNING_CONFIG_FAILED
;
9679 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9680 if (ret
!= CMD_SUCCESS
)
9685 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9686 ecommunity_free(&bgp
->vpn_policy
[afi
]
9687 .import_redirect_rtlist
);
9688 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9689 ecommunity_dup(ecom
);
9691 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9692 ecommunity_free(&bgp
->vpn_policy
[afi
]
9693 .import_redirect_rtlist
);
9694 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9698 ecommunity_free(&ecom
);
9703 void cli_show_bgp_global_afi_safi_header(struct vty
*vty
,
9704 struct lyd_node
*dnode
,
9707 const char *af_name
;
9711 af_name
= yang_dnode_get_string(dnode
, "./afi-safi-name");
9712 yang_afi_safi_identity2value(af_name
, &afi
, &safi
);
9714 vty_out(vty
, " !\n address-family ");
9715 if (afi
== AFI_IP
) {
9716 if (safi
== SAFI_UNICAST
)
9717 vty_out(vty
, "ipv4 unicast");
9718 else if (safi
== SAFI_LABELED_UNICAST
)
9719 vty_out(vty
, "ipv4 labeled-unicast");
9720 else if (safi
== SAFI_MULTICAST
)
9721 vty_out(vty
, "ipv4 multicast");
9722 else if (safi
== SAFI_MPLS_VPN
)
9723 vty_out(vty
, "ipv4 vpn");
9724 else if (safi
== SAFI_ENCAP
)
9725 vty_out(vty
, "ipv4 encap");
9726 else if (safi
== SAFI_FLOWSPEC
)
9727 vty_out(vty
, "ipv4 flowspec");
9728 } else if (afi
== AFI_IP6
) {
9729 if (safi
== SAFI_UNICAST
)
9730 vty_out(vty
, "ipv6 unicast");
9731 else if (safi
== SAFI_LABELED_UNICAST
)
9732 vty_out(vty
, "ipv6 labeled-unicast");
9733 else if (safi
== SAFI_MULTICAST
)
9734 vty_out(vty
, "ipv6 multicast");
9735 else if (safi
== SAFI_MPLS_VPN
)
9736 vty_out(vty
, "ipv6 vpn");
9737 else if (safi
== SAFI_ENCAP
)
9738 vty_out(vty
, "ipv6 encap");
9739 else if (safi
== SAFI_FLOWSPEC
)
9740 vty_out(vty
, "ipv6 flowspec");
9741 } else if (afi
== AFI_L2VPN
) {
9742 if (safi
== SAFI_EVPN
)
9743 vty_out(vty
, "l2vpn evpn");
9748 DEFUN_NOSH (address_family_ipv4_safi
,
9749 address_family_ipv4_safi_cmd
,
9750 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9751 "Enter Address Family command mode\n"
9753 BGP_SAFI_WITH_LABEL_HELP_STR
)
9756 safi_t safi
= SAFI_UNICAST
;
9757 const struct lyd_node
*vrf_dnode
, *bgp_glb_dnode
;
9758 const char *vrf_name
= NULL
;
9761 safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9763 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
9765 vrf_dnode
= yang_dnode_get_parent(bgp_glb_dnode
,
9766 "control-plane-protocol");
9767 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
9769 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
)
9770 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9771 && safi
!= SAFI_EVPN
) {
9773 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9774 return CMD_WARNING_CONFIG_FAILED
;
9777 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9782 DEFUN_NOSH (address_family_ipv6_safi
,
9783 address_family_ipv6_safi_cmd
,
9784 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9785 "Enter Address Family command mode\n"
9787 BGP_SAFI_WITH_LABEL_HELP_STR
)
9789 safi_t safi
= SAFI_UNICAST
;
9790 const struct lyd_node
*vrf_dnode
, *bgp_glb_dnode
;
9791 const char *vrf_name
= NULL
;
9794 safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9795 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
9797 vrf_dnode
= yang_dnode_get_parent(bgp_glb_dnode
,
9798 "control-plane-protocol");
9799 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
9801 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
)
9802 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9803 && safi
!= SAFI_EVPN
) {
9805 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9806 return CMD_WARNING_CONFIG_FAILED
;
9809 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9814 #ifdef KEEP_OLD_VPN_COMMANDS
9815 DEFUN_NOSH (address_family_vpnv4
,
9816 address_family_vpnv4_cmd
,
9817 "address-family vpnv4 [unicast]",
9818 "Enter Address Family command mode\n"
9820 "Address Family modifier\n")
9822 vty
->node
= BGP_VPNV4_NODE
;
9826 DEFUN_NOSH (address_family_vpnv6
,
9827 address_family_vpnv6_cmd
,
9828 "address-family vpnv6 [unicast]",
9829 "Enter Address Family command mode\n"
9831 "Address Family modifier\n")
9833 vty
->node
= BGP_VPNV6_NODE
;
9836 #endif /* KEEP_OLD_VPN_COMMANDS */
9838 DEFUN_NOSH (address_family_evpn
,
9839 address_family_evpn_cmd
,
9840 "address-family l2vpn evpn",
9841 "Enter Address Family command mode\n"
9843 "Address Family modifier\n")
9845 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9846 vty
->node
= BGP_EVPN_NODE
;
9850 DEFUN_NOSH (exit_address_family
,
9851 exit_address_family_cmd
,
9852 "exit-address-family",
9853 "Exit from Address Family configuration mode\n")
9855 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9856 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9857 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9858 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9859 || vty
->node
== BGP_EVPN_NODE
9860 || vty
->node
== BGP_FLOWSPECV4_NODE
9861 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9862 vty
->node
= BGP_NODE
;
9866 void cli_show_bgp_global_afi_safi_header_end(struct vty
*vty
,
9867 struct lyd_node
*dnode
9868 __attribute__((__unused__
)))
9870 vty_out(vty
, " exit-address-family\n");
9873 /* Recalculate bestpath and re-advertise a prefix */
9874 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9875 const char *ip_str
, afi_t afi
, safi_t safi
,
9876 struct prefix_rd
*prd
)
9879 struct prefix match
;
9880 struct bgp_dest
*dest
;
9881 struct bgp_dest
*rm
;
9883 struct bgp_table
*table
;
9884 struct bgp_table
*rib
;
9886 /* BGP structure lookup. */
9888 bgp
= bgp_lookup_by_name(view_name
);
9890 vty_out(vty
, "%% Can't find BGP instance %s\n",
9895 bgp
= bgp_get_default();
9897 vty_out(vty
, "%% No BGP process is configured\n");
9902 /* Check IP address argument. */
9903 ret
= str2prefix(ip_str
, &match
);
9905 vty_out(vty
, "%% address is malformed\n");
9909 match
.family
= afi2family(afi
);
9910 rib
= bgp
->rib
[afi
][safi
];
9912 if (safi
== SAFI_MPLS_VPN
) {
9913 for (dest
= bgp_table_top(rib
); dest
;
9914 dest
= bgp_route_next(dest
)) {
9915 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9917 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9920 table
= bgp_dest_get_bgp_table_info(dest
);
9924 if ((rm
= bgp_node_match(table
, &match
)) != NULL
) {
9925 const struct prefix
*rm_p
=
9926 bgp_dest_get_prefix(rm
);
9928 if (rm_p
->prefixlen
== match
.prefixlen
) {
9930 BGP_NODE_USER_CLEAR
);
9931 bgp_process(bgp
, rm
, afi
, safi
);
9933 bgp_dest_unlock_node(rm
);
9937 if ((dest
= bgp_node_match(rib
, &match
)) != NULL
) {
9938 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9940 if (dest_p
->prefixlen
== match
.prefixlen
) {
9941 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9942 bgp_process(bgp
, dest
, afi
, safi
);
9944 bgp_dest_unlock_node(dest
);
9951 /* one clear bgp command to rule them all */
9952 DEFUN (clear_ip_bgp_all
,
9953 clear_ip_bgp_all_cmd
,
9954 "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>]",
9958 BGP_INSTANCE_HELP_STR
9961 BGP_SAFI_WITH_LABEL_HELP_STR
9962 "Address Family modifier\n"
9964 "BGP IPv4 neighbor to clear\n"
9965 "BGP IPv6 neighbor to clear\n"
9966 "BGP neighbor on interface to clear\n"
9967 "Clear peers with the AS number\n"
9968 "Clear all external peers\n"
9969 "Clear all members of peer-group\n"
9970 "BGP peer-group name\n"
9975 "Push out prefix-list ORF and do inbound soft reconfig\n"
9980 afi_t afi
= AFI_UNSPEC
;
9981 safi_t safi
= SAFI_UNSPEC
;
9982 enum clear_sort clr_sort
= clear_peer
;
9983 enum bgp_clear_type clr_type
;
9984 char *clr_arg
= NULL
;
9987 char errmsg
[BUFSIZ
] = {'\0'};
9990 /* clear [ip] bgp */
9991 if (argv_find(argv
, argc
, "ip", &idx
))
9994 /* [<vrf> VIEWVRFNAME] */
9995 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9996 vrf
= argv
[idx
+ 1]->arg
;
9998 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10000 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10001 /* [<view> VIEWVRFNAME] */
10002 vrf
= argv
[idx
+ 1]->arg
;
10005 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
10006 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
10007 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
10009 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
10010 if (argv_find(argv
, argc
, "*", &idx
)) {
10011 clr_sort
= clear_all
;
10012 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
10013 clr_sort
= clear_peer
;
10014 clr_arg
= argv
[idx
]->arg
;
10015 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
10016 clr_sort
= clear_peer
;
10017 clr_arg
= argv
[idx
]->arg
;
10018 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
10019 clr_sort
= clear_group
;
10021 clr_arg
= argv
[idx
]->arg
;
10022 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
10023 clr_sort
= clear_peer
;
10024 clr_arg
= argv
[idx
]->arg
;
10025 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
10026 clr_sort
= clear_peer
;
10027 clr_arg
= argv
[idx
]->arg
;
10028 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
10029 clr_sort
= clear_as
;
10030 clr_arg
= argv
[idx
]->arg
;
10031 } else if (argv_find(argv
, argc
, "external", &idx
)) {
10032 clr_sort
= clear_external
;
10035 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
10036 if (argv_find(argv
, argc
, "soft", &idx
)) {
10037 if (argv_find(argv
, argc
, "in", &idx
)
10038 || argv_find(argv
, argc
, "out", &idx
))
10039 clr_type
= strmatch(argv
[idx
]->text
, "in")
10040 ? BGP_CLEAR_SOFT_IN
10041 : BGP_CLEAR_SOFT_OUT
;
10043 clr_type
= BGP_CLEAR_SOFT_BOTH
;
10044 } else if (argv_find(argv
, argc
, "in", &idx
)) {
10045 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
10046 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
10047 : BGP_CLEAR_SOFT_IN
;
10048 } else if (argv_find(argv
, argc
, "out", &idx
)) {
10049 clr_type
= BGP_CLEAR_SOFT_OUT
;
10051 clr_type
= BGP_CLEAR_SOFT_NONE
;
10053 ret
= bgp_clear_vty(vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
, errmsg
,
10056 vty_out(vty
, "Error description: %s\n", errmsg
);
10061 DEFUN (clear_ip_bgp_prefix
,
10062 clear_ip_bgp_prefix_cmd
,
10063 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
10067 BGP_INSTANCE_HELP_STR
10068 "Clear bestpath and re-advertise\n"
10072 char *prefix
= NULL
;
10076 /* [<view|vrf> VIEWVRFNAME] */
10077 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10078 vrf
= argv
[idx
+ 1]->arg
;
10080 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10082 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10083 /* [<view> VIEWVRFNAME] */
10084 vrf
= argv
[idx
+ 1]->arg
;
10088 prefix
= argv
[argc
- 1]->arg
;
10090 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
10093 DEFUN (clear_bgp_ipv6_safi_prefix
,
10094 clear_bgp_ipv6_safi_prefix_cmd
,
10095 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10101 "Clear bestpath and re-advertise\n"
10105 int idx_ipv6_prefix
= 0;
10106 safi_t safi
= SAFI_UNICAST
;
10107 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10108 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10110 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10111 return bgp_clear_prefix(
10112 vty
, NULL
, prefix
, AFI_IP6
,
10116 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
10117 clear_bgp_instance_ipv6_safi_prefix_cmd
,
10118 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10122 BGP_INSTANCE_HELP_STR
10125 "Clear bestpath and re-advertise\n"
10129 int idx_vrfview
= 0;
10130 int idx_ipv6_prefix
= 0;
10131 safi_t safi
= SAFI_UNICAST
;
10132 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10133 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10134 char *vrfview
= NULL
;
10136 /* [<view|vrf> VIEWVRFNAME] */
10137 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
10138 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10139 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
10141 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
10142 /* [<view> VIEWVRFNAME] */
10143 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10145 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10147 return bgp_clear_prefix(
10148 vty
, vrfview
, prefix
,
10149 AFI_IP6
, safi
, NULL
);
10152 DEFUN (show_bgp_views
,
10153 show_bgp_views_cmd
,
10154 "show [ip] bgp views",
10158 "Show the defined BGP views\n")
10160 struct list
*inst
= bm
->bgp
;
10161 struct listnode
*node
;
10164 vty_out(vty
, "Defined BGP views:\n");
10165 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10167 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10169 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
10173 return CMD_SUCCESS
;
10176 DEFUN (show_bgp_vrfs
,
10178 "show [ip] bgp vrfs [json]",
10185 char buf
[ETHER_ADDR_STRLEN
];
10186 struct list
*inst
= bm
->bgp
;
10187 struct listnode
*node
;
10189 bool uj
= use_json(argc
, argv
);
10190 json_object
*json
= NULL
;
10191 json_object
*json_vrfs
= NULL
;
10195 json
= json_object_new_object();
10196 json_vrfs
= json_object_new_object();
10199 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10200 const char *name
, *type
;
10202 struct listnode
*node2
, *nnode2
;
10203 int peers_cfg
, peers_estb
;
10204 json_object
*json_vrf
= NULL
;
10207 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10211 if (!uj
&& count
== 1) {
10213 "%4s %-5s %-16s %9s %10s %-37s\n",
10214 "Type", "Id", "routerId", "#PeersCfg",
10215 "#PeersEstb", "Name");
10216 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10217 "L3-VNI", "RouterMAC", "Interface");
10220 peers_cfg
= peers_estb
= 0;
10222 json_vrf
= json_object_new_object();
10225 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
10226 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10229 if (peer
->status
== Established
)
10233 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10234 name
= VRF_DEFAULT_NAME
;
10243 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10245 : (int64_t)bgp
->vrf_id
;
10246 char buf
[BUFSIZ
] = {0};
10248 json_object_string_add(json_vrf
, "type", type
);
10249 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
10250 json_object_string_add(json_vrf
, "routerId",
10252 &bgp
->router_id
, buf
,
10254 json_object_int_add(json_vrf
, "numConfiguredPeers",
10256 json_object_int_add(json_vrf
, "numEstablishedPeers",
10259 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
10260 json_object_string_add(
10262 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
10263 json_object_string_add(json_vrf
, "interface",
10264 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10266 json_object_object_add(json_vrfs
, name
, json_vrf
);
10268 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10270 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10271 : (int)bgp
->vrf_id
,
10272 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10273 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
10275 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
10276 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10282 json_object_object_add(json
, "vrfs", json_vrfs
);
10284 json_object_int_add(json
, "totalVrfs", count
);
10286 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10287 json
, JSON_C_TO_STRING_PRETTY
));
10288 json_object_free(json
);
10292 "\nTotal number of VRFs (including default): %d\n",
10296 return CMD_SUCCESS
;
10299 DEFUN (show_bgp_mac_hash
,
10300 show_bgp_mac_hash_cmd
,
10301 "show bgp mac hash",
10305 "Mac Address database\n")
10307 bgp_mac_dump_table(vty
);
10309 return CMD_SUCCESS
;
10312 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10314 struct vty
*vty
= (struct vty
*)args
;
10315 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10317 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10320 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10322 vty_out(vty
, "self nexthop database:\n");
10323 bgp_nexthop_show_address_hash(vty
, bgp
);
10325 vty_out(vty
, "Tunnel-ip database:\n");
10326 hash_iterate(bgp
->tip_hash
,
10327 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10331 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10332 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10333 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10334 "martian next-hops\n"
10335 "martian next-hop database\n")
10337 struct bgp
*bgp
= NULL
;
10341 /* [<vrf> VIEWVRFNAME] */
10342 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10343 name
= argv
[idx
+ 1]->arg
;
10344 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10346 } else if (argv_find(argv
, argc
, "view", &idx
))
10347 /* [<view> VIEWVRFNAME] */
10348 name
= argv
[idx
+ 1]->arg
;
10350 bgp
= bgp_lookup_by_name(name
);
10352 bgp
= bgp_get_default();
10355 vty_out(vty
, "%% No BGP process is configured\n");
10356 return CMD_WARNING
;
10358 bgp_show_martian_nexthops(vty
, bgp
);
10360 return CMD_SUCCESS
;
10363 DEFUN (show_bgp_memory
,
10364 show_bgp_memory_cmd
,
10365 "show [ip] bgp memory",
10369 "Global BGP memory statistics\n")
10371 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10372 unsigned long count
;
10374 /* RIB related usage stats */
10375 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10376 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10377 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10378 count
* sizeof(struct bgp_dest
)));
10380 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10381 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10382 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10383 count
* sizeof(struct bgp_path_info
)));
10384 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10385 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10388 memstrbuf
, sizeof(memstrbuf
),
10389 count
* sizeof(struct bgp_path_info_extra
)));
10391 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10392 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10393 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10394 count
* sizeof(struct bgp_static
)));
10396 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10397 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10398 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10399 count
* sizeof(struct bpacket
)));
10402 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10403 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10404 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10405 count
* sizeof(struct bgp_adj_in
)));
10406 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10407 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10408 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10409 count
* sizeof(struct bgp_adj_out
)));
10411 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10412 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10414 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10415 count
* sizeof(struct bgp_nexthop_cache
)));
10417 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10418 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10420 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10421 count
* sizeof(struct bgp_damp_info
)));
10424 count
= attr_count();
10425 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10426 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10427 count
* sizeof(struct attr
)));
10429 if ((count
= attr_unknown_count()))
10430 vty_out(vty
, "%ld unknown attributes\n", count
);
10432 /* AS_PATH attributes */
10433 count
= aspath_count();
10434 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10435 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10436 count
* sizeof(struct aspath
)));
10438 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10439 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10440 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10441 count
* sizeof(struct assegment
)));
10443 /* Other attributes */
10444 if ((count
= community_count()))
10445 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10446 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10447 count
* sizeof(struct community
)));
10448 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10449 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10450 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10451 count
* sizeof(struct ecommunity
)));
10452 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10454 "%ld BGP large-community entries, using %s of memory\n",
10455 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10456 count
* sizeof(struct lcommunity
)));
10458 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10459 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10460 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10461 count
* sizeof(struct cluster_list
)));
10463 /* Peer related usage */
10464 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10465 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10466 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10467 count
* sizeof(struct peer
)));
10469 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10470 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10471 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10472 count
* sizeof(struct peer_group
)));
10475 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10476 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10477 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10478 count
* sizeof(regex_t
)));
10479 return CMD_SUCCESS
;
10482 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10484 json_object
*bestpath
= json_object_new_object();
10486 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10487 json_object_string_add(bestpath
, "asPath", "ignore");
10489 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10490 json_object_string_add(bestpath
, "asPath", "confed");
10492 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10493 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10494 json_object_string_add(bestpath
, "multiPathRelax",
10497 json_object_string_add(bestpath
, "multiPathRelax",
10500 json_object_string_add(bestpath
, "multiPathRelax", "false");
10502 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10503 json_object_string_add(bestpath
, "compareRouterId", "true");
10504 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10505 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10506 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10507 json_object_string_add(bestpath
, "med", "confed");
10508 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10509 json_object_string_add(bestpath
, "med",
10510 "missing-as-worst");
10512 json_object_string_add(bestpath
, "med", "true");
10515 json_object_object_add(json
, "bestPath", bestpath
);
10518 /* Print the error code/subcode for why the peer is down */
10519 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10520 json_object
*json_peer
, bool use_json
)
10522 const char *code_str
;
10523 const char *subcode_str
;
10526 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10527 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10528 char errorcodesubcode_hexstr
[5];
10529 char errorcodesubcode_str
[256];
10531 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10532 subcode_str
= bgp_notify_subcode_str(
10534 peer
->notify
.subcode
);
10536 snprintf(errorcodesubcode_hexstr
,
10537 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10538 peer
->notify
.code
, peer
->notify
.subcode
);
10539 json_object_string_add(json_peer
,
10540 "lastErrorCodeSubcode",
10541 errorcodesubcode_hexstr
);
10542 snprintf(errorcodesubcode_str
, 255, "%s%s",
10543 code_str
, subcode_str
);
10544 json_object_string_add(json_peer
,
10545 "lastNotificationReason",
10546 errorcodesubcode_str
);
10547 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10548 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10549 && (peer
->notify
.subcode
10550 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10551 || peer
->notify
.subcode
10552 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10553 && peer
->notify
.length
) {
10555 const char *msg_str
;
10557 msg_str
= bgp_notify_admin_message(
10558 msgbuf
, sizeof(msgbuf
),
10559 (uint8_t *)peer
->notify
.data
,
10560 peer
->notify
.length
);
10562 json_object_string_add(
10564 "lastShutdownDescription",
10569 json_object_string_add(json_peer
, "lastResetDueTo",
10570 peer_down_str
[(int)peer
->last_reset
]);
10571 json_object_int_add(json_peer
, "lastResetCode",
10574 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10575 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10576 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10578 bgp_notify_subcode_str(peer
->notify
.code
,
10579 peer
->notify
.subcode
);
10580 vty_out(vty
, " Notification %s (%s%s)\n",
10581 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10584 code_str
, subcode_str
);
10586 vty_out(vty
, " %s\n",
10587 peer_down_str
[(int)peer
->last_reset
]);
10592 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10595 return ((peer
->status
!= Established
) ||
10596 !peer
->afc_recv
[afi
][safi
]);
10599 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10600 struct peer
*peer
, json_object
*json_peer
,
10601 int max_neighbor_width
, bool use_json
)
10603 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10607 if (peer_dynamic_neighbor(peer
))
10608 json_object_boolean_true_add(json_peer
,
10610 if (peer
->hostname
)
10611 json_object_string_add(json_peer
, "hostname",
10614 if (peer
->domainname
)
10615 json_object_string_add(json_peer
, "domainname",
10617 json_object_int_add(json_peer
, "connectionsEstablished",
10618 peer
->established
);
10619 json_object_int_add(json_peer
, "connectionsDropped",
10621 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10622 use_json
, json_peer
);
10623 if (peer
->status
== Established
)
10624 json_object_string_add(json_peer
, "lastResetDueTo",
10625 "AFI/SAFI Not Negotiated");
10627 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10630 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10632 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10633 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10634 peer
->hostname
, peer
->host
);
10636 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10638 /* pad the neighbor column with spaces */
10639 if (len
< max_neighbor_width
)
10640 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10642 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10644 peer_uptime(peer
->uptime
, timebuf
,
10645 BGP_UPTIME_LEN
, 0, NULL
));
10646 if (peer
->status
== Established
)
10647 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10649 bgp_show_peer_reset(vty
, peer
, NULL
,
10655 /* Show BGP peer's summary information. */
10656 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10657 bool show_failed
, bool show_established
,
10661 struct listnode
*node
, *nnode
;
10662 unsigned int count
= 0, dn_count
= 0;
10663 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10664 char neighbor_buf
[VTY_BUFSIZ
];
10665 int neighbor_col_default_width
= 16;
10666 int len
, failed_count
= 0;
10667 int max_neighbor_width
= 0;
10669 json_object
*json
= NULL
;
10670 json_object
*json_peer
= NULL
;
10671 json_object
*json_peers
= NULL
;
10672 struct peer_af
*paf
;
10673 struct bgp_filter
*filter
;
10675 /* labeled-unicast routes are installed in the unicast table so in order
10677 * display the correct PfxRcd value we must look at SAFI_UNICAST
10680 if (safi
== SAFI_LABELED_UNICAST
)
10681 pfx_rcd_safi
= SAFI_UNICAST
;
10683 pfx_rcd_safi
= safi
;
10686 json
= json_object_new_object();
10687 json_peers
= json_object_new_object();
10688 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10689 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10692 if (peer
->afc
[afi
][safi
]) {
10693 /* See if we have at least a single failed peer */
10694 if (bgp_has_peer_failed(peer
, afi
, safi
))
10698 if (peer_dynamic_neighbor(peer
))
10703 /* Loop over all neighbors that will be displayed to determine
10705 * characters are needed for the Neighbor column
10707 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10708 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10711 if (peer
->afc
[afi
][safi
]) {
10712 memset(dn_flag
, '\0', sizeof(dn_flag
));
10713 if (peer_dynamic_neighbor(peer
))
10717 && CHECK_FLAG(bgp
->flags
,
10718 BGP_FLAG_SHOW_HOSTNAME
))
10719 snprintf(neighbor_buf
,
10720 sizeof(neighbor_buf
),
10721 "%s%s(%s) ", dn_flag
,
10722 peer
->hostname
, peer
->host
);
10724 snprintf(neighbor_buf
,
10725 sizeof(neighbor_buf
), "%s%s ",
10726 dn_flag
, peer
->host
);
10728 len
= strlen(neighbor_buf
);
10730 if (len
> max_neighbor_width
)
10731 max_neighbor_width
= len
;
10733 /* See if we have at least a single failed peer */
10734 if (bgp_has_peer_failed(peer
, afi
, safi
))
10740 /* Originally we displayed the Neighbor column as 16
10741 * characters wide so make that the default
10743 if (max_neighbor_width
< neighbor_col_default_width
)
10744 max_neighbor_width
= neighbor_col_default_width
;
10747 if (show_failed
&& !failed_count
) {
10749 json_object_int_add(json
, "failedPeersCount", 0);
10750 json_object_int_add(json
, "dynamicPeers", dn_count
);
10751 json_object_int_add(json
, "totalPeers", count
);
10753 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10754 json
, JSON_C_TO_STRING_PRETTY
));
10755 json_object_free(json
);
10757 vty_out(vty
, "%% No failed BGP neighbors found\n");
10758 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
10760 return CMD_SUCCESS
;
10763 count
= 0; /* Reset the value as its used again */
10764 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10765 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10768 if (!peer
->afc
[afi
][safi
])
10772 unsigned long ents
;
10773 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10776 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10778 : (int64_t)bgp
->vrf_id
;
10780 /* Usage summary and header */
10782 char buf
[BUFSIZ
] = {0};
10784 json_object_string_add(
10786 inet_ntop(AF_INET
, &bgp
->router_id
, buf
,
10788 json_object_int_add(json
, "as", bgp
->as
);
10789 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10790 json_object_string_add(
10793 == BGP_INSTANCE_TYPE_DEFAULT
)
10798 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10799 &bgp
->router_id
, bgp
->as
,
10800 bgp
->vrf_id
== VRF_UNKNOWN
10802 : (int)bgp
->vrf_id
);
10803 vty_out(vty
, "\n");
10806 if (bgp_update_delay_configured(bgp
)) {
10808 json_object_int_add(
10809 json
, "updateDelayLimit",
10810 bgp
->v_update_delay
);
10812 if (bgp
->v_update_delay
10813 != bgp
->v_establish_wait
)
10814 json_object_int_add(
10816 "updateDelayEstablishWait",
10817 bgp
->v_establish_wait
);
10819 if (bgp_update_delay_active(bgp
)) {
10820 json_object_string_add(
10822 "updateDelayFirstNeighbor",
10823 bgp
->update_delay_begin_time
);
10824 json_object_boolean_true_add(
10826 "updateDelayInProgress");
10828 if (bgp
->update_delay_over
) {
10829 json_object_string_add(
10831 "updateDelayFirstNeighbor",
10832 bgp
->update_delay_begin_time
);
10833 json_object_string_add(
10835 "updateDelayBestpathResumed",
10836 bgp
->update_delay_end_time
);
10837 json_object_string_add(
10839 "updateDelayZebraUpdateResume",
10840 bgp
->update_delay_zebra_resume_time
);
10841 json_object_string_add(
10843 "updateDelayPeerUpdateResume",
10844 bgp
->update_delay_peers_resume_time
);
10849 "Read-only mode update-delay limit: %d seconds\n",
10850 bgp
->v_update_delay
);
10851 if (bgp
->v_update_delay
10852 != bgp
->v_establish_wait
)
10854 " Establish wait: %d seconds\n",
10855 bgp
->v_establish_wait
);
10857 if (bgp_update_delay_active(bgp
)) {
10859 " First neighbor established: %s\n",
10860 bgp
->update_delay_begin_time
);
10862 " Delay in progress\n");
10864 if (bgp
->update_delay_over
) {
10866 " First neighbor established: %s\n",
10867 bgp
->update_delay_begin_time
);
10869 " Best-paths resumed: %s\n",
10870 bgp
->update_delay_end_time
);
10872 " zebra update resumed: %s\n",
10873 bgp
->update_delay_zebra_resume_time
);
10875 " peers update resumed: %s\n",
10876 bgp
->update_delay_peers_resume_time
);
10883 if (bgp_maxmed_onstartup_configured(bgp
)
10884 && bgp
->maxmed_active
)
10885 json_object_boolean_true_add(
10886 json
, "maxMedOnStartup");
10887 if (bgp
->v_maxmed_admin
)
10888 json_object_boolean_true_add(
10889 json
, "maxMedAdministrative");
10891 json_object_int_add(
10892 json
, "tableVersion",
10893 bgp_table_version(bgp
->rib
[afi
][safi
]));
10895 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10896 json_object_int_add(json
, "ribCount", ents
);
10897 json_object_int_add(
10899 ents
* sizeof(struct bgp_dest
));
10901 ents
= bgp
->af_peer_count
[afi
][safi
];
10902 json_object_int_add(json
, "peerCount", ents
);
10903 json_object_int_add(json
, "peerMemory",
10904 ents
* sizeof(struct peer
));
10906 if ((ents
= listcount(bgp
->group
))) {
10907 json_object_int_add(
10908 json
, "peerGroupCount", ents
);
10909 json_object_int_add(
10910 json
, "peerGroupMemory",
10911 ents
* sizeof(struct
10915 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10916 BGP_CONFIG_DAMPENING
))
10917 json_object_boolean_true_add(
10918 json
, "dampeningEnabled");
10920 if (bgp_maxmed_onstartup_configured(bgp
)
10921 && bgp
->maxmed_active
)
10923 "Max-med on-startup active\n");
10924 if (bgp
->v_maxmed_admin
)
10926 "Max-med administrative active\n");
10928 vty_out(vty
, "BGP table version %" PRIu64
"\n",
10929 bgp_table_version(bgp
->rib
[afi
][safi
]));
10931 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10933 "RIB entries %ld, using %s of memory\n",
10936 memstrbuf
, sizeof(memstrbuf
),
10941 /* Peer related usage */
10942 ents
= bgp
->af_peer_count
[afi
][safi
];
10943 vty_out(vty
, "Peers %ld, using %s of memory\n",
10946 memstrbuf
, sizeof(memstrbuf
),
10947 ents
* sizeof(struct peer
)));
10949 if ((ents
= listcount(bgp
->group
)))
10951 "Peer groups %ld, using %s of memory\n",
10956 ents
* sizeof(struct
10959 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10960 BGP_CONFIG_DAMPENING
))
10961 vty_out(vty
, "Dampening enabled.\n");
10962 vty_out(vty
, "\n");
10964 /* Subtract 8 here because 'Neighbor' is
10966 vty_out(vty
, "Neighbor");
10967 vty_out(vty
, "%*s", max_neighbor_width
- 8,
10970 vty_out(vty
, "EstdCnt DropCnt ResetTime Reason\n");
10973 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc\n");
10977 paf
= peer_af_find(peer
, afi
, safi
);
10978 filter
= &peer
->filter
[afi
][safi
];
10981 /* Works for both failed & successful cases */
10982 if (peer_dynamic_neighbor(peer
))
10989 bgp_has_peer_failed(peer
, afi
, safi
)) {
10990 json_peer
= json_object_new_object();
10991 bgp_show_failed_summary(vty
, bgp
, peer
,
10992 json_peer
, 0, use_json
);
10993 } else if (!show_failed
) {
10994 if (show_established
10995 && bgp_has_peer_failed(peer
, afi
, safi
))
10998 json_peer
= json_object_new_object();
10999 if (peer_dynamic_neighbor(peer
)) {
11000 json_object_boolean_true_add(json_peer
,
11004 if (peer
->hostname
)
11005 json_object_string_add(json_peer
, "hostname",
11008 if (peer
->domainname
)
11009 json_object_string_add(json_peer
, "domainname",
11012 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
11013 json_object_int_add(json_peer
, "version", 4);
11014 json_object_int_add(json_peer
, "msgRcvd",
11015 PEER_TOTAL_RX(peer
));
11016 json_object_int_add(json_peer
, "msgSent",
11017 PEER_TOTAL_TX(peer
));
11019 atomic_size_t outq_count
, inq_count
;
11020 outq_count
= atomic_load_explicit(
11021 &peer
->obuf
->count
,
11022 memory_order_relaxed
);
11023 inq_count
= atomic_load_explicit(
11024 &peer
->ibuf
->count
,
11025 memory_order_relaxed
);
11027 json_object_int_add(json_peer
, "tableVersion",
11028 peer
->version
[afi
][safi
]);
11029 json_object_int_add(json_peer
, "outq",
11031 json_object_int_add(json_peer
, "inq",
11033 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
11034 use_json
, json_peer
);
11036 json_object_int_add(json_peer
, "pfxRcd",
11037 peer
->pcount
[afi
][pfx_rcd_safi
]);
11039 if (paf
&& PAF_SUBGRP(paf
))
11040 json_object_int_add(
11041 json_peer
, "pfxSnt",
11042 (PAF_SUBGRP(paf
))->scount
);
11044 json_object_int_add(json_peer
, "pfxSnt",
11047 /* BGP FSM state */
11048 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11049 || CHECK_FLAG(peer
->bgp
->flags
,
11050 BGP_FLAG_SHUTDOWN
))
11051 json_object_string_add(json_peer
,
11054 else if (peer
->afc_recv
[afi
][safi
])
11055 json_object_string_add(
11056 json_peer
, "state",
11057 lookup_msg(bgp_status_msg
,
11058 peer
->status
, NULL
));
11059 else if (CHECK_FLAG(
11061 PEER_STATUS_PREFIX_OVERFLOW
))
11062 json_object_string_add(json_peer
,
11066 json_object_string_add(
11067 json_peer
, "state",
11068 lookup_msg(bgp_status_msg
,
11069 peer
->status
, NULL
));
11071 /* BGP peer state */
11072 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11073 || CHECK_FLAG(peer
->bgp
->flags
,
11074 BGP_FLAG_SHUTDOWN
))
11075 json_object_string_add(json_peer
,
11078 else if (CHECK_FLAG(
11080 PEER_STATUS_PREFIX_OVERFLOW
))
11081 json_object_string_add(json_peer
,
11084 else if (CHECK_FLAG(peer
->flags
,
11085 PEER_FLAG_PASSIVE
))
11086 json_object_string_add(json_peer
,
11089 else if (CHECK_FLAG(peer
->sflags
,
11090 PEER_STATUS_NSF_WAIT
))
11091 json_object_string_add(json_peer
,
11094 else if (CHECK_FLAG(
11096 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11097 && (!bgp_inbound_policy_exists(peer
,
11099 || !bgp_outbound_policy_exists(
11101 json_object_string_add(json_peer
,
11105 json_object_string_add(
11106 json_peer
, "peerState", "OK");
11108 json_object_int_add(json_peer
, "connectionsEstablished",
11109 peer
->established
);
11110 json_object_int_add(json_peer
, "connectionsDropped",
11113 json_object_string_add(
11114 json_peer
, "desc", peer
->desc
);
11116 /* Avoid creating empty peer dicts in JSON */
11117 if (json_peer
== NULL
)
11121 json_object_string_add(json_peer
, "idType",
11123 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11124 json_object_string_add(json_peer
, "idType",
11126 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11127 json_object_string_add(json_peer
, "idType",
11129 json_object_object_add(json_peers
, peer
->host
,
11133 bgp_has_peer_failed(peer
, afi
, safi
)) {
11134 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11135 max_neighbor_width
,
11137 } else if (!show_failed
) {
11138 if (show_established
11139 && bgp_has_peer_failed(peer
, afi
, safi
))
11142 memset(dn_flag
, '\0', sizeof(dn_flag
));
11143 if (peer_dynamic_neighbor(peer
)) {
11148 && CHECK_FLAG(bgp
->flags
,
11149 BGP_FLAG_SHOW_HOSTNAME
))
11150 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11154 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11156 /* pad the neighbor column with spaces */
11157 if (len
< max_neighbor_width
)
11158 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11161 atomic_size_t outq_count
, inq_count
;
11162 outq_count
= atomic_load_explicit(
11163 &peer
->obuf
->count
,
11164 memory_order_relaxed
);
11165 inq_count
= atomic_load_explicit(
11166 &peer
->ibuf
->count
,
11167 memory_order_relaxed
);
11170 "4 %10u %9u %9u %8" PRIu64
" %4zu %4zu %8s",
11171 peer
->as
, PEER_TOTAL_RX(peer
),
11172 PEER_TOTAL_TX(peer
),
11173 peer
->version
[afi
][safi
], inq_count
,
11175 peer_uptime(peer
->uptime
, timebuf
,
11176 BGP_UPTIME_LEN
, 0, NULL
));
11178 if (peer
->status
== Established
) {
11179 if (peer
->afc_recv
[afi
][safi
]) {
11182 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11183 && !bgp_inbound_policy_exists(
11185 vty_out(vty
, " %12s",
11194 vty_out(vty
, " NoNeg");
11197 if (paf
&& PAF_SUBGRP(paf
)) {
11200 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11201 && !bgp_outbound_policy_exists(
11203 vty_out(vty
, " %8s",
11213 if (CHECK_FLAG(peer
->flags
,
11214 PEER_FLAG_SHUTDOWN
)
11215 || CHECK_FLAG(peer
->bgp
->flags
,
11216 BGP_FLAG_SHUTDOWN
))
11217 vty_out(vty
, " Idle (Admin)");
11218 else if (CHECK_FLAG(
11220 PEER_STATUS_PREFIX_OVERFLOW
))
11221 vty_out(vty
, " Idle (PfxCt)");
11223 vty_out(vty
, " %12s",
11224 lookup_msg(bgp_status_msg
,
11225 peer
->status
, NULL
));
11227 vty_out(vty
, " %8u", 0);
11230 vty_out(vty
, " %s", peer
->desc
);
11232 vty_out(vty
, " N/A");
11233 vty_out(vty
, "\n");
11240 json_object_object_add(json
, "peers", json_peers
);
11241 json_object_int_add(json
, "failedPeers", failed_count
);
11242 json_object_int_add(json
, "totalPeers", count
);
11243 json_object_int_add(json
, "dynamicPeers", dn_count
);
11246 bgp_show_bestpath_json(bgp
, json
);
11248 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11249 json
, JSON_C_TO_STRING_PRETTY
));
11250 json_object_free(json
);
11253 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
11255 vty_out(vty
, "No %s neighbor is configured\n",
11256 get_afi_safi_str(afi
, safi
, false));
11260 vty_out(vty
, "* - dynamic neighbor\n");
11261 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11262 dn_count
, bgp
->dynamic_neighbors_limit
);
11266 return CMD_SUCCESS
;
11269 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11270 int safi
, bool show_failed
,
11271 bool show_established
, bool use_json
)
11274 int afi_wildcard
= (afi
== AFI_MAX
);
11275 int safi_wildcard
= (safi
== SAFI_MAX
);
11276 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11277 bool nbr_output
= false;
11279 if (use_json
&& is_wildcard
)
11280 vty_out(vty
, "{\n");
11282 afi
= 1; /* AFI_IP */
11283 while (afi
< AFI_MAX
) {
11285 safi
= 1; /* SAFI_UNICAST */
11286 while (safi
< SAFI_MAX
) {
11287 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11292 * So limit output to those afi/safi
11294 * actualy have something interesting in
11299 vty_out(vty
, ",\n");
11303 vty_out(vty
, "\"%s\":",
11304 get_afi_safi_str(afi
,
11308 vty_out(vty
, "\n%s Summary:\n",
11309 get_afi_safi_str(afi
,
11314 bgp_show_summary(vty
, bgp
, afi
, safi
,
11315 show_failed
, show_established
,
11319 if (!safi_wildcard
)
11327 if (use_json
&& is_wildcard
)
11328 vty_out(vty
, "}\n");
11329 else if (!nbr_output
) {
11331 vty_out(vty
, "{}\n");
11333 vty_out(vty
, "%% No BGP neighbors found\n");
11337 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11338 safi_t safi
, bool show_failed
,
11339 bool show_established
,
11342 struct listnode
*node
, *nnode
;
11345 bool nbr_output
= false;
11348 vty_out(vty
, "{\n");
11350 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11354 vty_out(vty
, ",\n");
11358 vty_out(vty
, "\"%s\":",
11359 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11363 vty_out(vty
, "\nInstance %s:\n",
11364 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11368 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
11369 show_established
, use_json
);
11373 vty_out(vty
, "}\n");
11374 else if (!nbr_output
)
11375 vty_out(vty
, "%% BGP instance not found\n");
11378 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11379 safi_t safi
, bool show_failed
, bool show_established
,
11385 if (strmatch(name
, "all")) {
11386 bgp_show_all_instances_summary_vty(
11387 vty
, afi
, safi
, show_failed
, show_established
,
11389 return CMD_SUCCESS
;
11391 bgp
= bgp_lookup_by_name(name
);
11395 vty_out(vty
, "{}\n");
11398 "%% BGP instance not found\n");
11399 return CMD_WARNING
;
11402 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
,
11403 show_failed
, show_established
,
11405 return CMD_SUCCESS
;
11409 bgp
= bgp_get_default();
11412 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
11413 show_established
, use_json
);
11416 vty_out(vty
, "{}\n");
11418 vty_out(vty
, "%% BGP instance not found\n");
11419 return CMD_WARNING
;
11422 return CMD_SUCCESS
;
11425 /* `show [ip] bgp summary' commands. */
11426 DEFPY (show_ip_bgp_summary
,
11427 show_ip_bgp_summary_cmd
,
11428 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] [all$all] summary [established|failed] [json$uj]",
11432 BGP_INSTANCE_HELP_STR
11434 BGP_SAFI_WITH_LABEL_HELP_STR
11435 "Display the entries for all address families\n"
11436 "Summary of BGP neighbor status\n"
11437 "Show only sessions in Established state\n"
11438 "Show only sessions not in Established state\n"
11442 afi_t afi
= AFI_MAX
;
11443 safi_t safi
= SAFI_MAX
;
11444 bool show_failed
= false;
11445 bool show_established
= false;
11449 /* show [ip] bgp */
11450 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11452 /* [<vrf> VIEWVRFNAME] */
11453 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11454 vrf
= argv
[idx
+ 1]->arg
;
11455 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11457 } else if (argv_find(argv
, argc
, "view", &idx
))
11458 /* [<view> VIEWVRFNAME] */
11459 vrf
= argv
[idx
+ 1]->arg
;
11460 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11461 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11462 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11465 if (argv_find(argv
, argc
, "failed", &idx
))
11466 show_failed
= true;
11467 if (argv_find(argv
, argc
, "established", &idx
))
11468 show_established
= true;
11470 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, show_failed
,
11471 show_established
, uj
);
11474 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11477 return get_afi_safi_json_str(afi
, safi
);
11479 return get_afi_safi_vty_str(afi
, safi
);
11483 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11484 afi_t afi
, safi_t safi
,
11485 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11486 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11487 bool use_json
, json_object
*json_pref
)
11490 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11491 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11493 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11494 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11495 json_object_string_add(json_pref
, "sendMode",
11496 "advertisedAndReceived");
11497 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11498 json_object_string_add(json_pref
, "sendMode",
11500 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11501 json_object_string_add(json_pref
, "sendMode",
11504 vty_out(vty
, " Send-mode: ");
11505 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11506 vty_out(vty
, "advertised");
11507 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11508 vty_out(vty
, "%sreceived",
11509 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11513 vty_out(vty
, "\n");
11518 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11519 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11521 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11522 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11523 json_object_string_add(json_pref
, "recvMode",
11524 "advertisedAndReceived");
11525 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11526 json_object_string_add(json_pref
, "recvMode",
11528 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11529 json_object_string_add(json_pref
, "recvMode",
11532 vty_out(vty
, " Receive-mode: ");
11533 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11534 vty_out(vty
, "advertised");
11535 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11536 vty_out(vty
, "%sreceived",
11537 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11541 vty_out(vty
, "\n");
11546 static void bgp_show_neighnor_graceful_restart_rbit(struct vty
*vty
,
11551 bool rbit_status
= false;
11554 vty_out(vty
, "\n R bit: ");
11556 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11557 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11558 && (p
->status
== Established
)) {
11560 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_BIT_RCV
))
11561 rbit_status
= true;
11563 rbit_status
= false;
11568 json_object_boolean_true_add(json
, "rBit");
11570 vty_out(vty
, "True\n");
11573 json_object_boolean_false_add(json
, "rBit");
11575 vty_out(vty
, "False\n");
11579 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11584 const char *mode
= "NotApplicable";
11587 vty_out(vty
, "\n Remote GR Mode: ");
11589 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11590 && (peer
->status
== Established
)) {
11592 if ((peer
->nsf_af_count
== 0)
11593 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11597 } else if (peer
->nsf_af_count
== 0
11598 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11602 } else if (peer
->nsf_af_count
!= 0
11603 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11610 json_object_string_add(json
, "remoteGrMode", mode
);
11612 vty_out(vty
, mode
, "\n");
11615 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11620 const char *mode
= "Invalid";
11623 vty_out(vty
, " Local GR Mode: ");
11625 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11627 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11629 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11631 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11632 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11634 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11636 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11643 json_object_string_add(json
, "localGrMode", mode
);
11645 vty_out(vty
, mode
, "\n");
11649 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11650 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11654 json_object
*json_afi_safi
= NULL
;
11655 json_object
*json_timer
= NULL
;
11656 json_object
*json_endofrib_status
= NULL
;
11657 bool eor_flag
= false;
11659 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11660 for (safi
= SAFI_UNICAST
; safi
<= SAFI_MPLS_VPN
; safi
++) {
11661 if (!peer
->afc
[afi
][safi
])
11664 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11665 || !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11669 json_afi_safi
= json_object_new_object();
11670 json_endofrib_status
= json_object_new_object();
11671 json_timer
= json_object_new_object();
11674 if (peer
->eor_stime
[afi
][safi
]
11675 >= peer
->pkt_stime
[afi
][safi
])
11681 vty_out(vty
, " %s:\n",
11682 get_afi_safi_str(afi
, safi
, false));
11684 vty_out(vty
, " F bit: ");
11687 if (peer
->nsf
[afi
][safi
]
11688 && CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11689 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11692 json_object_boolean_true_add(
11693 json_afi_safi
, "fBit");
11695 vty_out(vty
, "True\n");
11698 json_object_boolean_false_add(
11699 json_afi_safi
, "fBit");
11701 vty_out(vty
, "False\n");
11705 vty_out(vty
, " End-of-RIB sent: ");
11707 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11708 PEER_STATUS_EOR_SEND
)) {
11710 json_object_boolean_true_add(
11711 json_endofrib_status
,
11714 PRINT_EOR_JSON(eor_flag
);
11716 vty_out(vty
, "Yes\n");
11718 " End-of-RIB sent after update: ");
11720 PRINT_EOR(eor_flag
);
11724 json_object_boolean_false_add(
11725 json_endofrib_status
,
11727 json_object_boolean_false_add(
11728 json_endofrib_status
,
11729 "endOfRibSentAfterUpdate");
11731 vty_out(vty
, "No\n");
11733 " End-of-RIB sent after update: ");
11734 vty_out(vty
, "No\n");
11739 vty_out(vty
, " End-of-RIB received: ");
11741 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11742 PEER_STATUS_EOR_RECEIVED
)) {
11744 json_object_boolean_true_add(
11745 json_endofrib_status
,
11748 vty_out(vty
, "Yes\n");
11751 json_object_boolean_false_add(
11752 json_endofrib_status
,
11755 vty_out(vty
, "No\n");
11759 json_object_int_add(json_timer
,
11761 peer
->bgp
->stalepath_time
);
11763 if (peer
->t_gr_stale
!= NULL
) {
11764 json_object_int_add(
11766 "stalePathTimerRemaining",
11767 thread_timer_remain_second(
11768 peer
->t_gr_stale
));
11771 /* Display Configured Selection
11772 * Deferral only when when
11773 * Gr mode is enabled.
11775 if (CHECK_FLAG(peer
->flags
,
11776 PEER_FLAG_GRACEFUL_RESTART
)) {
11777 json_object_int_add(
11779 "selectionDeferralTimer",
11780 peer
->bgp
->stalepath_time
);
11783 if (peer
->bgp
->gr_info
[afi
][safi
]
11787 json_object_int_add(
11789 "selectionDeferralTimerRemaining",
11790 thread_timer_remain_second(
11794 .t_select_deferral
));
11797 vty_out(vty
, " Timers:\n");
11799 " Configured Stale Path Time(sec): %u\n",
11800 peer
->bgp
->stalepath_time
);
11802 if (peer
->t_gr_stale
!= NULL
)
11804 " Stale Path Remaining(sec): %ld\n",
11805 thread_timer_remain_second(
11806 peer
->t_gr_stale
));
11807 /* Display Configured Selection
11808 * Deferral only when when
11809 * Gr mode is enabled.
11811 if (CHECK_FLAG(peer
->flags
,
11812 PEER_FLAG_GRACEFUL_RESTART
))
11814 " Configured Selection Deferral Time(sec): %u\n",
11815 peer
->bgp
->select_defer_time
);
11817 if (peer
->bgp
->gr_info
[afi
][safi
]
11821 " Selection Deferral Time Remaining(sec): %ld\n",
11822 thread_timer_remain_second(
11826 .t_select_deferral
));
11829 json_object_object_add(json_afi_safi
,
11831 json_endofrib_status
);
11832 json_object_object_add(json_afi_safi
, "timers",
11834 json_object_object_add(
11835 json
, get_afi_safi_str(afi
, safi
, true),
11842 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
11848 json_object
*json_timer
= NULL
;
11850 json_timer
= json_object_new_object();
11852 json_object_int_add(json_timer
, "configuredRestartTimer",
11853 p
->bgp
->restart_time
);
11855 json_object_int_add(json_timer
, "receivedRestartTimer",
11858 if (p
->t_gr_restart
!= NULL
)
11859 json_object_int_add(
11860 json_timer
, "restartTimerRemaining",
11861 thread_timer_remain_second(p
->t_gr_restart
));
11863 json_object_object_add(json
, "timers", json_timer
);
11866 vty_out(vty
, " Timers:\n");
11867 vty_out(vty
, " Configured Restart Time(sec): %u\n",
11868 p
->bgp
->restart_time
);
11870 vty_out(vty
, " Received Restart Time(sec): %u\n",
11872 if (p
->t_gr_restart
!= NULL
)
11873 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11874 thread_timer_remain_second(p
->t_gr_restart
));
11875 if (p
->t_gr_restart
!= NULL
) {
11876 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11877 thread_timer_remain_second(p
->t_gr_restart
));
11882 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
11883 bool use_json
, json_object
*json
)
11885 char buf
[SU_ADDRSTRLEN
] = {0};
11886 char dn_flag
[2] = {0};
11887 /* '*' + v6 address of neighbor */
11888 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
11890 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11895 json_object_string_add(
11896 json
, "neighborAddr",
11897 BGP_PEER_SU_UNSPEC(p
)
11899 : sockunion2str(&p
->su
, buf
,
11902 vty_out(vty
, "BGP neighbor on %s: %s\n", p
->conf_if
,
11903 BGP_PEER_SU_UNSPEC(p
)
11905 : sockunion2str(&p
->su
, buf
,
11908 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
11912 json_object_string_add(json
, "neighborAddr",
11915 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
11918 /* more gr info in new format */
11919 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
11922 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
11923 safi_t safi
, bool use_json
,
11924 json_object
*json_neigh
)
11926 struct bgp_filter
*filter
;
11927 struct peer_af
*paf
;
11928 char orf_pfx_name
[BUFSIZ
];
11930 json_object
*json_af
= NULL
;
11931 json_object
*json_prefA
= NULL
;
11932 json_object
*json_prefB
= NULL
;
11933 json_object
*json_addr
= NULL
;
11934 json_object
*json_advmap
= NULL
;
11937 json_addr
= json_object_new_object();
11938 json_af
= json_object_new_object();
11939 filter
= &p
->filter
[afi
][safi
];
11941 if (peer_group_active(p
))
11942 json_object_string_add(json_addr
, "peerGroupMember",
11945 paf
= peer_af_find(p
, afi
, safi
);
11946 if (paf
&& PAF_SUBGRP(paf
)) {
11947 json_object_int_add(json_addr
, "updateGroupId",
11948 PAF_UPDGRP(paf
)->id
);
11949 json_object_int_add(json_addr
, "subGroupId",
11950 PAF_SUBGRP(paf
)->id
);
11951 json_object_int_add(json_addr
, "packetQueueLength",
11952 bpacket_queue_virtual_length(paf
));
11955 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11956 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11957 PEER_CAP_ORF_PREFIX_SM_RCV
)
11958 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11959 PEER_CAP_ORF_PREFIX_RM_ADV
)
11960 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11961 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11962 json_object_int_add(json_af
, "orfType",
11964 json_prefA
= json_object_new_object();
11965 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
11966 PEER_CAP_ORF_PREFIX_SM_ADV
,
11967 PEER_CAP_ORF_PREFIX_RM_ADV
,
11968 PEER_CAP_ORF_PREFIX_SM_RCV
,
11969 PEER_CAP_ORF_PREFIX_RM_RCV
,
11970 use_json
, json_prefA
);
11971 json_object_object_add(json_af
, "orfPrefixList",
11975 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11976 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11977 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11978 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11979 PEER_CAP_ORF_PREFIX_RM_ADV
)
11980 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11981 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
11982 json_object_int_add(json_af
, "orfOldType",
11983 ORF_TYPE_PREFIX_OLD
);
11984 json_prefB
= json_object_new_object();
11985 bgp_show_peer_afi_orf_cap(
11986 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
11987 PEER_CAP_ORF_PREFIX_RM_ADV
,
11988 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
11989 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
11991 json_object_object_add(json_af
, "orfOldPrefixList",
11995 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11996 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11997 PEER_CAP_ORF_PREFIX_SM_RCV
)
11998 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11999 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12000 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12001 PEER_CAP_ORF_PREFIX_RM_ADV
)
12002 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12003 PEER_CAP_ORF_PREFIX_RM_RCV
)
12004 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12005 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12006 json_object_object_add(json_addr
, "afDependentCap",
12009 json_object_free(json_af
);
12011 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12012 p
->host
, afi
, safi
);
12013 orf_pfx_count
= prefix_bgp_show_prefix_list(
12014 NULL
, afi
, orf_pfx_name
, use_json
);
12016 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12017 PEER_STATUS_ORF_PREFIX_SEND
)
12018 || orf_pfx_count
) {
12019 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12020 PEER_STATUS_ORF_PREFIX_SEND
))
12021 json_object_boolean_true_add(json_neigh
,
12024 json_object_int_add(json_addr
, "orfRecvCounter",
12027 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12028 PEER_STATUS_ORF_WAIT_REFRESH
))
12029 json_object_string_add(
12030 json_addr
, "orfFirstUpdate",
12031 "deferredUntilORFOrRouteRefreshRecvd");
12033 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12034 PEER_FLAG_REFLECTOR_CLIENT
))
12035 json_object_boolean_true_add(json_addr
,
12036 "routeReflectorClient");
12037 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12038 PEER_FLAG_RSERVER_CLIENT
))
12039 json_object_boolean_true_add(json_addr
,
12040 "routeServerClient");
12041 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12042 json_object_boolean_true_add(json_addr
,
12043 "inboundSoftConfigPermit");
12045 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12046 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12047 json_object_boolean_true_add(
12049 "privateAsNumsAllReplacedInUpdatesToNbr");
12050 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12051 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12052 json_object_boolean_true_add(
12054 "privateAsNumsReplacedInUpdatesToNbr");
12055 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12056 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12057 json_object_boolean_true_add(
12059 "privateAsNumsAllRemovedInUpdatesToNbr");
12060 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12061 PEER_FLAG_REMOVE_PRIVATE_AS
))
12062 json_object_boolean_true_add(
12064 "privateAsNumsRemovedInUpdatesToNbr");
12066 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12067 json_object_boolean_true_add(
12069 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12072 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12073 json_object_string_add(json_addr
,
12074 "overrideASNsInOutboundUpdates",
12075 "ifAspathEqualRemoteAs");
12077 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12078 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12079 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12080 json_object_boolean_true_add(json_addr
,
12081 "routerAlwaysNextHop");
12082 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12083 PEER_FLAG_AS_PATH_UNCHANGED
))
12084 json_object_boolean_true_add(
12085 json_addr
, "unchangedAsPathPropogatedToNbr");
12086 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12087 PEER_FLAG_NEXTHOP_UNCHANGED
))
12088 json_object_boolean_true_add(
12089 json_addr
, "unchangedNextHopPropogatedToNbr");
12090 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12091 json_object_boolean_true_add(
12092 json_addr
, "unchangedMedPropogatedToNbr");
12093 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12094 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12095 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12096 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12097 PEER_FLAG_SEND_COMMUNITY
)
12098 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12099 PEER_FLAG_SEND_EXT_COMMUNITY
))
12100 json_object_string_add(json_addr
,
12101 "commAttriSentToNbr",
12102 "extendedAndStandard");
12103 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12104 PEER_FLAG_SEND_EXT_COMMUNITY
))
12105 json_object_string_add(json_addr
,
12106 "commAttriSentToNbr",
12109 json_object_string_add(json_addr
,
12110 "commAttriSentToNbr",
12113 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12114 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12115 if (p
->default_rmap
[afi
][safi
].name
)
12116 json_object_string_add(
12117 json_addr
, "defaultRouteMap",
12118 p
->default_rmap
[afi
][safi
].name
);
12120 if (paf
&& PAF_SUBGRP(paf
)
12121 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12122 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12123 json_object_boolean_true_add(json_addr
,
12126 json_object_boolean_true_add(json_addr
,
12130 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12131 if (is_evpn_enabled())
12132 json_object_boolean_true_add(
12133 json_addr
, "advertiseAllVnis");
12136 if (filter
->plist
[FILTER_IN
].name
12137 || filter
->dlist
[FILTER_IN
].name
12138 || filter
->aslist
[FILTER_IN
].name
12139 || filter
->map
[RMAP_IN
].name
)
12140 json_object_boolean_true_add(json_addr
,
12141 "inboundPathPolicyConfig");
12142 if (filter
->plist
[FILTER_OUT
].name
12143 || filter
->dlist
[FILTER_OUT
].name
12144 || filter
->aslist
[FILTER_OUT
].name
12145 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12146 json_object_boolean_true_add(
12147 json_addr
, "outboundPathPolicyConfig");
12150 if (filter
->plist
[FILTER_IN
].name
)
12151 json_object_string_add(json_addr
,
12152 "incomingUpdatePrefixFilterList",
12153 filter
->plist
[FILTER_IN
].name
);
12154 if (filter
->plist
[FILTER_OUT
].name
)
12155 json_object_string_add(json_addr
,
12156 "outgoingUpdatePrefixFilterList",
12157 filter
->plist
[FILTER_OUT
].name
);
12159 /* distribute-list */
12160 if (filter
->dlist
[FILTER_IN
].name
)
12161 json_object_string_add(
12162 json_addr
, "incomingUpdateNetworkFilterList",
12163 filter
->dlist
[FILTER_IN
].name
);
12164 if (filter
->dlist
[FILTER_OUT
].name
)
12165 json_object_string_add(
12166 json_addr
, "outgoingUpdateNetworkFilterList",
12167 filter
->dlist
[FILTER_OUT
].name
);
12170 if (filter
->aslist
[FILTER_IN
].name
)
12171 json_object_string_add(json_addr
,
12172 "incomingUpdateAsPathFilterList",
12173 filter
->aslist
[FILTER_IN
].name
);
12174 if (filter
->aslist
[FILTER_OUT
].name
)
12175 json_object_string_add(json_addr
,
12176 "outgoingUpdateAsPathFilterList",
12177 filter
->aslist
[FILTER_OUT
].name
);
12180 if (filter
->map
[RMAP_IN
].name
)
12181 json_object_string_add(
12182 json_addr
, "routeMapForIncomingAdvertisements",
12183 filter
->map
[RMAP_IN
].name
);
12184 if (filter
->map
[RMAP_OUT
].name
)
12185 json_object_string_add(
12186 json_addr
, "routeMapForOutgoingAdvertisements",
12187 filter
->map
[RMAP_OUT
].name
);
12189 /* ebgp-requires-policy (inbound) */
12190 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12191 && !bgp_inbound_policy_exists(p
, filter
))
12192 json_object_string_add(
12193 json_addr
, "inboundEbgpRequiresPolicy",
12194 "Inbound updates discarded due to missing policy");
12196 /* ebgp-requires-policy (outbound) */
12197 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12198 && (!bgp_outbound_policy_exists(p
, filter
)))
12199 json_object_string_add(
12200 json_addr
, "outboundEbgpRequiresPolicy",
12201 "Outbound updates discarded due to missing policy");
12203 /* unsuppress-map */
12204 if (filter
->usmap
.name
)
12205 json_object_string_add(json_addr
,
12206 "selectiveUnsuppressRouteMap",
12207 filter
->usmap
.name
);
12209 /* advertise-map */
12210 if (filter
->advmap
.aname
) {
12211 json_advmap
= json_object_new_object();
12212 json_object_string_add(json_advmap
, "condition",
12213 filter
->advmap
.condition
12216 json_object_string_add(json_advmap
, "conditionMap",
12217 filter
->advmap
.cname
);
12218 json_object_string_add(json_advmap
, "advertiseMap",
12219 filter
->advmap
.aname
);
12220 json_object_string_add(json_advmap
, "advertiseStatus",
12221 filter
->advmap
.update_type
12225 json_object_object_add(json_addr
, "advertiseMap",
12229 /* Receive prefix count */
12230 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12231 p
->pcount
[afi
][safi
]);
12232 if (paf
&& PAF_SUBGRP(paf
))
12233 json_object_int_add(json_addr
, "sentPrefixCounter",
12234 (PAF_SUBGRP(paf
))->scount
);
12236 /* Maximum prefix */
12237 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12238 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12239 p
->pmax_out
[afi
][safi
]);
12241 /* Maximum prefix */
12242 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12243 json_object_int_add(json_addr
, "prefixAllowedMax",
12244 p
->pmax
[afi
][safi
]);
12245 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12246 PEER_FLAG_MAX_PREFIX_WARNING
))
12247 json_object_boolean_true_add(
12248 json_addr
, "prefixAllowedMaxWarning");
12249 json_object_int_add(json_addr
,
12250 "prefixAllowedWarningThresh",
12251 p
->pmax_threshold
[afi
][safi
]);
12252 if (p
->pmax_restart
[afi
][safi
])
12253 json_object_int_add(
12255 "prefixAllowedRestartIntervalMsecs",
12256 p
->pmax_restart
[afi
][safi
] * 60000);
12258 json_object_object_add(json_neigh
,
12259 get_afi_safi_str(afi
, safi
, true),
12263 filter
= &p
->filter
[afi
][safi
];
12265 vty_out(vty
, " For address family: %s\n",
12266 get_afi_safi_str(afi
, safi
, false));
12268 if (peer_group_active(p
))
12269 vty_out(vty
, " %s peer-group member\n",
12272 paf
= peer_af_find(p
, afi
, safi
);
12273 if (paf
&& PAF_SUBGRP(paf
)) {
12274 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12275 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12276 vty_out(vty
, " Packet Queue length %d\n",
12277 bpacket_queue_virtual_length(paf
));
12279 vty_out(vty
, " Not part of any update group\n");
12281 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12282 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12283 PEER_CAP_ORF_PREFIX_SM_RCV
)
12284 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12285 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12286 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12287 PEER_CAP_ORF_PREFIX_RM_ADV
)
12288 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12289 PEER_CAP_ORF_PREFIX_RM_RCV
)
12290 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12291 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12292 vty_out(vty
, " AF-dependant capabilities:\n");
12294 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12295 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12296 PEER_CAP_ORF_PREFIX_SM_RCV
)
12297 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12298 PEER_CAP_ORF_PREFIX_RM_ADV
)
12299 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12300 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12302 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12304 bgp_show_peer_afi_orf_cap(
12305 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12306 PEER_CAP_ORF_PREFIX_RM_ADV
,
12307 PEER_CAP_ORF_PREFIX_SM_RCV
,
12308 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12310 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12311 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12312 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12313 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12314 PEER_CAP_ORF_PREFIX_RM_ADV
)
12315 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12316 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12318 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12319 ORF_TYPE_PREFIX_OLD
);
12320 bgp_show_peer_afi_orf_cap(
12321 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12322 PEER_CAP_ORF_PREFIX_RM_ADV
,
12323 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12324 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12327 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12328 p
->host
, afi
, safi
);
12329 orf_pfx_count
= prefix_bgp_show_prefix_list(
12330 NULL
, afi
, orf_pfx_name
, use_json
);
12332 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12333 PEER_STATUS_ORF_PREFIX_SEND
)
12334 || orf_pfx_count
) {
12335 vty_out(vty
, " Outbound Route Filter (ORF):");
12336 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12337 PEER_STATUS_ORF_PREFIX_SEND
))
12338 vty_out(vty
, " sent;");
12340 vty_out(vty
, " received (%d entries)",
12342 vty_out(vty
, "\n");
12344 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12345 PEER_STATUS_ORF_WAIT_REFRESH
))
12347 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12349 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12350 PEER_FLAG_REFLECTOR_CLIENT
))
12351 vty_out(vty
, " Route-Reflector Client\n");
12352 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12353 PEER_FLAG_RSERVER_CLIENT
))
12354 vty_out(vty
, " Route-Server Client\n");
12355 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12357 " Inbound soft reconfiguration allowed\n");
12359 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12360 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12362 " Private AS numbers (all) replaced in updates to this neighbor\n");
12363 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12364 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12366 " Private AS numbers replaced in updates to this neighbor\n");
12367 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12368 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12370 " Private AS numbers (all) removed in updates to this neighbor\n");
12371 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12372 PEER_FLAG_REMOVE_PRIVATE_AS
))
12374 " Private AS numbers removed in updates to this neighbor\n");
12376 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12377 vty_out(vty
, " %s\n",
12378 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12379 ->human_description
);
12381 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12383 " Override ASNs in outbound updates if aspath equals remote-as\n");
12385 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12386 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12387 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12388 vty_out(vty
, " NEXT_HOP is always this router\n");
12389 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12390 PEER_FLAG_AS_PATH_UNCHANGED
))
12392 " AS_PATH is propagated unchanged to this neighbor\n");
12393 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12394 PEER_FLAG_NEXTHOP_UNCHANGED
))
12396 " NEXT_HOP is propagated unchanged to this neighbor\n");
12397 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12399 " MED is propagated unchanged to this neighbor\n");
12400 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12401 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12402 PEER_FLAG_SEND_EXT_COMMUNITY
)
12403 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12404 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12406 " Community attribute sent to this neighbor");
12407 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12408 PEER_FLAG_SEND_COMMUNITY
)
12409 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12410 PEER_FLAG_SEND_EXT_COMMUNITY
)
12411 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12412 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12413 vty_out(vty
, "(all)\n");
12414 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12415 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12416 vty_out(vty
, "(large)\n");
12417 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12418 PEER_FLAG_SEND_EXT_COMMUNITY
))
12419 vty_out(vty
, "(extended)\n");
12421 vty_out(vty
, "(standard)\n");
12423 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12424 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12425 vty_out(vty
, " Default information originate,");
12427 if (p
->default_rmap
[afi
][safi
].name
)
12428 vty_out(vty
, " default route-map %s%s,",
12429 p
->default_rmap
[afi
][safi
].map
? "*"
12431 p
->default_rmap
[afi
][safi
].name
);
12432 if (paf
&& PAF_SUBGRP(paf
)
12433 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12434 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12435 vty_out(vty
, " default sent\n");
12437 vty_out(vty
, " default not sent\n");
12440 /* advertise-vni-all */
12441 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12442 if (is_evpn_enabled())
12443 vty_out(vty
, " advertise-all-vni\n");
12446 if (filter
->plist
[FILTER_IN
].name
12447 || filter
->dlist
[FILTER_IN
].name
12448 || filter
->aslist
[FILTER_IN
].name
12449 || filter
->map
[RMAP_IN
].name
)
12450 vty_out(vty
, " Inbound path policy configured\n");
12451 if (filter
->plist
[FILTER_OUT
].name
12452 || filter
->dlist
[FILTER_OUT
].name
12453 || filter
->aslist
[FILTER_OUT
].name
12454 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12455 vty_out(vty
, " Outbound path policy configured\n");
12458 if (filter
->plist
[FILTER_IN
].name
)
12460 " Incoming update prefix filter list is %s%s\n",
12461 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12462 filter
->plist
[FILTER_IN
].name
);
12463 if (filter
->plist
[FILTER_OUT
].name
)
12465 " Outgoing update prefix filter list is %s%s\n",
12466 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12467 filter
->plist
[FILTER_OUT
].name
);
12469 /* distribute-list */
12470 if (filter
->dlist
[FILTER_IN
].name
)
12472 " Incoming update network filter list is %s%s\n",
12473 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12474 filter
->dlist
[FILTER_IN
].name
);
12475 if (filter
->dlist
[FILTER_OUT
].name
)
12477 " Outgoing update network filter list is %s%s\n",
12478 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12479 filter
->dlist
[FILTER_OUT
].name
);
12482 if (filter
->aslist
[FILTER_IN
].name
)
12484 " Incoming update AS path filter list is %s%s\n",
12485 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12486 filter
->aslist
[FILTER_IN
].name
);
12487 if (filter
->aslist
[FILTER_OUT
].name
)
12489 " Outgoing update AS path filter list is %s%s\n",
12490 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12491 filter
->aslist
[FILTER_OUT
].name
);
12494 if (filter
->map
[RMAP_IN
].name
)
12496 " Route map for incoming advertisements is %s%s\n",
12497 filter
->map
[RMAP_IN
].map
? "*" : "",
12498 filter
->map
[RMAP_IN
].name
);
12499 if (filter
->map
[RMAP_OUT
].name
)
12501 " Route map for outgoing advertisements is %s%s\n",
12502 filter
->map
[RMAP_OUT
].map
? "*" : "",
12503 filter
->map
[RMAP_OUT
].name
);
12505 /* ebgp-requires-policy (inbound) */
12506 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12507 && !bgp_inbound_policy_exists(p
, filter
))
12509 " Inbound updates discarded due to missing policy\n");
12511 /* ebgp-requires-policy (outbound) */
12512 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12513 && !bgp_outbound_policy_exists(p
, filter
))
12515 " Outbound updates discarded due to missing policy\n");
12517 /* unsuppress-map */
12518 if (filter
->usmap
.name
)
12520 " Route map for selective unsuppress is %s%s\n",
12521 filter
->usmap
.map
? "*" : "",
12522 filter
->usmap
.name
);
12524 /* advertise-map */
12525 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12527 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12528 filter
->advmap
.condition
? "EXIST"
12530 filter
->advmap
.cmap
? "*" : "",
12531 filter
->advmap
.cname
,
12532 filter
->advmap
.amap
? "*" : "",
12533 filter
->advmap
.aname
,
12534 filter
->advmap
.update_type
== ADVERTISE
12538 /* Receive prefix count */
12539 vty_out(vty
, " %u accepted prefixes\n",
12540 p
->pcount
[afi
][safi
]);
12542 /* maximum-prefix-out */
12543 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12544 PEER_FLAG_MAX_PREFIX_OUT
))
12546 " Maximum allowed prefixes sent %u\n",
12547 p
->pmax_out
[afi
][safi
]);
12549 /* Maximum prefix */
12550 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12552 " Maximum prefixes allowed %u%s\n",
12553 p
->pmax
[afi
][safi
],
12554 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12555 PEER_FLAG_MAX_PREFIX_WARNING
)
12556 ? " (warning-only)"
12558 vty_out(vty
, " Threshold for warning message %d%%",
12559 p
->pmax_threshold
[afi
][safi
]);
12560 if (p
->pmax_restart
[afi
][safi
])
12561 vty_out(vty
, ", restart interval %d min",
12562 p
->pmax_restart
[afi
][safi
]);
12563 vty_out(vty
, "\n");
12566 vty_out(vty
, "\n");
12570 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12574 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
12575 char timebuf
[BGP_UPTIME_LEN
];
12581 json_object
*json_neigh
= NULL
;
12587 json_neigh
= json_object_new_object();
12589 memset(dn_flag
, '\0', sizeof(dn_flag
));
12590 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12594 if (p
->conf_if
) /* Configured interface name. */
12595 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
12596 BGP_PEER_SU_UNSPEC(p
)
12598 : sockunion2str(&p
->su
, buf
,
12600 else /* Configured IP address. */
12601 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12606 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12607 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12609 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12610 json_object_string_add(
12611 json_neigh
, "bgpNeighborAddr",
12612 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
12614 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12616 if (p
->change_local_as
)
12617 json_object_int_add(json_neigh
, "localAs",
12618 p
->change_local_as
);
12620 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12622 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12623 json_object_boolean_true_add(json_neigh
,
12624 "localAsNoPrepend");
12626 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12627 json_object_boolean_true_add(json_neigh
,
12628 "localAsReplaceAs");
12630 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12631 || (p
->as_type
== AS_INTERNAL
))
12632 vty_out(vty
, "remote AS %u, ", p
->as
);
12634 vty_out(vty
, "remote AS Unspecified, ");
12635 vty_out(vty
, "local AS %u%s%s, ",
12636 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12637 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12640 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12644 /* peer type internal or confed-internal */
12645 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12647 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12648 json_object_boolean_true_add(
12649 json_neigh
, "nbrConfedInternalLink");
12651 json_object_boolean_true_add(json_neigh
,
12652 "nbrInternalLink");
12654 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12655 vty_out(vty
, "confed-internal link\n");
12657 vty_out(vty
, "internal link\n");
12659 /* peer type external or confed-external */
12660 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12662 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12663 json_object_boolean_true_add(
12664 json_neigh
, "nbrConfedExternalLink");
12666 json_object_boolean_true_add(json_neigh
,
12667 "nbrExternalLink");
12669 if (bgp_confederation_peers_check(bgp
, p
->as
))
12670 vty_out(vty
, "confed-external link\n");
12672 vty_out(vty
, "external link\n");
12676 json_object_boolean_true_add(json_neigh
,
12677 "nbrUnspecifiedLink");
12679 vty_out(vty
, "unspecified link\n");
12685 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12687 vty_out(vty
, " Description: %s\n", p
->desc
);
12693 json_object_string_add(json_neigh
, "hostname",
12697 json_object_string_add(json_neigh
, "domainname",
12700 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12701 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12704 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12711 json_object_string_add(json_neigh
, "peerGroup",
12715 struct prefix prefix
, *range
= NULL
;
12717 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12718 range
= peer_group_lookup_dynamic_neighbor_range(
12719 p
->group
, &prefix
);
12722 prefix2str(range
, buf1
, sizeof(buf1
));
12723 json_object_string_add(
12725 "peerSubnetRangeGroup", buf1
);
12730 " Member of peer-group %s for session parameters\n",
12734 struct prefix prefix
, *range
= NULL
;
12736 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12737 range
= peer_group_lookup_dynamic_neighbor_range(
12738 p
->group
, &prefix
);
12742 " Belongs to the subnet range group: %pFX\n",
12750 /* Administrative shutdown. */
12751 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12752 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12753 json_object_boolean_true_add(json_neigh
,
12757 json_object_int_add(json_neigh
, "bgpVersion", 4);
12758 json_object_string_add(
12759 json_neigh
, "remoteRouterId",
12760 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12761 json_object_string_add(
12762 json_neigh
, "localRouterId",
12763 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12766 /* Confederation */
12767 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12768 && bgp_confederation_peers_check(bgp
, p
->as
))
12769 json_object_boolean_true_add(json_neigh
,
12773 json_object_string_add(
12774 json_neigh
, "bgpState",
12775 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12777 if (p
->status
== Established
) {
12780 uptime
= bgp_clock();
12781 uptime
-= p
->uptime
;
12782 epoch_tbuf
= time(NULL
) - uptime
;
12784 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
12786 json_object_string_add(json_neigh
, "bgpTimerUpString",
12787 peer_uptime(p
->uptime
, timebuf
,
12790 json_object_int_add(json_neigh
,
12791 "bgpTimerUpEstablishedEpoch",
12795 else if (p
->status
== Active
) {
12796 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12797 json_object_string_add(json_neigh
, "bgpStateIs",
12799 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12800 json_object_string_add(json_neigh
, "bgpStateIs",
12808 uptime
= bgp_clock();
12809 uptime
-= p
->readtime
;
12810 gmtime_r(&uptime
, &tm
);
12812 json_object_int_add(json_neigh
, "bgpTimerLastRead",
12813 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12814 + (tm
.tm_hour
* 3600000));
12816 uptime
= bgp_clock();
12817 uptime
-= p
->last_write
;
12818 gmtime_r(&uptime
, &tm
);
12820 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
12821 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12822 + (tm
.tm_hour
* 3600000));
12824 uptime
= bgp_clock();
12825 uptime
-= p
->update_time
;
12826 gmtime_r(&uptime
, &tm
);
12828 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
12829 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12830 + (tm
.tm_hour
* 3600000));
12832 /* Configured timer values. */
12833 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
12834 p
->v_holdtime
* 1000);
12835 json_object_int_add(json_neigh
,
12836 "bgpTimerKeepAliveIntervalMsecs",
12837 p
->v_keepalive
* 1000);
12838 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
12839 json_object_int_add(json_neigh
,
12840 "bgpTimerDelayOpenTimeMsecs",
12841 p
->v_delayopen
* 1000);
12844 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12845 json_object_int_add(json_neigh
,
12846 "bgpTimerConfiguredHoldTimeMsecs",
12847 p
->holdtime
* 1000);
12848 json_object_int_add(
12850 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12851 p
->keepalive
* 1000);
12852 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12853 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12854 json_object_int_add(json_neigh
,
12855 "bgpTimerConfiguredHoldTimeMsecs",
12856 bgp
->default_holdtime
);
12857 json_object_int_add(
12859 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12860 bgp
->default_keepalive
);
12863 /* Administrative shutdown. */
12864 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12865 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12866 vty_out(vty
, " Administratively shut down\n");
12869 vty_out(vty
, " BGP version 4");
12870 vty_out(vty
, ", remote router ID %s",
12871 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12872 vty_out(vty
, ", local router ID %s\n",
12873 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12876 /* Confederation */
12877 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12878 && bgp_confederation_peers_check(bgp
, p
->as
))
12880 " Neighbor under common administration\n");
12883 vty_out(vty
, " BGP state = %s",
12884 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12886 if (p
->status
== Established
)
12887 vty_out(vty
, ", up for %8s",
12888 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
12891 else if (p
->status
== Active
) {
12892 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12893 vty_out(vty
, " (passive)");
12894 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12895 vty_out(vty
, " (NSF passive)");
12897 vty_out(vty
, "\n");
12900 vty_out(vty
, " Last read %s",
12901 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
12903 vty_out(vty
, ", Last write %s\n",
12904 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
12907 /* Configured timer values. */
12909 " Hold time is %d, keepalive interval is %d seconds\n",
12910 p
->v_holdtime
, p
->v_keepalive
);
12911 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12912 vty_out(vty
, " Configured hold time is %d",
12914 vty_out(vty
, ", keepalive interval is %d seconds\n",
12916 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12917 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12918 vty_out(vty
, " Configured hold time is %d",
12919 bgp
->default_holdtime
);
12920 vty_out(vty
, ", keepalive interval is %d seconds\n",
12921 bgp
->default_keepalive
);
12923 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
12925 " Configured DelayOpenTime is %d seconds\n",
12929 if (p
->status
== Established
) {
12930 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
12931 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
12932 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
12933 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
12934 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
12935 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
12936 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
12937 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
12938 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
12939 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
12940 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
12941 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
12942 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
12943 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
12944 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
12945 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
12946 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
12947 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
12948 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
12949 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
12951 json_object
*json_cap
= NULL
;
12953 json_cap
= json_object_new_object();
12956 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
12957 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
12958 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
12959 && CHECK_FLAG(p
->cap
,
12961 json_object_string_add(
12962 json_cap
, "4byteAs",
12963 "advertisedAndReceived");
12964 else if (CHECK_FLAG(p
->cap
,
12966 json_object_string_add(
12967 json_cap
, "4byteAs",
12969 else if (CHECK_FLAG(p
->cap
,
12971 json_object_string_add(
12972 json_cap
, "4byteAs",
12977 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
12978 || CHECK_FLAG(p
->cap
,
12979 PEER_CAP_ADDPATH_ADV
)) {
12980 json_object
*json_add
= NULL
;
12981 const char *print_store
;
12983 json_add
= json_object_new_object();
12985 FOREACH_AFI_SAFI (afi
, safi
) {
12986 json_object
*json_sub
= NULL
;
12988 json_object_new_object();
12989 print_store
= get_afi_safi_str(
12995 PEER_CAP_ADDPATH_AF_TX_ADV
)
12999 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13004 PEER_CAP_ADDPATH_AF_TX_ADV
)
13009 PEER_CAP_ADDPATH_AF_TX_RCV
))
13010 json_object_boolean_true_add(
13012 "txAdvertisedAndReceived");
13018 PEER_CAP_ADDPATH_AF_TX_ADV
))
13019 json_object_boolean_true_add(
13027 PEER_CAP_ADDPATH_AF_TX_RCV
))
13028 json_object_boolean_true_add(
13036 PEER_CAP_ADDPATH_AF_RX_ADV
)
13040 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13045 PEER_CAP_ADDPATH_AF_RX_ADV
)
13050 PEER_CAP_ADDPATH_AF_RX_RCV
))
13051 json_object_boolean_true_add(
13053 "rxAdvertisedAndReceived");
13059 PEER_CAP_ADDPATH_AF_RX_ADV
))
13060 json_object_boolean_true_add(
13068 PEER_CAP_ADDPATH_AF_RX_RCV
))
13069 json_object_boolean_true_add(
13077 PEER_CAP_ADDPATH_AF_TX_ADV
)
13081 PEER_CAP_ADDPATH_AF_TX_RCV
)
13085 PEER_CAP_ADDPATH_AF_RX_ADV
)
13089 PEER_CAP_ADDPATH_AF_RX_RCV
))
13090 json_object_object_add(
13099 json_object_object_add(
13100 json_cap
, "addPath", json_add
);
13104 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
13105 || CHECK_FLAG(p
->cap
,
13106 PEER_CAP_DYNAMIC_ADV
)) {
13107 if (CHECK_FLAG(p
->cap
,
13108 PEER_CAP_DYNAMIC_ADV
)
13109 && CHECK_FLAG(p
->cap
,
13110 PEER_CAP_DYNAMIC_RCV
))
13111 json_object_string_add(
13112 json_cap
, "dynamic",
13113 "advertisedAndReceived");
13114 else if (CHECK_FLAG(
13116 PEER_CAP_DYNAMIC_ADV
))
13117 json_object_string_add(
13118 json_cap
, "dynamic",
13120 else if (CHECK_FLAG(
13122 PEER_CAP_DYNAMIC_RCV
))
13123 json_object_string_add(
13124 json_cap
, "dynamic",
13128 /* Extended nexthop */
13129 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
13130 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13131 json_object
*json_nxt
= NULL
;
13132 const char *print_store
;
13135 if (CHECK_FLAG(p
->cap
,
13137 && CHECK_FLAG(p
->cap
,
13138 PEER_CAP_ENHE_RCV
))
13139 json_object_string_add(
13142 "advertisedAndReceived");
13143 else if (CHECK_FLAG(p
->cap
,
13144 PEER_CAP_ENHE_ADV
))
13145 json_object_string_add(
13149 else if (CHECK_FLAG(p
->cap
,
13150 PEER_CAP_ENHE_RCV
))
13151 json_object_string_add(
13156 if (CHECK_FLAG(p
->cap
,
13157 PEER_CAP_ENHE_RCV
)) {
13159 json_object_new_object();
13161 for (safi
= SAFI_UNICAST
;
13162 safi
< SAFI_MAX
; safi
++) {
13167 PEER_CAP_ENHE_AF_RCV
)) {
13168 print_store
= get_afi_safi_str(
13171 json_object_string_add(
13174 "recieved"); /* misspelled for compatibility */
13177 json_object_object_add(
13179 "extendedNexthopFamililesByPeer",
13184 /* Route Refresh */
13185 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
13186 || CHECK_FLAG(p
->cap
,
13187 PEER_CAP_REFRESH_NEW_RCV
)
13188 || CHECK_FLAG(p
->cap
,
13189 PEER_CAP_REFRESH_OLD_RCV
)) {
13190 if (CHECK_FLAG(p
->cap
,
13191 PEER_CAP_REFRESH_ADV
)
13194 PEER_CAP_REFRESH_NEW_RCV
)
13197 PEER_CAP_REFRESH_OLD_RCV
))) {
13200 PEER_CAP_REFRESH_OLD_RCV
)
13203 PEER_CAP_REFRESH_NEW_RCV
))
13204 json_object_string_add(
13207 "advertisedAndReceivedOldNew");
13211 PEER_CAP_REFRESH_OLD_RCV
))
13212 json_object_string_add(
13215 "advertisedAndReceivedOld");
13217 json_object_string_add(
13220 "advertisedAndReceivedNew");
13225 PEER_CAP_REFRESH_ADV
))
13226 json_object_string_add(
13233 PEER_CAP_REFRESH_NEW_RCV
)
13236 PEER_CAP_REFRESH_OLD_RCV
))
13237 json_object_string_add(
13243 /* Enhanced Route Refresh */
13244 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
)
13245 || CHECK_FLAG(p
->cap
,
13246 PEER_CAP_ENHANCED_RR_RCV
)) {
13247 if (CHECK_FLAG(p
->cap
,
13248 PEER_CAP_ENHANCED_RR_ADV
)
13251 PEER_CAP_ENHANCED_RR_RCV
))
13252 json_object_string_add(
13254 "enhancedRouteRefresh",
13255 "advertisedAndReceived");
13259 PEER_CAP_ENHANCED_RR_ADV
))
13260 json_object_string_add(
13262 "enhancedRouteRefresh",
13267 PEER_CAP_ENHANCED_RR_RCV
))
13268 json_object_string_add(
13270 "enhancedRouteRefresh",
13274 /* Multiprotocol Extensions */
13275 json_object
*json_multi
= NULL
;
13276 json_multi
= json_object_new_object();
13278 FOREACH_AFI_SAFI (afi
, safi
) {
13279 if (p
->afc_adv
[afi
][safi
]
13280 || p
->afc_recv
[afi
][safi
]) {
13281 json_object
*json_exten
= NULL
;
13283 json_object_new_object();
13285 if (p
->afc_adv
[afi
][safi
]
13286 && p
->afc_recv
[afi
][safi
])
13287 json_object_boolean_true_add(
13289 "advertisedAndReceived");
13290 else if (p
->afc_adv
[afi
][safi
])
13291 json_object_boolean_true_add(
13294 else if (p
->afc_recv
[afi
][safi
])
13295 json_object_boolean_true_add(
13299 json_object_object_add(
13301 get_afi_safi_str(afi
,
13307 json_object_object_add(
13308 json_cap
, "multiprotocolExtensions",
13311 /* Hostname capabilities */
13312 json_object
*json_hname
= NULL
;
13314 json_hname
= json_object_new_object();
13316 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13317 json_object_string_add(
13318 json_hname
, "advHostName",
13319 bgp
->peer_self
->hostname
13323 json_object_string_add(
13324 json_hname
, "advDomainName",
13325 bgp
->peer_self
->domainname
13332 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13333 json_object_string_add(
13334 json_hname
, "rcvHostName",
13335 p
->hostname
? p
->hostname
13337 json_object_string_add(
13338 json_hname
, "rcvDomainName",
13339 p
->domainname
? p
->domainname
13343 json_object_object_add(json_cap
, "hostName",
13346 /* Gracefull Restart */
13347 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
13348 || CHECK_FLAG(p
->cap
,
13349 PEER_CAP_RESTART_ADV
)) {
13350 if (CHECK_FLAG(p
->cap
,
13351 PEER_CAP_RESTART_ADV
)
13352 && CHECK_FLAG(p
->cap
,
13353 PEER_CAP_RESTART_RCV
))
13354 json_object_string_add(
13357 "advertisedAndReceived");
13358 else if (CHECK_FLAG(
13360 PEER_CAP_RESTART_ADV
))
13361 json_object_string_add(
13363 "gracefulRestartCapability",
13365 else if (CHECK_FLAG(
13367 PEER_CAP_RESTART_RCV
))
13368 json_object_string_add(
13370 "gracefulRestartCapability",
13373 if (CHECK_FLAG(p
->cap
,
13374 PEER_CAP_RESTART_RCV
)) {
13375 int restart_af_count
= 0;
13376 json_object
*json_restart
=
13379 json_object_new_object();
13381 json_object_int_add(
13383 "gracefulRestartRemoteTimerMsecs",
13384 p
->v_gr_restart
* 1000);
13386 FOREACH_AFI_SAFI (afi
, safi
) {
13391 PEER_CAP_RESTART_AF_RCV
)) {
13396 json_object_new_object();
13402 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13403 json_object_boolean_true_add(
13406 restart_af_count
++;
13407 json_object_object_add(
13416 if (!restart_af_count
) {
13417 json_object_string_add(
13419 "addressFamiliesByPeer",
13424 json_object_object_add(
13426 "addressFamiliesByPeer",
13430 json_object_object_add(json_neigh
,
13431 "neighborCapabilities",
13434 vty_out(vty
, " Neighbor capabilities:\n");
13437 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
13438 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13439 vty_out(vty
, " 4 Byte AS:");
13440 if (CHECK_FLAG(p
->cap
,
13442 vty_out(vty
, " advertised");
13443 if (CHECK_FLAG(p
->cap
,
13445 vty_out(vty
, " %sreceived",
13451 vty_out(vty
, "\n");
13455 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
13456 || CHECK_FLAG(p
->cap
,
13457 PEER_CAP_ADDPATH_ADV
)) {
13458 vty_out(vty
, " AddPath:\n");
13460 FOREACH_AFI_SAFI (afi
, safi
) {
13464 PEER_CAP_ADDPATH_AF_TX_ADV
)
13468 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13480 PEER_CAP_ADDPATH_AF_TX_ADV
))
13492 PEER_CAP_ADDPATH_AF_TX_RCV
))
13499 PEER_CAP_ADDPATH_AF_TX_ADV
)
13503 vty_out(vty
, "\n");
13509 PEER_CAP_ADDPATH_AF_RX_ADV
)
13513 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13525 PEER_CAP_ADDPATH_AF_RX_ADV
))
13537 PEER_CAP_ADDPATH_AF_RX_RCV
))
13544 PEER_CAP_ADDPATH_AF_RX_ADV
)
13548 vty_out(vty
, "\n");
13554 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
13555 || CHECK_FLAG(p
->cap
,
13556 PEER_CAP_DYNAMIC_ADV
)) {
13557 vty_out(vty
, " Dynamic:");
13558 if (CHECK_FLAG(p
->cap
,
13559 PEER_CAP_DYNAMIC_ADV
))
13560 vty_out(vty
, " advertised");
13561 if (CHECK_FLAG(p
->cap
,
13562 PEER_CAP_DYNAMIC_RCV
))
13563 vty_out(vty
, " %sreceived",
13566 PEER_CAP_DYNAMIC_ADV
)
13569 vty_out(vty
, "\n");
13572 /* Extended nexthop */
13573 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
13574 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13575 vty_out(vty
, " Extended nexthop:");
13576 if (CHECK_FLAG(p
->cap
,
13577 PEER_CAP_ENHE_ADV
))
13578 vty_out(vty
, " advertised");
13579 if (CHECK_FLAG(p
->cap
,
13580 PEER_CAP_ENHE_RCV
))
13581 vty_out(vty
, " %sreceived",
13587 vty_out(vty
, "\n");
13589 if (CHECK_FLAG(p
->cap
,
13590 PEER_CAP_ENHE_RCV
)) {
13592 " Address families by peer:\n ");
13593 for (safi
= SAFI_UNICAST
;
13594 safi
< SAFI_MAX
; safi
++)
13599 PEER_CAP_ENHE_AF_RCV
))
13609 /* Route Refresh */
13610 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
13611 || CHECK_FLAG(p
->cap
,
13612 PEER_CAP_REFRESH_NEW_RCV
)
13613 || CHECK_FLAG(p
->cap
,
13614 PEER_CAP_REFRESH_OLD_RCV
)) {
13615 vty_out(vty
, " Route refresh:");
13616 if (CHECK_FLAG(p
->cap
,
13617 PEER_CAP_REFRESH_ADV
))
13618 vty_out(vty
, " advertised");
13619 if (CHECK_FLAG(p
->cap
,
13620 PEER_CAP_REFRESH_NEW_RCV
)
13623 PEER_CAP_REFRESH_OLD_RCV
))
13624 vty_out(vty
, " %sreceived(%s)",
13627 PEER_CAP_REFRESH_ADV
)
13632 PEER_CAP_REFRESH_OLD_RCV
)
13635 PEER_CAP_REFRESH_NEW_RCV
))
13639 PEER_CAP_REFRESH_OLD_RCV
)
13643 vty_out(vty
, "\n");
13646 /* Enhanced Route Refresh */
13647 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
)
13648 || CHECK_FLAG(p
->cap
,
13649 PEER_CAP_ENHANCED_RR_RCV
)) {
13651 " Enhanced Route Refresh:");
13654 PEER_CAP_ENHANCED_RR_ADV
))
13655 vty_out(vty
, " advertised");
13658 PEER_CAP_ENHANCED_RR_RCV
))
13659 vty_out(vty
, " %sreceived",
13662 PEER_CAP_REFRESH_ADV
)
13665 vty_out(vty
, "\n");
13668 /* Multiprotocol Extensions */
13669 FOREACH_AFI_SAFI (afi
, safi
)
13670 if (p
->afc_adv
[afi
][safi
]
13671 || p
->afc_recv
[afi
][safi
]) {
13673 " Address Family %s:",
13678 if (p
->afc_adv
[afi
][safi
])
13681 if (p
->afc_recv
[afi
][safi
])
13688 vty_out(vty
, "\n");
13691 /* Hostname capability */
13692 vty_out(vty
, " Hostname Capability:");
13694 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13696 " advertised (name: %s,domain name: %s)",
13697 bgp
->peer_self
->hostname
13701 bgp
->peer_self
->domainname
13706 vty_out(vty
, " not advertised");
13709 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13711 " received (name: %s,domain name: %s)",
13712 p
->hostname
? p
->hostname
13714 p
->domainname
? p
->domainname
13717 vty_out(vty
, " not received");
13720 vty_out(vty
, "\n");
13722 /* Graceful Restart */
13723 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
13724 || CHECK_FLAG(p
->cap
,
13725 PEER_CAP_RESTART_ADV
)) {
13727 " Graceful Restart Capability:");
13728 if (CHECK_FLAG(p
->cap
,
13729 PEER_CAP_RESTART_ADV
))
13730 vty_out(vty
, " advertised");
13731 if (CHECK_FLAG(p
->cap
,
13732 PEER_CAP_RESTART_RCV
))
13733 vty_out(vty
, " %sreceived",
13736 PEER_CAP_RESTART_ADV
)
13739 vty_out(vty
, "\n");
13741 if (CHECK_FLAG(p
->cap
,
13742 PEER_CAP_RESTART_RCV
)) {
13743 int restart_af_count
= 0;
13746 " Remote Restart timer is %d seconds\n",
13749 " Address families by peer:\n ");
13751 FOREACH_AFI_SAFI (afi
, safi
)
13756 PEER_CAP_RESTART_AF_RCV
)) {
13770 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13772 : "not preserved");
13773 restart_af_count
++;
13775 if (!restart_af_count
)
13776 vty_out(vty
, "none");
13777 vty_out(vty
, "\n");
13779 } /* Gracefull Restart */
13784 /* graceful restart information */
13785 json_object
*json_grace
= NULL
;
13786 json_object
*json_grace_send
= NULL
;
13787 json_object
*json_grace_recv
= NULL
;
13788 int eor_send_af_count
= 0;
13789 int eor_receive_af_count
= 0;
13792 json_grace
= json_object_new_object();
13793 json_grace_send
= json_object_new_object();
13794 json_grace_recv
= json_object_new_object();
13796 if ((p
->status
== Established
)
13797 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13798 FOREACH_AFI_SAFI (afi
, safi
) {
13799 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13800 PEER_STATUS_EOR_SEND
)) {
13801 json_object_boolean_true_add(
13803 get_afi_safi_str(afi
,
13806 eor_send_af_count
++;
13809 FOREACH_AFI_SAFI (afi
, safi
) {
13811 p
->af_sflags
[afi
][safi
],
13812 PEER_STATUS_EOR_RECEIVED
)) {
13813 json_object_boolean_true_add(
13815 get_afi_safi_str(afi
,
13818 eor_receive_af_count
++;
13822 json_object_object_add(json_grace
, "endOfRibSend",
13824 json_object_object_add(json_grace
, "endOfRibRecv",
13828 if (p
->t_gr_restart
)
13829 json_object_int_add(json_grace
,
13830 "gracefulRestartTimerMsecs",
13831 thread_timer_remain_second(
13836 json_object_int_add(
13838 "gracefulStalepathTimerMsecs",
13839 thread_timer_remain_second(
13842 /* more gr info in new format */
13843 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
,
13845 json_object_object_add(
13846 json_neigh
, "gracefulRestartInfo", json_grace
);
13848 vty_out(vty
, " Graceful restart information:\n");
13849 if ((p
->status
== Established
)
13850 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13852 vty_out(vty
, " End-of-RIB send: ");
13853 FOREACH_AFI_SAFI (afi
, safi
) {
13854 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13855 PEER_STATUS_EOR_SEND
)) {
13856 vty_out(vty
, "%s%s",
13857 eor_send_af_count
? ", "
13862 eor_send_af_count
++;
13865 vty_out(vty
, "\n");
13866 vty_out(vty
, " End-of-RIB received: ");
13867 FOREACH_AFI_SAFI (afi
, safi
) {
13869 p
->af_sflags
[afi
][safi
],
13870 PEER_STATUS_EOR_RECEIVED
)) {
13871 vty_out(vty
, "%s%s",
13872 eor_receive_af_count
13875 get_afi_safi_str(afi
,
13878 eor_receive_af_count
++;
13881 vty_out(vty
, "\n");
13884 if (p
->t_gr_restart
)
13886 " The remaining time of restart timer is %ld\n",
13887 thread_timer_remain_second(
13892 " The remaining time of stalepath timer is %ld\n",
13893 thread_timer_remain_second(
13896 /* more gr info in new format */
13897 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
13901 json_object
*json_stat
= NULL
;
13902 json_stat
= json_object_new_object();
13903 /* Packet counts. */
13905 atomic_size_t outq_count
, inq_count
;
13906 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13907 memory_order_relaxed
);
13908 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13909 memory_order_relaxed
);
13911 json_object_int_add(json_stat
, "depthInq",
13912 (unsigned long)inq_count
);
13913 json_object_int_add(json_stat
, "depthOutq",
13914 (unsigned long)outq_count
);
13915 json_object_int_add(json_stat
, "opensSent",
13916 atomic_load_explicit(&p
->open_out
,
13917 memory_order_relaxed
));
13918 json_object_int_add(json_stat
, "opensRecv",
13919 atomic_load_explicit(&p
->open_in
,
13920 memory_order_relaxed
));
13921 json_object_int_add(json_stat
, "notificationsSent",
13922 atomic_load_explicit(&p
->notify_out
,
13923 memory_order_relaxed
));
13924 json_object_int_add(json_stat
, "notificationsRecv",
13925 atomic_load_explicit(&p
->notify_in
,
13926 memory_order_relaxed
));
13927 json_object_int_add(json_stat
, "updatesSent",
13928 atomic_load_explicit(&p
->update_out
,
13929 memory_order_relaxed
));
13930 json_object_int_add(json_stat
, "updatesRecv",
13931 atomic_load_explicit(&p
->update_in
,
13932 memory_order_relaxed
));
13933 json_object_int_add(json_stat
, "keepalivesSent",
13934 atomic_load_explicit(&p
->keepalive_out
,
13935 memory_order_relaxed
));
13936 json_object_int_add(json_stat
, "keepalivesRecv",
13937 atomic_load_explicit(&p
->keepalive_in
,
13938 memory_order_relaxed
));
13939 json_object_int_add(json_stat
, "routeRefreshSent",
13940 atomic_load_explicit(&p
->refresh_out
,
13941 memory_order_relaxed
));
13942 json_object_int_add(json_stat
, "routeRefreshRecv",
13943 atomic_load_explicit(&p
->refresh_in
,
13944 memory_order_relaxed
));
13945 json_object_int_add(json_stat
, "capabilitySent",
13946 atomic_load_explicit(&p
->dynamic_cap_out
,
13947 memory_order_relaxed
));
13948 json_object_int_add(json_stat
, "capabilityRecv",
13949 atomic_load_explicit(&p
->dynamic_cap_in
,
13950 memory_order_relaxed
));
13951 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
13952 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
13953 json_object_object_add(json_neigh
, "messageStats", json_stat
);
13955 atomic_size_t outq_count
, inq_count
;
13956 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13957 memory_order_relaxed
);
13958 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13959 memory_order_relaxed
);
13961 /* Packet counts. */
13962 vty_out(vty
, " Message statistics:\n");
13963 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
13964 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
13965 vty_out(vty
, " Sent Rcvd\n");
13966 vty_out(vty
, " Opens: %10d %10d\n",
13967 atomic_load_explicit(&p
->open_out
,
13968 memory_order_relaxed
),
13969 atomic_load_explicit(&p
->open_in
,
13970 memory_order_relaxed
));
13971 vty_out(vty
, " Notifications: %10d %10d\n",
13972 atomic_load_explicit(&p
->notify_out
,
13973 memory_order_relaxed
),
13974 atomic_load_explicit(&p
->notify_in
,
13975 memory_order_relaxed
));
13976 vty_out(vty
, " Updates: %10d %10d\n",
13977 atomic_load_explicit(&p
->update_out
,
13978 memory_order_relaxed
),
13979 atomic_load_explicit(&p
->update_in
,
13980 memory_order_relaxed
));
13981 vty_out(vty
, " Keepalives: %10d %10d\n",
13982 atomic_load_explicit(&p
->keepalive_out
,
13983 memory_order_relaxed
),
13984 atomic_load_explicit(&p
->keepalive_in
,
13985 memory_order_relaxed
));
13986 vty_out(vty
, " Route Refresh: %10d %10d\n",
13987 atomic_load_explicit(&p
->refresh_out
,
13988 memory_order_relaxed
),
13989 atomic_load_explicit(&p
->refresh_in
,
13990 memory_order_relaxed
));
13991 vty_out(vty
, " Capability: %10d %10d\n",
13992 atomic_load_explicit(&p
->dynamic_cap_out
,
13993 memory_order_relaxed
),
13994 atomic_load_explicit(&p
->dynamic_cap_in
,
13995 memory_order_relaxed
));
13996 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
14001 /* advertisement-interval */
14002 json_object_int_add(json_neigh
,
14003 "minBtwnAdvertisementRunsTimerMsecs",
14004 p
->v_routeadv
* 1000);
14006 /* Update-source. */
14007 if (p
->update_if
|| p
->update_source
) {
14009 json_object_string_add(json_neigh
,
14012 else if (p
->update_source
)
14013 json_object_string_add(
14014 json_neigh
, "updateSource",
14015 sockunion2str(p
->update_source
, buf1
,
14019 /* advertisement-interval */
14021 " Minimum time between advertisement runs is %d seconds\n",
14024 /* Update-source. */
14025 if (p
->update_if
|| p
->update_source
) {
14026 vty_out(vty
, " Update source is ");
14028 vty_out(vty
, "%s", p
->update_if
);
14029 else if (p
->update_source
)
14031 sockunion2str(p
->update_source
, buf1
,
14033 vty_out(vty
, "\n");
14036 vty_out(vty
, "\n");
14039 /* Address Family Information */
14040 json_object
*json_hold
= NULL
;
14043 json_hold
= json_object_new_object();
14045 FOREACH_AFI_SAFI (afi
, safi
)
14046 if (p
->afc
[afi
][safi
])
14047 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14051 json_object_object_add(json_neigh
, "addressFamilyInfo",
14053 json_object_int_add(json_neigh
, "connectionsEstablished",
14055 json_object_int_add(json_neigh
, "connectionsDropped",
14058 vty_out(vty
, " Connections established %d; dropped %d\n",
14059 p
->established
, p
->dropped
);
14061 if (!p
->last_reset
) {
14063 json_object_string_add(json_neigh
, "lastReset",
14066 vty_out(vty
, " Last reset never\n");
14072 uptime
= bgp_clock();
14073 uptime
-= p
->resettime
;
14074 gmtime_r(&uptime
, &tm
);
14076 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14078 + (tm
.tm_min
* 60000)
14079 + (tm
.tm_hour
* 3600000));
14080 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14082 vty_out(vty
, " Last reset %s, ",
14083 peer_uptime(p
->resettime
, timebuf
,
14084 BGP_UPTIME_LEN
, 0, NULL
));
14086 bgp_show_peer_reset(vty
, p
, NULL
, false);
14087 if (p
->last_reset_cause_size
) {
14088 msg
= p
->last_reset_cause
;
14090 " Message received that caused BGP to send a NOTIFICATION:\n ");
14091 for (i
= 1; i
<= p
->last_reset_cause_size
;
14093 vty_out(vty
, "%02X", *msg
++);
14095 if (i
!= p
->last_reset_cause_size
) {
14097 vty_out(vty
, "\n ");
14098 } else if (i
% 4 == 0) {
14103 vty_out(vty
, "\n");
14108 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14110 json_object_boolean_true_add(json_neigh
,
14111 "prefixesConfigExceedMax");
14114 " Peer had exceeded the max. no. of prefixes configured.\n");
14116 if (p
->t_pmax_restart
) {
14118 json_object_boolean_true_add(
14119 json_neigh
, "reducePrefixNumFrom");
14120 json_object_int_add(json_neigh
,
14121 "restartInTimerMsec",
14122 thread_timer_remain_second(
14127 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14128 p
->host
, thread_timer_remain_second(
14129 p
->t_pmax_restart
));
14132 json_object_boolean_true_add(
14134 "reducePrefixNumAndClearIpBgp");
14137 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14142 /* EBGP Multihop and GTSM */
14143 if (p
->sort
!= BGP_PEER_IBGP
) {
14145 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14146 json_object_int_add(json_neigh
,
14147 "externalBgpNbrMaxHopsAway",
14149 else if (p
->ttl
> BGP_DEFAULT_TTL
)
14150 json_object_int_add(json_neigh
,
14151 "externalBgpNbrMaxHopsAway",
14154 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14156 " External BGP neighbor may be up to %d hops away.\n",
14158 else if (p
->ttl
> BGP_DEFAULT_TTL
)
14160 " External BGP neighbor may be up to %d hops away.\n",
14164 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
) {
14166 json_object_int_add(json_neigh
,
14167 "internalBgpNbrMaxHopsAway",
14171 " Internal BGP neighbor may be up to %d hops away.\n",
14176 /* Local address. */
14179 json_object_string_add(json_neigh
, "hostLocal",
14180 sockunion2str(p
->su_local
, buf1
,
14182 json_object_int_add(json_neigh
, "portLocal",
14183 ntohs(p
->su_local
->sin
.sin_port
));
14185 vty_out(vty
, "Local host: %s, Local port: %d\n",
14186 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
14187 ntohs(p
->su_local
->sin
.sin_port
));
14190 /* Remote address. */
14191 if (p
->su_remote
) {
14193 json_object_string_add(json_neigh
, "hostForeign",
14194 sockunion2str(p
->su_remote
, buf1
,
14196 json_object_int_add(json_neigh
, "portForeign",
14197 ntohs(p
->su_remote
->sin
.sin_port
));
14199 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
14200 sockunion2str(p
->su_remote
, buf1
,
14202 ntohs(p
->su_remote
->sin
.sin_port
));
14205 /* Nexthop display. */
14208 json_object_string_add(json_neigh
, "nexthop",
14210 &p
->nexthop
.v4
, buf1
,
14212 json_object_string_add(json_neigh
, "nexthopGlobal",
14213 inet_ntop(AF_INET6
,
14214 &p
->nexthop
.v6_global
,
14215 buf1
, sizeof(buf1
)));
14216 json_object_string_add(json_neigh
, "nexthopLocal",
14217 inet_ntop(AF_INET6
,
14218 &p
->nexthop
.v6_local
,
14219 buf1
, sizeof(buf1
)));
14220 if (p
->shared_network
)
14221 json_object_string_add(json_neigh
,
14225 json_object_string_add(json_neigh
,
14227 "nonSharedNetwork");
14229 vty_out(vty
, "Nexthop: %s\n",
14230 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
14232 vty_out(vty
, "Nexthop global: %s\n",
14233 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
14235 vty_out(vty
, "Nexthop local: %s\n",
14236 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
14238 vty_out(vty
, "BGP connection: %s\n",
14239 p
->shared_network
? "shared network"
14240 : "non shared network");
14244 /* Timer information. */
14246 json_object_int_add(json_neigh
, "connectRetryTimer",
14248 if (p
->status
== Established
&& p
->rtt
)
14249 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14252 json_object_int_add(
14253 json_neigh
, "nextStartTimerDueInMsecs",
14254 thread_timer_remain_second(p
->t_start
) * 1000);
14256 json_object_int_add(
14257 json_neigh
, "nextConnectTimerDueInMsecs",
14258 thread_timer_remain_second(p
->t_connect
)
14260 if (p
->t_routeadv
) {
14261 json_object_int_add(json_neigh
, "mraiInterval",
14263 json_object_int_add(
14264 json_neigh
, "mraiTimerExpireInMsecs",
14265 thread_timer_remain_second(p
->t_routeadv
)
14269 json_object_int_add(json_neigh
, "authenticationEnabled",
14273 json_object_string_add(json_neigh
, "readThread", "on");
14275 json_object_string_add(json_neigh
, "readThread", "off");
14277 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14278 json_object_string_add(json_neigh
, "writeThread", "on");
14280 json_object_string_add(json_neigh
, "writeThread",
14283 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14285 if (p
->status
== Established
&& p
->rtt
)
14286 vty_out(vty
, "Estimated round trip time: %d ms\n",
14289 vty_out(vty
, "Next start timer due in %ld seconds\n",
14290 thread_timer_remain_second(p
->t_start
));
14292 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14293 thread_timer_remain_second(p
->t_connect
));
14296 "MRAI (interval %u) timer expires in %ld seconds\n",
14298 thread_timer_remain_second(p
->t_routeadv
));
14300 vty_out(vty
, "Peer Authentication Enabled\n");
14302 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14303 p
->t_read
? "on" : "off",
14304 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14309 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14310 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14311 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14314 vty_out(vty
, "\n");
14316 /* BFD information. */
14317 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
14320 if (p
->conf_if
) /* Configured interface name. */
14321 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14322 else /* Configured IP address. */
14323 json_object_object_add(json
, p
->host
, json_neigh
);
14327 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14328 enum show_type type
,
14329 union sockunion
*su
,
14330 const char *conf_if
, afi_t afi
,
14333 struct listnode
*node
, *nnode
;
14336 safi_t safi
= SAFI_UNICAST
;
14337 json_object
*json
= NULL
;
14338 json_object
*json_neighbor
= NULL
;
14341 json
= json_object_new_object();
14342 json_neighbor
= json_object_new_object();
14345 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14347 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14350 if ((peer
->afc
[afi
][safi
]) == 0)
14353 if (type
== show_all
) {
14354 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14358 json_object_object_add(json
, peer
->host
,
14360 json_neighbor
= NULL
;
14363 } else if (type
== show_peer
) {
14366 && !strcmp(peer
->conf_if
, conf_if
))
14368 && !strcmp(peer
->hostname
, conf_if
))) {
14370 bgp_show_peer_gr_status(vty
, peer
,
14375 if (sockunion_same(&peer
->su
, su
)) {
14377 bgp_show_peer_gr_status(vty
, peer
,
14382 if (use_json
&& find
)
14383 json_object_object_add(json
, peer
->host
,
14388 json_neighbor
= NULL
;
14393 if (type
== show_peer
&& !find
) {
14395 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14397 vty_out(vty
, "%% No such neighbor\n");
14400 vty_out(vty
, "%s\n",
14401 json_object_to_json_string_ext(
14402 json
, JSON_C_TO_STRING_PRETTY
));
14405 json_object_free(json_neighbor
);
14406 json_object_free(json
);
14408 vty_out(vty
, "\n");
14411 return CMD_SUCCESS
;
14414 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14415 enum show_type type
, union sockunion
*su
,
14416 const char *conf_if
, bool use_json
,
14419 struct listnode
*node
, *nnode
;
14422 bool nbr_output
= false;
14423 afi_t afi
= AFI_MAX
;
14424 safi_t safi
= SAFI_MAX
;
14426 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14428 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14432 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14433 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14438 bgp_show_peer(vty
, peer
, use_json
, json
);
14444 && !strcmp(peer
->conf_if
, conf_if
))
14446 && !strcmp(peer
->hostname
, conf_if
))) {
14448 bgp_show_peer(vty
, peer
, use_json
,
14452 if (sockunion_same(&peer
->su
, su
)) {
14454 bgp_show_peer(vty
, peer
, use_json
,
14459 case show_ipv4_peer
:
14460 case show_ipv6_peer
:
14461 FOREACH_SAFI (safi
) {
14462 if (peer
->afc
[afi
][safi
]) {
14465 && !strcmp(peer
->conf_if
, conf_if
))
14467 && !strcmp(peer
->hostname
, conf_if
))) {
14469 bgp_show_peer(vty
, peer
, use_json
,
14474 if (sockunion_same(&peer
->su
, su
)) {
14476 bgp_show_peer(vty
, peer
, use_json
,
14484 case show_ipv4_all
:
14485 case show_ipv6_all
:
14486 FOREACH_SAFI (safi
) {
14487 if (peer
->afc
[afi
][safi
]) {
14488 bgp_show_peer(vty
, peer
, use_json
, json
);
14497 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14498 type
== show_ipv6_peer
) && !find
) {
14500 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14502 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14505 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14506 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14507 vty_out(vty
, "%% No BGP neighbors found\n");
14510 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14511 json
, JSON_C_TO_STRING_PRETTY
));
14513 vty_out(vty
, "\n");
14516 return CMD_SUCCESS
;
14519 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14520 enum show_type type
,
14521 const char *ip_str
,
14522 afi_t afi
, bool use_json
)
14527 union sockunion su
;
14529 bgp
= bgp_get_default();
14535 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14539 ret
= str2sockunion(ip_str
, &su
);
14541 bgp_show_neighbor_graceful_restart(
14542 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14544 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14545 NULL
, afi
, use_json
);
14547 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14551 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14552 enum show_type type
,
14553 const char *ip_str
,
14556 struct listnode
*node
, *nnode
;
14558 union sockunion su
;
14559 json_object
*json
= NULL
;
14560 int ret
, is_first
= 1;
14561 bool nbr_output
= false;
14564 vty_out(vty
, "{\n");
14566 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14569 if (!(json
= json_object_new_object())) {
14571 EC_BGP_JSON_MEM_ERROR
,
14572 "Unable to allocate memory for JSON object");
14574 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14578 json_object_int_add(json
, "vrfId",
14579 (bgp
->vrf_id
== VRF_UNKNOWN
)
14581 : (int64_t)bgp
->vrf_id
);
14582 json_object_string_add(
14584 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14589 vty_out(vty
, ",\n");
14593 vty_out(vty
, "\"%s\":",
14594 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14598 vty_out(vty
, "\nInstance %s:\n",
14599 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14604 if (type
== show_peer
|| type
== show_ipv4_peer
||
14605 type
== show_ipv6_peer
) {
14606 ret
= str2sockunion(ip_str
, &su
);
14608 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14611 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14614 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14617 json_object_free(json
);
14622 vty_out(vty
, "}\n");
14623 else if (!nbr_output
)
14624 vty_out(vty
, "%% BGP instance not found\n");
14627 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14628 enum show_type type
, const char *ip_str
,
14633 union sockunion su
;
14634 json_object
*json
= NULL
;
14637 if (strmatch(name
, "all")) {
14638 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14640 return CMD_SUCCESS
;
14642 bgp
= bgp_lookup_by_name(name
);
14645 json
= json_object_new_object();
14646 vty_out(vty
, "%s\n",
14647 json_object_to_json_string_ext(
14649 JSON_C_TO_STRING_PRETTY
));
14650 json_object_free(json
);
14653 "%% BGP instance not found\n");
14655 return CMD_WARNING
;
14659 bgp
= bgp_get_default();
14663 json
= json_object_new_object();
14665 ret
= str2sockunion(ip_str
, &su
);
14667 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14670 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14673 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14676 json_object_free(json
);
14679 vty_out(vty
, "{}\n");
14681 vty_out(vty
, "%% BGP instance not found\n");
14684 return CMD_SUCCESS
;
14689 /* "show [ip] bgp neighbors graceful-restart" commands. */
14690 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
14691 show_ip_bgp_neighbors_graceful_restart_cmd
,
14692 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14698 "Neighbor to display information about\n"
14699 "Neighbor to display information about\n"
14700 "Neighbor on BGP configured interface\n"
14704 char *sh_arg
= NULL
;
14705 enum show_type sh_type
;
14707 afi_t afi
= AFI_MAX
;
14708 bool uj
= use_json(argc
, argv
);
14710 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14715 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14716 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14717 || argv_find(argv
, argc
, "WORD", &idx
)) {
14718 sh_type
= show_peer
;
14719 sh_arg
= argv
[idx
]->arg
;
14721 sh_type
= show_all
;
14723 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14724 return CMD_SUCCESS
;
14727 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14731 /* "show [ip] bgp neighbors" commands. */
14732 DEFUN (show_ip_bgp_neighbors
,
14733 show_ip_bgp_neighbors_cmd
,
14734 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14738 BGP_INSTANCE_HELP_STR
14741 "Detailed information on TCP and BGP neighbor connections\n"
14742 "Neighbor to display information about\n"
14743 "Neighbor to display information about\n"
14744 "Neighbor on BGP configured interface\n"
14748 char *sh_arg
= NULL
;
14749 enum show_type sh_type
;
14750 afi_t afi
= AFI_MAX
;
14752 bool uj
= use_json(argc
, argv
);
14756 /* [<vrf> VIEWVRFNAME] */
14757 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14758 vrf
= argv
[idx
+ 1]->arg
;
14759 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14761 } else if (argv_find(argv
, argc
, "view", &idx
))
14762 /* [<view> VIEWVRFNAME] */
14763 vrf
= argv
[idx
+ 1]->arg
;
14767 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14768 sh_type
= show_ipv4_all
;
14770 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14771 sh_type
= show_ipv6_all
;
14774 sh_type
= show_all
;
14777 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14778 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14779 || argv_find(argv
, argc
, "WORD", &idx
)) {
14780 sh_type
= show_peer
;
14781 sh_arg
= argv
[idx
]->arg
;
14784 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14785 sh_type
= show_ipv4_peer
;
14786 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14787 sh_type
= show_ipv6_peer
;
14790 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14793 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14794 paths' and `show ip mbgp paths'. Those functions results are the
14796 DEFUN (show_ip_bgp_paths
,
14797 show_ip_bgp_paths_cmd
,
14798 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14803 "Path information\n")
14805 vty_out(vty
, "Address Refcnt Path\n");
14806 aspath_print_all_vty(vty
);
14807 return CMD_SUCCESS
;
14812 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14815 struct community
*com
;
14817 com
= (struct community
*)bucket
->data
;
14818 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14819 community_str(com
, false));
14822 /* Show BGP's community internal data. */
14823 DEFUN (show_ip_bgp_community_info
,
14824 show_ip_bgp_community_info_cmd
,
14825 "show [ip] bgp community-info",
14829 "List all bgp community information\n")
14831 vty_out(vty
, "Address Refcnt Community\n");
14833 hash_iterate(community_hash(),
14834 (void (*)(struct hash_bucket
*,
14835 void *))community_show_all_iterator
,
14838 return CMD_SUCCESS
;
14841 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14844 struct lcommunity
*lcom
;
14846 lcom
= (struct lcommunity
*)bucket
->data
;
14847 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14848 lcommunity_str(lcom
, false));
14851 /* Show BGP's community internal data. */
14852 DEFUN (show_ip_bgp_lcommunity_info
,
14853 show_ip_bgp_lcommunity_info_cmd
,
14854 "show ip bgp large-community-info",
14858 "List all bgp large-community information\n")
14860 vty_out(vty
, "Address Refcnt Large-community\n");
14862 hash_iterate(lcommunity_hash(),
14863 (void (*)(struct hash_bucket
*,
14864 void *))lcommunity_show_all_iterator
,
14867 return CMD_SUCCESS
;
14869 /* Graceful Restart */
14871 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
14878 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
14880 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
14882 switch (bgp_global_gr_mode
) {
14884 case GLOBAL_HELPER
:
14885 vty_out(vty
, "Global BGP GR Mode : Helper\n");
14889 vty_out(vty
, "Global BGP GR Mode : Restart\n");
14892 case GLOBAL_DISABLE
:
14893 vty_out(vty
, "Global BGP GR Mode : Disable\n");
14896 case GLOBAL_INVALID
:
14898 "Global BGP GR Mode Invalid\n");
14901 vty_out(vty
, "\n");
14904 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
14905 enum show_type type
,
14906 const char *ip_str
,
14907 afi_t afi
, bool use_json
)
14909 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
14912 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
14914 bgp_show_neighbor_graceful_restart_vty(
14915 vty
, type
, ip_str
, afi
, use_json
);
14918 } else if (afi
!= AFI_MAX
) {
14919 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
14922 return CMD_ERR_INCOMPLETE
;
14925 return CMD_SUCCESS
;
14927 /* Graceful Restart */
14929 DEFUN (show_ip_bgp_attr_info
,
14930 show_ip_bgp_attr_info_cmd
,
14931 "show [ip] bgp attribute-info",
14935 "List all bgp attribute information\n")
14937 attr_show_all(vty
);
14938 return CMD_SUCCESS
;
14941 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
14942 afi_t afi
, safi_t safi
,
14943 bool use_json
, json_object
*json
)
14946 struct listnode
*node
;
14948 char buf1
[INET6_ADDRSTRLEN
];
14950 vpn_policy_direction_t dir
;
14953 json_object
*json_import_vrfs
= NULL
;
14954 json_object
*json_export_vrfs
= NULL
;
14956 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14959 vty_out(vty
, "%s\n",
14960 json_object_to_json_string_ext(
14962 JSON_C_TO_STRING_PRETTY
));
14963 json_object_free(json
);
14965 return CMD_WARNING
;
14968 /* Provide context for the block */
14969 json_object_string_add(json
, "vrf", name
? name
: "default");
14970 json_object_string_add(json
, "afiSafi",
14971 get_afi_safi_str(afi
, safi
, true));
14973 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14974 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
14975 json_object_string_add(json
, "importFromVrfs", "none");
14976 json_object_string_add(json
, "importRts", "none");
14978 json_import_vrfs
= json_object_new_array();
14980 for (ALL_LIST_ELEMENTS_RO(
14981 bgp
->vpn_policy
[afi
].import_vrf
,
14983 json_object_array_add(json_import_vrfs
,
14984 json_object_new_string(vname
));
14986 json_object_object_add(json
, "importFromVrfs",
14988 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14989 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14990 ecom_str
= ecommunity_ecom2str(
14991 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14992 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14993 json_object_string_add(json
, "importRts",
14995 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14997 json_object_string_add(json
, "importRts",
15001 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15002 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15003 json_object_string_add(json
, "exportToVrfs", "none");
15004 json_object_string_add(json
, "routeDistinguisher",
15006 json_object_string_add(json
, "exportRts", "none");
15008 json_export_vrfs
= json_object_new_array();
15010 for (ALL_LIST_ELEMENTS_RO(
15011 bgp
->vpn_policy
[afi
].export_vrf
,
15013 json_object_array_add(json_export_vrfs
,
15014 json_object_new_string(vname
));
15015 json_object_object_add(json
, "exportToVrfs",
15017 json_object_string_add(json
, "routeDistinguisher",
15018 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
15019 buf1
, RD_ADDRSTRLEN
));
15021 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15022 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15023 ecom_str
= ecommunity_ecom2str(
15024 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15025 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15026 json_object_string_add(json
, "exportRts",
15028 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15030 json_object_string_add(json
, "exportRts",
15035 vty_out(vty
, "%s\n",
15036 json_object_to_json_string_ext(json
,
15037 JSON_C_TO_STRING_PRETTY
));
15038 json_object_free(json
);
15041 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15044 vty_out(vty
, "%% No such BGP instance exist\n");
15045 return CMD_WARNING
;
15048 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15049 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15051 "This VRF is not importing %s routes from any other VRF\n",
15052 get_afi_safi_str(afi
, safi
, false));
15055 "This VRF is importing %s routes from the following VRFs:\n",
15056 get_afi_safi_str(afi
, safi
, false));
15058 for (ALL_LIST_ELEMENTS_RO(
15059 bgp
->vpn_policy
[afi
].import_vrf
,
15061 vty_out(vty
, " %s\n", vname
);
15063 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15065 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15066 ecom_str
= ecommunity_ecom2str(
15067 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15068 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15069 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15071 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15073 vty_out(vty
, "Import RT(s):\n");
15076 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15077 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15079 "This VRF is not exporting %s routes to any other VRF\n",
15080 get_afi_safi_str(afi
, safi
, false));
15083 "This VRF is exporting %s routes to the following VRFs:\n",
15084 get_afi_safi_str(afi
, safi
, false));
15086 for (ALL_LIST_ELEMENTS_RO(
15087 bgp
->vpn_policy
[afi
].export_vrf
,
15089 vty_out(vty
, " %s\n", vname
);
15091 vty_out(vty
, "RD: %s\n",
15092 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
15093 buf1
, RD_ADDRSTRLEN
));
15095 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15096 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15097 ecom_str
= ecommunity_ecom2str(
15098 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15099 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15100 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15101 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15103 vty_out(vty
, "Import RT(s):\n");
15107 return CMD_SUCCESS
;
15110 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15111 safi_t safi
, bool use_json
)
15113 struct listnode
*node
, *nnode
;
15115 char *vrf_name
= NULL
;
15116 json_object
*json
= NULL
;
15117 json_object
*json_vrf
= NULL
;
15118 json_object
*json_vrfs
= NULL
;
15121 json
= json_object_new_object();
15122 json_vrfs
= json_object_new_object();
15125 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15127 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15128 vrf_name
= bgp
->name
;
15131 json_vrf
= json_object_new_object();
15133 vty_out(vty
, "\nInstance %s:\n",
15134 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15135 ? VRF_DEFAULT_NAME
: bgp
->name
);
15137 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15139 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15140 json_object_object_add(json_vrfs
,
15141 VRF_DEFAULT_NAME
, json_vrf
);
15143 json_object_object_add(json_vrfs
, vrf_name
,
15149 json_object_object_add(json
, "vrfs", json_vrfs
);
15150 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
15151 JSON_C_TO_STRING_PRETTY
));
15152 json_object_free(json
);
15155 return CMD_SUCCESS
;
15158 /* "show [ip] bgp route-leak" command. */
15159 DEFUN (show_ip_bgp_route_leak
,
15160 show_ip_bgp_route_leak_cmd
,
15161 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15165 BGP_INSTANCE_HELP_STR
15168 "Route leaking information\n"
15172 afi_t afi
= AFI_MAX
;
15173 safi_t safi
= SAFI_MAX
;
15175 bool uj
= use_json(argc
, argv
);
15177 json_object
*json
= NULL
;
15179 /* show [ip] bgp */
15180 if (argv_find(argv
, argc
, "ip", &idx
)) {
15182 safi
= SAFI_UNICAST
;
15184 /* [vrf VIEWVRFNAME] */
15185 if (argv_find(argv
, argc
, "view", &idx
)) {
15187 "%% This command is not applicable to BGP views\n");
15188 return CMD_WARNING
;
15191 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15192 vrf
= argv
[idx
+ 1]->arg
;
15193 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15196 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15197 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15198 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15201 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15203 "%% This command is applicable only for unicast ipv4|ipv6\n");
15204 return CMD_WARNING
;
15207 if (vrf
&& strmatch(vrf
, "all"))
15208 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15211 json
= json_object_new_object();
15213 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15216 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15219 struct listnode
*node
, *nnode
;
15222 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15223 vty_out(vty
, "\nInstance %s:\n",
15224 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15227 update_group_show(bgp
, afi
, safi
, vty
, 0);
15231 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15232 int safi
, uint64_t subgrp_id
)
15237 if (strmatch(name
, "all")) {
15238 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
15239 return CMD_SUCCESS
;
15241 bgp
= bgp_lookup_by_name(name
);
15244 bgp
= bgp_get_default();
15248 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
15249 return CMD_SUCCESS
;
15252 DEFUN (show_ip_bgp_updgrps
,
15253 show_ip_bgp_updgrps_cmd
,
15254 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
15258 BGP_INSTANCE_HELP_STR
15260 BGP_SAFI_WITH_LABEL_HELP_STR
15261 "Detailed info about dynamic update groups\n"
15262 "Specific subgroup to display detailed info for\n")
15265 afi_t afi
= AFI_IP6
;
15266 safi_t safi
= SAFI_UNICAST
;
15267 uint64_t subgrp_id
= 0;
15271 /* show [ip] bgp */
15272 if (argv_find(argv
, argc
, "ip", &idx
))
15274 /* [<vrf> VIEWVRFNAME] */
15275 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15276 vrf
= argv
[idx
+ 1]->arg
;
15277 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15279 } else if (argv_find(argv
, argc
, "view", &idx
))
15280 /* [<view> VIEWVRFNAME] */
15281 vrf
= argv
[idx
+ 1]->arg
;
15282 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15283 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15284 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15287 /* get subgroup id, if provided */
15289 if (argv
[idx
]->type
== VARIABLE_TKN
)
15290 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15292 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
15295 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15296 show_bgp_instance_all_ipv6_updgrps_cmd
,
15297 "show [ip] bgp <view|vrf> all update-groups",
15301 BGP_INSTANCE_ALL_HELP_STR
15302 "Detailed info about dynamic update groups\n")
15304 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15305 return CMD_SUCCESS
;
15308 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15309 show_bgp_l2vpn_evpn_updgrps_cmd
,
15310 "show [ip] bgp l2vpn evpn update-groups",
15314 "l2vpn address family\n"
15315 "evpn sub-address family\n"
15316 "Detailed info about dynamic update groups\n")
15319 uint64_t subgrp_id
= 0;
15321 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15322 return CMD_SUCCESS
;
15325 DEFUN (show_bgp_updgrps_stats
,
15326 show_bgp_updgrps_stats_cmd
,
15327 "show [ip] bgp update-groups statistics",
15331 "Detailed info about dynamic update groups\n"
15336 bgp
= bgp_get_default();
15338 update_group_show_stats(bgp
, vty
);
15340 return CMD_SUCCESS
;
15343 DEFUN (show_bgp_instance_updgrps_stats
,
15344 show_bgp_instance_updgrps_stats_cmd
,
15345 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15349 BGP_INSTANCE_HELP_STR
15350 "Detailed info about dynamic update groups\n"
15356 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15358 update_group_show_stats(bgp
, vty
);
15360 return CMD_SUCCESS
;
15363 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15364 afi_t afi
, safi_t safi
,
15365 const char *what
, uint64_t subgrp_id
)
15370 bgp
= bgp_lookup_by_name(name
);
15372 bgp
= bgp_get_default();
15375 if (!strcmp(what
, "advertise-queue"))
15376 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15378 else if (!strcmp(what
, "advertised-routes"))
15379 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15381 else if (!strcmp(what
, "packet-queue"))
15382 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15387 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15388 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15389 "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",
15390 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15392 "Detailed info about dynamic update groups\n"
15393 "Specific subgroup to display info for\n"
15394 "Advertisement queue\n"
15395 "Announced routes\n"
15398 uint64_t subgrp_id
= 0;
15402 subgrp_id
= strtoull(sgid
, NULL
, 10);
15407 afiz
= bgp_vty_afi_from_str(afi
);
15411 afiz
= bgp_vty_afi_from_str(afi
);
15412 if (afiz
!= AFI_IP
)
15414 "%% Cannot specify both 'ip' and 'ipv6'\n");
15415 return CMD_WARNING
;
15418 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15420 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15421 return CMD_SUCCESS
;
15424 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
15426 struct listnode
*node
, *nnode
;
15427 struct prefix
*range
;
15432 const char *peer_status
;
15433 const char *af_str
;
15438 conf
= group
->conf
;
15440 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15441 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15442 group
->name
, conf
->as
);
15443 } else if (conf
->as_type
== AS_INTERNAL
) {
15444 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15445 group
->name
, group
->bgp
->as
);
15447 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15450 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
15451 vty_out(vty
, " Peer-group type is internal\n");
15453 vty_out(vty
, " Peer-group type is external\n");
15455 /* Display AFs configured. */
15456 vty_out(vty
, " Configured address-families:");
15457 FOREACH_AFI_SAFI (afi
, safi
) {
15458 if (conf
->afc
[afi
][safi
]) {
15460 vty_out(vty
, " %s;", get_afi_safi_str(afi
, safi
, false));
15464 vty_out(vty
, " none\n");
15466 vty_out(vty
, "\n");
15468 /* Display listen ranges (for dynamic neighbors), if any */
15469 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15472 else if (afi
== AFI_IP6
)
15476 lr_count
= listcount(group
->listen_range
[afi
]);
15478 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
15482 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15484 vty_out(vty
, " %pFX\n", range
);
15488 /* Display group members and their status */
15489 if (listcount(group
->peer
)) {
15490 vty_out(vty
, " Peer-group members:\n");
15491 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15492 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15493 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15494 peer_status
= "Idle (Admin)";
15495 else if (CHECK_FLAG(peer
->sflags
,
15496 PEER_STATUS_PREFIX_OVERFLOW
))
15497 peer_status
= "Idle (PfxCt)";
15499 peer_status
= lookup_msg(bgp_status_msg
,
15500 peer
->status
, NULL
);
15502 dynamic
= peer_dynamic_neighbor(peer
);
15503 vty_out(vty
, " %s %s %s \n", peer
->host
,
15504 dynamic
? "(dynamic)" : "", peer_status
);
15508 return CMD_SUCCESS
;
15511 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15512 const char *group_name
)
15515 struct listnode
*node
, *nnode
;
15516 struct peer_group
*group
;
15517 bool found
= false;
15519 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15522 vty_out(vty
, "%% BGP instance not found\n");
15523 return CMD_WARNING
;
15526 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15528 if (strmatch(group
->name
, group_name
)) {
15529 bgp_show_one_peer_group(vty
, group
);
15534 bgp_show_one_peer_group(vty
, group
);
15538 if (group_name
&& !found
)
15539 vty_out(vty
, "%% No such peer-group\n");
15541 return CMD_SUCCESS
;
15544 DEFUN (show_ip_bgp_peer_groups
,
15545 show_ip_bgp_peer_groups_cmd
,
15546 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
15550 BGP_INSTANCE_HELP_STR
15551 "Detailed information on BGP peer groups\n"
15552 "Peer group name\n")
15557 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15559 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15561 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
15565 /* Redistribute VTY commands. */
15567 DEFUN_YANG (bgp_redistribute_ipv4
,
15568 bgp_redistribute_ipv4_cmd
,
15569 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15570 "Redistribute information from another routing protocol\n"
15571 FRR_IP_REDIST_HELP_STR_BGPD
)
15573 int idx_protocol
= 1;
15574 char base_xpath
[XPATH_MAXLEN
];
15576 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15577 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15578 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15579 argv
[idx_protocol
]->text
, "0");
15581 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15583 return nb_cli_apply_changes(vty
, base_xpath
);
15587 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15588 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15589 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15591 DEFUN_YANG (bgp_redistribute_ipv4_rmap
,
15592 bgp_redistribute_ipv4_rmap_cmd
,
15593 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15594 "Redistribute information from another routing protocol\n"
15595 FRR_IP_REDIST_HELP_STR_BGPD
15596 "Route map reference\n"
15597 "Pointer to route-map entries\n")
15599 int idx_protocol
= 1;
15601 char base_xpath
[XPATH_MAXLEN
];
15603 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15604 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15605 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15606 argv
[idx_protocol
]->text
, "0");
15608 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15609 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15610 argv
[idx_word
]->arg
);
15612 return nb_cli_apply_changes(vty
, base_xpath
);
15616 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15617 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15618 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15619 "Route map reference\n"
15620 "Pointer to route-map entries\n")
15622 DEFUN_YANG (bgp_redistribute_ipv4_metric
,
15623 bgp_redistribute_ipv4_metric_cmd
,
15624 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15625 "Redistribute information from another routing protocol\n"
15626 FRR_IP_REDIST_HELP_STR_BGPD
15627 "Metric for redistributed routes\n"
15628 "Default metric\n")
15630 int idx_protocol
= 1;
15631 int idx_number
= 3;
15632 char base_xpath
[XPATH_MAXLEN
];
15634 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15635 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15636 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15637 argv
[idx_protocol
]->text
, "0");
15639 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15640 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15641 argv
[idx_number
]->arg
);
15643 return nb_cli_apply_changes(vty
, base_xpath
);
15647 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15648 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15649 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15650 "Metric for redistributed routes\n"
15651 "Default metric\n")
15654 bgp_redistribute_ipv4_rmap_metric
,
15655 bgp_redistribute_ipv4_rmap_metric_cmd
,
15656 "redistribute " FRR_IP_REDIST_STR_BGPD
15657 " route-map WORD metric (0-4294967295)",
15658 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15659 "Route map reference\n"
15660 "Pointer to route-map entries\n"
15661 "Metric for redistributed routes\n"
15662 "Default metric\n")
15664 int idx_protocol
= 1;
15666 int idx_number
= 5;
15667 char base_xpath
[XPATH_MAXLEN
];
15669 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15670 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15671 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15672 argv
[idx_protocol
]->text
, "0");
15674 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15675 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15676 argv
[idx_word
]->arg
);
15677 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15678 argv
[idx_number
]->arg
);
15680 return nb_cli_apply_changes(vty
, base_xpath
);
15684 bgp_redistribute_ipv4_rmap_metric
,
15685 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15686 "redistribute " FRR_IP_REDIST_STR_BGPD
15687 " route-map WORD metric (0-4294967295)",
15688 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15689 "Route map reference\n"
15690 "Pointer to route-map entries\n"
15691 "Metric for redistributed routes\n"
15692 "Default metric\n")
15695 bgp_redistribute_ipv4_metric_rmap
,
15696 bgp_redistribute_ipv4_metric_rmap_cmd
,
15697 "redistribute " FRR_IP_REDIST_STR_BGPD
15698 " metric (0-4294967295) route-map WORD",
15699 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15700 "Metric for redistributed routes\n"
15702 "Route map reference\n"
15703 "Pointer to route-map entries\n")
15705 int idx_protocol
= 1;
15707 int idx_number
= 3;
15708 char base_xpath
[XPATH_MAXLEN
];
15710 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15711 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15712 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15713 argv
[idx_protocol
]->text
, "0");
15715 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15716 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15717 argv
[idx_number
]->arg
);
15718 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15719 argv
[idx_word
]->arg
);
15721 return nb_cli_apply_changes(vty
, base_xpath
);
15725 bgp_redistribute_ipv4_metric_rmap
,
15726 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15727 "redistribute " FRR_IP_REDIST_STR_BGPD
15728 " metric (0-4294967295) route-map WORD",
15729 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15730 "Metric for redistributed routes\n"
15732 "Route map reference\n"
15733 "Pointer to route-map entries\n")
15735 DEFUN_YANG (bgp_redistribute_ipv4_ospf
,
15736 bgp_redistribute_ipv4_ospf_cmd
,
15737 "redistribute <ospf|table> (1-65535)",
15738 "Redistribute information from another routing protocol\n"
15739 "Open Shortest Path First (OSPFv2)\n"
15740 "Non-main Kernel Routing Table\n"
15741 "Instance ID/Table ID\n")
15743 int idx_protocol
= 1;
15744 int idx_number
= 2;
15745 char base_xpath
[XPATH_MAXLEN
];
15747 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15748 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15749 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15750 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15752 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15754 return nb_cli_apply_changes(vty
, base_xpath
);
15757 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
15758 "redistribute <ospf|table> (1-65535)",
15759 "Redistribute information from another routing protocol\n"
15760 "Open Shortest Path First (OSPFv2)\n"
15761 "Non-main Kernel Routing Table\n"
15762 "Instance ID/Table ID\n")
15764 DEFUN_YANG (bgp_redistribute_ipv4_ospf_rmap
,
15765 bgp_redistribute_ipv4_ospf_rmap_cmd
,
15766 "redistribute <ospf|table> (1-65535) route-map WORD",
15767 "Redistribute information from another routing protocol\n"
15768 "Open Shortest Path First (OSPFv2)\n"
15769 "Non-main Kernel Routing Table\n"
15770 "Instance ID/Table ID\n"
15771 "Route map reference\n"
15772 "Pointer to route-map entries\n")
15774 int idx_protocol
= 1;
15775 int idx_number
= 2;
15777 char base_xpath
[XPATH_MAXLEN
];
15779 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15780 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15781 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15782 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15784 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15786 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15787 argv
[idx_word
]->arg
);
15789 return nb_cli_apply_changes(vty
, base_xpath
);
15792 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
15793 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
15794 "redistribute <ospf|table> (1-65535) route-map WORD",
15795 "Redistribute information from another routing protocol\n"
15796 "Open Shortest Path First (OSPFv2)\n"
15797 "Non-main Kernel Routing Table\n"
15798 "Instance ID/Table ID\n"
15799 "Route map reference\n"
15800 "Pointer to route-map entries\n")
15802 DEFUN_YANG(bgp_redistribute_ipv4_ospf_metric
,
15803 bgp_redistribute_ipv4_ospf_metric_cmd
,
15804 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15805 "Redistribute information from another routing protocol\n"
15806 "Open Shortest Path First (OSPFv2)\n"
15807 "Non-main Kernel Routing Table\n"
15808 "Instance ID/Table ID\n"
15809 "Metric for redistributed routes\n"
15810 "Default metric\n")
15812 int idx_protocol
= 1;
15813 int idx_number
= 2;
15814 int idx_number_2
= 4;
15815 char base_xpath
[XPATH_MAXLEN
];
15817 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15818 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15819 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15820 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15822 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15824 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15825 argv
[idx_number_2
]->arg
);
15827 return nb_cli_apply_changes(vty
, base_xpath
);
15830 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
15831 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
15832 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15833 "Redistribute information from another routing protocol\n"
15834 "Open Shortest Path First (OSPFv2)\n"
15835 "Non-main Kernel Routing Table\n"
15836 "Instance ID/Table ID\n"
15837 "Metric for redistributed routes\n"
15838 "Default metric\n")
15841 bgp_redistribute_ipv4_ospf_rmap_metric
,
15842 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
15843 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15844 "Redistribute information from another routing protocol\n"
15845 "Open Shortest Path First (OSPFv2)\n"
15846 "Non-main Kernel Routing Table\n"
15847 "Instance ID/Table ID\n"
15848 "Route map reference\n"
15849 "Pointer to route-map entries\n"
15850 "Metric for redistributed routes\n"
15851 "Default metric\n")
15853 int idx_protocol
= 1;
15854 int idx_number
= 2;
15856 int idx_number_2
= 6;
15857 char base_xpath
[XPATH_MAXLEN
];
15859 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15860 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15861 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15862 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15864 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15866 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15867 argv
[idx_word
]->arg
);
15868 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15869 argv
[idx_number_2
]->arg
);
15871 return nb_cli_apply_changes(vty
, base_xpath
);
15875 bgp_redistribute_ipv4_ospf_rmap_metric
,
15876 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
15877 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15878 "Redistribute information from another routing protocol\n"
15879 "Open Shortest Path First (OSPFv2)\n"
15880 "Non-main Kernel Routing Table\n"
15881 "Instance ID/Table ID\n"
15882 "Route map reference\n"
15883 "Pointer to route-map entries\n"
15884 "Metric for redistributed routes\n"
15885 "Default metric\n")
15888 bgp_redistribute_ipv4_ospf_metric_rmap
,
15889 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
15890 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15891 "Redistribute information from another routing protocol\n"
15892 "Open Shortest Path First (OSPFv2)\n"
15893 "Non-main Kernel Routing Table\n"
15894 "Instance ID/Table ID\n"
15895 "Metric for redistributed routes\n"
15897 "Route map reference\n"
15898 "Pointer to route-map entries\n")
15900 int idx_protocol
= 1;
15901 int idx_number
= 2;
15902 int idx_number_2
= 4;
15904 char base_xpath
[XPATH_MAXLEN
];
15906 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15907 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15908 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15909 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15911 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15913 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15914 argv
[idx_number_2
]->arg
);
15915 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15916 argv
[idx_word
]->arg
);
15918 return nb_cli_apply_changes(vty
, base_xpath
);
15922 bgp_redistribute_ipv4_ospf_metric_rmap
,
15923 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
15924 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15925 "Redistribute information from another routing protocol\n"
15926 "Open Shortest Path First (OSPFv2)\n"
15927 "Non-main Kernel Routing Table\n"
15928 "Instance ID/Table ID\n"
15929 "Metric for redistributed routes\n"
15931 "Route map reference\n"
15932 "Pointer to route-map entries\n")
15934 DEFUN_YANG (no_bgp_redistribute_ipv4_ospf
,
15935 no_bgp_redistribute_ipv4_ospf_cmd
,
15936 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
15938 "Redistribute information from another routing protocol\n"
15939 "Open Shortest Path First (OSPFv2)\n"
15940 "Non-main Kernel Routing Table\n"
15941 "Instance ID/Table ID\n"
15942 "Metric for redistributed routes\n"
15944 "Route map reference\n"
15945 "Pointer to route-map entries\n")
15947 int idx_protocol
= 2;
15948 int idx_number
= 3;
15949 char base_xpath
[XPATH_MAXLEN
];
15951 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15952 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15953 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15954 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15956 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
15958 return nb_cli_apply_changes(vty
, base_xpath
);
15962 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
15963 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
15965 "Redistribute information from another routing protocol\n"
15966 "Open Shortest Path First (OSPFv2)\n"
15967 "Non-main Kernel Routing Table\n"
15968 "Instance ID/Table ID\n"
15969 "Metric for redistributed routes\n"
15971 "Route map reference\n"
15972 "Pointer to route-map entries\n")
15974 DEFUN_YANG (no_bgp_redistribute_ipv4
,
15975 no_bgp_redistribute_ipv4_cmd
,
15976 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
15978 "Redistribute information from another routing protocol\n"
15979 FRR_IP_REDIST_HELP_STR_BGPD
15980 "Metric for redistributed routes\n"
15982 "Route map reference\n"
15983 "Pointer to route-map entries\n")
15985 int idx_protocol
= 2;
15986 char base_xpath
[XPATH_MAXLEN
];
15988 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15989 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15990 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15991 argv
[idx_protocol
]->text
, "0");
15993 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
15995 return nb_cli_apply_changes(vty
, base_xpath
);
15999 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16000 "no redistribute " FRR_IP_REDIST_STR_BGPD
16001 " [{metric (0-4294967295)|route-map WORD}]",
16003 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16004 "Metric for redistributed routes\n"
16006 "Route map reference\n"
16007 "Pointer to route-map entries\n")
16009 DEFUN_YANG (bgp_redistribute_ipv6
,
16010 bgp_redistribute_ipv6_cmd
,
16011 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16012 "Redistribute information from another routing protocol\n"
16013 FRR_IP6_REDIST_HELP_STR_BGPD
)
16015 int idx_protocol
= 1;
16016 char base_xpath
[XPATH_MAXLEN
];
16018 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16019 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16020 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16021 argv
[idx_protocol
]->text
, "0");
16023 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16025 return nb_cli_apply_changes(vty
, base_xpath
);
16028 DEFUN_YANG (bgp_redistribute_ipv6_rmap
,
16029 bgp_redistribute_ipv6_rmap_cmd
,
16030 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
16031 "Redistribute information from another routing protocol\n"
16032 FRR_IP6_REDIST_HELP_STR_BGPD
16033 "Route map reference\n"
16034 "Pointer to route-map entries\n")
16036 int idx_protocol
= 1;
16038 char base_xpath
[XPATH_MAXLEN
];
16040 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16041 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16042 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16043 argv
[idx_protocol
]->text
, "0");
16045 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16046 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16047 argv
[idx_word
]->arg
);
16049 return nb_cli_apply_changes(vty
, base_xpath
);
16052 DEFUN_YANG (bgp_redistribute_ipv6_metric
,
16053 bgp_redistribute_ipv6_metric_cmd
,
16054 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16055 "Redistribute information from another routing protocol\n"
16056 FRR_IP6_REDIST_HELP_STR_BGPD
16057 "Metric for redistributed routes\n"
16058 "Default metric\n")
16060 int idx_protocol
= 1;
16061 int idx_number
= 3;
16062 char base_xpath
[XPATH_MAXLEN
];
16064 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16065 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16066 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16067 argv
[idx_protocol
]->text
, "0");
16069 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16070 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16071 argv
[idx_number
]->arg
);
16073 return nb_cli_apply_changes(vty
, base_xpath
);
16077 bgp_redistribute_ipv6_rmap_metric
,
16078 bgp_redistribute_ipv6_rmap_metric_cmd
,
16079 "redistribute " FRR_IP6_REDIST_STR_BGPD
16080 " route-map WORD metric (0-4294967295)",
16081 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
16082 "Route map reference\n"
16083 "Pointer to route-map entries\n"
16084 "Metric for redistributed routes\n"
16085 "Default metric\n")
16087 int idx_protocol
= 1;
16089 int idx_number
= 5;
16090 char base_xpath
[XPATH_MAXLEN
];
16092 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16093 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16094 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16095 argv
[idx_protocol
]->text
, "0");
16097 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16098 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16099 argv
[idx_word
]->arg
);
16100 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16101 argv
[idx_number
]->arg
);
16103 return nb_cli_apply_changes(vty
, base_xpath
);
16107 bgp_redistribute_ipv6_metric_rmap
,
16108 bgp_redistribute_ipv6_metric_rmap_cmd
,
16109 "redistribute " FRR_IP6_REDIST_STR_BGPD
16110 " metric (0-4294967295) route-map WORD",
16111 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
16112 "Metric for redistributed routes\n"
16114 "Route map reference\n"
16115 "Pointer to route-map entries\n")
16117 int idx_protocol
= 1;
16119 int idx_number
= 3;
16120 char base_xpath
[XPATH_MAXLEN
];
16122 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16123 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16124 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16125 argv
[idx_protocol
]->text
, "0");
16127 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16128 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16129 argv
[idx_number
]->arg
);
16130 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16131 argv
[idx_word
]->arg
);
16133 return nb_cli_apply_changes(vty
, base_xpath
);
16137 no_bgp_redistribute_ipv6
,
16138 no_bgp_redistribute_ipv6_cmd
,
16139 "no redistribute " FRR_IP6_REDIST_STR_BGPD
16140 " [{metric (0-4294967295)|route-map WORD}]",
16142 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
16143 "Metric for redistributed routes\n"
16145 "Route map reference\n"
16146 "Pointer to route-map entries\n")
16148 int idx_protocol
= 2;
16149 char base_xpath
[XPATH_MAXLEN
];
16151 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16152 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16153 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16154 argv
[idx_protocol
]->text
, "0");
16156 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
16158 return nb_cli_apply_changes(vty
, base_xpath
);
16161 void cli_show_bgp_global_afi_safi_ip_unicast_redistribution_list(
16162 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
16164 uint32_t instance
= 0;
16166 vty_out(vty
, " redistribute %s",
16167 yang_dnode_get_string(dnode
, "./route-type"));
16168 if ((instance
= yang_dnode_get_uint16(dnode
, "./route-instance")))
16169 vty_out(vty
, " %d", instance
);
16170 if (yang_dnode_exists(dnode
, "./metric"))
16171 vty_out(vty
, " metric %u",
16172 yang_dnode_get_uint32(dnode
, "./metric"));
16173 if (yang_dnode_exists(dnode
, "./rmap-policy-import"))
16174 vty_out(vty
, " route-map %s",
16175 yang_dnode_get_string(dnode
, "./rmap-policy-import"));
16176 vty_out(vty
, "\n");
16179 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16180 afi_t afi
, safi_t safi
)
16184 /* Unicast redistribution only. */
16185 if (safi
!= SAFI_UNICAST
)
16188 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16189 /* Redistribute BGP does not make sense. */
16190 if (i
!= ZEBRA_ROUTE_BGP
) {
16191 struct list
*red_list
;
16192 struct listnode
*node
;
16193 struct bgp_redist
*red
;
16195 red_list
= bgp
->redist
[afi
][i
];
16199 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16200 /* "redistribute" configuration. */
16201 vty_out(vty
, " redistribute %s",
16202 zebra_route_string(i
));
16204 vty_out(vty
, " %d", red
->instance
);
16205 if (red
->redist_metric_flag
)
16206 vty_out(vty
, " metric %u",
16207 red
->redist_metric
);
16208 if (red
->rmap
.name
)
16209 vty_out(vty
, " route-map %s",
16211 vty_out(vty
, "\n");
16217 /* peer-group helpers for config-write */
16219 static bool peergroup_flag_check(struct peer
*peer
, uint32_t flag
)
16221 if (!peer_group_active(peer
)) {
16222 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16223 return !CHECK_FLAG(peer
->flags
, flag
);
16225 return !!CHECK_FLAG(peer
->flags
, flag
);
16228 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16231 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16234 if (!peer_group_active(peer
)) {
16235 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16236 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16238 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16241 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16244 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16245 uint8_t type
, int direct
)
16247 struct bgp_filter
*filter
;
16249 if (peer_group_active(peer
))
16250 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16253 filter
= &peer
->filter
[afi
][safi
];
16255 case PEER_FT_DISTRIBUTE_LIST
:
16256 return !!(filter
->dlist
[direct
].name
);
16257 case PEER_FT_FILTER_LIST
:
16258 return !!(filter
->aslist
[direct
].name
);
16259 case PEER_FT_PREFIX_LIST
:
16260 return !!(filter
->plist
[direct
].name
);
16261 case PEER_FT_ROUTE_MAP
:
16262 return !!(filter
->map
[direct
].name
);
16263 case PEER_FT_UNSUPPRESS_MAP
:
16264 return !!(filter
->usmap
.name
);
16265 case PEER_FT_ADVERTISE_MAP
:
16266 return !!(filter
->advmap
.aname
16267 && ((filter
->advmap
.condition
== direct
)
16268 && filter
->advmap
.cname
));
16274 /* Return true if the addpath type is set for peer and different from
16277 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16280 enum bgp_addpath_strat type
, g_type
;
16282 type
= peer
->addpath_type
[afi
][safi
];
16284 if (type
!= BGP_ADDPATH_NONE
) {
16285 if (peer_group_active(peer
)) {
16286 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16288 if (type
!= g_type
)
16300 /* This is part of the address-family block (unicast only) */
16301 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16306 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16307 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16308 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16309 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16310 bgp
->vpn_policy
[afi
]
16311 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16313 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16314 bgp
->vpn_policy
[afi
]
16315 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16317 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16318 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16319 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16320 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16323 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16324 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16326 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16329 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16330 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16331 bgp
->vpn_policy
[afi
].tovpn_label
);
16334 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16335 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
16336 char buf
[RD_ADDRSTRLEN
];
16337 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
16338 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
16341 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16342 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16344 char buf
[PREFIX_STRLEN
];
16345 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16346 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16349 vty_out(vty
, "%*snexthop vpn export %s\n",
16353 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16354 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16356 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16357 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16359 char *b
= ecommunity_ecom2str(
16360 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16361 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16362 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16363 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16365 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16366 char *b
= ecommunity_ecom2str(
16367 bgp
->vpn_policy
[afi
]
16368 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16369 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16370 ECOMMUNITY_ROUTE_TARGET
);
16371 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16372 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16374 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16375 char *b
= ecommunity_ecom2str(
16376 bgp
->vpn_policy
[afi
]
16377 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16378 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16379 ECOMMUNITY_ROUTE_TARGET
);
16380 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16381 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16385 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16386 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16387 bgp
->vpn_policy
[afi
]
16388 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16390 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16391 char *b
= ecommunity_ecom2str(
16392 bgp
->vpn_policy
[afi
]
16393 .import_redirect_rtlist
,
16394 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16395 ECOMMUNITY_ROUTE_TARGET
);
16397 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16398 != ECOMMUNITY_SIZE
)
16399 vty_out(vty
, "%*srt6 redirect import %s\n",
16402 vty_out(vty
, "%*srt redirect import %s\n",
16404 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16408 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16409 afi_t afi
, safi_t safi
)
16411 struct bgp_filter
*filter
;
16415 filter
= &peer
->filter
[afi
][safi
];
16417 /* distribute-list. */
16418 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16420 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16421 filter
->dlist
[FILTER_IN
].name
);
16423 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16425 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16426 filter
->dlist
[FILTER_OUT
].name
);
16429 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16431 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16432 filter
->plist
[FILTER_IN
].name
);
16434 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16436 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16437 filter
->plist
[FILTER_OUT
].name
);
16440 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16441 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16442 filter
->map
[RMAP_IN
].name
);
16444 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16446 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16447 filter
->map
[RMAP_OUT
].name
);
16449 /* unsuppress-map */
16450 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16451 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16452 filter
->usmap
.name
);
16454 /* advertise-map : always applied in OUT direction*/
16455 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16456 CONDITION_NON_EXIST
))
16458 " neighbor %s advertise-map %s non-exist-map %s\n",
16459 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16461 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16463 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16464 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16467 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16469 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16470 filter
->aslist
[FILTER_IN
].name
);
16472 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16474 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16475 filter
->aslist
[FILTER_OUT
].name
);
16478 /* BGP peer configuration display function. */
16479 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16482 struct peer
*g_peer
= NULL
;
16483 char buf
[SU_ADDRSTRLEN
];
16485 int if_pg_printed
= false;
16486 int if_ras_printed
= false;
16488 /* Skip dynamic neighbors. */
16489 if (peer_dynamic_neighbor(peer
))
16493 addr
= peer
->conf_if
;
16497 /************************************
16498 ****** Global to the neighbor ******
16499 ************************************/
16500 if (peer
->conf_if
) {
16501 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16502 vty_out(vty
, " neighbor %s interface v6only", addr
);
16504 vty_out(vty
, " neighbor %s interface", addr
);
16506 if (peer_group_active(peer
)) {
16507 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16508 if_pg_printed
= true;
16509 } else if (peer
->as_type
== AS_SPECIFIED
) {
16510 vty_out(vty
, " remote-as %u", peer
->as
);
16511 if_ras_printed
= true;
16512 } else if (peer
->as_type
== AS_INTERNAL
) {
16513 vty_out(vty
, " remote-as internal");
16514 if_ras_printed
= true;
16515 } else if (peer
->as_type
== AS_EXTERNAL
) {
16516 vty_out(vty
, " remote-as external");
16517 if_ras_printed
= true;
16520 vty_out(vty
, "\n");
16523 /* remote-as and peer-group */
16524 /* peer is a member of a peer-group */
16525 if (peer_group_active(peer
)) {
16526 g_peer
= peer
->group
->conf
;
16528 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16529 if (peer
->as_type
== AS_SPECIFIED
) {
16530 vty_out(vty
, " neighbor %s remote-as %u\n",
16532 } else if (peer
->as_type
== AS_INTERNAL
) {
16534 " neighbor %s remote-as internal\n",
16536 } else if (peer
->as_type
== AS_EXTERNAL
) {
16538 " neighbor %s remote-as external\n",
16543 /* For swpX peers we displayed the peer-group
16544 * via 'neighbor swpX interface peer-group PGNAME' */
16545 if (!if_pg_printed
)
16546 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16547 peer
->group
->name
);
16550 /* peer is NOT a member of a peer-group */
16552 /* peer is a peer-group, declare the peer-group */
16553 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16554 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16557 if (!if_ras_printed
) {
16558 if (peer
->as_type
== AS_SPECIFIED
) {
16559 vty_out(vty
, " neighbor %s remote-as %u\n",
16561 } else if (peer
->as_type
== AS_INTERNAL
) {
16563 " neighbor %s remote-as internal\n",
16565 } else if (peer
->as_type
== AS_EXTERNAL
) {
16567 " neighbor %s remote-as external\n",
16574 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16575 vty_out(vty
, " neighbor %s local-as %u", addr
,
16576 peer
->change_local_as
);
16577 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16578 vty_out(vty
, " no-prepend");
16579 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16580 vty_out(vty
, " replace-as");
16581 vty_out(vty
, "\n");
16586 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16590 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16591 if (peer
->tx_shutdown_message
)
16592 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16593 peer
->tx_shutdown_message
);
16595 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16598 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16599 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16600 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16603 if (peer
->bfd_info
) {
16604 if (!peer_group_active(peer
) || !g_peer
->bfd_info
) {
16605 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16610 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16611 vty_out(vty
, " neighbor %s password %s\n", addr
,
16614 /* neighbor solo */
16615 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16616 if (!peer_group_active(peer
)) {
16617 vty_out(vty
, " neighbor %s solo\n", addr
);
16622 if (peer
->port
!= BGP_PORT_DEFAULT
) {
16623 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
16626 /* Local interface name */
16627 if (peer
->ifname
) {
16628 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
16632 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
16633 vty_out(vty
, " neighbor %s passive\n", addr
);
16635 /* ebgp-multihop */
16636 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
16637 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
16638 && peer
->ttl
== MAXTTL
)) {
16639 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
16640 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
16645 /* ttl-security hops */
16646 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
16647 if (!peer_group_active(peer
)
16648 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
16649 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
16650 addr
, peer
->gtsm_hops
);
16654 /* disable-connected-check */
16655 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
16656 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
16658 /* enforce-first-as */
16659 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
16660 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
16662 /* update-source */
16663 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
16664 if (peer
->update_source
)
16665 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16666 sockunion2str(peer
->update_source
, buf
,
16668 else if (peer
->update_if
)
16669 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16673 /* advertisement-interval */
16674 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
16675 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
16679 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
16680 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
16681 peer
->keepalive
, peer
->holdtime
);
16683 /* timers connect */
16684 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
16685 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16687 /* need special-case handling for changed default values due to
16688 * config profile / version (because there is no "timers bgp connect"
16689 * command, we need to save this per-peer :/)
16691 else if (!peer_group_active(peer
) && !peer
->connect
&&
16692 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
16693 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16694 peer
->bgp
->default_connect_retry
);
16696 /* timers delayopen */
16697 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
16698 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16700 /* Save config even though flag is not set if default values have been
16703 else if (!peer_group_active(peer
) && !peer
->delayopen
16704 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
16705 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16706 peer
->bgp
->default_delayopen
);
16708 /* capability dynamic */
16709 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
16710 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
16712 /* capability extended-nexthop */
16713 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
16714 if (!peer
->conf_if
) {
16715 if (CHECK_FLAG(peer
->flags_invert
,
16716 PEER_FLAG_CAPABILITY_ENHE
))
16718 " no neighbor %s capability extended-nexthop\n",
16722 " neighbor %s capability extended-nexthop\n",
16727 /* dont-capability-negotiation */
16728 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
16729 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
16731 /* override-capability */
16732 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
16733 vty_out(vty
, " neighbor %s override-capability\n", addr
);
16735 /* strict-capability-match */
16736 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
16737 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
16739 /* Sender side AS path loop detection. */
16740 if (peer
->as_path_loop_detection
)
16741 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
16744 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16745 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
16747 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16748 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
16750 " neighbor %s graceful-restart-helper\n", addr
);
16751 } else if (CHECK_FLAG(
16752 peer
->peer_gr_new_status_flag
,
16753 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
16755 " neighbor %s graceful-restart\n", addr
);
16757 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16758 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
16760 peer
->peer_gr_new_status_flag
,
16761 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
16762 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
16768 /* BGP peer configuration display function. */
16769 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
16770 struct peer
*peer
, afi_t afi
, safi_t safi
)
16772 struct peer
*g_peer
= NULL
;
16774 bool flag_scomm
, flag_secomm
, flag_slcomm
;
16776 /* Skip dynamic neighbors. */
16777 if (peer_dynamic_neighbor(peer
))
16781 addr
= peer
->conf_if
;
16785 /************************************
16786 ****** Per AF to the neighbor ******
16787 ************************************/
16788 if (peer_group_active(peer
)) {
16789 g_peer
= peer
->group
->conf
;
16791 /* If the peer-group is active but peer is not, print a 'no
16793 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
16794 vty_out(vty
, " no neighbor %s activate\n", addr
);
16797 /* If the peer-group is not active but peer is, print an
16799 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
16800 vty_out(vty
, " neighbor %s activate\n", addr
);
16803 if (peer
->afc
[afi
][safi
]) {
16804 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
16805 if (CHECK_FLAG(bgp
->flags
,
16806 BGP_FLAG_NO_DEFAULT_IPV4
)) {
16807 vty_out(vty
, " neighbor %s activate\n",
16811 vty_out(vty
, " neighbor %s activate\n", addr
);
16813 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
16814 if (!CHECK_FLAG(bgp
->flags
,
16815 BGP_FLAG_NO_DEFAULT_IPV4
)) {
16817 " no neighbor %s activate\n",
16824 /* addpath TX knobs */
16825 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
16826 switch (peer
->addpath_type
[afi
][safi
]) {
16827 case BGP_ADDPATH_ALL
:
16828 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
16831 case BGP_ADDPATH_BEST_PER_AS
:
16833 " neighbor %s addpath-tx-bestpath-per-AS\n",
16836 case BGP_ADDPATH_MAX
:
16837 case BGP_ADDPATH_NONE
:
16842 /* ORF capability. */
16843 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
16844 || peergroup_af_flag_check(peer
, afi
, safi
,
16845 PEER_FLAG_ORF_PREFIX_RM
)) {
16846 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
16848 if (peergroup_af_flag_check(peer
, afi
, safi
,
16849 PEER_FLAG_ORF_PREFIX_SM
)
16850 && peergroup_af_flag_check(peer
, afi
, safi
,
16851 PEER_FLAG_ORF_PREFIX_RM
))
16852 vty_out(vty
, " both");
16853 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16854 PEER_FLAG_ORF_PREFIX_SM
))
16855 vty_out(vty
, " send");
16857 vty_out(vty
, " receive");
16858 vty_out(vty
, "\n");
16861 /* Route reflector client. */
16862 if (peergroup_af_flag_check(peer
, afi
, safi
,
16863 PEER_FLAG_REFLECTOR_CLIENT
)) {
16864 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
16867 /* next-hop-self force */
16868 if (peergroup_af_flag_check(peer
, afi
, safi
,
16869 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
16870 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
16873 /* next-hop-self */
16874 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
16875 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
16878 /* remove-private-AS */
16879 if (peergroup_af_flag_check(peer
, afi
, safi
,
16880 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
16881 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
16885 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16886 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
16887 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
16891 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16892 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
16893 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
16896 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16897 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
16898 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
16902 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
16903 vty_out(vty
, " neighbor %s as-override\n", addr
);
16906 /* send-community print. */
16907 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16908 PEER_FLAG_SEND_COMMUNITY
);
16909 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16910 PEER_FLAG_SEND_EXT_COMMUNITY
);
16911 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16912 PEER_FLAG_SEND_LARGE_COMMUNITY
);
16914 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
16915 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
16918 vty_out(vty
, " no neighbor %s send-community\n", addr
);
16921 " no neighbor %s send-community extended\n",
16925 vty_out(vty
, " no neighbor %s send-community large\n",
16929 /* Default information */
16930 if (peergroup_af_flag_check(peer
, afi
, safi
,
16931 PEER_FLAG_DEFAULT_ORIGINATE
)) {
16932 vty_out(vty
, " neighbor %s default-originate", addr
);
16934 if (peer
->default_rmap
[afi
][safi
].name
)
16935 vty_out(vty
, " route-map %s",
16936 peer
->default_rmap
[afi
][safi
].name
);
16938 vty_out(vty
, "\n");
16941 /* Soft reconfiguration inbound. */
16942 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
16943 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
16947 /* maximum-prefix. */
16948 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
16949 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
16950 peer
->pmax
[afi
][safi
]);
16952 if (peer
->pmax_threshold
[afi
][safi
]
16953 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
16954 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
16955 if (peer_af_flag_check(peer
, afi
, safi
,
16956 PEER_FLAG_MAX_PREFIX_WARNING
))
16957 vty_out(vty
, " warning-only");
16958 if (peer
->pmax_restart
[afi
][safi
])
16959 vty_out(vty
, " restart %u",
16960 peer
->pmax_restart
[afi
][safi
]);
16961 if (peer_af_flag_check(peer
, afi
, safi
,
16962 PEER_FLAG_MAX_PREFIX_FORCE
))
16963 vty_out(vty
, " force");
16965 vty_out(vty
, "\n");
16968 /* maximum-prefix-out */
16969 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
16970 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
16971 addr
, peer
->pmax_out
[afi
][safi
]);
16973 /* Route server client. */
16974 if (peergroup_af_flag_check(peer
, afi
, safi
,
16975 PEER_FLAG_RSERVER_CLIENT
)) {
16976 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
16979 /* Nexthop-local unchanged. */
16980 if (peergroup_af_flag_check(peer
, afi
, safi
,
16981 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
16982 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
16985 /* allowas-in <1-10> */
16986 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
16987 if (peer_af_flag_check(peer
, afi
, safi
,
16988 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
16989 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
16990 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
16991 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
16993 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
16994 peer
->allowas_in
[afi
][safi
]);
16999 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17000 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17001 peer
->weight
[afi
][safi
]);
17004 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17006 /* atribute-unchanged. */
17007 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17008 || (safi
!= SAFI_EVPN
17009 && peer_af_flag_check(peer
, afi
, safi
,
17010 PEER_FLAG_NEXTHOP_UNCHANGED
))
17011 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17013 if (!peer_group_active(peer
)
17014 || peergroup_af_flag_check(peer
, afi
, safi
,
17015 PEER_FLAG_AS_PATH_UNCHANGED
)
17016 || peergroup_af_flag_check(peer
, afi
, safi
,
17017 PEER_FLAG_NEXTHOP_UNCHANGED
)
17018 || peergroup_af_flag_check(peer
, afi
, safi
,
17019 PEER_FLAG_MED_UNCHANGED
)) {
17022 " neighbor %s attribute-unchanged%s%s%s\n",
17024 peer_af_flag_check(peer
, afi
, safi
,
17025 PEER_FLAG_AS_PATH_UNCHANGED
)
17028 peer_af_flag_check(peer
, afi
, safi
,
17029 PEER_FLAG_NEXTHOP_UNCHANGED
)
17032 peer_af_flag_check(peer
, afi
, safi
,
17033 PEER_FLAG_MED_UNCHANGED
)
17040 /* Address family based peer configuration display. */
17041 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17045 struct peer_group
*group
;
17046 struct listnode
*node
, *nnode
;
17049 vty_frame(vty
, " !\n address-family ");
17050 if (afi
== AFI_IP
) {
17051 if (safi
== SAFI_UNICAST
)
17052 vty_frame(vty
, "ipv4 unicast");
17053 else if (safi
== SAFI_LABELED_UNICAST
)
17054 vty_frame(vty
, "ipv4 labeled-unicast");
17055 else if (safi
== SAFI_MULTICAST
)
17056 vty_frame(vty
, "ipv4 multicast");
17057 else if (safi
== SAFI_MPLS_VPN
)
17058 vty_frame(vty
, "ipv4 vpn");
17059 else if (safi
== SAFI_ENCAP
)
17060 vty_frame(vty
, "ipv4 encap");
17061 else if (safi
== SAFI_FLOWSPEC
)
17062 vty_frame(vty
, "ipv4 flowspec");
17063 } else if (afi
== AFI_IP6
) {
17064 if (safi
== SAFI_UNICAST
)
17065 vty_frame(vty
, "ipv6 unicast");
17066 else if (safi
== SAFI_LABELED_UNICAST
)
17067 vty_frame(vty
, "ipv6 labeled-unicast");
17068 else if (safi
== SAFI_MULTICAST
)
17069 vty_frame(vty
, "ipv6 multicast");
17070 else if (safi
== SAFI_MPLS_VPN
)
17071 vty_frame(vty
, "ipv6 vpn");
17072 else if (safi
== SAFI_ENCAP
)
17073 vty_frame(vty
, "ipv6 encap");
17074 else if (safi
== SAFI_FLOWSPEC
)
17075 vty_frame(vty
, "ipv6 flowspec");
17076 } else if (afi
== AFI_L2VPN
) {
17077 if (safi
== SAFI_EVPN
)
17078 vty_frame(vty
, "l2vpn evpn");
17080 vty_frame(vty
, "\n");
17082 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17084 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17086 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17088 /* BGP flag dampening. */
17089 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17090 bgp_config_write_damp(vty
, bgp
, afi
, safi
);
17091 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, node
, group
))
17092 if (peer_af_flag_check(group
->conf
, afi
, safi
,
17093 PEER_FLAG_CONFIG_DAMPENING
))
17094 bgp_config_write_peer_damp(vty
, group
->conf
, afi
, safi
);
17095 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, node
, peer
))
17096 if (peer_af_flag_check(peer
, afi
, safi
,
17097 PEER_FLAG_CONFIG_DAMPENING
))
17098 bgp_config_write_peer_damp(vty
, peer
, afi
, safi
);
17100 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17101 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17103 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17104 /* Skip dynamic neighbors. */
17105 if (peer_dynamic_neighbor(peer
))
17108 /* Do not display doppelganger peers */
17109 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17110 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17113 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17114 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17116 if (safi
== SAFI_EVPN
)
17117 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17119 if (safi
== SAFI_FLOWSPEC
)
17120 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17122 if (safi
== SAFI_UNICAST
) {
17123 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17124 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17125 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17127 vty_out(vty
, " export vpn\n");
17129 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17130 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17132 vty_out(vty
, " import vpn\n");
17134 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17135 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17138 for (ALL_LIST_ELEMENTS_RO(
17139 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17141 vty_out(vty
, " import vrf %s\n", name
);
17145 vty_endframe(vty
, " exit-address-family\n");
17148 int bgp_config_write(struct vty
*vty
)
17151 struct peer_group
*group
;
17153 struct listnode
*node
, *nnode
;
17154 struct listnode
*mnode
, *mnnode
;
17156 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17157 vty_out(vty
, "bgp route-map delay-timer %u\n",
17158 bm
->rmap_update_timer
);
17160 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17161 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17162 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17163 vty_out(vty
, " %d", bm
->v_establish_wait
);
17164 vty_out(vty
, "\n");
17167 if (bm
->wait_for_fib
)
17168 vty_out(vty
, "bgp suppress-fib-pending\n");
17170 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17171 vty_out(vty
, "bgp graceful-shutdown\n");
17173 /* No-RIB (Zebra) option flag configuration */
17174 if (bgp_option_check(BGP_OPT_NO_FIB
))
17175 vty_out(vty
, "bgp no-rib\n");
17177 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17178 vty_out(vty
, "no bgp send-extra-data zebra\n");
17180 /* BGP configuration. */
17181 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17183 /* skip all auto created vrf as they dont have user config */
17184 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17187 /* Router bgp ASN */
17188 vty_out(vty
, "router bgp %u", bgp
->as
);
17191 vty_out(vty
, " %s %s",
17192 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17193 ? "view" : "vrf", bgp
->name
);
17194 vty_out(vty
, "\n");
17196 /* BGP fast-external-failover. */
17197 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17198 vty_out(vty
, " no bgp fast-external-failover\n");
17200 /* BGP router ID. */
17201 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17202 vty_out(vty
, " bgp router-id %pI4\n",
17203 &bgp
->router_id_static
);
17205 /* Suppress fib pending */
17206 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17207 vty_out(vty
, " bgp suppress-fib-pending\n");
17209 /* BGP log-neighbor-changes. */
17210 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17211 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17212 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17213 CHECK_FLAG(bgp
->flags
,
17214 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17218 /* BGP configuration. */
17219 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17220 vty_out(vty
, " bgp always-compare-med\n");
17222 /* RFC8212 default eBGP policy. */
17223 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17224 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17225 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17226 CHECK_FLAG(bgp
->flags
,
17227 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17231 /* draft-ietf-idr-deprecate-as-set-confed-set */
17232 if (bgp
->reject_as_sets
)
17233 vty_out(vty
, " bgp reject-as-sets\n");
17235 /* Suppress duplicate updates if the route actually not changed
17237 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17238 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17239 vty_out(vty
, " %sbgp suppress-duplicates\n",
17240 CHECK_FLAG(bgp
->flags
,
17241 BGP_FLAG_SUPPRESS_DUPLICATES
)
17245 /* BGP default ipv4-unicast. */
17246 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
))
17247 vty_out(vty
, " no bgp default ipv4-unicast\n");
17249 /* BGP default local-preference. */
17250 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17251 vty_out(vty
, " bgp default local-preference %u\n",
17252 bgp
->default_local_pref
);
17254 /* BGP default show-hostname */
17255 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17256 != SAVE_BGP_SHOW_HOSTNAME
)
17257 vty_out(vty
, " %sbgp default show-hostname\n",
17258 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17262 /* BGP default show-nexthop-hostname */
17263 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17264 != SAVE_BGP_SHOW_HOSTNAME
)
17265 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17266 CHECK_FLAG(bgp
->flags
,
17267 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17271 /* BGP default subgroup-pkt-queue-max. */
17272 if (bgp
->default_subgroup_pkt_queue_max
17273 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17274 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17275 bgp
->default_subgroup_pkt_queue_max
);
17277 /* BGP client-to-client reflection. */
17278 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17279 vty_out(vty
, " no bgp client-to-client reflection\n");
17281 /* BGP cluster ID. */
17282 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17283 vty_out(vty
, " bgp cluster-id %pI4\n",
17286 /* Disable ebgp connected nexthop check */
17287 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17289 " bgp disable-ebgp-connected-route-check\n");
17291 /* Confederation identifier*/
17292 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17293 vty_out(vty
, " bgp confederation identifier %u\n",
17296 /* Confederation peer */
17297 if (bgp
->confed_peers_cnt
> 0) {
17300 vty_out(vty
, " bgp confederation peers");
17302 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17303 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17305 vty_out(vty
, "\n");
17308 /* BGP deterministic-med. */
17309 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17310 != SAVE_BGP_DETERMINISTIC_MED
)
17311 vty_out(vty
, " %sbgp deterministic-med\n",
17312 CHECK_FLAG(bgp
->flags
,
17313 BGP_FLAG_DETERMINISTIC_MED
)
17317 /* BGP update-delay. */
17318 bgp_config_write_update_delay(vty
, bgp
);
17320 if (bgp
->v_maxmed_onstartup
17321 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17322 vty_out(vty
, " bgp max-med on-startup %u",
17323 bgp
->v_maxmed_onstartup
);
17324 if (bgp
->maxmed_onstartup_value
17325 != BGP_MAXMED_VALUE_DEFAULT
)
17326 vty_out(vty
, " %u",
17327 bgp
->maxmed_onstartup_value
);
17328 vty_out(vty
, "\n");
17330 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17331 vty_out(vty
, " bgp max-med administrative");
17332 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17333 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17334 vty_out(vty
, "\n");
17338 bgp_config_write_wpkt_quanta(vty
, bgp
);
17340 bgp_config_write_rpkt_quanta(vty
, bgp
);
17342 /* coalesce time */
17343 bgp_config_write_coalesce_time(vty
, bgp
);
17345 /* BGP per-instance graceful-shutdown */
17346 /* BGP-wide settings and per-instance settings are mutually
17349 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17350 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17351 vty_out(vty
, " bgp graceful-shutdown\n");
17353 /* BGP graceful-restart. */
17354 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17356 " bgp graceful-restart stalepath-time %u\n",
17357 bgp
->stalepath_time
);
17359 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17360 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17361 bgp
->restart_time
);
17363 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17365 " bgp graceful-restart select-defer-time %u\n",
17366 bgp
->select_defer_time
);
17368 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17369 vty_out(vty
, " bgp graceful-restart\n");
17371 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17372 vty_out(vty
, " bgp graceful-restart-disable\n");
17374 /* BGP graceful-restart Preserve State F bit. */
17375 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17377 " bgp graceful-restart preserve-fw-state\n");
17379 /* Stale timer for RIB */
17380 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17382 " bgp graceful-restart rib-stale-time %u\n",
17383 bgp
->rib_stale_time
);
17385 /* BGP bestpath method. */
17386 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17387 vty_out(vty
, " bgp bestpath as-path ignore\n");
17388 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17389 vty_out(vty
, " bgp bestpath as-path confed\n");
17391 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17392 if (CHECK_FLAG(bgp
->flags
,
17393 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17395 " bgp bestpath as-path multipath-relax as-set\n");
17398 " bgp bestpath as-path multipath-relax\n");
17402 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17404 " bgp route-reflector allow-outbound-policy\n");
17406 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17407 vty_out(vty
, " bgp bestpath compare-routerid\n");
17408 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17409 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17410 vty_out(vty
, " bgp bestpath med");
17411 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17412 vty_out(vty
, " confed");
17413 if (CHECK_FLAG(bgp
->flags
,
17414 BGP_FLAG_MED_MISSING_AS_WORST
))
17415 vty_out(vty
, " missing-as-worst");
17416 vty_out(vty
, "\n");
17419 /* Link bandwidth handling. */
17420 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17421 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17422 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17423 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17424 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17425 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17427 /* BGP network import check. */
17428 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17429 != SAVE_BGP_IMPORT_CHECK
)
17430 vty_out(vty
, " %sbgp network import-check\n",
17431 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17435 /* BGP timers configuration. */
17436 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17437 && bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17438 vty_out(vty
, " timers bgp %u %u\n",
17439 bgp
->default_keepalive
, bgp
->default_holdtime
);
17442 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17443 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17446 /* Normal neighbor configuration. */
17447 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17448 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17449 bgp_config_write_peer_global(vty
, bgp
, peer
);
17452 /* listen range and limit for dynamic BGP neighbors */
17453 bgp_config_write_listen(vty
, bgp
);
17456 * BGP default autoshutdown neighbors
17458 * This must be placed after any peer and peer-group
17459 * configuration, to avoid setting all peers to shutdown after
17460 * a daemon restart, which is undesired behavior. (see #2286)
17462 if (bgp
->autoshutdown
)
17463 vty_out(vty
, " bgp default shutdown\n");
17465 /* BGP instance administrative shutdown */
17466 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17467 vty_out(vty
, " bgp shutdown\n");
17469 /* IPv4 unicast configuration. */
17470 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17472 /* IPv4 multicast configuration. */
17473 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17475 /* IPv4 labeled-unicast configuration. */
17476 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17478 /* IPv4 VPN configuration. */
17479 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17481 /* ENCAPv4 configuration. */
17482 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17484 /* FLOWSPEC v4 configuration. */
17485 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17487 /* IPv6 unicast configuration. */
17488 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17490 /* IPv6 multicast configuration. */
17491 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17493 /* IPv6 labeled-unicast configuration. */
17494 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17495 SAFI_LABELED_UNICAST
);
17497 /* IPv6 VPN configuration. */
17498 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17500 /* ENCAPv6 configuration. */
17501 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17503 /* FLOWSPEC v6 configuration. */
17504 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17506 /* EVPN configuration. */
17507 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17509 hook_call(bgp_inst_config_write
, bgp
, vty
);
17511 #ifdef ENABLE_BGP_VNC
17512 bgp_rfapi_cfg_write(vty
, bgp
);
17515 vty_out(vty
, "!\n");
17521 /* BGP node structure. */
17522 static struct cmd_node bgp_node
= {
17525 .parent_node
= CONFIG_NODE
,
17526 .prompt
= "%s(config-router)# ",
17527 .config_write
= bgp_config_write
,
17530 static struct cmd_node bgp_ipv4_unicast_node
= {
17531 .name
= "bgp ipv4 unicast",
17532 .node
= BGP_IPV4_NODE
,
17533 .parent_node
= BGP_NODE
,
17534 .prompt
= "%s(config-router-af)# ",
17537 static struct cmd_node bgp_ipv4_multicast_node
= {
17538 .name
= "bgp ipv4 multicast",
17539 .node
= BGP_IPV4M_NODE
,
17540 .parent_node
= BGP_NODE
,
17541 .prompt
= "%s(config-router-af)# ",
17544 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
17545 .name
= "bgp ipv4 labeled unicast",
17546 .node
= BGP_IPV4L_NODE
,
17547 .parent_node
= BGP_NODE
,
17548 .prompt
= "%s(config-router-af)# ",
17551 static struct cmd_node bgp_ipv6_unicast_node
= {
17552 .name
= "bgp ipv6",
17553 .node
= BGP_IPV6_NODE
,
17554 .parent_node
= BGP_NODE
,
17555 .prompt
= "%s(config-router-af)# ",
17558 static struct cmd_node bgp_ipv6_multicast_node
= {
17559 .name
= "bgp ipv6 multicast",
17560 .node
= BGP_IPV6M_NODE
,
17561 .parent_node
= BGP_NODE
,
17562 .prompt
= "%s(config-router-af)# ",
17565 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
17566 .name
= "bgp ipv6 labeled unicast",
17567 .node
= BGP_IPV6L_NODE
,
17568 .parent_node
= BGP_NODE
,
17569 .prompt
= "%s(config-router-af)# ",
17572 static struct cmd_node bgp_vpnv4_node
= {
17573 .name
= "bgp vpnv4",
17574 .node
= BGP_VPNV4_NODE
,
17575 .parent_node
= BGP_NODE
,
17576 .prompt
= "%s(config-router-af)# ",
17579 static struct cmd_node bgp_vpnv6_node
= {
17580 .name
= "bgp vpnv6",
17581 .node
= BGP_VPNV6_NODE
,
17582 .parent_node
= BGP_NODE
,
17583 .prompt
= "%s(config-router-af-vpnv6)# ",
17586 static struct cmd_node bgp_evpn_node
= {
17587 .name
= "bgp evpn",
17588 .node
= BGP_EVPN_NODE
,
17589 .parent_node
= BGP_NODE
,
17590 .prompt
= "%s(config-router-evpn)# ",
17593 static struct cmd_node bgp_evpn_vni_node
= {
17594 .name
= "bgp evpn vni",
17595 .node
= BGP_EVPN_VNI_NODE
,
17596 .parent_node
= BGP_EVPN_NODE
,
17597 .prompt
= "%s(config-router-af-vni)# ",
17600 static struct cmd_node bgp_flowspecv4_node
= {
17601 .name
= "bgp ipv4 flowspec",
17602 .node
= BGP_FLOWSPECV4_NODE
,
17603 .parent_node
= BGP_NODE
,
17604 .prompt
= "%s(config-router-af)# ",
17607 static struct cmd_node bgp_flowspecv6_node
= {
17608 .name
= "bgp ipv6 flowspec",
17609 .node
= BGP_FLOWSPECV6_NODE
,
17610 .parent_node
= BGP_NODE
,
17611 .prompt
= "%s(config-router-af-vpnv6)# ",
17614 static void community_list_vty(void);
17616 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
17620 struct listnode
*lnbgp
, *lnpeer
;
17622 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17623 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
17624 /* only provide suggestions on the appropriate input
17626 * they'll otherwise show up multiple times */
17627 enum cmd_token_type match_type
;
17628 char *name
= peer
->host
;
17630 if (peer
->conf_if
) {
17631 match_type
= VARIABLE_TKN
;
17632 name
= peer
->conf_if
;
17633 } else if (strchr(peer
->host
, ':'))
17634 match_type
= IPV6_TKN
;
17636 match_type
= IPV4_TKN
;
17638 if (token
->type
!= match_type
)
17641 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
17646 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
17647 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
17648 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
17649 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
17650 {.completions
= NULL
}};
17652 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
17655 struct peer_group
*group
;
17656 struct listnode
*lnbgp
, *lnpeer
;
17658 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17659 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
17660 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
17665 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
17666 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
17667 {.completions
= NULL
} };
17669 void bgp_vty_init(void)
17671 cmd_variable_handler_register(bgp_var_neighbor
);
17672 cmd_variable_handler_register(bgp_var_peergroup
);
17674 /* Install bgp top node. */
17675 install_node(&bgp_node
);
17676 install_node(&bgp_ipv4_unicast_node
);
17677 install_node(&bgp_ipv4_multicast_node
);
17678 install_node(&bgp_ipv4_labeled_unicast_node
);
17679 install_node(&bgp_ipv6_unicast_node
);
17680 install_node(&bgp_ipv6_multicast_node
);
17681 install_node(&bgp_ipv6_labeled_unicast_node
);
17682 install_node(&bgp_vpnv4_node
);
17683 install_node(&bgp_vpnv6_node
);
17684 install_node(&bgp_evpn_node
);
17685 install_node(&bgp_evpn_vni_node
);
17686 install_node(&bgp_flowspecv4_node
);
17687 install_node(&bgp_flowspecv6_node
);
17689 /* Install default VTY commands to new nodes. */
17690 install_default(BGP_NODE
);
17691 install_default(BGP_IPV4_NODE
);
17692 install_default(BGP_IPV4M_NODE
);
17693 install_default(BGP_IPV4L_NODE
);
17694 install_default(BGP_IPV6_NODE
);
17695 install_default(BGP_IPV6M_NODE
);
17696 install_default(BGP_IPV6L_NODE
);
17697 install_default(BGP_VPNV4_NODE
);
17698 install_default(BGP_VPNV6_NODE
);
17699 install_default(BGP_FLOWSPECV4_NODE
);
17700 install_default(BGP_FLOWSPECV6_NODE
);
17701 install_default(BGP_EVPN_NODE
);
17702 install_default(BGP_EVPN_VNI_NODE
);
17704 /* "bgp local-mac" hidden commands. */
17705 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
17706 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
17708 /* "bgp suppress-fib-pending" global */
17709 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
17711 /* bgp route-map delay-timer commands. */
17712 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17713 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17715 /* global bgp update-delay command */
17716 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
17717 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
17719 /* global bgp graceful-shutdown command */
17720 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
17721 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
17723 /* Dummy commands (Currently not supported) */
17724 install_element(BGP_NODE
, &no_synchronization_cmd
);
17725 install_element(BGP_NODE
, &no_auto_summary_cmd
);
17727 /* "router bgp" commands. */
17728 install_element(CONFIG_NODE
, &router_bgp_cmd
);
17730 /* "no router bgp" commands. */
17731 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
17733 /* "bgp router-id" commands. */
17734 install_element(BGP_NODE
, &bgp_router_id_cmd
);
17735 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
17737 /* "bgp suppress-fib-pending" command */
17738 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
17740 /* "bgp cluster-id" commands. */
17741 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
17742 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
17744 /* "bgp no-rib" commands. */
17745 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
17746 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
17748 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
17750 /* "bgp confederation" commands. */
17751 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
17752 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
17754 /* "bgp confederation peers" commands. */
17755 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
17756 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
17758 /* bgp max-med command */
17759 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
17760 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
17761 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
17762 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
17763 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
17765 /* bgp disable-ebgp-connected-nh-check */
17766 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
17767 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
17769 /* bgp update-delay command */
17770 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
17771 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
17773 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
17774 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
17776 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
17777 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
17779 /* "maximum-paths" commands. */
17780 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
17781 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
17782 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
17783 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
17784 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
17785 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
17786 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
17787 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
17788 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
17789 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
17790 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17791 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17792 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
17793 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17794 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17796 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
17797 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
17798 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17799 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17800 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17801 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
17802 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
17803 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17804 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17805 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17807 /* "timers bgp" commands. */
17808 install_element(BGP_NODE
, &bgp_timers_cmd
);
17809 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
17811 /* route-map delay-timer commands - per instance for backwards compat.
17813 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17814 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17816 /* "bgp client-to-client reflection" commands */
17817 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
17818 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
17820 /* "bgp always-compare-med" commands */
17821 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
17822 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
17824 /* bgp ebgp-requires-policy */
17825 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
17826 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
17828 /* bgp suppress-duplicates */
17829 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
17830 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
17832 /* bgp reject-as-sets */
17833 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
17834 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
17836 /* "bgp deterministic-med" commands */
17837 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
17838 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
17840 /* "bgp graceful-restart" command */
17841 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
17842 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
17844 /* "bgp graceful-restart-disable" command */
17845 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
17846 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
17848 /* "neighbor a:b:c:d graceful-restart" command */
17849 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
17850 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
17852 /* "neighbor a:b:c:d graceful-restart-disable" command */
17853 install_element(BGP_NODE
,
17854 &bgp_neighbor_graceful_restart_disable_set_cmd
);
17855 install_element(BGP_NODE
,
17856 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
17858 /* "neighbor a:b:c:d graceful-restart-helper" command */
17859 install_element(BGP_NODE
,
17860 &bgp_neighbor_graceful_restart_helper_set_cmd
);
17861 install_element(BGP_NODE
,
17862 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
17864 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
17865 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
17866 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
17867 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
17868 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
17869 install_element(BGP_NODE
,
17870 &no_bgp_graceful_restart_select_defer_time_cmd
);
17871 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
17872 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
17874 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
17875 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
17876 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
17877 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
17879 /* "bgp graceful-shutdown" commands */
17880 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
17881 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
17883 /* "bgp fast-external-failover" commands */
17884 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
17885 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
17887 /* "bgp bestpath compare-routerid" commands */
17888 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
17889 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
17891 /* "bgp bestpath as-path ignore" commands */
17892 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
17893 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
17895 /* "bgp bestpath as-path confed" commands */
17896 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
17897 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
17899 /* "bgp bestpath as-path multipath-relax" commands */
17900 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
17901 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
17903 /* "bgp log-neighbor-changes" commands */
17904 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
17905 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
17907 /* "bgp bestpath med" commands */
17908 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
17909 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
17911 /* "bgp bestpath bandwidth" commands */
17912 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
17913 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
17915 /* "no bgp default ipv4-unicast" commands. */
17916 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
17917 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
17919 /* "bgp network import-check" commands. */
17920 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
17921 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
17922 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
17924 /* "bgp default local-preference" commands. */
17925 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
17926 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
17928 /* bgp default show-hostname */
17929 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
17930 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
17932 /* bgp default show-nexthop-hostname */
17933 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
17934 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
17936 /* "bgp default subgroup-pkt-queue-max" commands. */
17937 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
17938 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
17940 /* bgp ibgp-allow-policy-mods command */
17941 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
17942 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
17944 /* "bgp listen limit" commands. */
17945 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
17946 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
17948 /* "bgp listen range" commands. */
17949 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
17950 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
17952 /* "bgp default shutdown" command */
17953 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
17955 /* "bgp shutdown" commands */
17956 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
17957 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
17958 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
17959 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
17961 /* "neighbor remote-as" commands. */
17962 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
17963 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
17964 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
17965 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
17966 install_element(BGP_NODE
,
17967 &neighbor_interface_v6only_config_remote_as_cmd
);
17968 install_element(BGP_NODE
, &no_neighbor_cmd
);
17969 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
17971 /* "neighbor peer-group" commands. */
17972 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
17973 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
17974 install_element(BGP_NODE
,
17975 &no_neighbor_interface_peer_group_remote_as_cmd
);
17977 /* "neighbor local-as" commands. */
17978 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
17979 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
17980 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
17981 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
17983 /* "neighbor solo" commands. */
17984 install_element(BGP_NODE
, &neighbor_solo_cmd
);
17985 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
17987 /* "neighbor password" commands. */
17988 install_element(BGP_NODE
, &neighbor_password_cmd
);
17989 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
17991 /* "neighbor activate" commands. */
17992 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
17993 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
17994 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
17995 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
17996 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
17997 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
17998 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
17999 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
18000 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
18001 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
18002 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
18003 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
18005 /* "no neighbor activate" commands. */
18006 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
18007 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
18008 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
18009 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
18010 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
18011 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
18012 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
18013 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
18014 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
18015 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
18016 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
18017 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
18019 /* "neighbor peer-group" set commands. */
18020 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
18021 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18022 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18023 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18024 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18025 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18026 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18027 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18028 install_element(BGP_FLOWSPECV4_NODE
,
18029 &neighbor_set_peer_group_hidden_cmd
);
18030 install_element(BGP_FLOWSPECV6_NODE
,
18031 &neighbor_set_peer_group_hidden_cmd
);
18033 /* "no neighbor peer-group unset" commands. */
18034 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
18035 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18036 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18037 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18038 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18039 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18040 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18041 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18042 install_element(BGP_FLOWSPECV4_NODE
,
18043 &no_neighbor_set_peer_group_hidden_cmd
);
18044 install_element(BGP_FLOWSPECV6_NODE
,
18045 &no_neighbor_set_peer_group_hidden_cmd
);
18047 /* "neighbor softreconfiguration inbound" commands.*/
18048 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
18049 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
18050 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18051 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18052 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18053 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18054 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18055 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18056 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18057 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18058 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18059 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18060 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18061 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18062 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18063 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18064 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18065 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18066 install_element(BGP_FLOWSPECV4_NODE
,
18067 &neighbor_soft_reconfiguration_cmd
);
18068 install_element(BGP_FLOWSPECV4_NODE
,
18069 &no_neighbor_soft_reconfiguration_cmd
);
18070 install_element(BGP_FLOWSPECV6_NODE
,
18071 &neighbor_soft_reconfiguration_cmd
);
18072 install_element(BGP_FLOWSPECV6_NODE
,
18073 &no_neighbor_soft_reconfiguration_cmd
);
18074 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
18075 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18077 /* "neighbor attribute-unchanged" commands. */
18078 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
18079 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
18080 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
18081 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18082 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
18083 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18084 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
18085 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18086 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
18087 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18088 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
18089 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18090 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
18091 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18092 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
18093 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18094 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
18095 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18097 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
18098 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
18100 /* "nexthop-local unchanged" commands */
18101 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
18102 install_element(BGP_IPV6_NODE
,
18103 &no_neighbor_nexthop_local_unchanged_cmd
);
18105 /* "neighbor next-hop-self" commands. */
18106 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
18107 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
18108 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
18109 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18110 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
18111 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
18112 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
18113 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
18114 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
18115 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18116 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
18117 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
18118 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
18119 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
18120 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
18121 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18122 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
18123 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18124 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
18125 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
18127 /* "neighbor next-hop-self force" commands. */
18128 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
18129 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
18130 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18131 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
18132 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18133 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18134 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18135 install_element(BGP_IPV4_NODE
,
18136 &no_neighbor_nexthop_self_all_hidden_cmd
);
18137 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
18138 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18139 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18140 install_element(BGP_IPV4M_NODE
,
18141 &no_neighbor_nexthop_self_all_hidden_cmd
);
18142 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
18143 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18144 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18145 install_element(BGP_IPV4L_NODE
,
18146 &no_neighbor_nexthop_self_all_hidden_cmd
);
18147 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18148 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18149 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18150 install_element(BGP_IPV6_NODE
,
18151 &no_neighbor_nexthop_self_all_hidden_cmd
);
18152 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
18153 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18154 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18155 install_element(BGP_IPV6M_NODE
,
18156 &no_neighbor_nexthop_self_all_hidden_cmd
);
18157 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
18158 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18159 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18160 install_element(BGP_IPV6L_NODE
,
18161 &no_neighbor_nexthop_self_all_hidden_cmd
);
18162 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18163 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18164 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18165 install_element(BGP_VPNV4_NODE
,
18166 &no_neighbor_nexthop_self_all_hidden_cmd
);
18167 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18168 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18169 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18170 install_element(BGP_VPNV6_NODE
,
18171 &no_neighbor_nexthop_self_all_hidden_cmd
);
18172 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
18173 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18175 /* "neighbor as-override" commands. */
18176 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
18177 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
18178 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
18179 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
18180 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
18181 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
18182 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
18183 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
18184 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
18185 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
18186 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
18187 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
18188 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
18189 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
18190 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
18191 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
18192 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
18193 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
18195 /* "neighbor remove-private-AS" commands. */
18196 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
18197 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
18198 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
18199 install_element(BGP_NODE
,
18200 &no_neighbor_remove_private_as_all_hidden_cmd
);
18201 install_element(BGP_NODE
,
18202 &neighbor_remove_private_as_replace_as_hidden_cmd
);
18203 install_element(BGP_NODE
,
18204 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
18205 install_element(BGP_NODE
,
18206 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18209 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18210 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
18211 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18212 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18213 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18214 install_element(BGP_IPV4_NODE
,
18215 &neighbor_remove_private_as_replace_as_cmd
);
18216 install_element(BGP_IPV4_NODE
,
18217 &no_neighbor_remove_private_as_replace_as_cmd
);
18218 install_element(BGP_IPV4_NODE
,
18219 &neighbor_remove_private_as_all_replace_as_cmd
);
18220 install_element(BGP_IPV4_NODE
,
18221 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18222 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
18223 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
18224 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
18225 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18226 install_element(BGP_IPV4M_NODE
,
18227 &neighbor_remove_private_as_replace_as_cmd
);
18228 install_element(BGP_IPV4M_NODE
,
18229 &no_neighbor_remove_private_as_replace_as_cmd
);
18230 install_element(BGP_IPV4M_NODE
,
18231 &neighbor_remove_private_as_all_replace_as_cmd
);
18232 install_element(BGP_IPV4M_NODE
,
18233 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18234 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
18235 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
18236 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
18237 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18238 install_element(BGP_IPV4L_NODE
,
18239 &neighbor_remove_private_as_replace_as_cmd
);
18240 install_element(BGP_IPV4L_NODE
,
18241 &no_neighbor_remove_private_as_replace_as_cmd
);
18242 install_element(BGP_IPV4L_NODE
,
18243 &neighbor_remove_private_as_all_replace_as_cmd
);
18244 install_element(BGP_IPV4L_NODE
,
18245 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18246 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
18247 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18248 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18249 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18250 install_element(BGP_IPV6_NODE
,
18251 &neighbor_remove_private_as_replace_as_cmd
);
18252 install_element(BGP_IPV6_NODE
,
18253 &no_neighbor_remove_private_as_replace_as_cmd
);
18254 install_element(BGP_IPV6_NODE
,
18255 &neighbor_remove_private_as_all_replace_as_cmd
);
18256 install_element(BGP_IPV6_NODE
,
18257 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18258 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
18259 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
18260 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
18261 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18262 install_element(BGP_IPV6M_NODE
,
18263 &neighbor_remove_private_as_replace_as_cmd
);
18264 install_element(BGP_IPV6M_NODE
,
18265 &no_neighbor_remove_private_as_replace_as_cmd
);
18266 install_element(BGP_IPV6M_NODE
,
18267 &neighbor_remove_private_as_all_replace_as_cmd
);
18268 install_element(BGP_IPV6M_NODE
,
18269 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18270 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
18271 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
18272 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
18273 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18274 install_element(BGP_IPV6L_NODE
,
18275 &neighbor_remove_private_as_replace_as_cmd
);
18276 install_element(BGP_IPV6L_NODE
,
18277 &no_neighbor_remove_private_as_replace_as_cmd
);
18278 install_element(BGP_IPV6L_NODE
,
18279 &neighbor_remove_private_as_all_replace_as_cmd
);
18280 install_element(BGP_IPV6L_NODE
,
18281 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18282 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
18283 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18284 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18285 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18286 install_element(BGP_VPNV4_NODE
,
18287 &neighbor_remove_private_as_replace_as_cmd
);
18288 install_element(BGP_VPNV4_NODE
,
18289 &no_neighbor_remove_private_as_replace_as_cmd
);
18290 install_element(BGP_VPNV4_NODE
,
18291 &neighbor_remove_private_as_all_replace_as_cmd
);
18292 install_element(BGP_VPNV4_NODE
,
18293 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18294 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
18295 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18296 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18297 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18298 install_element(BGP_VPNV6_NODE
,
18299 &neighbor_remove_private_as_replace_as_cmd
);
18300 install_element(BGP_VPNV6_NODE
,
18301 &no_neighbor_remove_private_as_replace_as_cmd
);
18302 install_element(BGP_VPNV6_NODE
,
18303 &neighbor_remove_private_as_all_replace_as_cmd
);
18304 install_element(BGP_VPNV6_NODE
,
18305 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18307 /* "neighbor send-community" commands.*/
18308 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
18309 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
18310 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
18311 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
18312 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
18313 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
18314 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
18315 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
18316 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
18317 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
18318 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
18319 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
18320 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
18321 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
18322 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
18323 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
18324 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
18325 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
18326 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
18327 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
18328 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
18329 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
18330 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
18331 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
18332 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
18333 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
18334 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
18335 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
18336 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
18337 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
18338 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
18339 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
18340 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
18341 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
18342 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
18343 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
18345 /* "neighbor route-reflector" commands.*/
18346 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
18347 install_element(BGP_NODE
,
18348 &no_neighbor_route_reflector_client_hidden_cmd
);
18349 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
18350 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
18351 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
18352 install_element(BGP_IPV4M_NODE
,
18353 &no_neighbor_route_reflector_client_cmd
);
18354 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
18355 install_element(BGP_IPV4L_NODE
,
18356 &no_neighbor_route_reflector_client_cmd
);
18357 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
18358 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
18359 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
18360 install_element(BGP_IPV6M_NODE
,
18361 &no_neighbor_route_reflector_client_cmd
);
18362 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
18363 install_element(BGP_IPV6L_NODE
,
18364 &no_neighbor_route_reflector_client_cmd
);
18365 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
18366 install_element(BGP_VPNV4_NODE
,
18367 &no_neighbor_route_reflector_client_cmd
);
18368 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
18369 install_element(BGP_VPNV6_NODE
,
18370 &no_neighbor_route_reflector_client_cmd
);
18371 install_element(BGP_FLOWSPECV4_NODE
,
18372 &neighbor_route_reflector_client_cmd
);
18373 install_element(BGP_FLOWSPECV4_NODE
,
18374 &no_neighbor_route_reflector_client_cmd
);
18375 install_element(BGP_FLOWSPECV6_NODE
,
18376 &neighbor_route_reflector_client_cmd
);
18377 install_element(BGP_FLOWSPECV6_NODE
,
18378 &no_neighbor_route_reflector_client_cmd
);
18379 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
18380 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
18382 /* "neighbor route-server" commands.*/
18383 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
18384 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
18385 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
18386 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
18387 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
18388 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
18389 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
18390 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
18391 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
18392 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
18393 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
18394 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
18395 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
18396 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
18397 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
18398 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
18399 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
18400 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
18401 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
18402 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
18403 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
18404 install_element(BGP_FLOWSPECV4_NODE
,
18405 &no_neighbor_route_server_client_cmd
);
18406 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
18407 install_element(BGP_FLOWSPECV6_NODE
,
18408 &no_neighbor_route_server_client_cmd
);
18410 /* "neighbor addpath-tx-all-paths" commands.*/
18411 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
18412 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
18413 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18414 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18415 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18416 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18417 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18418 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18419 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18420 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18421 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18422 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18423 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18424 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18425 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18426 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18427 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18428 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18430 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
18431 install_element(BGP_NODE
,
18432 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18433 install_element(BGP_NODE
,
18434 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18435 install_element(BGP_IPV4_NODE
,
18436 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18437 install_element(BGP_IPV4_NODE
,
18438 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18439 install_element(BGP_IPV4M_NODE
,
18440 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18441 install_element(BGP_IPV4M_NODE
,
18442 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18443 install_element(BGP_IPV4L_NODE
,
18444 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18445 install_element(BGP_IPV4L_NODE
,
18446 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18447 install_element(BGP_IPV6_NODE
,
18448 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18449 install_element(BGP_IPV6_NODE
,
18450 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18451 install_element(BGP_IPV6M_NODE
,
18452 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18453 install_element(BGP_IPV6M_NODE
,
18454 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18455 install_element(BGP_IPV6L_NODE
,
18456 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18457 install_element(BGP_IPV6L_NODE
,
18458 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18459 install_element(BGP_VPNV4_NODE
,
18460 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18461 install_element(BGP_VPNV4_NODE
,
18462 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18463 install_element(BGP_VPNV6_NODE
,
18464 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18465 install_element(BGP_VPNV6_NODE
,
18466 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18468 /* "neighbor sender-as-path-loop-detection" commands. */
18469 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
18470 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
18472 /* "neighbor passive" commands. */
18473 install_element(BGP_NODE
, &neighbor_passive_cmd
);
18474 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
18477 /* "neighbor shutdown" commands. */
18478 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
18479 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
18480 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
18481 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
18482 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
18483 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
18485 /* "neighbor capability extended-nexthop" commands.*/
18486 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
18487 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
18489 /* "neighbor capability orf prefix-list" commands.*/
18490 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
18491 install_element(BGP_NODE
,
18492 &no_neighbor_capability_orf_prefix_hidden_cmd
);
18493 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
18494 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18495 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18496 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18497 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18498 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18499 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
18500 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18501 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18502 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18503 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18504 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18506 /* "neighbor capability dynamic" commands.*/
18507 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
18508 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
18510 /* "neighbor dont-capability-negotiate" commands. */
18511 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
18512 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
18514 /* "neighbor ebgp-multihop" commands. */
18515 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
18516 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
18517 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
18519 /* "neighbor disable-connected-check" commands. */
18520 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
18521 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
18523 /* "neighbor enforce-first-as" commands. */
18524 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
18525 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
18527 /* "neighbor description" commands. */
18528 install_element(BGP_NODE
, &neighbor_description_cmd
);
18529 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
18530 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
18532 /* "neighbor update-source" commands. "*/
18533 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
18534 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
18536 /* "neighbor default-originate" commands. */
18537 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
18538 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
18539 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
18540 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
18541 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
18542 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
18543 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
18544 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
18545 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
18546 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
18547 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
18548 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
18549 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
18550 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
18551 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
18552 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
18553 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
18554 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
18555 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
18556 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
18557 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
18559 /* "neighbor port" commands. */
18560 install_element(BGP_NODE
, &neighbor_port_cmd
);
18561 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
18563 /* "neighbor weight" commands. */
18564 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
18565 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
18567 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
18568 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
18569 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
18570 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
18571 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
18572 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
18573 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
18574 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
18575 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
18576 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
18577 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
18578 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
18579 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
18580 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
18581 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
18582 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
18584 /* "neighbor override-capability" commands. */
18585 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
18586 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
18588 /* "neighbor strict-capability-match" commands. */
18589 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
18590 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
18592 /* "neighbor timers" commands. */
18593 install_element(BGP_NODE
, &neighbor_timers_cmd
);
18594 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
18596 /* "neighbor timers connect" commands. */
18597 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
18598 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
18600 /* "neighbor timers delayopen" commands. */
18601 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
18602 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
18604 /* "neighbor advertisement-interval" commands. */
18605 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
18606 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
18608 /* "neighbor interface" commands. */
18609 install_element(BGP_NODE
, &neighbor_interface_cmd
);
18610 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
18612 /* "neighbor distribute" commands. */
18613 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
18614 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
18615 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
18616 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
18617 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
18618 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
18619 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
18620 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
18621 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
18622 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
18623 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
18624 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
18625 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
18626 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
18627 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
18628 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
18629 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
18630 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
18632 /* "neighbor prefix-list" commands. */
18633 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
18634 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
18635 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
18636 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
18637 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
18638 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
18639 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
18640 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
18641 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
18642 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
18643 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
18644 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
18645 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
18646 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
18647 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
18648 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
18649 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
18650 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
18651 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
18652 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
18653 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
18654 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
18656 /* "neighbor filter-list" commands. */
18657 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
18658 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
18659 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
18660 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
18661 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
18662 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
18663 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
18664 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
18665 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
18666 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
18667 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
18668 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
18669 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
18670 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
18671 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
18672 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
18673 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
18674 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
18675 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
18676 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
18677 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
18678 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
18680 /* "neighbor route-map" commands. */
18681 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
18682 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
18683 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
18684 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
18685 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
18686 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
18687 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
18688 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
18689 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
18690 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
18691 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
18692 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
18693 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
18694 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
18695 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
18696 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
18697 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
18698 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
18699 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
18700 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
18701 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
18702 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
18703 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
18704 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
18706 /* "neighbor unsuppress-map" commands. */
18707 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
18708 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
18709 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
18710 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18711 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
18712 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18713 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
18714 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18715 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
18716 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18717 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
18718 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18719 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
18720 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18721 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
18722 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18723 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
18724 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18726 /* "neighbor advertise-map" commands. */
18727 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
18728 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
18729 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
18730 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
18731 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
18732 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
18733 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
18734 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
18735 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
18737 /* neighbor maximum-prefix-out commands. */
18738 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
18739 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18740 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18741 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18742 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18743 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18744 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18745 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18746 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18747 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18748 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18749 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18750 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18751 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18752 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18753 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18754 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18755 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18757 /* "neighbor maximum-prefix" commands. */
18758 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
18759 install_element(BGP_NODE
,
18760 &neighbor_maximum_prefix_threshold_hidden_cmd
);
18761 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
18762 install_element(BGP_NODE
,
18763 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
18764 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
18765 install_element(BGP_NODE
,
18766 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
18767 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
18768 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
18769 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18770 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18771 install_element(BGP_IPV4_NODE
,
18772 &neighbor_maximum_prefix_threshold_warning_cmd
);
18773 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18774 install_element(BGP_IPV4_NODE
,
18775 &neighbor_maximum_prefix_threshold_restart_cmd
);
18776 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18777 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
18778 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18779 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18780 install_element(BGP_IPV4M_NODE
,
18781 &neighbor_maximum_prefix_threshold_warning_cmd
);
18782 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18783 install_element(BGP_IPV4M_NODE
,
18784 &neighbor_maximum_prefix_threshold_restart_cmd
);
18785 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18786 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
18787 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18788 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18789 install_element(BGP_IPV4L_NODE
,
18790 &neighbor_maximum_prefix_threshold_warning_cmd
);
18791 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18792 install_element(BGP_IPV4L_NODE
,
18793 &neighbor_maximum_prefix_threshold_restart_cmd
);
18794 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18795 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
18796 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18797 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18798 install_element(BGP_IPV6_NODE
,
18799 &neighbor_maximum_prefix_threshold_warning_cmd
);
18800 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18801 install_element(BGP_IPV6_NODE
,
18802 &neighbor_maximum_prefix_threshold_restart_cmd
);
18803 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18804 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
18805 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18806 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18807 install_element(BGP_IPV6M_NODE
,
18808 &neighbor_maximum_prefix_threshold_warning_cmd
);
18809 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18810 install_element(BGP_IPV6M_NODE
,
18811 &neighbor_maximum_prefix_threshold_restart_cmd
);
18812 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18813 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
18814 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18815 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18816 install_element(BGP_IPV6L_NODE
,
18817 &neighbor_maximum_prefix_threshold_warning_cmd
);
18818 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18819 install_element(BGP_IPV6L_NODE
,
18820 &neighbor_maximum_prefix_threshold_restart_cmd
);
18821 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18822 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
18823 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18824 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18825 install_element(BGP_VPNV4_NODE
,
18826 &neighbor_maximum_prefix_threshold_warning_cmd
);
18827 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18828 install_element(BGP_VPNV4_NODE
,
18829 &neighbor_maximum_prefix_threshold_restart_cmd
);
18830 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18831 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
18832 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18833 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18834 install_element(BGP_VPNV6_NODE
,
18835 &neighbor_maximum_prefix_threshold_warning_cmd
);
18836 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18837 install_element(BGP_VPNV6_NODE
,
18838 &neighbor_maximum_prefix_threshold_restart_cmd
);
18839 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18841 /* "neighbor allowas-in" */
18842 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
18843 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
18844 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
18845 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
18846 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
18847 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
18848 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
18849 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
18850 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
18851 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
18852 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
18853 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
18854 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
18855 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
18856 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
18857 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
18858 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
18859 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
18860 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
18861 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
18863 /* "neighbor dampening" commands. */
18864 install_element(BGP_NODE
, &neighbor_damp_cmd
);
18865 install_element(BGP_NODE
, &no_neighbor_damp_cmd
);
18866 install_element(BGP_IPV4_NODE
, &neighbor_damp_cmd
);
18867 install_element(BGP_IPV4_NODE
, &no_neighbor_damp_cmd
);
18868 install_element(BGP_IPV4M_NODE
, &neighbor_damp_cmd
);
18869 install_element(BGP_IPV4M_NODE
, &no_neighbor_damp_cmd
);
18870 install_element(BGP_IPV4L_NODE
, &neighbor_damp_cmd
);
18871 install_element(BGP_IPV4L_NODE
, &no_neighbor_damp_cmd
);
18872 install_element(BGP_IPV6_NODE
, &neighbor_damp_cmd
);
18873 install_element(BGP_IPV6_NODE
, &no_neighbor_damp_cmd
);
18874 install_element(BGP_IPV6M_NODE
, &neighbor_damp_cmd
);
18875 install_element(BGP_IPV6M_NODE
, &no_neighbor_damp_cmd
);
18876 install_element(BGP_IPV6L_NODE
, &neighbor_damp_cmd
);
18877 install_element(BGP_IPV6L_NODE
, &no_neighbor_damp_cmd
);
18878 install_element(VIEW_NODE
, &show_ip_bgp_neighbor_damp_param_cmd
);
18880 /* address-family commands. */
18881 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
18882 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
18883 #ifdef KEEP_OLD_VPN_COMMANDS
18884 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
18885 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
18886 #endif /* KEEP_OLD_VPN_COMMANDS */
18888 install_element(BGP_NODE
, &address_family_evpn_cmd
);
18890 /* "exit-address-family" command. */
18891 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
18892 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
18893 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
18894 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
18895 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
18896 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
18897 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
18898 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
18899 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
18900 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
18901 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
18903 /* "clear ip bgp commands" */
18904 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
18906 /* clear ip bgp prefix */
18907 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
18908 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
18909 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
18911 /* "show [ip] bgp summary" commands. */
18912 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
18913 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
18914 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
18915 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
18916 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
18917 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
18918 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
18920 /* "show [ip] bgp neighbors" commands. */
18921 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
18923 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
18925 /* "show [ip] bgp peer-group" commands. */
18926 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
18928 /* "show [ip] bgp paths" commands. */
18929 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
18931 /* "show [ip] bgp community" commands. */
18932 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
18934 /* "show ip bgp large-community" commands. */
18935 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
18936 /* "show [ip] bgp attribute-info" commands. */
18937 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
18938 /* "show [ip] bgp route-leak" command */
18939 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
18941 /* "redistribute" commands. */
18942 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
18943 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
18944 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
18945 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
18946 install_element(BGP_NODE
,
18947 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
18948 install_element(BGP_NODE
,
18949 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
18950 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
18951 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
18952 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
18953 install_element(BGP_NODE
,
18954 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
18955 install_element(BGP_NODE
,
18956 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
18957 install_element(BGP_NODE
,
18958 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
18959 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
18960 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
18961 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
18962 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
18963 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
18964 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
18965 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
18966 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
18967 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
18968 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
18969 install_element(BGP_IPV4_NODE
,
18970 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
18971 install_element(BGP_IPV4_NODE
,
18972 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
18973 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
18974 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
18975 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
18976 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
18977 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
18978 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
18980 /* import|export vpn [route-map WORD] */
18981 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
18982 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
18984 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
18985 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
18987 /* ttl_security commands */
18988 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
18989 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
18991 /* "show [ip] bgp memory" commands. */
18992 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
18994 /* "show bgp martian next-hop" */
18995 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
18997 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
18999 /* "show [ip] bgp views" commands. */
19000 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
19002 /* "show [ip] bgp vrfs" commands. */
19003 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
19005 /* Community-list. */
19006 community_list_vty();
19008 /* vpn-policy commands */
19009 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
19010 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
19011 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
19012 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
19013 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
19014 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
19015 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
19016 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
19017 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
19018 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
19019 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
19020 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
19022 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
19023 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
19025 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
19026 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
19027 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
19028 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
19029 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
19030 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
19031 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19032 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19033 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
19034 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
19037 #include "memory.h"
19038 #include "bgp_regex.h"
19039 #include "bgp_clist.h"
19040 #include "bgp_ecommunity.h"
19042 /* VTY functions. */
19044 /* Direction value to string conversion. */
19045 static const char *community_direct_str(int direct
)
19048 case COMMUNITY_DENY
:
19050 case COMMUNITY_PERMIT
:
19057 /* Display error string. */
19058 static void community_list_perror(struct vty
*vty
, int ret
)
19061 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
19062 vty_out(vty
, "%% Can't find community-list\n");
19064 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
19065 vty_out(vty
, "%% Malformed community-list value\n");
19067 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
19069 "%% Community name conflict, previously defined as standard community\n");
19071 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
19073 "%% Community name conflict, previously defined as expanded community\n");
19078 /* "community-list" keyword help string. */
19079 #define COMMUNITY_LIST_STR "Add a community list entry\n"
19081 /*community-list standard */
19082 DEFUN (community_list_standard
,
19083 bgp_community_list_standard_cmd
,
19084 "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19087 "Community list number (standard)\n"
19088 "Add an standard community-list entry\n"
19089 "Community list name\n"
19090 "Sequence number of an entry\n"
19091 "Sequence number\n"
19092 "Specify community to reject\n"
19093 "Specify community to accept\n"
19096 char *cl_name_or_number
= NULL
;
19099 int style
= COMMUNITY_LIST_STANDARD
;
19102 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
19104 seq
= argv
[idx
]->arg
;
19107 argv_find(argv
, argc
, "(1-99)", &idx
);
19108 argv_find(argv
, argc
, "WORD", &idx
);
19109 cl_name_or_number
= argv
[idx
]->arg
;
19110 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19112 argv_find(argv
, argc
, "AA:NN", &idx
);
19113 char *str
= argv_concat(argv
, argc
, idx
);
19115 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19118 XFREE(MTYPE_TMP
, str
);
19121 /* Display error string. */
19122 community_list_perror(vty
, ret
);
19123 return CMD_WARNING_CONFIG_FAILED
;
19126 return CMD_SUCCESS
;
19129 DEFUN (no_community_list_standard_all
,
19130 no_bgp_community_list_standard_all_cmd
,
19131 "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19135 "Community list number (standard)\n"
19136 "Add an standard community-list entry\n"
19137 "Community list name\n"
19138 "Sequence number of an entry\n"
19139 "Sequence number\n"
19140 "Specify community to reject\n"
19141 "Specify community to accept\n"
19144 char *cl_name_or_number
= NULL
;
19147 int style
= COMMUNITY_LIST_STANDARD
;
19151 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
19153 seq
= argv
[idx
]->arg
;
19156 argv_find(argv
, argc
, "permit", &idx
);
19157 argv_find(argv
, argc
, "deny", &idx
);
19160 direct
= argv_find(argv
, argc
, "permit", &idx
)
19165 argv_find(argv
, argc
, "AA:NN", &idx
);
19166 str
= argv_concat(argv
, argc
, idx
);
19170 argv_find(argv
, argc
, "(1-99)", &idx
);
19171 argv_find(argv
, argc
, "WORD", &idx
);
19172 cl_name_or_number
= argv
[idx
]->arg
;
19174 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19177 XFREE(MTYPE_TMP
, str
);
19180 community_list_perror(vty
, ret
);
19181 return CMD_WARNING_CONFIG_FAILED
;
19184 return CMD_SUCCESS
;
19187 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
19188 "no bgp community-list <(1-99)|standard WORD>",
19189 NO_STR BGP_STR COMMUNITY_LIST_STR
19190 "Community list number (standard)\n"
19191 "Add an standard community-list entry\n"
19192 "Community list name\n")
19194 /*community-list expanded */
19195 DEFUN (community_list_expanded_all
,
19196 bgp_community_list_expanded_all_cmd
,
19197 "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19200 "Community list number (expanded)\n"
19201 "Add an expanded community-list entry\n"
19202 "Community list name\n"
19203 "Sequence number of an entry\n"
19204 "Sequence number\n"
19205 "Specify community to reject\n"
19206 "Specify community to accept\n"
19209 char *cl_name_or_number
= NULL
;
19212 int style
= COMMUNITY_LIST_EXPANDED
;
19215 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
19217 seq
= argv
[idx
]->arg
;
19221 argv_find(argv
, argc
, "(100-500)", &idx
);
19222 argv_find(argv
, argc
, "WORD", &idx
);
19223 cl_name_or_number
= argv
[idx
]->arg
;
19224 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19226 argv_find(argv
, argc
, "AA:NN", &idx
);
19227 char *str
= argv_concat(argv
, argc
, idx
);
19229 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19232 XFREE(MTYPE_TMP
, str
);
19235 /* Display error string. */
19236 community_list_perror(vty
, ret
);
19237 return CMD_WARNING_CONFIG_FAILED
;
19240 return CMD_SUCCESS
;
19243 DEFUN (no_community_list_expanded_all
,
19244 no_bgp_community_list_expanded_all_cmd
,
19245 "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19249 "Community list number (expanded)\n"
19250 "Add an expanded community-list entry\n"
19251 "Community list name\n"
19252 "Sequence number of an entry\n"
19253 "Sequence number\n"
19254 "Specify community to reject\n"
19255 "Specify community to accept\n"
19258 char *cl_name_or_number
= NULL
;
19262 int style
= COMMUNITY_LIST_EXPANDED
;
19265 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
19267 seq
= argv
[idx
]->arg
;
19270 argv_find(argv
, argc
, "permit", &idx
);
19271 argv_find(argv
, argc
, "deny", &idx
);
19274 direct
= argv_find(argv
, argc
, "permit", &idx
)
19279 argv_find(argv
, argc
, "AA:NN", &idx
);
19280 str
= argv_concat(argv
, argc
, idx
);
19284 argv_find(argv
, argc
, "(100-500)", &idx
);
19285 argv_find(argv
, argc
, "WORD", &idx
);
19286 cl_name_or_number
= argv
[idx
]->arg
;
19288 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19291 XFREE(MTYPE_TMP
, str
);
19294 community_list_perror(vty
, ret
);
19295 return CMD_WARNING_CONFIG_FAILED
;
19298 return CMD_SUCCESS
;
19301 ALIAS(no_community_list_expanded_all
,
19302 no_bgp_community_list_expanded_all_list_cmd
,
19303 "no bgp community-list <(100-500)|expanded WORD>",
19304 NO_STR BGP_STR COMMUNITY_LIST_STR
19305 "Community list number (expanded)\n"
19306 "Add an expanded community-list entry\n"
19307 "Community list name\n")
19309 /* Return configuration string of community-list entry. */
19310 static const char *community_list_config_str(struct community_entry
*entry
)
19317 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
19318 str
= community_str(entry
->u
.com
, false);
19319 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
19320 str
= lcommunity_str(entry
->u
.lcom
, false);
19322 str
= entry
->config
;
19327 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
19329 struct community_entry
*entry
;
19331 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19332 if (entry
== list
->head
) {
19333 if (all_digit(list
->name
))
19334 vty_out(vty
, "Community %s list %s\n",
19335 entry
->style
== COMMUNITY_LIST_STANDARD
19337 : "(expanded) access",
19340 vty_out(vty
, "Named Community %s list %s\n",
19341 entry
->style
== COMMUNITY_LIST_STANDARD
19347 vty_out(vty
, " %s\n",
19348 community_direct_str(entry
->direct
));
19350 vty_out(vty
, " %s %s\n",
19351 community_direct_str(entry
->direct
),
19352 community_list_config_str(entry
));
19356 DEFUN (show_community_list
,
19357 show_bgp_community_list_cmd
,
19358 "show bgp community-list",
19361 "List community-list\n")
19363 struct community_list
*list
;
19364 struct community_list_master
*cm
;
19366 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19368 return CMD_SUCCESS
;
19370 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19371 community_list_show(vty
, list
);
19373 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19374 community_list_show(vty
, list
);
19376 return CMD_SUCCESS
;
19379 DEFUN (show_community_list_arg
,
19380 show_bgp_community_list_arg_cmd
,
19381 "show bgp community-list <(1-500)|WORD> detail",
19384 "List community-list\n"
19385 "Community-list number\n"
19386 "Community-list name\n"
19387 "Detailed information on community-list\n")
19389 int idx_comm_list
= 3;
19390 struct community_list
*list
;
19392 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
19393 COMMUNITY_LIST_MASTER
);
19395 vty_out(vty
, "%% Can't find community-list\n");
19396 return CMD_WARNING
;
19399 community_list_show(vty
, list
);
19401 return CMD_SUCCESS
;
19405 * Large Community code.
19407 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
19408 struct cmd_token
**argv
, int style
,
19409 int reject_all_digit_name
)
19418 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19419 seq
= argv
[idx
]->arg
;
19422 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19425 /* All digit name check. */
19427 argv_find(argv
, argc
, "WORD", &idx
);
19428 argv_find(argv
, argc
, "(1-99)", &idx
);
19429 argv_find(argv
, argc
, "(100-500)", &idx
);
19430 cl_name
= argv
[idx
]->arg
;
19431 if (reject_all_digit_name
&& all_digit(cl_name
)) {
19432 vty_out(vty
, "%% Community name cannot have all digits\n");
19433 return CMD_WARNING_CONFIG_FAILED
;
19437 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
19438 argv_find(argv
, argc
, "LINE", &idx
);
19439 /* Concat community string argument. */
19441 str
= argv_concat(argv
, argc
, idx
);
19445 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
19447 /* Free temporary community list string allocated by
19449 XFREE(MTYPE_TMP
, str
);
19452 community_list_perror(vty
, ret
);
19453 return CMD_WARNING_CONFIG_FAILED
;
19455 return CMD_SUCCESS
;
19458 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
19459 struct cmd_token
**argv
, int style
)
19467 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19468 seq
= argv
[idx
]->arg
;
19471 argv_find(argv
, argc
, "permit", &idx
);
19472 argv_find(argv
, argc
, "deny", &idx
);
19475 /* Check the list direct. */
19476 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
19477 direct
= COMMUNITY_PERMIT
;
19479 direct
= COMMUNITY_DENY
;
19482 argv_find(argv
, argc
, "LINE", &idx
);
19483 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
19484 /* Concat community string argument. */
19485 str
= argv_concat(argv
, argc
, idx
);
19489 argv_find(argv
, argc
, "(1-99)", &idx
);
19490 argv_find(argv
, argc
, "(100-500)", &idx
);
19491 argv_find(argv
, argc
, "WORD", &idx
);
19493 /* Unset community list. */
19494 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
19497 /* Free temporary community list string allocated by
19499 XFREE(MTYPE_TMP
, str
);
19502 community_list_perror(vty
, ret
);
19503 return CMD_WARNING_CONFIG_FAILED
;
19506 return CMD_SUCCESS
;
19509 /* "large-community-list" keyword help string. */
19510 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
19511 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
19513 DEFUN (lcommunity_list_standard
,
19514 bgp_lcommunity_list_standard_cmd
,
19515 "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...",
19517 LCOMMUNITY_LIST_STR
19518 "Large Community list number (standard)\n"
19519 "Sequence number of an entry\n"
19520 "Sequence number\n"
19521 "Specify large community to reject\n"
19522 "Specify large community to accept\n"
19523 LCOMMUNITY_VAL_STR
)
19525 return lcommunity_list_set_vty(vty
, argc
, argv
,
19526 LARGE_COMMUNITY_LIST_STANDARD
, 0);
19529 DEFUN (lcommunity_list_expanded
,
19530 bgp_lcommunity_list_expanded_cmd
,
19531 "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...",
19533 LCOMMUNITY_LIST_STR
19534 "Large Community list number (expanded)\n"
19535 "Sequence number of an entry\n"
19536 "Sequence number\n"
19537 "Specify large community to reject\n"
19538 "Specify large community to accept\n"
19539 "An ordered list as a regular-expression\n")
19541 return lcommunity_list_set_vty(vty
, argc
, argv
,
19542 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
19545 DEFUN (lcommunity_list_name_standard
,
19546 bgp_lcommunity_list_name_standard_cmd
,
19547 "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...",
19549 LCOMMUNITY_LIST_STR
19550 "Specify standard large-community-list\n"
19551 "Large Community list name\n"
19552 "Sequence number of an entry\n"
19553 "Sequence number\n"
19554 "Specify large community to reject\n"
19555 "Specify large community to accept\n"
19556 LCOMMUNITY_VAL_STR
)
19558 return lcommunity_list_set_vty(vty
, argc
, argv
,
19559 LARGE_COMMUNITY_LIST_STANDARD
, 1);
19562 DEFUN (lcommunity_list_name_expanded
,
19563 bgp_lcommunity_list_name_expanded_cmd
,
19564 "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...",
19566 LCOMMUNITY_LIST_STR
19567 "Specify expanded large-community-list\n"
19568 "Large Community list name\n"
19569 "Sequence number of an entry\n"
19570 "Sequence number\n"
19571 "Specify large community to reject\n"
19572 "Specify large community to accept\n"
19573 "An ordered list as a regular-expression\n")
19575 return lcommunity_list_set_vty(vty
, argc
, argv
,
19576 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
19579 DEFUN (no_lcommunity_list_all
,
19580 no_bgp_lcommunity_list_all_cmd
,
19581 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
19584 LCOMMUNITY_LIST_STR
19585 "Large Community list number (standard)\n"
19586 "Large Community list number (expanded)\n"
19587 "Large Community list name\n")
19589 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19590 LARGE_COMMUNITY_LIST_STANDARD
);
19593 DEFUN (no_lcommunity_list_name_standard_all
,
19594 no_bgp_lcommunity_list_name_standard_all_cmd
,
19595 "no bgp large-community-list standard WORD",
19598 LCOMMUNITY_LIST_STR
19599 "Specify standard large-community-list\n"
19600 "Large Community list name\n")
19602 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19603 LARGE_COMMUNITY_LIST_STANDARD
);
19606 DEFUN (no_lcommunity_list_name_expanded_all
,
19607 no_bgp_lcommunity_list_name_expanded_all_cmd
,
19608 "no bgp large-community-list expanded WORD",
19611 LCOMMUNITY_LIST_STR
19612 "Specify expanded large-community-list\n"
19613 "Large Community list name\n")
19615 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19616 LARGE_COMMUNITY_LIST_EXPANDED
);
19619 DEFUN (no_lcommunity_list_standard
,
19620 no_bgp_lcommunity_list_standard_cmd
,
19621 "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...",
19624 LCOMMUNITY_LIST_STR
19625 "Large Community list number (standard)\n"
19626 "Sequence number of an entry\n"
19627 "Sequence number\n"
19628 "Specify large community to reject\n"
19629 "Specify large community to accept\n"
19630 LCOMMUNITY_VAL_STR
)
19632 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19633 LARGE_COMMUNITY_LIST_STANDARD
);
19636 DEFUN (no_lcommunity_list_expanded
,
19637 no_bgp_lcommunity_list_expanded_cmd
,
19638 "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...",
19641 LCOMMUNITY_LIST_STR
19642 "Large Community list number (expanded)\n"
19643 "Sequence number of an entry\n"
19644 "Sequence number\n"
19645 "Specify large community to reject\n"
19646 "Specify large community to accept\n"
19647 "An ordered list as a regular-expression\n")
19649 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19650 LARGE_COMMUNITY_LIST_EXPANDED
);
19653 DEFUN (no_lcommunity_list_name_standard
,
19654 no_bgp_lcommunity_list_name_standard_cmd
,
19655 "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...",
19658 LCOMMUNITY_LIST_STR
19659 "Specify standard large-community-list\n"
19660 "Large Community list name\n"
19661 "Sequence number of an entry\n"
19662 "Sequence number\n"
19663 "Specify large community to reject\n"
19664 "Specify large community to accept\n"
19665 LCOMMUNITY_VAL_STR
)
19667 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19668 LARGE_COMMUNITY_LIST_STANDARD
);
19671 DEFUN (no_lcommunity_list_name_expanded
,
19672 no_bgp_lcommunity_list_name_expanded_cmd
,
19673 "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...",
19676 LCOMMUNITY_LIST_STR
19677 "Specify expanded large-community-list\n"
19678 "Large community list name\n"
19679 "Sequence number of an entry\n"
19680 "Sequence number\n"
19681 "Specify large community to reject\n"
19682 "Specify large community to accept\n"
19683 "An ordered list as a regular-expression\n")
19685 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19686 LARGE_COMMUNITY_LIST_EXPANDED
);
19689 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
19691 struct community_entry
*entry
;
19693 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19694 if (entry
== list
->head
) {
19695 if (all_digit(list
->name
))
19696 vty_out(vty
, "Large community %s list %s\n",
19698 LARGE_COMMUNITY_LIST_STANDARD
19700 : "(expanded) access",
19704 "Named large community %s list %s\n",
19706 LARGE_COMMUNITY_LIST_STANDARD
19712 vty_out(vty
, " %s\n",
19713 community_direct_str(entry
->direct
));
19715 vty_out(vty
, " %s %s\n",
19716 community_direct_str(entry
->direct
),
19717 community_list_config_str(entry
));
19721 DEFUN (show_lcommunity_list
,
19722 show_bgp_lcommunity_list_cmd
,
19723 "show bgp large-community-list",
19726 "List large-community list\n")
19728 struct community_list
*list
;
19729 struct community_list_master
*cm
;
19731 cm
= community_list_master_lookup(bgp_clist
,
19732 LARGE_COMMUNITY_LIST_MASTER
);
19734 return CMD_SUCCESS
;
19736 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19737 lcommunity_list_show(vty
, list
);
19739 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19740 lcommunity_list_show(vty
, list
);
19742 return CMD_SUCCESS
;
19745 DEFUN (show_lcommunity_list_arg
,
19746 show_bgp_lcommunity_list_arg_cmd
,
19747 "show bgp large-community-list <(1-500)|WORD> detail",
19750 "List large-community list\n"
19751 "Large-community-list number\n"
19752 "Large-community-list name\n"
19753 "Detailed information on large-community-list\n")
19755 struct community_list
*list
;
19757 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
19758 LARGE_COMMUNITY_LIST_MASTER
);
19760 vty_out(vty
, "%% Can't find large-community-list\n");
19761 return CMD_WARNING
;
19764 lcommunity_list_show(vty
, list
);
19766 return CMD_SUCCESS
;
19769 /* "extcommunity-list" keyword help string. */
19770 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
19771 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
19773 DEFUN (extcommunity_list_standard
,
19774 bgp_extcommunity_list_standard_cmd
,
19775 "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19777 EXTCOMMUNITY_LIST_STR
19778 "Extended Community list number (standard)\n"
19779 "Specify standard extcommunity-list\n"
19780 "Community list name\n"
19781 "Sequence number of an entry\n"
19782 "Sequence number\n"
19783 "Specify community to reject\n"
19784 "Specify community to accept\n"
19785 EXTCOMMUNITY_VAL_STR
)
19787 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19789 char *cl_number_or_name
= NULL
;
19794 argv_find(argv
, argc
, "(1-99)", &idx
);
19795 argv_find(argv
, argc
, "WORD", &idx
);
19796 cl_number_or_name
= argv
[idx
]->arg
;
19798 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19799 seq
= argv
[idx
]->arg
;
19801 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19803 argv_find(argv
, argc
, "AA:NN", &idx
);
19804 char *str
= argv_concat(argv
, argc
, idx
);
19806 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19809 XFREE(MTYPE_TMP
, str
);
19812 community_list_perror(vty
, ret
);
19813 return CMD_WARNING_CONFIG_FAILED
;
19816 return CMD_SUCCESS
;
19819 DEFUN (extcommunity_list_name_expanded
,
19820 bgp_extcommunity_list_name_expanded_cmd
,
19821 "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...",
19823 EXTCOMMUNITY_LIST_STR
19824 "Extended Community list number (expanded)\n"
19825 "Specify expanded extcommunity-list\n"
19826 "Extended Community list name\n"
19827 "Sequence number of an entry\n"
19828 "Sequence number\n"
19829 "Specify community to reject\n"
19830 "Specify community to accept\n"
19831 "An ordered list as a regular-expression\n")
19833 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
19835 char *cl_number_or_name
= NULL
;
19839 argv_find(argv
, argc
, "(100-500)", &idx
);
19840 argv_find(argv
, argc
, "WORD", &idx
);
19841 cl_number_or_name
= argv
[idx
]->arg
;
19843 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19844 seq
= argv
[idx
]->arg
;
19846 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19848 argv_find(argv
, argc
, "LINE", &idx
);
19849 char *str
= argv_concat(argv
, argc
, idx
);
19851 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19854 XFREE(MTYPE_TMP
, str
);
19857 community_list_perror(vty
, ret
);
19858 return CMD_WARNING_CONFIG_FAILED
;
19861 return CMD_SUCCESS
;
19864 DEFUN (no_extcommunity_list_standard_all
,
19865 no_bgp_extcommunity_list_standard_all_cmd
,
19866 "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19869 EXTCOMMUNITY_LIST_STR
19870 "Extended Community list number (standard)\n"
19871 "Specify standard extcommunity-list\n"
19872 "Community list name\n"
19873 "Sequence number of an entry\n"
19874 "Sequence number\n"
19875 "Specify community to reject\n"
19876 "Specify community to accept\n"
19877 EXTCOMMUNITY_VAL_STR
)
19879 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19881 char *cl_number_or_name
= NULL
;
19886 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19887 seq
= argv
[idx
]->arg
;
19890 argv_find(argv
, argc
, "permit", &idx
);
19891 argv_find(argv
, argc
, "deny", &idx
);
19893 direct
= argv_find(argv
, argc
, "permit", &idx
)
19898 argv_find(argv
, argc
, "AA:NN", &idx
);
19899 str
= argv_concat(argv
, argc
, idx
);
19903 argv_find(argv
, argc
, "(1-99)", &idx
);
19904 argv_find(argv
, argc
, "WORD", &idx
);
19905 cl_number_or_name
= argv
[idx
]->arg
;
19907 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
19908 seq
, direct
, style
);
19910 XFREE(MTYPE_TMP
, str
);
19913 community_list_perror(vty
, ret
);
19914 return CMD_WARNING_CONFIG_FAILED
;
19917 return CMD_SUCCESS
;
19920 ALIAS(no_extcommunity_list_standard_all
,
19921 no_bgp_extcommunity_list_standard_all_list_cmd
,
19922 "no bgp extcommunity-list <(1-99)|standard WORD>",
19923 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
19924 "Extended Community list number (standard)\n"
19925 "Specify standard extcommunity-list\n"
19926 "Community list name\n")
19928 DEFUN (no_extcommunity_list_expanded_all
,
19929 no_bgp_extcommunity_list_expanded_all_cmd
,
19930 "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...",
19933 EXTCOMMUNITY_LIST_STR
19934 "Extended Community list number (expanded)\n"
19935 "Specify expanded extcommunity-list\n"
19936 "Extended Community list name\n"
19937 "Sequence number of an entry\n"
19938 "Sequence number\n"
19939 "Specify community to reject\n"
19940 "Specify community to accept\n"
19941 "An ordered list as a regular-expression\n")
19943 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
19945 char *cl_number_or_name
= NULL
;
19950 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19951 seq
= argv
[idx
]->arg
;
19954 argv_find(argv
, argc
, "permit", &idx
);
19955 argv_find(argv
, argc
, "deny", &idx
);
19958 direct
= argv_find(argv
, argc
, "permit", &idx
)
19963 argv_find(argv
, argc
, "LINE", &idx
);
19964 str
= argv_concat(argv
, argc
, idx
);
19968 argv_find(argv
, argc
, "(100-500)", &idx
);
19969 argv_find(argv
, argc
, "WORD", &idx
);
19970 cl_number_or_name
= argv
[idx
]->arg
;
19972 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
19973 seq
, direct
, style
);
19975 XFREE(MTYPE_TMP
, str
);
19978 community_list_perror(vty
, ret
);
19979 return CMD_WARNING_CONFIG_FAILED
;
19982 return CMD_SUCCESS
;
19985 ALIAS(no_extcommunity_list_expanded_all
,
19986 no_bgp_extcommunity_list_expanded_all_list_cmd
,
19987 "no bgp extcommunity-list <(100-500)|expanded WORD>",
19988 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
19989 "Extended Community list number (expanded)\n"
19990 "Specify expanded extcommunity-list\n"
19991 "Extended Community list name\n")
19993 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
19995 struct community_entry
*entry
;
19997 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19998 if (entry
== list
->head
) {
19999 if (all_digit(list
->name
))
20000 vty_out(vty
, "Extended community %s list %s\n",
20001 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20003 : "(expanded) access",
20007 "Named extended community %s list %s\n",
20008 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20014 vty_out(vty
, " %s\n",
20015 community_direct_str(entry
->direct
));
20017 vty_out(vty
, " %s %s\n",
20018 community_direct_str(entry
->direct
),
20019 community_list_config_str(entry
));
20023 DEFUN (show_extcommunity_list
,
20024 show_bgp_extcommunity_list_cmd
,
20025 "show bgp extcommunity-list",
20028 "List extended-community list\n")
20030 struct community_list
*list
;
20031 struct community_list_master
*cm
;
20033 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20035 return CMD_SUCCESS
;
20037 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20038 extcommunity_list_show(vty
, list
);
20040 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20041 extcommunity_list_show(vty
, list
);
20043 return CMD_SUCCESS
;
20046 DEFUN (show_extcommunity_list_arg
,
20047 show_bgp_extcommunity_list_arg_cmd
,
20048 "show bgp extcommunity-list <(1-500)|WORD> detail",
20051 "List extended-community list\n"
20052 "Extcommunity-list number\n"
20053 "Extcommunity-list name\n"
20054 "Detailed information on extcommunity-list\n")
20056 int idx_comm_list
= 3;
20057 struct community_list
*list
;
20059 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20060 EXTCOMMUNITY_LIST_MASTER
);
20062 vty_out(vty
, "%% Can't find extcommunity-list\n");
20063 return CMD_WARNING
;
20066 extcommunity_list_show(vty
, list
);
20068 return CMD_SUCCESS
;
20071 /* Display community-list and extcommunity-list configuration. */
20072 static int community_list_config_write(struct vty
*vty
)
20074 struct community_list
*list
;
20075 struct community_entry
*entry
;
20076 struct community_list_master
*cm
;
20079 /* Community-list. */
20080 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20082 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20083 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20085 "bgp community-list %s seq %" PRId64
" %s %s\n",
20086 list
->name
, entry
->seq
,
20087 community_direct_str(entry
->direct
),
20088 community_list_config_str(entry
));
20091 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20092 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20094 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
20095 entry
->style
== COMMUNITY_LIST_STANDARD
20098 list
->name
, entry
->seq
,
20099 community_direct_str(entry
->direct
),
20100 community_list_config_str(entry
));
20104 /* Extcommunity-list. */
20105 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20107 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20108 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20110 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
20111 list
->name
, entry
->seq
,
20112 community_direct_str(entry
->direct
),
20113 community_list_config_str(entry
));
20116 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20117 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20119 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
20120 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20123 list
->name
, entry
->seq
,
20124 community_direct_str(entry
->direct
),
20125 community_list_config_str(entry
));
20130 /* lcommunity-list. */
20131 cm
= community_list_master_lookup(bgp_clist
,
20132 LARGE_COMMUNITY_LIST_MASTER
);
20134 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20135 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20137 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
20138 list
->name
, entry
->seq
,
20139 community_direct_str(entry
->direct
),
20140 community_list_config_str(entry
));
20143 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20144 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20146 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
20148 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
20151 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
20152 community_list_config_str(entry
));
20159 static int community_list_config_write(struct vty
*vty
);
20160 static struct cmd_node community_list_node
= {
20161 .name
= "community list",
20162 .node
= COMMUNITY_LIST_NODE
,
20164 .config_write
= community_list_config_write
,
20167 static void community_list_vty(void)
20169 install_node(&community_list_node
);
20171 /* Community-list. */
20172 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
20173 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
20174 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
20175 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
20176 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
20177 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
20178 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
20179 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
20181 /* Extcommunity-list. */
20182 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
20183 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
20184 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
20185 install_element(CONFIG_NODE
,
20186 &no_bgp_extcommunity_list_standard_all_list_cmd
);
20187 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
20188 install_element(CONFIG_NODE
,
20189 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
20190 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
20191 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
20193 /* Large Community List */
20194 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
20195 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
20196 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
20197 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
20198 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
20199 install_element(CONFIG_NODE
,
20200 &no_bgp_lcommunity_list_name_standard_all_cmd
);
20201 install_element(CONFIG_NODE
,
20202 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
20203 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
20204 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
20205 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
20206 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
20207 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
20208 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);