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 (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")
4963 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4970 struct peer_group
*group
;
4972 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4974 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4976 vty_out(vty
, "%% Malformed address or name: %s\n",
4977 argv
[idx_peer
]->arg
);
4978 return CMD_WARNING_CONFIG_FAILED
;
4981 if (peer_address_self_check(bgp
, &su
)) {
4983 "%% Can not configure the local system as neighbor\n");
4984 return CMD_WARNING_CONFIG_FAILED
;
4987 /* Disallow for dynamic neighbor. */
4988 peer
= peer_lookup(bgp
, &su
);
4989 if (peer
&& peer_dynamic_neighbor(peer
)) {
4991 "%% Operation not allowed on a dynamic neighbor\n");
4992 return CMD_WARNING_CONFIG_FAILED
;
4996 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4998 vty_out(vty
, "%% Configure the peer-group first\n");
4999 return CMD_WARNING_CONFIG_FAILED
;
5002 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5004 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
5006 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
5008 return CMD_WARNING_CONFIG_FAILED
;
5011 return bgp_vty_return(vty
, ret
);
5014 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5015 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5016 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5017 "Member of the peer-group\n"
5018 "Peer-group name\n")
5020 DEFUN_YANG (no_neighbor_set_peer_group
,
5021 no_neighbor_set_peer_group_cmd
,
5022 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5026 "Member of the peer-group\n"
5027 "Peer-group name\n")
5030 char base_xpath
[XPATH_MAXLEN
];
5032 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5033 sizeof(base_xpath
), NULL
)
5035 return CMD_WARNING_CONFIG_FAILED
;
5037 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_DESTROY
, NULL
);
5039 return nb_cli_apply_changes(vty
, base_xpath
);
5042 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5043 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5044 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5045 "Member of the peer-group\n"
5046 "Peer-group name\n")
5048 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
5049 uint32_t flag
, int set
)
5054 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5056 return CMD_WARNING_CONFIG_FAILED
;
5059 * If 'neighbor <interface>', then this is for directly connected peers,
5060 * we should not accept disable-connected-check.
5062 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5064 "%s is directly connected peer, cannot accept disable-connected-check\n",
5066 return CMD_WARNING_CONFIG_FAILED
;
5069 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5070 peer_tx_shutdown_message_unset(peer
);
5073 ret
= peer_flag_set(peer
, flag
);
5075 ret
= peer_flag_unset(peer
, flag
);
5077 return bgp_vty_return(vty
, ret
);
5080 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
5082 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
5085 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
5088 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
5091 int peer_flag_modify_nb(struct bgp
*bgp
, const char *ip_str
, struct peer
*peer
,
5092 uint32_t flag
, bool set
, char *errmsg
,
5098 * If 'neighbor <interface>', then this is for directly connected peers,
5099 * we should not accept disable-connected-check.
5101 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5104 "%s is directly connected peer, cannot accept disable-connected-check\n",
5109 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5110 peer_tx_shutdown_message_unset(peer
);
5113 ret
= peer_flag_set(peer
, flag
);
5115 ret
= peer_flag_unset(peer
, flag
);
5117 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
5120 /* neighbor passive. */
5121 DEFUN_YANG(neighbor_passive
,
5122 neighbor_passive_cmd
,
5123 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5126 "Don't send open messages to this neighbor\n")
5129 char base_xpath
[XPATH_MAXLEN
];
5131 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5132 sizeof(base_xpath
), NULL
)
5134 return CMD_WARNING_CONFIG_FAILED
;
5136 nb_cli_enqueue_change(vty
, "./passive-mode", NB_OP_MODIFY
, "true");
5138 return nb_cli_apply_changes(vty
, base_xpath
);
5141 DEFUN_YANG(no_neighbor_passive
,
5142 no_neighbor_passive_cmd
,
5143 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5146 "Don't send open messages to this neighbor\n")
5149 char base_xpath
[XPATH_MAXLEN
];
5151 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5152 sizeof(base_xpath
), NULL
)
5154 return CMD_WARNING_CONFIG_FAILED
;
5156 nb_cli_enqueue_change(vty
, "./passive-mode", NB_OP_MODIFY
, "false");
5158 return nb_cli_apply_changes(vty
, base_xpath
);
5161 /* neighbor shutdown. */
5162 DEFUN_YANG(neighbor_shutdown_msg
,
5163 neighbor_shutdown_msg_cmd
,
5164 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5165 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5166 "Administratively shut down this neighbor\n"
5167 "Add 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
;
5181 message
= argv_concat(argv
, argc
, 4);
5182 nb_cli_enqueue_change(vty
, "./admin-shutdown/message",
5183 NB_OP_MODIFY
, message
);
5186 nb_cli_enqueue_change(vty
, "./admin-shutdown/enable", NB_OP_MODIFY
,
5189 return nb_cli_apply_changes(vty
, base_xpath
);
5192 ALIAS_YANG(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5193 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5194 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5195 "Administratively shut down this neighbor\n")
5197 DEFUN_YANG(no_neighbor_shutdown_msg
,
5198 no_neighbor_shutdown_msg_cmd
,
5199 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5202 "Administratively shut down this neighbor\n"
5203 "Remove a shutdown message (RFC 8203)\n"
5204 "Shutdown message\n")
5207 char base_xpath
[XPATH_MAXLEN
];
5209 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5210 sizeof(base_xpath
), NULL
)
5212 return CMD_WARNING_CONFIG_FAILED
;
5214 nb_cli_enqueue_change(vty
, "./admin-shutdown/enable", NB_OP_MODIFY
,
5217 return nb_cli_apply_changes(vty
, base_xpath
);
5220 ALIAS_YANG(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5221 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5222 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5223 "Administratively shut down this neighbor\n")
5225 DEFUN(neighbor_shutdown_rtt
,
5226 neighbor_shutdown_rtt_cmd
,
5227 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5230 "Administratively shut down this neighbor\n"
5231 "Shutdown if round-trip-time is higher than expected\n"
5232 "Round-trip-time in milliseconds\n"
5233 "Specify the number of keepalives before shutdown\n"
5234 "The number of keepalives with higher RTT to shutdown\n")
5241 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5244 return CMD_WARNING_CONFIG_FAILED
;
5246 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5248 if (argv_find(argv
, argc
, "count", &idx_count
))
5249 peer
->rtt_keepalive_conf
=
5250 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5252 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5253 PEER_FLAG_RTT_SHUTDOWN
);
5256 DEFUN(no_neighbor_shutdown_rtt
,
5257 no_neighbor_shutdown_rtt_cmd
,
5258 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5262 "Administratively shut down this neighbor\n"
5263 "Shutdown if round-trip-time is higher than expected\n"
5264 "Round-trip-time in milliseconds\n"
5265 "Specify the number of keepalives before shutdown\n"
5266 "The number of keepalives with higher RTT to shutdown\n")
5271 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5274 return CMD_WARNING_CONFIG_FAILED
;
5276 peer
->rtt_expected
= 0;
5277 peer
->rtt_keepalive_conf
= 1;
5279 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5280 PEER_FLAG_RTT_SHUTDOWN
);
5283 /* neighbor capability dynamic. */
5284 DEFUN_YANG (neighbor_capability_dynamic
,
5285 neighbor_capability_dynamic_cmd
,
5286 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5289 "Advertise capability to the peer\n"
5290 "Advertise dynamic capability to this neighbor\n")
5293 char base_xpath
[XPATH_MAXLEN
];
5295 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5296 sizeof(base_xpath
), NULL
)
5298 return CMD_WARNING_CONFIG_FAILED
;
5300 nb_cli_enqueue_change(vty
, "./capability-options/dynamic-capability",
5301 NB_OP_MODIFY
, "true");
5303 return nb_cli_apply_changes(vty
, base_xpath
);
5306 DEFUN_YANG (no_neighbor_capability_dynamic
,
5307 no_neighbor_capability_dynamic_cmd
,
5308 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5312 "Advertise capability to the peer\n"
5313 "Advertise dynamic capability to this neighbor\n")
5316 char base_xpath
[XPATH_MAXLEN
];
5318 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5319 sizeof(base_xpath
), NULL
)
5321 return CMD_WARNING_CONFIG_FAILED
;
5323 nb_cli_enqueue_change(vty
, "./capability-options/dynamic-capability",
5324 NB_OP_MODIFY
, "false");
5326 return nb_cli_apply_changes(vty
, base_xpath
);
5329 /* neighbor dont-capability-negotiate */
5330 DEFUN (neighbor_dont_capability_negotiate
,
5331 neighbor_dont_capability_negotiate_cmd
,
5332 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5335 "Do not perform capability negotiation\n")
5338 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5339 PEER_FLAG_DONT_CAPABILITY
);
5342 DEFUN (no_neighbor_dont_capability_negotiate
,
5343 no_neighbor_dont_capability_negotiate_cmd
,
5344 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5348 "Do not perform capability negotiation\n")
5351 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5352 PEER_FLAG_DONT_CAPABILITY
);
5355 /* neighbor capability extended next hop encoding */
5356 DEFUN_YANG (neighbor_capability_enhe
,
5357 neighbor_capability_enhe_cmd
,
5358 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5361 "Advertise capability to the peer\n"
5362 "Advertise extended next-hop capability to the peer\n")
5365 char base_xpath
[XPATH_MAXLEN
];
5367 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5368 sizeof(base_xpath
), NULL
)
5370 return CMD_WARNING_CONFIG_FAILED
;
5372 nb_cli_enqueue_change(
5373 vty
, "./capability-options/extended-nexthop-capability",
5374 NB_OP_MODIFY
, "true");
5376 return nb_cli_apply_changes(vty
, base_xpath
);
5379 DEFUN_YANG (no_neighbor_capability_enhe
,
5380 no_neighbor_capability_enhe_cmd
,
5381 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5385 "Advertise capability to the peer\n"
5386 "Advertise extended next-hop capability to the peer\n")
5389 char base_xpath
[XPATH_MAXLEN
];
5391 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5392 sizeof(base_xpath
), NULL
)
5394 return CMD_WARNING_CONFIG_FAILED
;
5396 nb_cli_enqueue_change(
5397 vty
, "./capability-options/extended-nexthop-capability",
5398 NB_OP_MODIFY
, "false");
5400 return nb_cli_apply_changes(vty
, base_xpath
);
5403 int peer_af_flag_modify_nb(struct peer
*peer
, afi_t afi
, safi_t safi
,
5404 uint32_t flag
, int set
, char *errmsg
,
5410 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5412 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5414 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
5417 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5418 afi_t afi
, safi_t safi
, uint32_t flag
,
5424 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5426 return CMD_WARNING_CONFIG_FAILED
;
5429 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5431 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5433 return bgp_vty_return(vty
, ret
);
5436 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5437 afi_t afi
, safi_t safi
, uint32_t flag
)
5439 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5442 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5443 afi_t afi
, safi_t safi
, uint32_t flag
)
5445 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5448 /* neighbor capability orf prefix-list. */
5449 DEFUN (neighbor_capability_orf_prefix
,
5450 neighbor_capability_orf_prefix_cmd
,
5451 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5454 "Advertise capability to the peer\n"
5455 "Advertise ORF capability to the peer\n"
5456 "Advertise prefixlist ORF capability to this neighbor\n"
5457 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5458 "Capability to RECEIVE the ORF from this neighbor\n"
5459 "Capability to SEND the ORF to this neighbor\n")
5461 int idx_send_recv
= 5;
5462 char *peer_str
= argv
[1]->arg
;
5464 afi_t afi
= bgp_node_afi(vty
);
5465 safi_t safi
= bgp_node_safi(vty
);
5467 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5469 return CMD_WARNING_CONFIG_FAILED
;
5471 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5472 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5473 PEER_FLAG_ORF_PREFIX_SM
);
5475 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5476 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5477 PEER_FLAG_ORF_PREFIX_RM
);
5479 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5480 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5481 PEER_FLAG_ORF_PREFIX_SM
)
5482 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5483 PEER_FLAG_ORF_PREFIX_RM
);
5485 return CMD_WARNING_CONFIG_FAILED
;
5489 neighbor_capability_orf_prefix
,
5490 neighbor_capability_orf_prefix_hidden_cmd
,
5491 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5492 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5493 "Advertise capability to the peer\n"
5494 "Advertise ORF capability to the peer\n"
5495 "Advertise prefixlist ORF capability to this neighbor\n"
5496 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5497 "Capability to RECEIVE the ORF from this neighbor\n"
5498 "Capability to SEND the ORF to this neighbor\n")
5500 DEFUN (no_neighbor_capability_orf_prefix
,
5501 no_neighbor_capability_orf_prefix_cmd
,
5502 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5506 "Advertise capability to the peer\n"
5507 "Advertise ORF capability to the peer\n"
5508 "Advertise prefixlist ORF capability to this neighbor\n"
5509 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5510 "Capability to RECEIVE the ORF from this neighbor\n"
5511 "Capability to SEND the ORF to this neighbor\n")
5513 int idx_send_recv
= 6;
5514 char *peer_str
= argv
[2]->arg
;
5516 afi_t afi
= bgp_node_afi(vty
);
5517 safi_t safi
= bgp_node_safi(vty
);
5519 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5521 return CMD_WARNING_CONFIG_FAILED
;
5523 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5524 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5525 PEER_FLAG_ORF_PREFIX_SM
);
5527 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5528 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5529 PEER_FLAG_ORF_PREFIX_RM
);
5531 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5532 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5533 PEER_FLAG_ORF_PREFIX_SM
)
5534 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5535 PEER_FLAG_ORF_PREFIX_RM
);
5537 return CMD_WARNING_CONFIG_FAILED
;
5541 no_neighbor_capability_orf_prefix
,
5542 no_neighbor_capability_orf_prefix_hidden_cmd
,
5543 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5544 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5545 "Advertise capability to the peer\n"
5546 "Advertise ORF capability to the peer\n"
5547 "Advertise prefixlist ORF capability to this neighbor\n"
5548 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5549 "Capability to RECEIVE the ORF from this neighbor\n"
5550 "Capability to SEND the ORF to this neighbor\n")
5552 /* neighbor next-hop-self. */
5553 DEFUN_YANG (neighbor_nexthop_self
,
5554 neighbor_nexthop_self_cmd
,
5555 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5558 "Disable the next hop calculation for this neighbor\n")
5561 char base_xpath
[XPATH_MAXLEN
];
5562 char af_xpath
[XPATH_MAXLEN
];
5563 char attr_xpath
[XPATH_MAXLEN
];
5564 afi_t afi
= bgp_node_afi(vty
);
5565 safi_t safi
= bgp_node_safi(vty
);
5568 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5569 yang_afi_safi_value2identity(afi
, safi
));
5571 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5572 sizeof(base_xpath
), af_xpath
)
5574 return CMD_WARNING_CONFIG_FAILED
;
5576 snprintf(attr_xpath
, sizeof(attr_xpath
),
5577 "./%s/nexthop-self/next-hop-self",
5578 bgp_afi_safi_get_container_str(afi
, safi
));
5580 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5582 return nb_cli_apply_changes(vty
, base_xpath
);
5585 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5586 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5587 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5588 "Disable the next hop calculation for this neighbor\n")
5590 /* neighbor next-hop-self. */
5591 DEFUN_YANG(neighbor_nexthop_self_force
,
5592 neighbor_nexthop_self_force_cmd
,
5593 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5596 "Disable the next hop calculation for this neighbor\n"
5597 "Set the next hop to self for reflected routes\n")
5600 char base_xpath
[XPATH_MAXLEN
];
5601 char af_xpath
[XPATH_MAXLEN
];
5602 char attr_xpath
[XPATH_MAXLEN
];
5603 afi_t afi
= bgp_node_afi(vty
);
5604 safi_t safi
= bgp_node_safi(vty
);
5607 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5608 yang_afi_safi_value2identity(afi
, safi
));
5610 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5611 sizeof(base_xpath
), af_xpath
)
5613 return CMD_WARNING_CONFIG_FAILED
;
5615 snprintf(attr_xpath
, sizeof(attr_xpath
),
5616 "./%s/nexthop-self/next-hop-self-force",
5617 bgp_afi_safi_get_container_str(afi
, safi
));
5619 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5621 return nb_cli_apply_changes(vty
, base_xpath
);
5624 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5625 neighbor_nexthop_self_force_hidden_cmd
,
5626 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5627 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5628 "Disable the next hop calculation for this neighbor\n"
5629 "Set the next hop to self for reflected routes\n")
5631 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5632 neighbor_nexthop_self_all_hidden_cmd
,
5633 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5634 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5635 "Disable the next hop calculation for this neighbor\n"
5636 "Set the next hop to self for reflected routes\n")
5638 DEFUN_YANG (no_neighbor_nexthop_self
,
5639 no_neighbor_nexthop_self_cmd
,
5640 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5644 "Disable the next hop calculation for this neighbor\n")
5647 char base_xpath
[XPATH_MAXLEN
];
5648 char af_xpath
[XPATH_MAXLEN
];
5649 char attr_xpath
[XPATH_MAXLEN
];
5650 afi_t afi
= bgp_node_afi(vty
);
5651 safi_t safi
= bgp_node_safi(vty
);
5653 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5654 yang_afi_safi_value2identity(afi
, safi
));
5656 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5657 sizeof(base_xpath
), af_xpath
)
5659 return CMD_WARNING_CONFIG_FAILED
;
5661 snprintf(attr_xpath
, sizeof(attr_xpath
),
5662 "./%s/nexthop-self/next-hop-self",
5663 bgp_afi_safi_get_container_str(afi
, safi
));
5665 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5667 return nb_cli_apply_changes(vty
, base_xpath
);
5670 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5671 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5672 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5673 "Disable the next hop calculation for this neighbor\n")
5675 DEFUN_YANG (no_neighbor_nexthop_self_force
,
5676 no_neighbor_nexthop_self_force_cmd
,
5677 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5681 "Disable the next hop calculation for this neighbor\n"
5682 "Set the next hop to self for reflected routes\n")
5685 char base_xpath
[XPATH_MAXLEN
];
5686 char af_xpath
[XPATH_MAXLEN
];
5687 char attr_xpath
[XPATH_MAXLEN
];
5688 afi_t afi
= bgp_node_afi(vty
);
5689 safi_t safi
= bgp_node_safi(vty
);
5692 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5693 yang_afi_safi_value2identity(afi
, safi
));
5695 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5696 sizeof(base_xpath
), af_xpath
)
5698 return CMD_WARNING_CONFIG_FAILED
;
5700 snprintf(attr_xpath
, sizeof(attr_xpath
),
5701 "./%s/nexthop-self/next-hop-self-force",
5702 bgp_afi_safi_get_container_str(afi
, safi
));
5704 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5706 return nb_cli_apply_changes(vty
, base_xpath
);
5709 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5710 no_neighbor_nexthop_self_force_hidden_cmd
,
5711 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5712 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5713 "Disable the next hop calculation for this neighbor\n"
5714 "Set the next hop to self for reflected routes\n")
5716 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5717 no_neighbor_nexthop_self_all_hidden_cmd
,
5718 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5719 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5720 "Disable the next hop calculation for this neighbor\n"
5721 "Set the next hop to self for reflected routes\n")
5723 /* neighbor as-override */
5724 DEFUN_YANG (neighbor_as_override
,
5725 neighbor_as_override_cmd
,
5726 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5729 "Override ASNs in outbound updates if aspath equals remote-as\n")
5732 char base_xpath
[XPATH_MAXLEN
];
5733 char af_xpath
[XPATH_MAXLEN
];
5734 char attr_xpath
[XPATH_MAXLEN
];
5735 afi_t afi
= bgp_node_afi(vty
);
5736 safi_t safi
= bgp_node_safi(vty
);
5738 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5739 yang_afi_safi_value2identity(afi
, safi
));
5741 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5742 sizeof(base_xpath
), af_xpath
)
5744 return CMD_WARNING_CONFIG_FAILED
;
5746 snprintf(attr_xpath
, sizeof(attr_xpath
),
5747 "./%s/as-path-options/replace-peer-as",
5748 bgp_afi_safi_get_container_str(afi
, safi
));
5750 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5752 return nb_cli_apply_changes(vty
, base_xpath
);
5755 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5756 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5757 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5758 "Override ASNs in outbound updates if aspath equals remote-as\n")
5760 DEFUN_YANG (no_neighbor_as_override
,
5761 no_neighbor_as_override_cmd
,
5762 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5766 "Override ASNs in outbound updates if aspath equals remote-as\n")
5769 char base_xpath
[XPATH_MAXLEN
];
5770 char af_xpath
[XPATH_MAXLEN
];
5771 char attr_xpath
[XPATH_MAXLEN
];
5772 afi_t afi
= bgp_node_afi(vty
);
5773 safi_t safi
= bgp_node_safi(vty
);
5775 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5776 yang_afi_safi_value2identity(afi
, safi
));
5778 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5779 sizeof(base_xpath
), af_xpath
)
5781 return CMD_WARNING_CONFIG_FAILED
;
5783 snprintf(attr_xpath
, sizeof(attr_xpath
),
5784 "./%s/as-path-options/replace-peer-as",
5785 bgp_afi_safi_get_container_str(afi
, safi
));
5787 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5789 return nb_cli_apply_changes(vty
, base_xpath
);
5792 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5793 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5794 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5795 "Override ASNs in outbound updates if aspath equals remote-as\n")
5797 /* neighbor remove-private-AS. */
5798 DEFUN_YANG (neighbor_remove_private_as
,
5799 neighbor_remove_private_as_cmd
,
5800 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5803 "Remove private ASNs in outbound updates\n")
5806 char base_xpath
[XPATH_MAXLEN
];
5807 char af_xpath
[XPATH_MAXLEN
];
5808 char attr_xpath
[XPATH_MAXLEN
];
5809 afi_t afi
= bgp_node_afi(vty
);
5810 safi_t safi
= bgp_node_safi(vty
);
5812 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5813 yang_afi_safi_value2identity(afi
, safi
));
5815 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5816 sizeof(base_xpath
), af_xpath
)
5818 return CMD_WARNING_CONFIG_FAILED
;
5820 snprintf(attr_xpath
, sizeof(attr_xpath
),
5821 "./%s/private-as/remove-private-as",
5822 bgp_afi_safi_get_container_str(afi
, safi
));
5824 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5826 return nb_cli_apply_changes(vty
, base_xpath
);
5829 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5830 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5831 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5832 "Remove private ASNs in outbound updates\n")
5834 DEFUN_YANG (neighbor_remove_private_as_all
,
5835 neighbor_remove_private_as_all_cmd
,
5836 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5839 "Remove private ASNs in outbound updates\n"
5840 "Apply to all AS numbers\n")
5843 char base_xpath
[XPATH_MAXLEN
];
5844 char af_xpath
[XPATH_MAXLEN
];
5845 char attr_xpath
[XPATH_MAXLEN
];
5846 afi_t afi
= bgp_node_afi(vty
);
5847 safi_t safi
= bgp_node_safi(vty
);
5850 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5851 yang_afi_safi_value2identity(afi
, safi
));
5853 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5854 sizeof(base_xpath
), af_xpath
)
5856 return CMD_WARNING_CONFIG_FAILED
;
5858 snprintf(attr_xpath
, sizeof(attr_xpath
),
5859 "./%s/private-as/remove-private-as-all",
5860 bgp_afi_safi_get_container_str(afi
, safi
));
5862 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5864 return nb_cli_apply_changes(vty
, base_xpath
);
5867 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5868 neighbor_remove_private_as_all_hidden_cmd
,
5869 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5870 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5871 "Remove private ASNs in outbound updates\n"
5872 "Apply to all AS numbers")
5874 DEFUN_YANG (neighbor_remove_private_as_replace_as
,
5875 neighbor_remove_private_as_replace_as_cmd
,
5876 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5879 "Remove private ASNs in outbound updates\n"
5880 "Replace private ASNs with our ASN in outbound updates\n")
5883 char base_xpath
[XPATH_MAXLEN
];
5884 char af_xpath
[XPATH_MAXLEN
];
5885 char attr_xpath
[XPATH_MAXLEN
];
5886 afi_t afi
= bgp_node_afi(vty
);
5887 safi_t safi
= bgp_node_safi(vty
);
5890 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5891 yang_afi_safi_value2identity(afi
, safi
));
5893 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5894 sizeof(base_xpath
), af_xpath
)
5896 return CMD_WARNING_CONFIG_FAILED
;
5898 snprintf(attr_xpath
, sizeof(attr_xpath
),
5899 "./%s/private-as/remove-private-as-replace",
5900 bgp_afi_safi_get_container_str(afi
, safi
));
5902 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5904 return nb_cli_apply_changes(vty
, base_xpath
);
5907 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5908 neighbor_remove_private_as_replace_as_hidden_cmd
,
5909 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5910 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5911 "Remove private ASNs in outbound updates\n"
5912 "Replace private ASNs with our ASN in outbound updates\n")
5914 DEFUN_YANG (neighbor_remove_private_as_all_replace_as
,
5915 neighbor_remove_private_as_all_replace_as_cmd
,
5916 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5919 "Remove private ASNs in outbound updates\n"
5920 "Apply to all AS numbers\n"
5921 "Replace private ASNs with our ASN in outbound updates\n")
5924 char base_xpath
[XPATH_MAXLEN
];
5925 char af_xpath
[XPATH_MAXLEN
];
5926 char attr_xpath
[XPATH_MAXLEN
];
5927 afi_t afi
= bgp_node_afi(vty
);
5928 safi_t safi
= bgp_node_safi(vty
);
5931 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5932 yang_afi_safi_value2identity(afi
, safi
));
5934 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5935 sizeof(base_xpath
), af_xpath
)
5937 return CMD_WARNING_CONFIG_FAILED
;
5939 snprintf(attr_xpath
, sizeof(attr_xpath
),
5940 "./%s/private-as/remove-private-as-all-replace",
5941 bgp_afi_safi_get_container_str(afi
, safi
));
5943 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5945 return nb_cli_apply_changes(vty
, base_xpath
);
5949 neighbor_remove_private_as_all_replace_as
,
5950 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5951 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5952 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5953 "Remove private ASNs in outbound updates\n"
5954 "Apply to all AS numbers\n"
5955 "Replace private ASNs with our ASN in outbound updates\n")
5957 DEFUN_YANG (no_neighbor_remove_private_as
,
5958 no_neighbor_remove_private_as_cmd
,
5959 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5963 "Remove private ASNs in outbound updates\n")
5966 char base_xpath
[XPATH_MAXLEN
];
5967 char af_xpath
[XPATH_MAXLEN
];
5968 char attr_xpath
[XPATH_MAXLEN
];
5969 afi_t afi
= bgp_node_afi(vty
);
5970 safi_t safi
= bgp_node_safi(vty
);
5972 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5973 yang_afi_safi_value2identity(afi
, safi
));
5975 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5976 sizeof(base_xpath
), af_xpath
)
5978 return CMD_WARNING_CONFIG_FAILED
;
5980 snprintf(attr_xpath
, sizeof(attr_xpath
),
5981 "./%s/private-as/remove-private-as",
5982 bgp_afi_safi_get_container_str(afi
, safi
));
5984 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5986 return nb_cli_apply_changes(vty
, base_xpath
);
5989 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5990 no_neighbor_remove_private_as_hidden_cmd
,
5991 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5992 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5993 "Remove private ASNs in outbound updates\n")
5995 DEFUN_YANG (no_neighbor_remove_private_as_all
,
5996 no_neighbor_remove_private_as_all_cmd
,
5997 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
6001 "Remove private ASNs in outbound updates\n"
6002 "Apply to all AS numbers\n")
6005 char base_xpath
[XPATH_MAXLEN
];
6006 char af_xpath
[XPATH_MAXLEN
];
6007 char attr_xpath
[XPATH_MAXLEN
];
6008 afi_t afi
= bgp_node_afi(vty
);
6009 safi_t safi
= bgp_node_safi(vty
);
6012 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6013 yang_afi_safi_value2identity(afi
, safi
));
6015 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6016 sizeof(base_xpath
), af_xpath
)
6018 return CMD_WARNING_CONFIG_FAILED
;
6020 snprintf(attr_xpath
, sizeof(attr_xpath
),
6021 "./%s/private-as/remove-private-as-all",
6022 bgp_afi_safi_get_container_str(afi
, safi
));
6024 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6026 return nb_cli_apply_changes(vty
, base_xpath
);
6029 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
6030 no_neighbor_remove_private_as_all_hidden_cmd
,
6031 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
6032 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6033 "Remove private ASNs in outbound updates\n"
6034 "Apply to all AS numbers\n")
6036 DEFUN_YANG (no_neighbor_remove_private_as_replace_as
,
6037 no_neighbor_remove_private_as_replace_as_cmd
,
6038 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
6042 "Remove private ASNs in outbound updates\n"
6043 "Replace private ASNs with our ASN in outbound updates\n")
6046 char base_xpath
[XPATH_MAXLEN
];
6047 char af_xpath
[XPATH_MAXLEN
];
6048 char attr_xpath
[XPATH_MAXLEN
];
6049 afi_t afi
= bgp_node_afi(vty
);
6050 safi_t safi
= bgp_node_safi(vty
);
6053 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6054 yang_afi_safi_value2identity(afi
, safi
));
6056 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6057 sizeof(base_xpath
), af_xpath
)
6059 return CMD_WARNING_CONFIG_FAILED
;
6061 snprintf(attr_xpath
, sizeof(attr_xpath
),
6062 "./%s/private-as/remove-private-as-replace",
6063 bgp_afi_safi_get_container_str(afi
, safi
));
6065 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6067 return nb_cli_apply_changes(vty
, base_xpath
);
6070 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
6071 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
6072 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
6073 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6074 "Remove private ASNs in outbound updates\n"
6075 "Replace private ASNs with our ASN in outbound updates\n")
6077 DEFUN_YANG (no_neighbor_remove_private_as_all_replace_as
,
6078 no_neighbor_remove_private_as_all_replace_as_cmd
,
6079 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6083 "Remove private ASNs in outbound updates\n"
6084 "Apply to all AS numbers\n"
6085 "Replace private ASNs with our ASN in outbound updates\n")
6088 char base_xpath
[XPATH_MAXLEN
];
6089 char af_xpath
[XPATH_MAXLEN
];
6090 char attr_xpath
[XPATH_MAXLEN
];
6091 afi_t afi
= bgp_node_afi(vty
);
6092 safi_t safi
= bgp_node_safi(vty
);
6095 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6096 yang_afi_safi_value2identity(afi
, safi
));
6098 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6099 sizeof(base_xpath
), af_xpath
)
6101 return CMD_WARNING_CONFIG_FAILED
;
6103 snprintf(attr_xpath
, sizeof(attr_xpath
),
6104 "./%s/private-as/remove-private-as-all-replace",
6105 bgp_afi_safi_get_container_str(afi
, safi
));
6107 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6109 return nb_cli_apply_changes(vty
, base_xpath
);
6113 no_neighbor_remove_private_as_all_replace_as
,
6114 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
6115 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6116 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6117 "Remove private ASNs in outbound updates\n"
6118 "Apply to all AS numbers\n"
6119 "Replace private ASNs with our ASN in outbound updates\n")
6122 /* neighbor send-community. */
6123 DEFUN_YANG (neighbor_send_community
,
6124 neighbor_send_community_cmd
,
6125 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6128 "Send Community attribute to this neighbor\n")
6132 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6134 PEER_FLAG_SEND_COMMUNITY
);
6137 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
6138 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6139 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6140 "Send Community attribute to this neighbor\n")
6142 DEFUN_YANG (no_neighbor_send_community
,
6143 no_neighbor_send_community_cmd
,
6144 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6148 "Send Community attribute to this neighbor\n")
6152 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6153 bgp_node_afi(vty
), bgp_node_safi(vty
),
6154 PEER_FLAG_SEND_COMMUNITY
);
6157 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
6158 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6159 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6160 "Send Community attribute to this neighbor\n")
6162 /* neighbor send-community extended. */
6163 DEFUN_YANG (neighbor_send_community_type
,
6164 neighbor_send_community_type_cmd
,
6165 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6168 "Send Community attribute to this neighbor\n"
6169 "Send Standard and Extended Community attributes\n"
6170 "Send Standard, Large and Extended Community attributes\n"
6171 "Send Extended Community attributes\n"
6172 "Send Standard Community attributes\n"
6173 "Send Large Community attributes\n")
6175 const char *type
= argv
[argc
- 1]->text
;
6176 char *peer_str
= argv
[1]->arg
;
6177 char base_xpath
[XPATH_MAXLEN
];
6178 char af_xpath
[XPATH_MAXLEN
];
6179 char std_xpath
[XPATH_MAXLEN
];
6180 char ext_xpath
[XPATH_MAXLEN
];
6181 char lrg_xpath
[XPATH_MAXLEN
];
6182 afi_t afi
= bgp_node_afi(vty
);
6183 safi_t safi
= bgp_node_safi(vty
);
6185 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6186 yang_afi_safi_value2identity(afi
, safi
));
6188 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6189 sizeof(base_xpath
), af_xpath
)
6191 return CMD_WARNING_CONFIG_FAILED
;
6193 if (strmatch(type
, "standard")) {
6194 snprintf(std_xpath
, sizeof(std_xpath
),
6195 "./%s/send-community/send-community",
6196 bgp_afi_safi_get_container_str(afi
, safi
));
6198 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6201 if (strmatch(type
, "extended")) {
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");
6209 if (strmatch(type
, "large")) {
6210 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6211 "./%s/send-community/send-large-community",
6212 bgp_afi_safi_get_container_str(afi
, safi
));
6214 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "true");
6217 if (strmatch(type
, "both")) {
6218 snprintf(std_xpath
, sizeof(std_xpath
),
6219 "./%s/send-community/send-community",
6220 bgp_afi_safi_get_container_str(afi
, safi
));
6222 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6224 snprintf(ext_xpath
, sizeof(ext_xpath
),
6225 "./%s/send-community/send-ext-community",
6226 bgp_afi_safi_get_container_str(afi
, safi
));
6228 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6231 if (strmatch(type
, "all")) {
6232 snprintf(std_xpath
, sizeof(std_xpath
),
6233 "./%s/send-community/send-community",
6234 bgp_afi_safi_get_container_str(afi
, safi
));
6236 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6238 snprintf(ext_xpath
, sizeof(ext_xpath
),
6239 "./%s/send-community/send-ext-community",
6240 bgp_afi_safi_get_container_str(afi
, safi
));
6242 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6244 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6245 "./%s/send-community/send-large-community",
6246 bgp_afi_safi_get_container_str(afi
, safi
));
6248 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "true");
6251 return nb_cli_apply_changes(vty
, base_xpath
);
6255 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6256 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6257 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6258 "Send Community attribute to this neighbor\n"
6259 "Send Standard and Extended Community attributes\n"
6260 "Send Standard, Large and Extended Community attributes\n"
6261 "Send Extended Community attributes\n"
6262 "Send Standard Community attributes\n"
6263 "Send Large Community attributes\n")
6265 DEFUN_YANG (no_neighbor_send_community_type
,
6266 no_neighbor_send_community_type_cmd
,
6267 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6271 "Send Community attribute to this neighbor\n"
6272 "Send Standard and Extended Community attributes\n"
6273 "Send Standard, Large and Extended Community attributes\n"
6274 "Send Extended Community attributes\n"
6275 "Send Standard Community attributes\n"
6276 "Send Large Community attributes\n")
6278 const char *type
= argv
[argc
- 1]->text
;
6279 char *peer_str
= argv
[2]->arg
;
6280 char base_xpath
[XPATH_MAXLEN
];
6281 char af_xpath
[XPATH_MAXLEN
];
6282 char std_xpath
[XPATH_MAXLEN
];
6283 char ext_xpath
[XPATH_MAXLEN
];
6284 char lrg_xpath
[XPATH_MAXLEN
];
6285 afi_t afi
= bgp_node_afi(vty
);
6286 safi_t safi
= bgp_node_safi(vty
);
6288 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6289 yang_afi_safi_value2identity(afi
, safi
));
6291 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6292 sizeof(base_xpath
), af_xpath
)
6294 return CMD_WARNING_CONFIG_FAILED
;
6296 if (strmatch(type
, "standard")) {
6297 snprintf(std_xpath
, sizeof(std_xpath
),
6298 "./%s/send-community/send-community",
6299 bgp_afi_safi_get_container_str(afi
, safi
));
6301 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6304 if (strmatch(type
, "extended")) {
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");
6312 if (strmatch(type
, "large")) {
6313 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6314 "./%s/send-community/send-large-community",
6315 bgp_afi_safi_get_container_str(afi
, safi
));
6317 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "false");
6320 if (strmatch(type
, "both")) {
6321 snprintf(std_xpath
, sizeof(std_xpath
),
6322 "./%s/send-community/send-community",
6323 bgp_afi_safi_get_container_str(afi
, safi
));
6325 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6327 snprintf(ext_xpath
, sizeof(ext_xpath
),
6328 "./%s/send-community/send-ext-community",
6329 bgp_afi_safi_get_container_str(afi
, safi
));
6331 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6334 if (strmatch(type
, "all")) {
6335 snprintf(std_xpath
, sizeof(std_xpath
),
6336 "./%s/send-community/send-community",
6337 bgp_afi_safi_get_container_str(afi
, safi
));
6339 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6341 snprintf(ext_xpath
, sizeof(ext_xpath
),
6342 "./%s/send-community/send-ext-community",
6343 bgp_afi_safi_get_container_str(afi
, safi
));
6345 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6347 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6348 "./%s/send-community/send-large-community",
6349 bgp_afi_safi_get_container_str(afi
, safi
));
6351 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "false");
6354 return nb_cli_apply_changes(vty
, base_xpath
);
6358 no_neighbor_send_community_type
,
6359 no_neighbor_send_community_type_hidden_cmd
,
6360 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6361 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6362 "Send Community attribute to this neighbor\n"
6363 "Send Standard and Extended Community attributes\n"
6364 "Send Standard, Large and Extended Community attributes\n"
6365 "Send Extended Community attributes\n"
6366 "Send Standard Community attributes\n"
6367 "Send Large Community attributes\n")
6369 /* neighbor soft-reconfig. */
6370 DEFUN_YANG (neighbor_soft_reconfiguration
,
6371 neighbor_soft_reconfiguration_cmd
,
6372 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6373 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6374 "Per neighbor soft reconfiguration\n"
6375 "Allow inbound soft reconfiguration for this neighbor\n")
6378 char base_xpath
[XPATH_MAXLEN
];
6379 char af_xpath
[XPATH_MAXLEN
];
6380 char soft_xpath
[XPATH_MAXLEN
];
6381 afi_t afi
= bgp_node_afi(vty
);
6382 safi_t safi
= bgp_node_safi(vty
);
6385 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6386 yang_afi_safi_value2identity(afi
, safi
));
6388 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6389 sizeof(base_xpath
), af_xpath
)
6391 return CMD_WARNING_CONFIG_FAILED
;
6393 snprintf(soft_xpath
, sizeof(soft_xpath
), "./%s/soft-reconfiguration",
6394 bgp_afi_safi_get_container_str(afi
, safi
));
6396 nb_cli_enqueue_change(vty
, soft_xpath
, NB_OP_MODIFY
, "true");
6398 return nb_cli_apply_changes(vty
, base_xpath
);
6401 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6402 neighbor_soft_reconfiguration_hidden_cmd
,
6403 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6404 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6405 "Per neighbor soft reconfiguration\n"
6406 "Allow inbound soft reconfiguration for this neighbor\n")
6408 DEFUN_YANG (no_neighbor_soft_reconfiguration
,
6409 no_neighbor_soft_reconfiguration_cmd
,
6410 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6411 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6412 "Per neighbor soft reconfiguration\n"
6413 "Allow inbound soft reconfiguration for this neighbor\n")
6416 char base_xpath
[XPATH_MAXLEN
];
6417 char af_xpath
[XPATH_MAXLEN
];
6418 char soft_xpath
[XPATH_MAXLEN
];
6419 afi_t afi
= bgp_node_afi(vty
);
6420 safi_t safi
= bgp_node_safi(vty
);
6422 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6423 yang_afi_safi_value2identity(afi
, safi
));
6425 snprintf(soft_xpath
, sizeof(soft_xpath
), "./%s/soft-reconfiguration",
6426 bgp_afi_safi_get_container_str(afi
, safi
));
6428 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6429 sizeof(base_xpath
), af_xpath
)
6431 return CMD_WARNING_CONFIG_FAILED
;
6433 nb_cli_enqueue_change(vty
, soft_xpath
, NB_OP_MODIFY
, "false");
6435 return nb_cli_apply_changes(vty
, base_xpath
);
6438 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6439 no_neighbor_soft_reconfiguration_hidden_cmd
,
6440 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6441 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6442 "Per neighbor soft reconfiguration\n"
6443 "Allow inbound soft reconfiguration for this neighbor\n")
6445 DEFUN_YANG (neighbor_route_reflector_client
,
6446 neighbor_route_reflector_client_cmd
,
6447 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6450 "Configure a neighbor as Route Reflector client\n")
6453 char base_xpath
[XPATH_MAXLEN
];
6454 char af_xpath
[XPATH_MAXLEN
];
6455 char attr_xpath
[XPATH_MAXLEN
];
6456 afi_t afi
= bgp_node_afi(vty
);
6457 safi_t safi
= bgp_node_safi(vty
);
6459 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6460 yang_afi_safi_value2identity(afi
, safi
));
6462 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6463 sizeof(base_xpath
), af_xpath
)
6465 return CMD_WARNING_CONFIG_FAILED
;
6467 snprintf(attr_xpath
, sizeof(attr_xpath
),
6468 "./%s/route-reflector/route-reflector-client",
6469 bgp_afi_safi_get_container_str(afi
, safi
));
6471 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6473 return nb_cli_apply_changes(vty
, base_xpath
);
6476 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6477 neighbor_route_reflector_client_hidden_cmd
,
6478 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6479 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6480 "Configure a neighbor as Route Reflector client\n")
6482 DEFUN_YANG (no_neighbor_route_reflector_client
,
6483 no_neighbor_route_reflector_client_cmd
,
6484 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6488 "Configure a neighbor as Route Reflector client\n")
6491 char base_xpath
[XPATH_MAXLEN
];
6492 char af_xpath
[XPATH_MAXLEN
];
6493 char attr_xpath
[XPATH_MAXLEN
];
6494 afi_t afi
= bgp_node_afi(vty
);
6495 safi_t safi
= bgp_node_safi(vty
);
6497 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6498 yang_afi_safi_value2identity(afi
, safi
));
6500 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6501 sizeof(base_xpath
), af_xpath
)
6503 return CMD_WARNING_CONFIG_FAILED
;
6505 snprintf(attr_xpath
, sizeof(attr_xpath
),
6506 "./%s/route-reflector/route-reflector-client",
6507 bgp_afi_safi_get_container_str(afi
, safi
));
6509 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6511 return nb_cli_apply_changes(vty
, base_xpath
);
6514 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6515 no_neighbor_route_reflector_client_hidden_cmd
,
6516 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6517 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6518 "Configure a neighbor as Route Reflector client\n")
6520 /* neighbor route-server-client. */
6521 DEFUN_YANG (neighbor_route_server_client
,
6522 neighbor_route_server_client_cmd
,
6523 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6526 "Configure a neighbor as Route Server client\n")
6529 char base_xpath
[XPATH_MAXLEN
];
6530 char af_xpath
[XPATH_MAXLEN
];
6531 char attr_xpath
[XPATH_MAXLEN
];
6532 afi_t afi
= bgp_node_afi(vty
);
6533 safi_t safi
= bgp_node_safi(vty
);
6535 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6536 yang_afi_safi_value2identity(afi
, safi
));
6538 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6539 sizeof(base_xpath
), af_xpath
)
6541 return CMD_WARNING_CONFIG_FAILED
;
6543 snprintf(attr_xpath
, sizeof(attr_xpath
),
6544 "./%s/route-server/route-server-client",
6545 bgp_afi_safi_get_container_str(afi
, safi
));
6547 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6549 return nb_cli_apply_changes(vty
, base_xpath
);
6552 ALIAS_HIDDEN(neighbor_route_server_client
,
6553 neighbor_route_server_client_hidden_cmd
,
6554 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6555 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6556 "Configure a neighbor as Route Server client\n")
6558 DEFUN_YANG (no_neighbor_route_server_client
,
6559 no_neighbor_route_server_client_cmd
,
6560 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6564 "Configure a neighbor as Route Server client\n")
6567 char base_xpath
[XPATH_MAXLEN
];
6568 char af_xpath
[XPATH_MAXLEN
];
6569 char attr_xpath
[XPATH_MAXLEN
];
6570 afi_t afi
= bgp_node_afi(vty
);
6571 safi_t safi
= bgp_node_safi(vty
);
6573 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6574 yang_afi_safi_value2identity(afi
, safi
));
6576 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6577 sizeof(base_xpath
), af_xpath
)
6579 return CMD_WARNING_CONFIG_FAILED
;
6581 snprintf(attr_xpath
, sizeof(attr_xpath
),
6582 "./%s/route-server/route-server-client",
6583 bgp_afi_safi_get_container_str(afi
, safi
));
6585 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6587 return nb_cli_apply_changes(vty
, base_xpath
);
6590 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6591 no_neighbor_route_server_client_hidden_cmd
,
6592 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6593 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6594 "Configure a neighbor as Route Server client\n")
6596 DEFUN (neighbor_nexthop_local_unchanged
,
6597 neighbor_nexthop_local_unchanged_cmd
,
6598 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6601 "Configure treatment of outgoing link-local nexthop attribute\n"
6602 "Leave link-local nexthop unchanged for this peer\n")
6605 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6607 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6610 DEFUN (no_neighbor_nexthop_local_unchanged
,
6611 no_neighbor_nexthop_local_unchanged_cmd
,
6612 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6616 "Configure treatment of outgoing link-local-nexthop attribute\n"
6617 "Leave link-local nexthop unchanged for this peer\n")
6620 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6621 bgp_node_afi(vty
), bgp_node_safi(vty
),
6622 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6625 DEFUN_YANG (neighbor_attr_unchanged
,
6626 neighbor_attr_unchanged_cmd
,
6627 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6630 "BGP attribute is propagated unchanged to this neighbor\n"
6631 "As-path attribute\n"
6632 "Nexthop attribute\n"
6636 char *peer_str
= argv
[1]->arg
;
6637 bool aspath
= false;
6638 bool nexthop
= false;
6640 afi_t afi
= bgp_node_afi(vty
);
6641 safi_t safi
= bgp_node_safi(vty
);
6642 char base_xpath
[XPATH_MAXLEN
];
6643 char af_xpath
[XPATH_MAXLEN
];
6644 char as_xpath
[XPATH_MAXLEN
];
6645 char nxthop_xpath
[XPATH_MAXLEN
];
6646 char med_xpath
[XPATH_MAXLEN
];
6648 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6649 yang_afi_safi_value2identity(afi
, safi
));
6651 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6652 sizeof(base_xpath
), af_xpath
)
6654 return CMD_WARNING_CONFIG_FAILED
;
6656 if (argv_find(argv
, argc
, "as-path", &idx
))
6660 if (argv_find(argv
, argc
, "next-hop", &idx
))
6664 if (argv_find(argv
, argc
, "med", &idx
))
6667 snprintf(as_xpath
, sizeof(as_xpath
),
6668 "./%s/attr-unchanged/as-path-unchanged",
6669 bgp_afi_safi_get_container_str(afi
, safi
));
6670 snprintf(nxthop_xpath
, sizeof(nxthop_xpath
),
6671 "./%s/attr-unchanged/next-hop-unchanged",
6672 bgp_afi_safi_get_container_str(afi
, safi
));
6673 snprintf(med_xpath
, sizeof(med_xpath
),
6674 "./%s/attr-unchanged/med-unchanged",
6675 bgp_afi_safi_get_container_str(afi
, safi
));
6677 /* no flags means all of them! */
6678 if (!aspath
&& !nexthop
&& !med
) {
6679 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "true");
6680 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "true");
6681 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "true");
6684 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
,
6687 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
,
6691 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
,
6694 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
,
6698 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
,
6701 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
,
6705 return nb_cli_apply_changes(vty
, base_xpath
);
6709 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6710 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6711 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6712 "BGP attribute is propagated unchanged to this neighbor\n"
6713 "As-path attribute\n"
6714 "Nexthop attribute\n"
6717 DEFUN_YANG (no_neighbor_attr_unchanged
,
6718 no_neighbor_attr_unchanged_cmd
,
6719 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6723 "BGP attribute is propagated unchanged to this neighbor\n"
6724 "As-path attribute\n"
6725 "Nexthop attribute\n"
6729 char *peer_str
= argv
[2]->arg
;
6730 bool aspath
= false;
6731 bool nexthop
= false;
6733 afi_t afi
= bgp_node_afi(vty
);
6734 safi_t safi
= bgp_node_safi(vty
);
6735 char base_xpath
[XPATH_MAXLEN
];
6736 char af_xpath
[XPATH_MAXLEN
];
6737 char as_xpath
[XPATH_MAXLEN
];
6738 char nxthop_xpath
[XPATH_MAXLEN
];
6739 char med_xpath
[XPATH_MAXLEN
];
6741 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6742 yang_afi_safi_value2identity(afi
, safi
));
6744 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6745 sizeof(base_xpath
), af_xpath
)
6747 return CMD_WARNING_CONFIG_FAILED
;
6749 if (argv_find(argv
, argc
, "as-path", &idx
))
6753 if (argv_find(argv
, argc
, "next-hop", &idx
))
6757 if (argv_find(argv
, argc
, "med", &idx
))
6760 snprintf(as_xpath
, sizeof(as_xpath
),
6761 "./%s/attr-unchanged/as-path-unchanged",
6762 bgp_afi_safi_get_container_str(afi
, safi
));
6763 snprintf(nxthop_xpath
, sizeof(nxthop_xpath
),
6764 "./%s/attr-unchanged/next-hop-unchanged",
6765 bgp_afi_safi_get_container_str(afi
, safi
));
6766 snprintf(med_xpath
, sizeof(med_xpath
),
6767 "./%s/attr-unchanged/med-unchanged",
6768 bgp_afi_safi_get_container_str(afi
, safi
));
6770 /* no flags means all of them! */
6771 if (!aspath
&& !nexthop
&& !med
) {
6772 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "false");
6773 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "false");
6774 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "false");
6778 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "false");
6781 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "false");
6784 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "false");
6786 return nb_cli_apply_changes(vty
, base_xpath
);
6790 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6791 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6792 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6793 "BGP attribute is propagated unchanged to this neighbor\n"
6794 "As-path attribute\n"
6795 "Nexthop attribute\n"
6798 /* neighbor ebgp-multihop. */
6799 DEFUN_YANG (neighbor_ebgp_multihop
,
6800 neighbor_ebgp_multihop_cmd
,
6801 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6802 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6803 "Allow EBGP neighbors not on directly connected networks\n")
6806 char base_xpath
[XPATH_MAXLEN
];
6808 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6809 sizeof(base_xpath
), NULL
)
6811 return CMD_WARNING_CONFIG_FAILED
;
6813 nb_cli_enqueue_change(vty
, "./ebgp-multihop/enabled", NB_OP_MODIFY
,
6816 return nb_cli_apply_changes(vty
, base_xpath
);
6819 DEFUN_YANG (neighbor_ebgp_multihop_ttl
,
6820 neighbor_ebgp_multihop_ttl_cmd
,
6821 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6822 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6823 "Allow EBGP neighbors not on directly connected networks\n"
6824 "maximum hop count\n")
6828 char base_xpath
[XPATH_MAXLEN
];
6830 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6831 sizeof(base_xpath
), NULL
)
6833 return CMD_WARNING_CONFIG_FAILED
;
6835 nb_cli_enqueue_change(vty
, "./ebgp-multihop/multihop-ttl", NB_OP_MODIFY
,
6836 argv
[idx_number
]->arg
);
6838 return nb_cli_apply_changes(vty
, base_xpath
);
6841 DEFUN_YANG (no_neighbor_ebgp_multihop
,
6842 no_neighbor_ebgp_multihop_cmd
,
6843 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6844 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6845 "Allow EBGP neighbors not on directly connected networks\n"
6846 "maximum hop count\n")
6849 char base_xpath
[XPATH_MAXLEN
];
6851 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6852 sizeof(base_xpath
), NULL
)
6854 return CMD_WARNING_CONFIG_FAILED
;
6857 nb_cli_enqueue_change(vty
, "./ebgp-multihop/multihop-ttl",
6858 NB_OP_DESTROY
, NULL
);
6860 nb_cli_enqueue_change(vty
, "./ebgp-multihop/enabled",
6861 NB_OP_MODIFY
, "false");
6863 return nb_cli_apply_changes(vty
, base_xpath
);
6867 /* disable-connected-check */
6868 DEFUN_YANG (neighbor_disable_connected_check
,
6869 neighbor_disable_connected_check_cmd
,
6870 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6871 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6872 "one-hop away EBGP peer using loopback address\n"
6873 "Enforce EBGP neighbors perform multihop\n")
6876 char base_xpath
[XPATH_MAXLEN
];
6878 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6879 sizeof(base_xpath
), NULL
)
6881 return CMD_WARNING_CONFIG_FAILED
;
6883 nb_cli_enqueue_change(vty
, "./ebgp-multihop/disable-connected-check",
6884 NB_OP_MODIFY
, "true");
6886 return nb_cli_apply_changes(vty
, base_xpath
);
6889 DEFUN_YANG (no_neighbor_disable_connected_check
,
6890 no_neighbor_disable_connected_check_cmd
,
6891 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6892 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6893 "one-hop away EBGP peer using loopback address\n"
6894 "Enforce EBGP neighbors perform multihop\n")
6897 char base_xpath
[XPATH_MAXLEN
];
6899 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6900 sizeof(base_xpath
), NULL
)
6902 return CMD_WARNING_CONFIG_FAILED
;
6904 nb_cli_enqueue_change(vty
, "./ebgp-multihop/disable-connected-check",
6905 NB_OP_MODIFY
, "false");
6907 return nb_cli_apply_changes(vty
, base_xpath
);
6911 /* enforce-first-as */
6912 DEFUN_YANG (neighbor_enforce_first_as
,
6913 neighbor_enforce_first_as_cmd
,
6914 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6915 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6916 "Enforce the first AS for EBGP routes\n")
6919 char base_xpath
[XPATH_MAXLEN
];
6921 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6922 sizeof(base_xpath
), NULL
)
6924 return CMD_WARNING_CONFIG_FAILED
;
6926 nb_cli_enqueue_change(vty
, "./enforce-first-as", NB_OP_MODIFY
, "true");
6928 return nb_cli_apply_changes(vty
, base_xpath
);
6931 DEFUN_YANG (no_neighbor_enforce_first_as
,
6932 no_neighbor_enforce_first_as_cmd
,
6933 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6934 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6935 "Enforce the first AS for EBGP routes\n")
6938 char base_xpath
[XPATH_MAXLEN
];
6940 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6941 sizeof(base_xpath
), NULL
)
6943 return CMD_WARNING_CONFIG_FAILED
;
6945 nb_cli_enqueue_change(vty
, "./enforce-first-as", NB_OP_MODIFY
, "false");
6947 return nb_cli_apply_changes(vty
, base_xpath
);
6950 static int peer_and_group_lookup_nb(struct vty
*vty
, const char *peer_str
,
6951 char *base_xpath
, int xpath_len
,
6955 char num_xpath
[XPATH_MAXLEN
];
6956 char unnbr_xpath
[XPATH_MAXLEN
];
6957 char prgrp_xpath
[XPATH_MAXLEN
];
6959 if (str2sockunion(peer_str
, &su
) == 0) {
6960 snprintf(num_xpath
, sizeof(num_xpath
),
6961 "/neighbors/neighbor[remote-address='%s']", peer_str
);
6962 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
6963 VTY_CURR_XPATH
, num_xpath
)) {
6964 snprintf(base_xpath
, xpath_len
,
6965 FRR_BGP_NEIGHBOR_NUM_XPATH
, peer_str
,
6966 xpath
? xpath
: "");
6969 "%% Specify remote-as or peer-group commands first\n");
6974 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
6975 "/neighbors/unnumbered-neighbor[interface='%s']",
6978 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
6979 "/peer-groups/peer-group[peer-group-name='%s']",
6982 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
6983 VTY_CURR_XPATH
, unnbr_xpath
)) {
6984 snprintf(base_xpath
, xpath_len
,
6985 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, peer_str
,
6986 xpath
? xpath
: "");
6987 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
,
6988 "%s%s", VTY_CURR_XPATH
,
6990 snprintf(base_xpath
, xpath_len
,
6991 FRR_BGP_PEER_GROUP_XPATH
, peer_str
,
6992 xpath
? xpath
: "");
6995 "%% Create the peer-group or interface first\n");
7003 DEFUN_YANG (neighbor_description
,
7004 neighbor_description_cmd
,
7005 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
7006 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7007 "Neighbor specific description\n"
7008 "Up to 80 characters describing this neighbor\n")
7013 char base_xpath
[XPATH_MAXLEN
];
7016 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7017 sizeof(base_xpath
), NULL
)
7019 return CMD_WARNING_CONFIG_FAILED
;
7021 str
= argv_concat(argv
, argc
, idx_line
);
7023 nb_cli_enqueue_change(vty
, "./description", NB_OP_MODIFY
, str
);
7025 ret
= nb_cli_apply_changes(vty
, base_xpath
);
7027 XFREE(MTYPE_TMP
, str
);
7032 DEFUN_YANG (no_neighbor_description
,
7033 no_neighbor_description_cmd
,
7034 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
7035 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7036 "Neighbor specific description\n")
7039 char base_xpath
[XPATH_MAXLEN
];
7041 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7042 sizeof(base_xpath
), NULL
)
7044 return CMD_WARNING_CONFIG_FAILED
;
7046 nb_cli_enqueue_change(vty
, "./description", NB_OP_DESTROY
, NULL
);
7048 return nb_cli_apply_changes(vty
, base_xpath
);
7051 ALIAS_YANG(no_neighbor_description
, no_neighbor_description_comment_cmd
,
7052 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
7053 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7054 "Neighbor specific description\n"
7055 "Up to 80 characters describing this neighbor\n")
7057 #define BGP_UPDATE_SOURCE_HELP_STR \
7060 "Interface name (requires zebra to be running)\n"
7062 DEFUN_YANG (neighbor_update_source
,
7063 neighbor_update_source_cmd
,
7064 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
7065 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7066 "Source of routing updates\n"
7067 BGP_UPDATE_SOURCE_HELP_STR
)
7072 char base_xpath
[XPATH_MAXLEN
];
7074 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7075 sizeof(base_xpath
), NULL
)
7077 return CMD_WARNING_CONFIG_FAILED
;
7079 if (str2sockunion(argv
[idx_peer_2
]->arg
, &su
) == 0)
7080 nb_cli_enqueue_change(vty
, "./update-source/ip", NB_OP_MODIFY
,
7081 argv
[idx_peer_2
]->arg
);
7083 nb_cli_enqueue_change(vty
, "./update-source/interface",
7084 NB_OP_MODIFY
, argv
[idx_peer_2
]->arg
);
7086 return nb_cli_apply_changes(vty
, base_xpath
);
7089 DEFUN_YANG (no_neighbor_update_source
,
7090 no_neighbor_update_source_cmd
,
7091 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
7094 "Source of routing updates\n"
7095 BGP_UPDATE_SOURCE_HELP_STR
)
7098 char base_xpath
[XPATH_MAXLEN
];
7100 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7101 sizeof(base_xpath
), NULL
)
7103 return CMD_WARNING_CONFIG_FAILED
;
7105 nb_cli_enqueue_change(vty
, "./update-source/ip", NB_OP_DESTROY
, NULL
);
7106 nb_cli_enqueue_change(vty
, "./update-source/interface", NB_OP_DESTROY
,
7109 return nb_cli_apply_changes(vty
, base_xpath
);
7112 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
7113 afi_t afi
, safi_t safi
,
7114 const char *rmap
, int set
)
7118 struct route_map
*route_map
= NULL
;
7120 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
7122 return CMD_WARNING_CONFIG_FAILED
;
7126 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
7127 ret
= peer_default_originate_set(peer
, afi
, safi
,
7130 ret
= peer_default_originate_unset(peer
, afi
, safi
);
7132 return bgp_vty_return(vty
, ret
);
7135 /* neighbor default-originate. */
7136 DEFUN (neighbor_default_originate
,
7137 neighbor_default_originate_cmd
,
7138 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
7141 "Originate default route to this neighbor\n")
7144 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
7146 bgp_node_safi(vty
), NULL
, 1);
7149 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
7150 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
7151 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7152 "Originate default route to this neighbor\n")
7154 DEFUN (neighbor_default_originate_rmap
,
7155 neighbor_default_originate_rmap_cmd
,
7156 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
7159 "Originate default route to this neighbor\n"
7160 "Route-map to specify criteria to originate default\n"
7165 return peer_default_originate_set_vty(
7166 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7167 argv
[idx_word
]->arg
, 1);
7171 neighbor_default_originate_rmap
,
7172 neighbor_default_originate_rmap_hidden_cmd
,
7173 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
7174 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7175 "Originate default route to this neighbor\n"
7176 "Route-map to specify criteria to originate default\n"
7179 DEFUN (no_neighbor_default_originate
,
7180 no_neighbor_default_originate_cmd
,
7181 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
7185 "Originate default route to this neighbor\n"
7186 "Route-map to specify criteria to originate default\n"
7190 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
7192 bgp_node_safi(vty
), NULL
, 0);
7196 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
7197 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
7198 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7199 "Originate default route to this neighbor\n"
7200 "Route-map to specify criteria to originate default\n"
7204 /* Set specified peer's BGP port. */
7205 DEFUN_YANG (neighbor_port
,
7207 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
7210 "Neighbor's BGP port\n"
7211 "TCP port number\n")
7215 char base_xpath
[XPATH_MAXLEN
];
7217 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7218 argv
[idx_ip
]->arg
, "");
7220 nb_cli_enqueue_change(vty
, "./local-port", NB_OP_MODIFY
,
7221 argv
[idx_number
]->arg
);
7223 return nb_cli_apply_changes(vty
, base_xpath
);
7226 DEFUN_YANG (no_neighbor_port
,
7227 no_neighbor_port_cmd
,
7228 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
7229 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR
7230 "Neighbor's BGP port\n"
7231 "TCP port number\n")
7234 char base_xpath
[XPATH_MAXLEN
];
7236 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7237 argv
[idx_ip
]->arg
, "");
7239 nb_cli_enqueue_change(vty
, "./local-port", NB_OP_DESTROY
, NULL
);
7241 return nb_cli_apply_changes(vty
, base_xpath
);
7244 DEFUN_YANG (neighbor_weight
,
7245 neighbor_weight_cmd
,
7246 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7247 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7248 "Set default weight for routes from this neighbor\n"
7253 char base_xpath
[XPATH_MAXLEN
];
7254 char af_xpath
[XPATH_MAXLEN
];
7255 char attr_xpath
[XPATH_MAXLEN
];
7256 afi_t afi
= bgp_node_afi(vty
);
7257 safi_t safi
= bgp_node_safi(vty
);
7259 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
7260 yang_afi_safi_value2identity(afi
, safi
));
7262 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7263 sizeof(base_xpath
), af_xpath
)
7265 return CMD_WARNING_CONFIG_FAILED
;
7267 snprintf(attr_xpath
, sizeof(attr_xpath
), "./%s/weight/weight-attribute",
7268 bgp_afi_safi_get_container_str(afi
, safi
));
7270 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
,
7271 argv
[idx_number
]->arg
);
7273 return nb_cli_apply_changes(vty
, base_xpath
);
7276 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
7277 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7278 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7279 "Set default weight for routes from this neighbor\n"
7282 DEFUN_YANG (no_neighbor_weight
,
7283 no_neighbor_weight_cmd
,
7284 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7285 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7286 "Set default weight for routes from this neighbor\n"
7290 char base_xpath
[XPATH_MAXLEN
];
7291 char af_xpath
[XPATH_MAXLEN
];
7292 char attr_xpath
[XPATH_MAXLEN
];
7293 afi_t afi
= bgp_node_afi(vty
);
7294 safi_t safi
= bgp_node_safi(vty
);
7296 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
7297 yang_afi_safi_value2identity(afi
, safi
));
7299 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7300 sizeof(base_xpath
), af_xpath
)
7302 return CMD_WARNING_CONFIG_FAILED
;
7304 snprintf(attr_xpath
, sizeof(attr_xpath
), "./%s/weight/weight-attribute",
7305 bgp_afi_safi_get_container_str(afi
, safi
));
7307 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_DESTROY
, NULL
);
7309 return nb_cli_apply_changes(vty
, base_xpath
);
7312 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
7313 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7314 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7315 "Set default weight for routes from this neighbor\n"
7319 /* Override capability negotiation. */
7320 DEFUN_YANG (neighbor_override_capability
,
7321 neighbor_override_capability_cmd
,
7322 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7325 "Override capability negotiation result\n")
7328 char base_xpath
[XPATH_MAXLEN
];
7330 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7331 sizeof(base_xpath
), NULL
)
7333 return CMD_WARNING_CONFIG_FAILED
;
7335 nb_cli_enqueue_change(
7336 vty
, "./capability-options/override-capability",
7337 NB_OP_MODIFY
, "true");
7339 return nb_cli_apply_changes(vty
, base_xpath
);
7342 DEFUN_YANG (no_neighbor_override_capability
,
7343 no_neighbor_override_capability_cmd
,
7344 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7348 "Override capability negotiation result\n")
7351 char base_xpath
[XPATH_MAXLEN
];
7353 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7354 sizeof(base_xpath
), NULL
)
7356 return CMD_WARNING_CONFIG_FAILED
;
7358 nb_cli_enqueue_change(
7359 vty
, "./capability-options/override-capability",
7360 NB_OP_MODIFY
, "false");
7362 return nb_cli_apply_changes(vty
, base_xpath
);
7365 DEFUN_YANG (neighbor_strict_capability
,
7366 neighbor_strict_capability_cmd
,
7367 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7370 "Strict capability negotiation match\n")
7373 char base_xpath
[XPATH_MAXLEN
];
7375 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7376 sizeof(base_xpath
), NULL
)
7378 return CMD_WARNING_CONFIG_FAILED
;
7380 nb_cli_enqueue_change(
7381 vty
, "./capability-options/strict-capability",
7382 NB_OP_MODIFY
, "true");
7384 return nb_cli_apply_changes(vty
, base_xpath
);
7387 DEFUN_YANG (no_neighbor_strict_capability
,
7388 no_neighbor_strict_capability_cmd
,
7389 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7393 "Strict capability negotiation match\n")
7396 char base_xpath
[XPATH_MAXLEN
];
7398 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7399 sizeof(base_xpath
), NULL
)
7401 return CMD_WARNING_CONFIG_FAILED
;
7403 nb_cli_enqueue_change(
7404 vty
, "./capability-options/strict-capability",
7405 NB_OP_MODIFY
, "false");
7407 return nb_cli_apply_changes(vty
, base_xpath
);
7410 DEFUN_YANG (neighbor_timers
,
7411 neighbor_timers_cmd
,
7412 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7413 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7414 "BGP per neighbor timers\n"
7415 "Keepalive interval\n"
7420 int idx_number_2
= 4;
7421 char base_xpath
[XPATH_MAXLEN
];
7423 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7424 sizeof(base_xpath
), NULL
)
7426 return CMD_WARNING_CONFIG_FAILED
;
7428 nb_cli_enqueue_change(vty
, "./timers/keepalive", NB_OP_MODIFY
,
7429 argv
[idx_number
]->arg
);
7431 nb_cli_enqueue_change(vty
, "./timers/hold-time", NB_OP_MODIFY
,
7432 argv
[idx_number_2
]->arg
);
7434 return nb_cli_apply_changes(vty
, base_xpath
);
7437 DEFUN_YANG (no_neighbor_timers
,
7438 no_neighbor_timers_cmd
,
7439 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7440 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7441 "BGP per neighbor timers\n"
7442 "Keepalive interval\n"
7446 char base_xpath
[XPATH_MAXLEN
];
7448 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7449 sizeof(base_xpath
), NULL
)
7451 return CMD_WARNING_CONFIG_FAILED
;
7453 nb_cli_enqueue_change(vty
, "./timers/hold-time", NB_OP_DESTROY
, NULL
);
7455 nb_cli_enqueue_change(vty
, "./timers/keepalive", NB_OP_DESTROY
, NULL
);
7457 return nb_cli_apply_changes(vty
, base_xpath
);
7460 DEFUN_YANG (neighbor_timers_connect
,
7461 neighbor_timers_connect_cmd
,
7462 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7463 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7464 "BGP per neighbor timers\n"
7465 "BGP connect timer\n"
7470 char base_xpath
[XPATH_MAXLEN
];
7472 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7473 sizeof(base_xpath
), NULL
)
7475 return CMD_WARNING_CONFIG_FAILED
;
7477 nb_cli_enqueue_change(vty
, "./timers/connect-time", NB_OP_MODIFY
,
7478 argv
[idx_number
]->arg
);
7480 return nb_cli_apply_changes(vty
, base_xpath
);
7483 DEFUN_YANG (no_neighbor_timers_connect
,
7484 no_neighbor_timers_connect_cmd
,
7485 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7486 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7487 "BGP per neighbor timers\n"
7488 "BGP connect timer\n"
7492 char base_xpath
[XPATH_MAXLEN
];
7494 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7495 sizeof(base_xpath
), NULL
)
7497 return CMD_WARNING_CONFIG_FAILED
;
7499 nb_cli_enqueue_change(vty
, "./timers/connect-time", NB_OP_DESTROY
,
7502 return nb_cli_apply_changes(vty
, base_xpath
);
7505 DEFPY (neighbor_timers_delayopen
,
7506 neighbor_timers_delayopen_cmd
,
7507 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7510 "BGP per neighbor timers\n"
7511 "RFC 4271 DelayOpenTimer\n"
7512 "DelayOpenTime timer interval\n")
7516 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7518 return CMD_WARNING_CONFIG_FAILED
;
7521 if (peer_timers_delayopen_unset(peer
))
7522 return CMD_WARNING_CONFIG_FAILED
;
7524 if (peer_timers_delayopen_set(peer
, interval
))
7525 return CMD_WARNING_CONFIG_FAILED
;
7531 DEFPY (no_neighbor_timers_delayopen
,
7532 no_neighbor_timers_delayopen_cmd
,
7533 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7537 "BGP per neighbor timers\n"
7538 "RFC 4271 DelayOpenTimer\n"
7539 "DelayOpenTime timer interval\n")
7543 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7545 return CMD_WARNING_CONFIG_FAILED
;
7547 if (peer_timers_delayopen_unset(peer
))
7548 return CMD_WARNING_CONFIG_FAILED
;
7553 DEFUN_YANG (neighbor_advertise_interval
,
7554 neighbor_advertise_interval_cmd
,
7555 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7556 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7557 "Minimum interval between sending BGP routing updates\n"
7558 "time in seconds\n")
7562 char base_xpath
[XPATH_MAXLEN
];
7564 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7565 sizeof(base_xpath
), NULL
)
7567 return CMD_WARNING_CONFIG_FAILED
;
7569 nb_cli_enqueue_change(vty
, "./timers/advertise-interval", NB_OP_MODIFY
,
7570 argv
[idx_number
]->arg
);
7572 return nb_cli_apply_changes(vty
, base_xpath
);
7575 DEFUN_YANG (no_neighbor_advertise_interval
,
7576 no_neighbor_advertise_interval_cmd
,
7577 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7578 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7579 "Minimum interval between sending BGP routing updates\n"
7580 "time in seconds\n")
7583 char base_xpath
[XPATH_MAXLEN
];
7585 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7586 sizeof(base_xpath
), NULL
)
7588 return CMD_WARNING_CONFIG_FAILED
;
7590 nb_cli_enqueue_change(vty
, "./timers/advertise-interval", NB_OP_DESTROY
,
7593 return nb_cli_apply_changes(vty
, base_xpath
);
7597 /* Time to wait before processing route-map updates */
7598 DEFUN (bgp_set_route_map_delay_timer
,
7599 bgp_set_route_map_delay_timer_cmd
,
7600 "bgp route-map delay-timer (0-600)",
7602 "BGP route-map delay timer\n"
7603 "Time in secs to wait before processing route-map changes\n"
7604 "0 disables the timer, no route updates happen when route-maps change\n")
7607 uint32_t rmap_delay_timer
;
7609 if (argv
[idx_number
]->arg
) {
7610 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7611 bm
->rmap_update_timer
= rmap_delay_timer
;
7613 /* if the dynamic update handling is being disabled, and a timer
7615 * running, stop the timer and act as if the timer has already
7618 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7619 BGP_TIMER_OFF(bm
->t_rmap_update
);
7620 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7625 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7626 return CMD_WARNING_CONFIG_FAILED
;
7630 DEFUN (no_bgp_set_route_map_delay_timer
,
7631 no_bgp_set_route_map_delay_timer_cmd
,
7632 "no bgp route-map delay-timer [(0-600)]",
7635 "Default BGP route-map delay timer\n"
7636 "Reset to default time to wait for processing route-map changes\n"
7637 "0 disables the timer, no route updates happen when route-maps change\n")
7640 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7645 DEFUN_YANG (neighbor_interface
,
7646 neighbor_interface_cmd
,
7647 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7648 NEIGHBOR_STR NEIGHBOR_ADDR_STR
7654 char base_xpath
[XPATH_MAXLEN
];
7656 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7657 argv
[idx_ip
]->arg
, "");
7659 nb_cli_enqueue_change(vty
, "./local-interface", NB_OP_MODIFY
,
7660 argv
[idx_word
]->arg
);
7662 return nb_cli_apply_changes(vty
, base_xpath
);
7665 DEFUN_YANG (no_neighbor_interface
,
7666 no_neighbor_interface_cmd
,
7667 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
7668 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7673 char base_xpath
[XPATH_MAXLEN
];
7675 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7676 argv
[idx_peer
]->arg
, "");
7678 nb_cli_enqueue_change(vty
, "./local-interface", NB_OP_DESTROY
, NULL
);
7680 return nb_cli_apply_changes(vty
, base_xpath
);
7683 DEFUN (neighbor_distribute_list
,
7684 neighbor_distribute_list_cmd
,
7685 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7688 "Filter updates to/from this neighbor\n"
7689 "IP access-list number\n"
7690 "IP access-list number (expanded range)\n"
7691 "IP Access-list name\n"
7692 "Filter incoming updates\n"
7693 "Filter outgoing updates\n")
7700 const char *pstr
= argv
[idx_peer
]->arg
;
7701 const char *acl
= argv
[idx_acl
]->arg
;
7702 const char *inout
= argv
[argc
- 1]->text
;
7704 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7706 return CMD_WARNING_CONFIG_FAILED
;
7708 /* Check filter direction. */
7709 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7710 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7713 return bgp_vty_return(vty
, ret
);
7717 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7718 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7719 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7720 "Filter updates to/from this neighbor\n"
7721 "IP access-list number\n"
7722 "IP access-list number (expanded range)\n"
7723 "IP Access-list name\n"
7724 "Filter incoming updates\n"
7725 "Filter outgoing updates\n")
7727 DEFUN (no_neighbor_distribute_list
,
7728 no_neighbor_distribute_list_cmd
,
7729 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7733 "Filter updates to/from this neighbor\n"
7734 "IP access-list number\n"
7735 "IP access-list number (expanded range)\n"
7736 "IP Access-list name\n"
7737 "Filter incoming updates\n"
7738 "Filter outgoing updates\n")
7744 const char *pstr
= argv
[idx_peer
]->arg
;
7745 const char *inout
= argv
[argc
- 1]->text
;
7747 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7749 return CMD_WARNING_CONFIG_FAILED
;
7751 /* Check filter direction. */
7752 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7753 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7756 return bgp_vty_return(vty
, ret
);
7760 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7761 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7762 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7763 "Filter updates to/from this neighbor\n"
7764 "IP access-list number\n"
7765 "IP access-list number (expanded range)\n"
7766 "IP Access-list name\n"
7767 "Filter incoming updates\n"
7768 "Filter outgoing updates\n")
7770 /* Set prefix list to the peer. */
7771 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7772 afi_t afi
, safi_t safi
,
7773 const char *name_str
,
7774 const char *direct_str
)
7777 int direct
= FILTER_IN
;
7780 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7782 return CMD_WARNING_CONFIG_FAILED
;
7784 /* Check filter direction. */
7785 if (strncmp(direct_str
, "i", 1) == 0)
7787 else if (strncmp(direct_str
, "o", 1) == 0)
7788 direct
= FILTER_OUT
;
7790 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7792 return bgp_vty_return(vty
, ret
);
7795 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7796 afi_t afi
, safi_t safi
,
7797 const char *direct_str
)
7801 int direct
= FILTER_IN
;
7803 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7805 return CMD_WARNING_CONFIG_FAILED
;
7807 /* Check filter direction. */
7808 if (strncmp(direct_str
, "i", 1) == 0)
7810 else if (strncmp(direct_str
, "o", 1) == 0)
7811 direct
= FILTER_OUT
;
7813 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7815 return bgp_vty_return(vty
, ret
);
7818 DEFUN (neighbor_prefix_list
,
7819 neighbor_prefix_list_cmd
,
7820 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7823 "Filter updates to/from this neighbor\n"
7824 "Name of a prefix list\n"
7825 "Filter incoming updates\n"
7826 "Filter outgoing updates\n")
7831 return peer_prefix_list_set_vty(
7832 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7833 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7836 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7837 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7838 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7839 "Filter updates to/from this neighbor\n"
7840 "Name of a prefix list\n"
7841 "Filter incoming updates\n"
7842 "Filter outgoing updates\n")
7844 DEFUN (no_neighbor_prefix_list
,
7845 no_neighbor_prefix_list_cmd
,
7846 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7850 "Filter updates to/from this neighbor\n"
7851 "Name of a prefix list\n"
7852 "Filter incoming updates\n"
7853 "Filter outgoing updates\n")
7857 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7858 bgp_node_afi(vty
), bgp_node_safi(vty
),
7859 argv
[idx_in_out
]->arg
);
7862 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7863 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7864 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7865 "Filter updates to/from this neighbor\n"
7866 "Name of a prefix list\n"
7867 "Filter incoming updates\n"
7868 "Filter outgoing updates\n")
7870 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7871 safi_t safi
, const char *name_str
,
7872 const char *direct_str
)
7876 int direct
= FILTER_IN
;
7878 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7880 return CMD_WARNING_CONFIG_FAILED
;
7882 /* Check filter direction. */
7883 if (strncmp(direct_str
, "i", 1) == 0)
7885 else if (strncmp(direct_str
, "o", 1) == 0)
7886 direct
= FILTER_OUT
;
7888 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7890 return bgp_vty_return(vty
, ret
);
7893 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7894 safi_t safi
, const char *direct_str
)
7898 int direct
= FILTER_IN
;
7900 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7902 return CMD_WARNING_CONFIG_FAILED
;
7904 /* Check filter direction. */
7905 if (strncmp(direct_str
, "i", 1) == 0)
7907 else if (strncmp(direct_str
, "o", 1) == 0)
7908 direct
= FILTER_OUT
;
7910 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7912 return bgp_vty_return(vty
, ret
);
7915 DEFUN (neighbor_filter_list
,
7916 neighbor_filter_list_cmd
,
7917 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7920 "Establish BGP filters\n"
7921 "AS path access-list name\n"
7922 "Filter incoming routes\n"
7923 "Filter outgoing routes\n")
7928 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7929 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7930 argv
[idx_in_out
]->arg
);
7933 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7934 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7935 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7936 "Establish BGP filters\n"
7937 "AS path access-list name\n"
7938 "Filter incoming routes\n"
7939 "Filter outgoing routes\n")
7941 DEFUN (no_neighbor_filter_list
,
7942 no_neighbor_filter_list_cmd
,
7943 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7947 "Establish BGP filters\n"
7948 "AS path access-list name\n"
7949 "Filter incoming routes\n"
7950 "Filter outgoing routes\n")
7954 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7955 bgp_node_afi(vty
), bgp_node_safi(vty
),
7956 argv
[idx_in_out
]->arg
);
7959 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7960 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7961 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7962 "Establish BGP filters\n"
7963 "AS path access-list name\n"
7964 "Filter incoming routes\n"
7965 "Filter outgoing routes\n")
7967 /* Set advertise-map to the peer. */
7968 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7969 afi_t afi
, safi_t safi
,
7970 const char *advertise_str
,
7971 const char *condition_str
, bool condition
,
7974 int ret
= CMD_WARNING_CONFIG_FAILED
;
7976 struct route_map
*advertise_map
;
7977 struct route_map
*condition_map
;
7979 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7983 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7984 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7987 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7988 advertise_map
, condition_str
,
7989 condition_map
, condition
);
7991 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7992 advertise_map
, condition_str
,
7993 condition_map
, condition
);
7995 return bgp_vty_return(vty
, ret
);
7998 DEFPY (neighbor_advertise_map
,
7999 neighbor_advertise_map_cmd
,
8000 "[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",
8004 "Route-map to conditionally advertise routes\n"
8005 "Name of advertise map\n"
8006 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
8007 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
8008 "Name of the exist or non exist map\n")
8010 bool condition
= CONDITION_EXIST
;
8012 if (!strcmp(exist
, "non-exist-map"))
8013 condition
= CONDITION_NON_EXIST
;
8015 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
8016 bgp_node_safi(vty
), advertise_str
,
8017 condition_str
, condition
, !no
);
8020 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
8021 "[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",
8022 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8023 "Route-map to conditionally advertise routes\n"
8024 "Name of advertise map\n"
8025 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
8026 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
8027 "Name of the exist or non exist map\n")
8029 /* Set route-map to the peer. */
8030 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
8031 afi_t afi
, safi_t safi
, const char *name_str
,
8032 const char *direct_str
)
8036 int direct
= RMAP_IN
;
8037 struct route_map
*route_map
;
8039 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8041 return CMD_WARNING_CONFIG_FAILED
;
8043 /* Check filter direction. */
8044 if (strncmp(direct_str
, "in", 2) == 0)
8046 else if (strncmp(direct_str
, "o", 1) == 0)
8049 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
8050 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
8052 return bgp_vty_return(vty
, ret
);
8055 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
8056 afi_t afi
, safi_t safi
,
8057 const char *direct_str
)
8061 int direct
= RMAP_IN
;
8063 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8065 return CMD_WARNING_CONFIG_FAILED
;
8067 /* Check filter direction. */
8068 if (strncmp(direct_str
, "in", 2) == 0)
8070 else if (strncmp(direct_str
, "o", 1) == 0)
8073 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
8075 return bgp_vty_return(vty
, ret
);
8078 DEFUN (neighbor_route_map
,
8079 neighbor_route_map_cmd
,
8080 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
8083 "Apply route map to neighbor\n"
8084 "Name of route map\n"
8085 "Apply map to incoming routes\n"
8086 "Apply map to outbound routes\n")
8091 return peer_route_map_set_vty(
8092 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8093 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
8096 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
8097 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
8098 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8099 "Apply route map to neighbor\n"
8100 "Name of route map\n"
8101 "Apply map to incoming routes\n"
8102 "Apply map to outbound routes\n")
8104 DEFUN (no_neighbor_route_map
,
8105 no_neighbor_route_map_cmd
,
8106 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
8110 "Apply route map to neighbor\n"
8111 "Name of route map\n"
8112 "Apply map to incoming routes\n"
8113 "Apply map to outbound routes\n")
8117 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
8118 bgp_node_afi(vty
), bgp_node_safi(vty
),
8119 argv
[idx_in_out
]->arg
);
8122 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
8123 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
8124 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8125 "Apply route map to neighbor\n"
8126 "Name of route map\n"
8127 "Apply map to incoming routes\n"
8128 "Apply map to outbound routes\n")
8130 /* Set unsuppress-map to the peer. */
8131 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
8132 afi_t afi
, safi_t safi
,
8133 const char *name_str
)
8137 struct route_map
*route_map
;
8139 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8141 return CMD_WARNING_CONFIG_FAILED
;
8143 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
8144 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
8146 return bgp_vty_return(vty
, ret
);
8149 /* Unset route-map from the peer. */
8150 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
8151 afi_t afi
, safi_t safi
)
8156 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8158 return CMD_WARNING_CONFIG_FAILED
;
8160 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
8162 return bgp_vty_return(vty
, ret
);
8165 DEFUN (neighbor_unsuppress_map
,
8166 neighbor_unsuppress_map_cmd
,
8167 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8170 "Route-map to selectively unsuppress suppressed routes\n"
8171 "Name of route map\n")
8175 return peer_unsuppress_map_set_vty(
8176 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8177 argv
[idx_word
]->arg
);
8180 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
8181 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8182 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8183 "Route-map to selectively unsuppress suppressed routes\n"
8184 "Name of route map\n")
8186 DEFUN (no_neighbor_unsuppress_map
,
8187 no_neighbor_unsuppress_map_cmd
,
8188 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8192 "Route-map to selectively unsuppress suppressed routes\n"
8193 "Name of route map\n")
8196 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
8198 bgp_node_safi(vty
));
8201 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
8202 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8203 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8204 "Route-map to selectively unsuppress suppressed routes\n"
8205 "Name of route map\n")
8207 /* Maximum number of prefix to be sent to the neighbor. */
8208 DEFUN_YANG(neighbor_maximum_prefix_out
,
8209 neighbor_maximum_prefix_out_cmd
,
8210 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
8211 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8212 "Maximum number of prefixes to be sent to this peer\n"
8213 "Maximum no. of prefix limit\n")
8215 char base_xpath
[XPATH_MAXLEN
];
8216 char af_xpath
[XPATH_MAXLEN
];
8217 char attr_xpath
[XPATH_MAXLEN
];
8220 afi_t afi
= bgp_node_afi(vty
);
8221 safi_t safi
= bgp_node_safi(vty
);
8223 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8224 yang_afi_safi_value2identity(afi
, safi
));
8225 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8226 sizeof(base_xpath
), af_xpath
)
8228 return CMD_WARNING_CONFIG_FAILED
;
8230 snprintf(attr_xpath
, sizeof(attr_xpath
),
8231 "/%s/prefix-limit/direction-list[direction='out']",
8232 bgp_afi_safi_get_container_str(afi
, safi
));
8233 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8235 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8237 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8238 argv
[idx_number
]->arg
);
8240 return nb_cli_apply_changes(vty
, base_xpath
);
8243 DEFUN_YANG(no_neighbor_maximum_prefix_out
,
8244 no_neighbor_maximum_prefix_out_cmd
,
8245 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out",
8246 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8247 "Maximum number of prefixes to be sent to this peer\n")
8249 char base_xpath
[XPATH_MAXLEN
];
8250 char af_xpath
[XPATH_MAXLEN
];
8251 char attr_xpath
[XPATH_MAXLEN
];
8253 afi_t afi
= bgp_node_afi(vty
);
8254 safi_t safi
= bgp_node_safi(vty
);
8256 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8257 yang_afi_safi_value2identity(afi
, safi
));
8258 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8259 sizeof(base_xpath
), af_xpath
)
8261 return CMD_WARNING_CONFIG_FAILED
;
8263 snprintf(attr_xpath
, sizeof(attr_xpath
),
8264 "/%s/prefix-limit/direction-list[direction='out']",
8265 bgp_afi_safi_get_container_str(afi
, safi
));
8266 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8268 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
8270 return nb_cli_apply_changes(vty
, base_xpath
);
8273 /* Maximum number of prefix configuration. Prefix count is different
8274 for each peer configuration. So this configuration can be set for
8275 each peer configuration. */
8276 DEFUN_YANG(neighbor_maximum_prefix
,
8277 neighbor_maximum_prefix_cmd
,
8278 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8279 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8280 "Maximum number of prefix accept from this peer\n"
8281 "maximum no. of prefix limit\n"
8282 "Force checking all received routes not only accepted\n")
8287 char base_xpath
[XPATH_MAXLEN
];
8288 char af_xpath
[XPATH_MAXLEN
];
8289 char attr_xpath
[XPATH_MAXLEN
];
8290 afi_t afi
= bgp_node_afi(vty
);
8291 safi_t safi
= bgp_node_safi(vty
);
8293 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8294 yang_afi_safi_value2identity(afi
, safi
));
8295 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8296 sizeof(base_xpath
), af_xpath
)
8298 return CMD_WARNING_CONFIG_FAILED
;
8300 snprintf(attr_xpath
, sizeof(attr_xpath
),
8301 "/%s/prefix-limit/direction-list[direction='in']",
8302 bgp_afi_safi_get_container_str(afi
, safi
));
8303 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8305 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8307 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8308 argv
[idx_number
]->arg
);
8309 if (argv_find(argv
, argc
, "force", &idx_force
))
8310 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8313 return nb_cli_apply_changes(vty
, base_xpath
);
8316 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8317 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8318 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8319 "Maximum number of prefix accept from this peer\n"
8320 "maximum no. of prefix limit\n"
8321 "Force checking all received routes not only accepted\n")
8323 DEFUN_YANG(neighbor_maximum_prefix_threshold
,
8324 neighbor_maximum_prefix_threshold_cmd
,
8325 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8326 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8327 "Maximum number of prefix accept from this peer\n"
8328 "maximum no. of prefix limit\n"
8329 "Threshold value (%) at which to generate a warning msg\n"
8330 "Force checking all received routes not only accepted\n")
8334 int idx_number_2
= 4;
8336 char base_xpath
[XPATH_MAXLEN
];
8337 char af_xpath
[XPATH_MAXLEN
];
8338 char attr_xpath
[XPATH_MAXLEN
];
8339 afi_t afi
= bgp_node_afi(vty
);
8340 safi_t safi
= bgp_node_safi(vty
);
8342 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8343 yang_afi_safi_value2identity(afi
, safi
));
8344 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8345 sizeof(base_xpath
), af_xpath
)
8347 return CMD_WARNING_CONFIG_FAILED
;
8349 snprintf(attr_xpath
, sizeof(attr_xpath
),
8350 "/%s/prefix-limit/direction-list[direction='in']",
8351 bgp_afi_safi_get_container_str(afi
, safi
));
8352 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8354 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8356 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8357 argv
[idx_number
]->arg
);
8359 nb_cli_enqueue_change(vty
, "./options/shutdown-threshold-pct",
8360 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8362 if (argv_find(argv
, argc
, "force", &idx_force
))
8363 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8366 return nb_cli_apply_changes(vty
, base_xpath
);
8370 neighbor_maximum_prefix_threshold
,
8371 neighbor_maximum_prefix_threshold_hidden_cmd
,
8372 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8373 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8374 "Maximum number of prefix accept from this peer\n"
8375 "maximum no. of prefix limit\n"
8376 "Threshold value (%) at which to generate a warning msg\n"
8377 "Force checking all received routes not only accepted\n")
8379 DEFUN_YANG(neighbor_maximum_prefix_warning
,
8380 neighbor_maximum_prefix_warning_cmd
,
8381 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8382 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8383 "Maximum number of prefix accept from this peer\n"
8384 "maximum no. of prefix limit\n"
8385 "Only give warning message when limit is exceeded\n"
8386 "Force checking all received routes not only accepted\n")
8391 char base_xpath
[XPATH_MAXLEN
];
8392 char af_xpath
[XPATH_MAXLEN
];
8393 char attr_xpath
[XPATH_MAXLEN
];
8394 afi_t afi
= bgp_node_afi(vty
);
8395 safi_t safi
= bgp_node_safi(vty
);
8397 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8398 yang_afi_safi_value2identity(afi
, safi
));
8399 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8400 sizeof(base_xpath
), af_xpath
)
8402 return CMD_WARNING_CONFIG_FAILED
;
8404 snprintf(attr_xpath
, sizeof(attr_xpath
),
8405 "/%s/prefix-limit/direction-list[direction='in']",
8406 bgp_afi_safi_get_container_str(afi
, safi
));
8407 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8409 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8411 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8412 argv
[idx_number
]->arg
);
8414 nb_cli_enqueue_change(vty
, "./options/warning-only", NB_OP_MODIFY
,
8416 if (argv_find(argv
, argc
, "force", &idx_force
))
8417 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8420 return nb_cli_apply_changes(vty
, base_xpath
);
8424 neighbor_maximum_prefix_warning
,
8425 neighbor_maximum_prefix_warning_hidden_cmd
,
8426 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8427 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8428 "Maximum number of prefix accept from this peer\n"
8429 "maximum no. of prefix limit\n"
8430 "Only give warning message when limit is exceeded\n"
8431 "Force checking all received routes not only accepted\n")
8433 DEFUN_YANG(neighbor_maximum_prefix_threshold_warning
,
8434 neighbor_maximum_prefix_threshold_warning_cmd
,
8435 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8436 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8437 "Maximum number of prefix accept from this peer\n"
8438 "maximum no. of prefix limit\n"
8439 "Threshold value (%) at which to generate a warning msg\n"
8440 "Only give warning message when limit is exceeded\n"
8441 "Force checking all received routes not only accepted\n")
8445 int idx_number_2
= 4;
8447 char base_xpath
[XPATH_MAXLEN
];
8448 char af_xpath
[XPATH_MAXLEN
];
8449 char attr_xpath
[XPATH_MAXLEN
];
8450 afi_t afi
= bgp_node_afi(vty
);
8451 safi_t safi
= bgp_node_safi(vty
);
8453 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8454 yang_afi_safi_value2identity(afi
, safi
));
8455 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8456 sizeof(base_xpath
), af_xpath
)
8458 return CMD_WARNING_CONFIG_FAILED
;
8460 snprintf(attr_xpath
, sizeof(attr_xpath
),
8461 "/%s/prefix-limit/direction-list[direction='in']",
8462 bgp_afi_safi_get_container_str(afi
, safi
));
8463 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8465 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8467 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8468 argv
[idx_number
]->arg
);
8469 nb_cli_enqueue_change(vty
, "./options/tw-shutdown-threshold-pct",
8470 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8471 nb_cli_enqueue_change(vty
, "./options/tw-warning-only", NB_OP_MODIFY
,
8473 if (argv_find(argv
, argc
, "force", &idx_force
))
8474 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8477 return nb_cli_apply_changes(vty
, base_xpath
);
8481 neighbor_maximum_prefix_threshold_warning
,
8482 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8483 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8484 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8485 "Maximum number of prefix accept from this peer\n"
8486 "maximum no. of prefix limit\n"
8487 "Threshold value (%) at which to generate a warning msg\n"
8488 "Only give warning message when limit is exceeded\n"
8489 "Force checking all received routes not only accepted\n")
8491 DEFUN_YANG(neighbor_maximum_prefix_restart
,
8492 neighbor_maximum_prefix_restart_cmd
,
8493 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8494 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8495 "Maximum number of prefix accept from this peer\n"
8496 "maximum no. of prefix limit\n"
8497 "Restart bgp connection after limit is exceeded\n"
8498 "Restart interval in minutes\n"
8499 "Force checking all received routes not only accepted\n")
8503 int idx_number_2
= 5;
8505 char base_xpath
[XPATH_MAXLEN
];
8506 char af_xpath
[XPATH_MAXLEN
];
8507 char attr_xpath
[XPATH_MAXLEN
];
8508 afi_t afi
= bgp_node_afi(vty
);
8509 safi_t safi
= bgp_node_safi(vty
);
8511 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8512 yang_afi_safi_value2identity(afi
, safi
));
8513 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8514 sizeof(base_xpath
), af_xpath
)
8516 return CMD_WARNING_CONFIG_FAILED
;
8518 snprintf(attr_xpath
, sizeof(attr_xpath
),
8519 "/%s/prefix-limit/direction-list[direction='in']",
8520 bgp_afi_safi_get_container_str(afi
, safi
));
8521 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8523 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8525 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8526 argv
[idx_number
]->arg
);
8527 nb_cli_enqueue_change(vty
, "./options/restart-timer", NB_OP_MODIFY
,
8528 argv
[idx_number_2
]->arg
);
8529 if (argv_find(argv
, argc
, "force", &idx_force
))
8530 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8533 return nb_cli_apply_changes(vty
, base_xpath
);
8537 neighbor_maximum_prefix_restart
,
8538 neighbor_maximum_prefix_restart_hidden_cmd
,
8539 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8540 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8541 "Maximum number of prefix accept from this peer\n"
8542 "maximum no. of prefix limit\n"
8543 "Restart bgp connection after limit is exceeded\n"
8544 "Restart interval in minutes\n"
8545 "Force checking all received routes not only accepted\n")
8547 DEFUN_YANG(neighbor_maximum_prefix_threshold_restart
,
8548 neighbor_maximum_prefix_threshold_restart_cmd
,
8549 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8550 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8551 "Maximum number of prefixes to accept from this peer\n"
8552 "maximum no. of prefix limit\n"
8553 "Threshold value (%) at which to generate a warning msg\n"
8554 "Restart bgp connection after limit is exceeded\n"
8555 "Restart interval in minutes\n"
8556 "Force checking all received routes not only accepted\n")
8560 int idx_number_2
= 4;
8561 int idx_number_3
= 6;
8563 char base_xpath
[XPATH_MAXLEN
];
8564 char af_xpath
[XPATH_MAXLEN
];
8565 char attr_xpath
[XPATH_MAXLEN
];
8566 afi_t afi
= bgp_node_afi(vty
);
8567 safi_t safi
= bgp_node_safi(vty
);
8569 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8570 yang_afi_safi_value2identity(afi
, safi
));
8571 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8572 sizeof(base_xpath
), af_xpath
)
8574 return CMD_WARNING_CONFIG_FAILED
;
8576 snprintf(attr_xpath
, sizeof(attr_xpath
),
8577 "/%s/prefix-limit/direction-list[direction='in']",
8578 bgp_afi_safi_get_container_str(afi
, safi
));
8579 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8581 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8583 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8584 argv
[idx_number
]->arg
);
8585 nb_cli_enqueue_change(vty
, "./options/tr-shutdown-threshold-pct",
8586 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8587 nb_cli_enqueue_change(vty
, "./options/tr-restart-timer", NB_OP_MODIFY
,
8588 argv
[idx_number_3
]->arg
);
8589 if (argv_find(argv
, argc
, "force", &idx_force
))
8590 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8593 return nb_cli_apply_changes(vty
, base_xpath
);
8597 neighbor_maximum_prefix_threshold_restart
,
8598 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8599 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8600 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8601 "Maximum number of prefixes to accept from this peer\n"
8602 "maximum no. of prefix limit\n"
8603 "Threshold value (%) at which to generate a warning msg\n"
8604 "Restart bgp connection after limit is exceeded\n"
8605 "Restart interval in minutes\n"
8606 "Force checking all received routes not only accepted\n")
8608 DEFUN_YANG(no_neighbor_maximum_prefix
,
8609 no_neighbor_maximum_prefix_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 char base_xpath
[XPATH_MAXLEN
];
8622 char af_xpath
[XPATH_MAXLEN
];
8623 char attr_xpath
[XPATH_MAXLEN
];
8624 afi_t afi
= bgp_node_afi(vty
);
8625 safi_t safi
= bgp_node_safi(vty
);
8627 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8628 yang_afi_safi_value2identity(afi
, safi
));
8629 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8630 sizeof(base_xpath
), af_xpath
)
8632 return CMD_WARNING_CONFIG_FAILED
;
8634 snprintf(attr_xpath
, sizeof(attr_xpath
),
8635 "/%s/prefix-limit/direction-list[direction='in']",
8636 bgp_afi_safi_get_container_str(afi
, safi
));
8637 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8639 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
8641 return nb_cli_apply_changes(vty
, base_xpath
);
8645 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8646 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8647 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8648 "Maximum number of prefixes to accept from this peer\n"
8649 "maximum no. of prefix limit\n"
8650 "Threshold value (%) at which to generate a warning msg\n"
8651 "Restart bgp connection after limit is exceeded\n"
8652 "Restart interval in minutes\n"
8653 "Only give warning message when limit is exceeded\n"
8654 "Force checking all received routes not only accepted\n")
8657 /* "neighbor allowas-in" */
8658 DEFUN (neighbor_allowas_in
,
8659 neighbor_allowas_in_cmd
,
8660 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8663 "Accept as-path with my AS present in it\n"
8664 "Number of occurrences of AS number\n"
8665 "Only accept my AS in the as-path if the route was originated in my AS\n")
8668 int idx_number_origin
= 3;
8674 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8676 return CMD_WARNING_CONFIG_FAILED
;
8678 if (argc
<= idx_number_origin
)
8681 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8684 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8687 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8690 return bgp_vty_return(vty
, ret
);
8694 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8695 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8696 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8697 "Accept as-path with my AS present in it\n"
8698 "Number of occurrences of AS number\n"
8699 "Only accept my AS in the as-path if the route was originated in my AS\n")
8701 DEFUN (no_neighbor_allowas_in
,
8702 no_neighbor_allowas_in_cmd
,
8703 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8707 "allow local ASN appears in aspath attribute\n"
8708 "Number of occurrences of AS number\n"
8709 "Only accept my AS in the as-path if the route was originated in my AS\n")
8715 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8717 return CMD_WARNING_CONFIG_FAILED
;
8719 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8720 bgp_node_safi(vty
));
8722 return bgp_vty_return(vty
, ret
);
8726 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8727 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8728 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8729 "allow local ASN appears in aspath attribute\n"
8730 "Number of occurrences of AS number\n"
8731 "Only accept my AS in the as-path if the route was originated in my AS\n")
8733 DEFUN_YANG (neighbor_ttl_security
,
8734 neighbor_ttl_security_cmd
,
8735 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8738 "BGP ttl-security parameters\n"
8739 "Specify the maximum number of hops to the BGP peer\n"
8740 "Number of hops to BGP peer\n")
8744 char base_xpath
[XPATH_MAXLEN
];
8746 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8747 sizeof(base_xpath
), NULL
)
8749 return CMD_WARNING_CONFIG_FAILED
;
8751 nb_cli_enqueue_change(vty
, "./ttl-security", NB_OP_MODIFY
,
8752 argv
[idx_number
]->arg
);
8754 return nb_cli_apply_changes(vty
, base_xpath
);
8757 DEFUN_YANG(no_neighbor_ttl_security
,
8758 no_neighbor_ttl_security_cmd
,
8759 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8760 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8761 "BGP ttl-security parameters\n"
8762 "Specify the maximum number of hops to the BGP peer\n"
8763 "Number of hops to BGP peer\n")
8766 char base_xpath
[XPATH_MAXLEN
];
8768 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8769 sizeof(base_xpath
), NULL
)
8771 return CMD_WARNING_CONFIG_FAILED
;
8773 nb_cli_enqueue_change(vty
, "./ttl-security", NB_OP_DESTROY
, NULL
);
8775 return nb_cli_apply_changes(vty
, base_xpath
);
8778 DEFUN (neighbor_addpath_tx_all_paths
,
8779 neighbor_addpath_tx_all_paths_cmd
,
8780 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8783 "Use addpath to advertise all paths to a neighbor\n")
8788 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8790 return CMD_WARNING_CONFIG_FAILED
;
8792 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8797 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8798 neighbor_addpath_tx_all_paths_hidden_cmd
,
8799 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8800 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8801 "Use addpath to advertise all paths to a neighbor\n")
8803 DEFUN (no_neighbor_addpath_tx_all_paths
,
8804 no_neighbor_addpath_tx_all_paths_cmd
,
8805 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8809 "Use addpath to advertise all paths to a neighbor\n")
8814 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8816 return CMD_WARNING_CONFIG_FAILED
;
8818 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8819 != BGP_ADDPATH_ALL
) {
8821 "%% Peer not currently configured to transmit all paths.");
8822 return CMD_WARNING_CONFIG_FAILED
;
8825 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8831 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8832 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8833 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8834 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8835 "Use addpath to advertise all paths to a neighbor\n")
8837 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8838 neighbor_addpath_tx_bestpath_per_as_cmd
,
8839 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8842 "Use addpath to advertise the bestpath per each neighboring AS\n")
8847 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8849 return CMD_WARNING_CONFIG_FAILED
;
8851 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8852 BGP_ADDPATH_BEST_PER_AS
);
8857 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8858 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8859 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8860 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8861 "Use addpath to advertise the bestpath per each neighboring AS\n")
8863 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8864 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8865 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8869 "Use addpath to advertise the bestpath per each neighboring AS\n")
8874 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8876 return CMD_WARNING_CONFIG_FAILED
;
8878 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8879 != BGP_ADDPATH_BEST_PER_AS
) {
8881 "%% Peer not currently configured to transmit all best path per as.");
8882 return CMD_WARNING_CONFIG_FAILED
;
8885 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8891 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8892 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8893 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8894 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8895 "Use addpath to advertise the bestpath per each neighboring AS\n")
8898 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8899 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8902 "Detect AS loops before sending to neighbor\n")
8906 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8908 return CMD_WARNING_CONFIG_FAILED
;
8910 peer
->as_path_loop_detection
= true;
8916 no_neighbor_aspath_loop_detection
,
8917 no_neighbor_aspath_loop_detection_cmd
,
8918 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8922 "Detect AS loops before sending to neighbor\n")
8926 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8928 return CMD_WARNING_CONFIG_FAILED
;
8930 peer
->as_path_loop_detection
= false;
8935 DEFPY(neighbor_damp
,
8937 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor dampening [(1-45)$half [(1-20000)$reuse (1-20000)$suppress (1-255)$max]]",
8940 "Enable neighbor route-flap dampening\n"
8941 "Half-life time for the penalty\n"
8942 "Value to start reusing a route\n"
8943 "Value to start suppressing a route\n"
8944 "Maximum duration to suppress a stable route\n")
8946 struct peer
*peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8949 return CMD_WARNING_CONFIG_FAILED
;
8951 half
= DEFAULT_HALF_LIFE
;
8953 reuse
= DEFAULT_REUSE
;
8954 suppress
= DEFAULT_SUPPRESS
;
8957 if (suppress
< reuse
) {
8959 "Suppress value cannot be less than reuse value\n");
8960 return CMD_WARNING_CONFIG_FAILED
;
8962 bgp_peer_damp_enable(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8963 half
* 60, reuse
, suppress
, max
* 60);
8967 DEFPY(no_neighbor_damp
,
8968 no_neighbor_damp_cmd
,
8969 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor dampening [HALF [REUSE SUPPRESS MAX]]",
8973 "Enable neighbor route-flap dampening\n"
8974 "Half-life time for the penalty\n"
8975 "Value to start reusing a route\n"
8976 "Value to start suppressing a route\n"
8977 "Maximum duration to suppress a stable route\n")
8979 struct peer
*peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8982 return CMD_WARNING_CONFIG_FAILED
;
8983 bgp_peer_damp_disable(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
8987 DEFPY (show_ip_bgp_neighbor_damp_param
,
8988 show_ip_bgp_neighbor_damp_param_cmd
,
8989 "show [ip] bgp [<ipv4|ipv6> [unicast]] neighbors <A.B.C.D|X:X::X:X|WORD>$neighbor dampening parameters [json]$json",
8994 "Address Family modifier\n"
8997 "Neighbor route-flap dampening information\n"
8998 "Display detail of configured dampening parameters\n"
9001 bool use_json
= false;
9004 safi_t safi
= SAFI_UNICAST
;
9007 if (argv_find(argv
, argc
, "ip", &idx
))
9009 if (argv_find(argv
, argc
, "ipv4", &idx
))
9011 if (argv_find(argv
, argc
, "ipv6", &idx
))
9013 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
9018 bgp_show_peer_dampening_parameters(vty
, peer
, afi
, safi
, use_json
);
9022 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
9023 struct ecommunity
**list
, bool is_rt6
)
9025 struct ecommunity
*ecom
= NULL
;
9026 struct ecommunity
*ecomadd
;
9028 for (; argc
; --argc
, ++argv
) {
9030 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
9031 ECOMMUNITY_ROUTE_TARGET
,
9034 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
9035 ECOMMUNITY_ROUTE_TARGET
,
9038 vty_out(vty
, "Malformed community-list value\n");
9040 ecommunity_free(&ecom
);
9041 return CMD_WARNING_CONFIG_FAILED
;
9045 ecommunity_merge(ecom
, ecomadd
);
9046 ecommunity_free(&ecomadd
);
9053 ecommunity_free(&*list
);
9060 bool vpn_policy_check_import(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
9061 bool v2vimport
, char *errmsg
, size_t errmsg_len
)
9064 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9065 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
9066 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9067 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
9069 errmsg
, errmsg_len
, "%s",
9070 "%% error: Please unconfigure import vrf commands before using vpn commands");
9074 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9075 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
9076 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9077 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
9079 errmsg
, errmsg_len
, "%s",
9080 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands");
9088 * v2vimport is true if we are handling a `import vrf ...` command
9090 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
9094 switch (vty
->node
) {
9103 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
9108 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9109 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
9110 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9111 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
9113 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
9117 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9118 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
9119 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9120 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
9122 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
9131 af_rd_vpn_export_cmd
,
9132 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
9134 "Specify route distinguisher\n"
9135 "Between current address-family and vpn\n"
9136 "For routes leaked from current address-family to vpn\n"
9137 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
9139 char base_xpath
[XPATH_MAXLEN
];
9144 afi
= bgp_node_afi(vty
);
9145 safi
= bgp_node_safi(vty
);
9148 base_xpath
, sizeof(base_xpath
),
9149 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9150 yang_afi_safi_value2identity(afi
, safi
),
9151 bgp_afi_safi_get_container_str(afi
, safi
));
9153 if (argv_find(argv
, argc
, "no", &idx
))
9154 nb_cli_enqueue_change(vty
, "./rd", NB_OP_DESTROY
, NULL
);
9156 nb_cli_enqueue_change(vty
, "./rd", NB_OP_MODIFY
, rd_str
);
9158 return nb_cli_apply_changes(vty
, base_xpath
);
9161 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rd(
9162 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9166 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
9167 yang_dnode_get_string(dnode
, NULL
));
9170 ALIAS (af_rd_vpn_export
,
9171 af_no_rd_vpn_export_cmd
,
9174 "Specify route distinguisher\n"
9175 "Between current address-family and vpn\n"
9176 "For routes leaked from current address-family to vpn\n")
9178 DEFPY (af_label_vpn_export
,
9179 af_label_vpn_export_cmd
,
9180 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
9182 "label value for VRF\n"
9183 "Between current address-family and vpn\n"
9184 "For routes leaked from current address-family to vpn\n"
9185 "Label Value <0-1048575>\n"
9186 "Automatically assign a label\n")
9188 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9189 mpls_label_t label
= MPLS_LABEL_NONE
;
9194 if (argv_find(argv
, argc
, "no", &idx
))
9197 /* If "no ...", squash trailing parameter */
9203 label
= label_val
; /* parser should force unsigned */
9206 afi
= vpn_policy_getafi(vty
, bgp
, false);
9208 return CMD_WARNING_CONFIG_FAILED
;
9211 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9212 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
9217 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9219 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9220 bgp_get_default(), bgp
);
9222 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9223 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
9225 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
9228 * label has previously been automatically
9229 * assigned by labelpool: release it
9231 * NB if tovpn_label == MPLS_LABEL_NONE it
9232 * means the automatic assignment is in flight
9233 * and therefore the labelpool callback must
9234 * detect that the auto label is not needed.
9237 bgp_lp_release(LP_TYPE_VRF
,
9238 &bgp
->vpn_policy
[afi
],
9239 bgp
->vpn_policy
[afi
].tovpn_label
);
9241 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9242 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9245 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
9247 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9248 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9249 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
9250 vpn_leak_label_callback
);
9253 /* post-change: re-export vpn routes */
9254 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9255 bgp_get_default(), bgp
);
9260 ALIAS (af_label_vpn_export
,
9261 af_no_label_vpn_export_cmd
,
9262 "no label vpn export",
9264 "label value for VRF\n"
9265 "Between current address-family and vpn\n"
9266 "For routes leaked from current address-family to vpn\n")
9268 DEFPY_YANG (af_nexthop_vpn_export
,
9269 af_nexthop_vpn_export_cmd
,
9270 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
9272 "Specify next hop to use for VRF advertised prefixes\n"
9273 "Between current address-family and vpn\n"
9274 "For routes leaked from current address-family to vpn\n"
9278 char base_xpath
[XPATH_MAXLEN
];
9286 vty_out(vty
, "%% Nexthop required\n");
9287 return CMD_WARNING_CONFIG_FAILED
;
9289 if (!sockunion2hostprefix(nexthop_su
, &p
))
9290 return CMD_WARNING_CONFIG_FAILED
;
9293 afi
= bgp_node_afi(vty
);
9294 safi
= bgp_node_safi(vty
);
9297 base_xpath
, sizeof(base_xpath
),
9298 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9299 yang_afi_safi_value2identity(afi
, safi
),
9300 bgp_afi_safi_get_container_str(afi
, safi
));
9302 if (argv_find(argv
, argc
, "no", &idx
))
9303 nb_cli_enqueue_change(vty
, "./nexthop", NB_OP_DESTROY
, NULL
);
9305 nb_cli_enqueue_change(vty
, "./nexthop", NB_OP_MODIFY
,
9308 return nb_cli_apply_changes(vty
, base_xpath
);
9311 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_nexthop(
9312 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9316 vty_out(vty
, "%*snexthop vpn export %s\n", indent
, "",
9317 yang_dnode_get_string(dnode
, NULL
));
9320 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9322 if (!strcmp(dstr
, "import")) {
9323 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9324 } else if (!strcmp(dstr
, "export")) {
9325 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9326 } else if (!strcmp(dstr
, "both")) {
9327 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9328 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9330 vty_out(vty
, "%% direction parse error\n");
9331 return CMD_WARNING_CONFIG_FAILED
;
9336 DEFPY (af_rt_vpn_imexport
,
9337 af_rt_vpn_imexport_cmd
,
9338 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9340 "Specify route target list\n"
9341 "Specify route target list\n"
9342 "Between current address-family and vpn\n"
9343 "For routes leaked from vpn to current address-family: match any\n"
9344 "For routes leaked from current address-family to vpn: set\n"
9345 "both import: match any and export: set\n"
9346 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9348 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9350 struct ecommunity
*ecom
= NULL
;
9351 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9352 vpn_policy_direction_t dir
;
9357 if (argv_find(argv
, argc
, "no", &idx
))
9360 afi
= vpn_policy_getafi(vty
, bgp
, false);
9362 return CMD_WARNING_CONFIG_FAILED
;
9364 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9365 if (ret
!= CMD_SUCCESS
)
9369 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9370 vty_out(vty
, "%% Missing RTLIST\n");
9371 return CMD_WARNING_CONFIG_FAILED
;
9373 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9374 if (ret
!= CMD_SUCCESS
) {
9379 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9383 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9386 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9388 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9389 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9390 ecommunity_dup(ecom
);
9392 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9394 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9395 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9398 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9402 ecommunity_free(&ecom
);
9407 ALIAS (af_rt_vpn_imexport
,
9408 af_no_rt_vpn_imexport_cmd
,
9409 "no <rt|route-target> vpn <import|export|both>$direction_str",
9411 "Specify route target list\n"
9412 "Specify route target list\n"
9413 "Between current address-family and vpn\n"
9414 "For routes leaked from vpn to current address-family\n"
9415 "For routes leaked from current address-family to vpn\n"
9416 "both import and export\n")
9418 DEFPY_YANG (af_route_map_vpn_imexport
,
9419 af_route_map_vpn_imexport_cmd
,
9420 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9421 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9423 "Specify route map\n"
9424 "Between current address-family and vpn\n"
9425 "For routes leaked from vpn to current address-family\n"
9426 "For routes leaked from current address-family to vpn\n"
9427 "name of route-map\n")
9429 char base_xpath
[XPATH_MAXLEN
];
9434 afi
= bgp_node_afi(vty
);
9435 safi
= bgp_node_safi(vty
);
9438 base_xpath
, sizeof(base_xpath
),
9439 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9440 yang_afi_safi_value2identity(afi
, safi
),
9441 bgp_afi_safi_get_container_str(afi
, safi
));
9443 if (argv_find(argv
, argc
, "no", &idx
)) {
9444 if (!strcmp(direction_str
, "import"))
9445 nb_cli_enqueue_change(vty
, "./rmap-import",
9446 NB_OP_DESTROY
, NULL
);
9447 else if (!strcmp(direction_str
, "export"))
9448 nb_cli_enqueue_change(vty
, "./rmap-export",
9449 NB_OP_DESTROY
, NULL
);
9451 if (!strcmp(direction_str
, "import"))
9452 nb_cli_enqueue_change(vty
, "./rmap-import",
9453 NB_OP_MODIFY
, rmap_str
);
9454 if (!strcmp(direction_str
, "export"))
9455 nb_cli_enqueue_change(vty
, "./rmap-export",
9456 NB_OP_MODIFY
, rmap_str
);
9458 return nb_cli_apply_changes(vty
, base_xpath
);
9461 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_import(
9462 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9466 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
9467 yang_dnode_get_string(dnode
, NULL
));
9470 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_export(
9471 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9475 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
9476 yang_dnode_get_string(dnode
, NULL
));
9479 ALIAS (af_route_map_vpn_imexport
,
9480 af_no_route_map_vpn_imexport_cmd
,
9481 "no route-map vpn <import|export>$direction_str",
9483 "Specify route map\n"
9484 "Between current address-family and vpn\n"
9485 "For routes leaked from vpn to current address-family\n"
9486 "For routes leaked from current address-family to vpn\n")
9488 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9489 "import vrf route-map RMAP$rmap_str",
9490 "Import routes from another VRF\n"
9491 "Vrf routes being filtered\n"
9492 "Specify route map\n"
9493 "name of route-map\n")
9495 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9496 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9498 struct bgp
*bgp_default
;
9500 afi
= vpn_policy_getafi(vty
, bgp
, true);
9502 return CMD_WARNING_CONFIG_FAILED
;
9504 bgp_default
= bgp_get_default();
9509 /* Auto-create assuming the same AS */
9510 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9511 BGP_INSTANCE_TYPE_DEFAULT
);
9515 "VRF default is not configured as a bgp instance\n");
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
] =
9526 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9527 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9528 route_map_lookup_warn_noexist(vty
, rmap_str
);
9529 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9532 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9533 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9535 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9540 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9541 "no import vrf route-map [RMAP$rmap_str]",
9543 "Import routes from another VRF\n"
9544 "Vrf routes being filtered\n"
9545 "Specify route map\n"
9546 "name of route-map\n")
9548 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9549 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9552 afi
= vpn_policy_getafi(vty
, bgp
, true);
9554 return CMD_WARNING_CONFIG_FAILED
;
9556 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9558 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9559 XFREE(MTYPE_ROUTE_MAP_NAME
,
9560 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9561 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9562 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9564 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9565 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9566 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9568 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9573 DEFPY_YANG(bgp_imexport_vrf
,
9574 bgp_imexport_vrf_cmd
,
9575 "[no] import vrf VIEWVRFNAME$import_name",
9577 "Import routes from another VRF\n"
9578 "VRF to import from\n"
9579 "The name of the VRF\n")
9581 char base_xpath
[XPATH_MAXLEN
];
9586 if (import_name
== NULL
) {
9587 vty_out(vty
, "%% Missing import name\n");
9591 if (strcmp(import_name
, "route-map") == 0) {
9592 vty_out(vty
, "%% Must include route-map name\n");
9596 afi
= bgp_node_afi(vty
);
9597 safi
= bgp_node_safi(vty
);
9600 base_xpath
, sizeof(base_xpath
),
9601 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vrf-list[vrf='%s']",
9602 yang_afi_safi_value2identity(afi
, safi
),
9603 bgp_afi_safi_get_container_str(afi
, safi
), import_name
);
9605 if (argv_find(argv
, argc
, "no", &idx
))
9606 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
9608 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
9610 return nb_cli_apply_changes(vty
, base_xpath
);
9613 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vrfs(
9614 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9616 vty_out(vty
, " import vrf %s\n",
9617 yang_dnode_get_string(dnode
, "./vrf"));
9620 /* This command is valid only in a bgp vrf instance or the default instance */
9621 DEFPY_YANG (bgp_imexport_vpn
,
9622 bgp_imexport_vpn_cmd
,
9623 "[no] <import|export>$direction_str vpn",
9625 "Import routes to this address-family\n"
9626 "Export routes from this address-family\n"
9627 "to/from default instance VPN RIB\n")
9629 char base_xpath
[XPATH_MAXLEN
];
9634 afi
= bgp_node_afi(vty
);
9635 safi
= bgp_node_safi(vty
);
9637 if (!strcmp(direction_str
, "import")) {
9639 base_xpath
, sizeof(base_xpath
),
9640 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vpn",
9641 yang_afi_safi_value2identity(afi
, safi
),
9642 bgp_afi_safi_get_container_str(afi
, safi
));
9643 } else if (!strcmp(direction_str
, "export")) {
9645 base_xpath
, sizeof(base_xpath
),
9646 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/export-vpn",
9647 yang_afi_safi_value2identity(afi
, safi
),
9648 bgp_afi_safi_get_container_str(afi
, safi
));
9650 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9651 return CMD_WARNING_CONFIG_FAILED
;
9654 if (argv_find(argv
, argc
, "no", &idx
))
9655 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
9657 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, "true");
9659 return nb_cli_apply_changes(vty
, base_xpath
);
9662 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vpn(
9663 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9665 if (yang_dnode_get_bool(dnode
, NULL
))
9666 vty_out(vty
, " import vpn\n");
9669 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_export_vpn(
9670 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9672 if (yang_dnode_get_bool(dnode
, NULL
))
9673 vty_out(vty
, " export vpn\n");
9676 DEFPY (af_routetarget_import
,
9677 af_routetarget_import_cmd
,
9678 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9680 "Specify route target list\n"
9681 "Specify route target list\n"
9682 "Specify route target list\n"
9683 "Specify route target list\n"
9684 "Flow-spec redirect type route target\n"
9685 "Import routes to this address-family\n"
9686 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9688 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9690 struct ecommunity
*ecom
= NULL
;
9692 int idx
= 0, idx_unused
= 0;
9696 if (argv_find(argv
, argc
, "no", &idx
))
9699 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9700 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9703 afi
= vpn_policy_getafi(vty
, bgp
, false);
9705 return CMD_WARNING_CONFIG_FAILED
;
9707 if (rt6
&& afi
!= AFI_IP6
)
9708 return CMD_WARNING_CONFIG_FAILED
;
9711 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9712 vty_out(vty
, "%% Missing RTLIST\n");
9713 return CMD_WARNING_CONFIG_FAILED
;
9715 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9716 if (ret
!= CMD_SUCCESS
)
9721 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9722 ecommunity_free(&bgp
->vpn_policy
[afi
]
9723 .import_redirect_rtlist
);
9724 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9725 ecommunity_dup(ecom
);
9727 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9728 ecommunity_free(&bgp
->vpn_policy
[afi
]
9729 .import_redirect_rtlist
);
9730 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9734 ecommunity_free(&ecom
);
9739 void cli_show_bgp_global_afi_safi_header(struct vty
*vty
,
9740 struct lyd_node
*dnode
,
9743 const char *af_name
;
9747 af_name
= yang_dnode_get_string(dnode
, "./afi-safi-name");
9748 yang_afi_safi_identity2value(af_name
, &afi
, &safi
);
9750 vty_out(vty
, " !\n address-family ");
9751 if (afi
== AFI_IP
) {
9752 if (safi
== SAFI_UNICAST
)
9753 vty_out(vty
, "ipv4 unicast");
9754 else if (safi
== SAFI_LABELED_UNICAST
)
9755 vty_out(vty
, "ipv4 labeled-unicast");
9756 else if (safi
== SAFI_MULTICAST
)
9757 vty_out(vty
, "ipv4 multicast");
9758 else if (safi
== SAFI_MPLS_VPN
)
9759 vty_out(vty
, "ipv4 vpn");
9760 else if (safi
== SAFI_ENCAP
)
9761 vty_out(vty
, "ipv4 encap");
9762 else if (safi
== SAFI_FLOWSPEC
)
9763 vty_out(vty
, "ipv4 flowspec");
9764 } else if (afi
== AFI_IP6
) {
9765 if (safi
== SAFI_UNICAST
)
9766 vty_out(vty
, "ipv6 unicast");
9767 else if (safi
== SAFI_LABELED_UNICAST
)
9768 vty_out(vty
, "ipv6 labeled-unicast");
9769 else if (safi
== SAFI_MULTICAST
)
9770 vty_out(vty
, "ipv6 multicast");
9771 else if (safi
== SAFI_MPLS_VPN
)
9772 vty_out(vty
, "ipv6 vpn");
9773 else if (safi
== SAFI_ENCAP
)
9774 vty_out(vty
, "ipv6 encap");
9775 else if (safi
== SAFI_FLOWSPEC
)
9776 vty_out(vty
, "ipv6 flowspec");
9777 } else if (afi
== AFI_L2VPN
) {
9778 if (safi
== SAFI_EVPN
)
9779 vty_out(vty
, "l2vpn evpn");
9784 DEFUN_NOSH (address_family_ipv4_safi
,
9785 address_family_ipv4_safi_cmd
,
9786 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9787 "Enter Address Family command mode\n"
9789 BGP_SAFI_WITH_LABEL_HELP_STR
)
9792 safi_t safi
= SAFI_UNICAST
;
9793 const struct lyd_node
*vrf_dnode
, *bgp_glb_dnode
;
9794 const char *vrf_name
= NULL
;
9797 safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9799 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
9801 vrf_dnode
= yang_dnode_get_parent(bgp_glb_dnode
,
9802 "control-plane-protocol");
9803 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
9805 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
)
9806 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9807 && safi
!= SAFI_EVPN
) {
9809 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9810 return CMD_WARNING_CONFIG_FAILED
;
9813 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9818 DEFUN_NOSH (address_family_ipv6_safi
,
9819 address_family_ipv6_safi_cmd
,
9820 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9821 "Enter Address Family command mode\n"
9823 BGP_SAFI_WITH_LABEL_HELP_STR
)
9825 safi_t safi
= SAFI_UNICAST
;
9826 const struct lyd_node
*vrf_dnode
, *bgp_glb_dnode
;
9827 const char *vrf_name
= NULL
;
9830 safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9831 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
9833 vrf_dnode
= yang_dnode_get_parent(bgp_glb_dnode
,
9834 "control-plane-protocol");
9835 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
9837 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
)
9838 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9839 && safi
!= SAFI_EVPN
) {
9841 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9842 return CMD_WARNING_CONFIG_FAILED
;
9845 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9850 #ifdef KEEP_OLD_VPN_COMMANDS
9851 DEFUN_NOSH (address_family_vpnv4
,
9852 address_family_vpnv4_cmd
,
9853 "address-family vpnv4 [unicast]",
9854 "Enter Address Family command mode\n"
9856 "Address Family modifier\n")
9858 vty
->node
= BGP_VPNV4_NODE
;
9862 DEFUN_NOSH (address_family_vpnv6
,
9863 address_family_vpnv6_cmd
,
9864 "address-family vpnv6 [unicast]",
9865 "Enter Address Family command mode\n"
9867 "Address Family modifier\n")
9869 vty
->node
= BGP_VPNV6_NODE
;
9872 #endif /* KEEP_OLD_VPN_COMMANDS */
9874 DEFUN_NOSH (address_family_evpn
,
9875 address_family_evpn_cmd
,
9876 "address-family l2vpn evpn",
9877 "Enter Address Family command mode\n"
9879 "Address Family modifier\n")
9881 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9882 vty
->node
= BGP_EVPN_NODE
;
9886 DEFUN_NOSH (exit_address_family
,
9887 exit_address_family_cmd
,
9888 "exit-address-family",
9889 "Exit from Address Family configuration mode\n")
9891 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9892 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9893 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9894 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9895 || vty
->node
== BGP_EVPN_NODE
9896 || vty
->node
== BGP_FLOWSPECV4_NODE
9897 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9898 vty
->node
= BGP_NODE
;
9902 void cli_show_bgp_global_afi_safi_header_end(struct vty
*vty
,
9903 struct lyd_node
*dnode
9904 __attribute__((__unused__
)))
9906 vty_out(vty
, " exit-address-family\n");
9909 /* Recalculate bestpath and re-advertise a prefix */
9910 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9911 const char *ip_str
, afi_t afi
, safi_t safi
,
9912 struct prefix_rd
*prd
)
9915 struct prefix match
;
9916 struct bgp_dest
*dest
;
9917 struct bgp_dest
*rm
;
9919 struct bgp_table
*table
;
9920 struct bgp_table
*rib
;
9922 /* BGP structure lookup. */
9924 bgp
= bgp_lookup_by_name(view_name
);
9926 vty_out(vty
, "%% Can't find BGP instance %s\n",
9931 bgp
= bgp_get_default();
9933 vty_out(vty
, "%% No BGP process is configured\n");
9938 /* Check IP address argument. */
9939 ret
= str2prefix(ip_str
, &match
);
9941 vty_out(vty
, "%% address is malformed\n");
9945 match
.family
= afi2family(afi
);
9946 rib
= bgp
->rib
[afi
][safi
];
9948 if (safi
== SAFI_MPLS_VPN
) {
9949 for (dest
= bgp_table_top(rib
); dest
;
9950 dest
= bgp_route_next(dest
)) {
9951 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9953 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9956 table
= bgp_dest_get_bgp_table_info(dest
);
9960 if ((rm
= bgp_node_match(table
, &match
)) != NULL
) {
9961 const struct prefix
*rm_p
=
9962 bgp_dest_get_prefix(rm
);
9964 if (rm_p
->prefixlen
== match
.prefixlen
) {
9966 BGP_NODE_USER_CLEAR
);
9967 bgp_process(bgp
, rm
, afi
, safi
);
9969 bgp_dest_unlock_node(rm
);
9973 if ((dest
= bgp_node_match(rib
, &match
)) != NULL
) {
9974 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9976 if (dest_p
->prefixlen
== match
.prefixlen
) {
9977 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9978 bgp_process(bgp
, dest
, afi
, safi
);
9980 bgp_dest_unlock_node(dest
);
9987 /* one clear bgp command to rule them all */
9988 DEFUN (clear_ip_bgp_all
,
9989 clear_ip_bgp_all_cmd
,
9990 "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>]",
9994 BGP_INSTANCE_HELP_STR
9997 BGP_SAFI_WITH_LABEL_HELP_STR
9998 "Address Family modifier\n"
10000 "BGP IPv4 neighbor to clear\n"
10001 "BGP IPv6 neighbor to clear\n"
10002 "BGP neighbor on interface to clear\n"
10003 "Clear peers with the AS number\n"
10004 "Clear all external peers\n"
10005 "Clear all members of peer-group\n"
10006 "BGP peer-group name\n"
10011 "Push out prefix-list ORF and do inbound soft reconfig\n"
10016 afi_t afi
= AFI_UNSPEC
;
10017 safi_t safi
= SAFI_UNSPEC
;
10018 enum clear_sort clr_sort
= clear_peer
;
10019 enum bgp_clear_type clr_type
;
10020 char *clr_arg
= NULL
;
10023 char errmsg
[BUFSIZ
] = {'\0'};
10026 /* clear [ip] bgp */
10027 if (argv_find(argv
, argc
, "ip", &idx
))
10030 /* [<vrf> VIEWVRFNAME] */
10031 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10032 vrf
= argv
[idx
+ 1]->arg
;
10034 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10036 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10037 /* [<view> VIEWVRFNAME] */
10038 vrf
= argv
[idx
+ 1]->arg
;
10041 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
10042 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
10043 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
10045 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
10046 if (argv_find(argv
, argc
, "*", &idx
)) {
10047 clr_sort
= clear_all
;
10048 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
10049 clr_sort
= clear_peer
;
10050 clr_arg
= argv
[idx
]->arg
;
10051 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
10052 clr_sort
= clear_peer
;
10053 clr_arg
= argv
[idx
]->arg
;
10054 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
10055 clr_sort
= clear_group
;
10057 clr_arg
= argv
[idx
]->arg
;
10058 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
10059 clr_sort
= clear_peer
;
10060 clr_arg
= argv
[idx
]->arg
;
10061 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
10062 clr_sort
= clear_peer
;
10063 clr_arg
= argv
[idx
]->arg
;
10064 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
10065 clr_sort
= clear_as
;
10066 clr_arg
= argv
[idx
]->arg
;
10067 } else if (argv_find(argv
, argc
, "external", &idx
)) {
10068 clr_sort
= clear_external
;
10071 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
10072 if (argv_find(argv
, argc
, "soft", &idx
)) {
10073 if (argv_find(argv
, argc
, "in", &idx
)
10074 || argv_find(argv
, argc
, "out", &idx
))
10075 clr_type
= strmatch(argv
[idx
]->text
, "in")
10076 ? BGP_CLEAR_SOFT_IN
10077 : BGP_CLEAR_SOFT_OUT
;
10079 clr_type
= BGP_CLEAR_SOFT_BOTH
;
10080 } else if (argv_find(argv
, argc
, "in", &idx
)) {
10081 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
10082 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
10083 : BGP_CLEAR_SOFT_IN
;
10084 } else if (argv_find(argv
, argc
, "out", &idx
)) {
10085 clr_type
= BGP_CLEAR_SOFT_OUT
;
10087 clr_type
= BGP_CLEAR_SOFT_NONE
;
10089 ret
= bgp_clear_vty(vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
, errmsg
,
10092 vty_out(vty
, "Error description: %s\n", errmsg
);
10097 DEFUN (clear_ip_bgp_prefix
,
10098 clear_ip_bgp_prefix_cmd
,
10099 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
10103 BGP_INSTANCE_HELP_STR
10104 "Clear bestpath and re-advertise\n"
10108 char *prefix
= NULL
;
10112 /* [<view|vrf> VIEWVRFNAME] */
10113 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10114 vrf
= argv
[idx
+ 1]->arg
;
10116 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10118 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10119 /* [<view> VIEWVRFNAME] */
10120 vrf
= argv
[idx
+ 1]->arg
;
10124 prefix
= argv
[argc
- 1]->arg
;
10126 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
10129 DEFUN (clear_bgp_ipv6_safi_prefix
,
10130 clear_bgp_ipv6_safi_prefix_cmd
,
10131 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10137 "Clear bestpath and re-advertise\n"
10141 int idx_ipv6_prefix
= 0;
10142 safi_t safi
= SAFI_UNICAST
;
10143 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10144 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10146 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10147 return bgp_clear_prefix(
10148 vty
, NULL
, prefix
, AFI_IP6
,
10152 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
10153 clear_bgp_instance_ipv6_safi_prefix_cmd
,
10154 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10158 BGP_INSTANCE_HELP_STR
10161 "Clear bestpath and re-advertise\n"
10165 int idx_vrfview
= 0;
10166 int idx_ipv6_prefix
= 0;
10167 safi_t safi
= SAFI_UNICAST
;
10168 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10169 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10170 char *vrfview
= NULL
;
10172 /* [<view|vrf> VIEWVRFNAME] */
10173 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
10174 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10175 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
10177 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
10178 /* [<view> VIEWVRFNAME] */
10179 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10181 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10183 return bgp_clear_prefix(
10184 vty
, vrfview
, prefix
,
10185 AFI_IP6
, safi
, NULL
);
10188 DEFUN (show_bgp_views
,
10189 show_bgp_views_cmd
,
10190 "show [ip] bgp views",
10194 "Show the defined BGP views\n")
10196 struct list
*inst
= bm
->bgp
;
10197 struct listnode
*node
;
10200 vty_out(vty
, "Defined BGP views:\n");
10201 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10203 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10205 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
10209 return CMD_SUCCESS
;
10212 DEFUN (show_bgp_vrfs
,
10214 "show [ip] bgp vrfs [json]",
10221 char buf
[ETHER_ADDR_STRLEN
];
10222 struct list
*inst
= bm
->bgp
;
10223 struct listnode
*node
;
10225 bool uj
= use_json(argc
, argv
);
10226 json_object
*json
= NULL
;
10227 json_object
*json_vrfs
= NULL
;
10231 json
= json_object_new_object();
10232 json_vrfs
= json_object_new_object();
10235 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10236 const char *name
, *type
;
10238 struct listnode
*node2
, *nnode2
;
10239 int peers_cfg
, peers_estb
;
10240 json_object
*json_vrf
= NULL
;
10243 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10247 if (!uj
&& count
== 1) {
10249 "%4s %-5s %-16s %9s %10s %-37s\n",
10250 "Type", "Id", "routerId", "#PeersCfg",
10251 "#PeersEstb", "Name");
10252 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10253 "L3-VNI", "RouterMAC", "Interface");
10256 peers_cfg
= peers_estb
= 0;
10258 json_vrf
= json_object_new_object();
10261 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
10262 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10265 if (peer
->status
== Established
)
10269 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10270 name
= VRF_DEFAULT_NAME
;
10279 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10281 : (int64_t)bgp
->vrf_id
;
10282 char buf
[BUFSIZ
] = {0};
10284 json_object_string_add(json_vrf
, "type", type
);
10285 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
10286 json_object_string_add(json_vrf
, "routerId",
10288 &bgp
->router_id
, buf
,
10290 json_object_int_add(json_vrf
, "numConfiguredPeers",
10292 json_object_int_add(json_vrf
, "numEstablishedPeers",
10295 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
10296 json_object_string_add(
10298 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
10299 json_object_string_add(json_vrf
, "interface",
10300 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10302 json_object_object_add(json_vrfs
, name
, json_vrf
);
10304 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10306 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10307 : (int)bgp
->vrf_id
,
10308 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10309 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
10311 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
10312 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10318 json_object_object_add(json
, "vrfs", json_vrfs
);
10320 json_object_int_add(json
, "totalVrfs", count
);
10322 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10323 json
, JSON_C_TO_STRING_PRETTY
));
10324 json_object_free(json
);
10328 "\nTotal number of VRFs (including default): %d\n",
10332 return CMD_SUCCESS
;
10335 DEFUN (show_bgp_mac_hash
,
10336 show_bgp_mac_hash_cmd
,
10337 "show bgp mac hash",
10341 "Mac Address database\n")
10343 bgp_mac_dump_table(vty
);
10345 return CMD_SUCCESS
;
10348 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10350 struct vty
*vty
= (struct vty
*)args
;
10351 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10353 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10356 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10358 vty_out(vty
, "self nexthop database:\n");
10359 bgp_nexthop_show_address_hash(vty
, bgp
);
10361 vty_out(vty
, "Tunnel-ip database:\n");
10362 hash_iterate(bgp
->tip_hash
,
10363 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10367 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10368 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10369 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10370 "martian next-hops\n"
10371 "martian next-hop database\n")
10373 struct bgp
*bgp
= NULL
;
10377 /* [<vrf> VIEWVRFNAME] */
10378 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10379 name
= argv
[idx
+ 1]->arg
;
10380 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10382 } else if (argv_find(argv
, argc
, "view", &idx
))
10383 /* [<view> VIEWVRFNAME] */
10384 name
= argv
[idx
+ 1]->arg
;
10386 bgp
= bgp_lookup_by_name(name
);
10388 bgp
= bgp_get_default();
10391 vty_out(vty
, "%% No BGP process is configured\n");
10392 return CMD_WARNING
;
10394 bgp_show_martian_nexthops(vty
, bgp
);
10396 return CMD_SUCCESS
;
10399 DEFUN (show_bgp_memory
,
10400 show_bgp_memory_cmd
,
10401 "show [ip] bgp memory",
10405 "Global BGP memory statistics\n")
10407 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10408 unsigned long count
;
10410 /* RIB related usage stats */
10411 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10412 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10413 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10414 count
* sizeof(struct bgp_dest
)));
10416 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10417 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10418 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10419 count
* sizeof(struct bgp_path_info
)));
10420 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10421 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10424 memstrbuf
, sizeof(memstrbuf
),
10425 count
* sizeof(struct bgp_path_info_extra
)));
10427 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10428 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10429 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10430 count
* sizeof(struct bgp_static
)));
10432 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10433 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10434 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10435 count
* sizeof(struct bpacket
)));
10438 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10439 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10440 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10441 count
* sizeof(struct bgp_adj_in
)));
10442 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10443 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10444 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10445 count
* sizeof(struct bgp_adj_out
)));
10447 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10448 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10450 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10451 count
* sizeof(struct bgp_nexthop_cache
)));
10453 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10454 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10456 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10457 count
* sizeof(struct bgp_damp_info
)));
10460 count
= attr_count();
10461 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10462 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10463 count
* sizeof(struct attr
)));
10465 if ((count
= attr_unknown_count()))
10466 vty_out(vty
, "%ld unknown attributes\n", count
);
10468 /* AS_PATH attributes */
10469 count
= aspath_count();
10470 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10471 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10472 count
* sizeof(struct aspath
)));
10474 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10475 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10476 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10477 count
* sizeof(struct assegment
)));
10479 /* Other attributes */
10480 if ((count
= community_count()))
10481 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10482 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10483 count
* sizeof(struct community
)));
10484 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10485 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10486 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10487 count
* sizeof(struct ecommunity
)));
10488 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10490 "%ld BGP large-community entries, using %s of memory\n",
10491 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10492 count
* sizeof(struct lcommunity
)));
10494 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10495 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10496 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10497 count
* sizeof(struct cluster_list
)));
10499 /* Peer related usage */
10500 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10501 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10502 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10503 count
* sizeof(struct peer
)));
10505 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10506 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10507 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10508 count
* sizeof(struct peer_group
)));
10511 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10512 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10513 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10514 count
* sizeof(regex_t
)));
10515 return CMD_SUCCESS
;
10518 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10520 json_object
*bestpath
= json_object_new_object();
10522 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10523 json_object_string_add(bestpath
, "asPath", "ignore");
10525 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10526 json_object_string_add(bestpath
, "asPath", "confed");
10528 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10529 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10530 json_object_string_add(bestpath
, "multiPathRelax",
10533 json_object_string_add(bestpath
, "multiPathRelax",
10536 json_object_string_add(bestpath
, "multiPathRelax", "false");
10538 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10539 json_object_string_add(bestpath
, "compareRouterId", "true");
10540 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10541 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10542 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10543 json_object_string_add(bestpath
, "med", "confed");
10544 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10545 json_object_string_add(bestpath
, "med",
10546 "missing-as-worst");
10548 json_object_string_add(bestpath
, "med", "true");
10551 json_object_object_add(json
, "bestPath", bestpath
);
10554 /* Print the error code/subcode for why the peer is down */
10555 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10556 json_object
*json_peer
, bool use_json
)
10558 const char *code_str
;
10559 const char *subcode_str
;
10562 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10563 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10564 char errorcodesubcode_hexstr
[5];
10565 char errorcodesubcode_str
[256];
10567 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10568 subcode_str
= bgp_notify_subcode_str(
10570 peer
->notify
.subcode
);
10572 snprintf(errorcodesubcode_hexstr
,
10573 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10574 peer
->notify
.code
, peer
->notify
.subcode
);
10575 json_object_string_add(json_peer
,
10576 "lastErrorCodeSubcode",
10577 errorcodesubcode_hexstr
);
10578 snprintf(errorcodesubcode_str
, 255, "%s%s",
10579 code_str
, subcode_str
);
10580 json_object_string_add(json_peer
,
10581 "lastNotificationReason",
10582 errorcodesubcode_str
);
10583 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10584 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10585 && (peer
->notify
.subcode
10586 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10587 || peer
->notify
.subcode
10588 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10589 && peer
->notify
.length
) {
10591 const char *msg_str
;
10593 msg_str
= bgp_notify_admin_message(
10594 msgbuf
, sizeof(msgbuf
),
10595 (uint8_t *)peer
->notify
.data
,
10596 peer
->notify
.length
);
10598 json_object_string_add(
10600 "lastShutdownDescription",
10605 json_object_string_add(json_peer
, "lastResetDueTo",
10606 peer_down_str
[(int)peer
->last_reset
]);
10607 json_object_int_add(json_peer
, "lastResetCode",
10610 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10611 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10612 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10614 bgp_notify_subcode_str(peer
->notify
.code
,
10615 peer
->notify
.subcode
);
10616 vty_out(vty
, " Notification %s (%s%s)\n",
10617 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10620 code_str
, subcode_str
);
10622 vty_out(vty
, " %s\n",
10623 peer_down_str
[(int)peer
->last_reset
]);
10628 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10631 return ((peer
->status
!= Established
) ||
10632 !peer
->afc_recv
[afi
][safi
]);
10635 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10636 struct peer
*peer
, json_object
*json_peer
,
10637 int max_neighbor_width
, bool use_json
)
10639 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10643 if (peer_dynamic_neighbor(peer
))
10644 json_object_boolean_true_add(json_peer
,
10646 if (peer
->hostname
)
10647 json_object_string_add(json_peer
, "hostname",
10650 if (peer
->domainname
)
10651 json_object_string_add(json_peer
, "domainname",
10653 json_object_int_add(json_peer
, "connectionsEstablished",
10654 peer
->established
);
10655 json_object_int_add(json_peer
, "connectionsDropped",
10657 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10658 use_json
, json_peer
);
10659 if (peer
->status
== Established
)
10660 json_object_string_add(json_peer
, "lastResetDueTo",
10661 "AFI/SAFI Not Negotiated");
10663 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10666 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10668 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10669 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10670 peer
->hostname
, peer
->host
);
10672 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10674 /* pad the neighbor column with spaces */
10675 if (len
< max_neighbor_width
)
10676 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10678 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10680 peer_uptime(peer
->uptime
, timebuf
,
10681 BGP_UPTIME_LEN
, 0, NULL
));
10682 if (peer
->status
== Established
)
10683 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10685 bgp_show_peer_reset(vty
, peer
, NULL
,
10691 /* Show BGP peer's summary information. */
10692 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10693 bool show_failed
, bool show_established
,
10697 struct listnode
*node
, *nnode
;
10698 unsigned int count
= 0, dn_count
= 0;
10699 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10700 char neighbor_buf
[VTY_BUFSIZ
];
10701 int neighbor_col_default_width
= 16;
10702 int len
, failed_count
= 0;
10703 int max_neighbor_width
= 0;
10705 json_object
*json
= NULL
;
10706 json_object
*json_peer
= NULL
;
10707 json_object
*json_peers
= NULL
;
10708 struct peer_af
*paf
;
10709 struct bgp_filter
*filter
;
10711 /* labeled-unicast routes are installed in the unicast table so in order
10713 * display the correct PfxRcd value we must look at SAFI_UNICAST
10716 if (safi
== SAFI_LABELED_UNICAST
)
10717 pfx_rcd_safi
= SAFI_UNICAST
;
10719 pfx_rcd_safi
= safi
;
10722 json
= json_object_new_object();
10723 json_peers
= json_object_new_object();
10724 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10725 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10728 if (peer
->afc
[afi
][safi
]) {
10729 /* See if we have at least a single failed peer */
10730 if (bgp_has_peer_failed(peer
, afi
, safi
))
10734 if (peer_dynamic_neighbor(peer
))
10739 /* Loop over all neighbors that will be displayed to determine
10741 * characters are needed for the Neighbor column
10743 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10744 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10747 if (peer
->afc
[afi
][safi
]) {
10748 memset(dn_flag
, '\0', sizeof(dn_flag
));
10749 if (peer_dynamic_neighbor(peer
))
10753 && CHECK_FLAG(bgp
->flags
,
10754 BGP_FLAG_SHOW_HOSTNAME
))
10755 snprintf(neighbor_buf
,
10756 sizeof(neighbor_buf
),
10757 "%s%s(%s) ", dn_flag
,
10758 peer
->hostname
, peer
->host
);
10760 snprintf(neighbor_buf
,
10761 sizeof(neighbor_buf
), "%s%s ",
10762 dn_flag
, peer
->host
);
10764 len
= strlen(neighbor_buf
);
10766 if (len
> max_neighbor_width
)
10767 max_neighbor_width
= len
;
10769 /* See if we have at least a single failed peer */
10770 if (bgp_has_peer_failed(peer
, afi
, safi
))
10776 /* Originally we displayed the Neighbor column as 16
10777 * characters wide so make that the default
10779 if (max_neighbor_width
< neighbor_col_default_width
)
10780 max_neighbor_width
= neighbor_col_default_width
;
10783 if (show_failed
&& !failed_count
) {
10785 json_object_int_add(json
, "failedPeersCount", 0);
10786 json_object_int_add(json
, "dynamicPeers", dn_count
);
10787 json_object_int_add(json
, "totalPeers", count
);
10789 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10790 json
, JSON_C_TO_STRING_PRETTY
));
10791 json_object_free(json
);
10793 vty_out(vty
, "%% No failed BGP neighbors found\n");
10794 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
10796 return CMD_SUCCESS
;
10799 count
= 0; /* Reset the value as its used again */
10800 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10801 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10804 if (!peer
->afc
[afi
][safi
])
10808 unsigned long ents
;
10809 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10812 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10814 : (int64_t)bgp
->vrf_id
;
10816 /* Usage summary and header */
10818 char buf
[BUFSIZ
] = {0};
10820 json_object_string_add(
10822 inet_ntop(AF_INET
, &bgp
->router_id
, buf
,
10824 json_object_int_add(json
, "as", bgp
->as
);
10825 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10826 json_object_string_add(
10829 == BGP_INSTANCE_TYPE_DEFAULT
)
10834 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10835 &bgp
->router_id
, bgp
->as
,
10836 bgp
->vrf_id
== VRF_UNKNOWN
10838 : (int)bgp
->vrf_id
);
10839 vty_out(vty
, "\n");
10842 if (bgp_update_delay_configured(bgp
)) {
10844 json_object_int_add(
10845 json
, "updateDelayLimit",
10846 bgp
->v_update_delay
);
10848 if (bgp
->v_update_delay
10849 != bgp
->v_establish_wait
)
10850 json_object_int_add(
10852 "updateDelayEstablishWait",
10853 bgp
->v_establish_wait
);
10855 if (bgp_update_delay_active(bgp
)) {
10856 json_object_string_add(
10858 "updateDelayFirstNeighbor",
10859 bgp
->update_delay_begin_time
);
10860 json_object_boolean_true_add(
10862 "updateDelayInProgress");
10864 if (bgp
->update_delay_over
) {
10865 json_object_string_add(
10867 "updateDelayFirstNeighbor",
10868 bgp
->update_delay_begin_time
);
10869 json_object_string_add(
10871 "updateDelayBestpathResumed",
10872 bgp
->update_delay_end_time
);
10873 json_object_string_add(
10875 "updateDelayZebraUpdateResume",
10876 bgp
->update_delay_zebra_resume_time
);
10877 json_object_string_add(
10879 "updateDelayPeerUpdateResume",
10880 bgp
->update_delay_peers_resume_time
);
10885 "Read-only mode update-delay limit: %d seconds\n",
10886 bgp
->v_update_delay
);
10887 if (bgp
->v_update_delay
10888 != bgp
->v_establish_wait
)
10890 " Establish wait: %d seconds\n",
10891 bgp
->v_establish_wait
);
10893 if (bgp_update_delay_active(bgp
)) {
10895 " First neighbor established: %s\n",
10896 bgp
->update_delay_begin_time
);
10898 " Delay in progress\n");
10900 if (bgp
->update_delay_over
) {
10902 " First neighbor established: %s\n",
10903 bgp
->update_delay_begin_time
);
10905 " Best-paths resumed: %s\n",
10906 bgp
->update_delay_end_time
);
10908 " zebra update resumed: %s\n",
10909 bgp
->update_delay_zebra_resume_time
);
10911 " peers update resumed: %s\n",
10912 bgp
->update_delay_peers_resume_time
);
10919 if (bgp_maxmed_onstartup_configured(bgp
)
10920 && bgp
->maxmed_active
)
10921 json_object_boolean_true_add(
10922 json
, "maxMedOnStartup");
10923 if (bgp
->v_maxmed_admin
)
10924 json_object_boolean_true_add(
10925 json
, "maxMedAdministrative");
10927 json_object_int_add(
10928 json
, "tableVersion",
10929 bgp_table_version(bgp
->rib
[afi
][safi
]));
10931 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10932 json_object_int_add(json
, "ribCount", ents
);
10933 json_object_int_add(
10935 ents
* sizeof(struct bgp_dest
));
10937 ents
= bgp
->af_peer_count
[afi
][safi
];
10938 json_object_int_add(json
, "peerCount", ents
);
10939 json_object_int_add(json
, "peerMemory",
10940 ents
* sizeof(struct peer
));
10942 if ((ents
= listcount(bgp
->group
))) {
10943 json_object_int_add(
10944 json
, "peerGroupCount", ents
);
10945 json_object_int_add(
10946 json
, "peerGroupMemory",
10947 ents
* sizeof(struct
10951 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10952 BGP_CONFIG_DAMPENING
))
10953 json_object_boolean_true_add(
10954 json
, "dampeningEnabled");
10956 if (bgp_maxmed_onstartup_configured(bgp
)
10957 && bgp
->maxmed_active
)
10959 "Max-med on-startup active\n");
10960 if (bgp
->v_maxmed_admin
)
10962 "Max-med administrative active\n");
10964 vty_out(vty
, "BGP table version %" PRIu64
"\n",
10965 bgp_table_version(bgp
->rib
[afi
][safi
]));
10967 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10969 "RIB entries %ld, using %s of memory\n",
10972 memstrbuf
, sizeof(memstrbuf
),
10977 /* Peer related usage */
10978 ents
= bgp
->af_peer_count
[afi
][safi
];
10979 vty_out(vty
, "Peers %ld, using %s of memory\n",
10982 memstrbuf
, sizeof(memstrbuf
),
10983 ents
* sizeof(struct peer
)));
10985 if ((ents
= listcount(bgp
->group
)))
10987 "Peer groups %ld, using %s of memory\n",
10992 ents
* sizeof(struct
10995 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10996 BGP_CONFIG_DAMPENING
))
10997 vty_out(vty
, "Dampening enabled.\n");
10998 vty_out(vty
, "\n");
11000 /* Subtract 8 here because 'Neighbor' is
11002 vty_out(vty
, "Neighbor");
11003 vty_out(vty
, "%*s", max_neighbor_width
- 8,
11006 vty_out(vty
, "EstdCnt DropCnt ResetTime Reason\n");
11009 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc\n");
11013 paf
= peer_af_find(peer
, afi
, safi
);
11014 filter
= &peer
->filter
[afi
][safi
];
11017 /* Works for both failed & successful cases */
11018 if (peer_dynamic_neighbor(peer
))
11025 bgp_has_peer_failed(peer
, afi
, safi
)) {
11026 json_peer
= json_object_new_object();
11027 bgp_show_failed_summary(vty
, bgp
, peer
,
11028 json_peer
, 0, use_json
);
11029 } else if (!show_failed
) {
11030 if (show_established
11031 && bgp_has_peer_failed(peer
, afi
, safi
))
11034 json_peer
= json_object_new_object();
11035 if (peer_dynamic_neighbor(peer
)) {
11036 json_object_boolean_true_add(json_peer
,
11040 if (peer
->hostname
)
11041 json_object_string_add(json_peer
, "hostname",
11044 if (peer
->domainname
)
11045 json_object_string_add(json_peer
, "domainname",
11048 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
11049 json_object_int_add(json_peer
, "version", 4);
11050 json_object_int_add(json_peer
, "msgRcvd",
11051 PEER_TOTAL_RX(peer
));
11052 json_object_int_add(json_peer
, "msgSent",
11053 PEER_TOTAL_TX(peer
));
11055 atomic_size_t outq_count
, inq_count
;
11056 outq_count
= atomic_load_explicit(
11057 &peer
->obuf
->count
,
11058 memory_order_relaxed
);
11059 inq_count
= atomic_load_explicit(
11060 &peer
->ibuf
->count
,
11061 memory_order_relaxed
);
11063 json_object_int_add(json_peer
, "tableVersion",
11064 peer
->version
[afi
][safi
]);
11065 json_object_int_add(json_peer
, "outq",
11067 json_object_int_add(json_peer
, "inq",
11069 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
11070 use_json
, json_peer
);
11072 json_object_int_add(json_peer
, "pfxRcd",
11073 peer
->pcount
[afi
][pfx_rcd_safi
]);
11075 if (paf
&& PAF_SUBGRP(paf
))
11076 json_object_int_add(
11077 json_peer
, "pfxSnt",
11078 (PAF_SUBGRP(paf
))->scount
);
11080 json_object_int_add(json_peer
, "pfxSnt",
11083 /* BGP FSM state */
11084 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11085 || CHECK_FLAG(peer
->bgp
->flags
,
11086 BGP_FLAG_SHUTDOWN
))
11087 json_object_string_add(json_peer
,
11090 else if (peer
->afc_recv
[afi
][safi
])
11091 json_object_string_add(
11092 json_peer
, "state",
11093 lookup_msg(bgp_status_msg
,
11094 peer
->status
, NULL
));
11095 else if (CHECK_FLAG(
11097 PEER_STATUS_PREFIX_OVERFLOW
))
11098 json_object_string_add(json_peer
,
11102 json_object_string_add(
11103 json_peer
, "state",
11104 lookup_msg(bgp_status_msg
,
11105 peer
->status
, NULL
));
11107 /* BGP peer state */
11108 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11109 || CHECK_FLAG(peer
->bgp
->flags
,
11110 BGP_FLAG_SHUTDOWN
))
11111 json_object_string_add(json_peer
,
11114 else if (CHECK_FLAG(
11116 PEER_STATUS_PREFIX_OVERFLOW
))
11117 json_object_string_add(json_peer
,
11120 else if (CHECK_FLAG(peer
->flags
,
11121 PEER_FLAG_PASSIVE
))
11122 json_object_string_add(json_peer
,
11125 else if (CHECK_FLAG(peer
->sflags
,
11126 PEER_STATUS_NSF_WAIT
))
11127 json_object_string_add(json_peer
,
11130 else if (CHECK_FLAG(
11132 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11133 && (!bgp_inbound_policy_exists(peer
,
11135 || !bgp_outbound_policy_exists(
11137 json_object_string_add(json_peer
,
11141 json_object_string_add(
11142 json_peer
, "peerState", "OK");
11144 json_object_int_add(json_peer
, "connectionsEstablished",
11145 peer
->established
);
11146 json_object_int_add(json_peer
, "connectionsDropped",
11149 json_object_string_add(
11150 json_peer
, "desc", peer
->desc
);
11152 /* Avoid creating empty peer dicts in JSON */
11153 if (json_peer
== NULL
)
11157 json_object_string_add(json_peer
, "idType",
11159 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11160 json_object_string_add(json_peer
, "idType",
11162 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11163 json_object_string_add(json_peer
, "idType",
11165 json_object_object_add(json_peers
, peer
->host
,
11169 bgp_has_peer_failed(peer
, afi
, safi
)) {
11170 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11171 max_neighbor_width
,
11173 } else if (!show_failed
) {
11174 if (show_established
11175 && bgp_has_peer_failed(peer
, afi
, safi
))
11178 memset(dn_flag
, '\0', sizeof(dn_flag
));
11179 if (peer_dynamic_neighbor(peer
)) {
11184 && CHECK_FLAG(bgp
->flags
,
11185 BGP_FLAG_SHOW_HOSTNAME
))
11186 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11190 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11192 /* pad the neighbor column with spaces */
11193 if (len
< max_neighbor_width
)
11194 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11197 atomic_size_t outq_count
, inq_count
;
11198 outq_count
= atomic_load_explicit(
11199 &peer
->obuf
->count
,
11200 memory_order_relaxed
);
11201 inq_count
= atomic_load_explicit(
11202 &peer
->ibuf
->count
,
11203 memory_order_relaxed
);
11206 "4 %10u %9u %9u %8" PRIu64
" %4zu %4zu %8s",
11207 peer
->as
, PEER_TOTAL_RX(peer
),
11208 PEER_TOTAL_TX(peer
),
11209 peer
->version
[afi
][safi
], inq_count
,
11211 peer_uptime(peer
->uptime
, timebuf
,
11212 BGP_UPTIME_LEN
, 0, NULL
));
11214 if (peer
->status
== Established
) {
11215 if (peer
->afc_recv
[afi
][safi
]) {
11218 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11219 && !bgp_inbound_policy_exists(
11221 vty_out(vty
, " %12s",
11230 vty_out(vty
, " NoNeg");
11233 if (paf
&& PAF_SUBGRP(paf
)) {
11236 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11237 && !bgp_outbound_policy_exists(
11239 vty_out(vty
, " %8s",
11249 if (CHECK_FLAG(peer
->flags
,
11250 PEER_FLAG_SHUTDOWN
)
11251 || CHECK_FLAG(peer
->bgp
->flags
,
11252 BGP_FLAG_SHUTDOWN
))
11253 vty_out(vty
, " Idle (Admin)");
11254 else if (CHECK_FLAG(
11256 PEER_STATUS_PREFIX_OVERFLOW
))
11257 vty_out(vty
, " Idle (PfxCt)");
11259 vty_out(vty
, " %12s",
11260 lookup_msg(bgp_status_msg
,
11261 peer
->status
, NULL
));
11263 vty_out(vty
, " %8u", 0);
11266 vty_out(vty
, " %s", peer
->desc
);
11268 vty_out(vty
, " N/A");
11269 vty_out(vty
, "\n");
11276 json_object_object_add(json
, "peers", json_peers
);
11277 json_object_int_add(json
, "failedPeers", failed_count
);
11278 json_object_int_add(json
, "totalPeers", count
);
11279 json_object_int_add(json
, "dynamicPeers", dn_count
);
11282 bgp_show_bestpath_json(bgp
, json
);
11284 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11285 json
, JSON_C_TO_STRING_PRETTY
));
11286 json_object_free(json
);
11289 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
11291 vty_out(vty
, "No %s neighbor is configured\n",
11292 get_afi_safi_str(afi
, safi
, false));
11296 vty_out(vty
, "* - dynamic neighbor\n");
11297 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11298 dn_count
, bgp
->dynamic_neighbors_limit
);
11302 return CMD_SUCCESS
;
11305 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11306 int safi
, bool show_failed
,
11307 bool show_established
, bool use_json
)
11310 int afi_wildcard
= (afi
== AFI_MAX
);
11311 int safi_wildcard
= (safi
== SAFI_MAX
);
11312 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11313 bool nbr_output
= false;
11315 if (use_json
&& is_wildcard
)
11316 vty_out(vty
, "{\n");
11318 afi
= 1; /* AFI_IP */
11319 while (afi
< AFI_MAX
) {
11321 safi
= 1; /* SAFI_UNICAST */
11322 while (safi
< SAFI_MAX
) {
11323 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11328 * So limit output to those afi/safi
11330 * actualy have something interesting in
11335 vty_out(vty
, ",\n");
11339 vty_out(vty
, "\"%s\":",
11340 get_afi_safi_str(afi
,
11344 vty_out(vty
, "\n%s Summary:\n",
11345 get_afi_safi_str(afi
,
11350 bgp_show_summary(vty
, bgp
, afi
, safi
,
11351 show_failed
, show_established
,
11355 if (!safi_wildcard
)
11363 if (use_json
&& is_wildcard
)
11364 vty_out(vty
, "}\n");
11365 else if (!nbr_output
) {
11367 vty_out(vty
, "{}\n");
11369 vty_out(vty
, "%% No BGP neighbors found\n");
11373 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11374 safi_t safi
, bool show_failed
,
11375 bool show_established
,
11378 struct listnode
*node
, *nnode
;
11381 bool nbr_output
= false;
11384 vty_out(vty
, "{\n");
11386 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11390 vty_out(vty
, ",\n");
11394 vty_out(vty
, "\"%s\":",
11395 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11399 vty_out(vty
, "\nInstance %s:\n",
11400 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11404 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
11405 show_established
, use_json
);
11409 vty_out(vty
, "}\n");
11410 else if (!nbr_output
)
11411 vty_out(vty
, "%% BGP instance not found\n");
11414 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11415 safi_t safi
, bool show_failed
, bool show_established
,
11421 if (strmatch(name
, "all")) {
11422 bgp_show_all_instances_summary_vty(
11423 vty
, afi
, safi
, show_failed
, show_established
,
11425 return CMD_SUCCESS
;
11427 bgp
= bgp_lookup_by_name(name
);
11431 vty_out(vty
, "{}\n");
11434 "%% BGP instance not found\n");
11435 return CMD_WARNING
;
11438 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
,
11439 show_failed
, show_established
,
11441 return CMD_SUCCESS
;
11445 bgp
= bgp_get_default();
11448 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
11449 show_established
, use_json
);
11452 vty_out(vty
, "{}\n");
11454 vty_out(vty
, "%% BGP instance not found\n");
11455 return CMD_WARNING
;
11458 return CMD_SUCCESS
;
11461 /* `show [ip] bgp summary' commands. */
11462 DEFPY (show_ip_bgp_summary
,
11463 show_ip_bgp_summary_cmd
,
11464 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] [all$all] summary [established|failed] [json$uj]",
11468 BGP_INSTANCE_HELP_STR
11470 BGP_SAFI_WITH_LABEL_HELP_STR
11471 "Display the entries for all address families\n"
11472 "Summary of BGP neighbor status\n"
11473 "Show only sessions in Established state\n"
11474 "Show only sessions not in Established state\n"
11478 afi_t afi
= AFI_MAX
;
11479 safi_t safi
= SAFI_MAX
;
11480 bool show_failed
= false;
11481 bool show_established
= false;
11485 /* show [ip] bgp */
11486 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11488 /* [<vrf> VIEWVRFNAME] */
11489 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11490 vrf
= argv
[idx
+ 1]->arg
;
11491 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11493 } else if (argv_find(argv
, argc
, "view", &idx
))
11494 /* [<view> VIEWVRFNAME] */
11495 vrf
= argv
[idx
+ 1]->arg
;
11496 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11497 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11498 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11501 if (argv_find(argv
, argc
, "failed", &idx
))
11502 show_failed
= true;
11503 if (argv_find(argv
, argc
, "established", &idx
))
11504 show_established
= true;
11506 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, show_failed
,
11507 show_established
, uj
);
11510 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11513 return get_afi_safi_json_str(afi
, safi
);
11515 return get_afi_safi_vty_str(afi
, safi
);
11519 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11520 afi_t afi
, safi_t safi
,
11521 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11522 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11523 bool use_json
, json_object
*json_pref
)
11526 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11527 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11529 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11530 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11531 json_object_string_add(json_pref
, "sendMode",
11532 "advertisedAndReceived");
11533 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11534 json_object_string_add(json_pref
, "sendMode",
11536 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11537 json_object_string_add(json_pref
, "sendMode",
11540 vty_out(vty
, " Send-mode: ");
11541 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11542 vty_out(vty
, "advertised");
11543 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11544 vty_out(vty
, "%sreceived",
11545 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11549 vty_out(vty
, "\n");
11554 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11555 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11557 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11558 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11559 json_object_string_add(json_pref
, "recvMode",
11560 "advertisedAndReceived");
11561 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11562 json_object_string_add(json_pref
, "recvMode",
11564 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11565 json_object_string_add(json_pref
, "recvMode",
11568 vty_out(vty
, " Receive-mode: ");
11569 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11570 vty_out(vty
, "advertised");
11571 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11572 vty_out(vty
, "%sreceived",
11573 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11577 vty_out(vty
, "\n");
11582 static void bgp_show_neighnor_graceful_restart_rbit(struct vty
*vty
,
11587 bool rbit_status
= false;
11590 vty_out(vty
, "\n R bit: ");
11592 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11593 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11594 && (p
->status
== Established
)) {
11596 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_BIT_RCV
))
11597 rbit_status
= true;
11599 rbit_status
= false;
11604 json_object_boolean_true_add(json
, "rBit");
11606 vty_out(vty
, "True\n");
11609 json_object_boolean_false_add(json
, "rBit");
11611 vty_out(vty
, "False\n");
11615 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11620 const char *mode
= "NotApplicable";
11623 vty_out(vty
, "\n Remote GR Mode: ");
11625 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11626 && (peer
->status
== Established
)) {
11628 if ((peer
->nsf_af_count
== 0)
11629 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11633 } else if (peer
->nsf_af_count
== 0
11634 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11638 } else if (peer
->nsf_af_count
!= 0
11639 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11646 json_object_string_add(json
, "remoteGrMode", mode
);
11648 vty_out(vty
, mode
, "\n");
11651 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11656 const char *mode
= "Invalid";
11659 vty_out(vty
, " Local GR Mode: ");
11661 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11663 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11665 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11667 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11668 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11670 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11672 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11679 json_object_string_add(json
, "localGrMode", mode
);
11681 vty_out(vty
, mode
, "\n");
11685 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11686 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11690 json_object
*json_afi_safi
= NULL
;
11691 json_object
*json_timer
= NULL
;
11692 json_object
*json_endofrib_status
= NULL
;
11693 bool eor_flag
= false;
11695 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11696 for (safi
= SAFI_UNICAST
; safi
<= SAFI_MPLS_VPN
; safi
++) {
11697 if (!peer
->afc
[afi
][safi
])
11700 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11701 || !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11705 json_afi_safi
= json_object_new_object();
11706 json_endofrib_status
= json_object_new_object();
11707 json_timer
= json_object_new_object();
11710 if (peer
->eor_stime
[afi
][safi
]
11711 >= peer
->pkt_stime
[afi
][safi
])
11717 vty_out(vty
, " %s:\n",
11718 get_afi_safi_str(afi
, safi
, false));
11720 vty_out(vty
, " F bit: ");
11723 if (peer
->nsf
[afi
][safi
]
11724 && CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11725 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11728 json_object_boolean_true_add(
11729 json_afi_safi
, "fBit");
11731 vty_out(vty
, "True\n");
11734 json_object_boolean_false_add(
11735 json_afi_safi
, "fBit");
11737 vty_out(vty
, "False\n");
11741 vty_out(vty
, " End-of-RIB sent: ");
11743 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11744 PEER_STATUS_EOR_SEND
)) {
11746 json_object_boolean_true_add(
11747 json_endofrib_status
,
11750 PRINT_EOR_JSON(eor_flag
);
11752 vty_out(vty
, "Yes\n");
11754 " End-of-RIB sent after update: ");
11756 PRINT_EOR(eor_flag
);
11760 json_object_boolean_false_add(
11761 json_endofrib_status
,
11763 json_object_boolean_false_add(
11764 json_endofrib_status
,
11765 "endOfRibSentAfterUpdate");
11767 vty_out(vty
, "No\n");
11769 " End-of-RIB sent after update: ");
11770 vty_out(vty
, "No\n");
11775 vty_out(vty
, " End-of-RIB received: ");
11777 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11778 PEER_STATUS_EOR_RECEIVED
)) {
11780 json_object_boolean_true_add(
11781 json_endofrib_status
,
11784 vty_out(vty
, "Yes\n");
11787 json_object_boolean_false_add(
11788 json_endofrib_status
,
11791 vty_out(vty
, "No\n");
11795 json_object_int_add(json_timer
,
11797 peer
->bgp
->stalepath_time
);
11799 if (peer
->t_gr_stale
!= NULL
) {
11800 json_object_int_add(
11802 "stalePathTimerRemaining",
11803 thread_timer_remain_second(
11804 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
)) {
11813 json_object_int_add(
11815 "selectionDeferralTimer",
11816 peer
->bgp
->stalepath_time
);
11819 if (peer
->bgp
->gr_info
[afi
][safi
]
11823 json_object_int_add(
11825 "selectionDeferralTimerRemaining",
11826 thread_timer_remain_second(
11830 .t_select_deferral
));
11833 vty_out(vty
, " Timers:\n");
11835 " Configured Stale Path Time(sec): %u\n",
11836 peer
->bgp
->stalepath_time
);
11838 if (peer
->t_gr_stale
!= NULL
)
11840 " Stale Path Remaining(sec): %ld\n",
11841 thread_timer_remain_second(
11842 peer
->t_gr_stale
));
11843 /* Display Configured Selection
11844 * Deferral only when when
11845 * Gr mode is enabled.
11847 if (CHECK_FLAG(peer
->flags
,
11848 PEER_FLAG_GRACEFUL_RESTART
))
11850 " Configured Selection Deferral Time(sec): %u\n",
11851 peer
->bgp
->select_defer_time
);
11853 if (peer
->bgp
->gr_info
[afi
][safi
]
11857 " Selection Deferral Time Remaining(sec): %ld\n",
11858 thread_timer_remain_second(
11862 .t_select_deferral
));
11865 json_object_object_add(json_afi_safi
,
11867 json_endofrib_status
);
11868 json_object_object_add(json_afi_safi
, "timers",
11870 json_object_object_add(
11871 json
, get_afi_safi_str(afi
, safi
, true),
11878 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
11884 json_object
*json_timer
= NULL
;
11886 json_timer
= json_object_new_object();
11888 json_object_int_add(json_timer
, "configuredRestartTimer",
11889 p
->bgp
->restart_time
);
11891 json_object_int_add(json_timer
, "receivedRestartTimer",
11894 if (p
->t_gr_restart
!= NULL
)
11895 json_object_int_add(
11896 json_timer
, "restartTimerRemaining",
11897 thread_timer_remain_second(p
->t_gr_restart
));
11899 json_object_object_add(json
, "timers", json_timer
);
11902 vty_out(vty
, " Timers:\n");
11903 vty_out(vty
, " Configured Restart Time(sec): %u\n",
11904 p
->bgp
->restart_time
);
11906 vty_out(vty
, " Received Restart Time(sec): %u\n",
11908 if (p
->t_gr_restart
!= NULL
)
11909 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11910 thread_timer_remain_second(p
->t_gr_restart
));
11911 if (p
->t_gr_restart
!= NULL
) {
11912 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11913 thread_timer_remain_second(p
->t_gr_restart
));
11918 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
11919 bool use_json
, json_object
*json
)
11921 char buf
[SU_ADDRSTRLEN
] = {0};
11922 char dn_flag
[2] = {0};
11923 /* '*' + v6 address of neighbor */
11924 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
11926 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11931 json_object_string_add(
11932 json
, "neighborAddr",
11933 BGP_PEER_SU_UNSPEC(p
)
11935 : sockunion2str(&p
->su
, buf
,
11938 vty_out(vty
, "BGP neighbor on %s: %s\n", p
->conf_if
,
11939 BGP_PEER_SU_UNSPEC(p
)
11941 : sockunion2str(&p
->su
, buf
,
11944 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
11948 json_object_string_add(json
, "neighborAddr",
11951 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
11954 /* more gr info in new format */
11955 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
11958 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
11959 safi_t safi
, bool use_json
,
11960 json_object
*json_neigh
)
11962 struct bgp_filter
*filter
;
11963 struct peer_af
*paf
;
11964 char orf_pfx_name
[BUFSIZ
];
11966 json_object
*json_af
= NULL
;
11967 json_object
*json_prefA
= NULL
;
11968 json_object
*json_prefB
= NULL
;
11969 json_object
*json_addr
= NULL
;
11970 json_object
*json_advmap
= NULL
;
11973 json_addr
= json_object_new_object();
11974 json_af
= json_object_new_object();
11975 filter
= &p
->filter
[afi
][safi
];
11977 if (peer_group_active(p
))
11978 json_object_string_add(json_addr
, "peerGroupMember",
11981 paf
= peer_af_find(p
, afi
, safi
);
11982 if (paf
&& PAF_SUBGRP(paf
)) {
11983 json_object_int_add(json_addr
, "updateGroupId",
11984 PAF_UPDGRP(paf
)->id
);
11985 json_object_int_add(json_addr
, "subGroupId",
11986 PAF_SUBGRP(paf
)->id
);
11987 json_object_int_add(json_addr
, "packetQueueLength",
11988 bpacket_queue_virtual_length(paf
));
11991 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11992 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11993 PEER_CAP_ORF_PREFIX_SM_RCV
)
11994 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11995 PEER_CAP_ORF_PREFIX_RM_ADV
)
11996 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11997 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11998 json_object_int_add(json_af
, "orfType",
12000 json_prefA
= json_object_new_object();
12001 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
12002 PEER_CAP_ORF_PREFIX_SM_ADV
,
12003 PEER_CAP_ORF_PREFIX_RM_ADV
,
12004 PEER_CAP_ORF_PREFIX_SM_RCV
,
12005 PEER_CAP_ORF_PREFIX_RM_RCV
,
12006 use_json
, json_prefA
);
12007 json_object_object_add(json_af
, "orfPrefixList",
12011 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12012 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12013 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12014 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12015 PEER_CAP_ORF_PREFIX_RM_ADV
)
12016 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12017 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12018 json_object_int_add(json_af
, "orfOldType",
12019 ORF_TYPE_PREFIX_OLD
);
12020 json_prefB
= json_object_new_object();
12021 bgp_show_peer_afi_orf_cap(
12022 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12023 PEER_CAP_ORF_PREFIX_RM_ADV
,
12024 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12025 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
12027 json_object_object_add(json_af
, "orfOldPrefixList",
12031 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12032 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12033 PEER_CAP_ORF_PREFIX_SM_RCV
)
12034 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12035 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12036 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12037 PEER_CAP_ORF_PREFIX_RM_ADV
)
12038 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12039 PEER_CAP_ORF_PREFIX_RM_RCV
)
12040 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12041 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12042 json_object_object_add(json_addr
, "afDependentCap",
12045 json_object_free(json_af
);
12047 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12048 p
->host
, afi
, safi
);
12049 orf_pfx_count
= prefix_bgp_show_prefix_list(
12050 NULL
, afi
, orf_pfx_name
, use_json
);
12052 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12053 PEER_STATUS_ORF_PREFIX_SEND
)
12054 || orf_pfx_count
) {
12055 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12056 PEER_STATUS_ORF_PREFIX_SEND
))
12057 json_object_boolean_true_add(json_neigh
,
12060 json_object_int_add(json_addr
, "orfRecvCounter",
12063 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12064 PEER_STATUS_ORF_WAIT_REFRESH
))
12065 json_object_string_add(
12066 json_addr
, "orfFirstUpdate",
12067 "deferredUntilORFOrRouteRefreshRecvd");
12069 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12070 PEER_FLAG_REFLECTOR_CLIENT
))
12071 json_object_boolean_true_add(json_addr
,
12072 "routeReflectorClient");
12073 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12074 PEER_FLAG_RSERVER_CLIENT
))
12075 json_object_boolean_true_add(json_addr
,
12076 "routeServerClient");
12077 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12078 json_object_boolean_true_add(json_addr
,
12079 "inboundSoftConfigPermit");
12081 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12082 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12083 json_object_boolean_true_add(
12085 "privateAsNumsAllReplacedInUpdatesToNbr");
12086 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12087 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12088 json_object_boolean_true_add(
12090 "privateAsNumsReplacedInUpdatesToNbr");
12091 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12092 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12093 json_object_boolean_true_add(
12095 "privateAsNumsAllRemovedInUpdatesToNbr");
12096 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12097 PEER_FLAG_REMOVE_PRIVATE_AS
))
12098 json_object_boolean_true_add(
12100 "privateAsNumsRemovedInUpdatesToNbr");
12102 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12103 json_object_boolean_true_add(
12105 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12108 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12109 json_object_string_add(json_addr
,
12110 "overrideASNsInOutboundUpdates",
12111 "ifAspathEqualRemoteAs");
12113 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12114 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12115 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12116 json_object_boolean_true_add(json_addr
,
12117 "routerAlwaysNextHop");
12118 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12119 PEER_FLAG_AS_PATH_UNCHANGED
))
12120 json_object_boolean_true_add(
12121 json_addr
, "unchangedAsPathPropogatedToNbr");
12122 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12123 PEER_FLAG_NEXTHOP_UNCHANGED
))
12124 json_object_boolean_true_add(
12125 json_addr
, "unchangedNextHopPropogatedToNbr");
12126 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12127 json_object_boolean_true_add(
12128 json_addr
, "unchangedMedPropogatedToNbr");
12129 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12130 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12131 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12132 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12133 PEER_FLAG_SEND_COMMUNITY
)
12134 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12135 PEER_FLAG_SEND_EXT_COMMUNITY
))
12136 json_object_string_add(json_addr
,
12137 "commAttriSentToNbr",
12138 "extendedAndStandard");
12139 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12140 PEER_FLAG_SEND_EXT_COMMUNITY
))
12141 json_object_string_add(json_addr
,
12142 "commAttriSentToNbr",
12145 json_object_string_add(json_addr
,
12146 "commAttriSentToNbr",
12149 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12150 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12151 if (p
->default_rmap
[afi
][safi
].name
)
12152 json_object_string_add(
12153 json_addr
, "defaultRouteMap",
12154 p
->default_rmap
[afi
][safi
].name
);
12156 if (paf
&& PAF_SUBGRP(paf
)
12157 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12158 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12159 json_object_boolean_true_add(json_addr
,
12162 json_object_boolean_true_add(json_addr
,
12166 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12167 if (is_evpn_enabled())
12168 json_object_boolean_true_add(
12169 json_addr
, "advertiseAllVnis");
12172 if (filter
->plist
[FILTER_IN
].name
12173 || filter
->dlist
[FILTER_IN
].name
12174 || filter
->aslist
[FILTER_IN
].name
12175 || filter
->map
[RMAP_IN
].name
)
12176 json_object_boolean_true_add(json_addr
,
12177 "inboundPathPolicyConfig");
12178 if (filter
->plist
[FILTER_OUT
].name
12179 || filter
->dlist
[FILTER_OUT
].name
12180 || filter
->aslist
[FILTER_OUT
].name
12181 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12182 json_object_boolean_true_add(
12183 json_addr
, "outboundPathPolicyConfig");
12186 if (filter
->plist
[FILTER_IN
].name
)
12187 json_object_string_add(json_addr
,
12188 "incomingUpdatePrefixFilterList",
12189 filter
->plist
[FILTER_IN
].name
);
12190 if (filter
->plist
[FILTER_OUT
].name
)
12191 json_object_string_add(json_addr
,
12192 "outgoingUpdatePrefixFilterList",
12193 filter
->plist
[FILTER_OUT
].name
);
12195 /* distribute-list */
12196 if (filter
->dlist
[FILTER_IN
].name
)
12197 json_object_string_add(
12198 json_addr
, "incomingUpdateNetworkFilterList",
12199 filter
->dlist
[FILTER_IN
].name
);
12200 if (filter
->dlist
[FILTER_OUT
].name
)
12201 json_object_string_add(
12202 json_addr
, "outgoingUpdateNetworkFilterList",
12203 filter
->dlist
[FILTER_OUT
].name
);
12206 if (filter
->aslist
[FILTER_IN
].name
)
12207 json_object_string_add(json_addr
,
12208 "incomingUpdateAsPathFilterList",
12209 filter
->aslist
[FILTER_IN
].name
);
12210 if (filter
->aslist
[FILTER_OUT
].name
)
12211 json_object_string_add(json_addr
,
12212 "outgoingUpdateAsPathFilterList",
12213 filter
->aslist
[FILTER_OUT
].name
);
12216 if (filter
->map
[RMAP_IN
].name
)
12217 json_object_string_add(
12218 json_addr
, "routeMapForIncomingAdvertisements",
12219 filter
->map
[RMAP_IN
].name
);
12220 if (filter
->map
[RMAP_OUT
].name
)
12221 json_object_string_add(
12222 json_addr
, "routeMapForOutgoingAdvertisements",
12223 filter
->map
[RMAP_OUT
].name
);
12225 /* ebgp-requires-policy (inbound) */
12226 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12227 && !bgp_inbound_policy_exists(p
, filter
))
12228 json_object_string_add(
12229 json_addr
, "inboundEbgpRequiresPolicy",
12230 "Inbound updates discarded due to missing policy");
12232 /* ebgp-requires-policy (outbound) */
12233 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12234 && (!bgp_outbound_policy_exists(p
, filter
)))
12235 json_object_string_add(
12236 json_addr
, "outboundEbgpRequiresPolicy",
12237 "Outbound updates discarded due to missing policy");
12239 /* unsuppress-map */
12240 if (filter
->usmap
.name
)
12241 json_object_string_add(json_addr
,
12242 "selectiveUnsuppressRouteMap",
12243 filter
->usmap
.name
);
12245 /* advertise-map */
12246 if (filter
->advmap
.aname
) {
12247 json_advmap
= json_object_new_object();
12248 json_object_string_add(json_advmap
, "condition",
12249 filter
->advmap
.condition
12252 json_object_string_add(json_advmap
, "conditionMap",
12253 filter
->advmap
.cname
);
12254 json_object_string_add(json_advmap
, "advertiseMap",
12255 filter
->advmap
.aname
);
12256 json_object_string_add(json_advmap
, "advertiseStatus",
12257 filter
->advmap
.update_type
12261 json_object_object_add(json_addr
, "advertiseMap",
12265 /* Receive prefix count */
12266 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12267 p
->pcount
[afi
][safi
]);
12268 if (paf
&& PAF_SUBGRP(paf
))
12269 json_object_int_add(json_addr
, "sentPrefixCounter",
12270 (PAF_SUBGRP(paf
))->scount
);
12272 /* Maximum prefix */
12273 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12274 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12275 p
->pmax_out
[afi
][safi
]);
12277 /* Maximum prefix */
12278 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12279 json_object_int_add(json_addr
, "prefixAllowedMax",
12280 p
->pmax
[afi
][safi
]);
12281 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12282 PEER_FLAG_MAX_PREFIX_WARNING
))
12283 json_object_boolean_true_add(
12284 json_addr
, "prefixAllowedMaxWarning");
12285 json_object_int_add(json_addr
,
12286 "prefixAllowedWarningThresh",
12287 p
->pmax_threshold
[afi
][safi
]);
12288 if (p
->pmax_restart
[afi
][safi
])
12289 json_object_int_add(
12291 "prefixAllowedRestartIntervalMsecs",
12292 p
->pmax_restart
[afi
][safi
] * 60000);
12294 json_object_object_add(json_neigh
,
12295 get_afi_safi_str(afi
, safi
, true),
12299 filter
= &p
->filter
[afi
][safi
];
12301 vty_out(vty
, " For address family: %s\n",
12302 get_afi_safi_str(afi
, safi
, false));
12304 if (peer_group_active(p
))
12305 vty_out(vty
, " %s peer-group member\n",
12308 paf
= peer_af_find(p
, afi
, safi
);
12309 if (paf
&& PAF_SUBGRP(paf
)) {
12310 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12311 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12312 vty_out(vty
, " Packet Queue length %d\n",
12313 bpacket_queue_virtual_length(paf
));
12315 vty_out(vty
, " Not part of any update group\n");
12317 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12318 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12319 PEER_CAP_ORF_PREFIX_SM_RCV
)
12320 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12321 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12322 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12323 PEER_CAP_ORF_PREFIX_RM_ADV
)
12324 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12325 PEER_CAP_ORF_PREFIX_RM_RCV
)
12326 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12327 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12328 vty_out(vty
, " AF-dependant capabilities:\n");
12330 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12331 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12332 PEER_CAP_ORF_PREFIX_SM_RCV
)
12333 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12334 PEER_CAP_ORF_PREFIX_RM_ADV
)
12335 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12336 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12338 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12340 bgp_show_peer_afi_orf_cap(
12341 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12342 PEER_CAP_ORF_PREFIX_RM_ADV
,
12343 PEER_CAP_ORF_PREFIX_SM_RCV
,
12344 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12346 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12347 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12348 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12349 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12350 PEER_CAP_ORF_PREFIX_RM_ADV
)
12351 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12352 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12354 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12355 ORF_TYPE_PREFIX_OLD
);
12356 bgp_show_peer_afi_orf_cap(
12357 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12358 PEER_CAP_ORF_PREFIX_RM_ADV
,
12359 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12360 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12363 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12364 p
->host
, afi
, safi
);
12365 orf_pfx_count
= prefix_bgp_show_prefix_list(
12366 NULL
, afi
, orf_pfx_name
, use_json
);
12368 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12369 PEER_STATUS_ORF_PREFIX_SEND
)
12370 || orf_pfx_count
) {
12371 vty_out(vty
, " Outbound Route Filter (ORF):");
12372 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12373 PEER_STATUS_ORF_PREFIX_SEND
))
12374 vty_out(vty
, " sent;");
12376 vty_out(vty
, " received (%d entries)",
12378 vty_out(vty
, "\n");
12380 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12381 PEER_STATUS_ORF_WAIT_REFRESH
))
12383 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12385 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12386 PEER_FLAG_REFLECTOR_CLIENT
))
12387 vty_out(vty
, " Route-Reflector Client\n");
12388 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12389 PEER_FLAG_RSERVER_CLIENT
))
12390 vty_out(vty
, " Route-Server Client\n");
12391 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12393 " Inbound soft reconfiguration allowed\n");
12395 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12396 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12398 " Private AS numbers (all) replaced in updates to this neighbor\n");
12399 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12400 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12402 " Private AS numbers replaced in updates to this neighbor\n");
12403 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12404 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12406 " Private AS numbers (all) removed in updates to this neighbor\n");
12407 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12408 PEER_FLAG_REMOVE_PRIVATE_AS
))
12410 " Private AS numbers removed in updates to this neighbor\n");
12412 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12413 vty_out(vty
, " %s\n",
12414 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12415 ->human_description
);
12417 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12419 " Override ASNs in outbound updates if aspath equals remote-as\n");
12421 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12422 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12423 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12424 vty_out(vty
, " NEXT_HOP is always this router\n");
12425 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12426 PEER_FLAG_AS_PATH_UNCHANGED
))
12428 " AS_PATH is propagated unchanged to this neighbor\n");
12429 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12430 PEER_FLAG_NEXTHOP_UNCHANGED
))
12432 " NEXT_HOP is propagated unchanged to this neighbor\n");
12433 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12435 " MED is propagated unchanged to this neighbor\n");
12436 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12437 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12438 PEER_FLAG_SEND_EXT_COMMUNITY
)
12439 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12440 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12442 " Community attribute sent to this neighbor");
12443 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12444 PEER_FLAG_SEND_COMMUNITY
)
12445 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12446 PEER_FLAG_SEND_EXT_COMMUNITY
)
12447 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12448 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12449 vty_out(vty
, "(all)\n");
12450 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12451 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12452 vty_out(vty
, "(large)\n");
12453 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12454 PEER_FLAG_SEND_EXT_COMMUNITY
))
12455 vty_out(vty
, "(extended)\n");
12457 vty_out(vty
, "(standard)\n");
12459 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12460 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12461 vty_out(vty
, " Default information originate,");
12463 if (p
->default_rmap
[afi
][safi
].name
)
12464 vty_out(vty
, " default route-map %s%s,",
12465 p
->default_rmap
[afi
][safi
].map
? "*"
12467 p
->default_rmap
[afi
][safi
].name
);
12468 if (paf
&& PAF_SUBGRP(paf
)
12469 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12470 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12471 vty_out(vty
, " default sent\n");
12473 vty_out(vty
, " default not sent\n");
12476 /* advertise-vni-all */
12477 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12478 if (is_evpn_enabled())
12479 vty_out(vty
, " advertise-all-vni\n");
12482 if (filter
->plist
[FILTER_IN
].name
12483 || filter
->dlist
[FILTER_IN
].name
12484 || filter
->aslist
[FILTER_IN
].name
12485 || filter
->map
[RMAP_IN
].name
)
12486 vty_out(vty
, " Inbound path policy configured\n");
12487 if (filter
->plist
[FILTER_OUT
].name
12488 || filter
->dlist
[FILTER_OUT
].name
12489 || filter
->aslist
[FILTER_OUT
].name
12490 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12491 vty_out(vty
, " Outbound path policy configured\n");
12494 if (filter
->plist
[FILTER_IN
].name
)
12496 " Incoming update prefix filter list is %s%s\n",
12497 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12498 filter
->plist
[FILTER_IN
].name
);
12499 if (filter
->plist
[FILTER_OUT
].name
)
12501 " Outgoing update prefix filter list is %s%s\n",
12502 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12503 filter
->plist
[FILTER_OUT
].name
);
12505 /* distribute-list */
12506 if (filter
->dlist
[FILTER_IN
].name
)
12508 " Incoming update network filter list is %s%s\n",
12509 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12510 filter
->dlist
[FILTER_IN
].name
);
12511 if (filter
->dlist
[FILTER_OUT
].name
)
12513 " Outgoing update network filter list is %s%s\n",
12514 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12515 filter
->dlist
[FILTER_OUT
].name
);
12518 if (filter
->aslist
[FILTER_IN
].name
)
12520 " Incoming update AS path filter list is %s%s\n",
12521 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12522 filter
->aslist
[FILTER_IN
].name
);
12523 if (filter
->aslist
[FILTER_OUT
].name
)
12525 " Outgoing update AS path filter list is %s%s\n",
12526 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12527 filter
->aslist
[FILTER_OUT
].name
);
12530 if (filter
->map
[RMAP_IN
].name
)
12532 " Route map for incoming advertisements is %s%s\n",
12533 filter
->map
[RMAP_IN
].map
? "*" : "",
12534 filter
->map
[RMAP_IN
].name
);
12535 if (filter
->map
[RMAP_OUT
].name
)
12537 " Route map for outgoing advertisements is %s%s\n",
12538 filter
->map
[RMAP_OUT
].map
? "*" : "",
12539 filter
->map
[RMAP_OUT
].name
);
12541 /* ebgp-requires-policy (inbound) */
12542 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12543 && !bgp_inbound_policy_exists(p
, filter
))
12545 " Inbound updates discarded due to missing policy\n");
12547 /* ebgp-requires-policy (outbound) */
12548 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12549 && !bgp_outbound_policy_exists(p
, filter
))
12551 " Outbound updates discarded due to missing policy\n");
12553 /* unsuppress-map */
12554 if (filter
->usmap
.name
)
12556 " Route map for selective unsuppress is %s%s\n",
12557 filter
->usmap
.map
? "*" : "",
12558 filter
->usmap
.name
);
12560 /* advertise-map */
12561 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12563 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12564 filter
->advmap
.condition
? "EXIST"
12566 filter
->advmap
.cmap
? "*" : "",
12567 filter
->advmap
.cname
,
12568 filter
->advmap
.amap
? "*" : "",
12569 filter
->advmap
.aname
,
12570 filter
->advmap
.update_type
== ADVERTISE
12574 /* Receive prefix count */
12575 vty_out(vty
, " %u accepted prefixes\n",
12576 p
->pcount
[afi
][safi
]);
12578 /* maximum-prefix-out */
12579 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12580 PEER_FLAG_MAX_PREFIX_OUT
))
12582 " Maximum allowed prefixes sent %u\n",
12583 p
->pmax_out
[afi
][safi
]);
12585 /* Maximum prefix */
12586 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12588 " Maximum prefixes allowed %u%s\n",
12589 p
->pmax
[afi
][safi
],
12590 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12591 PEER_FLAG_MAX_PREFIX_WARNING
)
12592 ? " (warning-only)"
12594 vty_out(vty
, " Threshold for warning message %d%%",
12595 p
->pmax_threshold
[afi
][safi
]);
12596 if (p
->pmax_restart
[afi
][safi
])
12597 vty_out(vty
, ", restart interval %d min",
12598 p
->pmax_restart
[afi
][safi
]);
12599 vty_out(vty
, "\n");
12602 vty_out(vty
, "\n");
12606 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12610 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
12611 char timebuf
[BGP_UPTIME_LEN
];
12617 json_object
*json_neigh
= NULL
;
12623 json_neigh
= json_object_new_object();
12625 memset(dn_flag
, '\0', sizeof(dn_flag
));
12626 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12630 if (p
->conf_if
) /* Configured interface name. */
12631 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
12632 BGP_PEER_SU_UNSPEC(p
)
12634 : sockunion2str(&p
->su
, buf
,
12636 else /* Configured IP address. */
12637 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12642 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12643 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12645 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12646 json_object_string_add(
12647 json_neigh
, "bgpNeighborAddr",
12648 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
12650 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12652 if (p
->change_local_as
)
12653 json_object_int_add(json_neigh
, "localAs",
12654 p
->change_local_as
);
12656 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12658 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12659 json_object_boolean_true_add(json_neigh
,
12660 "localAsNoPrepend");
12662 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12663 json_object_boolean_true_add(json_neigh
,
12664 "localAsReplaceAs");
12666 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12667 || (p
->as_type
== AS_INTERNAL
))
12668 vty_out(vty
, "remote AS %u, ", p
->as
);
12670 vty_out(vty
, "remote AS Unspecified, ");
12671 vty_out(vty
, "local AS %u%s%s, ",
12672 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12673 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12676 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12680 /* peer type internal or confed-internal */
12681 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12683 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12684 json_object_boolean_true_add(
12685 json_neigh
, "nbrConfedInternalLink");
12687 json_object_boolean_true_add(json_neigh
,
12688 "nbrInternalLink");
12690 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12691 vty_out(vty
, "confed-internal link\n");
12693 vty_out(vty
, "internal link\n");
12695 /* peer type external or confed-external */
12696 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12698 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12699 json_object_boolean_true_add(
12700 json_neigh
, "nbrConfedExternalLink");
12702 json_object_boolean_true_add(json_neigh
,
12703 "nbrExternalLink");
12705 if (bgp_confederation_peers_check(bgp
, p
->as
))
12706 vty_out(vty
, "confed-external link\n");
12708 vty_out(vty
, "external link\n");
12712 json_object_boolean_true_add(json_neigh
,
12713 "nbrUnspecifiedLink");
12715 vty_out(vty
, "unspecified link\n");
12721 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12723 vty_out(vty
, " Description: %s\n", p
->desc
);
12729 json_object_string_add(json_neigh
, "hostname",
12733 json_object_string_add(json_neigh
, "domainname",
12736 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12737 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12740 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12747 json_object_string_add(json_neigh
, "peerGroup",
12751 struct prefix prefix
, *range
= NULL
;
12753 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12754 range
= peer_group_lookup_dynamic_neighbor_range(
12755 p
->group
, &prefix
);
12758 prefix2str(range
, buf1
, sizeof(buf1
));
12759 json_object_string_add(
12761 "peerSubnetRangeGroup", buf1
);
12766 " Member of peer-group %s for session parameters\n",
12770 struct prefix prefix
, *range
= NULL
;
12772 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12773 range
= peer_group_lookup_dynamic_neighbor_range(
12774 p
->group
, &prefix
);
12778 " Belongs to the subnet range group: %pFX\n",
12786 /* Administrative shutdown. */
12787 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12788 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12789 json_object_boolean_true_add(json_neigh
,
12793 json_object_int_add(json_neigh
, "bgpVersion", 4);
12794 json_object_string_add(
12795 json_neigh
, "remoteRouterId",
12796 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12797 json_object_string_add(
12798 json_neigh
, "localRouterId",
12799 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12802 /* Confederation */
12803 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12804 && bgp_confederation_peers_check(bgp
, p
->as
))
12805 json_object_boolean_true_add(json_neigh
,
12809 json_object_string_add(
12810 json_neigh
, "bgpState",
12811 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12813 if (p
->status
== Established
) {
12816 uptime
= bgp_clock();
12817 uptime
-= p
->uptime
;
12818 epoch_tbuf
= time(NULL
) - uptime
;
12820 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
12822 json_object_string_add(json_neigh
, "bgpTimerUpString",
12823 peer_uptime(p
->uptime
, timebuf
,
12826 json_object_int_add(json_neigh
,
12827 "bgpTimerUpEstablishedEpoch",
12831 else if (p
->status
== Active
) {
12832 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12833 json_object_string_add(json_neigh
, "bgpStateIs",
12835 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12836 json_object_string_add(json_neigh
, "bgpStateIs",
12844 uptime
= bgp_clock();
12845 uptime
-= p
->readtime
;
12846 gmtime_r(&uptime
, &tm
);
12848 json_object_int_add(json_neigh
, "bgpTimerLastRead",
12849 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12850 + (tm
.tm_hour
* 3600000));
12852 uptime
= bgp_clock();
12853 uptime
-= p
->last_write
;
12854 gmtime_r(&uptime
, &tm
);
12856 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
12857 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12858 + (tm
.tm_hour
* 3600000));
12860 uptime
= bgp_clock();
12861 uptime
-= p
->update_time
;
12862 gmtime_r(&uptime
, &tm
);
12864 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
12865 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12866 + (tm
.tm_hour
* 3600000));
12868 /* Configured timer values. */
12869 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
12870 p
->v_holdtime
* 1000);
12871 json_object_int_add(json_neigh
,
12872 "bgpTimerKeepAliveIntervalMsecs",
12873 p
->v_keepalive
* 1000);
12874 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
12875 json_object_int_add(json_neigh
,
12876 "bgpTimerDelayOpenTimeMsecs",
12877 p
->v_delayopen
* 1000);
12880 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12881 json_object_int_add(json_neigh
,
12882 "bgpTimerConfiguredHoldTimeMsecs",
12883 p
->holdtime
* 1000);
12884 json_object_int_add(
12886 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12887 p
->keepalive
* 1000);
12888 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12889 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12890 json_object_int_add(json_neigh
,
12891 "bgpTimerConfiguredHoldTimeMsecs",
12892 bgp
->default_holdtime
);
12893 json_object_int_add(
12895 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12896 bgp
->default_keepalive
);
12899 /* Administrative shutdown. */
12900 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12901 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12902 vty_out(vty
, " Administratively shut down\n");
12905 vty_out(vty
, " BGP version 4");
12906 vty_out(vty
, ", remote router ID %s",
12907 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12908 vty_out(vty
, ", local router ID %s\n",
12909 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12912 /* Confederation */
12913 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12914 && bgp_confederation_peers_check(bgp
, p
->as
))
12916 " Neighbor under common administration\n");
12919 vty_out(vty
, " BGP state = %s",
12920 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12922 if (p
->status
== Established
)
12923 vty_out(vty
, ", up for %8s",
12924 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
12927 else if (p
->status
== Active
) {
12928 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12929 vty_out(vty
, " (passive)");
12930 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12931 vty_out(vty
, " (NSF passive)");
12933 vty_out(vty
, "\n");
12936 vty_out(vty
, " Last read %s",
12937 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
12939 vty_out(vty
, ", Last write %s\n",
12940 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
12943 /* Configured timer values. */
12945 " Hold time is %d, keepalive interval is %d seconds\n",
12946 p
->v_holdtime
, p
->v_keepalive
);
12947 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12948 vty_out(vty
, " Configured hold time is %d",
12950 vty_out(vty
, ", keepalive interval is %d seconds\n",
12952 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12953 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12954 vty_out(vty
, " Configured hold time is %d",
12955 bgp
->default_holdtime
);
12956 vty_out(vty
, ", keepalive interval is %d seconds\n",
12957 bgp
->default_keepalive
);
12959 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
12961 " Configured DelayOpenTime is %d seconds\n",
12965 if (p
->status
== Established
) {
12966 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
12967 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
12968 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
12969 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
12970 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
12971 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
12972 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
12973 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
12974 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
12975 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
12976 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
12977 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
12978 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
12979 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
12980 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
12981 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
12982 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
12983 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
12984 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
12985 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
12987 json_object
*json_cap
= NULL
;
12989 json_cap
= json_object_new_object();
12992 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
12993 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
12994 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
12995 && CHECK_FLAG(p
->cap
,
12997 json_object_string_add(
12998 json_cap
, "4byteAs",
12999 "advertisedAndReceived");
13000 else if (CHECK_FLAG(p
->cap
,
13002 json_object_string_add(
13003 json_cap
, "4byteAs",
13005 else if (CHECK_FLAG(p
->cap
,
13007 json_object_string_add(
13008 json_cap
, "4byteAs",
13013 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
13014 || CHECK_FLAG(p
->cap
,
13015 PEER_CAP_ADDPATH_ADV
)) {
13016 json_object
*json_add
= NULL
;
13017 const char *print_store
;
13019 json_add
= json_object_new_object();
13021 FOREACH_AFI_SAFI (afi
, safi
) {
13022 json_object
*json_sub
= NULL
;
13024 json_object_new_object();
13025 print_store
= get_afi_safi_str(
13031 PEER_CAP_ADDPATH_AF_TX_ADV
)
13035 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13040 PEER_CAP_ADDPATH_AF_TX_ADV
)
13045 PEER_CAP_ADDPATH_AF_TX_RCV
))
13046 json_object_boolean_true_add(
13048 "txAdvertisedAndReceived");
13054 PEER_CAP_ADDPATH_AF_TX_ADV
))
13055 json_object_boolean_true_add(
13063 PEER_CAP_ADDPATH_AF_TX_RCV
))
13064 json_object_boolean_true_add(
13072 PEER_CAP_ADDPATH_AF_RX_ADV
)
13076 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13081 PEER_CAP_ADDPATH_AF_RX_ADV
)
13086 PEER_CAP_ADDPATH_AF_RX_RCV
))
13087 json_object_boolean_true_add(
13089 "rxAdvertisedAndReceived");
13095 PEER_CAP_ADDPATH_AF_RX_ADV
))
13096 json_object_boolean_true_add(
13104 PEER_CAP_ADDPATH_AF_RX_RCV
))
13105 json_object_boolean_true_add(
13113 PEER_CAP_ADDPATH_AF_TX_ADV
)
13117 PEER_CAP_ADDPATH_AF_TX_RCV
)
13121 PEER_CAP_ADDPATH_AF_RX_ADV
)
13125 PEER_CAP_ADDPATH_AF_RX_RCV
))
13126 json_object_object_add(
13135 json_object_object_add(
13136 json_cap
, "addPath", json_add
);
13140 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
13141 || CHECK_FLAG(p
->cap
,
13142 PEER_CAP_DYNAMIC_ADV
)) {
13143 if (CHECK_FLAG(p
->cap
,
13144 PEER_CAP_DYNAMIC_ADV
)
13145 && CHECK_FLAG(p
->cap
,
13146 PEER_CAP_DYNAMIC_RCV
))
13147 json_object_string_add(
13148 json_cap
, "dynamic",
13149 "advertisedAndReceived");
13150 else if (CHECK_FLAG(
13152 PEER_CAP_DYNAMIC_ADV
))
13153 json_object_string_add(
13154 json_cap
, "dynamic",
13156 else if (CHECK_FLAG(
13158 PEER_CAP_DYNAMIC_RCV
))
13159 json_object_string_add(
13160 json_cap
, "dynamic",
13164 /* Extended nexthop */
13165 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
13166 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13167 json_object
*json_nxt
= NULL
;
13168 const char *print_store
;
13171 if (CHECK_FLAG(p
->cap
,
13173 && CHECK_FLAG(p
->cap
,
13174 PEER_CAP_ENHE_RCV
))
13175 json_object_string_add(
13178 "advertisedAndReceived");
13179 else if (CHECK_FLAG(p
->cap
,
13180 PEER_CAP_ENHE_ADV
))
13181 json_object_string_add(
13185 else if (CHECK_FLAG(p
->cap
,
13186 PEER_CAP_ENHE_RCV
))
13187 json_object_string_add(
13192 if (CHECK_FLAG(p
->cap
,
13193 PEER_CAP_ENHE_RCV
)) {
13195 json_object_new_object();
13197 for (safi
= SAFI_UNICAST
;
13198 safi
< SAFI_MAX
; safi
++) {
13203 PEER_CAP_ENHE_AF_RCV
)) {
13204 print_store
= get_afi_safi_str(
13207 json_object_string_add(
13210 "recieved"); /* misspelled for compatibility */
13213 json_object_object_add(
13215 "extendedNexthopFamililesByPeer",
13220 /* Route Refresh */
13221 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
13222 || CHECK_FLAG(p
->cap
,
13223 PEER_CAP_REFRESH_NEW_RCV
)
13224 || CHECK_FLAG(p
->cap
,
13225 PEER_CAP_REFRESH_OLD_RCV
)) {
13226 if (CHECK_FLAG(p
->cap
,
13227 PEER_CAP_REFRESH_ADV
)
13230 PEER_CAP_REFRESH_NEW_RCV
)
13233 PEER_CAP_REFRESH_OLD_RCV
))) {
13236 PEER_CAP_REFRESH_OLD_RCV
)
13239 PEER_CAP_REFRESH_NEW_RCV
))
13240 json_object_string_add(
13243 "advertisedAndReceivedOldNew");
13247 PEER_CAP_REFRESH_OLD_RCV
))
13248 json_object_string_add(
13251 "advertisedAndReceivedOld");
13253 json_object_string_add(
13256 "advertisedAndReceivedNew");
13261 PEER_CAP_REFRESH_ADV
))
13262 json_object_string_add(
13269 PEER_CAP_REFRESH_NEW_RCV
)
13272 PEER_CAP_REFRESH_OLD_RCV
))
13273 json_object_string_add(
13279 /* Enhanced Route Refresh */
13280 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
)
13281 || CHECK_FLAG(p
->cap
,
13282 PEER_CAP_ENHANCED_RR_RCV
)) {
13283 if (CHECK_FLAG(p
->cap
,
13284 PEER_CAP_ENHANCED_RR_ADV
)
13287 PEER_CAP_ENHANCED_RR_RCV
))
13288 json_object_string_add(
13290 "enhancedRouteRefresh",
13291 "advertisedAndReceived");
13295 PEER_CAP_ENHANCED_RR_ADV
))
13296 json_object_string_add(
13298 "enhancedRouteRefresh",
13303 PEER_CAP_ENHANCED_RR_RCV
))
13304 json_object_string_add(
13306 "enhancedRouteRefresh",
13310 /* Multiprotocol Extensions */
13311 json_object
*json_multi
= NULL
;
13312 json_multi
= json_object_new_object();
13314 FOREACH_AFI_SAFI (afi
, safi
) {
13315 if (p
->afc_adv
[afi
][safi
]
13316 || p
->afc_recv
[afi
][safi
]) {
13317 json_object
*json_exten
= NULL
;
13319 json_object_new_object();
13321 if (p
->afc_adv
[afi
][safi
]
13322 && p
->afc_recv
[afi
][safi
])
13323 json_object_boolean_true_add(
13325 "advertisedAndReceived");
13326 else if (p
->afc_adv
[afi
][safi
])
13327 json_object_boolean_true_add(
13330 else if (p
->afc_recv
[afi
][safi
])
13331 json_object_boolean_true_add(
13335 json_object_object_add(
13337 get_afi_safi_str(afi
,
13343 json_object_object_add(
13344 json_cap
, "multiprotocolExtensions",
13347 /* Hostname capabilities */
13348 json_object
*json_hname
= NULL
;
13350 json_hname
= json_object_new_object();
13352 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13353 json_object_string_add(
13354 json_hname
, "advHostName",
13355 bgp
->peer_self
->hostname
13359 json_object_string_add(
13360 json_hname
, "advDomainName",
13361 bgp
->peer_self
->domainname
13368 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13369 json_object_string_add(
13370 json_hname
, "rcvHostName",
13371 p
->hostname
? p
->hostname
13373 json_object_string_add(
13374 json_hname
, "rcvDomainName",
13375 p
->domainname
? p
->domainname
13379 json_object_object_add(json_cap
, "hostName",
13382 /* Gracefull Restart */
13383 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
13384 || CHECK_FLAG(p
->cap
,
13385 PEER_CAP_RESTART_ADV
)) {
13386 if (CHECK_FLAG(p
->cap
,
13387 PEER_CAP_RESTART_ADV
)
13388 && CHECK_FLAG(p
->cap
,
13389 PEER_CAP_RESTART_RCV
))
13390 json_object_string_add(
13393 "advertisedAndReceived");
13394 else if (CHECK_FLAG(
13396 PEER_CAP_RESTART_ADV
))
13397 json_object_string_add(
13399 "gracefulRestartCapability",
13401 else if (CHECK_FLAG(
13403 PEER_CAP_RESTART_RCV
))
13404 json_object_string_add(
13406 "gracefulRestartCapability",
13409 if (CHECK_FLAG(p
->cap
,
13410 PEER_CAP_RESTART_RCV
)) {
13411 int restart_af_count
= 0;
13412 json_object
*json_restart
=
13415 json_object_new_object();
13417 json_object_int_add(
13419 "gracefulRestartRemoteTimerMsecs",
13420 p
->v_gr_restart
* 1000);
13422 FOREACH_AFI_SAFI (afi
, safi
) {
13427 PEER_CAP_RESTART_AF_RCV
)) {
13432 json_object_new_object();
13438 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13439 json_object_boolean_true_add(
13442 restart_af_count
++;
13443 json_object_object_add(
13452 if (!restart_af_count
) {
13453 json_object_string_add(
13455 "addressFamiliesByPeer",
13460 json_object_object_add(
13462 "addressFamiliesByPeer",
13466 json_object_object_add(json_neigh
,
13467 "neighborCapabilities",
13470 vty_out(vty
, " Neighbor capabilities:\n");
13473 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
13474 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13475 vty_out(vty
, " 4 Byte AS:");
13476 if (CHECK_FLAG(p
->cap
,
13478 vty_out(vty
, " advertised");
13479 if (CHECK_FLAG(p
->cap
,
13481 vty_out(vty
, " %sreceived",
13487 vty_out(vty
, "\n");
13491 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
13492 || CHECK_FLAG(p
->cap
,
13493 PEER_CAP_ADDPATH_ADV
)) {
13494 vty_out(vty
, " AddPath:\n");
13496 FOREACH_AFI_SAFI (afi
, safi
) {
13500 PEER_CAP_ADDPATH_AF_TX_ADV
)
13504 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13516 PEER_CAP_ADDPATH_AF_TX_ADV
))
13528 PEER_CAP_ADDPATH_AF_TX_RCV
))
13535 PEER_CAP_ADDPATH_AF_TX_ADV
)
13539 vty_out(vty
, "\n");
13545 PEER_CAP_ADDPATH_AF_RX_ADV
)
13549 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13561 PEER_CAP_ADDPATH_AF_RX_ADV
))
13573 PEER_CAP_ADDPATH_AF_RX_RCV
))
13580 PEER_CAP_ADDPATH_AF_RX_ADV
)
13584 vty_out(vty
, "\n");
13590 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
13591 || CHECK_FLAG(p
->cap
,
13592 PEER_CAP_DYNAMIC_ADV
)) {
13593 vty_out(vty
, " Dynamic:");
13594 if (CHECK_FLAG(p
->cap
,
13595 PEER_CAP_DYNAMIC_ADV
))
13596 vty_out(vty
, " advertised");
13597 if (CHECK_FLAG(p
->cap
,
13598 PEER_CAP_DYNAMIC_RCV
))
13599 vty_out(vty
, " %sreceived",
13602 PEER_CAP_DYNAMIC_ADV
)
13605 vty_out(vty
, "\n");
13608 /* Extended nexthop */
13609 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
13610 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13611 vty_out(vty
, " Extended nexthop:");
13612 if (CHECK_FLAG(p
->cap
,
13613 PEER_CAP_ENHE_ADV
))
13614 vty_out(vty
, " advertised");
13615 if (CHECK_FLAG(p
->cap
,
13616 PEER_CAP_ENHE_RCV
))
13617 vty_out(vty
, " %sreceived",
13623 vty_out(vty
, "\n");
13625 if (CHECK_FLAG(p
->cap
,
13626 PEER_CAP_ENHE_RCV
)) {
13628 " Address families by peer:\n ");
13629 for (safi
= SAFI_UNICAST
;
13630 safi
< SAFI_MAX
; safi
++)
13635 PEER_CAP_ENHE_AF_RCV
))
13645 /* Route Refresh */
13646 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
13647 || CHECK_FLAG(p
->cap
,
13648 PEER_CAP_REFRESH_NEW_RCV
)
13649 || CHECK_FLAG(p
->cap
,
13650 PEER_CAP_REFRESH_OLD_RCV
)) {
13651 vty_out(vty
, " Route refresh:");
13652 if (CHECK_FLAG(p
->cap
,
13653 PEER_CAP_REFRESH_ADV
))
13654 vty_out(vty
, " advertised");
13655 if (CHECK_FLAG(p
->cap
,
13656 PEER_CAP_REFRESH_NEW_RCV
)
13659 PEER_CAP_REFRESH_OLD_RCV
))
13660 vty_out(vty
, " %sreceived(%s)",
13663 PEER_CAP_REFRESH_ADV
)
13668 PEER_CAP_REFRESH_OLD_RCV
)
13671 PEER_CAP_REFRESH_NEW_RCV
))
13675 PEER_CAP_REFRESH_OLD_RCV
)
13679 vty_out(vty
, "\n");
13682 /* Enhanced Route Refresh */
13683 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
)
13684 || CHECK_FLAG(p
->cap
,
13685 PEER_CAP_ENHANCED_RR_RCV
)) {
13687 " Enhanced Route Refresh:");
13690 PEER_CAP_ENHANCED_RR_ADV
))
13691 vty_out(vty
, " advertised");
13694 PEER_CAP_ENHANCED_RR_RCV
))
13695 vty_out(vty
, " %sreceived",
13698 PEER_CAP_REFRESH_ADV
)
13701 vty_out(vty
, "\n");
13704 /* Multiprotocol Extensions */
13705 FOREACH_AFI_SAFI (afi
, safi
)
13706 if (p
->afc_adv
[afi
][safi
]
13707 || p
->afc_recv
[afi
][safi
]) {
13709 " Address Family %s:",
13714 if (p
->afc_adv
[afi
][safi
])
13717 if (p
->afc_recv
[afi
][safi
])
13724 vty_out(vty
, "\n");
13727 /* Hostname capability */
13728 vty_out(vty
, " Hostname Capability:");
13730 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13732 " advertised (name: %s,domain name: %s)",
13733 bgp
->peer_self
->hostname
13737 bgp
->peer_self
->domainname
13742 vty_out(vty
, " not advertised");
13745 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13747 " received (name: %s,domain name: %s)",
13748 p
->hostname
? p
->hostname
13750 p
->domainname
? p
->domainname
13753 vty_out(vty
, " not received");
13756 vty_out(vty
, "\n");
13758 /* Graceful Restart */
13759 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
13760 || CHECK_FLAG(p
->cap
,
13761 PEER_CAP_RESTART_ADV
)) {
13763 " Graceful Restart Capability:");
13764 if (CHECK_FLAG(p
->cap
,
13765 PEER_CAP_RESTART_ADV
))
13766 vty_out(vty
, " advertised");
13767 if (CHECK_FLAG(p
->cap
,
13768 PEER_CAP_RESTART_RCV
))
13769 vty_out(vty
, " %sreceived",
13772 PEER_CAP_RESTART_ADV
)
13775 vty_out(vty
, "\n");
13777 if (CHECK_FLAG(p
->cap
,
13778 PEER_CAP_RESTART_RCV
)) {
13779 int restart_af_count
= 0;
13782 " Remote Restart timer is %d seconds\n",
13785 " Address families by peer:\n ");
13787 FOREACH_AFI_SAFI (afi
, safi
)
13792 PEER_CAP_RESTART_AF_RCV
)) {
13806 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13808 : "not preserved");
13809 restart_af_count
++;
13811 if (!restart_af_count
)
13812 vty_out(vty
, "none");
13813 vty_out(vty
, "\n");
13815 } /* Gracefull Restart */
13820 /* graceful restart information */
13821 json_object
*json_grace
= NULL
;
13822 json_object
*json_grace_send
= NULL
;
13823 json_object
*json_grace_recv
= NULL
;
13824 int eor_send_af_count
= 0;
13825 int eor_receive_af_count
= 0;
13828 json_grace
= json_object_new_object();
13829 json_grace_send
= json_object_new_object();
13830 json_grace_recv
= json_object_new_object();
13832 if ((p
->status
== Established
)
13833 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13834 FOREACH_AFI_SAFI (afi
, safi
) {
13835 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13836 PEER_STATUS_EOR_SEND
)) {
13837 json_object_boolean_true_add(
13839 get_afi_safi_str(afi
,
13842 eor_send_af_count
++;
13845 FOREACH_AFI_SAFI (afi
, safi
) {
13847 p
->af_sflags
[afi
][safi
],
13848 PEER_STATUS_EOR_RECEIVED
)) {
13849 json_object_boolean_true_add(
13851 get_afi_safi_str(afi
,
13854 eor_receive_af_count
++;
13858 json_object_object_add(json_grace
, "endOfRibSend",
13860 json_object_object_add(json_grace
, "endOfRibRecv",
13864 if (p
->t_gr_restart
)
13865 json_object_int_add(json_grace
,
13866 "gracefulRestartTimerMsecs",
13867 thread_timer_remain_second(
13872 json_object_int_add(
13874 "gracefulStalepathTimerMsecs",
13875 thread_timer_remain_second(
13878 /* more gr info in new format */
13879 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
,
13881 json_object_object_add(
13882 json_neigh
, "gracefulRestartInfo", json_grace
);
13884 vty_out(vty
, " Graceful restart information:\n");
13885 if ((p
->status
== Established
)
13886 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13888 vty_out(vty
, " End-of-RIB send: ");
13889 FOREACH_AFI_SAFI (afi
, safi
) {
13890 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13891 PEER_STATUS_EOR_SEND
)) {
13892 vty_out(vty
, "%s%s",
13893 eor_send_af_count
? ", "
13898 eor_send_af_count
++;
13901 vty_out(vty
, "\n");
13902 vty_out(vty
, " End-of-RIB received: ");
13903 FOREACH_AFI_SAFI (afi
, safi
) {
13905 p
->af_sflags
[afi
][safi
],
13906 PEER_STATUS_EOR_RECEIVED
)) {
13907 vty_out(vty
, "%s%s",
13908 eor_receive_af_count
13911 get_afi_safi_str(afi
,
13914 eor_receive_af_count
++;
13917 vty_out(vty
, "\n");
13920 if (p
->t_gr_restart
)
13922 " The remaining time of restart timer is %ld\n",
13923 thread_timer_remain_second(
13928 " The remaining time of stalepath timer is %ld\n",
13929 thread_timer_remain_second(
13932 /* more gr info in new format */
13933 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
13937 json_object
*json_stat
= NULL
;
13938 json_stat
= json_object_new_object();
13939 /* Packet counts. */
13941 atomic_size_t outq_count
, inq_count
;
13942 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13943 memory_order_relaxed
);
13944 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13945 memory_order_relaxed
);
13947 json_object_int_add(json_stat
, "depthInq",
13948 (unsigned long)inq_count
);
13949 json_object_int_add(json_stat
, "depthOutq",
13950 (unsigned long)outq_count
);
13951 json_object_int_add(json_stat
, "opensSent",
13952 atomic_load_explicit(&p
->open_out
,
13953 memory_order_relaxed
));
13954 json_object_int_add(json_stat
, "opensRecv",
13955 atomic_load_explicit(&p
->open_in
,
13956 memory_order_relaxed
));
13957 json_object_int_add(json_stat
, "notificationsSent",
13958 atomic_load_explicit(&p
->notify_out
,
13959 memory_order_relaxed
));
13960 json_object_int_add(json_stat
, "notificationsRecv",
13961 atomic_load_explicit(&p
->notify_in
,
13962 memory_order_relaxed
));
13963 json_object_int_add(json_stat
, "updatesSent",
13964 atomic_load_explicit(&p
->update_out
,
13965 memory_order_relaxed
));
13966 json_object_int_add(json_stat
, "updatesRecv",
13967 atomic_load_explicit(&p
->update_in
,
13968 memory_order_relaxed
));
13969 json_object_int_add(json_stat
, "keepalivesSent",
13970 atomic_load_explicit(&p
->keepalive_out
,
13971 memory_order_relaxed
));
13972 json_object_int_add(json_stat
, "keepalivesRecv",
13973 atomic_load_explicit(&p
->keepalive_in
,
13974 memory_order_relaxed
));
13975 json_object_int_add(json_stat
, "routeRefreshSent",
13976 atomic_load_explicit(&p
->refresh_out
,
13977 memory_order_relaxed
));
13978 json_object_int_add(json_stat
, "routeRefreshRecv",
13979 atomic_load_explicit(&p
->refresh_in
,
13980 memory_order_relaxed
));
13981 json_object_int_add(json_stat
, "capabilitySent",
13982 atomic_load_explicit(&p
->dynamic_cap_out
,
13983 memory_order_relaxed
));
13984 json_object_int_add(json_stat
, "capabilityRecv",
13985 atomic_load_explicit(&p
->dynamic_cap_in
,
13986 memory_order_relaxed
));
13987 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
13988 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
13989 json_object_object_add(json_neigh
, "messageStats", json_stat
);
13991 atomic_size_t outq_count
, inq_count
;
13992 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13993 memory_order_relaxed
);
13994 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13995 memory_order_relaxed
);
13997 /* Packet counts. */
13998 vty_out(vty
, " Message statistics:\n");
13999 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
14000 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
14001 vty_out(vty
, " Sent Rcvd\n");
14002 vty_out(vty
, " Opens: %10d %10d\n",
14003 atomic_load_explicit(&p
->open_out
,
14004 memory_order_relaxed
),
14005 atomic_load_explicit(&p
->open_in
,
14006 memory_order_relaxed
));
14007 vty_out(vty
, " Notifications: %10d %10d\n",
14008 atomic_load_explicit(&p
->notify_out
,
14009 memory_order_relaxed
),
14010 atomic_load_explicit(&p
->notify_in
,
14011 memory_order_relaxed
));
14012 vty_out(vty
, " Updates: %10d %10d\n",
14013 atomic_load_explicit(&p
->update_out
,
14014 memory_order_relaxed
),
14015 atomic_load_explicit(&p
->update_in
,
14016 memory_order_relaxed
));
14017 vty_out(vty
, " Keepalives: %10d %10d\n",
14018 atomic_load_explicit(&p
->keepalive_out
,
14019 memory_order_relaxed
),
14020 atomic_load_explicit(&p
->keepalive_in
,
14021 memory_order_relaxed
));
14022 vty_out(vty
, " Route Refresh: %10d %10d\n",
14023 atomic_load_explicit(&p
->refresh_out
,
14024 memory_order_relaxed
),
14025 atomic_load_explicit(&p
->refresh_in
,
14026 memory_order_relaxed
));
14027 vty_out(vty
, " Capability: %10d %10d\n",
14028 atomic_load_explicit(&p
->dynamic_cap_out
,
14029 memory_order_relaxed
),
14030 atomic_load_explicit(&p
->dynamic_cap_in
,
14031 memory_order_relaxed
));
14032 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
14037 /* advertisement-interval */
14038 json_object_int_add(json_neigh
,
14039 "minBtwnAdvertisementRunsTimerMsecs",
14040 p
->v_routeadv
* 1000);
14042 /* Update-source. */
14043 if (p
->update_if
|| p
->update_source
) {
14045 json_object_string_add(json_neigh
,
14048 else if (p
->update_source
)
14049 json_object_string_add(
14050 json_neigh
, "updateSource",
14051 sockunion2str(p
->update_source
, buf1
,
14055 /* advertisement-interval */
14057 " Minimum time between advertisement runs is %d seconds\n",
14060 /* Update-source. */
14061 if (p
->update_if
|| p
->update_source
) {
14062 vty_out(vty
, " Update source is ");
14064 vty_out(vty
, "%s", p
->update_if
);
14065 else if (p
->update_source
)
14067 sockunion2str(p
->update_source
, buf1
,
14069 vty_out(vty
, "\n");
14072 vty_out(vty
, "\n");
14075 /* Address Family Information */
14076 json_object
*json_hold
= NULL
;
14079 json_hold
= json_object_new_object();
14081 FOREACH_AFI_SAFI (afi
, safi
)
14082 if (p
->afc
[afi
][safi
])
14083 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14087 json_object_object_add(json_neigh
, "addressFamilyInfo",
14089 json_object_int_add(json_neigh
, "connectionsEstablished",
14091 json_object_int_add(json_neigh
, "connectionsDropped",
14094 vty_out(vty
, " Connections established %d; dropped %d\n",
14095 p
->established
, p
->dropped
);
14097 if (!p
->last_reset
) {
14099 json_object_string_add(json_neigh
, "lastReset",
14102 vty_out(vty
, " Last reset never\n");
14108 uptime
= bgp_clock();
14109 uptime
-= p
->resettime
;
14110 gmtime_r(&uptime
, &tm
);
14112 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14114 + (tm
.tm_min
* 60000)
14115 + (tm
.tm_hour
* 3600000));
14116 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14118 vty_out(vty
, " Last reset %s, ",
14119 peer_uptime(p
->resettime
, timebuf
,
14120 BGP_UPTIME_LEN
, 0, NULL
));
14122 bgp_show_peer_reset(vty
, p
, NULL
, false);
14123 if (p
->last_reset_cause_size
) {
14124 msg
= p
->last_reset_cause
;
14126 " Message received that caused BGP to send a NOTIFICATION:\n ");
14127 for (i
= 1; i
<= p
->last_reset_cause_size
;
14129 vty_out(vty
, "%02X", *msg
++);
14131 if (i
!= p
->last_reset_cause_size
) {
14133 vty_out(vty
, "\n ");
14134 } else if (i
% 4 == 0) {
14139 vty_out(vty
, "\n");
14144 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14146 json_object_boolean_true_add(json_neigh
,
14147 "prefixesConfigExceedMax");
14150 " Peer had exceeded the max. no. of prefixes configured.\n");
14152 if (p
->t_pmax_restart
) {
14154 json_object_boolean_true_add(
14155 json_neigh
, "reducePrefixNumFrom");
14156 json_object_int_add(json_neigh
,
14157 "restartInTimerMsec",
14158 thread_timer_remain_second(
14163 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14164 p
->host
, thread_timer_remain_second(
14165 p
->t_pmax_restart
));
14168 json_object_boolean_true_add(
14170 "reducePrefixNumAndClearIpBgp");
14173 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14178 /* EBGP Multihop and GTSM */
14179 if (p
->sort
!= BGP_PEER_IBGP
) {
14181 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14182 json_object_int_add(json_neigh
,
14183 "externalBgpNbrMaxHopsAway",
14185 else if (p
->ttl
> BGP_DEFAULT_TTL
)
14186 json_object_int_add(json_neigh
,
14187 "externalBgpNbrMaxHopsAway",
14190 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14192 " External BGP neighbor may be up to %d hops away.\n",
14194 else if (p
->ttl
> BGP_DEFAULT_TTL
)
14196 " External BGP neighbor may be up to %d hops away.\n",
14200 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
) {
14202 json_object_int_add(json_neigh
,
14203 "internalBgpNbrMaxHopsAway",
14207 " Internal BGP neighbor may be up to %d hops away.\n",
14212 /* Local address. */
14215 json_object_string_add(json_neigh
, "hostLocal",
14216 sockunion2str(p
->su_local
, buf1
,
14218 json_object_int_add(json_neigh
, "portLocal",
14219 ntohs(p
->su_local
->sin
.sin_port
));
14221 vty_out(vty
, "Local host: %s, Local port: %d\n",
14222 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
14223 ntohs(p
->su_local
->sin
.sin_port
));
14226 /* Remote address. */
14227 if (p
->su_remote
) {
14229 json_object_string_add(json_neigh
, "hostForeign",
14230 sockunion2str(p
->su_remote
, buf1
,
14232 json_object_int_add(json_neigh
, "portForeign",
14233 ntohs(p
->su_remote
->sin
.sin_port
));
14235 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
14236 sockunion2str(p
->su_remote
, buf1
,
14238 ntohs(p
->su_remote
->sin
.sin_port
));
14241 /* Nexthop display. */
14244 json_object_string_add(json_neigh
, "nexthop",
14246 &p
->nexthop
.v4
, buf1
,
14248 json_object_string_add(json_neigh
, "nexthopGlobal",
14249 inet_ntop(AF_INET6
,
14250 &p
->nexthop
.v6_global
,
14251 buf1
, sizeof(buf1
)));
14252 json_object_string_add(json_neigh
, "nexthopLocal",
14253 inet_ntop(AF_INET6
,
14254 &p
->nexthop
.v6_local
,
14255 buf1
, sizeof(buf1
)));
14256 if (p
->shared_network
)
14257 json_object_string_add(json_neigh
,
14261 json_object_string_add(json_neigh
,
14263 "nonSharedNetwork");
14265 vty_out(vty
, "Nexthop: %s\n",
14266 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
14268 vty_out(vty
, "Nexthop global: %s\n",
14269 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
14271 vty_out(vty
, "Nexthop local: %s\n",
14272 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
14274 vty_out(vty
, "BGP connection: %s\n",
14275 p
->shared_network
? "shared network"
14276 : "non shared network");
14280 /* Timer information. */
14282 json_object_int_add(json_neigh
, "connectRetryTimer",
14284 if (p
->status
== Established
&& p
->rtt
)
14285 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14288 json_object_int_add(
14289 json_neigh
, "nextStartTimerDueInMsecs",
14290 thread_timer_remain_second(p
->t_start
) * 1000);
14292 json_object_int_add(
14293 json_neigh
, "nextConnectTimerDueInMsecs",
14294 thread_timer_remain_second(p
->t_connect
)
14296 if (p
->t_routeadv
) {
14297 json_object_int_add(json_neigh
, "mraiInterval",
14299 json_object_int_add(
14300 json_neigh
, "mraiTimerExpireInMsecs",
14301 thread_timer_remain_second(p
->t_routeadv
)
14305 json_object_int_add(json_neigh
, "authenticationEnabled",
14309 json_object_string_add(json_neigh
, "readThread", "on");
14311 json_object_string_add(json_neigh
, "readThread", "off");
14313 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14314 json_object_string_add(json_neigh
, "writeThread", "on");
14316 json_object_string_add(json_neigh
, "writeThread",
14319 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14321 if (p
->status
== Established
&& p
->rtt
)
14322 vty_out(vty
, "Estimated round trip time: %d ms\n",
14325 vty_out(vty
, "Next start timer due in %ld seconds\n",
14326 thread_timer_remain_second(p
->t_start
));
14328 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14329 thread_timer_remain_second(p
->t_connect
));
14332 "MRAI (interval %u) timer expires in %ld seconds\n",
14334 thread_timer_remain_second(p
->t_routeadv
));
14336 vty_out(vty
, "Peer Authentication Enabled\n");
14338 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14339 p
->t_read
? "on" : "off",
14340 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14345 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14346 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14347 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14350 vty_out(vty
, "\n");
14352 /* BFD information. */
14353 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
14356 if (p
->conf_if
) /* Configured interface name. */
14357 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14358 else /* Configured IP address. */
14359 json_object_object_add(json
, p
->host
, json_neigh
);
14363 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14364 enum show_type type
,
14365 union sockunion
*su
,
14366 const char *conf_if
, afi_t afi
,
14369 struct listnode
*node
, *nnode
;
14372 safi_t safi
= SAFI_UNICAST
;
14373 json_object
*json
= NULL
;
14374 json_object
*json_neighbor
= NULL
;
14377 json
= json_object_new_object();
14378 json_neighbor
= json_object_new_object();
14381 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14383 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14386 if ((peer
->afc
[afi
][safi
]) == 0)
14389 if (type
== show_all
) {
14390 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14394 json_object_object_add(json
, peer
->host
,
14396 json_neighbor
= NULL
;
14399 } else if (type
== show_peer
) {
14402 && !strcmp(peer
->conf_if
, conf_if
))
14404 && !strcmp(peer
->hostname
, conf_if
))) {
14406 bgp_show_peer_gr_status(vty
, peer
,
14411 if (sockunion_same(&peer
->su
, su
)) {
14413 bgp_show_peer_gr_status(vty
, peer
,
14418 if (use_json
&& find
)
14419 json_object_object_add(json
, peer
->host
,
14424 json_neighbor
= NULL
;
14429 if (type
== show_peer
&& !find
) {
14431 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14433 vty_out(vty
, "%% No such neighbor\n");
14436 vty_out(vty
, "%s\n",
14437 json_object_to_json_string_ext(
14438 json
, JSON_C_TO_STRING_PRETTY
));
14441 json_object_free(json_neighbor
);
14442 json_object_free(json
);
14444 vty_out(vty
, "\n");
14447 return CMD_SUCCESS
;
14450 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14451 enum show_type type
, union sockunion
*su
,
14452 const char *conf_if
, bool use_json
,
14455 struct listnode
*node
, *nnode
;
14458 bool nbr_output
= false;
14459 afi_t afi
= AFI_MAX
;
14460 safi_t safi
= SAFI_MAX
;
14462 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14464 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14468 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14469 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14474 bgp_show_peer(vty
, peer
, use_json
, json
);
14480 && !strcmp(peer
->conf_if
, conf_if
))
14482 && !strcmp(peer
->hostname
, conf_if
))) {
14484 bgp_show_peer(vty
, peer
, use_json
,
14488 if (sockunion_same(&peer
->su
, su
)) {
14490 bgp_show_peer(vty
, peer
, use_json
,
14495 case show_ipv4_peer
:
14496 case show_ipv6_peer
:
14497 FOREACH_SAFI (safi
) {
14498 if (peer
->afc
[afi
][safi
]) {
14501 && !strcmp(peer
->conf_if
, conf_if
))
14503 && !strcmp(peer
->hostname
, conf_if
))) {
14505 bgp_show_peer(vty
, peer
, use_json
,
14510 if (sockunion_same(&peer
->su
, su
)) {
14512 bgp_show_peer(vty
, peer
, use_json
,
14520 case show_ipv4_all
:
14521 case show_ipv6_all
:
14522 FOREACH_SAFI (safi
) {
14523 if (peer
->afc
[afi
][safi
]) {
14524 bgp_show_peer(vty
, peer
, use_json
, json
);
14533 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14534 type
== show_ipv6_peer
) && !find
) {
14536 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14538 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14541 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14542 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14543 vty_out(vty
, "%% No BGP neighbors found\n");
14546 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14547 json
, JSON_C_TO_STRING_PRETTY
));
14549 vty_out(vty
, "\n");
14552 return CMD_SUCCESS
;
14555 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14556 enum show_type type
,
14557 const char *ip_str
,
14558 afi_t afi
, bool use_json
)
14563 union sockunion su
;
14565 bgp
= bgp_get_default();
14571 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14575 ret
= str2sockunion(ip_str
, &su
);
14577 bgp_show_neighbor_graceful_restart(
14578 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14580 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14581 NULL
, afi
, use_json
);
14583 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14587 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14588 enum show_type type
,
14589 const char *ip_str
,
14592 struct listnode
*node
, *nnode
;
14594 union sockunion su
;
14595 json_object
*json
= NULL
;
14596 int ret
, is_first
= 1;
14597 bool nbr_output
= false;
14600 vty_out(vty
, "{\n");
14602 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14605 if (!(json
= json_object_new_object())) {
14607 EC_BGP_JSON_MEM_ERROR
,
14608 "Unable to allocate memory for JSON object");
14610 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14614 json_object_int_add(json
, "vrfId",
14615 (bgp
->vrf_id
== VRF_UNKNOWN
)
14617 : (int64_t)bgp
->vrf_id
);
14618 json_object_string_add(
14620 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14625 vty_out(vty
, ",\n");
14629 vty_out(vty
, "\"%s\":",
14630 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14634 vty_out(vty
, "\nInstance %s:\n",
14635 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14640 if (type
== show_peer
|| type
== show_ipv4_peer
||
14641 type
== show_ipv6_peer
) {
14642 ret
= str2sockunion(ip_str
, &su
);
14644 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14647 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14650 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14653 json_object_free(json
);
14658 vty_out(vty
, "}\n");
14659 else if (!nbr_output
)
14660 vty_out(vty
, "%% BGP instance not found\n");
14663 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14664 enum show_type type
, const char *ip_str
,
14669 union sockunion su
;
14670 json_object
*json
= NULL
;
14673 if (strmatch(name
, "all")) {
14674 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14676 return CMD_SUCCESS
;
14678 bgp
= bgp_lookup_by_name(name
);
14681 json
= json_object_new_object();
14682 vty_out(vty
, "%s\n",
14683 json_object_to_json_string_ext(
14685 JSON_C_TO_STRING_PRETTY
));
14686 json_object_free(json
);
14689 "%% BGP instance not found\n");
14691 return CMD_WARNING
;
14695 bgp
= bgp_get_default();
14699 json
= json_object_new_object();
14701 ret
= str2sockunion(ip_str
, &su
);
14703 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14706 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14709 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14712 json_object_free(json
);
14715 vty_out(vty
, "{}\n");
14717 vty_out(vty
, "%% BGP instance not found\n");
14720 return CMD_SUCCESS
;
14725 /* "show [ip] bgp neighbors graceful-restart" commands. */
14726 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
14727 show_ip_bgp_neighbors_graceful_restart_cmd
,
14728 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14734 "Neighbor to display information about\n"
14735 "Neighbor to display information about\n"
14736 "Neighbor on BGP configured interface\n"
14740 char *sh_arg
= NULL
;
14741 enum show_type sh_type
;
14743 afi_t afi
= AFI_MAX
;
14744 bool uj
= use_json(argc
, argv
);
14746 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14751 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14752 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14753 || argv_find(argv
, argc
, "WORD", &idx
)) {
14754 sh_type
= show_peer
;
14755 sh_arg
= argv
[idx
]->arg
;
14757 sh_type
= show_all
;
14759 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14760 return CMD_SUCCESS
;
14763 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14767 /* "show [ip] bgp neighbors" commands. */
14768 DEFUN (show_ip_bgp_neighbors
,
14769 show_ip_bgp_neighbors_cmd
,
14770 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14774 BGP_INSTANCE_HELP_STR
14777 "Detailed information on TCP and BGP neighbor connections\n"
14778 "Neighbor to display information about\n"
14779 "Neighbor to display information about\n"
14780 "Neighbor on BGP configured interface\n"
14784 char *sh_arg
= NULL
;
14785 enum show_type sh_type
;
14786 afi_t afi
= AFI_MAX
;
14788 bool uj
= use_json(argc
, argv
);
14792 /* [<vrf> VIEWVRFNAME] */
14793 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14794 vrf
= argv
[idx
+ 1]->arg
;
14795 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14797 } else if (argv_find(argv
, argc
, "view", &idx
))
14798 /* [<view> VIEWVRFNAME] */
14799 vrf
= argv
[idx
+ 1]->arg
;
14803 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14804 sh_type
= show_ipv4_all
;
14806 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14807 sh_type
= show_ipv6_all
;
14810 sh_type
= show_all
;
14813 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14814 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14815 || argv_find(argv
, argc
, "WORD", &idx
)) {
14816 sh_type
= show_peer
;
14817 sh_arg
= argv
[idx
]->arg
;
14820 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14821 sh_type
= show_ipv4_peer
;
14822 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14823 sh_type
= show_ipv6_peer
;
14826 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14829 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14830 paths' and `show ip mbgp paths'. Those functions results are the
14832 DEFUN (show_ip_bgp_paths
,
14833 show_ip_bgp_paths_cmd
,
14834 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14839 "Path information\n")
14841 vty_out(vty
, "Address Refcnt Path\n");
14842 aspath_print_all_vty(vty
);
14843 return CMD_SUCCESS
;
14848 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14851 struct community
*com
;
14853 com
= (struct community
*)bucket
->data
;
14854 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14855 community_str(com
, false));
14858 /* Show BGP's community internal data. */
14859 DEFUN (show_ip_bgp_community_info
,
14860 show_ip_bgp_community_info_cmd
,
14861 "show [ip] bgp community-info",
14865 "List all bgp community information\n")
14867 vty_out(vty
, "Address Refcnt Community\n");
14869 hash_iterate(community_hash(),
14870 (void (*)(struct hash_bucket
*,
14871 void *))community_show_all_iterator
,
14874 return CMD_SUCCESS
;
14877 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14880 struct lcommunity
*lcom
;
14882 lcom
= (struct lcommunity
*)bucket
->data
;
14883 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14884 lcommunity_str(lcom
, false));
14887 /* Show BGP's community internal data. */
14888 DEFUN (show_ip_bgp_lcommunity_info
,
14889 show_ip_bgp_lcommunity_info_cmd
,
14890 "show ip bgp large-community-info",
14894 "List all bgp large-community information\n")
14896 vty_out(vty
, "Address Refcnt Large-community\n");
14898 hash_iterate(lcommunity_hash(),
14899 (void (*)(struct hash_bucket
*,
14900 void *))lcommunity_show_all_iterator
,
14903 return CMD_SUCCESS
;
14905 /* Graceful Restart */
14907 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
14914 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
14916 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
14918 switch (bgp_global_gr_mode
) {
14920 case GLOBAL_HELPER
:
14921 vty_out(vty
, "Global BGP GR Mode : Helper\n");
14925 vty_out(vty
, "Global BGP GR Mode : Restart\n");
14928 case GLOBAL_DISABLE
:
14929 vty_out(vty
, "Global BGP GR Mode : Disable\n");
14932 case GLOBAL_INVALID
:
14934 "Global BGP GR Mode Invalid\n");
14937 vty_out(vty
, "\n");
14940 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
14941 enum show_type type
,
14942 const char *ip_str
,
14943 afi_t afi
, bool use_json
)
14945 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
14948 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
14950 bgp_show_neighbor_graceful_restart_vty(
14951 vty
, type
, ip_str
, afi
, use_json
);
14954 } else if (afi
!= AFI_MAX
) {
14955 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
14958 return CMD_ERR_INCOMPLETE
;
14961 return CMD_SUCCESS
;
14963 /* Graceful Restart */
14965 DEFUN (show_ip_bgp_attr_info
,
14966 show_ip_bgp_attr_info_cmd
,
14967 "show [ip] bgp attribute-info",
14971 "List all bgp attribute information\n")
14973 attr_show_all(vty
);
14974 return CMD_SUCCESS
;
14977 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
14978 afi_t afi
, safi_t safi
,
14979 bool use_json
, json_object
*json
)
14982 struct listnode
*node
;
14984 char buf1
[INET6_ADDRSTRLEN
];
14986 vpn_policy_direction_t dir
;
14989 json_object
*json_import_vrfs
= NULL
;
14990 json_object
*json_export_vrfs
= NULL
;
14992 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14995 vty_out(vty
, "%s\n",
14996 json_object_to_json_string_ext(
14998 JSON_C_TO_STRING_PRETTY
));
14999 json_object_free(json
);
15001 return CMD_WARNING
;
15004 /* Provide context for the block */
15005 json_object_string_add(json
, "vrf", name
? name
: "default");
15006 json_object_string_add(json
, "afiSafi",
15007 get_afi_safi_str(afi
, safi
, true));
15009 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15010 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15011 json_object_string_add(json
, "importFromVrfs", "none");
15012 json_object_string_add(json
, "importRts", "none");
15014 json_import_vrfs
= json_object_new_array();
15016 for (ALL_LIST_ELEMENTS_RO(
15017 bgp
->vpn_policy
[afi
].import_vrf
,
15019 json_object_array_add(json_import_vrfs
,
15020 json_object_new_string(vname
));
15022 json_object_object_add(json
, "importFromVrfs",
15024 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15025 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15026 ecom_str
= ecommunity_ecom2str(
15027 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15028 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15029 json_object_string_add(json
, "importRts",
15031 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15033 json_object_string_add(json
, "importRts",
15037 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15038 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15039 json_object_string_add(json
, "exportToVrfs", "none");
15040 json_object_string_add(json
, "routeDistinguisher",
15042 json_object_string_add(json
, "exportRts", "none");
15044 json_export_vrfs
= json_object_new_array();
15046 for (ALL_LIST_ELEMENTS_RO(
15047 bgp
->vpn_policy
[afi
].export_vrf
,
15049 json_object_array_add(json_export_vrfs
,
15050 json_object_new_string(vname
));
15051 json_object_object_add(json
, "exportToVrfs",
15053 json_object_string_add(json
, "routeDistinguisher",
15054 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
15055 buf1
, RD_ADDRSTRLEN
));
15057 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15058 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15059 ecom_str
= ecommunity_ecom2str(
15060 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15061 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15062 json_object_string_add(json
, "exportRts",
15064 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15066 json_object_string_add(json
, "exportRts",
15071 vty_out(vty
, "%s\n",
15072 json_object_to_json_string_ext(json
,
15073 JSON_C_TO_STRING_PRETTY
));
15074 json_object_free(json
);
15077 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15080 vty_out(vty
, "%% No such BGP instance exist\n");
15081 return CMD_WARNING
;
15084 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15085 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15087 "This VRF is not importing %s routes from any other VRF\n",
15088 get_afi_safi_str(afi
, safi
, false));
15091 "This VRF is importing %s routes from the following VRFs:\n",
15092 get_afi_safi_str(afi
, safi
, false));
15094 for (ALL_LIST_ELEMENTS_RO(
15095 bgp
->vpn_policy
[afi
].import_vrf
,
15097 vty_out(vty
, " %s\n", vname
);
15099 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15101 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15102 ecom_str
= ecommunity_ecom2str(
15103 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15104 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15105 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15107 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15109 vty_out(vty
, "Import RT(s):\n");
15112 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15113 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15115 "This VRF is not exporting %s routes to any other VRF\n",
15116 get_afi_safi_str(afi
, safi
, false));
15119 "This VRF is exporting %s routes to the following VRFs:\n",
15120 get_afi_safi_str(afi
, safi
, false));
15122 for (ALL_LIST_ELEMENTS_RO(
15123 bgp
->vpn_policy
[afi
].export_vrf
,
15125 vty_out(vty
, " %s\n", vname
);
15127 vty_out(vty
, "RD: %s\n",
15128 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
15129 buf1
, RD_ADDRSTRLEN
));
15131 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15132 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15133 ecom_str
= ecommunity_ecom2str(
15134 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15135 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15136 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15137 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15139 vty_out(vty
, "Import RT(s):\n");
15143 return CMD_SUCCESS
;
15146 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15147 safi_t safi
, bool use_json
)
15149 struct listnode
*node
, *nnode
;
15151 char *vrf_name
= NULL
;
15152 json_object
*json
= NULL
;
15153 json_object
*json_vrf
= NULL
;
15154 json_object
*json_vrfs
= NULL
;
15157 json
= json_object_new_object();
15158 json_vrfs
= json_object_new_object();
15161 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15163 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15164 vrf_name
= bgp
->name
;
15167 json_vrf
= json_object_new_object();
15169 vty_out(vty
, "\nInstance %s:\n",
15170 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15171 ? VRF_DEFAULT_NAME
: bgp
->name
);
15173 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15175 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15176 json_object_object_add(json_vrfs
,
15177 VRF_DEFAULT_NAME
, json_vrf
);
15179 json_object_object_add(json_vrfs
, vrf_name
,
15185 json_object_object_add(json
, "vrfs", json_vrfs
);
15186 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
15187 JSON_C_TO_STRING_PRETTY
));
15188 json_object_free(json
);
15191 return CMD_SUCCESS
;
15194 /* "show [ip] bgp route-leak" command. */
15195 DEFUN (show_ip_bgp_route_leak
,
15196 show_ip_bgp_route_leak_cmd
,
15197 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15201 BGP_INSTANCE_HELP_STR
15204 "Route leaking information\n"
15208 afi_t afi
= AFI_MAX
;
15209 safi_t safi
= SAFI_MAX
;
15211 bool uj
= use_json(argc
, argv
);
15213 json_object
*json
= NULL
;
15215 /* show [ip] bgp */
15216 if (argv_find(argv
, argc
, "ip", &idx
)) {
15218 safi
= SAFI_UNICAST
;
15220 /* [vrf VIEWVRFNAME] */
15221 if (argv_find(argv
, argc
, "view", &idx
)) {
15223 "%% This command is not applicable to BGP views\n");
15224 return CMD_WARNING
;
15227 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15228 vrf
= argv
[idx
+ 1]->arg
;
15229 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15232 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15233 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15234 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15237 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15239 "%% This command is applicable only for unicast ipv4|ipv6\n");
15240 return CMD_WARNING
;
15243 if (vrf
&& strmatch(vrf
, "all"))
15244 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15247 json
= json_object_new_object();
15249 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15252 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15255 struct listnode
*node
, *nnode
;
15258 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15259 vty_out(vty
, "\nInstance %s:\n",
15260 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15263 update_group_show(bgp
, afi
, safi
, vty
, 0);
15267 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15268 int safi
, uint64_t subgrp_id
)
15273 if (strmatch(name
, "all")) {
15274 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
15275 return CMD_SUCCESS
;
15277 bgp
= bgp_lookup_by_name(name
);
15280 bgp
= bgp_get_default();
15284 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
15285 return CMD_SUCCESS
;
15288 DEFUN (show_ip_bgp_updgrps
,
15289 show_ip_bgp_updgrps_cmd
,
15290 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
15294 BGP_INSTANCE_HELP_STR
15296 BGP_SAFI_WITH_LABEL_HELP_STR
15297 "Detailed info about dynamic update groups\n"
15298 "Specific subgroup to display detailed info for\n")
15301 afi_t afi
= AFI_IP6
;
15302 safi_t safi
= SAFI_UNICAST
;
15303 uint64_t subgrp_id
= 0;
15307 /* show [ip] bgp */
15308 if (argv_find(argv
, argc
, "ip", &idx
))
15310 /* [<vrf> VIEWVRFNAME] */
15311 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15312 vrf
= argv
[idx
+ 1]->arg
;
15313 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15315 } else if (argv_find(argv
, argc
, "view", &idx
))
15316 /* [<view> VIEWVRFNAME] */
15317 vrf
= argv
[idx
+ 1]->arg
;
15318 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15319 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15320 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15323 /* get subgroup id, if provided */
15325 if (argv
[idx
]->type
== VARIABLE_TKN
)
15326 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15328 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
15331 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15332 show_bgp_instance_all_ipv6_updgrps_cmd
,
15333 "show [ip] bgp <view|vrf> all update-groups",
15337 BGP_INSTANCE_ALL_HELP_STR
15338 "Detailed info about dynamic update groups\n")
15340 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15341 return CMD_SUCCESS
;
15344 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15345 show_bgp_l2vpn_evpn_updgrps_cmd
,
15346 "show [ip] bgp l2vpn evpn update-groups",
15350 "l2vpn address family\n"
15351 "evpn sub-address family\n"
15352 "Detailed info about dynamic update groups\n")
15355 uint64_t subgrp_id
= 0;
15357 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15358 return CMD_SUCCESS
;
15361 DEFUN (show_bgp_updgrps_stats
,
15362 show_bgp_updgrps_stats_cmd
,
15363 "show [ip] bgp update-groups statistics",
15367 "Detailed info about dynamic update groups\n"
15372 bgp
= bgp_get_default();
15374 update_group_show_stats(bgp
, vty
);
15376 return CMD_SUCCESS
;
15379 DEFUN (show_bgp_instance_updgrps_stats
,
15380 show_bgp_instance_updgrps_stats_cmd
,
15381 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15385 BGP_INSTANCE_HELP_STR
15386 "Detailed info about dynamic update groups\n"
15392 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15394 update_group_show_stats(bgp
, vty
);
15396 return CMD_SUCCESS
;
15399 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15400 afi_t afi
, safi_t safi
,
15401 const char *what
, uint64_t subgrp_id
)
15406 bgp
= bgp_lookup_by_name(name
);
15408 bgp
= bgp_get_default();
15411 if (!strcmp(what
, "advertise-queue"))
15412 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15414 else if (!strcmp(what
, "advertised-routes"))
15415 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15417 else if (!strcmp(what
, "packet-queue"))
15418 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15423 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15424 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15425 "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",
15426 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15428 "Detailed info about dynamic update groups\n"
15429 "Specific subgroup to display info for\n"
15430 "Advertisement queue\n"
15431 "Announced routes\n"
15434 uint64_t subgrp_id
= 0;
15438 subgrp_id
= strtoull(sgid
, NULL
, 10);
15443 afiz
= bgp_vty_afi_from_str(afi
);
15447 afiz
= bgp_vty_afi_from_str(afi
);
15448 if (afiz
!= AFI_IP
)
15450 "%% Cannot specify both 'ip' and 'ipv6'\n");
15451 return CMD_WARNING
;
15454 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15456 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15457 return CMD_SUCCESS
;
15460 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
15462 struct listnode
*node
, *nnode
;
15463 struct prefix
*range
;
15468 const char *peer_status
;
15469 const char *af_str
;
15474 conf
= group
->conf
;
15476 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15477 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15478 group
->name
, conf
->as
);
15479 } else if (conf
->as_type
== AS_INTERNAL
) {
15480 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15481 group
->name
, group
->bgp
->as
);
15483 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15486 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
15487 vty_out(vty
, " Peer-group type is internal\n");
15489 vty_out(vty
, " Peer-group type is external\n");
15491 /* Display AFs configured. */
15492 vty_out(vty
, " Configured address-families:");
15493 FOREACH_AFI_SAFI (afi
, safi
) {
15494 if (conf
->afc
[afi
][safi
]) {
15496 vty_out(vty
, " %s;", get_afi_safi_str(afi
, safi
, false));
15500 vty_out(vty
, " none\n");
15502 vty_out(vty
, "\n");
15504 /* Display listen ranges (for dynamic neighbors), if any */
15505 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15508 else if (afi
== AFI_IP6
)
15512 lr_count
= listcount(group
->listen_range
[afi
]);
15514 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
15518 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15520 vty_out(vty
, " %pFX\n", range
);
15524 /* Display group members and their status */
15525 if (listcount(group
->peer
)) {
15526 vty_out(vty
, " Peer-group members:\n");
15527 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15528 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15529 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15530 peer_status
= "Idle (Admin)";
15531 else if (CHECK_FLAG(peer
->sflags
,
15532 PEER_STATUS_PREFIX_OVERFLOW
))
15533 peer_status
= "Idle (PfxCt)";
15535 peer_status
= lookup_msg(bgp_status_msg
,
15536 peer
->status
, NULL
);
15538 dynamic
= peer_dynamic_neighbor(peer
);
15539 vty_out(vty
, " %s %s %s \n", peer
->host
,
15540 dynamic
? "(dynamic)" : "", peer_status
);
15544 return CMD_SUCCESS
;
15547 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15548 const char *group_name
)
15551 struct listnode
*node
, *nnode
;
15552 struct peer_group
*group
;
15553 bool found
= false;
15555 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15558 vty_out(vty
, "%% BGP instance not found\n");
15559 return CMD_WARNING
;
15562 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15564 if (strmatch(group
->name
, group_name
)) {
15565 bgp_show_one_peer_group(vty
, group
);
15570 bgp_show_one_peer_group(vty
, group
);
15574 if (group_name
&& !found
)
15575 vty_out(vty
, "%% No such peer-group\n");
15577 return CMD_SUCCESS
;
15580 DEFUN (show_ip_bgp_peer_groups
,
15581 show_ip_bgp_peer_groups_cmd
,
15582 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
15586 BGP_INSTANCE_HELP_STR
15587 "Detailed information on BGP peer groups\n"
15588 "Peer group name\n")
15593 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15595 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15597 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
15601 /* Redistribute VTY commands. */
15603 DEFUN_YANG (bgp_redistribute_ipv4
,
15604 bgp_redistribute_ipv4_cmd
,
15605 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15606 "Redistribute information from another routing protocol\n"
15607 FRR_IP_REDIST_HELP_STR_BGPD
)
15609 int idx_protocol
= 1;
15610 char base_xpath
[XPATH_MAXLEN
];
15612 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15613 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15614 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15615 argv
[idx_protocol
]->text
, "0");
15617 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15619 return nb_cli_apply_changes(vty
, base_xpath
);
15623 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15624 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15625 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15627 DEFUN_YANG (bgp_redistribute_ipv4_rmap
,
15628 bgp_redistribute_ipv4_rmap_cmd
,
15629 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15630 "Redistribute information from another routing protocol\n"
15631 FRR_IP_REDIST_HELP_STR_BGPD
15632 "Route map reference\n"
15633 "Pointer to route-map entries\n")
15635 int idx_protocol
= 1;
15637 char base_xpath
[XPATH_MAXLEN
];
15639 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15640 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15641 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15642 argv
[idx_protocol
]->text
, "0");
15644 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15645 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15646 argv
[idx_word
]->arg
);
15648 return nb_cli_apply_changes(vty
, base_xpath
);
15652 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15653 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15654 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15655 "Route map reference\n"
15656 "Pointer to route-map entries\n")
15658 DEFUN_YANG (bgp_redistribute_ipv4_metric
,
15659 bgp_redistribute_ipv4_metric_cmd
,
15660 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15661 "Redistribute information from another routing protocol\n"
15662 FRR_IP_REDIST_HELP_STR_BGPD
15663 "Metric for redistributed routes\n"
15664 "Default metric\n")
15666 int idx_protocol
= 1;
15667 int idx_number
= 3;
15668 char base_xpath
[XPATH_MAXLEN
];
15670 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15671 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15672 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15673 argv
[idx_protocol
]->text
, "0");
15675 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15676 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15677 argv
[idx_number
]->arg
);
15679 return nb_cli_apply_changes(vty
, base_xpath
);
15683 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15684 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15685 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15686 "Metric for redistributed routes\n"
15687 "Default metric\n")
15690 bgp_redistribute_ipv4_rmap_metric
,
15691 bgp_redistribute_ipv4_rmap_metric_cmd
,
15692 "redistribute " FRR_IP_REDIST_STR_BGPD
15693 " route-map WORD metric (0-4294967295)",
15694 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15695 "Route map reference\n"
15696 "Pointer to route-map entries\n"
15697 "Metric for redistributed routes\n"
15698 "Default metric\n")
15700 int idx_protocol
= 1;
15702 int idx_number
= 5;
15703 char base_xpath
[XPATH_MAXLEN
];
15705 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15706 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15707 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15708 argv
[idx_protocol
]->text
, "0");
15710 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15711 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15712 argv
[idx_word
]->arg
);
15713 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15714 argv
[idx_number
]->arg
);
15716 return nb_cli_apply_changes(vty
, base_xpath
);
15720 bgp_redistribute_ipv4_rmap_metric
,
15721 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15722 "redistribute " FRR_IP_REDIST_STR_BGPD
15723 " route-map WORD metric (0-4294967295)",
15724 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15725 "Route map reference\n"
15726 "Pointer to route-map entries\n"
15727 "Metric for redistributed routes\n"
15728 "Default metric\n")
15731 bgp_redistribute_ipv4_metric_rmap
,
15732 bgp_redistribute_ipv4_metric_rmap_cmd
,
15733 "redistribute " FRR_IP_REDIST_STR_BGPD
15734 " metric (0-4294967295) route-map WORD",
15735 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15736 "Metric for redistributed routes\n"
15738 "Route map reference\n"
15739 "Pointer to route-map entries\n")
15741 int idx_protocol
= 1;
15743 int idx_number
= 3;
15744 char base_xpath
[XPATH_MAXLEN
];
15746 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15747 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15748 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15749 argv
[idx_protocol
]->text
, "0");
15751 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15752 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15753 argv
[idx_number
]->arg
);
15754 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15755 argv
[idx_word
]->arg
);
15757 return nb_cli_apply_changes(vty
, base_xpath
);
15761 bgp_redistribute_ipv4_metric_rmap
,
15762 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15763 "redistribute " FRR_IP_REDIST_STR_BGPD
15764 " metric (0-4294967295) route-map WORD",
15765 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15766 "Metric for redistributed routes\n"
15768 "Route map reference\n"
15769 "Pointer to route-map entries\n")
15771 DEFUN_YANG (bgp_redistribute_ipv4_ospf
,
15772 bgp_redistribute_ipv4_ospf_cmd
,
15773 "redistribute <ospf|table> (1-65535)",
15774 "Redistribute information from another routing protocol\n"
15775 "Open Shortest Path First (OSPFv2)\n"
15776 "Non-main Kernel Routing Table\n"
15777 "Instance ID/Table ID\n")
15779 int idx_protocol
= 1;
15780 int idx_number
= 2;
15781 char base_xpath
[XPATH_MAXLEN
];
15783 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15784 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15785 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15786 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15788 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15790 return nb_cli_apply_changes(vty
, base_xpath
);
15793 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
15794 "redistribute <ospf|table> (1-65535)",
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")
15800 DEFUN_YANG (bgp_redistribute_ipv4_ospf_rmap
,
15801 bgp_redistribute_ipv4_ospf_rmap_cmd
,
15802 "redistribute <ospf|table> (1-65535) route-map WORD",
15803 "Redistribute information from another routing protocol\n"
15804 "Open Shortest Path First (OSPFv2)\n"
15805 "Non-main Kernel Routing Table\n"
15806 "Instance ID/Table ID\n"
15807 "Route map reference\n"
15808 "Pointer to route-map entries\n")
15810 int idx_protocol
= 1;
15811 int idx_number
= 2;
15813 char base_xpath
[XPATH_MAXLEN
];
15815 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15816 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15817 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15818 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15820 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15822 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15823 argv
[idx_word
]->arg
);
15825 return nb_cli_apply_changes(vty
, base_xpath
);
15828 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
15829 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
15830 "redistribute <ospf|table> (1-65535) route-map WORD",
15831 "Redistribute information from another routing protocol\n"
15832 "Open Shortest Path First (OSPFv2)\n"
15833 "Non-main Kernel Routing Table\n"
15834 "Instance ID/Table ID\n"
15835 "Route map reference\n"
15836 "Pointer to route-map entries\n")
15838 DEFUN_YANG(bgp_redistribute_ipv4_ospf_metric
,
15839 bgp_redistribute_ipv4_ospf_metric_cmd
,
15840 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15841 "Redistribute information from another routing protocol\n"
15842 "Open Shortest Path First (OSPFv2)\n"
15843 "Non-main Kernel Routing Table\n"
15844 "Instance ID/Table ID\n"
15845 "Metric for redistributed routes\n"
15846 "Default metric\n")
15848 int idx_protocol
= 1;
15849 int idx_number
= 2;
15850 int idx_number_2
= 4;
15851 char base_xpath
[XPATH_MAXLEN
];
15853 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15854 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15855 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15856 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15858 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15860 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15861 argv
[idx_number_2
]->arg
);
15863 return nb_cli_apply_changes(vty
, base_xpath
);
15866 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
15867 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
15868 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15869 "Redistribute information from another routing protocol\n"
15870 "Open Shortest Path First (OSPFv2)\n"
15871 "Non-main Kernel Routing Table\n"
15872 "Instance ID/Table ID\n"
15873 "Metric for redistributed routes\n"
15874 "Default metric\n")
15877 bgp_redistribute_ipv4_ospf_rmap_metric
,
15878 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
15879 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15880 "Redistribute information from another routing protocol\n"
15881 "Open Shortest Path First (OSPFv2)\n"
15882 "Non-main Kernel Routing Table\n"
15883 "Instance ID/Table ID\n"
15884 "Route map reference\n"
15885 "Pointer to route-map entries\n"
15886 "Metric for redistributed routes\n"
15887 "Default metric\n")
15889 int idx_protocol
= 1;
15890 int idx_number
= 2;
15892 int idx_number_2
= 6;
15893 char base_xpath
[XPATH_MAXLEN
];
15895 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15896 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15897 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15898 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15900 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15902 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15903 argv
[idx_word
]->arg
);
15904 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15905 argv
[idx_number_2
]->arg
);
15907 return nb_cli_apply_changes(vty
, base_xpath
);
15911 bgp_redistribute_ipv4_ospf_rmap_metric
,
15912 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
15913 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15914 "Redistribute information from another routing protocol\n"
15915 "Open Shortest Path First (OSPFv2)\n"
15916 "Non-main Kernel Routing Table\n"
15917 "Instance ID/Table ID\n"
15918 "Route map reference\n"
15919 "Pointer to route-map entries\n"
15920 "Metric for redistributed routes\n"
15921 "Default metric\n")
15924 bgp_redistribute_ipv4_ospf_metric_rmap
,
15925 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
15926 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15927 "Redistribute information from another routing protocol\n"
15928 "Open Shortest Path First (OSPFv2)\n"
15929 "Non-main Kernel Routing Table\n"
15930 "Instance ID/Table ID\n"
15931 "Metric for redistributed routes\n"
15933 "Route map reference\n"
15934 "Pointer to route-map entries\n")
15936 int idx_protocol
= 1;
15937 int idx_number
= 2;
15938 int idx_number_2
= 4;
15940 char base_xpath
[XPATH_MAXLEN
];
15942 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15943 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15944 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15945 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15947 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15949 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15950 argv
[idx_number_2
]->arg
);
15951 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15952 argv
[idx_word
]->arg
);
15954 return nb_cli_apply_changes(vty
, base_xpath
);
15958 bgp_redistribute_ipv4_ospf_metric_rmap
,
15959 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
15960 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15961 "Redistribute information from another routing protocol\n"
15962 "Open Shortest Path First (OSPFv2)\n"
15963 "Non-main Kernel Routing Table\n"
15964 "Instance ID/Table ID\n"
15965 "Metric for redistributed routes\n"
15967 "Route map reference\n"
15968 "Pointer to route-map entries\n")
15970 DEFUN_YANG (no_bgp_redistribute_ipv4_ospf
,
15971 no_bgp_redistribute_ipv4_ospf_cmd
,
15972 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
15974 "Redistribute information from another routing protocol\n"
15975 "Open Shortest Path First (OSPFv2)\n"
15976 "Non-main Kernel Routing Table\n"
15977 "Instance ID/Table ID\n"
15978 "Metric for redistributed routes\n"
15980 "Route map reference\n"
15981 "Pointer to route-map entries\n")
15983 int idx_protocol
= 2;
15984 int idx_number
= 3;
15985 char base_xpath
[XPATH_MAXLEN
];
15987 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15988 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15989 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15990 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15992 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
15994 return nb_cli_apply_changes(vty
, base_xpath
);
15998 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
15999 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
16001 "Redistribute information from another routing protocol\n"
16002 "Open Shortest Path First (OSPFv2)\n"
16003 "Non-main Kernel Routing Table\n"
16004 "Instance ID/Table ID\n"
16005 "Metric for redistributed routes\n"
16007 "Route map reference\n"
16008 "Pointer to route-map entries\n")
16010 DEFUN_YANG (no_bgp_redistribute_ipv4
,
16011 no_bgp_redistribute_ipv4_cmd
,
16012 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
16014 "Redistribute information from another routing protocol\n"
16015 FRR_IP_REDIST_HELP_STR_BGPD
16016 "Metric for redistributed routes\n"
16018 "Route map reference\n"
16019 "Pointer to route-map entries\n")
16021 int idx_protocol
= 2;
16022 char base_xpath
[XPATH_MAXLEN
];
16024 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16025 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16026 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16027 argv
[idx_protocol
]->text
, "0");
16029 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
16031 return nb_cli_apply_changes(vty
, base_xpath
);
16035 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16036 "no redistribute " FRR_IP_REDIST_STR_BGPD
16037 " [{metric (0-4294967295)|route-map WORD}]",
16039 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16040 "Metric for redistributed routes\n"
16042 "Route map reference\n"
16043 "Pointer to route-map entries\n")
16045 DEFUN_YANG (bgp_redistribute_ipv6
,
16046 bgp_redistribute_ipv6_cmd
,
16047 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16048 "Redistribute information from another routing protocol\n"
16049 FRR_IP6_REDIST_HELP_STR_BGPD
)
16051 int idx_protocol
= 1;
16052 char base_xpath
[XPATH_MAXLEN
];
16054 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16055 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16056 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16057 argv
[idx_protocol
]->text
, "0");
16059 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16061 return nb_cli_apply_changes(vty
, base_xpath
);
16064 DEFUN_YANG (bgp_redistribute_ipv6_rmap
,
16065 bgp_redistribute_ipv6_rmap_cmd
,
16066 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
16067 "Redistribute information from another routing protocol\n"
16068 FRR_IP6_REDIST_HELP_STR_BGPD
16069 "Route map reference\n"
16070 "Pointer to route-map entries\n")
16072 int idx_protocol
= 1;
16074 char base_xpath
[XPATH_MAXLEN
];
16076 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16077 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16078 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16079 argv
[idx_protocol
]->text
, "0");
16081 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16082 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16083 argv
[idx_word
]->arg
);
16085 return nb_cli_apply_changes(vty
, base_xpath
);
16088 DEFUN_YANG (bgp_redistribute_ipv6_metric
,
16089 bgp_redistribute_ipv6_metric_cmd
,
16090 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16091 "Redistribute information from another routing protocol\n"
16092 FRR_IP6_REDIST_HELP_STR_BGPD
16093 "Metric for redistributed routes\n"
16094 "Default metric\n")
16096 int idx_protocol
= 1;
16097 int idx_number
= 3;
16098 char base_xpath
[XPATH_MAXLEN
];
16100 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16101 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16102 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16103 argv
[idx_protocol
]->text
, "0");
16105 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16106 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16107 argv
[idx_number
]->arg
);
16109 return nb_cli_apply_changes(vty
, base_xpath
);
16113 bgp_redistribute_ipv6_rmap_metric
,
16114 bgp_redistribute_ipv6_rmap_metric_cmd
,
16115 "redistribute " FRR_IP6_REDIST_STR_BGPD
16116 " route-map WORD metric (0-4294967295)",
16117 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
16118 "Route map reference\n"
16119 "Pointer to route-map entries\n"
16120 "Metric for redistributed routes\n"
16121 "Default metric\n")
16123 int idx_protocol
= 1;
16125 int idx_number
= 5;
16126 char base_xpath
[XPATH_MAXLEN
];
16128 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16129 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16130 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16131 argv
[idx_protocol
]->text
, "0");
16133 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16134 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16135 argv
[idx_word
]->arg
);
16136 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16137 argv
[idx_number
]->arg
);
16139 return nb_cli_apply_changes(vty
, base_xpath
);
16143 bgp_redistribute_ipv6_metric_rmap
,
16144 bgp_redistribute_ipv6_metric_rmap_cmd
,
16145 "redistribute " FRR_IP6_REDIST_STR_BGPD
16146 " metric (0-4294967295) route-map WORD",
16147 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
16148 "Metric for redistributed routes\n"
16150 "Route map reference\n"
16151 "Pointer to route-map entries\n")
16153 int idx_protocol
= 1;
16155 int idx_number
= 3;
16156 char base_xpath
[XPATH_MAXLEN
];
16158 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16159 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16160 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16161 argv
[idx_protocol
]->text
, "0");
16163 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16164 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16165 argv
[idx_number
]->arg
);
16166 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16167 argv
[idx_word
]->arg
);
16169 return nb_cli_apply_changes(vty
, base_xpath
);
16173 no_bgp_redistribute_ipv6
,
16174 no_bgp_redistribute_ipv6_cmd
,
16175 "no redistribute " FRR_IP6_REDIST_STR_BGPD
16176 " [{metric (0-4294967295)|route-map WORD}]",
16178 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
16179 "Metric for redistributed routes\n"
16181 "Route map reference\n"
16182 "Pointer to route-map entries\n")
16184 int idx_protocol
= 2;
16185 char base_xpath
[XPATH_MAXLEN
];
16187 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16188 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16189 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16190 argv
[idx_protocol
]->text
, "0");
16192 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
16194 return nb_cli_apply_changes(vty
, base_xpath
);
16197 void cli_show_bgp_global_afi_safi_ip_unicast_redistribution_list(
16198 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
16200 uint32_t instance
= 0;
16202 vty_out(vty
, " redistribute %s",
16203 yang_dnode_get_string(dnode
, "./route-type"));
16204 if ((instance
= yang_dnode_get_uint16(dnode
, "./route-instance")))
16205 vty_out(vty
, " %d", instance
);
16206 if (yang_dnode_exists(dnode
, "./metric"))
16207 vty_out(vty
, " metric %u",
16208 yang_dnode_get_uint32(dnode
, "./metric"));
16209 if (yang_dnode_exists(dnode
, "./rmap-policy-import"))
16210 vty_out(vty
, " route-map %s",
16211 yang_dnode_get_string(dnode
, "./rmap-policy-import"));
16212 vty_out(vty
, "\n");
16215 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16216 afi_t afi
, safi_t safi
)
16220 /* Unicast redistribution only. */
16221 if (safi
!= SAFI_UNICAST
)
16224 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16225 /* Redistribute BGP does not make sense. */
16226 if (i
!= ZEBRA_ROUTE_BGP
) {
16227 struct list
*red_list
;
16228 struct listnode
*node
;
16229 struct bgp_redist
*red
;
16231 red_list
= bgp
->redist
[afi
][i
];
16235 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16236 /* "redistribute" configuration. */
16237 vty_out(vty
, " redistribute %s",
16238 zebra_route_string(i
));
16240 vty_out(vty
, " %d", red
->instance
);
16241 if (red
->redist_metric_flag
)
16242 vty_out(vty
, " metric %u",
16243 red
->redist_metric
);
16244 if (red
->rmap
.name
)
16245 vty_out(vty
, " route-map %s",
16247 vty_out(vty
, "\n");
16253 /* peer-group helpers for config-write */
16255 static bool peergroup_flag_check(struct peer
*peer
, uint32_t flag
)
16257 if (!peer_group_active(peer
)) {
16258 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16259 return !CHECK_FLAG(peer
->flags
, flag
);
16261 return !!CHECK_FLAG(peer
->flags
, flag
);
16264 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16267 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16270 if (!peer_group_active(peer
)) {
16271 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16272 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16274 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16277 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16280 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16281 uint8_t type
, int direct
)
16283 struct bgp_filter
*filter
;
16285 if (peer_group_active(peer
))
16286 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16289 filter
= &peer
->filter
[afi
][safi
];
16291 case PEER_FT_DISTRIBUTE_LIST
:
16292 return !!(filter
->dlist
[direct
].name
);
16293 case PEER_FT_FILTER_LIST
:
16294 return !!(filter
->aslist
[direct
].name
);
16295 case PEER_FT_PREFIX_LIST
:
16296 return !!(filter
->plist
[direct
].name
);
16297 case PEER_FT_ROUTE_MAP
:
16298 return !!(filter
->map
[direct
].name
);
16299 case PEER_FT_UNSUPPRESS_MAP
:
16300 return !!(filter
->usmap
.name
);
16301 case PEER_FT_ADVERTISE_MAP
:
16302 return !!(filter
->advmap
.aname
16303 && ((filter
->advmap
.condition
== direct
)
16304 && filter
->advmap
.cname
));
16310 /* Return true if the addpath type is set for peer and different from
16313 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16316 enum bgp_addpath_strat type
, g_type
;
16318 type
= peer
->addpath_type
[afi
][safi
];
16320 if (type
!= BGP_ADDPATH_NONE
) {
16321 if (peer_group_active(peer
)) {
16322 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16324 if (type
!= g_type
)
16336 /* This is part of the address-family block (unicast only) */
16337 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16342 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16343 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16344 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16345 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16346 bgp
->vpn_policy
[afi
]
16347 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16349 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16350 bgp
->vpn_policy
[afi
]
16351 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16353 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16354 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16355 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16356 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16359 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16360 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16362 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16365 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16366 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16367 bgp
->vpn_policy
[afi
].tovpn_label
);
16370 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16371 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
16372 char buf
[RD_ADDRSTRLEN
];
16373 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
16374 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
16377 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16378 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16380 char buf
[PREFIX_STRLEN
];
16381 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16382 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16385 vty_out(vty
, "%*snexthop vpn export %s\n",
16389 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16390 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16392 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16393 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16395 char *b
= ecommunity_ecom2str(
16396 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16397 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16398 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16399 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16401 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16402 char *b
= ecommunity_ecom2str(
16403 bgp
->vpn_policy
[afi
]
16404 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16405 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16406 ECOMMUNITY_ROUTE_TARGET
);
16407 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16408 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16410 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16411 char *b
= ecommunity_ecom2str(
16412 bgp
->vpn_policy
[afi
]
16413 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16414 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16415 ECOMMUNITY_ROUTE_TARGET
);
16416 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16417 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16421 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16422 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16423 bgp
->vpn_policy
[afi
]
16424 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16426 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16427 char *b
= ecommunity_ecom2str(
16428 bgp
->vpn_policy
[afi
]
16429 .import_redirect_rtlist
,
16430 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16431 ECOMMUNITY_ROUTE_TARGET
);
16433 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16434 != ECOMMUNITY_SIZE
)
16435 vty_out(vty
, "%*srt6 redirect import %s\n",
16438 vty_out(vty
, "%*srt redirect import %s\n",
16440 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16444 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16445 afi_t afi
, safi_t safi
)
16447 struct bgp_filter
*filter
;
16451 filter
= &peer
->filter
[afi
][safi
];
16453 /* distribute-list. */
16454 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16456 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16457 filter
->dlist
[FILTER_IN
].name
);
16459 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16461 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16462 filter
->dlist
[FILTER_OUT
].name
);
16465 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16467 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16468 filter
->plist
[FILTER_IN
].name
);
16470 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16472 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16473 filter
->plist
[FILTER_OUT
].name
);
16476 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16477 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16478 filter
->map
[RMAP_IN
].name
);
16480 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16482 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16483 filter
->map
[RMAP_OUT
].name
);
16485 /* unsuppress-map */
16486 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16487 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16488 filter
->usmap
.name
);
16490 /* advertise-map : always applied in OUT direction*/
16491 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16492 CONDITION_NON_EXIST
))
16494 " neighbor %s advertise-map %s non-exist-map %s\n",
16495 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16497 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16499 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16500 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16503 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16505 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16506 filter
->aslist
[FILTER_IN
].name
);
16508 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16510 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16511 filter
->aslist
[FILTER_OUT
].name
);
16514 /* BGP peer configuration display function. */
16515 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16518 struct peer
*g_peer
= NULL
;
16519 char buf
[SU_ADDRSTRLEN
];
16521 int if_pg_printed
= false;
16522 int if_ras_printed
= false;
16524 /* Skip dynamic neighbors. */
16525 if (peer_dynamic_neighbor(peer
))
16529 addr
= peer
->conf_if
;
16533 /************************************
16534 ****** Global to the neighbor ******
16535 ************************************/
16536 if (peer
->conf_if
) {
16537 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16538 vty_out(vty
, " neighbor %s interface v6only", addr
);
16540 vty_out(vty
, " neighbor %s interface", addr
);
16542 if (peer_group_active(peer
)) {
16543 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16544 if_pg_printed
= true;
16545 } else if (peer
->as_type
== AS_SPECIFIED
) {
16546 vty_out(vty
, " remote-as %u", peer
->as
);
16547 if_ras_printed
= true;
16548 } else if (peer
->as_type
== AS_INTERNAL
) {
16549 vty_out(vty
, " remote-as internal");
16550 if_ras_printed
= true;
16551 } else if (peer
->as_type
== AS_EXTERNAL
) {
16552 vty_out(vty
, " remote-as external");
16553 if_ras_printed
= true;
16556 vty_out(vty
, "\n");
16559 /* remote-as and peer-group */
16560 /* peer is a member of a peer-group */
16561 if (peer_group_active(peer
)) {
16562 g_peer
= peer
->group
->conf
;
16564 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16565 if (peer
->as_type
== AS_SPECIFIED
) {
16566 vty_out(vty
, " neighbor %s remote-as %u\n",
16568 } else if (peer
->as_type
== AS_INTERNAL
) {
16570 " neighbor %s remote-as internal\n",
16572 } else if (peer
->as_type
== AS_EXTERNAL
) {
16574 " neighbor %s remote-as external\n",
16579 /* For swpX peers we displayed the peer-group
16580 * via 'neighbor swpX interface peer-group PGNAME' */
16581 if (!if_pg_printed
)
16582 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16583 peer
->group
->name
);
16586 /* peer is NOT a member of a peer-group */
16588 /* peer is a peer-group, declare the peer-group */
16589 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16590 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16593 if (!if_ras_printed
) {
16594 if (peer
->as_type
== AS_SPECIFIED
) {
16595 vty_out(vty
, " neighbor %s remote-as %u\n",
16597 } else if (peer
->as_type
== AS_INTERNAL
) {
16599 " neighbor %s remote-as internal\n",
16601 } else if (peer
->as_type
== AS_EXTERNAL
) {
16603 " neighbor %s remote-as external\n",
16610 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16611 vty_out(vty
, " neighbor %s local-as %u", addr
,
16612 peer
->change_local_as
);
16613 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16614 vty_out(vty
, " no-prepend");
16615 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16616 vty_out(vty
, " replace-as");
16617 vty_out(vty
, "\n");
16622 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16626 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16627 if (peer
->tx_shutdown_message
)
16628 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16629 peer
->tx_shutdown_message
);
16631 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16634 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16635 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16636 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16639 if (peer
->bfd_info
) {
16640 if (!peer_group_active(peer
) || !g_peer
->bfd_info
) {
16641 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16646 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16647 vty_out(vty
, " neighbor %s password %s\n", addr
,
16650 /* neighbor solo */
16651 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16652 if (!peer_group_active(peer
)) {
16653 vty_out(vty
, " neighbor %s solo\n", addr
);
16658 if (peer
->port
!= BGP_PORT_DEFAULT
) {
16659 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
16662 /* Local interface name */
16663 if (peer
->ifname
) {
16664 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
16668 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
16669 vty_out(vty
, " neighbor %s passive\n", addr
);
16671 /* ebgp-multihop */
16672 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
16673 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
16674 && peer
->ttl
== MAXTTL
)) {
16675 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
16676 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
16681 /* ttl-security hops */
16682 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
16683 if (!peer_group_active(peer
)
16684 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
16685 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
16686 addr
, peer
->gtsm_hops
);
16690 /* disable-connected-check */
16691 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
16692 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
16694 /* enforce-first-as */
16695 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
16696 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
16698 /* update-source */
16699 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
16700 if (peer
->update_source
)
16701 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16702 sockunion2str(peer
->update_source
, buf
,
16704 else if (peer
->update_if
)
16705 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16709 /* advertisement-interval */
16710 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
16711 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
16715 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
16716 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
16717 peer
->keepalive
, peer
->holdtime
);
16719 /* timers connect */
16720 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
16721 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16723 /* need special-case handling for changed default values due to
16724 * config profile / version (because there is no "timers bgp connect"
16725 * command, we need to save this per-peer :/)
16727 else if (!peer_group_active(peer
) && !peer
->connect
&&
16728 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
16729 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16730 peer
->bgp
->default_connect_retry
);
16732 /* timers delayopen */
16733 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
16734 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16736 /* Save config even though flag is not set if default values have been
16739 else if (!peer_group_active(peer
) && !peer
->delayopen
16740 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
16741 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16742 peer
->bgp
->default_delayopen
);
16744 /* capability dynamic */
16745 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
16746 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
16748 /* capability extended-nexthop */
16749 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
16750 if (!peer
->conf_if
) {
16751 if (CHECK_FLAG(peer
->flags_invert
,
16752 PEER_FLAG_CAPABILITY_ENHE
))
16754 " no neighbor %s capability extended-nexthop\n",
16758 " neighbor %s capability extended-nexthop\n",
16763 /* dont-capability-negotiation */
16764 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
16765 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
16767 /* override-capability */
16768 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
16769 vty_out(vty
, " neighbor %s override-capability\n", addr
);
16771 /* strict-capability-match */
16772 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
16773 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
16775 /* Sender side AS path loop detection. */
16776 if (peer
->as_path_loop_detection
)
16777 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
16780 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16781 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
16783 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16784 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
16786 " neighbor %s graceful-restart-helper\n", addr
);
16787 } else if (CHECK_FLAG(
16788 peer
->peer_gr_new_status_flag
,
16789 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
16791 " neighbor %s graceful-restart\n", addr
);
16793 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16794 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
16796 peer
->peer_gr_new_status_flag
,
16797 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
16798 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
16804 /* BGP peer configuration display function. */
16805 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
16806 struct peer
*peer
, afi_t afi
, safi_t safi
)
16808 struct peer
*g_peer
= NULL
;
16810 bool flag_scomm
, flag_secomm
, flag_slcomm
;
16812 /* Skip dynamic neighbors. */
16813 if (peer_dynamic_neighbor(peer
))
16817 addr
= peer
->conf_if
;
16821 /************************************
16822 ****** Per AF to the neighbor ******
16823 ************************************/
16824 if (peer_group_active(peer
)) {
16825 g_peer
= peer
->group
->conf
;
16827 /* If the peer-group is active but peer is not, print a 'no
16829 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
16830 vty_out(vty
, " no neighbor %s activate\n", addr
);
16833 /* If the peer-group is not active but peer is, print an
16835 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
16836 vty_out(vty
, " neighbor %s activate\n", addr
);
16839 if (peer
->afc
[afi
][safi
]) {
16840 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
16841 if (CHECK_FLAG(bgp
->flags
,
16842 BGP_FLAG_NO_DEFAULT_IPV4
)) {
16843 vty_out(vty
, " neighbor %s activate\n",
16847 vty_out(vty
, " neighbor %s activate\n", addr
);
16849 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
16850 if (!CHECK_FLAG(bgp
->flags
,
16851 BGP_FLAG_NO_DEFAULT_IPV4
)) {
16853 " no neighbor %s activate\n",
16860 /* addpath TX knobs */
16861 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
16862 switch (peer
->addpath_type
[afi
][safi
]) {
16863 case BGP_ADDPATH_ALL
:
16864 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
16867 case BGP_ADDPATH_BEST_PER_AS
:
16869 " neighbor %s addpath-tx-bestpath-per-AS\n",
16872 case BGP_ADDPATH_MAX
:
16873 case BGP_ADDPATH_NONE
:
16878 /* ORF capability. */
16879 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
16880 || peergroup_af_flag_check(peer
, afi
, safi
,
16881 PEER_FLAG_ORF_PREFIX_RM
)) {
16882 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
16884 if (peergroup_af_flag_check(peer
, afi
, safi
,
16885 PEER_FLAG_ORF_PREFIX_SM
)
16886 && peergroup_af_flag_check(peer
, afi
, safi
,
16887 PEER_FLAG_ORF_PREFIX_RM
))
16888 vty_out(vty
, " both");
16889 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16890 PEER_FLAG_ORF_PREFIX_SM
))
16891 vty_out(vty
, " send");
16893 vty_out(vty
, " receive");
16894 vty_out(vty
, "\n");
16897 /* Route reflector client. */
16898 if (peergroup_af_flag_check(peer
, afi
, safi
,
16899 PEER_FLAG_REFLECTOR_CLIENT
)) {
16900 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
16903 /* next-hop-self force */
16904 if (peergroup_af_flag_check(peer
, afi
, safi
,
16905 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
16906 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
16909 /* next-hop-self */
16910 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
16911 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
16914 /* remove-private-AS */
16915 if (peergroup_af_flag_check(peer
, afi
, safi
,
16916 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
16917 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
16921 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16922 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
16923 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
16927 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16928 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
16929 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
16932 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16933 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
16934 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
16938 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
16939 vty_out(vty
, " neighbor %s as-override\n", addr
);
16942 /* send-community print. */
16943 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16944 PEER_FLAG_SEND_COMMUNITY
);
16945 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16946 PEER_FLAG_SEND_EXT_COMMUNITY
);
16947 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16948 PEER_FLAG_SEND_LARGE_COMMUNITY
);
16950 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
16951 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
16954 vty_out(vty
, " no neighbor %s send-community\n", addr
);
16957 " no neighbor %s send-community extended\n",
16961 vty_out(vty
, " no neighbor %s send-community large\n",
16965 /* Default information */
16966 if (peergroup_af_flag_check(peer
, afi
, safi
,
16967 PEER_FLAG_DEFAULT_ORIGINATE
)) {
16968 vty_out(vty
, " neighbor %s default-originate", addr
);
16970 if (peer
->default_rmap
[afi
][safi
].name
)
16971 vty_out(vty
, " route-map %s",
16972 peer
->default_rmap
[afi
][safi
].name
);
16974 vty_out(vty
, "\n");
16977 /* Soft reconfiguration inbound. */
16978 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
16979 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
16983 /* maximum-prefix. */
16984 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
16985 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
16986 peer
->pmax
[afi
][safi
]);
16988 if (peer
->pmax_threshold
[afi
][safi
]
16989 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
16990 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
16991 if (peer_af_flag_check(peer
, afi
, safi
,
16992 PEER_FLAG_MAX_PREFIX_WARNING
))
16993 vty_out(vty
, " warning-only");
16994 if (peer
->pmax_restart
[afi
][safi
])
16995 vty_out(vty
, " restart %u",
16996 peer
->pmax_restart
[afi
][safi
]);
16997 if (peer_af_flag_check(peer
, afi
, safi
,
16998 PEER_FLAG_MAX_PREFIX_FORCE
))
16999 vty_out(vty
, " force");
17001 vty_out(vty
, "\n");
17004 /* maximum-prefix-out */
17005 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17006 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17007 addr
, peer
->pmax_out
[afi
][safi
]);
17009 /* Route server client. */
17010 if (peergroup_af_flag_check(peer
, afi
, safi
,
17011 PEER_FLAG_RSERVER_CLIENT
)) {
17012 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17015 /* Nexthop-local unchanged. */
17016 if (peergroup_af_flag_check(peer
, afi
, safi
,
17017 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17018 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17021 /* allowas-in <1-10> */
17022 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17023 if (peer_af_flag_check(peer
, afi
, safi
,
17024 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17025 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17026 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17027 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17029 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17030 peer
->allowas_in
[afi
][safi
]);
17035 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17036 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17037 peer
->weight
[afi
][safi
]);
17040 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17042 /* atribute-unchanged. */
17043 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17044 || (safi
!= SAFI_EVPN
17045 && peer_af_flag_check(peer
, afi
, safi
,
17046 PEER_FLAG_NEXTHOP_UNCHANGED
))
17047 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17049 if (!peer_group_active(peer
)
17050 || peergroup_af_flag_check(peer
, afi
, safi
,
17051 PEER_FLAG_AS_PATH_UNCHANGED
)
17052 || peergroup_af_flag_check(peer
, afi
, safi
,
17053 PEER_FLAG_NEXTHOP_UNCHANGED
)
17054 || peergroup_af_flag_check(peer
, afi
, safi
,
17055 PEER_FLAG_MED_UNCHANGED
)) {
17058 " neighbor %s attribute-unchanged%s%s%s\n",
17060 peer_af_flag_check(peer
, afi
, safi
,
17061 PEER_FLAG_AS_PATH_UNCHANGED
)
17064 peer_af_flag_check(peer
, afi
, safi
,
17065 PEER_FLAG_NEXTHOP_UNCHANGED
)
17068 peer_af_flag_check(peer
, afi
, safi
,
17069 PEER_FLAG_MED_UNCHANGED
)
17076 /* Address family based peer configuration display. */
17077 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17081 struct peer_group
*group
;
17082 struct listnode
*node
, *nnode
;
17085 vty_frame(vty
, " !\n address-family ");
17086 if (afi
== AFI_IP
) {
17087 if (safi
== SAFI_UNICAST
)
17088 vty_frame(vty
, "ipv4 unicast");
17089 else if (safi
== SAFI_LABELED_UNICAST
)
17090 vty_frame(vty
, "ipv4 labeled-unicast");
17091 else if (safi
== SAFI_MULTICAST
)
17092 vty_frame(vty
, "ipv4 multicast");
17093 else if (safi
== SAFI_MPLS_VPN
)
17094 vty_frame(vty
, "ipv4 vpn");
17095 else if (safi
== SAFI_ENCAP
)
17096 vty_frame(vty
, "ipv4 encap");
17097 else if (safi
== SAFI_FLOWSPEC
)
17098 vty_frame(vty
, "ipv4 flowspec");
17099 } else if (afi
== AFI_IP6
) {
17100 if (safi
== SAFI_UNICAST
)
17101 vty_frame(vty
, "ipv6 unicast");
17102 else if (safi
== SAFI_LABELED_UNICAST
)
17103 vty_frame(vty
, "ipv6 labeled-unicast");
17104 else if (safi
== SAFI_MULTICAST
)
17105 vty_frame(vty
, "ipv6 multicast");
17106 else if (safi
== SAFI_MPLS_VPN
)
17107 vty_frame(vty
, "ipv6 vpn");
17108 else if (safi
== SAFI_ENCAP
)
17109 vty_frame(vty
, "ipv6 encap");
17110 else if (safi
== SAFI_FLOWSPEC
)
17111 vty_frame(vty
, "ipv6 flowspec");
17112 } else if (afi
== AFI_L2VPN
) {
17113 if (safi
== SAFI_EVPN
)
17114 vty_frame(vty
, "l2vpn evpn");
17116 vty_frame(vty
, "\n");
17118 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17120 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17122 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17124 /* BGP flag dampening. */
17125 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17126 bgp_config_write_damp(vty
, bgp
, afi
, safi
);
17127 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, node
, group
))
17128 if (peer_af_flag_check(group
->conf
, afi
, safi
,
17129 PEER_FLAG_CONFIG_DAMPENING
))
17130 bgp_config_write_peer_damp(vty
, group
->conf
, afi
, safi
);
17131 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, node
, peer
))
17132 if (peer_af_flag_check(peer
, afi
, safi
,
17133 PEER_FLAG_CONFIG_DAMPENING
))
17134 bgp_config_write_peer_damp(vty
, peer
, afi
, safi
);
17136 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17137 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17139 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17140 /* Skip dynamic neighbors. */
17141 if (peer_dynamic_neighbor(peer
))
17144 /* Do not display doppelganger peers */
17145 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17146 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17149 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17150 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17152 if (safi
== SAFI_EVPN
)
17153 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17155 if (safi
== SAFI_FLOWSPEC
)
17156 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17158 if (safi
== SAFI_UNICAST
) {
17159 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17160 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17161 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17163 vty_out(vty
, " export vpn\n");
17165 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17166 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17168 vty_out(vty
, " import vpn\n");
17170 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17171 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17174 for (ALL_LIST_ELEMENTS_RO(
17175 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17177 vty_out(vty
, " import vrf %s\n", name
);
17181 vty_endframe(vty
, " exit-address-family\n");
17184 int bgp_config_write(struct vty
*vty
)
17187 struct peer_group
*group
;
17189 struct listnode
*node
, *nnode
;
17190 struct listnode
*mnode
, *mnnode
;
17192 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17193 vty_out(vty
, "bgp route-map delay-timer %u\n",
17194 bm
->rmap_update_timer
);
17196 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17197 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17198 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17199 vty_out(vty
, " %d", bm
->v_establish_wait
);
17200 vty_out(vty
, "\n");
17203 if (bm
->wait_for_fib
)
17204 vty_out(vty
, "bgp suppress-fib-pending\n");
17206 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17207 vty_out(vty
, "bgp graceful-shutdown\n");
17209 /* No-RIB (Zebra) option flag configuration */
17210 if (bgp_option_check(BGP_OPT_NO_FIB
))
17211 vty_out(vty
, "bgp no-rib\n");
17213 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17214 vty_out(vty
, "no bgp send-extra-data zebra\n");
17216 /* BGP configuration. */
17217 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17219 /* skip all auto created vrf as they dont have user config */
17220 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17223 /* Router bgp ASN */
17224 vty_out(vty
, "router bgp %u", bgp
->as
);
17227 vty_out(vty
, " %s %s",
17228 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17229 ? "view" : "vrf", bgp
->name
);
17230 vty_out(vty
, "\n");
17232 /* BGP fast-external-failover. */
17233 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17234 vty_out(vty
, " no bgp fast-external-failover\n");
17236 /* BGP router ID. */
17237 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17238 vty_out(vty
, " bgp router-id %pI4\n",
17239 &bgp
->router_id_static
);
17241 /* Suppress fib pending */
17242 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17243 vty_out(vty
, " bgp suppress-fib-pending\n");
17245 /* BGP log-neighbor-changes. */
17246 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17247 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17248 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17249 CHECK_FLAG(bgp
->flags
,
17250 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17254 /* BGP configuration. */
17255 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17256 vty_out(vty
, " bgp always-compare-med\n");
17258 /* RFC8212 default eBGP policy. */
17259 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17260 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17261 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17262 CHECK_FLAG(bgp
->flags
,
17263 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17267 /* draft-ietf-idr-deprecate-as-set-confed-set */
17268 if (bgp
->reject_as_sets
)
17269 vty_out(vty
, " bgp reject-as-sets\n");
17271 /* Suppress duplicate updates if the route actually not changed
17273 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17274 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17275 vty_out(vty
, " %sbgp suppress-duplicates\n",
17276 CHECK_FLAG(bgp
->flags
,
17277 BGP_FLAG_SUPPRESS_DUPLICATES
)
17281 /* BGP default ipv4-unicast. */
17282 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
))
17283 vty_out(vty
, " no bgp default ipv4-unicast\n");
17285 /* BGP default local-preference. */
17286 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17287 vty_out(vty
, " bgp default local-preference %u\n",
17288 bgp
->default_local_pref
);
17290 /* BGP default show-hostname */
17291 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17292 != SAVE_BGP_SHOW_HOSTNAME
)
17293 vty_out(vty
, " %sbgp default show-hostname\n",
17294 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17298 /* BGP default show-nexthop-hostname */
17299 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17300 != SAVE_BGP_SHOW_HOSTNAME
)
17301 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17302 CHECK_FLAG(bgp
->flags
,
17303 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17307 /* BGP default subgroup-pkt-queue-max. */
17308 if (bgp
->default_subgroup_pkt_queue_max
17309 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17310 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17311 bgp
->default_subgroup_pkt_queue_max
);
17313 /* BGP client-to-client reflection. */
17314 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17315 vty_out(vty
, " no bgp client-to-client reflection\n");
17317 /* BGP cluster ID. */
17318 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17319 vty_out(vty
, " bgp cluster-id %pI4\n",
17322 /* Disable ebgp connected nexthop check */
17323 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17325 " bgp disable-ebgp-connected-route-check\n");
17327 /* Confederation identifier*/
17328 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17329 vty_out(vty
, " bgp confederation identifier %u\n",
17332 /* Confederation peer */
17333 if (bgp
->confed_peers_cnt
> 0) {
17336 vty_out(vty
, " bgp confederation peers");
17338 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17339 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17341 vty_out(vty
, "\n");
17344 /* BGP deterministic-med. */
17345 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17346 != SAVE_BGP_DETERMINISTIC_MED
)
17347 vty_out(vty
, " %sbgp deterministic-med\n",
17348 CHECK_FLAG(bgp
->flags
,
17349 BGP_FLAG_DETERMINISTIC_MED
)
17353 /* BGP update-delay. */
17354 bgp_config_write_update_delay(vty
, bgp
);
17356 if (bgp
->v_maxmed_onstartup
17357 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17358 vty_out(vty
, " bgp max-med on-startup %u",
17359 bgp
->v_maxmed_onstartup
);
17360 if (bgp
->maxmed_onstartup_value
17361 != BGP_MAXMED_VALUE_DEFAULT
)
17362 vty_out(vty
, " %u",
17363 bgp
->maxmed_onstartup_value
);
17364 vty_out(vty
, "\n");
17366 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17367 vty_out(vty
, " bgp max-med administrative");
17368 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17369 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17370 vty_out(vty
, "\n");
17374 bgp_config_write_wpkt_quanta(vty
, bgp
);
17376 bgp_config_write_rpkt_quanta(vty
, bgp
);
17378 /* coalesce time */
17379 bgp_config_write_coalesce_time(vty
, bgp
);
17381 /* BGP per-instance graceful-shutdown */
17382 /* BGP-wide settings and per-instance settings are mutually
17385 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17386 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17387 vty_out(vty
, " bgp graceful-shutdown\n");
17389 /* BGP graceful-restart. */
17390 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17392 " bgp graceful-restart stalepath-time %u\n",
17393 bgp
->stalepath_time
);
17395 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17396 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17397 bgp
->restart_time
);
17399 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17401 " bgp graceful-restart select-defer-time %u\n",
17402 bgp
->select_defer_time
);
17404 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17405 vty_out(vty
, " bgp graceful-restart\n");
17407 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17408 vty_out(vty
, " bgp graceful-restart-disable\n");
17410 /* BGP graceful-restart Preserve State F bit. */
17411 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17413 " bgp graceful-restart preserve-fw-state\n");
17415 /* Stale timer for RIB */
17416 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17418 " bgp graceful-restart rib-stale-time %u\n",
17419 bgp
->rib_stale_time
);
17421 /* BGP bestpath method. */
17422 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17423 vty_out(vty
, " bgp bestpath as-path ignore\n");
17424 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17425 vty_out(vty
, " bgp bestpath as-path confed\n");
17427 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17428 if (CHECK_FLAG(bgp
->flags
,
17429 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17431 " bgp bestpath as-path multipath-relax as-set\n");
17434 " bgp bestpath as-path multipath-relax\n");
17438 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17440 " bgp route-reflector allow-outbound-policy\n");
17442 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17443 vty_out(vty
, " bgp bestpath compare-routerid\n");
17444 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17445 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17446 vty_out(vty
, " bgp bestpath med");
17447 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17448 vty_out(vty
, " confed");
17449 if (CHECK_FLAG(bgp
->flags
,
17450 BGP_FLAG_MED_MISSING_AS_WORST
))
17451 vty_out(vty
, " missing-as-worst");
17452 vty_out(vty
, "\n");
17455 /* Link bandwidth handling. */
17456 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17457 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17458 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17459 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17460 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17461 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17463 /* BGP network import check. */
17464 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17465 != SAVE_BGP_IMPORT_CHECK
)
17466 vty_out(vty
, " %sbgp network import-check\n",
17467 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17471 /* BGP timers configuration. */
17472 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17473 && bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17474 vty_out(vty
, " timers bgp %u %u\n",
17475 bgp
->default_keepalive
, bgp
->default_holdtime
);
17478 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17479 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17482 /* Normal neighbor configuration. */
17483 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17484 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17485 bgp_config_write_peer_global(vty
, bgp
, peer
);
17488 /* listen range and limit for dynamic BGP neighbors */
17489 bgp_config_write_listen(vty
, bgp
);
17492 * BGP default autoshutdown neighbors
17494 * This must be placed after any peer and peer-group
17495 * configuration, to avoid setting all peers to shutdown after
17496 * a daemon restart, which is undesired behavior. (see #2286)
17498 if (bgp
->autoshutdown
)
17499 vty_out(vty
, " bgp default shutdown\n");
17501 /* BGP instance administrative shutdown */
17502 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17503 vty_out(vty
, " bgp shutdown\n");
17505 /* IPv4 unicast configuration. */
17506 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17508 /* IPv4 multicast configuration. */
17509 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17511 /* IPv4 labeled-unicast configuration. */
17512 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17514 /* IPv4 VPN configuration. */
17515 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17517 /* ENCAPv4 configuration. */
17518 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17520 /* FLOWSPEC v4 configuration. */
17521 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17523 /* IPv6 unicast configuration. */
17524 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17526 /* IPv6 multicast configuration. */
17527 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17529 /* IPv6 labeled-unicast configuration. */
17530 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17531 SAFI_LABELED_UNICAST
);
17533 /* IPv6 VPN configuration. */
17534 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17536 /* ENCAPv6 configuration. */
17537 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17539 /* FLOWSPEC v6 configuration. */
17540 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17542 /* EVPN configuration. */
17543 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17545 hook_call(bgp_inst_config_write
, bgp
, vty
);
17547 #ifdef ENABLE_BGP_VNC
17548 bgp_rfapi_cfg_write(vty
, bgp
);
17551 vty_out(vty
, "!\n");
17557 /* BGP node structure. */
17558 static struct cmd_node bgp_node
= {
17561 .parent_node
= CONFIG_NODE
,
17562 .prompt
= "%s(config-router)# ",
17563 .config_write
= bgp_config_write
,
17566 static struct cmd_node bgp_ipv4_unicast_node
= {
17567 .name
= "bgp ipv4 unicast",
17568 .node
= BGP_IPV4_NODE
,
17569 .parent_node
= BGP_NODE
,
17570 .prompt
= "%s(config-router-af)# ",
17573 static struct cmd_node bgp_ipv4_multicast_node
= {
17574 .name
= "bgp ipv4 multicast",
17575 .node
= BGP_IPV4M_NODE
,
17576 .parent_node
= BGP_NODE
,
17577 .prompt
= "%s(config-router-af)# ",
17580 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
17581 .name
= "bgp ipv4 labeled unicast",
17582 .node
= BGP_IPV4L_NODE
,
17583 .parent_node
= BGP_NODE
,
17584 .prompt
= "%s(config-router-af)# ",
17587 static struct cmd_node bgp_ipv6_unicast_node
= {
17588 .name
= "bgp ipv6",
17589 .node
= BGP_IPV6_NODE
,
17590 .parent_node
= BGP_NODE
,
17591 .prompt
= "%s(config-router-af)# ",
17594 static struct cmd_node bgp_ipv6_multicast_node
= {
17595 .name
= "bgp ipv6 multicast",
17596 .node
= BGP_IPV6M_NODE
,
17597 .parent_node
= BGP_NODE
,
17598 .prompt
= "%s(config-router-af)# ",
17601 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
17602 .name
= "bgp ipv6 labeled unicast",
17603 .node
= BGP_IPV6L_NODE
,
17604 .parent_node
= BGP_NODE
,
17605 .prompt
= "%s(config-router-af)# ",
17608 static struct cmd_node bgp_vpnv4_node
= {
17609 .name
= "bgp vpnv4",
17610 .node
= BGP_VPNV4_NODE
,
17611 .parent_node
= BGP_NODE
,
17612 .prompt
= "%s(config-router-af)# ",
17615 static struct cmd_node bgp_vpnv6_node
= {
17616 .name
= "bgp vpnv6",
17617 .node
= BGP_VPNV6_NODE
,
17618 .parent_node
= BGP_NODE
,
17619 .prompt
= "%s(config-router-af-vpnv6)# ",
17622 static struct cmd_node bgp_evpn_node
= {
17623 .name
= "bgp evpn",
17624 .node
= BGP_EVPN_NODE
,
17625 .parent_node
= BGP_NODE
,
17626 .prompt
= "%s(config-router-evpn)# ",
17629 static struct cmd_node bgp_evpn_vni_node
= {
17630 .name
= "bgp evpn vni",
17631 .node
= BGP_EVPN_VNI_NODE
,
17632 .parent_node
= BGP_EVPN_NODE
,
17633 .prompt
= "%s(config-router-af-vni)# ",
17636 static struct cmd_node bgp_flowspecv4_node
= {
17637 .name
= "bgp ipv4 flowspec",
17638 .node
= BGP_FLOWSPECV4_NODE
,
17639 .parent_node
= BGP_NODE
,
17640 .prompt
= "%s(config-router-af)# ",
17643 static struct cmd_node bgp_flowspecv6_node
= {
17644 .name
= "bgp ipv6 flowspec",
17645 .node
= BGP_FLOWSPECV6_NODE
,
17646 .parent_node
= BGP_NODE
,
17647 .prompt
= "%s(config-router-af-vpnv6)# ",
17650 static void community_list_vty(void);
17652 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
17656 struct listnode
*lnbgp
, *lnpeer
;
17658 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17659 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
17660 /* only provide suggestions on the appropriate input
17662 * they'll otherwise show up multiple times */
17663 enum cmd_token_type match_type
;
17664 char *name
= peer
->host
;
17666 if (peer
->conf_if
) {
17667 match_type
= VARIABLE_TKN
;
17668 name
= peer
->conf_if
;
17669 } else if (strchr(peer
->host
, ':'))
17670 match_type
= IPV6_TKN
;
17672 match_type
= IPV4_TKN
;
17674 if (token
->type
!= match_type
)
17677 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
17682 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
17683 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
17684 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
17685 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
17686 {.completions
= NULL
}};
17688 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
17691 struct peer_group
*group
;
17692 struct listnode
*lnbgp
, *lnpeer
;
17694 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17695 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
17696 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
17701 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
17702 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
17703 {.completions
= NULL
} };
17705 void bgp_vty_init(void)
17707 cmd_variable_handler_register(bgp_var_neighbor
);
17708 cmd_variable_handler_register(bgp_var_peergroup
);
17710 /* Install bgp top node. */
17711 install_node(&bgp_node
);
17712 install_node(&bgp_ipv4_unicast_node
);
17713 install_node(&bgp_ipv4_multicast_node
);
17714 install_node(&bgp_ipv4_labeled_unicast_node
);
17715 install_node(&bgp_ipv6_unicast_node
);
17716 install_node(&bgp_ipv6_multicast_node
);
17717 install_node(&bgp_ipv6_labeled_unicast_node
);
17718 install_node(&bgp_vpnv4_node
);
17719 install_node(&bgp_vpnv6_node
);
17720 install_node(&bgp_evpn_node
);
17721 install_node(&bgp_evpn_vni_node
);
17722 install_node(&bgp_flowspecv4_node
);
17723 install_node(&bgp_flowspecv6_node
);
17725 /* Install default VTY commands to new nodes. */
17726 install_default(BGP_NODE
);
17727 install_default(BGP_IPV4_NODE
);
17728 install_default(BGP_IPV4M_NODE
);
17729 install_default(BGP_IPV4L_NODE
);
17730 install_default(BGP_IPV6_NODE
);
17731 install_default(BGP_IPV6M_NODE
);
17732 install_default(BGP_IPV6L_NODE
);
17733 install_default(BGP_VPNV4_NODE
);
17734 install_default(BGP_VPNV6_NODE
);
17735 install_default(BGP_FLOWSPECV4_NODE
);
17736 install_default(BGP_FLOWSPECV6_NODE
);
17737 install_default(BGP_EVPN_NODE
);
17738 install_default(BGP_EVPN_VNI_NODE
);
17740 /* "bgp local-mac" hidden commands. */
17741 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
17742 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
17744 /* "bgp suppress-fib-pending" global */
17745 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
17747 /* bgp route-map delay-timer commands. */
17748 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17749 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17751 /* global bgp update-delay command */
17752 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
17753 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
17755 /* global bgp graceful-shutdown command */
17756 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
17757 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
17759 /* Dummy commands (Currently not supported) */
17760 install_element(BGP_NODE
, &no_synchronization_cmd
);
17761 install_element(BGP_NODE
, &no_auto_summary_cmd
);
17763 /* "router bgp" commands. */
17764 install_element(CONFIG_NODE
, &router_bgp_cmd
);
17766 /* "no router bgp" commands. */
17767 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
17769 /* "bgp router-id" commands. */
17770 install_element(BGP_NODE
, &bgp_router_id_cmd
);
17771 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
17773 /* "bgp suppress-fib-pending" command */
17774 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
17776 /* "bgp cluster-id" commands. */
17777 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
17778 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
17780 /* "bgp no-rib" commands. */
17781 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
17782 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
17784 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
17786 /* "bgp confederation" commands. */
17787 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
17788 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
17790 /* "bgp confederation peers" commands. */
17791 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
17792 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
17794 /* bgp max-med command */
17795 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
17796 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
17797 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
17798 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
17799 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
17801 /* bgp disable-ebgp-connected-nh-check */
17802 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
17803 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
17805 /* bgp update-delay command */
17806 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
17807 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
17809 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
17810 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
17812 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
17813 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
17815 /* "maximum-paths" commands. */
17816 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
17817 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
17818 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
17819 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
17820 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
17821 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
17822 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
17823 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
17824 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
17825 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
17826 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17827 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17828 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
17829 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17830 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17832 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
17833 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
17834 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17835 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17836 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17837 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
17838 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
17839 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17840 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17841 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17843 /* "timers bgp" commands. */
17844 install_element(BGP_NODE
, &bgp_timers_cmd
);
17845 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
17847 /* route-map delay-timer commands - per instance for backwards compat.
17849 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17850 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17852 /* "bgp client-to-client reflection" commands */
17853 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
17854 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
17856 /* "bgp always-compare-med" commands */
17857 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
17858 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
17860 /* bgp ebgp-requires-policy */
17861 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
17862 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
17864 /* bgp suppress-duplicates */
17865 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
17866 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
17868 /* bgp reject-as-sets */
17869 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
17870 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
17872 /* "bgp deterministic-med" commands */
17873 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
17874 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
17876 /* "bgp graceful-restart" command */
17877 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
17878 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
17880 /* "bgp graceful-restart-disable" command */
17881 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
17882 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
17884 /* "neighbor a:b:c:d graceful-restart" command */
17885 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
17886 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
17888 /* "neighbor a:b:c:d graceful-restart-disable" command */
17889 install_element(BGP_NODE
,
17890 &bgp_neighbor_graceful_restart_disable_set_cmd
);
17891 install_element(BGP_NODE
,
17892 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
17894 /* "neighbor a:b:c:d graceful-restart-helper" command */
17895 install_element(BGP_NODE
,
17896 &bgp_neighbor_graceful_restart_helper_set_cmd
);
17897 install_element(BGP_NODE
,
17898 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
17900 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
17901 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
17902 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
17903 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
17904 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
17905 install_element(BGP_NODE
,
17906 &no_bgp_graceful_restart_select_defer_time_cmd
);
17907 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
17908 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
17910 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
17911 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
17912 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
17913 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
17915 /* "bgp graceful-shutdown" commands */
17916 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
17917 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
17919 /* "bgp fast-external-failover" commands */
17920 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
17921 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
17923 /* "bgp bestpath compare-routerid" commands */
17924 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
17925 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
17927 /* "bgp bestpath as-path ignore" commands */
17928 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
17929 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
17931 /* "bgp bestpath as-path confed" commands */
17932 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
17933 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
17935 /* "bgp bestpath as-path multipath-relax" commands */
17936 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
17937 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
17939 /* "bgp log-neighbor-changes" commands */
17940 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
17941 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
17943 /* "bgp bestpath med" commands */
17944 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
17945 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
17947 /* "bgp bestpath bandwidth" commands */
17948 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
17949 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
17951 /* "no bgp default ipv4-unicast" commands. */
17952 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
17953 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
17955 /* "bgp network import-check" commands. */
17956 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
17957 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
17958 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
17960 /* "bgp default local-preference" commands. */
17961 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
17962 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
17964 /* bgp default show-hostname */
17965 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
17966 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
17968 /* bgp default show-nexthop-hostname */
17969 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
17970 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
17972 /* "bgp default subgroup-pkt-queue-max" commands. */
17973 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
17974 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
17976 /* bgp ibgp-allow-policy-mods command */
17977 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
17978 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
17980 /* "bgp listen limit" commands. */
17981 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
17982 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
17984 /* "bgp listen range" commands. */
17985 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
17986 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
17988 /* "bgp default shutdown" command */
17989 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
17991 /* "bgp shutdown" commands */
17992 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
17993 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
17994 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
17995 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
17997 /* "neighbor remote-as" commands. */
17998 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
17999 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
18000 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
18001 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
18002 install_element(BGP_NODE
,
18003 &neighbor_interface_v6only_config_remote_as_cmd
);
18004 install_element(BGP_NODE
, &no_neighbor_cmd
);
18005 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
18007 /* "neighbor peer-group" commands. */
18008 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
18009 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
18010 install_element(BGP_NODE
,
18011 &no_neighbor_interface_peer_group_remote_as_cmd
);
18013 /* "neighbor local-as" commands. */
18014 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
18015 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
18016 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
18017 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
18019 /* "neighbor solo" commands. */
18020 install_element(BGP_NODE
, &neighbor_solo_cmd
);
18021 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
18023 /* "neighbor password" commands. */
18024 install_element(BGP_NODE
, &neighbor_password_cmd
);
18025 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
18027 /* "neighbor activate" commands. */
18028 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
18029 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
18030 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
18031 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
18032 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
18033 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
18034 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
18035 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
18036 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
18037 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
18038 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
18039 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
18041 /* "no neighbor activate" commands. */
18042 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
18043 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
18044 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
18045 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
18046 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
18047 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
18048 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
18049 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
18050 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
18051 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
18052 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
18053 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
18055 /* "neighbor peer-group" set commands. */
18056 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
18057 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18058 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18059 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18060 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18061 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18062 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18063 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18064 install_element(BGP_FLOWSPECV4_NODE
,
18065 &neighbor_set_peer_group_hidden_cmd
);
18066 install_element(BGP_FLOWSPECV6_NODE
,
18067 &neighbor_set_peer_group_hidden_cmd
);
18069 /* "no neighbor peer-group unset" commands. */
18070 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
18071 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18072 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18073 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18074 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18075 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18076 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18077 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18078 install_element(BGP_FLOWSPECV4_NODE
,
18079 &no_neighbor_set_peer_group_hidden_cmd
);
18080 install_element(BGP_FLOWSPECV6_NODE
,
18081 &no_neighbor_set_peer_group_hidden_cmd
);
18083 /* "neighbor softreconfiguration inbound" commands.*/
18084 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
18085 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
18086 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18087 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18088 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18089 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18090 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18091 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18092 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18093 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18094 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18095 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18096 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18097 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18098 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18099 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18100 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18101 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18102 install_element(BGP_FLOWSPECV4_NODE
,
18103 &neighbor_soft_reconfiguration_cmd
);
18104 install_element(BGP_FLOWSPECV4_NODE
,
18105 &no_neighbor_soft_reconfiguration_cmd
);
18106 install_element(BGP_FLOWSPECV6_NODE
,
18107 &neighbor_soft_reconfiguration_cmd
);
18108 install_element(BGP_FLOWSPECV6_NODE
,
18109 &no_neighbor_soft_reconfiguration_cmd
);
18110 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
18111 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18113 /* "neighbor attribute-unchanged" commands. */
18114 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
18115 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
18116 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
18117 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18118 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
18119 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18120 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
18121 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18122 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
18123 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18124 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
18125 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18126 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
18127 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18128 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
18129 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18130 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
18131 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18133 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
18134 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
18136 /* "nexthop-local unchanged" commands */
18137 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
18138 install_element(BGP_IPV6_NODE
,
18139 &no_neighbor_nexthop_local_unchanged_cmd
);
18141 /* "neighbor next-hop-self" commands. */
18142 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
18143 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
18144 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
18145 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18146 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
18147 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
18148 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
18149 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
18150 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
18151 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18152 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
18153 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
18154 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
18155 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
18156 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
18157 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18158 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
18159 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18160 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
18161 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
18163 /* "neighbor next-hop-self force" commands. */
18164 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
18165 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
18166 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18167 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
18168 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18169 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18170 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18171 install_element(BGP_IPV4_NODE
,
18172 &no_neighbor_nexthop_self_all_hidden_cmd
);
18173 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
18174 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18175 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18176 install_element(BGP_IPV4M_NODE
,
18177 &no_neighbor_nexthop_self_all_hidden_cmd
);
18178 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
18179 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18180 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18181 install_element(BGP_IPV4L_NODE
,
18182 &no_neighbor_nexthop_self_all_hidden_cmd
);
18183 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18184 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18185 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18186 install_element(BGP_IPV6_NODE
,
18187 &no_neighbor_nexthop_self_all_hidden_cmd
);
18188 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
18189 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18190 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18191 install_element(BGP_IPV6M_NODE
,
18192 &no_neighbor_nexthop_self_all_hidden_cmd
);
18193 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
18194 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18195 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18196 install_element(BGP_IPV6L_NODE
,
18197 &no_neighbor_nexthop_self_all_hidden_cmd
);
18198 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18199 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18200 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18201 install_element(BGP_VPNV4_NODE
,
18202 &no_neighbor_nexthop_self_all_hidden_cmd
);
18203 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18204 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18205 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18206 install_element(BGP_VPNV6_NODE
,
18207 &no_neighbor_nexthop_self_all_hidden_cmd
);
18208 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
18209 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18211 /* "neighbor as-override" commands. */
18212 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
18213 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
18214 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
18215 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
18216 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
18217 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
18218 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
18219 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
18220 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
18221 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
18222 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
18223 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
18224 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
18225 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
18226 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
18227 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
18228 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
18229 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
18231 /* "neighbor remove-private-AS" commands. */
18232 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
18233 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
18234 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
18235 install_element(BGP_NODE
,
18236 &no_neighbor_remove_private_as_all_hidden_cmd
);
18237 install_element(BGP_NODE
,
18238 &neighbor_remove_private_as_replace_as_hidden_cmd
);
18239 install_element(BGP_NODE
,
18240 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
18241 install_element(BGP_NODE
,
18242 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18245 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18246 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
18247 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18248 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18249 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18250 install_element(BGP_IPV4_NODE
,
18251 &neighbor_remove_private_as_replace_as_cmd
);
18252 install_element(BGP_IPV4_NODE
,
18253 &no_neighbor_remove_private_as_replace_as_cmd
);
18254 install_element(BGP_IPV4_NODE
,
18255 &neighbor_remove_private_as_all_replace_as_cmd
);
18256 install_element(BGP_IPV4_NODE
,
18257 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18258 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
18259 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
18260 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
18261 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18262 install_element(BGP_IPV4M_NODE
,
18263 &neighbor_remove_private_as_replace_as_cmd
);
18264 install_element(BGP_IPV4M_NODE
,
18265 &no_neighbor_remove_private_as_replace_as_cmd
);
18266 install_element(BGP_IPV4M_NODE
,
18267 &neighbor_remove_private_as_all_replace_as_cmd
);
18268 install_element(BGP_IPV4M_NODE
,
18269 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18270 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
18271 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
18272 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
18273 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18274 install_element(BGP_IPV4L_NODE
,
18275 &neighbor_remove_private_as_replace_as_cmd
);
18276 install_element(BGP_IPV4L_NODE
,
18277 &no_neighbor_remove_private_as_replace_as_cmd
);
18278 install_element(BGP_IPV4L_NODE
,
18279 &neighbor_remove_private_as_all_replace_as_cmd
);
18280 install_element(BGP_IPV4L_NODE
,
18281 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18282 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
18283 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18284 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18285 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18286 install_element(BGP_IPV6_NODE
,
18287 &neighbor_remove_private_as_replace_as_cmd
);
18288 install_element(BGP_IPV6_NODE
,
18289 &no_neighbor_remove_private_as_replace_as_cmd
);
18290 install_element(BGP_IPV6_NODE
,
18291 &neighbor_remove_private_as_all_replace_as_cmd
);
18292 install_element(BGP_IPV6_NODE
,
18293 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18294 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
18295 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
18296 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
18297 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18298 install_element(BGP_IPV6M_NODE
,
18299 &neighbor_remove_private_as_replace_as_cmd
);
18300 install_element(BGP_IPV6M_NODE
,
18301 &no_neighbor_remove_private_as_replace_as_cmd
);
18302 install_element(BGP_IPV6M_NODE
,
18303 &neighbor_remove_private_as_all_replace_as_cmd
);
18304 install_element(BGP_IPV6M_NODE
,
18305 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18306 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
18307 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
18308 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
18309 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18310 install_element(BGP_IPV6L_NODE
,
18311 &neighbor_remove_private_as_replace_as_cmd
);
18312 install_element(BGP_IPV6L_NODE
,
18313 &no_neighbor_remove_private_as_replace_as_cmd
);
18314 install_element(BGP_IPV6L_NODE
,
18315 &neighbor_remove_private_as_all_replace_as_cmd
);
18316 install_element(BGP_IPV6L_NODE
,
18317 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18318 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
18319 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18320 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18321 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18322 install_element(BGP_VPNV4_NODE
,
18323 &neighbor_remove_private_as_replace_as_cmd
);
18324 install_element(BGP_VPNV4_NODE
,
18325 &no_neighbor_remove_private_as_replace_as_cmd
);
18326 install_element(BGP_VPNV4_NODE
,
18327 &neighbor_remove_private_as_all_replace_as_cmd
);
18328 install_element(BGP_VPNV4_NODE
,
18329 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18330 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
18331 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18332 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18333 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18334 install_element(BGP_VPNV6_NODE
,
18335 &neighbor_remove_private_as_replace_as_cmd
);
18336 install_element(BGP_VPNV6_NODE
,
18337 &no_neighbor_remove_private_as_replace_as_cmd
);
18338 install_element(BGP_VPNV6_NODE
,
18339 &neighbor_remove_private_as_all_replace_as_cmd
);
18340 install_element(BGP_VPNV6_NODE
,
18341 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18343 /* "neighbor send-community" commands.*/
18344 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
18345 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
18346 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
18347 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
18348 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
18349 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
18350 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
18351 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
18352 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
18353 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
18354 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
18355 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
18356 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
18357 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
18358 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
18359 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
18360 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
18361 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
18362 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
18363 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
18364 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
18365 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
18366 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
18367 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
18368 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
18369 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
18370 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
18371 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
18372 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
18373 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
18374 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
18375 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
18376 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
18377 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
18378 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
18379 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
18381 /* "neighbor route-reflector" commands.*/
18382 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
18383 install_element(BGP_NODE
,
18384 &no_neighbor_route_reflector_client_hidden_cmd
);
18385 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
18386 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
18387 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
18388 install_element(BGP_IPV4M_NODE
,
18389 &no_neighbor_route_reflector_client_cmd
);
18390 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
18391 install_element(BGP_IPV4L_NODE
,
18392 &no_neighbor_route_reflector_client_cmd
);
18393 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
18394 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
18395 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
18396 install_element(BGP_IPV6M_NODE
,
18397 &no_neighbor_route_reflector_client_cmd
);
18398 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
18399 install_element(BGP_IPV6L_NODE
,
18400 &no_neighbor_route_reflector_client_cmd
);
18401 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
18402 install_element(BGP_VPNV4_NODE
,
18403 &no_neighbor_route_reflector_client_cmd
);
18404 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
18405 install_element(BGP_VPNV6_NODE
,
18406 &no_neighbor_route_reflector_client_cmd
);
18407 install_element(BGP_FLOWSPECV4_NODE
,
18408 &neighbor_route_reflector_client_cmd
);
18409 install_element(BGP_FLOWSPECV4_NODE
,
18410 &no_neighbor_route_reflector_client_cmd
);
18411 install_element(BGP_FLOWSPECV6_NODE
,
18412 &neighbor_route_reflector_client_cmd
);
18413 install_element(BGP_FLOWSPECV6_NODE
,
18414 &no_neighbor_route_reflector_client_cmd
);
18415 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
18416 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
18418 /* "neighbor route-server" commands.*/
18419 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
18420 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
18421 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
18422 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
18423 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
18424 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
18425 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
18426 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
18427 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
18428 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
18429 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
18430 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
18431 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
18432 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
18433 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
18434 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
18435 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
18436 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
18437 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
18438 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
18439 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
18440 install_element(BGP_FLOWSPECV4_NODE
,
18441 &no_neighbor_route_server_client_cmd
);
18442 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
18443 install_element(BGP_FLOWSPECV6_NODE
,
18444 &no_neighbor_route_server_client_cmd
);
18446 /* "neighbor addpath-tx-all-paths" commands.*/
18447 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
18448 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
18449 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18450 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18451 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18452 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18453 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18454 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18455 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18456 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18457 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18458 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18459 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18460 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18461 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18462 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18463 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18464 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18466 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
18467 install_element(BGP_NODE
,
18468 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18469 install_element(BGP_NODE
,
18470 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18471 install_element(BGP_IPV4_NODE
,
18472 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18473 install_element(BGP_IPV4_NODE
,
18474 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18475 install_element(BGP_IPV4M_NODE
,
18476 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18477 install_element(BGP_IPV4M_NODE
,
18478 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18479 install_element(BGP_IPV4L_NODE
,
18480 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18481 install_element(BGP_IPV4L_NODE
,
18482 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18483 install_element(BGP_IPV6_NODE
,
18484 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18485 install_element(BGP_IPV6_NODE
,
18486 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18487 install_element(BGP_IPV6M_NODE
,
18488 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18489 install_element(BGP_IPV6M_NODE
,
18490 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18491 install_element(BGP_IPV6L_NODE
,
18492 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18493 install_element(BGP_IPV6L_NODE
,
18494 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18495 install_element(BGP_VPNV4_NODE
,
18496 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18497 install_element(BGP_VPNV4_NODE
,
18498 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18499 install_element(BGP_VPNV6_NODE
,
18500 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18501 install_element(BGP_VPNV6_NODE
,
18502 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18504 /* "neighbor sender-as-path-loop-detection" commands. */
18505 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
18506 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
18508 /* "neighbor passive" commands. */
18509 install_element(BGP_NODE
, &neighbor_passive_cmd
);
18510 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
18513 /* "neighbor shutdown" commands. */
18514 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
18515 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
18516 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
18517 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
18518 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
18519 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
18521 /* "neighbor capability extended-nexthop" commands.*/
18522 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
18523 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
18525 /* "neighbor capability orf prefix-list" commands.*/
18526 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
18527 install_element(BGP_NODE
,
18528 &no_neighbor_capability_orf_prefix_hidden_cmd
);
18529 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
18530 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18531 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18532 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18533 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18534 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18535 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
18536 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18537 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18538 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18539 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18540 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18542 /* "neighbor capability dynamic" commands.*/
18543 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
18544 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
18546 /* "neighbor dont-capability-negotiate" commands. */
18547 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
18548 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
18550 /* "neighbor ebgp-multihop" commands. */
18551 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
18552 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
18553 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
18555 /* "neighbor disable-connected-check" commands. */
18556 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
18557 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
18559 /* "neighbor enforce-first-as" commands. */
18560 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
18561 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
18563 /* "neighbor description" commands. */
18564 install_element(BGP_NODE
, &neighbor_description_cmd
);
18565 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
18566 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
18568 /* "neighbor update-source" commands. "*/
18569 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
18570 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
18572 /* "neighbor default-originate" commands. */
18573 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
18574 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
18575 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
18576 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
18577 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
18578 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
18579 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
18580 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
18581 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
18582 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
18583 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
18584 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
18585 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
18586 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
18587 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
18588 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
18589 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
18590 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
18591 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
18592 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
18593 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
18595 /* "neighbor port" commands. */
18596 install_element(BGP_NODE
, &neighbor_port_cmd
);
18597 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
18599 /* "neighbor weight" commands. */
18600 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
18601 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
18603 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
18604 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
18605 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
18606 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
18607 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
18608 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
18609 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
18610 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
18611 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
18612 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
18613 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
18614 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
18615 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
18616 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
18617 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
18618 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
18620 /* "neighbor override-capability" commands. */
18621 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
18622 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
18624 /* "neighbor strict-capability-match" commands. */
18625 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
18626 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
18628 /* "neighbor timers" commands. */
18629 install_element(BGP_NODE
, &neighbor_timers_cmd
);
18630 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
18632 /* "neighbor timers connect" commands. */
18633 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
18634 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
18636 /* "neighbor timers delayopen" commands. */
18637 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
18638 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
18640 /* "neighbor advertisement-interval" commands. */
18641 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
18642 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
18644 /* "neighbor interface" commands. */
18645 install_element(BGP_NODE
, &neighbor_interface_cmd
);
18646 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
18648 /* "neighbor distribute" commands. */
18649 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
18650 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
18651 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
18652 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
18653 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
18654 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
18655 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
18656 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
18657 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
18658 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
18659 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
18660 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
18661 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
18662 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
18663 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
18664 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
18665 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
18666 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
18668 /* "neighbor prefix-list" commands. */
18669 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
18670 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
18671 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
18672 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
18673 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
18674 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
18675 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
18676 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
18677 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
18678 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
18679 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
18680 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
18681 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
18682 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
18683 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
18684 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
18685 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
18686 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
18687 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
18688 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
18689 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
18690 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
18692 /* "neighbor filter-list" commands. */
18693 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
18694 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
18695 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
18696 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
18697 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
18698 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
18699 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
18700 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
18701 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
18702 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
18703 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
18704 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
18705 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
18706 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
18707 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
18708 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
18709 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
18710 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
18711 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
18712 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
18713 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
18714 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
18716 /* "neighbor route-map" commands. */
18717 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
18718 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
18719 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
18720 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
18721 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
18722 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
18723 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
18724 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
18725 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
18726 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
18727 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
18728 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
18729 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
18730 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
18731 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
18732 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
18733 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
18734 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
18735 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
18736 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
18737 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
18738 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
18739 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
18740 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
18742 /* "neighbor unsuppress-map" commands. */
18743 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
18744 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
18745 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
18746 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18747 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
18748 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18749 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
18750 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18751 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
18752 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18753 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
18754 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18755 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
18756 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18757 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
18758 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18759 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
18760 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18762 /* "neighbor advertise-map" commands. */
18763 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
18764 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
18765 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
18766 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
18767 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
18768 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
18769 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
18770 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
18771 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
18773 /* neighbor maximum-prefix-out commands. */
18774 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
18775 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18776 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18777 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18778 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18779 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18780 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18781 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18782 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18783 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18784 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18785 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18786 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18787 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18788 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18789 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18790 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18791 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18793 /* "neighbor maximum-prefix" commands. */
18794 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
18795 install_element(BGP_NODE
,
18796 &neighbor_maximum_prefix_threshold_hidden_cmd
);
18797 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
18798 install_element(BGP_NODE
,
18799 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
18800 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
18801 install_element(BGP_NODE
,
18802 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
18803 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
18804 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
18805 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18806 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18807 install_element(BGP_IPV4_NODE
,
18808 &neighbor_maximum_prefix_threshold_warning_cmd
);
18809 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18810 install_element(BGP_IPV4_NODE
,
18811 &neighbor_maximum_prefix_threshold_restart_cmd
);
18812 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18813 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
18814 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18815 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18816 install_element(BGP_IPV4M_NODE
,
18817 &neighbor_maximum_prefix_threshold_warning_cmd
);
18818 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18819 install_element(BGP_IPV4M_NODE
,
18820 &neighbor_maximum_prefix_threshold_restart_cmd
);
18821 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18822 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
18823 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18824 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18825 install_element(BGP_IPV4L_NODE
,
18826 &neighbor_maximum_prefix_threshold_warning_cmd
);
18827 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18828 install_element(BGP_IPV4L_NODE
,
18829 &neighbor_maximum_prefix_threshold_restart_cmd
);
18830 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18831 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
18832 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18833 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18834 install_element(BGP_IPV6_NODE
,
18835 &neighbor_maximum_prefix_threshold_warning_cmd
);
18836 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18837 install_element(BGP_IPV6_NODE
,
18838 &neighbor_maximum_prefix_threshold_restart_cmd
);
18839 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18840 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
18841 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18842 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18843 install_element(BGP_IPV6M_NODE
,
18844 &neighbor_maximum_prefix_threshold_warning_cmd
);
18845 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18846 install_element(BGP_IPV6M_NODE
,
18847 &neighbor_maximum_prefix_threshold_restart_cmd
);
18848 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18849 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
18850 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18851 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18852 install_element(BGP_IPV6L_NODE
,
18853 &neighbor_maximum_prefix_threshold_warning_cmd
);
18854 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18855 install_element(BGP_IPV6L_NODE
,
18856 &neighbor_maximum_prefix_threshold_restart_cmd
);
18857 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18858 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
18859 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18860 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18861 install_element(BGP_VPNV4_NODE
,
18862 &neighbor_maximum_prefix_threshold_warning_cmd
);
18863 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18864 install_element(BGP_VPNV4_NODE
,
18865 &neighbor_maximum_prefix_threshold_restart_cmd
);
18866 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18867 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
18868 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18869 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18870 install_element(BGP_VPNV6_NODE
,
18871 &neighbor_maximum_prefix_threshold_warning_cmd
);
18872 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18873 install_element(BGP_VPNV6_NODE
,
18874 &neighbor_maximum_prefix_threshold_restart_cmd
);
18875 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18877 /* "neighbor allowas-in" */
18878 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
18879 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
18880 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
18881 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
18882 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
18883 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
18884 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
18885 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
18886 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
18887 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
18888 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
18889 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
18890 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
18891 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
18892 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
18893 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
18894 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
18895 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
18896 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
18897 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
18899 /* "neighbor dampening" commands. */
18900 install_element(BGP_NODE
, &neighbor_damp_cmd
);
18901 install_element(BGP_NODE
, &no_neighbor_damp_cmd
);
18902 install_element(BGP_IPV4_NODE
, &neighbor_damp_cmd
);
18903 install_element(BGP_IPV4_NODE
, &no_neighbor_damp_cmd
);
18904 install_element(BGP_IPV4M_NODE
, &neighbor_damp_cmd
);
18905 install_element(BGP_IPV4M_NODE
, &no_neighbor_damp_cmd
);
18906 install_element(BGP_IPV4L_NODE
, &neighbor_damp_cmd
);
18907 install_element(BGP_IPV4L_NODE
, &no_neighbor_damp_cmd
);
18908 install_element(BGP_IPV6_NODE
, &neighbor_damp_cmd
);
18909 install_element(BGP_IPV6_NODE
, &no_neighbor_damp_cmd
);
18910 install_element(BGP_IPV6M_NODE
, &neighbor_damp_cmd
);
18911 install_element(BGP_IPV6M_NODE
, &no_neighbor_damp_cmd
);
18912 install_element(BGP_IPV6L_NODE
, &neighbor_damp_cmd
);
18913 install_element(BGP_IPV6L_NODE
, &no_neighbor_damp_cmd
);
18914 install_element(VIEW_NODE
, &show_ip_bgp_neighbor_damp_param_cmd
);
18916 /* address-family commands. */
18917 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
18918 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
18919 #ifdef KEEP_OLD_VPN_COMMANDS
18920 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
18921 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
18922 #endif /* KEEP_OLD_VPN_COMMANDS */
18924 install_element(BGP_NODE
, &address_family_evpn_cmd
);
18926 /* "exit-address-family" command. */
18927 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
18928 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
18929 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
18930 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
18931 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
18932 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
18933 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
18934 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
18935 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
18936 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
18937 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
18939 /* "clear ip bgp commands" */
18940 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
18942 /* clear ip bgp prefix */
18943 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
18944 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
18945 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
18947 /* "show [ip] bgp summary" commands. */
18948 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
18949 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
18950 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
18951 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
18952 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
18953 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
18954 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
18956 /* "show [ip] bgp neighbors" commands. */
18957 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
18959 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
18961 /* "show [ip] bgp peer-group" commands. */
18962 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
18964 /* "show [ip] bgp paths" commands. */
18965 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
18967 /* "show [ip] bgp community" commands. */
18968 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
18970 /* "show ip bgp large-community" commands. */
18971 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
18972 /* "show [ip] bgp attribute-info" commands. */
18973 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
18974 /* "show [ip] bgp route-leak" command */
18975 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
18977 /* "redistribute" commands. */
18978 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
18979 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
18980 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
18981 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
18982 install_element(BGP_NODE
,
18983 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
18984 install_element(BGP_NODE
,
18985 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
18986 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
18987 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
18988 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
18989 install_element(BGP_NODE
,
18990 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
18991 install_element(BGP_NODE
,
18992 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
18993 install_element(BGP_NODE
,
18994 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
18995 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
18996 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
18997 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
18998 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
18999 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
19000 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
19001 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
19002 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
19003 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
19004 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
19005 install_element(BGP_IPV4_NODE
,
19006 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
19007 install_element(BGP_IPV4_NODE
,
19008 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
19009 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
19010 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
19011 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
19012 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
19013 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
19014 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
19016 /* import|export vpn [route-map WORD] */
19017 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
19018 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
19020 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
19021 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
19023 /* ttl_security commands */
19024 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
19025 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
19027 /* "show [ip] bgp memory" commands. */
19028 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
19030 /* "show bgp martian next-hop" */
19031 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
19033 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
19035 /* "show [ip] bgp views" commands. */
19036 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
19038 /* "show [ip] bgp vrfs" commands. */
19039 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
19041 /* Community-list. */
19042 community_list_vty();
19044 /* vpn-policy commands */
19045 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
19046 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
19047 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
19048 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
19049 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
19050 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
19051 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
19052 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
19053 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
19054 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
19055 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
19056 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
19058 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
19059 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
19061 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
19062 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
19063 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
19064 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
19065 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
19066 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
19067 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19068 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19069 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
19070 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
19073 #include "memory.h"
19074 #include "bgp_regex.h"
19075 #include "bgp_clist.h"
19076 #include "bgp_ecommunity.h"
19078 /* VTY functions. */
19080 /* Direction value to string conversion. */
19081 static const char *community_direct_str(int direct
)
19084 case COMMUNITY_DENY
:
19086 case COMMUNITY_PERMIT
:
19093 /* Display error string. */
19094 static void community_list_perror(struct vty
*vty
, int ret
)
19097 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
19098 vty_out(vty
, "%% Can't find community-list\n");
19100 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
19101 vty_out(vty
, "%% Malformed community-list value\n");
19103 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
19105 "%% Community name conflict, previously defined as standard community\n");
19107 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
19109 "%% Community name conflict, previously defined as expanded community\n");
19114 /* "community-list" keyword help string. */
19115 #define COMMUNITY_LIST_STR "Add a community list entry\n"
19117 /*community-list standard */
19118 DEFUN (community_list_standard
,
19119 bgp_community_list_standard_cmd
,
19120 "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19123 "Community list number (standard)\n"
19124 "Add an standard community-list entry\n"
19125 "Community list name\n"
19126 "Sequence number of an entry\n"
19127 "Sequence number\n"
19128 "Specify community to reject\n"
19129 "Specify community to accept\n"
19132 char *cl_name_or_number
= NULL
;
19135 int style
= COMMUNITY_LIST_STANDARD
;
19138 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
19140 seq
= argv
[idx
]->arg
;
19143 argv_find(argv
, argc
, "(1-99)", &idx
);
19144 argv_find(argv
, argc
, "WORD", &idx
);
19145 cl_name_or_number
= argv
[idx
]->arg
;
19146 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19148 argv_find(argv
, argc
, "AA:NN", &idx
);
19149 char *str
= argv_concat(argv
, argc
, idx
);
19151 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19154 XFREE(MTYPE_TMP
, str
);
19157 /* Display error string. */
19158 community_list_perror(vty
, ret
);
19159 return CMD_WARNING_CONFIG_FAILED
;
19162 return CMD_SUCCESS
;
19165 DEFUN (no_community_list_standard_all
,
19166 no_bgp_community_list_standard_all_cmd
,
19167 "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19171 "Community list number (standard)\n"
19172 "Add an standard community-list entry\n"
19173 "Community list name\n"
19174 "Sequence number of an entry\n"
19175 "Sequence number\n"
19176 "Specify community to reject\n"
19177 "Specify community to accept\n"
19180 char *cl_name_or_number
= NULL
;
19183 int style
= COMMUNITY_LIST_STANDARD
;
19187 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
19189 seq
= argv
[idx
]->arg
;
19192 argv_find(argv
, argc
, "permit", &idx
);
19193 argv_find(argv
, argc
, "deny", &idx
);
19196 direct
= argv_find(argv
, argc
, "permit", &idx
)
19201 argv_find(argv
, argc
, "AA:NN", &idx
);
19202 str
= argv_concat(argv
, argc
, idx
);
19206 argv_find(argv
, argc
, "(1-99)", &idx
);
19207 argv_find(argv
, argc
, "WORD", &idx
);
19208 cl_name_or_number
= argv
[idx
]->arg
;
19210 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19213 XFREE(MTYPE_TMP
, str
);
19216 community_list_perror(vty
, ret
);
19217 return CMD_WARNING_CONFIG_FAILED
;
19220 return CMD_SUCCESS
;
19223 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
19224 "no bgp community-list <(1-99)|standard WORD>",
19225 NO_STR BGP_STR COMMUNITY_LIST_STR
19226 "Community list number (standard)\n"
19227 "Add an standard community-list entry\n"
19228 "Community list name\n")
19230 /*community-list expanded */
19231 DEFUN (community_list_expanded_all
,
19232 bgp_community_list_expanded_all_cmd
,
19233 "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19236 "Community list number (expanded)\n"
19237 "Add an expanded community-list entry\n"
19238 "Community list name\n"
19239 "Sequence number of an entry\n"
19240 "Sequence number\n"
19241 "Specify community to reject\n"
19242 "Specify community to accept\n"
19245 char *cl_name_or_number
= NULL
;
19248 int style
= COMMUNITY_LIST_EXPANDED
;
19251 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
19253 seq
= argv
[idx
]->arg
;
19257 argv_find(argv
, argc
, "(100-500)", &idx
);
19258 argv_find(argv
, argc
, "WORD", &idx
);
19259 cl_name_or_number
= argv
[idx
]->arg
;
19260 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19262 argv_find(argv
, argc
, "AA:NN", &idx
);
19263 char *str
= argv_concat(argv
, argc
, idx
);
19265 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19268 XFREE(MTYPE_TMP
, str
);
19271 /* Display error string. */
19272 community_list_perror(vty
, ret
);
19273 return CMD_WARNING_CONFIG_FAILED
;
19276 return CMD_SUCCESS
;
19279 DEFUN (no_community_list_expanded_all
,
19280 no_bgp_community_list_expanded_all_cmd
,
19281 "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19285 "Community list number (expanded)\n"
19286 "Add an expanded community-list entry\n"
19287 "Community list name\n"
19288 "Sequence number of an entry\n"
19289 "Sequence number\n"
19290 "Specify community to reject\n"
19291 "Specify community to accept\n"
19294 char *cl_name_or_number
= NULL
;
19298 int style
= COMMUNITY_LIST_EXPANDED
;
19301 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
19303 seq
= argv
[idx
]->arg
;
19306 argv_find(argv
, argc
, "permit", &idx
);
19307 argv_find(argv
, argc
, "deny", &idx
);
19310 direct
= argv_find(argv
, argc
, "permit", &idx
)
19315 argv_find(argv
, argc
, "AA:NN", &idx
);
19316 str
= argv_concat(argv
, argc
, idx
);
19320 argv_find(argv
, argc
, "(100-500)", &idx
);
19321 argv_find(argv
, argc
, "WORD", &idx
);
19322 cl_name_or_number
= argv
[idx
]->arg
;
19324 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19327 XFREE(MTYPE_TMP
, str
);
19330 community_list_perror(vty
, ret
);
19331 return CMD_WARNING_CONFIG_FAILED
;
19334 return CMD_SUCCESS
;
19337 ALIAS(no_community_list_expanded_all
,
19338 no_bgp_community_list_expanded_all_list_cmd
,
19339 "no bgp community-list <(100-500)|expanded WORD>",
19340 NO_STR BGP_STR COMMUNITY_LIST_STR
19341 "Community list number (expanded)\n"
19342 "Add an expanded community-list entry\n"
19343 "Community list name\n")
19345 /* Return configuration string of community-list entry. */
19346 static const char *community_list_config_str(struct community_entry
*entry
)
19353 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
19354 str
= community_str(entry
->u
.com
, false);
19355 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
19356 str
= lcommunity_str(entry
->u
.lcom
, false);
19358 str
= entry
->config
;
19363 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
19365 struct community_entry
*entry
;
19367 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19368 if (entry
== list
->head
) {
19369 if (all_digit(list
->name
))
19370 vty_out(vty
, "Community %s list %s\n",
19371 entry
->style
== COMMUNITY_LIST_STANDARD
19373 : "(expanded) access",
19376 vty_out(vty
, "Named Community %s list %s\n",
19377 entry
->style
== COMMUNITY_LIST_STANDARD
19383 vty_out(vty
, " %s\n",
19384 community_direct_str(entry
->direct
));
19386 vty_out(vty
, " %s %s\n",
19387 community_direct_str(entry
->direct
),
19388 community_list_config_str(entry
));
19392 DEFUN (show_community_list
,
19393 show_bgp_community_list_cmd
,
19394 "show bgp community-list",
19397 "List community-list\n")
19399 struct community_list
*list
;
19400 struct community_list_master
*cm
;
19402 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19404 return CMD_SUCCESS
;
19406 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19407 community_list_show(vty
, list
);
19409 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19410 community_list_show(vty
, list
);
19412 return CMD_SUCCESS
;
19415 DEFUN (show_community_list_arg
,
19416 show_bgp_community_list_arg_cmd
,
19417 "show bgp community-list <(1-500)|WORD> detail",
19420 "List community-list\n"
19421 "Community-list number\n"
19422 "Community-list name\n"
19423 "Detailed information on community-list\n")
19425 int idx_comm_list
= 3;
19426 struct community_list
*list
;
19428 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
19429 COMMUNITY_LIST_MASTER
);
19431 vty_out(vty
, "%% Can't find community-list\n");
19432 return CMD_WARNING
;
19435 community_list_show(vty
, list
);
19437 return CMD_SUCCESS
;
19441 * Large Community code.
19443 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
19444 struct cmd_token
**argv
, int style
,
19445 int reject_all_digit_name
)
19454 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19455 seq
= argv
[idx
]->arg
;
19458 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19461 /* All digit name check. */
19463 argv_find(argv
, argc
, "WORD", &idx
);
19464 argv_find(argv
, argc
, "(1-99)", &idx
);
19465 argv_find(argv
, argc
, "(100-500)", &idx
);
19466 cl_name
= argv
[idx
]->arg
;
19467 if (reject_all_digit_name
&& all_digit(cl_name
)) {
19468 vty_out(vty
, "%% Community name cannot have all digits\n");
19469 return CMD_WARNING_CONFIG_FAILED
;
19473 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
19474 argv_find(argv
, argc
, "LINE", &idx
);
19475 /* Concat community string argument. */
19477 str
= argv_concat(argv
, argc
, idx
);
19481 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
19483 /* Free temporary community list string allocated by
19485 XFREE(MTYPE_TMP
, str
);
19488 community_list_perror(vty
, ret
);
19489 return CMD_WARNING_CONFIG_FAILED
;
19491 return CMD_SUCCESS
;
19494 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
19495 struct cmd_token
**argv
, int style
)
19503 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19504 seq
= argv
[idx
]->arg
;
19507 argv_find(argv
, argc
, "permit", &idx
);
19508 argv_find(argv
, argc
, "deny", &idx
);
19511 /* Check the list direct. */
19512 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
19513 direct
= COMMUNITY_PERMIT
;
19515 direct
= COMMUNITY_DENY
;
19518 argv_find(argv
, argc
, "LINE", &idx
);
19519 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
19520 /* Concat community string argument. */
19521 str
= argv_concat(argv
, argc
, idx
);
19525 argv_find(argv
, argc
, "(1-99)", &idx
);
19526 argv_find(argv
, argc
, "(100-500)", &idx
);
19527 argv_find(argv
, argc
, "WORD", &idx
);
19529 /* Unset community list. */
19530 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
19533 /* Free temporary community list string allocated by
19535 XFREE(MTYPE_TMP
, str
);
19538 community_list_perror(vty
, ret
);
19539 return CMD_WARNING_CONFIG_FAILED
;
19542 return CMD_SUCCESS
;
19545 /* "large-community-list" keyword help string. */
19546 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
19547 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
19549 DEFUN (lcommunity_list_standard
,
19550 bgp_lcommunity_list_standard_cmd
,
19551 "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...",
19553 LCOMMUNITY_LIST_STR
19554 "Large Community list number (standard)\n"
19555 "Sequence number of an entry\n"
19556 "Sequence number\n"
19557 "Specify large community to reject\n"
19558 "Specify large community to accept\n"
19559 LCOMMUNITY_VAL_STR
)
19561 return lcommunity_list_set_vty(vty
, argc
, argv
,
19562 LARGE_COMMUNITY_LIST_STANDARD
, 0);
19565 DEFUN (lcommunity_list_expanded
,
19566 bgp_lcommunity_list_expanded_cmd
,
19567 "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...",
19569 LCOMMUNITY_LIST_STR
19570 "Large Community list number (expanded)\n"
19571 "Sequence number of an entry\n"
19572 "Sequence number\n"
19573 "Specify large community to reject\n"
19574 "Specify large community to accept\n"
19575 "An ordered list as a regular-expression\n")
19577 return lcommunity_list_set_vty(vty
, argc
, argv
,
19578 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
19581 DEFUN (lcommunity_list_name_standard
,
19582 bgp_lcommunity_list_name_standard_cmd
,
19583 "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...",
19585 LCOMMUNITY_LIST_STR
19586 "Specify standard large-community-list\n"
19587 "Large Community list name\n"
19588 "Sequence number of an entry\n"
19589 "Sequence number\n"
19590 "Specify large community to reject\n"
19591 "Specify large community to accept\n"
19592 LCOMMUNITY_VAL_STR
)
19594 return lcommunity_list_set_vty(vty
, argc
, argv
,
19595 LARGE_COMMUNITY_LIST_STANDARD
, 1);
19598 DEFUN (lcommunity_list_name_expanded
,
19599 bgp_lcommunity_list_name_expanded_cmd
,
19600 "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...",
19602 LCOMMUNITY_LIST_STR
19603 "Specify expanded large-community-list\n"
19604 "Large Community list name\n"
19605 "Sequence number of an entry\n"
19606 "Sequence number\n"
19607 "Specify large community to reject\n"
19608 "Specify large community to accept\n"
19609 "An ordered list as a regular-expression\n")
19611 return lcommunity_list_set_vty(vty
, argc
, argv
,
19612 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
19615 DEFUN (no_lcommunity_list_all
,
19616 no_bgp_lcommunity_list_all_cmd
,
19617 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
19620 LCOMMUNITY_LIST_STR
19621 "Large Community list number (standard)\n"
19622 "Large Community list number (expanded)\n"
19623 "Large Community list name\n")
19625 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19626 LARGE_COMMUNITY_LIST_STANDARD
);
19629 DEFUN (no_lcommunity_list_name_standard_all
,
19630 no_bgp_lcommunity_list_name_standard_all_cmd
,
19631 "no bgp large-community-list standard WORD",
19634 LCOMMUNITY_LIST_STR
19635 "Specify standard large-community-list\n"
19636 "Large Community list name\n")
19638 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19639 LARGE_COMMUNITY_LIST_STANDARD
);
19642 DEFUN (no_lcommunity_list_name_expanded_all
,
19643 no_bgp_lcommunity_list_name_expanded_all_cmd
,
19644 "no bgp large-community-list expanded WORD",
19647 LCOMMUNITY_LIST_STR
19648 "Specify expanded large-community-list\n"
19649 "Large Community list name\n")
19651 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19652 LARGE_COMMUNITY_LIST_EXPANDED
);
19655 DEFUN (no_lcommunity_list_standard
,
19656 no_bgp_lcommunity_list_standard_cmd
,
19657 "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...",
19660 LCOMMUNITY_LIST_STR
19661 "Large Community list number (standard)\n"
19662 "Sequence number of an entry\n"
19663 "Sequence number\n"
19664 "Specify large community to reject\n"
19665 "Specify large community to accept\n"
19666 LCOMMUNITY_VAL_STR
)
19668 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19669 LARGE_COMMUNITY_LIST_STANDARD
);
19672 DEFUN (no_lcommunity_list_expanded
,
19673 no_bgp_lcommunity_list_expanded_cmd
,
19674 "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...",
19677 LCOMMUNITY_LIST_STR
19678 "Large Community list number (expanded)\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 DEFUN (no_lcommunity_list_name_standard
,
19690 no_bgp_lcommunity_list_name_standard_cmd
,
19691 "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...",
19694 LCOMMUNITY_LIST_STR
19695 "Specify standard large-community-list\n"
19696 "Large Community list name\n"
19697 "Sequence number of an entry\n"
19698 "Sequence number\n"
19699 "Specify large community to reject\n"
19700 "Specify large community to accept\n"
19701 LCOMMUNITY_VAL_STR
)
19703 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19704 LARGE_COMMUNITY_LIST_STANDARD
);
19707 DEFUN (no_lcommunity_list_name_expanded
,
19708 no_bgp_lcommunity_list_name_expanded_cmd
,
19709 "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...",
19712 LCOMMUNITY_LIST_STR
19713 "Specify expanded large-community-list\n"
19714 "Large community list name\n"
19715 "Sequence number of an entry\n"
19716 "Sequence number\n"
19717 "Specify large community to reject\n"
19718 "Specify large community to accept\n"
19719 "An ordered list as a regular-expression\n")
19721 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19722 LARGE_COMMUNITY_LIST_EXPANDED
);
19725 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
19727 struct community_entry
*entry
;
19729 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19730 if (entry
== list
->head
) {
19731 if (all_digit(list
->name
))
19732 vty_out(vty
, "Large community %s list %s\n",
19734 LARGE_COMMUNITY_LIST_STANDARD
19736 : "(expanded) access",
19740 "Named large community %s list %s\n",
19742 LARGE_COMMUNITY_LIST_STANDARD
19748 vty_out(vty
, " %s\n",
19749 community_direct_str(entry
->direct
));
19751 vty_out(vty
, " %s %s\n",
19752 community_direct_str(entry
->direct
),
19753 community_list_config_str(entry
));
19757 DEFUN (show_lcommunity_list
,
19758 show_bgp_lcommunity_list_cmd
,
19759 "show bgp large-community-list",
19762 "List large-community list\n")
19764 struct community_list
*list
;
19765 struct community_list_master
*cm
;
19767 cm
= community_list_master_lookup(bgp_clist
,
19768 LARGE_COMMUNITY_LIST_MASTER
);
19770 return CMD_SUCCESS
;
19772 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19773 lcommunity_list_show(vty
, list
);
19775 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19776 lcommunity_list_show(vty
, list
);
19778 return CMD_SUCCESS
;
19781 DEFUN (show_lcommunity_list_arg
,
19782 show_bgp_lcommunity_list_arg_cmd
,
19783 "show bgp large-community-list <(1-500)|WORD> detail",
19786 "List large-community list\n"
19787 "Large-community-list number\n"
19788 "Large-community-list name\n"
19789 "Detailed information on large-community-list\n")
19791 struct community_list
*list
;
19793 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
19794 LARGE_COMMUNITY_LIST_MASTER
);
19796 vty_out(vty
, "%% Can't find large-community-list\n");
19797 return CMD_WARNING
;
19800 lcommunity_list_show(vty
, list
);
19802 return CMD_SUCCESS
;
19805 /* "extcommunity-list" keyword help string. */
19806 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
19807 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
19809 DEFUN (extcommunity_list_standard
,
19810 bgp_extcommunity_list_standard_cmd
,
19811 "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19813 EXTCOMMUNITY_LIST_STR
19814 "Extended Community list number (standard)\n"
19815 "Specify standard extcommunity-list\n"
19816 "Community list name\n"
19817 "Sequence number of an entry\n"
19818 "Sequence number\n"
19819 "Specify community to reject\n"
19820 "Specify community to accept\n"
19821 EXTCOMMUNITY_VAL_STR
)
19823 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19825 char *cl_number_or_name
= NULL
;
19830 argv_find(argv
, argc
, "(1-99)", &idx
);
19831 argv_find(argv
, argc
, "WORD", &idx
);
19832 cl_number_or_name
= argv
[idx
]->arg
;
19834 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19835 seq
= argv
[idx
]->arg
;
19837 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19839 argv_find(argv
, argc
, "AA:NN", &idx
);
19840 char *str
= argv_concat(argv
, argc
, idx
);
19842 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19845 XFREE(MTYPE_TMP
, str
);
19848 community_list_perror(vty
, ret
);
19849 return CMD_WARNING_CONFIG_FAILED
;
19852 return CMD_SUCCESS
;
19855 DEFUN (extcommunity_list_name_expanded
,
19856 bgp_extcommunity_list_name_expanded_cmd
,
19857 "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...",
19859 EXTCOMMUNITY_LIST_STR
19860 "Extended Community list number (expanded)\n"
19861 "Specify expanded extcommunity-list\n"
19862 "Extended Community list name\n"
19863 "Sequence number of an entry\n"
19864 "Sequence number\n"
19865 "Specify community to reject\n"
19866 "Specify community to accept\n"
19867 "An ordered list as a regular-expression\n")
19869 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
19871 char *cl_number_or_name
= NULL
;
19875 argv_find(argv
, argc
, "(100-500)", &idx
);
19876 argv_find(argv
, argc
, "WORD", &idx
);
19877 cl_number_or_name
= argv
[idx
]->arg
;
19879 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19880 seq
= argv
[idx
]->arg
;
19882 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19884 argv_find(argv
, argc
, "LINE", &idx
);
19885 char *str
= argv_concat(argv
, argc
, idx
);
19887 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19890 XFREE(MTYPE_TMP
, str
);
19893 community_list_perror(vty
, ret
);
19894 return CMD_WARNING_CONFIG_FAILED
;
19897 return CMD_SUCCESS
;
19900 DEFUN (no_extcommunity_list_standard_all
,
19901 no_bgp_extcommunity_list_standard_all_cmd
,
19902 "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19905 EXTCOMMUNITY_LIST_STR
19906 "Extended Community list number (standard)\n"
19907 "Specify standard extcommunity-list\n"
19908 "Community list name\n"
19909 "Sequence number of an entry\n"
19910 "Sequence number\n"
19911 "Specify community to reject\n"
19912 "Specify community to accept\n"
19913 EXTCOMMUNITY_VAL_STR
)
19915 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19917 char *cl_number_or_name
= NULL
;
19922 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19923 seq
= argv
[idx
]->arg
;
19926 argv_find(argv
, argc
, "permit", &idx
);
19927 argv_find(argv
, argc
, "deny", &idx
);
19929 direct
= argv_find(argv
, argc
, "permit", &idx
)
19934 argv_find(argv
, argc
, "AA:NN", &idx
);
19935 str
= argv_concat(argv
, argc
, idx
);
19939 argv_find(argv
, argc
, "(1-99)", &idx
);
19940 argv_find(argv
, argc
, "WORD", &idx
);
19941 cl_number_or_name
= argv
[idx
]->arg
;
19943 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
19944 seq
, direct
, style
);
19946 XFREE(MTYPE_TMP
, str
);
19949 community_list_perror(vty
, ret
);
19950 return CMD_WARNING_CONFIG_FAILED
;
19953 return CMD_SUCCESS
;
19956 ALIAS(no_extcommunity_list_standard_all
,
19957 no_bgp_extcommunity_list_standard_all_list_cmd
,
19958 "no bgp extcommunity-list <(1-99)|standard WORD>",
19959 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
19960 "Extended Community list number (standard)\n"
19961 "Specify standard extcommunity-list\n"
19962 "Community list name\n")
19964 DEFUN (no_extcommunity_list_expanded_all
,
19965 no_bgp_extcommunity_list_expanded_all_cmd
,
19966 "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...",
19969 EXTCOMMUNITY_LIST_STR
19970 "Extended Community list number (expanded)\n"
19971 "Specify expanded extcommunity-list\n"
19972 "Extended Community list name\n"
19973 "Sequence number of an entry\n"
19974 "Sequence number\n"
19975 "Specify community to reject\n"
19976 "Specify community to accept\n"
19977 "An ordered list as a regular-expression\n")
19979 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
19981 char *cl_number_or_name
= NULL
;
19986 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19987 seq
= argv
[idx
]->arg
;
19990 argv_find(argv
, argc
, "permit", &idx
);
19991 argv_find(argv
, argc
, "deny", &idx
);
19994 direct
= argv_find(argv
, argc
, "permit", &idx
)
19999 argv_find(argv
, argc
, "LINE", &idx
);
20000 str
= argv_concat(argv
, argc
, idx
);
20004 argv_find(argv
, argc
, "(100-500)", &idx
);
20005 argv_find(argv
, argc
, "WORD", &idx
);
20006 cl_number_or_name
= argv
[idx
]->arg
;
20008 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20009 seq
, direct
, style
);
20011 XFREE(MTYPE_TMP
, str
);
20014 community_list_perror(vty
, ret
);
20015 return CMD_WARNING_CONFIG_FAILED
;
20018 return CMD_SUCCESS
;
20021 ALIAS(no_extcommunity_list_expanded_all
,
20022 no_bgp_extcommunity_list_expanded_all_list_cmd
,
20023 "no bgp extcommunity-list <(100-500)|expanded WORD>",
20024 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20025 "Extended Community list number (expanded)\n"
20026 "Specify expanded extcommunity-list\n"
20027 "Extended Community list name\n")
20029 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20031 struct community_entry
*entry
;
20033 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20034 if (entry
== list
->head
) {
20035 if (all_digit(list
->name
))
20036 vty_out(vty
, "Extended community %s list %s\n",
20037 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20039 : "(expanded) access",
20043 "Named extended community %s list %s\n",
20044 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20050 vty_out(vty
, " %s\n",
20051 community_direct_str(entry
->direct
));
20053 vty_out(vty
, " %s %s\n",
20054 community_direct_str(entry
->direct
),
20055 community_list_config_str(entry
));
20059 DEFUN (show_extcommunity_list
,
20060 show_bgp_extcommunity_list_cmd
,
20061 "show bgp extcommunity-list",
20064 "List extended-community list\n")
20066 struct community_list
*list
;
20067 struct community_list_master
*cm
;
20069 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20071 return CMD_SUCCESS
;
20073 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20074 extcommunity_list_show(vty
, list
);
20076 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20077 extcommunity_list_show(vty
, list
);
20079 return CMD_SUCCESS
;
20082 DEFUN (show_extcommunity_list_arg
,
20083 show_bgp_extcommunity_list_arg_cmd
,
20084 "show bgp extcommunity-list <(1-500)|WORD> detail",
20087 "List extended-community list\n"
20088 "Extcommunity-list number\n"
20089 "Extcommunity-list name\n"
20090 "Detailed information on extcommunity-list\n")
20092 int idx_comm_list
= 3;
20093 struct community_list
*list
;
20095 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20096 EXTCOMMUNITY_LIST_MASTER
);
20098 vty_out(vty
, "%% Can't find extcommunity-list\n");
20099 return CMD_WARNING
;
20102 extcommunity_list_show(vty
, list
);
20104 return CMD_SUCCESS
;
20107 /* Display community-list and extcommunity-list configuration. */
20108 static int community_list_config_write(struct vty
*vty
)
20110 struct community_list
*list
;
20111 struct community_entry
*entry
;
20112 struct community_list_master
*cm
;
20115 /* Community-list. */
20116 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20118 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20119 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20121 "bgp community-list %s seq %" PRId64
" %s %s\n",
20122 list
->name
, entry
->seq
,
20123 community_direct_str(entry
->direct
),
20124 community_list_config_str(entry
));
20127 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20128 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20130 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
20131 entry
->style
== COMMUNITY_LIST_STANDARD
20134 list
->name
, entry
->seq
,
20135 community_direct_str(entry
->direct
),
20136 community_list_config_str(entry
));
20140 /* Extcommunity-list. */
20141 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20143 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20144 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20146 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
20147 list
->name
, entry
->seq
,
20148 community_direct_str(entry
->direct
),
20149 community_list_config_str(entry
));
20152 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20153 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20155 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
20156 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20159 list
->name
, entry
->seq
,
20160 community_direct_str(entry
->direct
),
20161 community_list_config_str(entry
));
20166 /* lcommunity-list. */
20167 cm
= community_list_master_lookup(bgp_clist
,
20168 LARGE_COMMUNITY_LIST_MASTER
);
20170 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20171 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20173 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
20174 list
->name
, entry
->seq
,
20175 community_direct_str(entry
->direct
),
20176 community_list_config_str(entry
));
20179 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20180 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20182 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
20184 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
20187 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
20188 community_list_config_str(entry
));
20195 static int community_list_config_write(struct vty
*vty
);
20196 static struct cmd_node community_list_node
= {
20197 .name
= "community list",
20198 .node
= COMMUNITY_LIST_NODE
,
20200 .config_write
= community_list_config_write
,
20203 static void community_list_vty(void)
20205 install_node(&community_list_node
);
20207 /* Community-list. */
20208 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
20209 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
20210 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
20211 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
20212 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
20213 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
20214 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
20215 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
20217 /* Extcommunity-list. */
20218 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
20219 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
20220 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
20221 install_element(CONFIG_NODE
,
20222 &no_bgp_extcommunity_list_standard_all_list_cmd
);
20223 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
20224 install_element(CONFIG_NODE
,
20225 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
20226 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
20227 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
20229 /* Large Community List */
20230 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
20231 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
20232 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
20233 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
20234 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
20235 install_element(CONFIG_NODE
,
20236 &no_bgp_lcommunity_list_name_standard_all_cmd
);
20237 install_element(CONFIG_NODE
,
20238 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
20239 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
20240 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
20241 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
20242 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
20243 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
20244 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);