2 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "lib_errors.h"
26 #include "lib/zclient.h"
41 #include "bgpd/bgpd.h"
42 #include "bgpd/bgp_attr_evpn.h"
43 #include "bgpd/bgp_advertise.h"
44 #include "bgpd/bgp_attr.h"
45 #include "bgpd/bgp_aspath.h"
46 #include "bgpd/bgp_community.h"
47 #include "bgpd/bgp_ecommunity.h"
48 #include "bgpd/bgp_lcommunity.h"
49 #include "bgpd/bgp_damp.h"
50 #include "bgpd/bgp_debug.h"
51 #include "bgpd/bgp_errors.h"
52 #include "bgpd/bgp_fsm.h"
53 #include "bgpd/bgp_nexthop.h"
54 #include "bgpd/bgp_open.h"
55 #include "bgpd/bgp_regex.h"
56 #include "bgpd/bgp_route.h"
57 #include "bgpd/bgp_mplsvpn.h"
58 #include "bgpd/bgp_zebra.h"
59 #include "bgpd/bgp_table.h"
60 #include "bgpd/bgp_vty.h"
61 #include "bgpd/bgp_mpath.h"
62 #include "bgpd/bgp_packet.h"
63 #include "bgpd/bgp_updgrp.h"
64 #include "bgpd/bgp_bfd.h"
65 #include "bgpd/bgp_io.h"
66 #include "bgpd/bgp_evpn.h"
67 #include "bgpd/bgp_evpn_vty.h"
68 #include "bgpd/bgp_evpn_mh.h"
69 #include "bgpd/bgp_addpath.h"
70 #include "bgpd/bgp_mac.h"
71 #include "bgpd/bgp_flowspec.h"
73 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
76 #include "northbound.h"
77 #include "northbound_cli.h"
78 #include "bgpd/bgp_nb.h"
81 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
84 .match_profile
= "traditional",
85 .match_version
= "< 7.4",
89 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
90 { .val_bool
= true, .match_profile
= "datacenter", },
91 { .val_bool
= false },
93 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
94 { .val_bool
= true, .match_profile
= "datacenter", },
95 { .val_bool
= false },
97 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
98 { .val_bool
= true, .match_profile
= "datacenter", },
99 { .val_bool
= false },
101 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
102 { .val_bool
= true, .match_profile
= "datacenter", },
103 { .val_bool
= false },
105 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
106 { .val_ulong
= 10, .match_profile
= "datacenter", },
107 { .val_ulong
= 120 },
109 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
110 { .val_ulong
= 9, .match_profile
= "datacenter", },
111 { .val_ulong
= 180 },
113 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
114 { .val_ulong
= 3, .match_profile
= "datacenter", },
117 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
118 { .val_bool
= false, .match_profile
= "datacenter", },
119 { .val_bool
= false, .match_version
= "< 7.4", },
120 { .val_bool
= true },
122 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
123 { .val_bool
= false, .match_version
= "< 7.6", },
124 { .val_bool
= true },
127 DEFINE_HOOK(bgp_inst_config_write
,
128 (struct bgp
*bgp
, struct vty
*vty
),
132 "The Graceful Restart No Operation was executed as cmd same as previous one."
134 "The Graceful Restart command used is not valid at this moment."
135 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
136 struct prefix
*range
, int exact
);
138 /* Show BGP peer's information. */
148 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
149 struct prefix
*range
, int exact
);
151 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
156 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
159 afi_t afi
, bool use_json
);
161 static int peer_and_group_lookup_nb(struct vty
*vty
, const char *peer_str
,
162 char *base_xpath
, int xpath_len
,
165 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
171 return BGP_IPV4_NODE
;
173 return BGP_IPV4M_NODE
;
174 case SAFI_LABELED_UNICAST
:
175 return BGP_IPV4L_NODE
;
177 return BGP_VPNV4_NODE
;
179 return BGP_FLOWSPECV4_NODE
;
182 return BGP_IPV4_NODE
;
188 return BGP_IPV6_NODE
;
190 return BGP_IPV6M_NODE
;
191 case SAFI_LABELED_UNICAST
:
192 return BGP_IPV6L_NODE
;
194 return BGP_VPNV6_NODE
;
196 return BGP_FLOWSPECV6_NODE
;
199 return BGP_IPV4_NODE
;
203 return BGP_EVPN_NODE
;
206 // We should never be here but to clarify the switch statement..
207 return BGP_IPV4_NODE
;
210 // Impossible to happen
211 return BGP_IPV4_NODE
;
214 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
217 if (safi
== SAFI_UNICAST
)
218 return "IPv4 Unicast";
219 if (safi
== SAFI_MULTICAST
)
220 return "IPv4 Multicast";
221 if (safi
== SAFI_LABELED_UNICAST
)
222 return "IPv4 Labeled Unicast";
223 if (safi
== SAFI_MPLS_VPN
)
225 if (safi
== SAFI_ENCAP
)
227 if (safi
== SAFI_FLOWSPEC
)
228 return "IPv4 Flowspec";
229 } else if (afi
== AFI_IP6
) {
230 if (safi
== SAFI_UNICAST
)
231 return "IPv6 Unicast";
232 if (safi
== SAFI_MULTICAST
)
233 return "IPv6 Multicast";
234 if (safi
== SAFI_LABELED_UNICAST
)
235 return "IPv6 Labeled Unicast";
236 if (safi
== SAFI_MPLS_VPN
)
238 if (safi
== SAFI_ENCAP
)
240 if (safi
== SAFI_FLOWSPEC
)
241 return "IPv6 Flowspec";
242 } else if (afi
== AFI_L2VPN
) {
243 if (safi
== SAFI_EVPN
)
251 * Please note that we have intentionally camelCased
252 * the return strings here. So if you want
253 * to use this function, please ensure you
254 * are doing this within json output
256 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
259 if (safi
== SAFI_UNICAST
)
260 return "ipv4Unicast";
261 if (safi
== SAFI_MULTICAST
)
262 return "ipv4Multicast";
263 if (safi
== SAFI_LABELED_UNICAST
)
264 return "ipv4LabeledUnicast";
265 if (safi
== SAFI_MPLS_VPN
)
267 if (safi
== SAFI_ENCAP
)
269 if (safi
== SAFI_FLOWSPEC
)
270 return "ipv4Flowspec";
271 } else if (afi
== AFI_IP6
) {
272 if (safi
== SAFI_UNICAST
)
273 return "ipv6Unicast";
274 if (safi
== SAFI_MULTICAST
)
275 return "ipv6Multicast";
276 if (safi
== SAFI_LABELED_UNICAST
)
277 return "ipv6LabeledUnicast";
278 if (safi
== SAFI_MPLS_VPN
)
280 if (safi
== SAFI_ENCAP
)
282 if (safi
== SAFI_FLOWSPEC
)
283 return "ipv6Flowspec";
284 } else if (afi
== AFI_L2VPN
) {
285 if (safi
== SAFI_EVPN
)
292 /* return string maps to afi-safi specific container names
293 * defined in bgp yang file.
295 const char *bgp_afi_safi_get_container_str(afi_t afi
, safi_t safi
)
298 if (safi
== SAFI_UNICAST
)
299 return "ipv4-unicast";
300 if (safi
== SAFI_MULTICAST
)
301 return "ipv4-multicast";
302 if (safi
== SAFI_LABELED_UNICAST
)
303 return "ipv4-labeled-unicast";
304 if (safi
== SAFI_MPLS_VPN
)
305 return "l3vpn-ipv4-unicast";
306 if (safi
== SAFI_FLOWSPEC
)
307 return "ipv4-flowspec";
308 } else if (afi
== AFI_IP6
) {
309 if (safi
== SAFI_UNICAST
)
310 return "ipv6-unicast";
311 if (safi
== SAFI_MULTICAST
)
312 return "ipv6-multicast";
313 if (safi
== SAFI_LABELED_UNICAST
)
314 return "ipv6-labeled-unicast";
315 if (safi
== SAFI_MPLS_VPN
)
316 return "l3vpn-ipv6-unicast";
317 if (safi
== SAFI_FLOWSPEC
)
318 return "ipv6-flowspec";
319 } else if (afi
== AFI_L2VPN
) {
320 if (safi
== SAFI_EVPN
)
327 /* Utility function to get address family from current node. */
328 afi_t
bgp_node_afi(struct vty
*vty
)
336 case BGP_FLOWSPECV6_NODE
:
349 /* Utility function to get subsequent address family from current
351 safi_t
bgp_node_safi(struct vty
*vty
)
357 safi
= SAFI_MPLS_VPN
;
361 safi
= SAFI_MULTICAST
;
368 safi
= SAFI_LABELED_UNICAST
;
370 case BGP_FLOWSPECV4_NODE
:
371 case BGP_FLOWSPECV6_NODE
:
372 safi
= SAFI_FLOWSPEC
;
382 * Converts an AFI in string form to afi_t
384 * @param afi string, one of
388 * @return the corresponding afi_t
390 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
392 afi_t afi
= AFI_MAX
; /* unknown */
393 if (strmatch(afi_str
, "ipv4"))
395 else if (strmatch(afi_str
, "ipv6"))
397 else if (strmatch(afi_str
, "l2vpn"))
402 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
406 if (argv_find(argv
, argc
, "ipv4", index
)) {
410 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
414 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
422 /* supports <unicast|multicast|vpn|labeled-unicast> */
423 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
425 safi_t safi
= SAFI_MAX
; /* unknown */
426 if (strmatch(safi_str
, "multicast"))
427 safi
= SAFI_MULTICAST
;
428 else if (strmatch(safi_str
, "unicast"))
430 else if (strmatch(safi_str
, "vpn"))
431 safi
= SAFI_MPLS_VPN
;
432 else if (strmatch(safi_str
, "evpn"))
434 else if (strmatch(safi_str
, "labeled-unicast"))
435 safi
= SAFI_LABELED_UNICAST
;
436 else if (strmatch(safi_str
, "flowspec"))
437 safi
= SAFI_FLOWSPEC
;
441 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
445 if (argv_find(argv
, argc
, "unicast", index
)) {
448 *safi
= SAFI_UNICAST
;
449 } else if (argv_find(argv
, argc
, "multicast", index
)) {
452 *safi
= SAFI_MULTICAST
;
453 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
456 *safi
= SAFI_LABELED_UNICAST
;
457 } else if (argv_find(argv
, argc
, "vpn", index
)) {
460 *safi
= SAFI_MPLS_VPN
;
461 } else if (argv_find(argv
, argc
, "evpn", index
)) {
465 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
468 *safi
= SAFI_FLOWSPEC
;
473 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
474 enum bgp_instance_type inst_type
)
476 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
478 if (ret
== BGP_CREATED
) {
479 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
480 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
482 if (DFLT_BGP_IMPORT_CHECK
)
483 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
484 if (DFLT_BGP_SHOW_HOSTNAME
)
485 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
486 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
487 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
488 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
489 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
490 if (DFLT_BGP_DETERMINISTIC_MED
)
491 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
492 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
493 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
494 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
495 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
503 * bgp_vty_find_and_parse_afi_safi_bgp
505 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
506 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
507 * to appropriate values for the calling function. This is to allow the
508 * calling function to make decisions appropriate for the show command
509 * that is being parsed.
511 * The show commands are generally of the form:
512 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
513 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
515 * Since we use argv_find if the show command in particular doesn't have:
517 * [<view|vrf> VIEWVRFNAME]
518 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
519 * The command parsing should still be ok.
521 * vty -> The vty for the command so we can output some useful data in
522 * the event of a parse error in the vrf.
523 * argv -> The command tokens
524 * argc -> How many command tokens we have
525 * idx -> The current place in the command, generally should be 0 for this
527 * afi -> The parsed afi if it was included in the show command, returned here
528 * safi -> The parsed safi if it was included in the show command, returned here
529 * bgp -> Pointer to the bgp data structure we need to fill in.
530 * use_json -> json is configured or not
532 * The function returns the correct location in the parse tree for the
535 * Returns 0 for failure to parse correctly, else the idx position of where
536 * it found the last token.
538 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
539 struct cmd_token
**argv
, int argc
,
540 int *idx
, afi_t
*afi
, safi_t
*safi
,
541 struct bgp
**bgp
, bool use_json
)
543 char *vrf_name
= NULL
;
549 if (argv_find(argv
, argc
, "ip", idx
))
552 if (argv_find(argv
, argc
, "view", idx
))
553 vrf_name
= argv
[*idx
+ 1]->arg
;
554 else if (argv_find(argv
, argc
, "vrf", idx
)) {
555 vrf_name
= argv
[*idx
+ 1]->arg
;
556 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
560 if (strmatch(vrf_name
, "all"))
563 *bgp
= bgp_lookup_by_name(vrf_name
);
566 json_object
*json
= NULL
;
567 json
= json_object_new_object();
568 json_object_string_add(
570 "View/Vrf is unknown");
572 json_object_to_json_string_ext(json
,
573 JSON_C_TO_STRING_PRETTY
));
574 json_object_free(json
);
577 vty_out(vty
, "View/Vrf %s is unknown\n",
584 *bgp
= bgp_get_default();
587 json_object
*json
= NULL
;
588 json
= json_object_new_object();
589 json_object_string_add(
591 "Default BGP instance not found");
593 json_object_to_json_string_ext(json
,
594 JSON_C_TO_STRING_PRETTY
));
595 json_object_free(json
);
599 "Default BGP instance not found\n");
605 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
606 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
612 bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
614 struct interface
*ifp
= NULL
;
616 if (su
->sa
.sa_family
== AF_INET
)
617 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
618 else if (su
->sa
.sa_family
== AF_INET6
)
619 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
620 su
->sin6
.sin6_scope_id
,
629 /* Utility function for looking up peer or peer group. */
630 /* This is used only for configuration, so disallow if attempted on
631 * a dynamic neighbor.
633 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
635 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
638 struct peer
*peer
= NULL
;
639 struct peer_group
*group
= NULL
;
645 ret
= str2sockunion(peer_str
, &su
);
647 /* IP address, locate peer. */
648 peer
= peer_lookup(bgp
, &su
);
650 /* Not IP, could match either peer configured on interface or a
652 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
654 group
= peer_group_lookup(bgp
, peer_str
);
658 if (peer_dynamic_neighbor(peer
)) {
660 "%% Operation not allowed on a dynamic neighbor\n");
670 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
675 int bgp_nb_errmsg_return(char *errmsg
, size_t errmsg_len
, int ret
)
677 const char *str
= NULL
;
680 case BGP_ERR_INVALID_VALUE
:
681 str
= "Invalid value";
683 case BGP_ERR_INVALID_FLAG
:
684 str
= "Invalid flag";
686 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
687 str
= "Peer-group has been shutdown. Activate the peer-group first";
689 case BGP_ERR_PEER_FLAG_CONFLICT
:
690 str
= "Can't set override-capability and strict-capability-match at the same time";
692 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
693 str
= "Specify remote-as or peer-group remote AS first";
695 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
696 str
= "Cannot change the peer-group. Deconfigure first";
698 case BGP_ERR_PEER_GROUP_MISMATCH
:
699 str
= "Peer is not a member of this peer-group";
701 case BGP_ERR_PEER_FILTER_CONFLICT
:
702 str
= "Prefix/distribute list can not co-exist";
704 case BGP_ERR_NOT_INTERNAL_PEER
:
705 str
= "Invalid command. Not an internal neighbor";
707 case BGP_ERR_REMOVE_PRIVATE_AS
:
708 str
= "remove-private-AS cannot be configured for IBGP peers";
710 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
711 str
= "Local-AS allowed only for EBGP peers";
713 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
714 str
= "Cannot have local-as same as BGP AS number";
716 case BGP_ERR_TCPSIG_FAILED
:
717 str
= "Error while applying TCP-Sig to session(s)";
719 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
720 str
= "ebgp-multihop and ttl-security cannot be configured together";
722 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
723 str
= "ttl-security only allowed for EBGP peers";
725 case BGP_ERR_AS_OVERRIDE
:
726 str
= "as-override cannot be configured for IBGP peers";
728 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
729 str
= "Invalid limit for number of dynamic neighbors";
731 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
732 str
= "Dynamic neighbor listen range already exists";
734 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
735 str
= "Operation not allowed on a dynamic neighbor";
737 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
738 str
= "Operation not allowed on a directly connected neighbor";
740 case BGP_ERR_PEER_SAFI_CONFLICT
:
743 case BGP_ERR_GR_INVALID_CMD
:
744 str
= "The Graceful Restart command used is not valid at this moment.";
746 case BGP_ERR_GR_OPERATION_FAILED
:
747 str
= "The Graceful Restart Operation failed due to an err.";
749 case BGP_GR_NO_OPERATION
:
752 case BGP_ERR_PEER_GROUP_MEMBER
:
753 str
= "Peer-group member cannot override remote-as of peer-group";
755 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
756 str
= "Peer-group members must be all internal or all external";
760 snprintf(errmsg
, errmsg_len
, "%s", str
);
767 int bgp_vty_return(struct vty
*vty
, int ret
)
769 const char *str
= NULL
;
772 case BGP_ERR_INVALID_VALUE
:
773 str
= "Invalid value";
775 case BGP_ERR_INVALID_FLAG
:
776 str
= "Invalid flag";
778 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
779 str
= "Peer-group has been shutdown. Activate the peer-group first";
781 case BGP_ERR_PEER_FLAG_CONFLICT
:
782 str
= "Can't set override-capability and strict-capability-match at the same time";
784 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
785 str
= "Specify remote-as or peer-group remote AS first";
787 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
788 str
= "Cannot change the peer-group. Deconfigure first";
790 case BGP_ERR_PEER_GROUP_MISMATCH
:
791 str
= "Peer is not a member of this peer-group";
793 case BGP_ERR_PEER_FILTER_CONFLICT
:
794 str
= "Prefix/distribute list can not co-exist";
796 case BGP_ERR_NOT_INTERNAL_PEER
:
797 str
= "Invalid command. Not an internal neighbor";
799 case BGP_ERR_REMOVE_PRIVATE_AS
:
800 str
= "remove-private-AS cannot be configured for IBGP peers";
802 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
803 str
= "Local-AS allowed only for EBGP peers";
805 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
806 str
= "Cannot have local-as same as BGP AS number";
808 case BGP_ERR_TCPSIG_FAILED
:
809 str
= "Error while applying TCP-Sig to session(s)";
811 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
812 str
= "ebgp-multihop and ttl-security cannot be configured together";
814 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
815 str
= "ttl-security only allowed for EBGP peers";
817 case BGP_ERR_AS_OVERRIDE
:
818 str
= "as-override cannot be configured for IBGP peers";
820 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
821 str
= "Invalid limit for number of dynamic neighbors";
823 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
824 str
= "Dynamic neighbor listen range already exists";
826 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
827 str
= "Operation not allowed on a dynamic neighbor";
829 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
830 str
= "Operation not allowed on a directly connected neighbor";
832 case BGP_ERR_PEER_SAFI_CONFLICT
:
835 case BGP_ERR_GR_INVALID_CMD
:
836 str
= "The Graceful Restart command used is not valid at this moment.";
838 case BGP_ERR_GR_OPERATION_FAILED
:
839 str
= "The Graceful Restart Operation failed due to an err.";
841 case BGP_GR_NO_OPERATION
:
846 vty_out(vty
, "%% %s\n", str
);
847 return CMD_WARNING_CONFIG_FAILED
;
852 /* BGP clear sort. */
861 static void bgp_clear_vty_error(struct peer
*peer
, afi_t afi
, safi_t safi
,
862 int error
, char *errmsg
, size_t errmsg_len
)
865 case BGP_ERR_AF_UNCONFIGURED
:
866 snprintf(errmsg
, errmsg_len
,
867 "%%BGP: Enable %s address family for the neighbor %s",
868 get_afi_safi_str(afi
, safi
, false), peer
->host
);
870 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
873 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig",
881 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
882 struct listnode
**nnode
, enum bgp_clear_type stype
)
887 /* if afi/.safi not specified, spin thru all of them */
888 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
892 FOREACH_AFI_SAFI (tmp_afi
, tmp_safi
) {
893 paf
= peer_af_find(peer
, tmp_afi
, tmp_safi
);
894 if (paf
&& paf
->subgroup
)
895 SET_FLAG(paf
->subgroup
->sflags
,
896 SUBGRP_STATUS_FORCE_UPDATES
);
898 if (!peer
->afc
[tmp_afi
][tmp_safi
])
901 if (stype
== BGP_CLEAR_SOFT_NONE
)
902 ret
= peer_clear(peer
, nnode
);
904 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
907 /* if afi specified and safi not, spin thru safis on this afi */
908 } else if (safi
== SAFI_UNSPEC
) {
911 for (tmp_safi
= SAFI_UNICAST
;
912 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
913 if (!peer
->afc
[afi
][tmp_safi
])
916 paf
= peer_af_find(peer
, afi
, tmp_safi
);
917 if (paf
&& paf
->subgroup
)
918 SET_FLAG(paf
->subgroup
->sflags
,
919 SUBGRP_STATUS_FORCE_UPDATES
);
921 if (stype
== BGP_CLEAR_SOFT_NONE
)
922 ret
= peer_clear(peer
, nnode
);
924 ret
= peer_clear_soft(peer
, afi
,
927 /* both afi/safi specified, let the caller know if not defined */
929 if (!peer
->afc
[afi
][safi
])
932 paf
= peer_af_find(peer
, afi
, safi
);
933 if (paf
&& paf
->subgroup
)
934 SET_FLAG(paf
->subgroup
->sflags
,
935 SUBGRP_STATUS_FORCE_UPDATES
);
937 if (stype
== BGP_CLEAR_SOFT_NONE
)
938 ret
= peer_clear(peer
, nnode
);
940 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
946 /* `clear ip bgp' functions. */
947 static int bgp_clear(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
948 enum clear_sort sort
, enum bgp_clear_type stype
,
949 const char *arg
, char *errmsg
, size_t errmsg_len
)
955 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
957 /* Clear all neighbors. */
959 * Pass along pointer to next node to peer_clear() when walking all
960 * nodes on the BGP instance as that may get freed if it is a
963 if (sort
== clear_all
) {
964 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
966 bgp_peer_gr_flags_update(peer
);
968 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
969 gr_router_detected
= true;
971 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
975 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
979 if (gr_router_detected
980 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
981 bgp_zebra_send_capabilities(bgp
, false);
982 } else if (!gr_router_detected
983 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
984 bgp_zebra_send_capabilities(bgp
, true);
987 /* This is to apply read-only mode on this clear. */
988 if (stype
== BGP_CLEAR_SOFT_NONE
)
989 bgp
->update_delay_over
= 0;
994 /* Clear specified neighbor. */
995 if (sort
== clear_peer
) {
998 /* Make sockunion for lookup. */
999 ret
= str2sockunion(arg
, &su
);
1001 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1003 peer
= peer_lookup_by_hostname(bgp
, arg
);
1007 "Malformed address or name: %s",
1013 peer
= peer_lookup(bgp
, &su
);
1015 snprintf(errmsg
, errmsg_len
,
1016 "%%BGP: Unknown neighbor - \"%s\"",
1022 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1023 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1025 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1027 /* if afi/safi not defined for this peer, let caller know */
1029 ret
= BGP_ERR_AF_UNCONFIGURED
;
1032 bgp_clear_vty_error(peer
, afi
, safi
, ret
, errmsg
,
1038 /* Clear all neighbors belonging to a specific peer-group. */
1039 if (sort
== clear_group
) {
1040 struct peer_group
*group
;
1042 group
= peer_group_lookup(bgp
, arg
);
1044 snprintf(errmsg
, errmsg_len
,
1045 "%%BGP: No such peer-group %s", arg
);
1049 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1050 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1053 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1054 errmsg
, errmsg_len
);
1062 "%%BGP: No %s peer belonging to peer-group %s is configured",
1063 get_afi_safi_str(afi
, safi
, false), arg
);
1068 /* Clear all external (eBGP) neighbors. */
1069 if (sort
== clear_external
) {
1070 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1071 if (peer
->sort
== BGP_PEER_IBGP
)
1074 bgp_peer_gr_flags_update(peer
);
1076 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1077 gr_router_detected
= true;
1079 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1082 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1083 errmsg
, errmsg_len
);
1088 if (gr_router_detected
1089 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1090 bgp_zebra_send_capabilities(bgp
, false);
1091 } else if (!gr_router_detected
1092 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1093 bgp_zebra_send_capabilities(bgp
, true);
1097 snprintf(errmsg
, errmsg_len
,
1098 "%%BGP: No external %s peer is configured",
1099 get_afi_safi_str(afi
, safi
, false));
1104 /* Clear all neighbors belonging to a specific AS. */
1105 if (sort
== clear_as
) {
1106 as_t as
= strtoul(arg
, NULL
, 10);
1108 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1112 bgp_peer_gr_flags_update(peer
);
1114 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1115 gr_router_detected
= true;
1117 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1120 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1121 errmsg
, errmsg_len
);
1126 if (gr_router_detected
1127 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1128 bgp_zebra_send_capabilities(bgp
, false);
1129 } else if (!gr_router_detected
1130 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1131 bgp_zebra_send_capabilities(bgp
, true);
1135 snprintf(errmsg
, errmsg_len
,
1136 "%%BGP: No %s peer is configured with AS %s",
1137 get_afi_safi_str(afi
, safi
, false), arg
);
1145 static int bgp_clear_vty(const char *name
, afi_t afi
, safi_t safi
,
1146 enum clear_sort sort
, enum bgp_clear_type stype
,
1147 const char *arg
, char *errmsg
, size_t errmsg_len
)
1151 /* BGP structure lookup. */
1153 bgp
= bgp_lookup_by_name(name
);
1155 snprintf(errmsg
, errmsg_len
,
1156 "Can't find BGP instance %s", name
);
1160 bgp
= bgp_get_default();
1162 snprintf(errmsg
, errmsg_len
,
1163 "No BGP process is configured");
1168 return bgp_clear(bgp
, afi
, safi
, sort
, stype
, arg
, errmsg
, errmsg_len
);
1171 /* clear soft inbound */
1172 int bgp_clear_star_soft_in(const char *name
, char *errmsg
, size_t errmsg_len
)
1178 FOREACH_AFI_SAFI (afi
, safi
) {
1179 ret
= bgp_clear_vty(name
, afi
, safi
, clear_all
,
1180 BGP_CLEAR_SOFT_IN
, NULL
, errmsg
,
1182 if (ret
!= CMD_SUCCESS
)
1189 /* clear soft outbound */
1190 int bgp_clear_star_soft_out(const char *name
, char *errmsg
, size_t errmsg_len
)
1196 FOREACH_AFI_SAFI (afi
, safi
) {
1197 ret
= bgp_clear_vty(name
, afi
, safi
, clear_all
,
1198 BGP_CLEAR_SOFT_OUT
, NULL
, errmsg
,
1200 if (ret
!= CMD_SUCCESS
)
1208 #ifndef VTYSH_EXTRACT_PL
1209 #include "bgpd/bgp_vty_clippy.c"
1212 DEFUN_HIDDEN (bgp_local_mac
,
1214 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1216 "Local MAC config\n"
1217 "VxLAN Network Identifier\n"
1221 "mac-mobility sequence\n"
1231 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1232 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1233 vty_out(vty
, "%% Malformed MAC address\n");
1236 memset(&ip
, 0, sizeof(ip
));
1237 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1239 bgp
= bgp_get_default();
1241 vty_out(vty
, "Default BGP instance is not there\n");
1245 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1248 vty_out(vty
, "Internal error\n");
1255 DEFUN_HIDDEN (no_bgp_local_mac
,
1256 no_bgp_local_mac_cmd
,
1257 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1260 "Local MAC config\n"
1261 "VxLAN Network Identifier\n"
1272 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1273 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1274 vty_out(vty
, "%% Malformed MAC address\n");
1277 memset(&ip
, 0, sizeof(ip
));
1279 bgp
= bgp_get_default();
1281 vty_out(vty
, "Default BGP instance is not there\n");
1285 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1287 vty_out(vty
, "Internal error\n");
1294 DEFUN (no_synchronization
,
1295 no_synchronization_cmd
,
1296 "no synchronization",
1298 "Perform IGP synchronization\n")
1303 DEFUN (no_auto_summary
,
1304 no_auto_summary_cmd
,
1307 "Enable automatic network number summarization\n")
1312 /* "router bgp" commands. */
1313 DEFUN_YANG_NOSH(router_bgp
,
1315 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1316 ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR
)
1319 int idx_view_vrf
= 3;
1321 int ret
= CMD_SUCCESS
;
1324 const char *name
= NULL
;
1325 char as_str
[12] = {'\0'};
1326 enum bgp_instance_type inst_type
;
1327 char base_xpath
[XPATH_MAXLEN
];
1329 // "router bgp" without an ASN
1331 // Pending: Make VRF option available for ASN less config
1332 bgp
= bgp_get_default();
1335 vty_out(vty
, "%% No BGP process is configured\n");
1336 return CMD_WARNING_CONFIG_FAILED
;
1339 if (listcount(bm
->bgp
) > 1) {
1340 vty_out(vty
, "%% Please specify ASN and VRF\n");
1341 return CMD_WARNING_CONFIG_FAILED
;
1344 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1345 "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME
);
1347 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
1348 snprintf(as_str
, 12, "%d", bgp
->as
);
1349 nb_cli_enqueue_change(vty
, "./global/local-as", NB_OP_MODIFY
,
1351 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
) {
1352 nb_cli_enqueue_change(vty
,
1353 "./global/instance-type-view",
1354 NB_OP_MODIFY
, "true");
1357 nb_cli_pending_commit_check(vty
);
1358 ret
= nb_cli_apply_changes(vty
, base_xpath
);
1359 if (ret
== CMD_SUCCESS
) {
1360 VTY_PUSH_XPATH(BGP_NODE
, base_xpath
);
1363 * For backward compatibility with old commands we still
1364 * need to use the qobj infrastructure.
1366 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1374 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1375 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1377 name
= argv
[idx_vrf
]->arg
;
1379 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1380 if (strmatch(name
, VRF_DEFAULT_NAME
))
1383 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1384 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view")) {
1385 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1388 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1389 "frr-bgp:bgp", "bgp", name
? name
: VRF_DEFAULT_NAME
);
1391 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
1392 nb_cli_enqueue_change(vty
, "./global/local-as", NB_OP_MODIFY
,
1393 argv
[idx_asn
]->arg
);
1394 if (inst_type
== BGP_INSTANCE_TYPE_VIEW
) {
1395 nb_cli_enqueue_change(vty
,
1396 "./global/instance-type-view",
1397 NB_OP_MODIFY
, "true");
1400 nb_cli_pending_commit_check(vty
);
1401 ret
= nb_cli_apply_changes(vty
, base_xpath
);
1402 if (ret
== CMD_SUCCESS
) {
1403 VTY_PUSH_XPATH(BGP_NODE
, base_xpath
);
1406 * For backward compatibility with old commands we still
1407 * need to use the qobj infrastructure.
1409 bgp
= bgp_lookup(as
, name
);
1411 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1418 /* "no router bgp" commands. */
1419 DEFUN_YANG(no_router_bgp
,
1421 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1422 NO_STR ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR
)
1428 const char *name
= NULL
;
1429 char base_xpath
[XPATH_MAXLEN
];
1430 const struct lyd_node
*bgp_glb_dnode
;
1432 // "no router bgp" without an ASN
1434 // Pending: Make VRF option available for ASN less config
1435 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1436 "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME
);
1438 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
1440 if (!bgp_glb_dnode
) {
1441 vty_out(vty
, "%% No BGP process is configured\n");
1442 return CMD_WARNING_CONFIG_FAILED
;
1445 if (listcount(bm
->bgp
) > 1) {
1446 vty_out(vty
, "%% Please specify ASN and VRF\n");
1447 return CMD_WARNING_CONFIG_FAILED
;
1450 /* tcli mode bgp would not be set until apply stage. */
1451 bgp
= nb_running_get_entry(bgp_glb_dnode
, NULL
, false);
1456 vty_out(vty
, "%% Please unconfigure l3vni %u",
1458 return CMD_WARNING_CONFIG_FAILED
;
1461 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1464 name
= argv
[idx_vrf
]->arg
;
1466 /* Lookup bgp structure. */
1467 bgp
= bgp_lookup(as
, name
);
1469 vty_out(vty
, "%% Can't find BGP instance\n");
1470 return CMD_WARNING_CONFIG_FAILED
;
1474 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1476 return CMD_WARNING_CONFIG_FAILED
;
1479 /* Cannot delete default instance if vrf instances exist */
1480 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1481 struct listnode
*node
;
1482 struct bgp
*tmp_bgp
;
1484 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1485 if (tmp_bgp
->inst_type
1486 == BGP_INSTANCE_TYPE_VRF
) {
1488 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1489 return CMD_WARNING_CONFIG_FAILED
;
1494 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1495 "frr-bgp:bgp", "bgp",
1496 bgp
->name
? bgp
->name
: VRF_DEFAULT_NAME
);
1498 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
1500 return nb_cli_apply_changes(vty
, base_xpath
);
1503 void cli_show_router_bgp(struct vty
*vty
, struct lyd_node
*dnode
,
1506 const struct lyd_node
*vrf_dnode
;
1507 const char *vrf_name
;
1510 vrf_dnode
= yang_dnode_get_parent(dnode
, "control-plane-protocol");
1511 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
1512 as
= yang_dnode_get_uint32(dnode
, "./global/local-as");
1514 vty_out(vty
, "!\n");
1515 vty_out(vty
, "router bgp %u", as
);
1516 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
))
1517 vty_out(vty
, " vrf %s", vrf_name
);
1521 /* BGP router-id. */
1523 DEFPY_YANG(bgp_router_id
, bgp_router_id_cmd
, "bgp router-id A.B.C.D",
1525 "Override configured router identifier\n"
1526 "Manually configured router identifier\n")
1528 nb_cli_enqueue_change(vty
, "./global/router-id", NB_OP_MODIFY
,
1531 return nb_cli_apply_changes(vty
, NULL
);
1534 DEFPY_YANG(no_bgp_router_id
, no_bgp_router_id_cmd
, "no bgp router-id [A.B.C.D]",
1536 "Override configured router identifier\n"
1537 "Manually configured router identifier\n")
1539 nb_cli_enqueue_change(vty
, "./global/router-id", NB_OP_DESTROY
,
1540 router_id_str
? router_id_str
: NULL
);
1542 return nb_cli_apply_changes(vty
, NULL
);
1545 void cli_show_router_bgp_router_id(struct vty
*vty
, struct lyd_node
*dnode
,
1548 vty_out(vty
, " bgp router-id %s\n", yang_dnode_get_string(dnode
, NULL
));
1551 DEFPY (bgp_global_suppress_fib_pending
,
1552 bgp_global_suppress_fib_pending_cmd
,
1553 "[no] bgp suppress-fib-pending",
1556 "Advertise only routes that are programmed in kernel to peers globally\n")
1558 bm_wait_for_fib_set(!no
);
1563 DEFPY (bgp_suppress_fib_pending
,
1564 bgp_suppress_fib_pending_cmd
,
1565 "[no] bgp suppress-fib-pending",
1568 "Advertise only routes that are programmed in kernel to peers\n")
1570 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1572 bgp_suppress_fib_pending_set(bgp
, !no
);
1577 /* BGP Cluster ID. */
1578 DEFUN_YANG(bgp_cluster_id
,
1580 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1582 "Configure Route-Reflector Cluster-id\n"
1583 "Route-Reflector Cluster-id in IP address format\n"
1584 "Route-Reflector Cluster-id as 32 bit quantity\n")
1588 nb_cli_enqueue_change(
1589 vty
, "./global/route-reflector/route-reflector-cluster-id",
1590 NB_OP_MODIFY
, argv
[idx_ipv4
]->arg
);
1592 return nb_cli_apply_changes(vty
, NULL
);
1595 DEFUN_YANG(no_bgp_cluster_id
,
1596 no_bgp_cluster_id_cmd
,
1597 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1599 "Configure Route-Reflector Cluster-id\n"
1600 "Route-Reflector Cluster-id in IP address format\n"
1601 "Route-Reflector Cluster-id as 32 bit quantity\n")
1603 nb_cli_enqueue_change(
1604 vty
, "./global/route-reflector/route-reflector-cluster-id",
1605 NB_OP_DESTROY
, NULL
);
1607 return nb_cli_apply_changes(vty
, NULL
);
1614 "Disable BGP route installation to RIB (Zebra)\n")
1616 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1618 "%% No-RIB option is already set, nothing to do here.\n");
1622 bgp_option_norib_set_runtime();
1627 DEFPY (no_bgp_norib
,
1632 "Disable BGP route installation to RIB (Zebra)\n")
1634 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1636 "%% No-RIB option is not set, nothing to do here.\n");
1640 bgp_option_norib_unset_runtime();
1645 DEFPY (no_bgp_send_extra_data
,
1646 no_bgp_send_extra_data_cmd
,
1647 "[no] bgp send-extra-data zebra",
1650 "Extra data to Zebra for display/use\n"
1654 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1656 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1661 DEFUN_YANG(bgp_confederation_identifier
,
1662 bgp_confederation_identifier_cmd
,
1663 "bgp confederation identifier (1-4294967295)",
1664 "BGP specific commands\n"
1665 "AS confederation parameters\n"
1667 "Set routing domain confederation AS\n")
1671 nb_cli_enqueue_change(vty
, "./global/confederation/identifier",
1672 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
1674 return nb_cli_apply_changes(vty
, NULL
);
1677 DEFUN_YANG(no_bgp_confederation_identifier
,
1678 no_bgp_confederation_identifier_cmd
,
1679 "no bgp confederation identifier [(1-4294967295)]",
1681 "BGP specific commands\n"
1682 "AS confederation parameters\n"
1684 "Set routing domain confederation AS\n")
1686 nb_cli_enqueue_change(vty
, "./global/confederation/identifier",
1687 NB_OP_DESTROY
, NULL
);
1689 return nb_cli_apply_changes(vty
, NULL
);
1692 void cli_show_router_bgp_confederation_identifier(struct vty
*vty
,
1693 struct lyd_node
*dnode
,
1696 vty_out(vty
, " bgp confederation identifier %u\n",
1697 yang_dnode_get_uint32(dnode
, NULL
));
1700 DEFUN_YANG(bgp_confederation_peers
,
1701 bgp_confederation_peers_cmd
,
1702 "bgp confederation peers (1-4294967295)...",
1703 "BGP specific commands\n"
1704 "AS confederation parameters\n"
1705 "Peer ASs in BGP confederation\n" AS_STR
)
1710 for (i
= idx_asn
; i
< argc
; i
++)
1711 nb_cli_enqueue_change(vty
, "./global/confederation/member-as",
1712 NB_OP_CREATE
, argv
[i
]->arg
);
1714 return nb_cli_apply_changes(vty
, NULL
);
1717 DEFUN_YANG(no_bgp_confederation_peers
,
1718 no_bgp_confederation_peers_cmd
,
1719 "no bgp confederation peers (1-4294967295)...",
1721 "BGP specific commands\n"
1722 "AS confederation parameters\n"
1723 "Peer ASs in BGP confederation\n" AS_STR
)
1728 for (i
= idx_asn
; i
< argc
; i
++)
1729 nb_cli_enqueue_change(vty
, "./global/confederation/member-as",
1730 NB_OP_DESTROY
, argv
[i
]->arg
);
1732 return nb_cli_apply_changes(vty
, NULL
);
1735 void cli_show_router_bgp_confederation_member_as(struct vty
*vty
,
1736 struct lyd_node
*dnode
,
1739 vty_out(vty
, " bgp confederation peers %u \n",
1740 yang_dnode_get_uint32(dnode
, NULL
));
1744 * Central routine for maximum-paths configuration.
1745 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1746 * @set: 1 for setting values, 0 for removing the max-paths config.
1748 int bgp_maxpaths_config_vty(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1749 int peer_type
, uint16_t maxpaths
, uint16_t options
,
1750 int set
, char *errmsg
, size_t errmsg_len
)
1755 if (maxpaths
> multipath_num
) {
1758 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1759 maxpaths
, multipath_num
);
1760 return CMD_WARNING_CONFIG_FAILED
;
1762 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1765 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1770 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1771 (set
== 1) ? "" : "un",
1772 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1773 maxpaths
, afi
, safi
);
1774 return CMD_WARNING_CONFIG_FAILED
;
1777 bgp_recalculate_all_bestpaths(bgp
);
1782 void cli_show_router_bgp_med_config(struct vty
*vty
, struct lyd_node
*dnode
,
1785 if (yang_dnode_get_bool(dnode
, "./enable-med-admin")) {
1786 uint32_t med_admin_val
;
1788 vty_out(vty
, " bgp max-med administrative");
1789 if ((med_admin_val
=
1790 yang_dnode_get_uint32(dnode
, "./max-med-admin"))
1791 != BGP_MAXMED_VALUE_DEFAULT
)
1792 vty_out(vty
, " %u", med_admin_val
);
1796 if (yang_dnode_exists(dnode
, "./max-med-onstart-up-time")) {
1797 uint32_t onstartup_val
;
1799 vty_out(vty
, " bgp max-med on-startup %u",
1800 yang_dnode_get_uint32(dnode
,
1801 "./max-med-onstart-up-time"));
1802 onstartup_val
= yang_dnode_get_uint32(
1803 dnode
, "./max-med-onstart-up-value");
1804 if (onstartup_val
!= BGP_MAXMED_VALUE_DEFAULT
)
1805 vty_out(vty
, " %u", onstartup_val
);
1811 DEFUN_YANG(bgp_maxmed_admin
,
1812 bgp_maxmed_admin_cmd
,
1813 "bgp max-med administrative ",
1815 "Advertise routes with max-med\n"
1816 "Administratively applied, for an indefinite period\n")
1818 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1819 NB_OP_MODIFY
, "true");
1821 return nb_cli_apply_changes(vty
, NULL
);
1824 DEFUN_YANG(bgp_maxmed_admin_medv
,
1825 bgp_maxmed_admin_medv_cmd
,
1826 "bgp max-med administrative (0-4294967295)",
1828 "Advertise routes with max-med\n"
1829 "Administratively applied, for an indefinite period\n"
1830 "Max MED value to be used\n")
1834 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1835 NB_OP_MODIFY
, "true");
1837 nb_cli_enqueue_change(vty
, "./global/med-config/max-med-admin",
1838 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
1840 return nb_cli_apply_changes(vty
, NULL
);
1843 DEFUN_YANG(no_bgp_maxmed_admin
,
1844 no_bgp_maxmed_admin_cmd
,
1845 "no bgp max-med administrative [(0-4294967295)]",
1847 "Advertise routes with max-med\n"
1848 "Administratively applied, for an indefinite period\n"
1849 "Max MED value to be used\n")
1851 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1852 NB_OP_MODIFY
, "false");
1854 nb_cli_enqueue_change(vty
, "./global/med-config/max-med-admin",
1855 NB_OP_MODIFY
, NULL
);
1857 return nb_cli_apply_changes(vty
, NULL
);
1860 DEFUN_YANG (bgp_maxmed_onstartup
,
1861 bgp_maxmed_onstartup_cmd
,
1862 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1864 "Advertise routes with max-med\n"
1865 "Effective on a startup\n"
1866 "Time (seconds) period for max-med\n"
1867 "Max MED value to be used\n")
1871 argv_find(argv
, argc
, "(5-86400)", &idx
);
1872 nb_cli_enqueue_change(vty
,
1873 "./global/med-config/max-med-onstart-up-time",
1874 NB_OP_MODIFY
, argv
[idx
]->arg
);
1876 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1877 nb_cli_enqueue_change(
1878 vty
, "./global/med-config/max-med-onstart-up-value",
1879 NB_OP_MODIFY
, argv
[idx
]->arg
);
1881 nb_cli_enqueue_change(
1882 vty
, "./global/med-config/max-med-onstart-up-value",
1883 NB_OP_MODIFY
, NULL
);
1885 return nb_cli_apply_changes(vty
, NULL
);
1888 DEFUN_YANG (no_bgp_maxmed_onstartup
,
1889 no_bgp_maxmed_onstartup_cmd
,
1890 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1892 "Advertise routes with max-med\n"
1893 "Effective on a startup\n"
1894 "Time (seconds) period for max-med\n"
1895 "Max MED value to be used\n")
1897 nb_cli_enqueue_change(vty
,
1898 "./global/med-config/max-med-onstart-up-time",
1899 NB_OP_DESTROY
, NULL
);
1901 nb_cli_enqueue_change(vty
,
1902 "./global/med-config/max-med-onstart-up-value",
1903 NB_OP_MODIFY
, NULL
);
1905 return nb_cli_apply_changes(vty
, NULL
);
1908 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
1909 uint16_t update_delay
,
1910 uint16_t establish_wait
)
1912 struct listnode
*node
, *nnode
;
1914 bool vrf_cfg
= false;
1917 * See if update-delay is set per-vrf and warn user to delete it
1918 * Note that we only need to check this if this is the first time
1919 * setting the global config.
1921 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
1922 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1923 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1925 "%% update-delay configuration found in vrf %s\n",
1926 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
1936 "%%Failed: global update-delay config not permitted\n");
1940 if (!establish_wait
) { /* update-delay <delay> */
1941 bm
->v_update_delay
= update_delay
;
1942 bm
->v_establish_wait
= bm
->v_update_delay
;
1944 /* update-delay <delay> <establish-wait> */
1945 if (update_delay
< establish_wait
) {
1947 "%%Failed: update-delay less than the establish-wait!\n");
1948 return CMD_WARNING_CONFIG_FAILED
;
1951 bm
->v_update_delay
= update_delay
;
1952 bm
->v_establish_wait
= establish_wait
;
1955 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1956 bgp
->v_update_delay
= bm
->v_update_delay
;
1957 bgp
->v_establish_wait
= bm
->v_establish_wait
;
1963 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
1965 struct listnode
*node
, *nnode
;
1968 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1969 bm
->v_establish_wait
= bm
->v_update_delay
;
1971 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1972 bgp
->v_update_delay
= bm
->v_update_delay
;
1973 bgp
->v_establish_wait
= bm
->v_establish_wait
;
1979 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
1980 uint16_t establish_wait
)
1982 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1984 /* if configured globally, per-instance config is not allowed */
1985 if (bm
->v_update_delay
) {
1987 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
1988 return CMD_WARNING_CONFIG_FAILED
;
1992 if (!establish_wait
) /* update-delay <delay> */
1994 bgp
->v_update_delay
= update_delay
;
1995 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1999 /* update-delay <delay> <establish-wait> */
2000 if (update_delay
< establish_wait
) {
2002 "%%Failed: update-delay less than the establish-wait!\n");
2003 return CMD_WARNING_CONFIG_FAILED
;
2006 bgp
->v_update_delay
= update_delay
;
2007 bgp
->v_establish_wait
= establish_wait
;
2012 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2014 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2016 /* If configured globally, cannot remove from one bgp instance */
2017 if (bm
->v_update_delay
) {
2019 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2020 return CMD_WARNING_CONFIG_FAILED
;
2022 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2023 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2028 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2030 /* If configured globally, no need to display per-instance value */
2031 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2032 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2033 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2034 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2039 /* Global update-delay configuration */
2040 DEFPY (bgp_global_update_delay
,
2041 bgp_global_update_delay_cmd
,
2042 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2044 "Force initial delay for best-path and updates for all bgp instances\n"
2045 "Max delay in seconds\n"
2046 "Establish wait in seconds\n")
2048 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2051 /* Global update-delay deconfiguration */
2052 DEFPY (no_bgp_global_update_delay
,
2053 no_bgp_global_update_delay_cmd
,
2054 "no bgp update-delay [(0-3600) [(1-3600)]]",
2057 "Force initial delay for best-path and updates\n"
2058 "Max delay in seconds\n"
2059 "Establish wait in seconds\n")
2061 return bgp_global_update_delay_deconfig_vty(vty
);
2064 /* Update-delay configuration */
2066 DEFPY (bgp_update_delay
,
2067 bgp_update_delay_cmd
,
2068 "update-delay (0-3600)$delay [(1-3600)$wait]",
2069 "Force initial delay for best-path and updates\n"
2070 "Max delay in seconds\n"
2071 "Establish wait in seconds\n")
2073 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2076 /* Update-delay deconfiguration */
2077 DEFPY (no_bgp_update_delay
,
2078 no_bgp_update_delay_cmd
,
2079 "no update-delay [(0-3600) [(1-3600)]]",
2081 "Force initial delay for best-path and updates\n"
2082 "Max delay in seconds\n"
2083 "Establish wait in seconds\n")
2085 return bgp_update_delay_deconfig_vty(vty
);
2089 int bgp_wpkt_quanta_config_vty(struct bgp
*bgp
, uint32_t quanta
, bool set
)
2091 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2092 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2097 int bgp_rpkt_quanta_config_vty(struct bgp
*bgp
, uint32_t quanta
, bool set
)
2099 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2100 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2105 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2108 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2109 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2110 vty_out(vty
, " write-quanta %d\n", quanta
);
2113 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2116 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2117 if (quanta
!= BGP_READ_PACKET_MAX
)
2118 vty_out(vty
, " read-quanta %d\n", quanta
);
2121 /* Packet quanta configuration
2123 * XXX: The value set here controls the size of a stack buffer in the IO
2124 * thread. When changing these limits be careful to prevent stack overflow.
2126 * Furthermore, the maximums used here should correspond to
2127 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2129 DEFPY_YANG (bgp_wpkt_quanta
,
2130 bgp_wpkt_quanta_cmd
,
2131 "[no] write-quanta (1-64)$quanta",
2133 "How many packets to write to peer socket per run\n"
2134 "Number of packets\n")
2137 nb_cli_enqueue_change(
2139 "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta",
2140 NB_OP_MODIFY
, quanta_str
);
2142 nb_cli_enqueue_change(
2144 "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta",
2145 NB_OP_MODIFY
, NULL
);
2147 return nb_cli_apply_changes(vty
, NULL
);
2150 DEFPY_YANG (bgp_rpkt_quanta
,
2151 bgp_rpkt_quanta_cmd
,
2152 "[no] read-quanta (1-10)$quanta",
2154 "How many packets to read from peer socket per I/O cycle\n"
2155 "Number of packets\n")
2158 nb_cli_enqueue_change(
2160 "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta",
2161 NB_OP_MODIFY
, quanta_str
);
2163 nb_cli_enqueue_change(
2165 "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta",
2166 NB_OP_MODIFY
, NULL
);
2168 return nb_cli_apply_changes(vty
, NULL
);
2171 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2173 if (!bgp
->heuristic_coalesce
)
2174 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2177 void cli_show_router_global_update_group_config_coalesce_time(
2178 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2180 vty_out(vty
, " coalesce-time %u\n", yang_dnode_get_uint32(dnode
, NULL
));
2184 DEFUN_YANG (bgp_coalesce_time
,
2185 bgp_coalesce_time_cmd
,
2186 "coalesce-time (0-4294967295)",
2187 "Subgroup coalesce timer\n"
2188 "Subgroup coalesce timer value (in ms)\n")
2192 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
2193 nb_cli_enqueue_change(
2194 vty
, "./global/global-update-group-config/coalesce-time",
2195 NB_OP_MODIFY
, argv
[idx
]->arg
);
2197 return nb_cli_apply_changes(vty
, NULL
);
2200 DEFUN_YANG(no_bgp_coalesce_time
,
2201 no_bgp_coalesce_time_cmd
,
2202 "no coalesce-time (0-4294967295)",
2204 "Subgroup coalesce timer\n"
2205 "Subgroup coalesce timer value (in ms)\n")
2207 nb_cli_enqueue_change(
2208 vty
, "./global/global-update-group-config/coalesce-time",
2209 NB_OP_MODIFY
, NULL
);
2211 return nb_cli_apply_changes(vty
, NULL
);
2214 /* Maximum-paths configuration */
2215 DEFUN_YANG (bgp_maxpaths
,
2217 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2218 "Forward packets over multiple paths\n"
2219 "Number of paths\n")
2222 char base_xpath
[XPATH_MAXLEN
];
2226 afi
= bgp_node_afi(vty
);
2227 safi
= bgp_node_safi(vty
);
2230 base_xpath
, sizeof(base_xpath
),
2231 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ebgp/maximum-paths",
2232 yang_afi_safi_value2identity(afi
, safi
),
2233 bgp_afi_safi_get_container_str(afi
, safi
));
2235 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2236 argv
[idx_number
]->arg
);
2238 return nb_cli_apply_changes(vty
, NULL
);
2241 void cli_show_bgp_global_afi_safi_unicast_use_multiple_paths_ebgp_maximum_paths(
2242 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2244 vty_out(vty
, " maximum-paths %d\n",
2245 yang_dnode_get_uint16(dnode
, NULL
));
2248 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2249 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2250 "Forward packets over multiple paths\n"
2251 "Number of paths\n")
2253 DEFUN_YANG (bgp_maxpaths_ibgp
,
2254 bgp_maxpaths_ibgp_cmd
,
2255 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2256 "Forward packets over multiple paths\n"
2258 "Number of paths\n")
2261 char base_xpath
[XPATH_MAXLEN
];
2265 afi
= bgp_node_afi(vty
);
2266 safi
= bgp_node_safi(vty
);
2269 base_xpath
, sizeof(base_xpath
),
2270 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2271 yang_afi_safi_value2identity(afi
, safi
),
2272 bgp_afi_safi_get_container_str(afi
, safi
));
2274 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2275 argv
[idx_number
]->arg
);
2277 return nb_cli_apply_changes(vty
, NULL
);
2280 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2281 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2282 "Forward packets over multiple paths\n"
2284 "Number of paths\n")
2286 DEFUN_YANG (bgp_maxpaths_ibgp_cluster
,
2287 bgp_maxpaths_ibgp_cluster_cmd
,
2288 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2289 "Forward packets over multiple paths\n"
2292 "Match the cluster length\n")
2295 char base_xpath
[XPATH_MAXLEN
];
2299 afi
= bgp_node_afi(vty
);
2300 safi
= bgp_node_safi(vty
);
2303 base_xpath
, sizeof(base_xpath
),
2304 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2305 yang_afi_safi_value2identity(afi
, safi
),
2306 bgp_afi_safi_get_container_str(afi
, safi
));
2308 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2309 argv
[idx_number
]->arg
);
2312 base_xpath
, sizeof(base_xpath
),
2313 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/cluster-length-list",
2314 yang_afi_safi_value2identity(afi
, safi
),
2315 bgp_afi_safi_get_container_str(afi
, safi
));
2317 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, "true");
2319 return nb_cli_apply_changes(vty
, NULL
);
2322 void cli_show_bgp_global_afi_safi_ip_unicast_use_multiple_paths_ibgp_maximum_paths(
2323 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2325 vty_out(vty
, " maximum-paths ibgp %d",
2326 yang_dnode_get_uint16(dnode
, "./maximum-paths"));
2327 if (yang_dnode_get_bool(dnode
, "./cluster-length-list"))
2328 vty_out(vty
, " equal-cluster-length");
2332 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2333 "maximum-paths ibgp " CMD_RANGE_STR(
2334 1, MULTIPATH_NUM
) " equal-cluster-length",
2335 "Forward packets over multiple paths\n"
2338 "Match the cluster length\n")
2340 DEFUN_YANG (no_bgp_maxpaths
,
2341 no_bgp_maxpaths_cmd
,
2342 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2344 "Forward packets over multiple paths\n"
2345 "Number of paths\n")
2347 char base_xpath
[XPATH_MAXLEN
];
2351 afi
= bgp_node_afi(vty
);
2352 safi
= bgp_node_safi(vty
);
2355 base_xpath
, sizeof(base_xpath
),
2356 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ebgp/maximum-paths",
2357 yang_afi_safi_value2identity(afi
, safi
),
2358 bgp_afi_safi_get_container_str(afi
, safi
));
2360 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, NULL
);
2362 return nb_cli_apply_changes(vty
, NULL
);
2365 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2366 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2367 "Forward packets over multiple paths\n"
2368 "Number of paths\n")
2370 DEFUN_YANG (no_bgp_maxpaths_ibgp
,
2371 no_bgp_maxpaths_ibgp_cmd
,
2372 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2374 "Forward packets over multiple paths\n"
2377 "Match the cluster length\n")
2379 char base_xpath
[XPATH_MAXLEN
];
2383 afi
= bgp_node_afi(vty
);
2384 safi
= bgp_node_safi(vty
);
2387 base_xpath
, sizeof(base_xpath
),
2388 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2389 yang_afi_safi_value2identity(afi
, safi
),
2390 bgp_afi_safi_get_container_str(afi
, safi
));
2392 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, NULL
);
2395 base_xpath
, sizeof(base_xpath
),
2396 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/cluster-length-list",
2397 yang_afi_safi_value2identity(afi
, safi
),
2398 bgp_afi_safi_get_container_str(afi
, safi
));
2400 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, "false");
2402 return nb_cli_apply_changes(vty
, NULL
);
2405 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2406 "no maximum-paths ibgp [" CMD_RANGE_STR(
2407 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2409 "Forward packets over multiple paths\n"
2412 "Match the cluster length\n")
2414 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2415 afi_t afi
, safi_t safi
)
2417 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2418 vty_out(vty
, " maximum-paths %d\n",
2419 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2422 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2423 vty_out(vty
, " maximum-paths ibgp %d",
2424 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2425 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
2426 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
2427 vty_out(vty
, " equal-cluster-length");
2434 DEFUN_YANG (bgp_timers
,
2436 "timers bgp (0-65535) (0-65535)",
2437 "Adjust routing timers\n"
2439 "Keepalive interval\n"
2443 int idx_number_2
= 3;
2445 nb_cli_enqueue_change(vty
, "./global/global-config-timers/keepalive",
2446 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
2447 nb_cli_enqueue_change(vty
, "./global/global-config-timers/hold-time",
2448 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
2450 return nb_cli_apply_changes(vty
, NULL
);
2453 DEFUN_YANG (no_bgp_timers
,
2455 "no timers bgp [(0-65535) (0-65535)]",
2457 "Adjust routing timers\n"
2459 "Keepalive interval\n"
2462 nb_cli_enqueue_change(vty
, "./global/global-config-timers/keepalive",
2463 NB_OP_DESTROY
, NULL
);
2464 nb_cli_enqueue_change(vty
, "./global/global-config-timers/hold-time",
2465 NB_OP_DESTROY
, NULL
);
2467 return nb_cli_apply_changes(vty
, NULL
);
2470 void cli_show_router_bgp_route_reflector(struct vty
*vty
,
2471 struct lyd_node
*dnode
,
2474 if (yang_dnode_get_bool(dnode
, "./no-client-reflect"))
2475 vty_out(vty
, " no bgp client-to-client reflection\n");
2477 if (yang_dnode_get_bool(dnode
, "./allow-outbound-policy"))
2478 vty_out(vty
, " bgp route-reflector allow-outbound-policy\n");
2480 if (yang_dnode_exists(dnode
, "./route-reflector-cluster-id"))
2481 vty_out(vty
, " bgp cluster-id %s\n",
2482 yang_dnode_get_string(dnode
,
2483 "./route-reflector-cluster-id"));
2486 DEFUN_YANG(bgp_client_to_client_reflection
,
2487 bgp_client_to_client_reflection_cmd
,
2488 "bgp client-to-client reflection",
2489 "BGP specific commands\n"
2490 "Configure client to client route reflection\n"
2491 "reflection of routes allowed\n")
2493 nb_cli_enqueue_change(vty
, "./global/route-reflector/no-client-reflect",
2494 NB_OP_MODIFY
, "false");
2496 return nb_cli_apply_changes(vty
, NULL
);
2499 DEFUN_YANG(no_bgp_client_to_client_reflection
,
2500 no_bgp_client_to_client_reflection_cmd
,
2501 "no bgp client-to-client reflection",
2503 "BGP specific commands\n"
2504 "Configure client to client route reflection\n"
2505 "reflection of routes allowed\n")
2507 nb_cli_enqueue_change(vty
, "./global/route-reflector/no-client-reflect",
2508 NB_OP_MODIFY
, "true");
2510 return nb_cli_apply_changes(vty
, NULL
);
2513 void cli_show_router_bgp_route_selection(struct vty
*vty
,
2514 struct lyd_node
*dnode
,
2518 if (yang_dnode_get_bool(dnode
, "./always-compare-med"))
2519 vty_out(vty
, " bgp always-compare-med\n");
2521 if (yang_dnode_get_bool(dnode
, "./ignore-as-path-length"))
2522 vty_out(vty
, " bgp bestpath as-path ignore\n");
2524 if (yang_dnode_get_bool(dnode
, "./aspath-confed"))
2525 vty_out(vty
, " bgp bestpath as-path confed\n");
2527 if (yang_dnode_get_bool(dnode
, "./external-compare-router-id"))
2528 vty_out(vty
, " bgp bestpath compare-routerid\n");
2530 if (yang_dnode_get_bool(dnode
, "./allow-multiple-as")) {
2531 if (yang_dnode_get_bool(dnode
, "./multi-path-as-set"))
2533 " bgp bestpath as-path multipath-relax as-set\n");
2535 vty_out(vty
, " bgp bestpath as-path multipath-relax\n");
2538 if (yang_dnode_get_bool(dnode
, "./deterministic-med"))
2539 vty_out(vty
, " bgp deterministic-med\n");
2541 if (yang_dnode_get_bool(dnode
, "./confed-med")
2542 || yang_dnode_get_bool(dnode
, "./missing-as-worst-med")) {
2543 vty_out(vty
, " bgp bestpath med");
2544 if (yang_dnode_get_bool(dnode
, "./confed-med"))
2545 vty_out(vty
, " confed");
2546 if (yang_dnode_get_bool(dnode
, "./missing-as-worst-med"))
2547 vty_out(vty
, " missing-as-worst");
2552 /* "bgp always-compare-med" configuration. */
2553 DEFUN_YANG(bgp_always_compare_med
,
2554 bgp_always_compare_med_cmd
,
2555 "bgp always-compare-med",
2556 "BGP specific commands\n"
2557 "Allow comparing MED from different neighbors\n")
2559 nb_cli_enqueue_change(
2560 vty
, "./global/route-selection-options/always-compare-med",
2561 NB_OP_MODIFY
, "true");
2563 return nb_cli_apply_changes(vty
, NULL
);
2566 DEFUN_YANG(no_bgp_always_compare_med
,
2567 no_bgp_always_compare_med_cmd
,
2568 "no bgp always-compare-med",
2570 "BGP specific commands\n"
2571 "Allow comparing MED from different neighbors\n")
2573 nb_cli_enqueue_change(
2574 vty
, "./global/route-selection-options/always-compare-med",
2575 NB_OP_MODIFY
, "false");
2577 return nb_cli_apply_changes(vty
, NULL
);
2580 DEFUN_YANG(bgp_suppress_duplicates
,
2581 bgp_suppress_duplicates_cmd
,
2582 "bgp suppress-duplicates",
2583 "BGP specific commands\n"
2584 "Suppress duplicate updates if the route actually not changed\n")
2586 nb_cli_enqueue_change(vty
, "./global/suppress-duplicates",
2587 NB_OP_MODIFY
, "true");
2588 return nb_cli_apply_changes(vty
, NULL
);
2591 DEFUN_YANG(no_bgp_suppress_duplicates
,
2592 no_bgp_suppress_duplicates_cmd
,
2593 "no bgp suppress-duplicates",
2595 "BGP specific commands\n"
2596 "Suppress duplicate updates if the route actually not changed\n")
2598 nb_cli_enqueue_change(vty
, "./global/suppress-duplicates",
2599 NB_OP_MODIFY
, "false");
2600 return nb_cli_apply_changes(vty
, NULL
);
2603 void cli_show_router_bgp_suppress_duplicates(struct vty
*vty
,
2604 struct lyd_node
*dnode
,
2607 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SUPPRESS_DUPLICATES
)
2608 vty_out(vty
, " bgp suppress-duplicates\n");
2611 DEFUN_YANG(bgp_ebgp_requires_policy
,
2612 bgp_ebgp_requires_policy_cmd
,
2613 "bgp ebgp-requires-policy",
2614 "BGP specific commands\n"
2615 "Require in and out policy for eBGP peers (RFC8212)\n")
2617 nb_cli_enqueue_change(vty
, "./global/ebgp-requires-policy",
2618 NB_OP_MODIFY
, "true");
2619 return nb_cli_apply_changes(vty
, NULL
);
2622 DEFUN_YANG(no_bgp_ebgp_requires_policy
,
2623 no_bgp_ebgp_requires_policy_cmd
,
2624 "no bgp ebgp-requires-policy",
2626 "BGP specific commands\n"
2627 "Require in and out policy for eBGP peers (RFC8212)\n")
2629 nb_cli_enqueue_change(vty
, "./global/ebgp-requires-policy",
2630 NB_OP_MODIFY
, "false");
2631 return nb_cli_apply_changes(vty
, NULL
);
2634 void cli_show_router_bgp_ebgp_requires_policy(struct vty
*vty
,
2635 struct lyd_node
*dnode
,
2638 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_EBGP_REQUIRES_POLICY
)
2639 vty_out(vty
, " bgp ebgp-requires-policy\n");
2642 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2643 "bgp reject-as-sets",
2644 "BGP specific commands\n"
2645 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2647 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2648 struct listnode
*node
, *nnode
;
2651 bgp
->reject_as_sets
= true;
2653 /* Reset existing BGP sessions to reject routes
2654 * with aspath containing AS_SET or AS_CONFED_SET.
2656 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2657 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2658 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2659 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2660 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2667 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2668 "no bgp reject-as-sets",
2670 "BGP specific commands\n"
2671 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2673 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2674 struct listnode
*node
, *nnode
;
2677 bgp
->reject_as_sets
= false;
2679 /* Reset existing BGP sessions to reject routes
2680 * with aspath containing AS_SET or AS_CONFED_SET.
2682 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2683 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2684 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2685 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2686 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2693 /* "bgp deterministic-med" configuration. */
2694 DEFUN_YANG (bgp_deterministic_med
,
2695 bgp_deterministic_med_cmd
,
2696 "bgp deterministic-med",
2697 "BGP specific commands\n"
2698 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2700 nb_cli_enqueue_change(
2701 vty
, "./global/route-selection-options/deterministic-med",
2702 NB_OP_MODIFY
, "true");
2704 return nb_cli_apply_changes(vty
, NULL
);
2707 DEFUN_YANG (no_bgp_deterministic_med
,
2708 no_bgp_deterministic_med_cmd
,
2709 "no bgp deterministic-med",
2711 "BGP specific commands\n"
2712 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2714 nb_cli_enqueue_change(
2715 vty
, "./global/route-selection-options/deterministic-med",
2716 NB_OP_MODIFY
, "false");
2718 return nb_cli_apply_changes(vty
, NULL
);
2721 /* "bgp graceful-restart mode" configuration. */
2722 DEFUN (bgp_graceful_restart
,
2723 bgp_graceful_restart_cmd
,
2724 "bgp graceful-restart",
2725 "BGP specific commands\n"
2729 int ret
= BGP_GR_FAILURE
;
2731 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2732 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2734 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2736 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2738 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2741 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2742 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2744 "Graceful restart configuration changed, reset all peers to take effect\n");
2745 return bgp_vty_return(vty
, ret
);
2748 DEFUN (no_bgp_graceful_restart
,
2749 no_bgp_graceful_restart_cmd
,
2750 "no bgp graceful-restart",
2752 "BGP specific commands\n"
2756 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2758 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2759 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2761 int ret
= BGP_GR_FAILURE
;
2763 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2765 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2768 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2769 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2771 "Graceful restart configuration changed, reset all peers to take effect\n");
2773 return bgp_vty_return(vty
, ret
);
2776 DEFUN (bgp_graceful_restart_stalepath_time
,
2777 bgp_graceful_restart_stalepath_time_cmd
,
2778 "bgp graceful-restart stalepath-time (1-4095)",
2779 "BGP specific commands\n"
2780 "Graceful restart capability parameters\n"
2781 "Set the max time to hold onto restarting peer's stale paths\n"
2782 "Delay value (seconds)\n")
2784 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2788 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2789 bgp
->stalepath_time
= stalepath
;
2793 DEFUN (bgp_graceful_restart_restart_time
,
2794 bgp_graceful_restart_restart_time_cmd
,
2795 "bgp graceful-restart restart-time (1-4095)",
2796 "BGP specific commands\n"
2797 "Graceful restart capability parameters\n"
2798 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2799 "Delay value (seconds)\n")
2801 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2805 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2806 bgp
->restart_time
= restart
;
2810 DEFUN (bgp_graceful_restart_select_defer_time
,
2811 bgp_graceful_restart_select_defer_time_cmd
,
2812 "bgp graceful-restart select-defer-time (0-3600)",
2813 "BGP specific commands\n"
2814 "Graceful restart capability parameters\n"
2815 "Set the time to defer the BGP route selection after restart\n"
2816 "Delay value (seconds, 0 - disable)\n")
2818 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2820 uint32_t defer_time
;
2822 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2823 bgp
->select_defer_time
= defer_time
;
2824 if (defer_time
== 0)
2825 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2827 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2832 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2833 no_bgp_graceful_restart_stalepath_time_cmd
,
2834 "no bgp graceful-restart stalepath-time [(1-4095)]",
2836 "BGP specific commands\n"
2837 "Graceful restart capability parameters\n"
2838 "Set the max time to hold onto restarting peer's stale paths\n"
2839 "Delay value (seconds)\n")
2841 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2843 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2847 DEFUN (no_bgp_graceful_restart_restart_time
,
2848 no_bgp_graceful_restart_restart_time_cmd
,
2849 "no bgp graceful-restart restart-time [(1-4095)]",
2851 "BGP specific commands\n"
2852 "Graceful restart capability parameters\n"
2853 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2854 "Delay value (seconds)\n")
2856 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2858 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2862 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2863 no_bgp_graceful_restart_select_defer_time_cmd
,
2864 "no bgp graceful-restart select-defer-time [(0-3600)]",
2866 "BGP specific commands\n"
2867 "Graceful restart capability parameters\n"
2868 "Set the time to defer the BGP route selection after restart\n"
2869 "Delay value (seconds)\n")
2871 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2873 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2874 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2879 DEFUN (bgp_graceful_restart_preserve_fw
,
2880 bgp_graceful_restart_preserve_fw_cmd
,
2881 "bgp graceful-restart preserve-fw-state",
2882 "BGP specific commands\n"
2883 "Graceful restart capability parameters\n"
2884 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2886 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2887 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2891 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2892 no_bgp_graceful_restart_preserve_fw_cmd
,
2893 "no bgp graceful-restart preserve-fw-state",
2895 "BGP specific commands\n"
2896 "Graceful restart capability parameters\n"
2897 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2899 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2900 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2904 DEFUN (bgp_graceful_restart_disable
,
2905 bgp_graceful_restart_disable_cmd
,
2906 "bgp graceful-restart-disable",
2907 "BGP specific commands\n"
2910 int ret
= BGP_GR_FAILURE
;
2912 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2914 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
2916 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2918 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
2920 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
2923 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2925 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
2927 "Graceful restart configuration changed, reset all peers to take effect\n");
2929 return bgp_vty_return(vty
, ret
);
2932 DEFUN (no_bgp_graceful_restart_disable
,
2933 no_bgp_graceful_restart_disable_cmd
,
2934 "no bgp graceful-restart-disable",
2936 "BGP specific commands\n"
2940 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2942 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2944 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
2946 int ret
= BGP_GR_FAILURE
;
2948 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
2950 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2953 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2955 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
2957 "Graceful restart configuration changed, reset all peers to take effect\n");
2959 return bgp_vty_return(vty
, ret
);
2962 DEFUN (bgp_neighbor_graceful_restart_set
,
2963 bgp_neighbor_graceful_restart_set_cmd
,
2964 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
2972 int ret
= BGP_GR_FAILURE
;
2974 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2976 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2978 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
2980 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2982 return CMD_WARNING_CONFIG_FAILED
;
2984 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
2986 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2987 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2989 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2991 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
2993 "Graceful restart configuration changed, reset this peer to take effect\n");
2995 return bgp_vty_return(vty
, ret
);
2998 DEFUN (no_bgp_neighbor_graceful_restart
,
2999 no_bgp_neighbor_graceful_restart_set_cmd
,
3000 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3008 int ret
= BGP_GR_FAILURE
;
3011 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3013 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3015 return CMD_WARNING_CONFIG_FAILED
;
3017 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3019 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3021 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
3023 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3024 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3026 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3028 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3030 "Graceful restart configuration changed, reset this peer to take effect\n");
3032 return bgp_vty_return(vty
, ret
);
3035 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3036 bgp_neighbor_graceful_restart_helper_set_cmd
,
3037 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3040 GR_NEIGHBOR_HELPER_CMD
3045 int ret
= BGP_GR_FAILURE
;
3047 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3049 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3051 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3053 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3056 return CMD_WARNING_CONFIG_FAILED
;
3059 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3061 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3062 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3064 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3066 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3068 "Graceful restart configuration changed, reset this peer to take effect\n");
3070 return bgp_vty_return(vty
, ret
);
3073 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3074 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3075 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3079 NO_GR_NEIGHBOR_HELPER_CMD
3083 int ret
= BGP_GR_FAILURE
;
3086 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3088 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3090 return CMD_WARNING_CONFIG_FAILED
;
3092 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3094 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3096 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3098 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3099 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3101 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3103 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3105 "Graceful restart configuration changed, reset this peer to take effect\n");
3107 return bgp_vty_return(vty
, ret
);
3110 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3111 bgp_neighbor_graceful_restart_disable_set_cmd
,
3112 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3115 GR_NEIGHBOR_DISABLE_CMD
3120 int ret
= BGP_GR_FAILURE
;
3122 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3124 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3126 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3128 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3130 return CMD_WARNING_CONFIG_FAILED
;
3132 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3134 if (peer
->bgp
->t_startup
)
3135 bgp_peer_gr_flags_update(peer
);
3137 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3138 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3140 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3142 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3144 "Graceful restart configuration changed, reset this peer to take effect\n");
3146 return bgp_vty_return(vty
, ret
);
3149 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3150 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3151 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3155 NO_GR_NEIGHBOR_DISABLE_CMD
3159 int ret
= BGP_GR_FAILURE
;
3162 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3164 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3166 return CMD_WARNING_CONFIG_FAILED
;
3168 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3170 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3172 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3174 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3175 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3177 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3179 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3181 "Graceful restart configuration changed, reset this peer to take effect\n");
3183 return bgp_vty_return(vty
, ret
);
3186 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3187 bgp_graceful_restart_disable_eor_cmd
,
3188 "bgp graceful-restart disable-eor",
3189 "BGP specific commands\n"
3190 "Graceful restart configuration parameters\n"
3191 "Disable EOR Check\n")
3193 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3194 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3199 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3200 no_bgp_graceful_restart_disable_eor_cmd
,
3201 "no bgp graceful-restart disable-eor",
3203 "BGP specific commands\n"
3204 "Graceful restart configuration parameters\n"
3205 "Disable EOR Check\n")
3207 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3208 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3213 DEFUN (bgp_graceful_restart_rib_stale_time
,
3214 bgp_graceful_restart_rib_stale_time_cmd
,
3215 "bgp graceful-restart rib-stale-time (1-3600)",
3216 "BGP specific commands\n"
3217 "Graceful restart configuration parameters\n"
3218 "Specify the stale route removal timer in rib\n"
3219 "Delay value (seconds)\n")
3221 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3223 uint32_t stale_time
;
3225 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3226 bgp
->rib_stale_time
= stale_time
;
3227 /* Send the stale timer update message to RIB */
3228 if (bgp_zebra_stale_timer_update(bgp
))
3234 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3235 no_bgp_graceful_restart_rib_stale_time_cmd
,
3236 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3238 "BGP specific commands\n"
3239 "Graceful restart configuration parameters\n"
3240 "Specify the stale route removal timer in rib\n"
3241 "Delay value (seconds)\n")
3243 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3245 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3246 /* Send the stale timer update message to RIB */
3247 if (bgp_zebra_stale_timer_update(bgp
))
3253 static inline int bgp_initiate_graceful_shut_unshut(struct bgp
*bgp
,
3257 bgp_static_redo_import_check(bgp
);
3258 bgp_redistribute_redo(bgp
);
3259 if (bgp_clear_star_soft_out(bgp
->name
, errmsg
, errmsg_len
) < 0)
3261 if (bgp_clear_star_soft_in(bgp
->name
, errmsg
, errmsg_len
) < 0)
3267 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3269 struct listnode
*node
, *nnode
;
3271 bool vrf_cfg
= false;
3272 char errmsg
[BUFSIZ
] = {'\0'};
3274 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3277 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3278 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3279 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3281 "%% graceful-shutdown configuration found in vrf %s\n",
3282 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3283 VRF_DEFAULT_NAME
: bgp
->name
);
3290 "%%Failed: global graceful-shutdown not permitted\n");
3294 /* Set flag globally */
3295 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3297 /* Initiate processing for all BGP instances. */
3298 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3299 if (bgp_initiate_graceful_shut_unshut(bgp
, errmsg
,
3303 vty_out(vty
, "%s\n", errmsg
);
3309 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3311 struct listnode
*node
, *nnode
;
3313 char errmsg
[BUFSIZ
] = {'\0'};
3315 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3318 /* Unset flag globally */
3319 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3321 /* Initiate processing for all BGP instances. */
3322 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3323 if (bgp_initiate_graceful_shut_unshut(bgp
, errmsg
,
3327 vty_out(vty
, "%s\n", errmsg
);
3333 /* "bgp graceful-shutdown" configuration */
3334 DEFUN (bgp_graceful_shutdown
,
3335 bgp_graceful_shutdown_cmd
,
3336 "bgp graceful-shutdown",
3338 "Graceful shutdown parameters\n")
3340 if (vty
->node
== CONFIG_NODE
)
3341 return bgp_global_graceful_shutdown_config_vty(vty
);
3343 nb_cli_enqueue_change(vty
, "./global/graceful-shutdown/enable",
3344 NB_OP_MODIFY
, "true");
3346 return nb_cli_apply_changes(vty
, NULL
);
3349 DEFUN_YANG (no_bgp_graceful_shutdown
,
3350 no_bgp_graceful_shutdown_cmd
,
3351 "no bgp graceful-shutdown",
3354 "Graceful shutdown parameters\n")
3356 if (vty
->node
== CONFIG_NODE
)
3357 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3359 nb_cli_enqueue_change(vty
, "./global/graceful-shutdown/enable",
3360 NB_OP_MODIFY
, "false");
3362 return nb_cli_apply_changes(vty
, NULL
);
3365 void cli_show_router_bgp_graceful_shutdown(struct vty
*vty
,
3366 struct lyd_node
*dnode
,
3369 if (yang_dnode_get_bool(dnode
, NULL
))
3370 vty_out(vty
, " bgp graceful-shutdown\n");
3373 /* "bgp fast-external-failover" configuration. */
3374 DEFUN_YANG (bgp_fast_external_failover
,
3375 bgp_fast_external_failover_cmd
,
3376 "bgp fast-external-failover",
3378 "Immediately reset session if a link to a directly connected external peer goes down\n")
3380 nb_cli_enqueue_change(vty
, "./global/fast-external-failover",
3381 NB_OP_MODIFY
, "false");
3383 return nb_cli_apply_changes(vty
, NULL
);
3386 DEFUN_YANG (no_bgp_fast_external_failover
,
3387 no_bgp_fast_external_failover_cmd
,
3388 "no bgp fast-external-failover",
3391 "Immediately reset session if a link to a directly connected external peer goes down\n")
3393 nb_cli_enqueue_change(vty
, "./global/fast-external-failover",
3394 NB_OP_MODIFY
, "true");
3396 return nb_cli_apply_changes(vty
, NULL
);
3399 void cli_show_router_bgp_fast_external_failover(struct vty
*vty
,
3400 struct lyd_node
*dnode
,
3403 if (!yang_dnode_get_bool(dnode
, NULL
))
3404 vty_out(vty
, " no bgp fast-external-failover\n");
3407 /* "bgp bestpath compare-routerid" configuration. */
3408 DEFUN_YANG(bgp_bestpath_compare_router_id
,
3409 bgp_bestpath_compare_router_id_cmd
,
3410 "bgp bestpath compare-routerid",
3411 "BGP specific commands\n"
3412 "Change the default bestpath selection\n"
3413 "Compare router-id for identical EBGP paths\n")
3415 nb_cli_enqueue_change(
3417 "./global/route-selection-options/external-compare-router-id",
3418 NB_OP_MODIFY
, "true");
3420 return nb_cli_apply_changes(vty
, NULL
);
3423 DEFUN_YANG(no_bgp_bestpath_compare_router_id
,
3424 no_bgp_bestpath_compare_router_id_cmd
,
3425 "no bgp bestpath compare-routerid",
3427 "BGP specific commands\n"
3428 "Change the default bestpath selection\n"
3429 "Compare router-id for identical EBGP paths\n")
3431 nb_cli_enqueue_change(
3433 "./global/route-selection-options/external-compare-router-id",
3434 NB_OP_MODIFY
, "false");
3436 return nb_cli_apply_changes(vty
, NULL
);
3439 /* "bgp bestpath as-path ignore" configuration. */
3440 DEFUN_YANG(bgp_bestpath_aspath_ignore
,
3441 bgp_bestpath_aspath_ignore_cmd
,
3442 "bgp bestpath as-path ignore",
3443 "BGP specific commands\n"
3444 "Change the default bestpath selection\n"
3445 "AS-path attribute\n"
3446 "Ignore as-path length in selecting a route\n")
3448 nb_cli_enqueue_change(
3449 vty
, "./global/route-selection-options/ignore-as-path-length",
3450 NB_OP_MODIFY
, "true");
3452 return nb_cli_apply_changes(vty
, NULL
);
3455 DEFUN_YANG(no_bgp_bestpath_aspath_ignore
,
3456 no_bgp_bestpath_aspath_ignore_cmd
,
3457 "no bgp bestpath as-path ignore",
3459 "BGP specific commands\n"
3460 "Change the default bestpath selection\n"
3461 "AS-path attribute\n"
3462 "Ignore as-path length in selecting a route\n")
3464 nb_cli_enqueue_change(
3465 vty
, "./global/route-selection-options/ignore-as-path-length",
3466 NB_OP_MODIFY
, "false");
3468 return nb_cli_apply_changes(vty
, NULL
);
3471 /* "bgp bestpath as-path confed" configuration. */
3472 DEFUN_YANG (bgp_bestpath_aspath_confed
,
3473 bgp_bestpath_aspath_confed_cmd
,
3474 "bgp bestpath as-path confed",
3475 "BGP specific commands\n"
3476 "Change the default bestpath selection\n"
3477 "AS-path attribute\n"
3478 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3480 nb_cli_enqueue_change(vty
,
3481 "./global/route-selection-options/aspath-confed",
3482 NB_OP_MODIFY
, "true");
3484 return nb_cli_apply_changes(vty
, NULL
);
3487 DEFUN_YANG (no_bgp_bestpath_aspath_confed
,
3488 no_bgp_bestpath_aspath_confed_cmd
,
3489 "no bgp bestpath as-path confed",
3491 "BGP specific commands\n"
3492 "Change the default bestpath selection\n"
3493 "AS-path attribute\n"
3494 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3496 nb_cli_enqueue_change(vty
,
3497 "./global/route-selection-options/aspath-confed",
3498 NB_OP_MODIFY
, "false");
3500 return nb_cli_apply_changes(vty
, NULL
);
3503 /* "bgp bestpath as-path multipath-relax" configuration. */
3504 DEFUN_YANG (bgp_bestpath_aspath_multipath_relax
,
3505 bgp_bestpath_aspath_multipath_relax_cmd
,
3506 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3507 "BGP specific commands\n"
3508 "Change the default bestpath selection\n"
3509 "AS-path attribute\n"
3510 "Allow load sharing across routes that have different AS paths (but same length)\n"
3511 "Generate an AS_SET\n"
3512 "Do not generate an AS_SET\n")
3516 nb_cli_enqueue_change(
3517 vty
, "./global/route-selection-options/allow-multiple-as",
3518 NB_OP_MODIFY
, "true");
3519 if (argv_find(argv
, argc
, "as-set", &idx
))
3520 nb_cli_enqueue_change(
3522 "./global/route-selection-options/multi-path-as-set",
3523 NB_OP_MODIFY
, "true");
3525 nb_cli_enqueue_change(
3527 "./global/route-selection-options/multi-path-as-set",
3528 NB_OP_MODIFY
, "false");
3530 return nb_cli_apply_changes(vty
, NULL
);
3533 DEFUN_YANG (no_bgp_bestpath_aspath_multipath_relax
,
3534 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3535 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3537 "BGP specific commands\n"
3538 "Change the default bestpath selection\n"
3539 "AS-path attribute\n"
3540 "Allow load sharing across routes that have different AS paths (but same length)\n"
3541 "Generate an AS_SET\n"
3542 "Do not generate an AS_SET\n")
3544 nb_cli_enqueue_change(
3545 vty
, "./global/route-selection-options/allow-multiple-as",
3546 NB_OP_MODIFY
, "false");
3547 nb_cli_enqueue_change(
3548 vty
, "./global/route-selection-options/multi-path-as-set",
3549 NB_OP_MODIFY
, "false");
3551 return nb_cli_apply_changes(vty
, NULL
);
3554 /* "bgp log-neighbor-changes" configuration. */
3555 DEFUN_YANG(bgp_log_neighbor_changes
,
3556 bgp_log_neighbor_changes_cmd
,
3557 "bgp log-neighbor-changes",
3558 "BGP specific commands\n"
3559 "Log neighbor up/down and reset reason\n")
3561 nb_cli_enqueue_change(
3562 vty
, "./global/global-neighbor-config/log-neighbor-changes",
3563 NB_OP_MODIFY
, "true");
3565 return nb_cli_apply_changes(vty
, NULL
);
3568 DEFUN_YANG(no_bgp_log_neighbor_changes
,
3569 no_bgp_log_neighbor_changes_cmd
,
3570 "no bgp log-neighbor-changes",
3572 "BGP specific commands\n"
3573 "Log neighbor up/down and reset reason\n")
3575 nb_cli_enqueue_change(
3576 vty
, "./global/global-neighbor-config/log-neighbor-changes",
3577 NB_OP_MODIFY
, "false");
3579 return nb_cli_apply_changes(vty
, NULL
);
3582 /* "bgp bestpath med" configuration. */
3583 DEFUN_YANG (bgp_bestpath_med
,
3584 bgp_bestpath_med_cmd
,
3585 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3586 "BGP specific commands\n"
3587 "Change the default bestpath selection\n"
3589 "Compare MED among confederation paths\n"
3590 "Treat missing MED as the least preferred one\n"
3591 "Treat missing MED as the least preferred one\n"
3592 "Compare MED among confederation paths\n")
3595 bool confed
= false;
3596 bool worst_med
= false;
3599 if (argv_find(argv
, argc
, "confed", &idx
))
3602 nb_cli_enqueue_change(vty
,
3603 "./global/route-selection-options/confed-med",
3604 NB_OP_MODIFY
, confed
? "true" : "false");
3607 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3610 nb_cli_enqueue_change(
3611 vty
, "./global/route-selection-options/missing-as-worst-med",
3612 NB_OP_MODIFY
, worst_med
? "true" : "false");
3614 return nb_cli_apply_changes(vty
, NULL
);
3617 DEFUN_YANG (no_bgp_bestpath_med
,
3618 no_bgp_bestpath_med_cmd
,
3619 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3621 "BGP specific commands\n"
3622 "Change the default bestpath selection\n"
3624 "Compare MED among confederation paths\n"
3625 "Treat missing MED as the least preferred one\n"
3626 "Treat missing MED as the least preferred one\n"
3627 "Compare MED among confederation paths\n")
3631 if (argv_find(argv
, argc
, "confed", &idx
))
3632 nb_cli_enqueue_change(
3633 vty
, "./global/route-selection-options/confed-med",
3634 NB_OP_MODIFY
, "false");
3637 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3638 nb_cli_enqueue_change(
3640 "./global/route-selection-options/missing-as-worst-med",
3641 NB_OP_MODIFY
, "false");
3643 return nb_cli_apply_changes(vty
, NULL
);
3646 /* "bgp bestpath bandwidth" configuration. */
3647 DEFPY (bgp_bestpath_bw
,
3648 bgp_bestpath_bw_cmd
,
3649 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3650 "BGP specific commands\n"
3651 "Change the default bestpath selection\n"
3652 "Link Bandwidth attribute\n"
3653 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3654 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3655 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3657 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3662 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3663 return CMD_ERR_INCOMPLETE
;
3665 if (!strcmp(bw_cfg
, "ignore"))
3666 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3667 else if (!strcmp(bw_cfg
, "skip-missing"))
3668 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3669 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3670 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3672 return CMD_ERR_NO_MATCH
;
3674 /* This config is used in route install, so redo that. */
3675 FOREACH_AFI_SAFI (afi
, safi
) {
3676 if (!bgp_fibupd_safi(safi
))
3678 bgp_zebra_announce_table(bgp
, afi
, safi
);
3684 DEFPY (no_bgp_bestpath_bw
,
3685 no_bgp_bestpath_bw_cmd
,
3686 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3688 "BGP specific commands\n"
3689 "Change the default bestpath selection\n"
3690 "Link Bandwidth attribute\n"
3691 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3692 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3693 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3695 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3699 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3701 /* This config is used in route install, so redo that. */
3702 FOREACH_AFI_SAFI (afi
, safi
) {
3703 if (!bgp_fibupd_safi(safi
))
3705 bgp_zebra_announce_table(bgp
, afi
, safi
);
3710 /* "no bgp default ipv4-unicast". */
3711 DEFUN (no_bgp_default_ipv4_unicast
,
3712 no_bgp_default_ipv4_unicast_cmd
,
3713 "no bgp default ipv4-unicast",
3715 "BGP specific commands\n"
3716 "Configure BGP defaults\n"
3717 "Activate ipv4-unicast for a peer by default\n")
3719 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3720 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
);
3724 DEFUN (bgp_default_ipv4_unicast
,
3725 bgp_default_ipv4_unicast_cmd
,
3726 "bgp default ipv4-unicast",
3727 "BGP specific commands\n"
3728 "Configure BGP defaults\n"
3729 "Activate ipv4-unicast for a peer by default\n")
3731 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3732 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
);
3736 /* Display hostname in certain command outputs */
3737 DEFUN_YANG (bgp_default_show_hostname
,
3738 bgp_default_show_hostname_cmd
,
3739 "bgp default show-hostname",
3740 "BGP specific commands\n"
3741 "Configure BGP defaults\n"
3742 "Show hostname in certain command outputs\n")
3744 nb_cli_enqueue_change(vty
, "./global/show-hostname", NB_OP_MODIFY
,
3747 return nb_cli_apply_changes(vty
, NULL
);
3750 DEFUN_YANG(no_bgp_default_show_hostname
,
3751 no_bgp_default_show_hostname_cmd
,
3752 "no bgp default show-hostname",
3754 "BGP specific commands\n"
3755 "Configure BGP defaults\n"
3756 "Show hostname in certain command outputs\n")
3758 nb_cli_enqueue_change(vty
, "./global/show-hostname", NB_OP_MODIFY
,
3761 return nb_cli_apply_changes(vty
, NULL
);
3764 void cli_show_router_bgp_show_hostname(struct vty
*vty
, struct lyd_node
*dnode
,
3767 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SHOW_HOSTNAME
)
3768 vty_out(vty
, " bgp default show-hostname\n");
3771 /* Display hostname in certain command outputs */
3772 DEFUN_YANG(bgp_default_show_nexthop_hostname
,
3773 bgp_default_show_nexthop_hostname_cmd
,
3774 "bgp default show-nexthop-hostname",
3775 "BGP specific commands\n"
3776 "Configure BGP defaults\n"
3777 "Show hostname for nexthop in certain command outputs\n")
3779 nb_cli_enqueue_change(vty
, "./global/show-nexthop-hostname",
3780 NB_OP_MODIFY
, "true");
3782 return nb_cli_apply_changes(vty
, NULL
);
3785 DEFUN (no_bgp_default_show_nexthop_hostname
,
3786 no_bgp_default_show_nexthop_hostname_cmd
,
3787 "no bgp default show-nexthop-hostname",
3789 "BGP specific commands\n"
3790 "Configure BGP defaults\n"
3791 "Show hostname for nexthop in certain command outputs\n")
3793 nb_cli_enqueue_change(vty
, "./global/show-nexthop-hostname",
3794 NB_OP_MODIFY
, "false");
3796 return nb_cli_apply_changes(vty
, NULL
);
3799 void cli_show_router_bgp_show_nexthop_hostname(struct vty
*vty
,
3800 struct lyd_node
*dnode
,
3803 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SHOW_HOSTNAME
)
3804 vty_out(vty
, " bgp default show-nexthop-hostname\n");
3807 /* "bgp network import-check" configuration. */
3808 DEFUN_YANG(bgp_network_import_check
,
3809 bgp_network_import_check_cmd
,
3810 "bgp network import-check",
3811 "BGP specific commands\n"
3812 "BGP network command\n"
3813 "Check BGP network route exists in IGP\n")
3815 nb_cli_enqueue_change(vty
, "./global/import-check", NB_OP_MODIFY
,
3818 return nb_cli_apply_changes(vty
, NULL
);
3821 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
3822 "bgp network import-check exact",
3823 "BGP specific commands\n"
3824 "BGP network command\n"
3825 "Check BGP network route exists in IGP\n"
3826 "Match route precisely\n")
3828 DEFUN_YANG(no_bgp_network_import_check
,
3829 no_bgp_network_import_check_cmd
,
3830 "no bgp network import-check",
3832 "BGP specific commands\n"
3833 "BGP network command\n"
3834 "Check BGP network route exists in IGP\n")
3836 nb_cli_enqueue_change(vty
, "./global/import-check", NB_OP_MODIFY
,
3839 return nb_cli_apply_changes(vty
, NULL
);
3842 void cli_show_router_bgp_import_check(struct vty
*vty
, struct lyd_node
*dnode
,
3845 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_IMPORT_CHECK
)
3846 vty_out(vty
, " bgp network import-check\n");
3849 DEFUN_YANG(bgp_default_local_preference
,
3850 bgp_default_local_preference_cmd
,
3851 "bgp default local-preference (0-4294967295)",
3852 "BGP specific commands\n"
3853 "Configure BGP defaults\n"
3854 "local preference (higher=more preferred)\n"
3855 "Configure default local preference value\n")
3859 nb_cli_enqueue_change(vty
, "./global/local-pref", NB_OP_MODIFY
,
3860 argv
[idx_number
]->arg
);
3862 return nb_cli_apply_changes(vty
, NULL
);
3865 DEFUN_YANG(no_bgp_default_local_preference
,
3866 no_bgp_default_local_preference_cmd
,
3867 "no bgp default local-preference [(0-4294967295)]",
3869 "BGP specific commands\n"
3870 "Configure BGP defaults\n"
3871 "local preference (higher=more preferred)\n"
3872 "Configure default local preference value\n")
3874 nb_cli_enqueue_change(vty
, "./global/local-pref", NB_OP_MODIFY
, NULL
);
3876 return nb_cli_apply_changes(vty
, NULL
);
3879 void cli_show_router_bgp_local_pref(struct vty
*vty
, struct lyd_node
*dnode
,
3882 vty_out(vty
, " bgp default local-preference %u\n",
3883 yang_dnode_get_uint32(dnode
, NULL
));
3887 DEFUN_YANG(bgp_default_subgroup_pkt_queue_max
,
3888 bgp_default_subgroup_pkt_queue_max_cmd
,
3889 "bgp default subgroup-pkt-queue-max (20-100)",
3890 "BGP specific commands\n"
3891 "Configure BGP defaults\n"
3892 "subgroup-pkt-queue-max\n"
3893 "Configure subgroup packet queue max\n")
3897 nb_cli_enqueue_change(
3899 "./global/global-update-group-config/subgroup-pkt-queue-size",
3900 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
3902 return nb_cli_apply_changes(vty
, NULL
);
3905 DEFUN_YANG(no_bgp_default_subgroup_pkt_queue_max
,
3906 no_bgp_default_subgroup_pkt_queue_max_cmd
,
3907 "no bgp default subgroup-pkt-queue-max [(20-100)]",
3909 "BGP specific commands\n"
3910 "Configure BGP defaults\n"
3911 "subgroup-pkt-queue-max\n"
3912 "Configure subgroup packet queue max\n")
3914 nb_cli_enqueue_change(
3916 "./global/global-update-group-config/subgroup-pkt-queue-size",
3917 NB_OP_MODIFY
, NULL
);
3919 return nb_cli_apply_changes(vty
, NULL
);
3922 void cli_show_router_global_update_group_config_subgroup_pkt_queue_size(
3923 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
3925 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
3926 yang_dnode_get_uint32(dnode
, NULL
));
3929 DEFUN_YANG(bgp_rr_allow_outbound_policy
,
3930 bgp_rr_allow_outbound_policy_cmd
,
3931 "bgp route-reflector allow-outbound-policy",
3932 "BGP specific commands\n"
3933 "Allow modifications made by out route-map\n"
3934 "on ibgp neighbors\n")
3936 nb_cli_enqueue_change(vty
,
3937 "./global/route-reflector/allow-outbound-policy",
3938 NB_OP_MODIFY
, "true");
3940 return nb_cli_apply_changes(vty
, NULL
);
3943 DEFUN_YANG(no_bgp_rr_allow_outbound_policy
,
3944 no_bgp_rr_allow_outbound_policy_cmd
,
3945 "no bgp route-reflector allow-outbound-policy",
3947 "BGP specific commands\n"
3948 "Allow modifications made by out route-map\n"
3949 "on ibgp neighbors\n")
3951 nb_cli_enqueue_change(vty
,
3952 "./global/route-reflector/allow-outbound-policy",
3953 NB_OP_MODIFY
, "false");
3955 return nb_cli_apply_changes(vty
, NULL
);
3959 void cli_show_router_global_neighbor_config(struct vty
*vty
,
3960 struct lyd_node
*dnode
,
3963 uint32_t write_quanta
, read_quanta
;
3965 if (yang_dnode_get_bool(dnode
, "./log-neighbor-changes"))
3966 vty_out(vty
, " bgp log-neighbor-changes\n");
3968 if (yang_dnode_exists(dnode
, "./dynamic-neighbors-limit")) {
3969 uint32_t listen_limit
= yang_dnode_get_uint32(
3970 dnode
, "./dynamic-neighbors-limit");
3971 vty_out(vty
, " bgp listen limit %u\n", listen_limit
);
3974 write_quanta
= yang_dnode_get_uint32(
3975 dnode
, "./packet-quanta-config/wpkt-quanta");
3976 if (write_quanta
!= BGP_WRITE_PACKET_MAX
)
3977 vty_out(vty
, " write-quanta %d\n", write_quanta
);
3979 read_quanta
= yang_dnode_get_uint32(
3980 dnode
, "./packet-quanta-config/rpkt-quanta");
3982 if (read_quanta
!= BGP_READ_PACKET_MAX
)
3983 vty_out(vty
, " read-quanta %d\n", read_quanta
);
3986 DEFUN_YANG(bgp_listen_limit
,
3987 bgp_listen_limit_cmd
,
3988 "bgp listen limit (1-5000)",
3989 "BGP specific commands\n"
3990 "BGP Dynamic Neighbors listen commands\n"
3991 "Maximum number of BGP Dynamic Neighbors that can be created\n"
3992 "Configure Dynamic Neighbors listen limit value\n")
3996 nb_cli_enqueue_change(
3997 vty
, "./global/global-neighbor-config/dynamic-neighbors-limit",
3998 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
4000 return nb_cli_apply_changes(vty
, NULL
);
4003 DEFUN_YANG(no_bgp_listen_limit
,
4004 no_bgp_listen_limit_cmd
,
4005 "no bgp listen limit [(1-5000)]",
4007 "BGP specific commands\n"
4008 "BGP Dynamic Neighbors listen commands\n"
4009 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4010 "Configure Dynamic Neighbors listen limit value\n")
4012 nb_cli_enqueue_change(
4013 vty
, "./global/global-neighbor-config/dynamic-neighbors-limit",
4014 NB_OP_DESTROY
, NULL
);
4016 return nb_cli_apply_changes(vty
, NULL
);
4021 * Check if this listen range is already configured. Check for exact
4022 * match or overlap based on input.
4024 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4025 struct prefix
*range
, int exact
)
4027 struct listnode
*node
, *nnode
;
4028 struct listnode
*node1
, *nnode1
;
4029 struct peer_group
*group
;
4034 afi
= family2afi(range
->family
);
4035 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4036 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4039 match
= prefix_same(range
, lr
);
4041 match
= (prefix_match(range
, lr
)
4042 || prefix_match(lr
, range
));
4051 DEFUN (bgp_listen_range
,
4052 bgp_listen_range_cmd
,
4053 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4054 "BGP specific commands\n"
4055 "Configure BGP dynamic neighbors listen range\n"
4056 "Configure BGP dynamic neighbors listen range\n"
4058 "Member of the peer-group\n"
4059 "Peer-group name\n")
4061 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4062 struct prefix range
;
4063 struct peer_group
*group
, *existing_group
;
4068 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4069 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4070 char *prefix
= argv
[idx
]->arg
;
4071 argv_find(argv
, argc
, "PGNAME", &idx
);
4072 char *peergroup
= argv
[idx
]->arg
;
4074 /* Convert IP prefix string to struct prefix. */
4075 ret
= str2prefix(prefix
, &range
);
4077 vty_out(vty
, "%% Malformed listen range\n");
4078 return CMD_WARNING_CONFIG_FAILED
;
4081 afi
= family2afi(range
.family
);
4083 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4085 "%% Malformed listen range (link-local address)\n");
4086 return CMD_WARNING_CONFIG_FAILED
;
4091 /* Check if same listen range is already configured. */
4092 existing_group
= listen_range_exists(bgp
, &range
, 1);
4093 if (existing_group
) {
4094 if (strcmp(existing_group
->name
, peergroup
) == 0)
4098 "%% Same listen range is attached to peer-group %s\n",
4099 existing_group
->name
);
4100 return CMD_WARNING_CONFIG_FAILED
;
4104 /* Check if an overlapping listen range exists. */
4105 if (listen_range_exists(bgp
, &range
, 0)) {
4107 "%% Listen range overlaps with existing listen range\n");
4108 return CMD_WARNING_CONFIG_FAILED
;
4111 group
= peer_group_lookup(bgp
, peergroup
);
4113 vty_out(vty
, "%% Configure the peer-group first\n");
4114 return CMD_WARNING_CONFIG_FAILED
;
4117 ret
= peer_group_listen_range_add(group
, &range
);
4118 return bgp_vty_return(vty
, ret
);
4121 DEFUN (no_bgp_listen_range
,
4122 no_bgp_listen_range_cmd
,
4123 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4125 "BGP specific commands\n"
4126 "Unconfigure BGP dynamic neighbors listen range\n"
4127 "Unconfigure BGP dynamic neighbors listen range\n"
4129 "Member of the peer-group\n"
4130 "Peer-group name\n")
4132 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4133 struct prefix range
;
4134 struct peer_group
*group
;
4139 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4140 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4141 char *prefix
= argv
[idx
]->arg
;
4142 argv_find(argv
, argc
, "PGNAME", &idx
);
4143 char *peergroup
= argv
[idx
]->arg
;
4145 /* Convert IP prefix string to struct prefix. */
4146 ret
= str2prefix(prefix
, &range
);
4148 vty_out(vty
, "%% Malformed listen range\n");
4149 return CMD_WARNING_CONFIG_FAILED
;
4152 afi
= family2afi(range
.family
);
4154 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4156 "%% Malformed listen range (link-local address)\n");
4157 return CMD_WARNING_CONFIG_FAILED
;
4162 group
= peer_group_lookup(bgp
, peergroup
);
4164 vty_out(vty
, "%% Peer-group does not exist\n");
4165 return CMD_WARNING_CONFIG_FAILED
;
4168 ret
= peer_group_listen_range_del(group
, &range
);
4169 return bgp_vty_return(vty
, ret
);
4172 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4174 struct peer_group
*group
;
4175 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4176 struct prefix
*range
;
4179 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4180 vty_out(vty
, " bgp listen limit %d\n",
4181 bgp
->dynamic_neighbors_limit
);
4183 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4184 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4185 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4188 " bgp listen range %pFX peer-group %s\n",
4189 range
, group
->name
);
4196 DEFUN_YANG(bgp_disable_connected_route_check
,
4197 bgp_disable_connected_route_check_cmd
,
4198 "bgp disable-ebgp-connected-route-check",
4199 "BGP specific commands\n"
4200 "Disable checking if nexthop is connected on ebgp sessions\n")
4202 nb_cli_enqueue_change(vty
,
4203 "./global/ebgp-multihop-connected-route-check",
4204 NB_OP_MODIFY
, "true");
4206 return nb_cli_apply_changes(vty
, NULL
);
4209 DEFUN_YANG(no_bgp_disable_connected_route_check
,
4210 no_bgp_disable_connected_route_check_cmd
,
4211 "no bgp disable-ebgp-connected-route-check",
4213 "BGP specific commands\n"
4214 "Disable checking if nexthop is connected on ebgp sessions\n")
4216 nb_cli_enqueue_change(vty
,
4217 "./global/ebgp-multihop-connected-route-check",
4218 NB_OP_MODIFY
, "false");
4220 return nb_cli_apply_changes(vty
, NULL
);
4223 void cli_show_router_global_ebgp_multihop_connected_route_check(
4224 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
4226 if (yang_dnode_get_bool(dnode
, NULL
))
4227 vty_out(vty
, " bgp disable-ebgp-connected-route-check\n");
4230 DEFUN_YANG(bgp_default_shutdown
,
4231 bgp_default_shutdown_cmd
,
4232 "[no] bgp default shutdown",
4234 "Configure BGP defaults\n"
4235 "Apply administrative shutdown to newly configured peers\n")
4237 nb_cli_enqueue_change(vty
, "./global/default-shutdown", NB_OP_MODIFY
,
4238 strmatch(argv
[0]->text
, "no") ? "false" : "true");
4240 return nb_cli_apply_changes(vty
, NULL
);
4243 void cli_show_router_bgp_default_shutdown(struct vty
*vty
,
4244 struct lyd_node
*dnode
,
4247 if (yang_dnode_get_bool(dnode
, NULL
))
4248 vty_out(vty
, " bgp default shutdown\n");
4251 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4253 "Administrative shutdown of the BGP instance\n"
4254 "Add a shutdown message (RFC 8203)\n"
4255 "Shutdown message\n")
4257 char *msgstr
= NULL
;
4259 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4262 msgstr
= argv_concat(argv
, argc
, 3);
4264 bgp_shutdown_enable(bgp
, msgstr
);
4265 XFREE(MTYPE_TMP
, msgstr
);
4270 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4271 BGP_STR
"Administrative shutdown of the BGP instance\n")
4273 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4275 bgp_shutdown_enable(bgp
, NULL
);
4280 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4281 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4283 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4285 bgp_shutdown_disable(bgp
);
4290 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4291 "no bgp shutdown message MSG...", NO_STR BGP_STR
4292 "Administrative shutdown of the BGP instance\n"
4293 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4295 DEFUN_YANG(neighbor_remote_as
,
4296 neighbor_remote_as_cmd
,
4297 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4298 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4299 "Specify a BGP neighbor\n" AS_STR
4300 "Internal BGP peer\n"
4301 "External BGP peer\n")
4304 int idx_remote_as
= 3;
4305 char base_xpath
[XPATH_MAXLEN
];
4306 char unnbr_xpath
[XPATH_MAXLEN
];
4307 char prgrp_xpath
[XPATH_MAXLEN
];
4309 const char *as_type_str
= "as-specified";
4311 if (str2sockunion(argv
[idx_peer
]->arg
, &su
) < 0) {
4312 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
4313 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, argv
[idx_peer
]->arg
, "");
4315 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
4316 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
, "");
4318 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4319 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4320 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4321 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
,
4322 "%s%s", VTY_CURR_XPATH
,
4324 snprintf(base_xpath
, sizeof(base_xpath
),
4325 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
,
4329 "%% Create the peer-group or interface first\n");
4330 return CMD_WARNING_CONFIG_FAILED
;
4333 snprintf(base_xpath
, sizeof(base_xpath
),
4334 FRR_BGP_NEIGHBOR_NUM_XPATH
, argv
[idx_peer
]->arg
, "");
4337 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4338 as_type_str
= "internal";
4339 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4340 as_type_str
= "external";
4342 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4343 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4345 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4346 NB_OP_MODIFY
, as_type_str
);
4348 return nb_cli_apply_changes(vty
, base_xpath
);
4351 int peer_conf_interface_create(struct bgp
*bgp
, const char *conf_if
, afi_t afi
,
4352 safi_t safi
, bool v6only
,
4353 const char *peer_group_name
, int as_type
,
4354 as_t as
, char *errmsg
, size_t errmsg_len
)
4357 struct peer_group
*group
;
4360 group
= peer_group_lookup(bgp
, conf_if
);
4363 snprintf(errmsg
, errmsg_len
,
4364 "Name conflict with peer-group \n");
4368 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4370 if (as_type
!= AS_UNSPECIFIED
)
4371 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
4374 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
)
4375 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
4376 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
4377 as_type
, 0, 0, NULL
);
4379 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
4380 as_type
, afi
, safi
, NULL
);
4383 snprintf(errmsg
, errmsg_len
,
4384 "BGP failed to create peer\n");
4389 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4391 /* Request zebra to initiate IPv6 RAs on this interface. We do
4393 * any unnumbered peer in order to not worry about run-time
4395 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4397 * gets deleted later etc.)
4400 bgp_zebra_initiate_radv(bgp
, peer
);
4403 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4404 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4406 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4408 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4410 /* v6only flag changed. Reset bgp seesion */
4411 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4412 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4413 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4414 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4416 bgp_session_reset(peer
);
4419 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4420 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4421 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4422 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4425 if (peer_group_name
) {
4426 group
= peer_group_lookup(bgp
, peer_group_name
);
4428 snprintf(errmsg
, errmsg_len
,
4429 "Configure the peer-group first\n");
4433 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4436 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
4439 DEFUN_YANG(neighbor_interface_config
,
4440 neighbor_interface_config_cmd
,
4441 "neighbor WORD interface [peer-group PGNAME]",
4443 "Interface name or neighbor tag\n"
4444 "Enable BGP on interface\n"
4445 "Member of the peer-group\n"
4446 "Peer-group name\n")
4449 int idx_peer_group_word
= 4;
4450 char base_xpath
[XPATH_MAXLEN
];
4452 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4453 argv
[idx_word
]->arg
, "");
4455 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4456 if (argc
> idx_peer_group_word
)
4457 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_MODIFY
,
4458 argv
[idx_peer_group_word
]->arg
);
4460 return nb_cli_apply_changes(vty
, base_xpath
);
4463 DEFUN_YANG(neighbor_interface_config_v6only
,
4464 neighbor_interface_config_v6only_cmd
,
4465 "neighbor WORD interface v6only [peer-group PGNAME]",
4467 "Interface name or neighbor tag\n"
4468 "Enable BGP on interface\n"
4469 "Enable BGP with v6 link-local only\n"
4470 "Member of the peer-group\n"
4471 "Peer-group name\n")
4474 int idx_peer_group_word
= 5;
4475 char base_xpath
[XPATH_MAXLEN
];
4477 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4478 argv
[idx_word
]->arg
, "");
4480 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4481 if (argc
> idx_peer_group_word
)
4482 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_MODIFY
,
4483 argv
[idx_peer_group_word
]->arg
);
4485 nb_cli_enqueue_change(vty
, "./v6only", NB_OP_MODIFY
, "true");
4487 return nb_cli_apply_changes(vty
, base_xpath
);
4492 neighbor_interface_config_remote_as
,
4493 neighbor_interface_config_remote_as_cmd
,
4494 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4496 "Interface name or neighbor tag\n"
4497 "Enable BGP on interface\n"
4498 "Specify a BGP neighbor\n" AS_STR
4499 "Internal BGP peer\n"
4500 "External BGP peer\n")
4503 int idx_remote_as
= 4;
4504 char base_xpath
[XPATH_MAXLEN
];
4505 const char *as_type_str
= "as-specified";
4507 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4508 argv
[idx_word
]->arg
, "");
4510 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4512 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4513 as_type_str
= "internal";
4514 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4515 as_type_str
= "external";
4517 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4518 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4520 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4521 NB_OP_MODIFY
, as_type_str
);
4523 return nb_cli_apply_changes(vty
, base_xpath
);
4527 neighbor_interface_v6only_config_remote_as
,
4528 neighbor_interface_v6only_config_remote_as_cmd
,
4529 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4531 "Interface name or neighbor tag\n"
4532 "Enable BGP with v6 link-local only\n"
4533 "Enable BGP on interface\n"
4534 "Specify a BGP neighbor\n" AS_STR
4535 "Internal BGP peer\n"
4536 "External BGP peer\n")
4539 int idx_remote_as
= 5;
4540 char base_xpath
[XPATH_MAXLEN
];
4541 const char *as_type_str
= "as-specified";
4543 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4544 argv
[idx_word
]->arg
, "");
4546 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4548 nb_cli_enqueue_change(vty
, "./v6only", NB_OP_MODIFY
, "true");
4550 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4551 as_type_str
= "internal";
4552 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4553 as_type_str
= "external";
4555 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4556 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4558 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4559 NB_OP_MODIFY
, as_type_str
);
4561 return nb_cli_apply_changes(vty
, base_xpath
);
4564 DEFUN_YANG(neighbor_peer_group
, neighbor_peer_group_cmd
,
4565 "neighbor WORD peer-group",
4567 "Interface name or neighbor tag\n"
4568 "Configure peer-group\n")
4570 char base_xpath
[XPATH_MAXLEN
];
4573 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4574 argv
[idx_word
]->arg
, "");
4576 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4578 return nb_cli_apply_changes(vty
, base_xpath
);
4581 DEFUN_YANG(no_neighbor
,
4583 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4586 "Specify a BGP neighbor\n" AS_STR
4587 "Internal BGP peer\n"
4588 "External BGP peer\n")
4591 char base_xpath
[XPATH_MAXLEN
];
4592 char num_xpath
[XPATH_MAXLEN
];
4593 char unnbr_xpath
[XPATH_MAXLEN
];
4594 char prgrp_xpath
[XPATH_MAXLEN
];
4597 if (str2sockunion(argv
[idx_peer
]->arg
, &su
) == 0) {
4598 snprintf(num_xpath
, sizeof(num_xpath
),
4599 FRR_BGP_NEIGHBOR_NUM_XPATH
, argv
[idx_peer
]->arg
, "");
4600 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4601 VTY_CURR_XPATH
, num_xpath
+ 1)) {
4602 strlcpy(base_xpath
, num_xpath
, sizeof(base_xpath
));
4605 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
4606 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, argv
[idx_peer
]->arg
, "");
4608 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
4609 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
, "");
4611 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4612 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4613 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4614 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
,
4615 "%s%s", VTY_CURR_XPATH
,
4617 strlcpy(base_xpath
, prgrp_xpath
, sizeof(base_xpath
));
4620 "%% Create the peer-group or interface first\n");
4621 return CMD_WARNING_CONFIG_FAILED
;
4625 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_DESTROY
, NULL
);
4627 return nb_cli_apply_changes(vty
, NULL
);
4630 DEFUN_YANG(no_neighbor_interface_config
,
4631 no_neighbor_interface_config_cmd
,
4632 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4635 "Configure BGP on interface\n"
4636 "Enable BGP with v6 link-local only\n"
4637 "Member of the peer-group\n"
4639 "Specify a BGP neighbor\n" AS_STR
4640 "Internal BGP peer\n"
4641 "External BGP peer\n")
4644 char base_xpath
[XPATH_MAXLEN
];
4646 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4647 argv
[idx_word
]->arg
, "");
4649 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
4651 return nb_cli_apply_changes(vty
, base_xpath
);
4654 DEFUN_YANG(no_neighbor_peer_group
,
4655 no_neighbor_peer_group_cmd
,
4656 "no neighbor WORD peer-group",
4659 "Configure peer-group\n")
4661 char base_xpath
[XPATH_MAXLEN
];
4664 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4665 argv
[idx_word
]->arg
, "");
4667 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
4669 return nb_cli_apply_changes(vty
, base_xpath
);
4672 DEFUN_YANG(no_neighbor_interface_peer_group_remote_as
,
4673 no_neighbor_interface_peer_group_remote_as_cmd
,
4674 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4676 "Interface name or neighbor tag\n"
4677 "Specify a BGP neighbor\n" AS_STR
4678 "Internal BGP peer\n"
4679 "External BGP peer\n")
4682 char base_xpath
[XPATH_MAXLEN
];
4683 char unnbr_xpath
[XPATH_MAXLEN
];
4684 char prgrp_xpath
[XPATH_MAXLEN
];
4686 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4687 argv
[idx_peer
]->arg
, "");
4689 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4690 argv
[idx_peer
]->arg
, "");
4692 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4693 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4694 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4695 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4696 VTY_CURR_XPATH
, prgrp_xpath
+ 1)) {
4697 strlcpy(base_xpath
, prgrp_xpath
, sizeof(base_xpath
));
4699 vty_out(vty
, "%% Create the peer-group or interface first\n");
4700 return CMD_WARNING_CONFIG_FAILED
;
4703 strlcat(base_xpath
, "/neighbor-remote-as/remote-as-type",
4704 sizeof(base_xpath
));
4706 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_DESTROY
, NULL
);
4708 return nb_cli_apply_changes(vty
, NULL
);
4711 DEFUN_YANG(neighbor_local_as
,
4712 neighbor_local_as_cmd
,
4713 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4714 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4715 "Specify a local-as number\n"
4716 "AS number used as local AS\n")
4720 char base_xpath
[XPATH_MAXLEN
];
4722 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4723 sizeof(base_xpath
), NULL
)
4725 return CMD_WARNING_CONFIG_FAILED
;
4727 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4728 argv
[idx_number
]->arg
);
4730 return nb_cli_apply_changes(vty
, base_xpath
);
4734 neighbor_local_as_no_prepend
, neighbor_local_as_no_prepend_cmd
,
4735 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4736 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4737 "Specify a local-as number\n"
4738 "AS number used as local AS\n"
4739 "Do not prepend local-as to updates from ebgp peers\n")
4743 char base_xpath
[XPATH_MAXLEN
];
4745 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4746 sizeof(base_xpath
), NULL
)
4748 return CMD_WARNING_CONFIG_FAILED
;
4750 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4751 argv
[idx_number
]->arg
);
4752 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4755 return nb_cli_apply_changes(vty
, base_xpath
);
4759 neighbor_local_as_no_prepend_replace_as
,
4760 neighbor_local_as_no_prepend_replace_as_cmd
,
4761 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4762 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4763 "Specify a local-as number\n"
4764 "AS number used as local AS\n"
4765 "Do not prepend local-as to updates from ebgp peers\n"
4766 "Do not prepend local-as to updates from ibgp peers\n")
4770 char base_xpath
[XPATH_MAXLEN
];
4772 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4773 sizeof(base_xpath
), NULL
)
4775 return CMD_WARNING_CONFIG_FAILED
;
4777 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4778 argv
[idx_number
]->arg
);
4779 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4781 nb_cli_enqueue_change(vty
, "./local-as/no-replace-as", NB_OP_MODIFY
,
4784 return nb_cli_apply_changes(vty
, base_xpath
);
4787 DEFUN_YANG(no_neighbor_local_as
,
4788 no_neighbor_local_as_cmd
,
4789 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4790 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4791 "Specify a local-as number\n"
4792 "AS number used as local AS\n"
4793 "Do not prepend local-as to updates from ebgp peers\n"
4794 "Do not prepend local-as to updates from ibgp peers\n")
4797 char base_xpath
[XPATH_MAXLEN
];
4799 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4800 sizeof(base_xpath
), NULL
)
4802 return CMD_WARNING_CONFIG_FAILED
;
4804 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_DESTROY
, NULL
);
4805 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4807 nb_cli_enqueue_change(vty
, "./local-as/no-replace-as", NB_OP_MODIFY
,
4810 return nb_cli_apply_changes(vty
, base_xpath
);
4814 DEFUN (neighbor_solo
,
4816 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4819 "Solo peer - part of its own update group\n")
4825 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4827 return CMD_WARNING_CONFIG_FAILED
;
4829 ret
= update_group_adjust_soloness(peer
, 1);
4830 return bgp_vty_return(vty
, ret
);
4833 DEFUN (no_neighbor_solo
,
4834 no_neighbor_solo_cmd
,
4835 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4839 "Solo peer - part of its own update group\n")
4845 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4847 return CMD_WARNING_CONFIG_FAILED
;
4849 ret
= update_group_adjust_soloness(peer
, 0);
4850 return bgp_vty_return(vty
, ret
);
4853 DEFUN_YANG(neighbor_password
,
4854 neighbor_password_cmd
,
4855 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
4856 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4862 char base_xpath
[XPATH_MAXLEN
];
4864 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4865 sizeof(base_xpath
), NULL
)
4867 return CMD_WARNING_CONFIG_FAILED
;
4869 nb_cli_enqueue_change(vty
, "./password", NB_OP_MODIFY
,
4870 argv
[idx_line
]->arg
);
4872 return nb_cli_apply_changes(vty
, base_xpath
);
4875 DEFUN_YANG(no_neighbor_password
,
4876 no_neighbor_password_cmd
,
4877 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
4878 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4883 char base_xpath
[XPATH_MAXLEN
];
4885 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4886 sizeof(base_xpath
), NULL
)
4888 return CMD_WARNING_CONFIG_FAILED
;
4890 nb_cli_enqueue_change(vty
, "./password", NB_OP_DESTROY
, NULL
);
4892 return nb_cli_apply_changes(vty
, base_xpath
);
4895 DEFUN_YANG(neighbor_activate
,
4896 neighbor_activate_cmd
,
4897 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4898 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4899 "Enable the Address Family for this Neighbor\n")
4902 char base_xpath
[XPATH_MAXLEN
];
4903 char af_xpath
[XPATH_MAXLEN
];
4904 afi_t afi
= bgp_node_afi(vty
);
4905 safi_t safi
= bgp_node_safi(vty
);
4907 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
4908 yang_afi_safi_value2identity(afi
, safi
));
4909 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4910 sizeof(base_xpath
), af_xpath
)
4912 return CMD_WARNING_CONFIG_FAILED
;
4914 nb_cli_enqueue_change(vty
, "./enabled", NB_OP_MODIFY
, "true");
4916 return nb_cli_apply_changes(vty
, base_xpath
);
4919 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
4920 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4921 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4922 "Enable the Address Family for this Neighbor\n")
4924 DEFUN_YANG(no_neighbor_activate
,
4925 no_neighbor_activate_cmd
,
4926 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4929 "Enable the Address Family for this Neighbor\n")
4932 char base_xpath
[XPATH_MAXLEN
];
4933 char af_xpath
[XPATH_MAXLEN
];
4934 afi_t afi
= bgp_node_afi(vty
);
4935 safi_t safi
= bgp_node_safi(vty
);
4937 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
4938 yang_afi_safi_value2identity(afi
, safi
));
4940 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4941 sizeof(base_xpath
), af_xpath
)
4943 return CMD_WARNING_CONFIG_FAILED
;
4945 nb_cli_enqueue_change(vty
, "./enabled", NB_OP_MODIFY
, "false");
4947 return nb_cli_apply_changes(vty
, base_xpath
);
4950 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
4951 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4952 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4953 "Enable the Address Family for this Neighbor\n")
4955 DEFUN_YANG (neighbor_set_peer_group
,
4956 neighbor_set_peer_group_cmd
,
4957 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4960 "Member of the peer-group\n"
4961 "Peer-group name\n")
4965 char base_xpath
[XPATH_MAXLEN
];
4967 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4968 sizeof(base_xpath
), NULL
)
4970 return CMD_WARNING_CONFIG_FAILED
;
4972 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_MODIFY
,
4973 argv
[idx_word
]->arg
);
4975 return nb_cli_apply_changes(vty
, base_xpath
);
4978 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
4979 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4980 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4981 "Member of the peer-group\n"
4982 "Peer-group name\n")
4984 DEFUN_YANG (no_neighbor_set_peer_group
,
4985 no_neighbor_set_peer_group_cmd
,
4986 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4990 "Member of the peer-group\n"
4991 "Peer-group name\n")
4994 char base_xpath
[XPATH_MAXLEN
];
4996 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4997 sizeof(base_xpath
), NULL
)
4999 return CMD_WARNING_CONFIG_FAILED
;
5001 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_DESTROY
, NULL
);
5003 return nb_cli_apply_changes(vty
, base_xpath
);
5006 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5007 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5008 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5009 "Member of the peer-group\n"
5010 "Peer-group name\n")
5012 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
5013 uint32_t flag
, int set
)
5018 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5020 return CMD_WARNING_CONFIG_FAILED
;
5023 * If 'neighbor <interface>', then this is for directly connected peers,
5024 * we should not accept disable-connected-check.
5026 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5028 "%s is directly connected peer, cannot accept disable-connected-check\n",
5030 return CMD_WARNING_CONFIG_FAILED
;
5033 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5034 peer_tx_shutdown_message_unset(peer
);
5037 ret
= peer_flag_set(peer
, flag
);
5039 ret
= peer_flag_unset(peer
, flag
);
5041 return bgp_vty_return(vty
, ret
);
5044 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
5046 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
5049 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
5052 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
5055 int peer_flag_modify_nb(struct bgp
*bgp
, const char *ip_str
, struct peer
*peer
,
5056 uint32_t flag
, bool set
, char *errmsg
,
5062 * If 'neighbor <interface>', then this is for directly connected peers,
5063 * we should not accept disable-connected-check.
5065 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5068 "%s is directly connected peer, cannot accept disable-connected-check\n",
5073 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5074 peer_tx_shutdown_message_unset(peer
);
5077 ret
= peer_flag_set(peer
, flag
);
5079 ret
= peer_flag_unset(peer
, flag
);
5081 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
5084 /* neighbor passive. */
5085 DEFUN_YANG(neighbor_passive
,
5086 neighbor_passive_cmd
,
5087 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5090 "Don't send open messages to this neighbor\n")
5093 char base_xpath
[XPATH_MAXLEN
];
5095 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5096 sizeof(base_xpath
), NULL
)
5098 return CMD_WARNING_CONFIG_FAILED
;
5100 nb_cli_enqueue_change(vty
, "./passive-mode", NB_OP_MODIFY
, "true");
5102 return nb_cli_apply_changes(vty
, base_xpath
);
5105 DEFUN_YANG(no_neighbor_passive
,
5106 no_neighbor_passive_cmd
,
5107 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5110 "Don't send open messages to this neighbor\n")
5113 char base_xpath
[XPATH_MAXLEN
];
5115 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5116 sizeof(base_xpath
), NULL
)
5118 return CMD_WARNING_CONFIG_FAILED
;
5120 nb_cli_enqueue_change(vty
, "./passive-mode", NB_OP_MODIFY
, "false");
5122 return nb_cli_apply_changes(vty
, base_xpath
);
5125 /* neighbor shutdown. */
5126 DEFUN_YANG(neighbor_shutdown_msg
,
5127 neighbor_shutdown_msg_cmd
,
5128 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5129 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5130 "Administratively shut down this neighbor\n"
5131 "Add a shutdown message (RFC 8203)\n"
5132 "Shutdown message\n")
5135 char base_xpath
[XPATH_MAXLEN
];
5137 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5138 sizeof(base_xpath
), NULL
)
5140 return CMD_WARNING_CONFIG_FAILED
;
5145 message
= argv_concat(argv
, argc
, 4);
5146 nb_cli_enqueue_change(vty
, "./admin-shutdown/message",
5147 NB_OP_MODIFY
, message
);
5150 nb_cli_enqueue_change(vty
, "./admin-shutdown/enable", NB_OP_MODIFY
,
5153 return nb_cli_apply_changes(vty
, base_xpath
);
5156 ALIAS_YANG(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5157 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5158 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5159 "Administratively shut down this neighbor\n")
5161 DEFUN_YANG(no_neighbor_shutdown_msg
,
5162 no_neighbor_shutdown_msg_cmd
,
5163 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5166 "Administratively shut down this neighbor\n"
5167 "Remove a shutdown message (RFC 8203)\n"
5168 "Shutdown message\n")
5171 char base_xpath
[XPATH_MAXLEN
];
5173 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5174 sizeof(base_xpath
), NULL
)
5176 return CMD_WARNING_CONFIG_FAILED
;
5178 nb_cli_enqueue_change(vty
, "./admin-shutdown/enable", NB_OP_MODIFY
,
5181 return nb_cli_apply_changes(vty
, base_xpath
);
5184 ALIAS_YANG(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5185 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5186 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5187 "Administratively shut down this neighbor\n")
5189 DEFUN(neighbor_shutdown_rtt
,
5190 neighbor_shutdown_rtt_cmd
,
5191 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5194 "Administratively shut down this neighbor\n"
5195 "Shutdown if round-trip-time is higher than expected\n"
5196 "Round-trip-time in milliseconds\n"
5197 "Specify the number of keepalives before shutdown\n"
5198 "The number of keepalives with higher RTT to shutdown\n")
5205 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5208 return CMD_WARNING_CONFIG_FAILED
;
5210 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5212 if (argv_find(argv
, argc
, "count", &idx_count
))
5213 peer
->rtt_keepalive_conf
=
5214 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5216 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5217 PEER_FLAG_RTT_SHUTDOWN
);
5220 DEFUN(no_neighbor_shutdown_rtt
,
5221 no_neighbor_shutdown_rtt_cmd
,
5222 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5226 "Administratively shut down this neighbor\n"
5227 "Shutdown if round-trip-time is higher than expected\n"
5228 "Round-trip-time in milliseconds\n"
5229 "Specify the number of keepalives before shutdown\n"
5230 "The number of keepalives with higher RTT to shutdown\n")
5235 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5238 return CMD_WARNING_CONFIG_FAILED
;
5240 peer
->rtt_expected
= 0;
5241 peer
->rtt_keepalive_conf
= 1;
5243 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5244 PEER_FLAG_RTT_SHUTDOWN
);
5247 /* neighbor capability dynamic. */
5248 DEFUN_YANG (neighbor_capability_dynamic
,
5249 neighbor_capability_dynamic_cmd
,
5250 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5253 "Advertise capability to the peer\n"
5254 "Advertise dynamic capability to this neighbor\n")
5257 char base_xpath
[XPATH_MAXLEN
];
5259 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5260 sizeof(base_xpath
), NULL
)
5262 return CMD_WARNING_CONFIG_FAILED
;
5264 nb_cli_enqueue_change(vty
, "./capability-options/dynamic-capability",
5265 NB_OP_MODIFY
, "true");
5267 return nb_cli_apply_changes(vty
, base_xpath
);
5270 DEFUN_YANG (no_neighbor_capability_dynamic
,
5271 no_neighbor_capability_dynamic_cmd
,
5272 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5276 "Advertise capability to the peer\n"
5277 "Advertise dynamic capability to this neighbor\n")
5280 char base_xpath
[XPATH_MAXLEN
];
5282 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5283 sizeof(base_xpath
), NULL
)
5285 return CMD_WARNING_CONFIG_FAILED
;
5287 nb_cli_enqueue_change(vty
, "./capability-options/dynamic-capability",
5288 NB_OP_MODIFY
, "false");
5290 return nb_cli_apply_changes(vty
, base_xpath
);
5293 /* neighbor dont-capability-negotiate */
5294 DEFUN (neighbor_dont_capability_negotiate
,
5295 neighbor_dont_capability_negotiate_cmd
,
5296 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5299 "Do not perform capability negotiation\n")
5302 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5303 PEER_FLAG_DONT_CAPABILITY
);
5306 DEFUN (no_neighbor_dont_capability_negotiate
,
5307 no_neighbor_dont_capability_negotiate_cmd
,
5308 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5312 "Do not perform capability negotiation\n")
5315 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5316 PEER_FLAG_DONT_CAPABILITY
);
5319 /* neighbor capability extended next hop encoding */
5320 DEFUN_YANG (neighbor_capability_enhe
,
5321 neighbor_capability_enhe_cmd
,
5322 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5325 "Advertise capability to the peer\n"
5326 "Advertise extended next-hop capability to the peer\n")
5329 char base_xpath
[XPATH_MAXLEN
];
5331 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5332 sizeof(base_xpath
), NULL
)
5334 return CMD_WARNING_CONFIG_FAILED
;
5336 nb_cli_enqueue_change(
5337 vty
, "./capability-options/extended-nexthop-capability",
5338 NB_OP_MODIFY
, "true");
5340 return nb_cli_apply_changes(vty
, base_xpath
);
5343 DEFUN_YANG (no_neighbor_capability_enhe
,
5344 no_neighbor_capability_enhe_cmd
,
5345 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5349 "Advertise capability to the peer\n"
5350 "Advertise extended next-hop capability to the peer\n")
5353 char base_xpath
[XPATH_MAXLEN
];
5355 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5356 sizeof(base_xpath
), NULL
)
5358 return CMD_WARNING_CONFIG_FAILED
;
5360 nb_cli_enqueue_change(
5361 vty
, "./capability-options/extended-nexthop-capability",
5362 NB_OP_MODIFY
, "false");
5364 return nb_cli_apply_changes(vty
, base_xpath
);
5367 int peer_af_flag_modify_nb(struct peer
*peer
, afi_t afi
, safi_t safi
,
5368 uint32_t flag
, int set
, char *errmsg
,
5374 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5376 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5378 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
5381 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5382 afi_t afi
, safi_t safi
, uint32_t flag
,
5388 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5390 return CMD_WARNING_CONFIG_FAILED
;
5393 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5395 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5397 return bgp_vty_return(vty
, ret
);
5400 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5401 afi_t afi
, safi_t safi
, uint32_t flag
)
5403 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5406 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5407 afi_t afi
, safi_t safi
, uint32_t flag
)
5409 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5412 /* neighbor capability orf prefix-list. */
5413 DEFUN (neighbor_capability_orf_prefix
,
5414 neighbor_capability_orf_prefix_cmd
,
5415 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5418 "Advertise capability to the peer\n"
5419 "Advertise ORF capability to the peer\n"
5420 "Advertise prefixlist ORF capability to this neighbor\n"
5421 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5422 "Capability to RECEIVE the ORF from this neighbor\n"
5423 "Capability to SEND the ORF to this neighbor\n")
5425 int idx_send_recv
= 5;
5426 char *peer_str
= argv
[1]->arg
;
5428 afi_t afi
= bgp_node_afi(vty
);
5429 safi_t safi
= bgp_node_safi(vty
);
5431 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5433 return CMD_WARNING_CONFIG_FAILED
;
5435 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5436 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5437 PEER_FLAG_ORF_PREFIX_SM
);
5439 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5440 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5441 PEER_FLAG_ORF_PREFIX_RM
);
5443 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5444 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5445 PEER_FLAG_ORF_PREFIX_SM
)
5446 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5447 PEER_FLAG_ORF_PREFIX_RM
);
5449 return CMD_WARNING_CONFIG_FAILED
;
5453 neighbor_capability_orf_prefix
,
5454 neighbor_capability_orf_prefix_hidden_cmd
,
5455 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5456 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5457 "Advertise capability to the peer\n"
5458 "Advertise ORF capability to the peer\n"
5459 "Advertise prefixlist ORF capability to this neighbor\n"
5460 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5461 "Capability to RECEIVE the ORF from this neighbor\n"
5462 "Capability to SEND the ORF to this neighbor\n")
5464 DEFUN (no_neighbor_capability_orf_prefix
,
5465 no_neighbor_capability_orf_prefix_cmd
,
5466 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5470 "Advertise capability to the peer\n"
5471 "Advertise ORF capability to the peer\n"
5472 "Advertise prefixlist ORF capability to this neighbor\n"
5473 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5474 "Capability to RECEIVE the ORF from this neighbor\n"
5475 "Capability to SEND the ORF to this neighbor\n")
5477 int idx_send_recv
= 6;
5478 char *peer_str
= argv
[2]->arg
;
5480 afi_t afi
= bgp_node_afi(vty
);
5481 safi_t safi
= bgp_node_safi(vty
);
5483 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5485 return CMD_WARNING_CONFIG_FAILED
;
5487 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5488 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5489 PEER_FLAG_ORF_PREFIX_SM
);
5491 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5492 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5493 PEER_FLAG_ORF_PREFIX_RM
);
5495 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5496 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5497 PEER_FLAG_ORF_PREFIX_SM
)
5498 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5499 PEER_FLAG_ORF_PREFIX_RM
);
5501 return CMD_WARNING_CONFIG_FAILED
;
5505 no_neighbor_capability_orf_prefix
,
5506 no_neighbor_capability_orf_prefix_hidden_cmd
,
5507 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5508 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5509 "Advertise capability to the peer\n"
5510 "Advertise ORF capability to the peer\n"
5511 "Advertise prefixlist ORF capability to this neighbor\n"
5512 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5513 "Capability to RECEIVE the ORF from this neighbor\n"
5514 "Capability to SEND the ORF to this neighbor\n")
5516 /* neighbor next-hop-self. */
5517 DEFUN_YANG (neighbor_nexthop_self
,
5518 neighbor_nexthop_self_cmd
,
5519 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5522 "Disable the next hop calculation for this neighbor\n")
5525 char base_xpath
[XPATH_MAXLEN
];
5526 char af_xpath
[XPATH_MAXLEN
];
5527 char attr_xpath
[XPATH_MAXLEN
];
5528 afi_t afi
= bgp_node_afi(vty
);
5529 safi_t safi
= bgp_node_safi(vty
);
5532 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5533 yang_afi_safi_value2identity(afi
, safi
));
5535 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5536 sizeof(base_xpath
), af_xpath
)
5538 return CMD_WARNING_CONFIG_FAILED
;
5540 snprintf(attr_xpath
, sizeof(attr_xpath
),
5541 "./%s/nexthop-self/next-hop-self",
5542 bgp_afi_safi_get_container_str(afi
, safi
));
5544 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5546 return nb_cli_apply_changes(vty
, base_xpath
);
5549 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5550 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5551 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5552 "Disable the next hop calculation for this neighbor\n")
5554 /* neighbor next-hop-self. */
5555 DEFUN_YANG(neighbor_nexthop_self_force
,
5556 neighbor_nexthop_self_force_cmd
,
5557 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5560 "Disable the next hop calculation for this neighbor\n"
5561 "Set the next hop to self for reflected routes\n")
5564 char base_xpath
[XPATH_MAXLEN
];
5565 char af_xpath
[XPATH_MAXLEN
];
5566 char attr_xpath
[XPATH_MAXLEN
];
5567 afi_t afi
= bgp_node_afi(vty
);
5568 safi_t safi
= bgp_node_safi(vty
);
5571 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5572 yang_afi_safi_value2identity(afi
, safi
));
5574 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5575 sizeof(base_xpath
), af_xpath
)
5577 return CMD_WARNING_CONFIG_FAILED
;
5579 snprintf(attr_xpath
, sizeof(attr_xpath
),
5580 "./%s/nexthop-self/next-hop-self-force",
5581 bgp_afi_safi_get_container_str(afi
, safi
));
5583 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5585 return nb_cli_apply_changes(vty
, base_xpath
);
5588 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5589 neighbor_nexthop_self_force_hidden_cmd
,
5590 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5591 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5592 "Disable the next hop calculation for this neighbor\n"
5593 "Set the next hop to self for reflected routes\n")
5595 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5596 neighbor_nexthop_self_all_hidden_cmd
,
5597 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5598 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5599 "Disable the next hop calculation for this neighbor\n"
5600 "Set the next hop to self for reflected routes\n")
5602 DEFUN_YANG (no_neighbor_nexthop_self
,
5603 no_neighbor_nexthop_self_cmd
,
5604 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5608 "Disable the next hop calculation for this neighbor\n")
5611 char base_xpath
[XPATH_MAXLEN
];
5612 char af_xpath
[XPATH_MAXLEN
];
5613 char attr_xpath
[XPATH_MAXLEN
];
5614 afi_t afi
= bgp_node_afi(vty
);
5615 safi_t safi
= bgp_node_safi(vty
);
5617 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5618 yang_afi_safi_value2identity(afi
, safi
));
5620 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5621 sizeof(base_xpath
), af_xpath
)
5623 return CMD_WARNING_CONFIG_FAILED
;
5625 snprintf(attr_xpath
, sizeof(attr_xpath
),
5626 "./%s/nexthop-self/next-hop-self",
5627 bgp_afi_safi_get_container_str(afi
, safi
));
5629 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5631 return nb_cli_apply_changes(vty
, base_xpath
);
5634 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5635 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5636 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5637 "Disable the next hop calculation for this neighbor\n")
5639 DEFUN_YANG (no_neighbor_nexthop_self_force
,
5640 no_neighbor_nexthop_self_force_cmd
,
5641 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5645 "Disable the next hop calculation for this neighbor\n"
5646 "Set the next hop to self for reflected routes\n")
5649 char base_xpath
[XPATH_MAXLEN
];
5650 char af_xpath
[XPATH_MAXLEN
];
5651 char attr_xpath
[XPATH_MAXLEN
];
5652 afi_t afi
= bgp_node_afi(vty
);
5653 safi_t safi
= bgp_node_safi(vty
);
5656 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5657 yang_afi_safi_value2identity(afi
, safi
));
5659 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5660 sizeof(base_xpath
), af_xpath
)
5662 return CMD_WARNING_CONFIG_FAILED
;
5664 snprintf(attr_xpath
, sizeof(attr_xpath
),
5665 "./%s/nexthop-self/next-hop-self-force",
5666 bgp_afi_safi_get_container_str(afi
, safi
));
5668 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5670 return nb_cli_apply_changes(vty
, base_xpath
);
5673 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5674 no_neighbor_nexthop_self_force_hidden_cmd
,
5675 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5676 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5677 "Disable the next hop calculation for this neighbor\n"
5678 "Set the next hop to self for reflected routes\n")
5680 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5681 no_neighbor_nexthop_self_all_hidden_cmd
,
5682 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5683 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5684 "Disable the next hop calculation for this neighbor\n"
5685 "Set the next hop to self for reflected routes\n")
5687 /* neighbor as-override */
5688 DEFUN_YANG (neighbor_as_override
,
5689 neighbor_as_override_cmd
,
5690 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5693 "Override ASNs in outbound updates if aspath equals remote-as\n")
5696 char base_xpath
[XPATH_MAXLEN
];
5697 char af_xpath
[XPATH_MAXLEN
];
5698 char attr_xpath
[XPATH_MAXLEN
];
5699 afi_t afi
= bgp_node_afi(vty
);
5700 safi_t safi
= bgp_node_safi(vty
);
5702 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5703 yang_afi_safi_value2identity(afi
, safi
));
5705 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5706 sizeof(base_xpath
), af_xpath
)
5708 return CMD_WARNING_CONFIG_FAILED
;
5710 snprintf(attr_xpath
, sizeof(attr_xpath
),
5711 "./%s/as-path-options/replace-peer-as",
5712 bgp_afi_safi_get_container_str(afi
, safi
));
5714 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5716 return nb_cli_apply_changes(vty
, base_xpath
);
5719 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5720 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5721 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5722 "Override ASNs in outbound updates if aspath equals remote-as\n")
5724 DEFUN_YANG (no_neighbor_as_override
,
5725 no_neighbor_as_override_cmd
,
5726 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5730 "Override ASNs in outbound updates if aspath equals remote-as\n")
5733 char base_xpath
[XPATH_MAXLEN
];
5734 char af_xpath
[XPATH_MAXLEN
];
5735 char attr_xpath
[XPATH_MAXLEN
];
5736 afi_t afi
= bgp_node_afi(vty
);
5737 safi_t safi
= bgp_node_safi(vty
);
5739 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5740 yang_afi_safi_value2identity(afi
, safi
));
5742 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5743 sizeof(base_xpath
), af_xpath
)
5745 return CMD_WARNING_CONFIG_FAILED
;
5747 snprintf(attr_xpath
, sizeof(attr_xpath
),
5748 "./%s/as-path-options/replace-peer-as",
5749 bgp_afi_safi_get_container_str(afi
, safi
));
5751 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5753 return nb_cli_apply_changes(vty
, base_xpath
);
5756 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5757 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5758 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5759 "Override ASNs in outbound updates if aspath equals remote-as\n")
5761 /* neighbor remove-private-AS. */
5762 DEFUN_YANG (neighbor_remove_private_as
,
5763 neighbor_remove_private_as_cmd
,
5764 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5767 "Remove private ASNs in outbound updates\n")
5770 char base_xpath
[XPATH_MAXLEN
];
5771 char af_xpath
[XPATH_MAXLEN
];
5772 char attr_xpath
[XPATH_MAXLEN
];
5773 afi_t afi
= bgp_node_afi(vty
);
5774 safi_t safi
= bgp_node_safi(vty
);
5776 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5777 yang_afi_safi_value2identity(afi
, safi
));
5779 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5780 sizeof(base_xpath
), af_xpath
)
5782 return CMD_WARNING_CONFIG_FAILED
;
5784 snprintf(attr_xpath
, sizeof(attr_xpath
),
5785 "./%s/private-as/remove-private-as",
5786 bgp_afi_safi_get_container_str(afi
, safi
));
5788 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5790 return nb_cli_apply_changes(vty
, base_xpath
);
5793 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5794 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5795 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5796 "Remove private ASNs in outbound updates\n")
5798 DEFUN_YANG (neighbor_remove_private_as_all
,
5799 neighbor_remove_private_as_all_cmd
,
5800 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5803 "Remove private ASNs in outbound updates\n"
5804 "Apply to all AS numbers\n")
5807 char base_xpath
[XPATH_MAXLEN
];
5808 char af_xpath
[XPATH_MAXLEN
];
5809 char attr_xpath
[XPATH_MAXLEN
];
5810 afi_t afi
= bgp_node_afi(vty
);
5811 safi_t safi
= bgp_node_safi(vty
);
5814 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5815 yang_afi_safi_value2identity(afi
, safi
));
5817 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5818 sizeof(base_xpath
), af_xpath
)
5820 return CMD_WARNING_CONFIG_FAILED
;
5822 snprintf(attr_xpath
, sizeof(attr_xpath
),
5823 "./%s/private-as/remove-private-as-all",
5824 bgp_afi_safi_get_container_str(afi
, safi
));
5826 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5828 return nb_cli_apply_changes(vty
, base_xpath
);
5831 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5832 neighbor_remove_private_as_all_hidden_cmd
,
5833 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5834 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5835 "Remove private ASNs in outbound updates\n"
5836 "Apply to all AS numbers")
5838 DEFUN_YANG (neighbor_remove_private_as_replace_as
,
5839 neighbor_remove_private_as_replace_as_cmd
,
5840 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5843 "Remove private ASNs in outbound updates\n"
5844 "Replace private ASNs with our ASN in outbound updates\n")
5847 char base_xpath
[XPATH_MAXLEN
];
5848 char af_xpath
[XPATH_MAXLEN
];
5849 char attr_xpath
[XPATH_MAXLEN
];
5850 afi_t afi
= bgp_node_afi(vty
);
5851 safi_t safi
= bgp_node_safi(vty
);
5854 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5855 yang_afi_safi_value2identity(afi
, safi
));
5857 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5858 sizeof(base_xpath
), af_xpath
)
5860 return CMD_WARNING_CONFIG_FAILED
;
5862 snprintf(attr_xpath
, sizeof(attr_xpath
),
5863 "./%s/private-as/remove-private-as-replace",
5864 bgp_afi_safi_get_container_str(afi
, safi
));
5866 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5868 return nb_cli_apply_changes(vty
, base_xpath
);
5871 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5872 neighbor_remove_private_as_replace_as_hidden_cmd
,
5873 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5874 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5875 "Remove private ASNs in outbound updates\n"
5876 "Replace private ASNs with our ASN in outbound updates\n")
5878 DEFUN_YANG (neighbor_remove_private_as_all_replace_as
,
5879 neighbor_remove_private_as_all_replace_as_cmd
,
5880 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5883 "Remove private ASNs in outbound updates\n"
5884 "Apply to all AS numbers\n"
5885 "Replace private ASNs with our ASN in outbound updates\n")
5888 char base_xpath
[XPATH_MAXLEN
];
5889 char af_xpath
[XPATH_MAXLEN
];
5890 char attr_xpath
[XPATH_MAXLEN
];
5891 afi_t afi
= bgp_node_afi(vty
);
5892 safi_t safi
= bgp_node_safi(vty
);
5895 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5896 yang_afi_safi_value2identity(afi
, safi
));
5898 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5899 sizeof(base_xpath
), af_xpath
)
5901 return CMD_WARNING_CONFIG_FAILED
;
5903 snprintf(attr_xpath
, sizeof(attr_xpath
),
5904 "./%s/private-as/remove-private-as-all-replace",
5905 bgp_afi_safi_get_container_str(afi
, safi
));
5907 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5909 return nb_cli_apply_changes(vty
, base_xpath
);
5913 neighbor_remove_private_as_all_replace_as
,
5914 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5915 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5916 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5917 "Remove private ASNs in outbound updates\n"
5918 "Apply to all AS numbers\n"
5919 "Replace private ASNs with our ASN in outbound updates\n")
5921 DEFUN_YANG (no_neighbor_remove_private_as
,
5922 no_neighbor_remove_private_as_cmd
,
5923 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5927 "Remove private ASNs in outbound updates\n")
5930 char base_xpath
[XPATH_MAXLEN
];
5931 char af_xpath
[XPATH_MAXLEN
];
5932 char attr_xpath
[XPATH_MAXLEN
];
5933 afi_t afi
= bgp_node_afi(vty
);
5934 safi_t safi
= bgp_node_safi(vty
);
5936 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5937 yang_afi_safi_value2identity(afi
, safi
));
5939 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5940 sizeof(base_xpath
), af_xpath
)
5942 return CMD_WARNING_CONFIG_FAILED
;
5944 snprintf(attr_xpath
, sizeof(attr_xpath
),
5945 "./%s/private-as/remove-private-as",
5946 bgp_afi_safi_get_container_str(afi
, safi
));
5948 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5950 return nb_cli_apply_changes(vty
, base_xpath
);
5953 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5954 no_neighbor_remove_private_as_hidden_cmd
,
5955 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5956 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5957 "Remove private ASNs in outbound updates\n")
5959 DEFUN_YANG (no_neighbor_remove_private_as_all
,
5960 no_neighbor_remove_private_as_all_cmd
,
5961 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5965 "Remove private ASNs in outbound updates\n"
5966 "Apply to all AS numbers\n")
5969 char base_xpath
[XPATH_MAXLEN
];
5970 char af_xpath
[XPATH_MAXLEN
];
5971 char attr_xpath
[XPATH_MAXLEN
];
5972 afi_t afi
= bgp_node_afi(vty
);
5973 safi_t safi
= bgp_node_safi(vty
);
5976 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5977 yang_afi_safi_value2identity(afi
, safi
));
5979 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5980 sizeof(base_xpath
), af_xpath
)
5982 return CMD_WARNING_CONFIG_FAILED
;
5984 snprintf(attr_xpath
, sizeof(attr_xpath
),
5985 "./%s/private-as/remove-private-as-all",
5986 bgp_afi_safi_get_container_str(afi
, safi
));
5988 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5990 return nb_cli_apply_changes(vty
, base_xpath
);
5993 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5994 no_neighbor_remove_private_as_all_hidden_cmd
,
5995 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5996 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5997 "Remove private ASNs in outbound updates\n"
5998 "Apply to all AS numbers\n")
6000 DEFUN_YANG (no_neighbor_remove_private_as_replace_as
,
6001 no_neighbor_remove_private_as_replace_as_cmd
,
6002 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
6006 "Remove private ASNs in outbound updates\n"
6007 "Replace private ASNs with our ASN in outbound updates\n")
6010 char base_xpath
[XPATH_MAXLEN
];
6011 char af_xpath
[XPATH_MAXLEN
];
6012 char attr_xpath
[XPATH_MAXLEN
];
6013 afi_t afi
= bgp_node_afi(vty
);
6014 safi_t safi
= bgp_node_safi(vty
);
6017 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6018 yang_afi_safi_value2identity(afi
, safi
));
6020 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6021 sizeof(base_xpath
), af_xpath
)
6023 return CMD_WARNING_CONFIG_FAILED
;
6025 snprintf(attr_xpath
, sizeof(attr_xpath
),
6026 "./%s/private-as/remove-private-as-replace",
6027 bgp_afi_safi_get_container_str(afi
, safi
));
6029 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6031 return nb_cli_apply_changes(vty
, base_xpath
);
6034 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
6035 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
6036 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
6037 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6038 "Remove private ASNs in outbound updates\n"
6039 "Replace private ASNs with our ASN in outbound updates\n")
6041 DEFUN_YANG (no_neighbor_remove_private_as_all_replace_as
,
6042 no_neighbor_remove_private_as_all_replace_as_cmd
,
6043 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6047 "Remove private ASNs in outbound updates\n"
6048 "Apply to all AS numbers\n"
6049 "Replace private ASNs with our ASN in outbound updates\n")
6052 char base_xpath
[XPATH_MAXLEN
];
6053 char af_xpath
[XPATH_MAXLEN
];
6054 char attr_xpath
[XPATH_MAXLEN
];
6055 afi_t afi
= bgp_node_afi(vty
);
6056 safi_t safi
= bgp_node_safi(vty
);
6059 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6060 yang_afi_safi_value2identity(afi
, safi
));
6062 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6063 sizeof(base_xpath
), af_xpath
)
6065 return CMD_WARNING_CONFIG_FAILED
;
6067 snprintf(attr_xpath
, sizeof(attr_xpath
),
6068 "./%s/private-as/remove-private-as-all-replace",
6069 bgp_afi_safi_get_container_str(afi
, safi
));
6071 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6073 return nb_cli_apply_changes(vty
, base_xpath
);
6077 no_neighbor_remove_private_as_all_replace_as
,
6078 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
6079 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6080 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6081 "Remove private ASNs in outbound updates\n"
6082 "Apply to all AS numbers\n"
6083 "Replace private ASNs with our ASN in outbound updates\n")
6086 /* neighbor send-community. */
6087 DEFUN_YANG (neighbor_send_community
,
6088 neighbor_send_community_cmd
,
6089 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6092 "Send Community attribute to this neighbor\n")
6096 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6098 PEER_FLAG_SEND_COMMUNITY
);
6101 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
6102 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6103 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6104 "Send Community attribute to this neighbor\n")
6106 DEFUN_YANG (no_neighbor_send_community
,
6107 no_neighbor_send_community_cmd
,
6108 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6112 "Send Community attribute to this neighbor\n")
6116 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6117 bgp_node_afi(vty
), bgp_node_safi(vty
),
6118 PEER_FLAG_SEND_COMMUNITY
);
6121 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
6122 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6123 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6124 "Send Community attribute to this neighbor\n")
6126 /* neighbor send-community extended. */
6127 DEFUN_YANG (neighbor_send_community_type
,
6128 neighbor_send_community_type_cmd
,
6129 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6132 "Send Community attribute to this neighbor\n"
6133 "Send Standard and Extended Community attributes\n"
6134 "Send Standard, Large and Extended Community attributes\n"
6135 "Send Extended Community attributes\n"
6136 "Send Standard Community attributes\n"
6137 "Send Large Community attributes\n")
6139 const char *type
= argv
[argc
- 1]->text
;
6140 char *peer_str
= argv
[1]->arg
;
6141 char base_xpath
[XPATH_MAXLEN
];
6142 char af_xpath
[XPATH_MAXLEN
];
6143 char std_xpath
[XPATH_MAXLEN
];
6144 char ext_xpath
[XPATH_MAXLEN
];
6145 char lrg_xpath
[XPATH_MAXLEN
];
6146 afi_t afi
= bgp_node_afi(vty
);
6147 safi_t safi
= bgp_node_safi(vty
);
6149 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6150 yang_afi_safi_value2identity(afi
, safi
));
6152 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6153 sizeof(base_xpath
), af_xpath
)
6155 return CMD_WARNING_CONFIG_FAILED
;
6157 if (strmatch(type
, "standard")) {
6158 snprintf(std_xpath
, sizeof(std_xpath
),
6159 "./%s/send-community/send-community",
6160 bgp_afi_safi_get_container_str(afi
, safi
));
6162 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6165 if (strmatch(type
, "extended")) {
6166 snprintf(ext_xpath
, sizeof(ext_xpath
),
6167 "./%s/send-community/send-ext-community",
6168 bgp_afi_safi_get_container_str(afi
, safi
));
6170 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6173 if (strmatch(type
, "large")) {
6174 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6175 "./%s/send-community/send-large-community",
6176 bgp_afi_safi_get_container_str(afi
, safi
));
6178 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "true");
6181 if (strmatch(type
, "both")) {
6182 snprintf(std_xpath
, sizeof(std_xpath
),
6183 "./%s/send-community/send-community",
6184 bgp_afi_safi_get_container_str(afi
, safi
));
6186 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6188 snprintf(ext_xpath
, sizeof(ext_xpath
),
6189 "./%s/send-community/send-ext-community",
6190 bgp_afi_safi_get_container_str(afi
, safi
));
6192 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6195 if (strmatch(type
, "all")) {
6196 snprintf(std_xpath
, sizeof(std_xpath
),
6197 "./%s/send-community/send-community",
6198 bgp_afi_safi_get_container_str(afi
, safi
));
6200 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6202 snprintf(ext_xpath
, sizeof(ext_xpath
),
6203 "./%s/send-community/send-ext-community",
6204 bgp_afi_safi_get_container_str(afi
, safi
));
6206 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6208 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6209 "./%s/send-community/send-large-community",
6210 bgp_afi_safi_get_container_str(afi
, safi
));
6212 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "true");
6215 return nb_cli_apply_changes(vty
, base_xpath
);
6219 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6220 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6221 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6222 "Send Community attribute to this neighbor\n"
6223 "Send Standard and Extended Community attributes\n"
6224 "Send Standard, Large and Extended Community attributes\n"
6225 "Send Extended Community attributes\n"
6226 "Send Standard Community attributes\n"
6227 "Send Large Community attributes\n")
6229 DEFUN_YANG (no_neighbor_send_community_type
,
6230 no_neighbor_send_community_type_cmd
,
6231 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6235 "Send Community attribute to this neighbor\n"
6236 "Send Standard and Extended Community attributes\n"
6237 "Send Standard, Large and Extended Community attributes\n"
6238 "Send Extended Community attributes\n"
6239 "Send Standard Community attributes\n"
6240 "Send Large Community attributes\n")
6242 const char *type
= argv
[argc
- 1]->text
;
6243 char *peer_str
= argv
[2]->arg
;
6244 char base_xpath
[XPATH_MAXLEN
];
6245 char af_xpath
[XPATH_MAXLEN
];
6246 char std_xpath
[XPATH_MAXLEN
];
6247 char ext_xpath
[XPATH_MAXLEN
];
6248 char lrg_xpath
[XPATH_MAXLEN
];
6249 afi_t afi
= bgp_node_afi(vty
);
6250 safi_t safi
= bgp_node_safi(vty
);
6252 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6253 yang_afi_safi_value2identity(afi
, safi
));
6255 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6256 sizeof(base_xpath
), af_xpath
)
6258 return CMD_WARNING_CONFIG_FAILED
;
6260 if (strmatch(type
, "standard")) {
6261 snprintf(std_xpath
, sizeof(std_xpath
),
6262 "./%s/send-community/send-community",
6263 bgp_afi_safi_get_container_str(afi
, safi
));
6265 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6268 if (strmatch(type
, "extended")) {
6269 snprintf(ext_xpath
, sizeof(ext_xpath
),
6270 "./%s/send-community/send-ext-community",
6271 bgp_afi_safi_get_container_str(afi
, safi
));
6273 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6276 if (strmatch(type
, "large")) {
6277 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6278 "./%s/send-community/send-large-community",
6279 bgp_afi_safi_get_container_str(afi
, safi
));
6281 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "false");
6284 if (strmatch(type
, "both")) {
6285 snprintf(std_xpath
, sizeof(std_xpath
),
6286 "./%s/send-community/send-community",
6287 bgp_afi_safi_get_container_str(afi
, safi
));
6289 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6291 snprintf(ext_xpath
, sizeof(ext_xpath
),
6292 "./%s/send-community/send-ext-community",
6293 bgp_afi_safi_get_container_str(afi
, safi
));
6295 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6298 if (strmatch(type
, "all")) {
6299 snprintf(std_xpath
, sizeof(std_xpath
),
6300 "./%s/send-community/send-community",
6301 bgp_afi_safi_get_container_str(afi
, safi
));
6303 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6305 snprintf(ext_xpath
, sizeof(ext_xpath
),
6306 "./%s/send-community/send-ext-community",
6307 bgp_afi_safi_get_container_str(afi
, safi
));
6309 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6311 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6312 "./%s/send-community/send-large-community",
6313 bgp_afi_safi_get_container_str(afi
, safi
));
6315 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "false");
6318 return nb_cli_apply_changes(vty
, base_xpath
);
6322 no_neighbor_send_community_type
,
6323 no_neighbor_send_community_type_hidden_cmd
,
6324 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6325 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6326 "Send Community attribute to this neighbor\n"
6327 "Send Standard and Extended Community attributes\n"
6328 "Send Standard, Large and Extended Community attributes\n"
6329 "Send Extended Community attributes\n"
6330 "Send Standard Community attributes\n"
6331 "Send Large Community attributes\n")
6333 /* neighbor soft-reconfig. */
6334 DEFUN_YANG (neighbor_soft_reconfiguration
,
6335 neighbor_soft_reconfiguration_cmd
,
6336 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6337 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6338 "Per neighbor soft reconfiguration\n"
6339 "Allow inbound soft reconfiguration for this neighbor\n")
6342 char base_xpath
[XPATH_MAXLEN
];
6343 char af_xpath
[XPATH_MAXLEN
];
6344 char soft_xpath
[XPATH_MAXLEN
];
6345 afi_t afi
= bgp_node_afi(vty
);
6346 safi_t safi
= bgp_node_safi(vty
);
6349 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6350 yang_afi_safi_value2identity(afi
, safi
));
6352 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6353 sizeof(base_xpath
), af_xpath
)
6355 return CMD_WARNING_CONFIG_FAILED
;
6357 snprintf(soft_xpath
, sizeof(soft_xpath
), "./%s/soft-reconfiguration",
6358 bgp_afi_safi_get_container_str(afi
, safi
));
6360 nb_cli_enqueue_change(vty
, soft_xpath
, NB_OP_MODIFY
, "true");
6362 return nb_cli_apply_changes(vty
, base_xpath
);
6365 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6366 neighbor_soft_reconfiguration_hidden_cmd
,
6367 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6368 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6369 "Per neighbor soft reconfiguration\n"
6370 "Allow inbound soft reconfiguration for this neighbor\n")
6372 DEFUN_YANG (no_neighbor_soft_reconfiguration
,
6373 no_neighbor_soft_reconfiguration_cmd
,
6374 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6375 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6376 "Per neighbor soft reconfiguration\n"
6377 "Allow inbound soft reconfiguration for this neighbor\n")
6380 char base_xpath
[XPATH_MAXLEN
];
6381 char af_xpath
[XPATH_MAXLEN
];
6382 char soft_xpath
[XPATH_MAXLEN
];
6383 afi_t afi
= bgp_node_afi(vty
);
6384 safi_t safi
= bgp_node_safi(vty
);
6386 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6387 yang_afi_safi_value2identity(afi
, safi
));
6389 snprintf(soft_xpath
, sizeof(soft_xpath
), "./%s/soft-reconfiguration",
6390 bgp_afi_safi_get_container_str(afi
, safi
));
6392 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6393 sizeof(base_xpath
), af_xpath
)
6395 return CMD_WARNING_CONFIG_FAILED
;
6397 nb_cli_enqueue_change(vty
, soft_xpath
, NB_OP_MODIFY
, "false");
6399 return nb_cli_apply_changes(vty
, base_xpath
);
6402 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6403 no_neighbor_soft_reconfiguration_hidden_cmd
,
6404 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6405 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6406 "Per neighbor soft reconfiguration\n"
6407 "Allow inbound soft reconfiguration for this neighbor\n")
6409 DEFUN_YANG (neighbor_route_reflector_client
,
6410 neighbor_route_reflector_client_cmd
,
6411 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6414 "Configure a neighbor as Route Reflector client\n")
6417 char base_xpath
[XPATH_MAXLEN
];
6418 char af_xpath
[XPATH_MAXLEN
];
6419 char attr_xpath
[XPATH_MAXLEN
];
6420 afi_t afi
= bgp_node_afi(vty
);
6421 safi_t safi
= bgp_node_safi(vty
);
6423 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6424 yang_afi_safi_value2identity(afi
, safi
));
6426 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6427 sizeof(base_xpath
), af_xpath
)
6429 return CMD_WARNING_CONFIG_FAILED
;
6431 snprintf(attr_xpath
, sizeof(attr_xpath
),
6432 "./%s/route-reflector/route-reflector-client",
6433 bgp_afi_safi_get_container_str(afi
, safi
));
6435 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6437 return nb_cli_apply_changes(vty
, base_xpath
);
6440 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6441 neighbor_route_reflector_client_hidden_cmd
,
6442 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6443 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6444 "Configure a neighbor as Route Reflector client\n")
6446 DEFUN_YANG (no_neighbor_route_reflector_client
,
6447 no_neighbor_route_reflector_client_cmd
,
6448 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6452 "Configure a neighbor as Route Reflector client\n")
6455 char base_xpath
[XPATH_MAXLEN
];
6456 char af_xpath
[XPATH_MAXLEN
];
6457 char attr_xpath
[XPATH_MAXLEN
];
6458 afi_t afi
= bgp_node_afi(vty
);
6459 safi_t safi
= bgp_node_safi(vty
);
6461 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6462 yang_afi_safi_value2identity(afi
, safi
));
6464 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6465 sizeof(base_xpath
), af_xpath
)
6467 return CMD_WARNING_CONFIG_FAILED
;
6469 snprintf(attr_xpath
, sizeof(attr_xpath
),
6470 "./%s/route-reflector/route-reflector-client",
6471 bgp_afi_safi_get_container_str(afi
, safi
));
6473 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6475 return nb_cli_apply_changes(vty
, base_xpath
);
6478 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6479 no_neighbor_route_reflector_client_hidden_cmd
,
6480 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6481 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6482 "Configure a neighbor as Route Reflector client\n")
6484 /* neighbor route-server-client. */
6485 DEFUN_YANG (neighbor_route_server_client
,
6486 neighbor_route_server_client_cmd
,
6487 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6490 "Configure a neighbor as Route Server client\n")
6493 char base_xpath
[XPATH_MAXLEN
];
6494 char af_xpath
[XPATH_MAXLEN
];
6495 char attr_xpath
[XPATH_MAXLEN
];
6496 afi_t afi
= bgp_node_afi(vty
);
6497 safi_t safi
= bgp_node_safi(vty
);
6499 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6500 yang_afi_safi_value2identity(afi
, safi
));
6502 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6503 sizeof(base_xpath
), af_xpath
)
6505 return CMD_WARNING_CONFIG_FAILED
;
6507 snprintf(attr_xpath
, sizeof(attr_xpath
),
6508 "./%s/route-server/route-server-client",
6509 bgp_afi_safi_get_container_str(afi
, safi
));
6511 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6513 return nb_cli_apply_changes(vty
, base_xpath
);
6516 ALIAS_HIDDEN(neighbor_route_server_client
,
6517 neighbor_route_server_client_hidden_cmd
,
6518 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6519 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6520 "Configure a neighbor as Route Server client\n")
6522 DEFUN_YANG (no_neighbor_route_server_client
,
6523 no_neighbor_route_server_client_cmd
,
6524 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6528 "Configure a neighbor as Route Server client\n")
6531 char base_xpath
[XPATH_MAXLEN
];
6532 char af_xpath
[XPATH_MAXLEN
];
6533 char attr_xpath
[XPATH_MAXLEN
];
6534 afi_t afi
= bgp_node_afi(vty
);
6535 safi_t safi
= bgp_node_safi(vty
);
6537 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6538 yang_afi_safi_value2identity(afi
, safi
));
6540 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6541 sizeof(base_xpath
), af_xpath
)
6543 return CMD_WARNING_CONFIG_FAILED
;
6545 snprintf(attr_xpath
, sizeof(attr_xpath
),
6546 "./%s/route-server/route-server-client",
6547 bgp_afi_safi_get_container_str(afi
, safi
));
6549 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6551 return nb_cli_apply_changes(vty
, base_xpath
);
6554 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6555 no_neighbor_route_server_client_hidden_cmd
,
6556 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6557 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6558 "Configure a neighbor as Route Server client\n")
6560 DEFUN (neighbor_nexthop_local_unchanged
,
6561 neighbor_nexthop_local_unchanged_cmd
,
6562 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6565 "Configure treatment of outgoing link-local nexthop attribute\n"
6566 "Leave link-local nexthop unchanged for this peer\n")
6569 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6571 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6574 DEFUN (no_neighbor_nexthop_local_unchanged
,
6575 no_neighbor_nexthop_local_unchanged_cmd
,
6576 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6580 "Configure treatment of outgoing link-local-nexthop attribute\n"
6581 "Leave link-local nexthop unchanged for this peer\n")
6584 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6585 bgp_node_afi(vty
), bgp_node_safi(vty
),
6586 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6589 DEFUN_YANG (neighbor_attr_unchanged
,
6590 neighbor_attr_unchanged_cmd
,
6591 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6594 "BGP attribute is propagated unchanged to this neighbor\n"
6595 "As-path attribute\n"
6596 "Nexthop attribute\n"
6600 char *peer_str
= argv
[1]->arg
;
6601 bool aspath
= false;
6602 bool nexthop
= false;
6604 afi_t afi
= bgp_node_afi(vty
);
6605 safi_t safi
= bgp_node_safi(vty
);
6606 char base_xpath
[XPATH_MAXLEN
];
6607 char af_xpath
[XPATH_MAXLEN
];
6608 char as_xpath
[XPATH_MAXLEN
];
6609 char nxthop_xpath
[XPATH_MAXLEN
];
6610 char med_xpath
[XPATH_MAXLEN
];
6612 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6613 yang_afi_safi_value2identity(afi
, safi
));
6615 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6616 sizeof(base_xpath
), af_xpath
)
6618 return CMD_WARNING_CONFIG_FAILED
;
6620 if (argv_find(argv
, argc
, "as-path", &idx
))
6624 if (argv_find(argv
, argc
, "next-hop", &idx
))
6628 if (argv_find(argv
, argc
, "med", &idx
))
6631 snprintf(as_xpath
, sizeof(as_xpath
),
6632 "./%s/attr-unchanged/as-path-unchanged",
6633 bgp_afi_safi_get_container_str(afi
, safi
));
6634 snprintf(nxthop_xpath
, sizeof(nxthop_xpath
),
6635 "./%s/attr-unchanged/next-hop-unchanged",
6636 bgp_afi_safi_get_container_str(afi
, safi
));
6637 snprintf(med_xpath
, sizeof(med_xpath
),
6638 "./%s/attr-unchanged/med-unchanged",
6639 bgp_afi_safi_get_container_str(afi
, safi
));
6641 /* no flags means all of them! */
6642 if (!aspath
&& !nexthop
&& !med
) {
6643 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "true");
6644 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "true");
6645 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "true");
6648 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
,
6651 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
,
6655 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
,
6658 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
,
6662 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
,
6665 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
,
6669 return nb_cli_apply_changes(vty
, base_xpath
);
6673 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6674 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6675 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6676 "BGP attribute is propagated unchanged to this neighbor\n"
6677 "As-path attribute\n"
6678 "Nexthop attribute\n"
6681 DEFUN_YANG (no_neighbor_attr_unchanged
,
6682 no_neighbor_attr_unchanged_cmd
,
6683 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6687 "BGP attribute is propagated unchanged to this neighbor\n"
6688 "As-path attribute\n"
6689 "Nexthop attribute\n"
6693 char *peer_str
= argv
[2]->arg
;
6694 bool aspath
= false;
6695 bool nexthop
= false;
6697 afi_t afi
= bgp_node_afi(vty
);
6698 safi_t safi
= bgp_node_safi(vty
);
6699 char base_xpath
[XPATH_MAXLEN
];
6700 char af_xpath
[XPATH_MAXLEN
];
6701 char as_xpath
[XPATH_MAXLEN
];
6702 char nxthop_xpath
[XPATH_MAXLEN
];
6703 char med_xpath
[XPATH_MAXLEN
];
6705 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6706 yang_afi_safi_value2identity(afi
, safi
));
6708 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6709 sizeof(base_xpath
), af_xpath
)
6711 return CMD_WARNING_CONFIG_FAILED
;
6713 if (argv_find(argv
, argc
, "as-path", &idx
))
6717 if (argv_find(argv
, argc
, "next-hop", &idx
))
6721 if (argv_find(argv
, argc
, "med", &idx
))
6724 snprintf(as_xpath
, sizeof(as_xpath
),
6725 "./%s/attr-unchanged/as-path-unchanged",
6726 bgp_afi_safi_get_container_str(afi
, safi
));
6727 snprintf(nxthop_xpath
, sizeof(nxthop_xpath
),
6728 "./%s/attr-unchanged/next-hop-unchanged",
6729 bgp_afi_safi_get_container_str(afi
, safi
));
6730 snprintf(med_xpath
, sizeof(med_xpath
),
6731 "./%s/attr-unchanged/med-unchanged",
6732 bgp_afi_safi_get_container_str(afi
, safi
));
6734 /* no flags means all of them! */
6735 if (!aspath
&& !nexthop
&& !med
) {
6736 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "false");
6737 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "false");
6738 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "false");
6742 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "false");
6745 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "false");
6748 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "false");
6750 return nb_cli_apply_changes(vty
, base_xpath
);
6754 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6755 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6756 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6757 "BGP attribute is propagated unchanged to this neighbor\n"
6758 "As-path attribute\n"
6759 "Nexthop attribute\n"
6762 /* neighbor ebgp-multihop. */
6763 DEFUN_YANG (neighbor_ebgp_multihop
,
6764 neighbor_ebgp_multihop_cmd
,
6765 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6766 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6767 "Allow EBGP neighbors not on directly connected networks\n")
6770 char base_xpath
[XPATH_MAXLEN
];
6772 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6773 sizeof(base_xpath
), NULL
)
6775 return CMD_WARNING_CONFIG_FAILED
;
6777 nb_cli_enqueue_change(vty
, "./ebgp-multihop/enabled", NB_OP_MODIFY
,
6780 return nb_cli_apply_changes(vty
, base_xpath
);
6783 DEFUN_YANG (neighbor_ebgp_multihop_ttl
,
6784 neighbor_ebgp_multihop_ttl_cmd
,
6785 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6786 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6787 "Allow EBGP neighbors not on directly connected networks\n"
6788 "maximum hop count\n")
6792 char base_xpath
[XPATH_MAXLEN
];
6794 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6795 sizeof(base_xpath
), NULL
)
6797 return CMD_WARNING_CONFIG_FAILED
;
6799 nb_cli_enqueue_change(vty
, "./ebgp-multihop/multihop-ttl", NB_OP_MODIFY
,
6800 argv
[idx_number
]->arg
);
6802 return nb_cli_apply_changes(vty
, base_xpath
);
6805 DEFUN_YANG (no_neighbor_ebgp_multihop
,
6806 no_neighbor_ebgp_multihop_cmd
,
6807 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6808 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6809 "Allow EBGP neighbors not on directly connected networks\n"
6810 "maximum hop count\n")
6813 char base_xpath
[XPATH_MAXLEN
];
6815 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6816 sizeof(base_xpath
), NULL
)
6818 return CMD_WARNING_CONFIG_FAILED
;
6821 nb_cli_enqueue_change(vty
, "./ebgp-multihop/multihop-ttl",
6822 NB_OP_DESTROY
, NULL
);
6824 nb_cli_enqueue_change(vty
, "./ebgp-multihop/enabled",
6825 NB_OP_MODIFY
, "false");
6827 return nb_cli_apply_changes(vty
, base_xpath
);
6831 /* disable-connected-check */
6832 DEFUN_YANG (neighbor_disable_connected_check
,
6833 neighbor_disable_connected_check_cmd
,
6834 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6835 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6836 "one-hop away EBGP peer using loopback address\n"
6837 "Enforce EBGP neighbors perform multihop\n")
6840 char base_xpath
[XPATH_MAXLEN
];
6842 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6843 sizeof(base_xpath
), NULL
)
6845 return CMD_WARNING_CONFIG_FAILED
;
6847 nb_cli_enqueue_change(vty
, "./ebgp-multihop/disable-connected-check",
6848 NB_OP_MODIFY
, "true");
6850 return nb_cli_apply_changes(vty
, base_xpath
);
6853 DEFUN_YANG (no_neighbor_disable_connected_check
,
6854 no_neighbor_disable_connected_check_cmd
,
6855 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6856 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6857 "one-hop away EBGP peer using loopback address\n"
6858 "Enforce EBGP neighbors perform multihop\n")
6861 char base_xpath
[XPATH_MAXLEN
];
6863 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6864 sizeof(base_xpath
), NULL
)
6866 return CMD_WARNING_CONFIG_FAILED
;
6868 nb_cli_enqueue_change(vty
, "./ebgp-multihop/disable-connected-check",
6869 NB_OP_MODIFY
, "false");
6871 return nb_cli_apply_changes(vty
, base_xpath
);
6875 /* enforce-first-as */
6876 DEFUN_YANG (neighbor_enforce_first_as
,
6877 neighbor_enforce_first_as_cmd
,
6878 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6879 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6880 "Enforce the first AS for EBGP routes\n")
6883 char base_xpath
[XPATH_MAXLEN
];
6885 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6886 sizeof(base_xpath
), NULL
)
6888 return CMD_WARNING_CONFIG_FAILED
;
6890 nb_cli_enqueue_change(vty
, "./enforce-first-as", NB_OP_MODIFY
, "true");
6892 return nb_cli_apply_changes(vty
, base_xpath
);
6895 DEFUN_YANG (no_neighbor_enforce_first_as
,
6896 no_neighbor_enforce_first_as_cmd
,
6897 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6898 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6899 "Enforce the first AS for EBGP routes\n")
6902 char base_xpath
[XPATH_MAXLEN
];
6904 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6905 sizeof(base_xpath
), NULL
)
6907 return CMD_WARNING_CONFIG_FAILED
;
6909 nb_cli_enqueue_change(vty
, "./enforce-first-as", NB_OP_MODIFY
, "false");
6911 return nb_cli_apply_changes(vty
, base_xpath
);
6914 static int peer_and_group_lookup_nb(struct vty
*vty
, const char *peer_str
,
6915 char *base_xpath
, int xpath_len
,
6919 char num_xpath
[XPATH_MAXLEN
];
6920 char unnbr_xpath
[XPATH_MAXLEN
];
6921 char prgrp_xpath
[XPATH_MAXLEN
];
6923 if (str2sockunion(peer_str
, &su
) == 0) {
6924 snprintf(num_xpath
, sizeof(num_xpath
),
6925 "/neighbors/neighbor[remote-address='%s']", peer_str
);
6926 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
6927 VTY_CURR_XPATH
, num_xpath
)) {
6928 snprintf(base_xpath
, xpath_len
,
6929 FRR_BGP_NEIGHBOR_NUM_XPATH
, peer_str
,
6930 xpath
? xpath
: "");
6933 "%% Specify remote-as or peer-group commands first\n");
6938 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
6939 "/neighbors/unnumbered-neighbor[interface='%s']",
6942 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
6943 "/peer-groups/peer-group[peer-group-name='%s']",
6946 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
6947 VTY_CURR_XPATH
, unnbr_xpath
)) {
6948 snprintf(base_xpath
, xpath_len
,
6949 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, peer_str
,
6950 xpath
? xpath
: "");
6951 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
,
6952 "%s%s", VTY_CURR_XPATH
,
6954 snprintf(base_xpath
, xpath_len
,
6955 FRR_BGP_PEER_GROUP_XPATH
, peer_str
,
6956 xpath
? xpath
: "");
6959 "%% Create the peer-group or interface first\n");
6967 DEFUN_YANG (neighbor_description
,
6968 neighbor_description_cmd
,
6969 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6970 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6971 "Neighbor specific description\n"
6972 "Up to 80 characters describing this neighbor\n")
6977 char base_xpath
[XPATH_MAXLEN
];
6980 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6981 sizeof(base_xpath
), NULL
)
6983 return CMD_WARNING_CONFIG_FAILED
;
6985 str
= argv_concat(argv
, argc
, idx_line
);
6987 nb_cli_enqueue_change(vty
, "./description", NB_OP_MODIFY
, str
);
6989 ret
= nb_cli_apply_changes(vty
, base_xpath
);
6991 XFREE(MTYPE_TMP
, str
);
6996 DEFUN_YANG (no_neighbor_description
,
6997 no_neighbor_description_cmd
,
6998 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6999 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7000 "Neighbor specific description\n")
7003 char base_xpath
[XPATH_MAXLEN
];
7005 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7006 sizeof(base_xpath
), NULL
)
7008 return CMD_WARNING_CONFIG_FAILED
;
7010 nb_cli_enqueue_change(vty
, "./description", NB_OP_DESTROY
, NULL
);
7012 return nb_cli_apply_changes(vty
, base_xpath
);
7015 ALIAS_YANG(no_neighbor_description
, no_neighbor_description_comment_cmd
,
7016 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
7017 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7018 "Neighbor specific description\n"
7019 "Up to 80 characters describing this neighbor\n")
7021 #define BGP_UPDATE_SOURCE_HELP_STR \
7024 "Interface name (requires zebra to be running)\n"
7026 DEFUN_YANG (neighbor_update_source
,
7027 neighbor_update_source_cmd
,
7028 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
7029 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7030 "Source of routing updates\n"
7031 BGP_UPDATE_SOURCE_HELP_STR
)
7036 char base_xpath
[XPATH_MAXLEN
];
7038 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7039 sizeof(base_xpath
), NULL
)
7041 return CMD_WARNING_CONFIG_FAILED
;
7043 if (str2sockunion(argv
[idx_peer_2
]->arg
, &su
) == 0)
7044 nb_cli_enqueue_change(vty
, "./update-source/ip", NB_OP_MODIFY
,
7045 argv
[idx_peer_2
]->arg
);
7047 nb_cli_enqueue_change(vty
, "./update-source/interface",
7048 NB_OP_MODIFY
, argv
[idx_peer_2
]->arg
);
7050 return nb_cli_apply_changes(vty
, base_xpath
);
7053 DEFUN_YANG (no_neighbor_update_source
,
7054 no_neighbor_update_source_cmd
,
7055 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
7058 "Source of routing updates\n"
7059 BGP_UPDATE_SOURCE_HELP_STR
)
7062 char base_xpath
[XPATH_MAXLEN
];
7064 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7065 sizeof(base_xpath
), NULL
)
7067 return CMD_WARNING_CONFIG_FAILED
;
7069 nb_cli_enqueue_change(vty
, "./update-source/ip", NB_OP_DESTROY
, NULL
);
7070 nb_cli_enqueue_change(vty
, "./update-source/interface", NB_OP_DESTROY
,
7073 return nb_cli_apply_changes(vty
, base_xpath
);
7076 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
7077 afi_t afi
, safi_t safi
,
7078 const char *rmap
, int set
)
7082 struct route_map
*route_map
= NULL
;
7084 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
7086 return CMD_WARNING_CONFIG_FAILED
;
7090 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
7091 ret
= peer_default_originate_set(peer
, afi
, safi
,
7094 ret
= peer_default_originate_unset(peer
, afi
, safi
);
7096 return bgp_vty_return(vty
, ret
);
7099 /* neighbor default-originate. */
7100 DEFUN (neighbor_default_originate
,
7101 neighbor_default_originate_cmd
,
7102 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
7105 "Originate default route to this neighbor\n")
7108 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
7110 bgp_node_safi(vty
), NULL
, 1);
7113 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
7114 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
7115 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7116 "Originate default route to this neighbor\n")
7118 DEFUN (neighbor_default_originate_rmap
,
7119 neighbor_default_originate_rmap_cmd
,
7120 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
7123 "Originate default route to this neighbor\n"
7124 "Route-map to specify criteria to originate default\n"
7129 return peer_default_originate_set_vty(
7130 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7131 argv
[idx_word
]->arg
, 1);
7135 neighbor_default_originate_rmap
,
7136 neighbor_default_originate_rmap_hidden_cmd
,
7137 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
7138 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7139 "Originate default route to this neighbor\n"
7140 "Route-map to specify criteria to originate default\n"
7143 DEFUN (no_neighbor_default_originate
,
7144 no_neighbor_default_originate_cmd
,
7145 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
7149 "Originate default route to this neighbor\n"
7150 "Route-map to specify criteria to originate default\n"
7154 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
7156 bgp_node_safi(vty
), NULL
, 0);
7160 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
7161 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
7162 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7163 "Originate default route to this neighbor\n"
7164 "Route-map to specify criteria to originate default\n"
7168 /* Set specified peer's BGP port. */
7169 DEFUN_YANG (neighbor_port
,
7171 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
7174 "Neighbor's BGP port\n"
7175 "TCP port number\n")
7179 char base_xpath
[XPATH_MAXLEN
];
7181 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7182 argv
[idx_ip
]->arg
, "");
7184 nb_cli_enqueue_change(vty
, "./local-port", NB_OP_MODIFY
,
7185 argv
[idx_number
]->arg
);
7187 return nb_cli_apply_changes(vty
, base_xpath
);
7190 DEFUN_YANG (no_neighbor_port
,
7191 no_neighbor_port_cmd
,
7192 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
7193 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR
7194 "Neighbor's BGP port\n"
7195 "TCP port number\n")
7198 char base_xpath
[XPATH_MAXLEN
];
7200 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7201 argv
[idx_ip
]->arg
, "");
7203 nb_cli_enqueue_change(vty
, "./local-port", NB_OP_DESTROY
, NULL
);
7205 return nb_cli_apply_changes(vty
, base_xpath
);
7208 DEFUN_YANG (neighbor_weight
,
7209 neighbor_weight_cmd
,
7210 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7211 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7212 "Set default weight for routes from this neighbor\n"
7217 char base_xpath
[XPATH_MAXLEN
];
7218 char af_xpath
[XPATH_MAXLEN
];
7219 char attr_xpath
[XPATH_MAXLEN
];
7220 afi_t afi
= bgp_node_afi(vty
);
7221 safi_t safi
= bgp_node_safi(vty
);
7223 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
7224 yang_afi_safi_value2identity(afi
, safi
));
7226 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7227 sizeof(base_xpath
), af_xpath
)
7229 return CMD_WARNING_CONFIG_FAILED
;
7231 snprintf(attr_xpath
, sizeof(attr_xpath
), "./%s/weight/weight-attribute",
7232 bgp_afi_safi_get_container_str(afi
, safi
));
7234 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
,
7235 argv
[idx_number
]->arg
);
7237 return nb_cli_apply_changes(vty
, base_xpath
);
7240 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
7241 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7242 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7243 "Set default weight for routes from this neighbor\n"
7246 DEFUN_YANG (no_neighbor_weight
,
7247 no_neighbor_weight_cmd
,
7248 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7249 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7250 "Set default weight for routes from this neighbor\n"
7254 char base_xpath
[XPATH_MAXLEN
];
7255 char af_xpath
[XPATH_MAXLEN
];
7256 char attr_xpath
[XPATH_MAXLEN
];
7257 afi_t afi
= bgp_node_afi(vty
);
7258 safi_t safi
= bgp_node_safi(vty
);
7260 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
7261 yang_afi_safi_value2identity(afi
, safi
));
7263 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7264 sizeof(base_xpath
), af_xpath
)
7266 return CMD_WARNING_CONFIG_FAILED
;
7268 snprintf(attr_xpath
, sizeof(attr_xpath
), "./%s/weight/weight-attribute",
7269 bgp_afi_safi_get_container_str(afi
, safi
));
7271 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_DESTROY
, NULL
);
7273 return nb_cli_apply_changes(vty
, base_xpath
);
7276 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
7277 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7278 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7279 "Set default weight for routes from this neighbor\n"
7283 /* Override capability negotiation. */
7284 DEFUN_YANG (neighbor_override_capability
,
7285 neighbor_override_capability_cmd
,
7286 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7289 "Override capability negotiation result\n")
7292 char base_xpath
[XPATH_MAXLEN
];
7294 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7295 sizeof(base_xpath
), NULL
)
7297 return CMD_WARNING_CONFIG_FAILED
;
7299 nb_cli_enqueue_change(
7300 vty
, "./capability-options/override-capability",
7301 NB_OP_MODIFY
, "true");
7303 return nb_cli_apply_changes(vty
, base_xpath
);
7306 DEFUN_YANG (no_neighbor_override_capability
,
7307 no_neighbor_override_capability_cmd
,
7308 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7312 "Override capability negotiation result\n")
7315 char base_xpath
[XPATH_MAXLEN
];
7317 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7318 sizeof(base_xpath
), NULL
)
7320 return CMD_WARNING_CONFIG_FAILED
;
7322 nb_cli_enqueue_change(
7323 vty
, "./capability-options/override-capability",
7324 NB_OP_MODIFY
, "false");
7326 return nb_cli_apply_changes(vty
, base_xpath
);
7329 DEFUN_YANG (neighbor_strict_capability
,
7330 neighbor_strict_capability_cmd
,
7331 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7334 "Strict capability negotiation match\n")
7337 char base_xpath
[XPATH_MAXLEN
];
7339 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7340 sizeof(base_xpath
), NULL
)
7342 return CMD_WARNING_CONFIG_FAILED
;
7344 nb_cli_enqueue_change(
7345 vty
, "./capability-options/strict-capability",
7346 NB_OP_MODIFY
, "true");
7348 return nb_cli_apply_changes(vty
, base_xpath
);
7351 DEFUN_YANG (no_neighbor_strict_capability
,
7352 no_neighbor_strict_capability_cmd
,
7353 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7357 "Strict capability negotiation match\n")
7360 char base_xpath
[XPATH_MAXLEN
];
7362 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7363 sizeof(base_xpath
), NULL
)
7365 return CMD_WARNING_CONFIG_FAILED
;
7367 nb_cli_enqueue_change(
7368 vty
, "./capability-options/strict-capability",
7369 NB_OP_MODIFY
, "false");
7371 return nb_cli_apply_changes(vty
, base_xpath
);
7374 DEFUN_YANG (neighbor_timers
,
7375 neighbor_timers_cmd
,
7376 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7377 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7378 "BGP per neighbor timers\n"
7379 "Keepalive interval\n"
7384 int idx_number_2
= 4;
7385 char base_xpath
[XPATH_MAXLEN
];
7387 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7388 sizeof(base_xpath
), NULL
)
7390 return CMD_WARNING_CONFIG_FAILED
;
7392 nb_cli_enqueue_change(vty
, "./timers/keepalive", NB_OP_MODIFY
,
7393 argv
[idx_number
]->arg
);
7395 nb_cli_enqueue_change(vty
, "./timers/hold-time", NB_OP_MODIFY
,
7396 argv
[idx_number_2
]->arg
);
7398 return nb_cli_apply_changes(vty
, base_xpath
);
7401 DEFUN_YANG (no_neighbor_timers
,
7402 no_neighbor_timers_cmd
,
7403 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7404 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7405 "BGP per neighbor timers\n"
7406 "Keepalive interval\n"
7410 char base_xpath
[XPATH_MAXLEN
];
7412 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7413 sizeof(base_xpath
), NULL
)
7415 return CMD_WARNING_CONFIG_FAILED
;
7417 nb_cli_enqueue_change(vty
, "./timers/hold-time", NB_OP_DESTROY
, NULL
);
7419 nb_cli_enqueue_change(vty
, "./timers/keepalive", NB_OP_DESTROY
, NULL
);
7421 return nb_cli_apply_changes(vty
, base_xpath
);
7424 DEFUN_YANG (neighbor_timers_connect
,
7425 neighbor_timers_connect_cmd
,
7426 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7427 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7428 "BGP per neighbor timers\n"
7429 "BGP connect timer\n"
7434 char base_xpath
[XPATH_MAXLEN
];
7436 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7437 sizeof(base_xpath
), NULL
)
7439 return CMD_WARNING_CONFIG_FAILED
;
7441 nb_cli_enqueue_change(vty
, "./timers/connect-time", NB_OP_MODIFY
,
7442 argv
[idx_number
]->arg
);
7444 return nb_cli_apply_changes(vty
, base_xpath
);
7447 DEFUN_YANG (no_neighbor_timers_connect
,
7448 no_neighbor_timers_connect_cmd
,
7449 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7450 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7451 "BGP per neighbor timers\n"
7452 "BGP connect timer\n"
7456 char base_xpath
[XPATH_MAXLEN
];
7458 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7459 sizeof(base_xpath
), NULL
)
7461 return CMD_WARNING_CONFIG_FAILED
;
7463 nb_cli_enqueue_change(vty
, "./timers/connect-time", NB_OP_DESTROY
,
7466 return nb_cli_apply_changes(vty
, base_xpath
);
7469 DEFPY (neighbor_timers_delayopen
,
7470 neighbor_timers_delayopen_cmd
,
7471 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7474 "BGP per neighbor timers\n"
7475 "RFC 4271 DelayOpenTimer\n"
7476 "DelayOpenTime timer interval\n")
7480 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7482 return CMD_WARNING_CONFIG_FAILED
;
7485 if (peer_timers_delayopen_unset(peer
))
7486 return CMD_WARNING_CONFIG_FAILED
;
7488 if (peer_timers_delayopen_set(peer
, interval
))
7489 return CMD_WARNING_CONFIG_FAILED
;
7495 DEFPY (no_neighbor_timers_delayopen
,
7496 no_neighbor_timers_delayopen_cmd
,
7497 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7501 "BGP per neighbor timers\n"
7502 "RFC 4271 DelayOpenTimer\n"
7503 "DelayOpenTime timer interval\n")
7507 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7509 return CMD_WARNING_CONFIG_FAILED
;
7511 if (peer_timers_delayopen_unset(peer
))
7512 return CMD_WARNING_CONFIG_FAILED
;
7517 DEFUN_YANG (neighbor_advertise_interval
,
7518 neighbor_advertise_interval_cmd
,
7519 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7520 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7521 "Minimum interval between sending BGP routing updates\n"
7522 "time in seconds\n")
7526 char base_xpath
[XPATH_MAXLEN
];
7528 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7529 sizeof(base_xpath
), NULL
)
7531 return CMD_WARNING_CONFIG_FAILED
;
7533 nb_cli_enqueue_change(vty
, "./timers/advertise-interval", NB_OP_MODIFY
,
7534 argv
[idx_number
]->arg
);
7536 return nb_cli_apply_changes(vty
, base_xpath
);
7539 DEFUN_YANG (no_neighbor_advertise_interval
,
7540 no_neighbor_advertise_interval_cmd
,
7541 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7542 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7543 "Minimum interval between sending BGP routing updates\n"
7544 "time in seconds\n")
7547 char base_xpath
[XPATH_MAXLEN
];
7549 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7550 sizeof(base_xpath
), NULL
)
7552 return CMD_WARNING_CONFIG_FAILED
;
7554 nb_cli_enqueue_change(vty
, "./timers/advertise-interval", NB_OP_DESTROY
,
7557 return nb_cli_apply_changes(vty
, base_xpath
);
7561 /* Time to wait before processing route-map updates */
7562 DEFUN (bgp_set_route_map_delay_timer
,
7563 bgp_set_route_map_delay_timer_cmd
,
7564 "bgp route-map delay-timer (0-600)",
7566 "BGP route-map delay timer\n"
7567 "Time in secs to wait before processing route-map changes\n"
7568 "0 disables the timer, no route updates happen when route-maps change\n")
7571 uint32_t rmap_delay_timer
;
7573 if (argv
[idx_number
]->arg
) {
7574 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7575 bm
->rmap_update_timer
= rmap_delay_timer
;
7577 /* if the dynamic update handling is being disabled, and a timer
7579 * running, stop the timer and act as if the timer has already
7582 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7583 BGP_TIMER_OFF(bm
->t_rmap_update
);
7584 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7589 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7590 return CMD_WARNING_CONFIG_FAILED
;
7594 DEFUN (no_bgp_set_route_map_delay_timer
,
7595 no_bgp_set_route_map_delay_timer_cmd
,
7596 "no bgp route-map delay-timer [(0-600)]",
7599 "Default BGP route-map delay timer\n"
7600 "Reset to default time to wait for processing route-map changes\n"
7601 "0 disables the timer, no route updates happen when route-maps change\n")
7604 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7609 DEFUN_YANG (neighbor_interface
,
7610 neighbor_interface_cmd
,
7611 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7612 NEIGHBOR_STR NEIGHBOR_ADDR_STR
7618 char base_xpath
[XPATH_MAXLEN
];
7620 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7621 argv
[idx_ip
]->arg
, "");
7623 nb_cli_enqueue_change(vty
, "./local-interface", NB_OP_MODIFY
,
7624 argv
[idx_word
]->arg
);
7626 return nb_cli_apply_changes(vty
, base_xpath
);
7629 DEFUN_YANG (no_neighbor_interface
,
7630 no_neighbor_interface_cmd
,
7631 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
7632 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7637 char base_xpath
[XPATH_MAXLEN
];
7639 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7640 argv
[idx_peer
]->arg
, "");
7642 nb_cli_enqueue_change(vty
, "./local-interface", NB_OP_DESTROY
, NULL
);
7644 return nb_cli_apply_changes(vty
, base_xpath
);
7647 DEFUN (neighbor_distribute_list
,
7648 neighbor_distribute_list_cmd
,
7649 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7652 "Filter updates to/from this neighbor\n"
7653 "IP access-list number\n"
7654 "IP access-list number (expanded range)\n"
7655 "IP Access-list name\n"
7656 "Filter incoming updates\n"
7657 "Filter outgoing updates\n")
7664 const char *pstr
= argv
[idx_peer
]->arg
;
7665 const char *acl
= argv
[idx_acl
]->arg
;
7666 const char *inout
= argv
[argc
- 1]->text
;
7668 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7670 return CMD_WARNING_CONFIG_FAILED
;
7672 /* Check filter direction. */
7673 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7674 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7677 return bgp_vty_return(vty
, ret
);
7681 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7682 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7683 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7684 "Filter updates to/from this neighbor\n"
7685 "IP access-list number\n"
7686 "IP access-list number (expanded range)\n"
7687 "IP Access-list name\n"
7688 "Filter incoming updates\n"
7689 "Filter outgoing updates\n")
7691 DEFUN (no_neighbor_distribute_list
,
7692 no_neighbor_distribute_list_cmd
,
7693 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7697 "Filter updates to/from this neighbor\n"
7698 "IP access-list number\n"
7699 "IP access-list number (expanded range)\n"
7700 "IP Access-list name\n"
7701 "Filter incoming updates\n"
7702 "Filter outgoing updates\n")
7708 const char *pstr
= argv
[idx_peer
]->arg
;
7709 const char *inout
= argv
[argc
- 1]->text
;
7711 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7713 return CMD_WARNING_CONFIG_FAILED
;
7715 /* Check filter direction. */
7716 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7717 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7720 return bgp_vty_return(vty
, ret
);
7724 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7725 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7726 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7727 "Filter updates to/from this neighbor\n"
7728 "IP access-list number\n"
7729 "IP access-list number (expanded range)\n"
7730 "IP Access-list name\n"
7731 "Filter incoming updates\n"
7732 "Filter outgoing updates\n")
7734 /* Set prefix list to the peer. */
7735 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7736 afi_t afi
, safi_t safi
,
7737 const char *name_str
,
7738 const char *direct_str
)
7741 int direct
= FILTER_IN
;
7744 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7746 return CMD_WARNING_CONFIG_FAILED
;
7748 /* Check filter direction. */
7749 if (strncmp(direct_str
, "i", 1) == 0)
7751 else if (strncmp(direct_str
, "o", 1) == 0)
7752 direct
= FILTER_OUT
;
7754 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7756 return bgp_vty_return(vty
, ret
);
7759 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7760 afi_t afi
, safi_t safi
,
7761 const char *direct_str
)
7765 int direct
= FILTER_IN
;
7767 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7769 return CMD_WARNING_CONFIG_FAILED
;
7771 /* Check filter direction. */
7772 if (strncmp(direct_str
, "i", 1) == 0)
7774 else if (strncmp(direct_str
, "o", 1) == 0)
7775 direct
= FILTER_OUT
;
7777 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7779 return bgp_vty_return(vty
, ret
);
7782 DEFUN (neighbor_prefix_list
,
7783 neighbor_prefix_list_cmd
,
7784 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7787 "Filter updates to/from this neighbor\n"
7788 "Name of a prefix list\n"
7789 "Filter incoming updates\n"
7790 "Filter outgoing updates\n")
7795 return peer_prefix_list_set_vty(
7796 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7797 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7800 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7801 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7802 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7803 "Filter updates to/from this neighbor\n"
7804 "Name of a prefix list\n"
7805 "Filter incoming updates\n"
7806 "Filter outgoing updates\n")
7808 DEFUN (no_neighbor_prefix_list
,
7809 no_neighbor_prefix_list_cmd
,
7810 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7814 "Filter updates to/from this neighbor\n"
7815 "Name of a prefix list\n"
7816 "Filter incoming updates\n"
7817 "Filter outgoing updates\n")
7821 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7822 bgp_node_afi(vty
), bgp_node_safi(vty
),
7823 argv
[idx_in_out
]->arg
);
7826 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7827 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7828 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7829 "Filter updates to/from this neighbor\n"
7830 "Name of a prefix list\n"
7831 "Filter incoming updates\n"
7832 "Filter outgoing updates\n")
7834 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7835 safi_t safi
, const char *name_str
,
7836 const char *direct_str
)
7840 int direct
= FILTER_IN
;
7842 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7844 return CMD_WARNING_CONFIG_FAILED
;
7846 /* Check filter direction. */
7847 if (strncmp(direct_str
, "i", 1) == 0)
7849 else if (strncmp(direct_str
, "o", 1) == 0)
7850 direct
= FILTER_OUT
;
7852 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7854 return bgp_vty_return(vty
, ret
);
7857 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7858 safi_t safi
, const char *direct_str
)
7862 int direct
= FILTER_IN
;
7864 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7866 return CMD_WARNING_CONFIG_FAILED
;
7868 /* Check filter direction. */
7869 if (strncmp(direct_str
, "i", 1) == 0)
7871 else if (strncmp(direct_str
, "o", 1) == 0)
7872 direct
= FILTER_OUT
;
7874 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7876 return bgp_vty_return(vty
, ret
);
7879 DEFUN (neighbor_filter_list
,
7880 neighbor_filter_list_cmd
,
7881 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7884 "Establish BGP filters\n"
7885 "AS path access-list name\n"
7886 "Filter incoming routes\n"
7887 "Filter outgoing routes\n")
7892 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7893 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7894 argv
[idx_in_out
]->arg
);
7897 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7898 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7899 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7900 "Establish BGP filters\n"
7901 "AS path access-list name\n"
7902 "Filter incoming routes\n"
7903 "Filter outgoing routes\n")
7905 DEFUN (no_neighbor_filter_list
,
7906 no_neighbor_filter_list_cmd
,
7907 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7911 "Establish BGP filters\n"
7912 "AS path access-list name\n"
7913 "Filter incoming routes\n"
7914 "Filter outgoing routes\n")
7918 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7919 bgp_node_afi(vty
), bgp_node_safi(vty
),
7920 argv
[idx_in_out
]->arg
);
7923 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7924 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7925 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7926 "Establish BGP filters\n"
7927 "AS path access-list name\n"
7928 "Filter incoming routes\n"
7929 "Filter outgoing routes\n")
7931 /* Set advertise-map to the peer. */
7932 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7933 afi_t afi
, safi_t safi
,
7934 const char *advertise_str
,
7935 const char *condition_str
, bool condition
,
7938 int ret
= CMD_WARNING_CONFIG_FAILED
;
7940 struct route_map
*advertise_map
;
7941 struct route_map
*condition_map
;
7943 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7947 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7948 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7951 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7952 advertise_map
, condition_str
,
7953 condition_map
, condition
);
7955 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7956 advertise_map
, condition_str
,
7957 condition_map
, condition
);
7959 return bgp_vty_return(vty
, ret
);
7962 DEFPY (neighbor_advertise_map
,
7963 neighbor_advertise_map_cmd
,
7964 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor advertise-map WORD$advertise_str <exist-map|non-exist-map>$exist WORD$condition_str",
7968 "Route-map to conditionally advertise routes\n"
7969 "Name of advertise map\n"
7970 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7971 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7972 "Name of the exist or non exist map\n")
7974 bool condition
= CONDITION_EXIST
;
7976 if (!strcmp(exist
, "non-exist-map"))
7977 condition
= CONDITION_NON_EXIST
;
7979 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7980 bgp_node_safi(vty
), advertise_str
,
7981 condition_str
, condition
, !no
);
7984 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7985 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor advertise-map WORD$advertise_str <exist-map|non-exist-map>$exist WORD$condition_str",
7986 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7987 "Route-map to conditionally advertise routes\n"
7988 "Name of advertise map\n"
7989 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7990 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7991 "Name of the exist or non exist map\n")
7993 /* Set route-map to the peer. */
7994 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7995 afi_t afi
, safi_t safi
, const char *name_str
,
7996 const char *direct_str
)
8000 int direct
= RMAP_IN
;
8001 struct route_map
*route_map
;
8003 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8005 return CMD_WARNING_CONFIG_FAILED
;
8007 /* Check filter direction. */
8008 if (strncmp(direct_str
, "in", 2) == 0)
8010 else if (strncmp(direct_str
, "o", 1) == 0)
8013 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
8014 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
8016 return bgp_vty_return(vty
, ret
);
8019 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
8020 afi_t afi
, safi_t safi
,
8021 const char *direct_str
)
8025 int direct
= RMAP_IN
;
8027 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8029 return CMD_WARNING_CONFIG_FAILED
;
8031 /* Check filter direction. */
8032 if (strncmp(direct_str
, "in", 2) == 0)
8034 else if (strncmp(direct_str
, "o", 1) == 0)
8037 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
8039 return bgp_vty_return(vty
, ret
);
8042 DEFUN (neighbor_route_map
,
8043 neighbor_route_map_cmd
,
8044 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
8047 "Apply route map to neighbor\n"
8048 "Name of route map\n"
8049 "Apply map to incoming routes\n"
8050 "Apply map to outbound routes\n")
8055 return peer_route_map_set_vty(
8056 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8057 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
8060 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
8061 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
8062 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8063 "Apply route map to neighbor\n"
8064 "Name of route map\n"
8065 "Apply map to incoming routes\n"
8066 "Apply map to outbound routes\n")
8068 DEFUN (no_neighbor_route_map
,
8069 no_neighbor_route_map_cmd
,
8070 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
8074 "Apply route map to neighbor\n"
8075 "Name of route map\n"
8076 "Apply map to incoming routes\n"
8077 "Apply map to outbound routes\n")
8081 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
8082 bgp_node_afi(vty
), bgp_node_safi(vty
),
8083 argv
[idx_in_out
]->arg
);
8086 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
8087 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
8088 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8089 "Apply route map to neighbor\n"
8090 "Name of route map\n"
8091 "Apply map to incoming routes\n"
8092 "Apply map to outbound routes\n")
8094 /* Set unsuppress-map to the peer. */
8095 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
8096 afi_t afi
, safi_t safi
,
8097 const char *name_str
)
8101 struct route_map
*route_map
;
8103 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8105 return CMD_WARNING_CONFIG_FAILED
;
8107 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
8108 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
8110 return bgp_vty_return(vty
, ret
);
8113 /* Unset route-map from the peer. */
8114 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
8115 afi_t afi
, safi_t safi
)
8120 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8122 return CMD_WARNING_CONFIG_FAILED
;
8124 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
8126 return bgp_vty_return(vty
, ret
);
8129 DEFUN (neighbor_unsuppress_map
,
8130 neighbor_unsuppress_map_cmd
,
8131 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8134 "Route-map to selectively unsuppress suppressed routes\n"
8135 "Name of route map\n")
8139 return peer_unsuppress_map_set_vty(
8140 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8141 argv
[idx_word
]->arg
);
8144 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
8145 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8146 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8147 "Route-map to selectively unsuppress suppressed routes\n"
8148 "Name of route map\n")
8150 DEFUN (no_neighbor_unsuppress_map
,
8151 no_neighbor_unsuppress_map_cmd
,
8152 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8156 "Route-map to selectively unsuppress suppressed routes\n"
8157 "Name of route map\n")
8160 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
8162 bgp_node_safi(vty
));
8165 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
8166 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8167 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8168 "Route-map to selectively unsuppress suppressed routes\n"
8169 "Name of route map\n")
8171 /* Maximum number of prefix to be sent to the neighbor. */
8172 DEFUN_YANG(neighbor_maximum_prefix_out
,
8173 neighbor_maximum_prefix_out_cmd
,
8174 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
8175 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8176 "Maximum number of prefixes to be sent to this peer\n"
8177 "Maximum no. of prefix limit\n")
8179 char base_xpath
[XPATH_MAXLEN
];
8180 char af_xpath
[XPATH_MAXLEN
];
8181 char attr_xpath
[XPATH_MAXLEN
];
8184 afi_t afi
= bgp_node_afi(vty
);
8185 safi_t safi
= bgp_node_safi(vty
);
8187 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8188 yang_afi_safi_value2identity(afi
, safi
));
8189 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8190 sizeof(base_xpath
), af_xpath
)
8192 return CMD_WARNING_CONFIG_FAILED
;
8194 snprintf(attr_xpath
, sizeof(attr_xpath
),
8195 "/%s/prefix-limit/direction-list[direction='out']",
8196 bgp_afi_safi_get_container_str(afi
, safi
));
8197 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8199 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8201 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8202 argv
[idx_number
]->arg
);
8204 return nb_cli_apply_changes(vty
, base_xpath
);
8207 DEFUN_YANG(no_neighbor_maximum_prefix_out
,
8208 no_neighbor_maximum_prefix_out_cmd
,
8209 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out",
8210 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8211 "Maximum number of prefixes to be sent to this peer\n")
8213 char base_xpath
[XPATH_MAXLEN
];
8214 char af_xpath
[XPATH_MAXLEN
];
8215 char attr_xpath
[XPATH_MAXLEN
];
8217 afi_t afi
= bgp_node_afi(vty
);
8218 safi_t safi
= bgp_node_safi(vty
);
8220 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8221 yang_afi_safi_value2identity(afi
, safi
));
8222 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8223 sizeof(base_xpath
), af_xpath
)
8225 return CMD_WARNING_CONFIG_FAILED
;
8227 snprintf(attr_xpath
, sizeof(attr_xpath
),
8228 "/%s/prefix-limit/direction-list[direction='out']",
8229 bgp_afi_safi_get_container_str(afi
, safi
));
8230 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8232 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
8234 return nb_cli_apply_changes(vty
, base_xpath
);
8237 /* Maximum number of prefix configuration. Prefix count is different
8238 for each peer configuration. So this configuration can be set for
8239 each peer configuration. */
8240 DEFUN_YANG(neighbor_maximum_prefix
,
8241 neighbor_maximum_prefix_cmd
,
8242 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8243 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8244 "Maximum number of prefix accept from this peer\n"
8245 "maximum no. of prefix limit\n"
8246 "Force checking all received routes not only accepted\n")
8251 char base_xpath
[XPATH_MAXLEN
];
8252 char af_xpath
[XPATH_MAXLEN
];
8253 char attr_xpath
[XPATH_MAXLEN
];
8254 afi_t afi
= bgp_node_afi(vty
);
8255 safi_t safi
= bgp_node_safi(vty
);
8257 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8258 yang_afi_safi_value2identity(afi
, safi
));
8259 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8260 sizeof(base_xpath
), af_xpath
)
8262 return CMD_WARNING_CONFIG_FAILED
;
8264 snprintf(attr_xpath
, sizeof(attr_xpath
),
8265 "/%s/prefix-limit/direction-list[direction='in']",
8266 bgp_afi_safi_get_container_str(afi
, safi
));
8267 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8269 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8271 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8272 argv
[idx_number
]->arg
);
8273 if (argv_find(argv
, argc
, "force", &idx_force
))
8274 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8277 return nb_cli_apply_changes(vty
, base_xpath
);
8280 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8281 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8282 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8283 "Maximum number of prefix accept from this peer\n"
8284 "maximum no. of prefix limit\n"
8285 "Force checking all received routes not only accepted\n")
8287 DEFUN_YANG(neighbor_maximum_prefix_threshold
,
8288 neighbor_maximum_prefix_threshold_cmd
,
8289 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8290 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8291 "Maximum number of prefix accept from this peer\n"
8292 "maximum no. of prefix limit\n"
8293 "Threshold value (%) at which to generate a warning msg\n"
8294 "Force checking all received routes not only accepted\n")
8298 int idx_number_2
= 4;
8300 char base_xpath
[XPATH_MAXLEN
];
8301 char af_xpath
[XPATH_MAXLEN
];
8302 char attr_xpath
[XPATH_MAXLEN
];
8303 afi_t afi
= bgp_node_afi(vty
);
8304 safi_t safi
= bgp_node_safi(vty
);
8306 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8307 yang_afi_safi_value2identity(afi
, safi
));
8308 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8309 sizeof(base_xpath
), af_xpath
)
8311 return CMD_WARNING_CONFIG_FAILED
;
8313 snprintf(attr_xpath
, sizeof(attr_xpath
),
8314 "/%s/prefix-limit/direction-list[direction='in']",
8315 bgp_afi_safi_get_container_str(afi
, safi
));
8316 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8318 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8320 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8321 argv
[idx_number
]->arg
);
8323 nb_cli_enqueue_change(vty
, "./options/shutdown-threshold-pct",
8324 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8326 if (argv_find(argv
, argc
, "force", &idx_force
))
8327 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8330 return nb_cli_apply_changes(vty
, base_xpath
);
8334 neighbor_maximum_prefix_threshold
,
8335 neighbor_maximum_prefix_threshold_hidden_cmd
,
8336 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8337 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8338 "Maximum number of prefix accept from this peer\n"
8339 "maximum no. of prefix limit\n"
8340 "Threshold value (%) at which to generate a warning msg\n"
8341 "Force checking all received routes not only accepted\n")
8343 DEFUN_YANG(neighbor_maximum_prefix_warning
,
8344 neighbor_maximum_prefix_warning_cmd
,
8345 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8346 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8347 "Maximum number of prefix accept from this peer\n"
8348 "maximum no. of prefix limit\n"
8349 "Only give warning message when limit is exceeded\n"
8350 "Force checking all received routes not only accepted\n")
8355 char base_xpath
[XPATH_MAXLEN
];
8356 char af_xpath
[XPATH_MAXLEN
];
8357 char attr_xpath
[XPATH_MAXLEN
];
8358 afi_t afi
= bgp_node_afi(vty
);
8359 safi_t safi
= bgp_node_safi(vty
);
8361 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8362 yang_afi_safi_value2identity(afi
, safi
));
8363 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8364 sizeof(base_xpath
), af_xpath
)
8366 return CMD_WARNING_CONFIG_FAILED
;
8368 snprintf(attr_xpath
, sizeof(attr_xpath
),
8369 "/%s/prefix-limit/direction-list[direction='in']",
8370 bgp_afi_safi_get_container_str(afi
, safi
));
8371 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8373 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8375 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8376 argv
[idx_number
]->arg
);
8378 nb_cli_enqueue_change(vty
, "./options/warning-only", NB_OP_MODIFY
,
8380 if (argv_find(argv
, argc
, "force", &idx_force
))
8381 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8384 return nb_cli_apply_changes(vty
, base_xpath
);
8388 neighbor_maximum_prefix_warning
,
8389 neighbor_maximum_prefix_warning_hidden_cmd
,
8390 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8391 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8392 "Maximum number of prefix accept from this peer\n"
8393 "maximum no. of prefix limit\n"
8394 "Only give warning message when limit is exceeded\n"
8395 "Force checking all received routes not only accepted\n")
8397 DEFUN_YANG(neighbor_maximum_prefix_threshold_warning
,
8398 neighbor_maximum_prefix_threshold_warning_cmd
,
8399 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8400 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8401 "Maximum number of prefix accept from this peer\n"
8402 "maximum no. of prefix limit\n"
8403 "Threshold value (%) at which to generate a warning msg\n"
8404 "Only give warning message when limit is exceeded\n"
8405 "Force checking all received routes not only accepted\n")
8409 int idx_number_2
= 4;
8411 char base_xpath
[XPATH_MAXLEN
];
8412 char af_xpath
[XPATH_MAXLEN
];
8413 char attr_xpath
[XPATH_MAXLEN
];
8414 afi_t afi
= bgp_node_afi(vty
);
8415 safi_t safi
= bgp_node_safi(vty
);
8417 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8418 yang_afi_safi_value2identity(afi
, safi
));
8419 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8420 sizeof(base_xpath
), af_xpath
)
8422 return CMD_WARNING_CONFIG_FAILED
;
8424 snprintf(attr_xpath
, sizeof(attr_xpath
),
8425 "/%s/prefix-limit/direction-list[direction='in']",
8426 bgp_afi_safi_get_container_str(afi
, safi
));
8427 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8429 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8431 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8432 argv
[idx_number
]->arg
);
8433 nb_cli_enqueue_change(vty
, "./options/tw-shutdown-threshold-pct",
8434 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8435 nb_cli_enqueue_change(vty
, "./options/tw-warning-only", NB_OP_MODIFY
,
8437 if (argv_find(argv
, argc
, "force", &idx_force
))
8438 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8441 return nb_cli_apply_changes(vty
, base_xpath
);
8445 neighbor_maximum_prefix_threshold_warning
,
8446 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8447 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8448 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8449 "Maximum number of prefix accept from this peer\n"
8450 "maximum no. of prefix limit\n"
8451 "Threshold value (%) at which to generate a warning msg\n"
8452 "Only give warning message when limit is exceeded\n"
8453 "Force checking all received routes not only accepted\n")
8455 DEFUN_YANG(neighbor_maximum_prefix_restart
,
8456 neighbor_maximum_prefix_restart_cmd
,
8457 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8458 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8459 "Maximum number of prefix accept from this peer\n"
8460 "maximum no. of prefix limit\n"
8461 "Restart bgp connection after limit is exceeded\n"
8462 "Restart interval in minutes\n"
8463 "Force checking all received routes not only accepted\n")
8467 int idx_number_2
= 5;
8469 char base_xpath
[XPATH_MAXLEN
];
8470 char af_xpath
[XPATH_MAXLEN
];
8471 char attr_xpath
[XPATH_MAXLEN
];
8472 afi_t afi
= bgp_node_afi(vty
);
8473 safi_t safi
= bgp_node_safi(vty
);
8475 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8476 yang_afi_safi_value2identity(afi
, safi
));
8477 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8478 sizeof(base_xpath
), af_xpath
)
8480 return CMD_WARNING_CONFIG_FAILED
;
8482 snprintf(attr_xpath
, sizeof(attr_xpath
),
8483 "/%s/prefix-limit/direction-list[direction='in']",
8484 bgp_afi_safi_get_container_str(afi
, safi
));
8485 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8487 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8489 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8490 argv
[idx_number
]->arg
);
8491 nb_cli_enqueue_change(vty
, "./options/restart-timer", NB_OP_MODIFY
,
8492 argv
[idx_number_2
]->arg
);
8493 if (argv_find(argv
, argc
, "force", &idx_force
))
8494 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8497 return nb_cli_apply_changes(vty
, base_xpath
);
8501 neighbor_maximum_prefix_restart
,
8502 neighbor_maximum_prefix_restart_hidden_cmd
,
8503 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8504 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8505 "Maximum number of prefix accept from this peer\n"
8506 "maximum no. of prefix limit\n"
8507 "Restart bgp connection after limit is exceeded\n"
8508 "Restart interval in minutes\n"
8509 "Force checking all received routes not only accepted\n")
8511 DEFUN_YANG(neighbor_maximum_prefix_threshold_restart
,
8512 neighbor_maximum_prefix_threshold_restart_cmd
,
8513 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8514 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8515 "Maximum number of prefixes to accept from this peer\n"
8516 "maximum no. of prefix limit\n"
8517 "Threshold value (%) at which to generate a warning msg\n"
8518 "Restart bgp connection after limit is exceeded\n"
8519 "Restart interval in minutes\n"
8520 "Force checking all received routes not only accepted\n")
8524 int idx_number_2
= 4;
8525 int idx_number_3
= 6;
8527 char base_xpath
[XPATH_MAXLEN
];
8528 char af_xpath
[XPATH_MAXLEN
];
8529 char attr_xpath
[XPATH_MAXLEN
];
8530 afi_t afi
= bgp_node_afi(vty
);
8531 safi_t safi
= bgp_node_safi(vty
);
8533 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8534 yang_afi_safi_value2identity(afi
, safi
));
8535 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8536 sizeof(base_xpath
), af_xpath
)
8538 return CMD_WARNING_CONFIG_FAILED
;
8540 snprintf(attr_xpath
, sizeof(attr_xpath
),
8541 "/%s/prefix-limit/direction-list[direction='in']",
8542 bgp_afi_safi_get_container_str(afi
, safi
));
8543 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8545 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8547 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8548 argv
[idx_number
]->arg
);
8549 nb_cli_enqueue_change(vty
, "./options/tr-shutdown-threshold-pct",
8550 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8551 nb_cli_enqueue_change(vty
, "./options/tr-restart-timer", NB_OP_MODIFY
,
8552 argv
[idx_number_3
]->arg
);
8553 if (argv_find(argv
, argc
, "force", &idx_force
))
8554 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8557 return nb_cli_apply_changes(vty
, base_xpath
);
8561 neighbor_maximum_prefix_threshold_restart
,
8562 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8563 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8564 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8565 "Maximum number of prefixes to accept from this peer\n"
8566 "maximum no. of prefix limit\n"
8567 "Threshold value (%) at which to generate a warning msg\n"
8568 "Restart bgp connection after limit is exceeded\n"
8569 "Restart interval in minutes\n"
8570 "Force checking all received routes not only accepted\n")
8572 DEFUN_YANG(no_neighbor_maximum_prefix
,
8573 no_neighbor_maximum_prefix_cmd
,
8574 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8575 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8576 "Maximum number of prefixes to accept from this peer\n"
8577 "maximum no. of prefix limit\n"
8578 "Threshold value (%) at which to generate a warning msg\n"
8579 "Restart bgp connection after limit is exceeded\n"
8580 "Restart interval in minutes\n"
8581 "Only give warning message when limit is exceeded\n"
8582 "Force checking all received routes not only accepted\n")
8585 char base_xpath
[XPATH_MAXLEN
];
8586 char af_xpath
[XPATH_MAXLEN
];
8587 char attr_xpath
[XPATH_MAXLEN
];
8588 afi_t afi
= bgp_node_afi(vty
);
8589 safi_t safi
= bgp_node_safi(vty
);
8591 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8592 yang_afi_safi_value2identity(afi
, safi
));
8593 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8594 sizeof(base_xpath
), af_xpath
)
8596 return CMD_WARNING_CONFIG_FAILED
;
8598 snprintf(attr_xpath
, sizeof(attr_xpath
),
8599 "/%s/prefix-limit/direction-list[direction='in']",
8600 bgp_afi_safi_get_container_str(afi
, safi
));
8601 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8603 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
8605 return nb_cli_apply_changes(vty
, base_xpath
);
8609 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8610 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8611 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8612 "Maximum number of prefixes to accept from this peer\n"
8613 "maximum no. of prefix limit\n"
8614 "Threshold value (%) at which to generate a warning msg\n"
8615 "Restart bgp connection after limit is exceeded\n"
8616 "Restart interval in minutes\n"
8617 "Only give warning message when limit is exceeded\n"
8618 "Force checking all received routes not only accepted\n")
8621 /* "neighbor allowas-in" */
8622 DEFUN (neighbor_allowas_in
,
8623 neighbor_allowas_in_cmd
,
8624 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8627 "Accept as-path with my AS present in it\n"
8628 "Number of occurrences of AS number\n"
8629 "Only accept my AS in the as-path if the route was originated in my AS\n")
8632 int idx_number_origin
= 3;
8638 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8640 return CMD_WARNING_CONFIG_FAILED
;
8642 if (argc
<= idx_number_origin
)
8645 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8648 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8651 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8654 return bgp_vty_return(vty
, ret
);
8658 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8659 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8660 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8661 "Accept as-path with my AS present in it\n"
8662 "Number of occurrences of AS number\n"
8663 "Only accept my AS in the as-path if the route was originated in my AS\n")
8665 DEFUN (no_neighbor_allowas_in
,
8666 no_neighbor_allowas_in_cmd
,
8667 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8671 "allow local ASN appears in aspath attribute\n"
8672 "Number of occurrences of AS number\n"
8673 "Only accept my AS in the as-path if the route was originated in my AS\n")
8679 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8681 return CMD_WARNING_CONFIG_FAILED
;
8683 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8684 bgp_node_safi(vty
));
8686 return bgp_vty_return(vty
, ret
);
8690 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8691 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8692 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8693 "allow local ASN appears in aspath attribute\n"
8694 "Number of occurrences of AS number\n"
8695 "Only accept my AS in the as-path if the route was originated in my AS\n")
8697 DEFUN_YANG (neighbor_ttl_security
,
8698 neighbor_ttl_security_cmd
,
8699 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8702 "BGP ttl-security parameters\n"
8703 "Specify the maximum number of hops to the BGP peer\n"
8704 "Number of hops to BGP peer\n")
8708 char base_xpath
[XPATH_MAXLEN
];
8710 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8711 sizeof(base_xpath
), NULL
)
8713 return CMD_WARNING_CONFIG_FAILED
;
8715 nb_cli_enqueue_change(vty
, "./ttl-security", NB_OP_MODIFY
,
8716 argv
[idx_number
]->arg
);
8718 return nb_cli_apply_changes(vty
, base_xpath
);
8721 DEFUN_YANG(no_neighbor_ttl_security
,
8722 no_neighbor_ttl_security_cmd
,
8723 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8724 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8725 "BGP ttl-security parameters\n"
8726 "Specify the maximum number of hops to the BGP peer\n"
8727 "Number of hops to BGP peer\n")
8730 char base_xpath
[XPATH_MAXLEN
];
8732 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8733 sizeof(base_xpath
), NULL
)
8735 return CMD_WARNING_CONFIG_FAILED
;
8737 nb_cli_enqueue_change(vty
, "./ttl-security", NB_OP_DESTROY
, NULL
);
8739 return nb_cli_apply_changes(vty
, base_xpath
);
8742 DEFUN (neighbor_addpath_tx_all_paths
,
8743 neighbor_addpath_tx_all_paths_cmd
,
8744 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8747 "Use addpath to advertise all paths to a neighbor\n")
8752 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8754 return CMD_WARNING_CONFIG_FAILED
;
8756 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8761 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8762 neighbor_addpath_tx_all_paths_hidden_cmd
,
8763 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8764 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8765 "Use addpath to advertise all paths to a neighbor\n")
8767 DEFUN (no_neighbor_addpath_tx_all_paths
,
8768 no_neighbor_addpath_tx_all_paths_cmd
,
8769 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8773 "Use addpath to advertise all paths to a neighbor\n")
8778 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8780 return CMD_WARNING_CONFIG_FAILED
;
8782 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8783 != BGP_ADDPATH_ALL
) {
8785 "%% Peer not currently configured to transmit all paths.");
8786 return CMD_WARNING_CONFIG_FAILED
;
8789 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8795 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8796 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8797 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8798 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8799 "Use addpath to advertise all paths to a neighbor\n")
8801 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8802 neighbor_addpath_tx_bestpath_per_as_cmd
,
8803 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8806 "Use addpath to advertise the bestpath per each neighboring AS\n")
8811 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8813 return CMD_WARNING_CONFIG_FAILED
;
8815 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8816 BGP_ADDPATH_BEST_PER_AS
);
8821 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8822 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8823 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8824 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8825 "Use addpath to advertise the bestpath per each neighboring AS\n")
8827 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8828 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8829 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8833 "Use addpath to advertise the bestpath per each neighboring AS\n")
8838 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8840 return CMD_WARNING_CONFIG_FAILED
;
8842 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8843 != BGP_ADDPATH_BEST_PER_AS
) {
8845 "%% Peer not currently configured to transmit all best path per as.");
8846 return CMD_WARNING_CONFIG_FAILED
;
8849 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8855 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8856 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8857 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8858 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8859 "Use addpath to advertise the bestpath per each neighboring AS\n")
8862 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8863 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8866 "Detect AS loops before sending to neighbor\n")
8870 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8872 return CMD_WARNING_CONFIG_FAILED
;
8874 peer
->as_path_loop_detection
= true;
8880 no_neighbor_aspath_loop_detection
,
8881 no_neighbor_aspath_loop_detection_cmd
,
8882 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8886 "Detect AS loops before sending to neighbor\n")
8890 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8892 return CMD_WARNING_CONFIG_FAILED
;
8894 peer
->as_path_loop_detection
= false;
8899 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8900 struct ecommunity
**list
, bool is_rt6
)
8902 struct ecommunity
*ecom
= NULL
;
8903 struct ecommunity
*ecomadd
;
8905 for (; argc
; --argc
, ++argv
) {
8907 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8908 ECOMMUNITY_ROUTE_TARGET
,
8911 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8912 ECOMMUNITY_ROUTE_TARGET
,
8915 vty_out(vty
, "Malformed community-list value\n");
8917 ecommunity_free(&ecom
);
8918 return CMD_WARNING_CONFIG_FAILED
;
8922 ecommunity_merge(ecom
, ecomadd
);
8923 ecommunity_free(&ecomadd
);
8930 ecommunity_free(&*list
);
8937 bool vpn_policy_check_import(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
8938 bool v2vimport
, char *errmsg
, size_t errmsg_len
)
8941 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8942 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8943 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8944 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8946 errmsg
, errmsg_len
, "%s",
8947 "%% error: Please unconfigure import vrf commands before using vpn commands");
8951 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8952 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8953 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8954 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8956 errmsg
, errmsg_len
, "%s",
8957 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands");
8965 * v2vimport is true if we are handling a `import vrf ...` command
8967 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8971 switch (vty
->node
) {
8980 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8985 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8986 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8987 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8988 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8990 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8994 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8995 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8996 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8997 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8999 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
9008 af_rd_vpn_export_cmd
,
9009 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
9011 "Specify route distinguisher\n"
9012 "Between current address-family and vpn\n"
9013 "For routes leaked from current address-family to vpn\n"
9014 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
9016 char base_xpath
[XPATH_MAXLEN
];
9021 afi
= bgp_node_afi(vty
);
9022 safi
= bgp_node_safi(vty
);
9025 base_xpath
, sizeof(base_xpath
),
9026 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9027 yang_afi_safi_value2identity(afi
, safi
),
9028 bgp_afi_safi_get_container_str(afi
, safi
));
9030 if (argv_find(argv
, argc
, "no", &idx
))
9031 nb_cli_enqueue_change(vty
, "./rd", NB_OP_DESTROY
, NULL
);
9033 nb_cli_enqueue_change(vty
, "./rd", NB_OP_MODIFY
, rd_str
);
9035 return nb_cli_apply_changes(vty
, base_xpath
);
9038 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rd(
9039 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9043 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
9044 yang_dnode_get_string(dnode
, NULL
));
9047 ALIAS (af_rd_vpn_export
,
9048 af_no_rd_vpn_export_cmd
,
9051 "Specify route distinguisher\n"
9052 "Between current address-family and vpn\n"
9053 "For routes leaked from current address-family to vpn\n")
9055 DEFPY (af_label_vpn_export
,
9056 af_label_vpn_export_cmd
,
9057 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
9059 "label value for VRF\n"
9060 "Between current address-family and vpn\n"
9061 "For routes leaked from current address-family to vpn\n"
9062 "Label Value <0-1048575>\n"
9063 "Automatically assign a label\n")
9065 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9066 mpls_label_t label
= MPLS_LABEL_NONE
;
9071 if (argv_find(argv
, argc
, "no", &idx
))
9074 /* If "no ...", squash trailing parameter */
9080 label
= label_val
; /* parser should force unsigned */
9083 afi
= vpn_policy_getafi(vty
, bgp
, false);
9085 return CMD_WARNING_CONFIG_FAILED
;
9088 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9089 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
9094 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9096 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9097 bgp_get_default(), bgp
);
9099 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9100 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
9102 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
9105 * label has previously been automatically
9106 * assigned by labelpool: release it
9108 * NB if tovpn_label == MPLS_LABEL_NONE it
9109 * means the automatic assignment is in flight
9110 * and therefore the labelpool callback must
9111 * detect that the auto label is not needed.
9114 bgp_lp_release(LP_TYPE_VRF
,
9115 &bgp
->vpn_policy
[afi
],
9116 bgp
->vpn_policy
[afi
].tovpn_label
);
9118 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9119 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9122 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
9124 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9125 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9126 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
9127 vpn_leak_label_callback
);
9130 /* post-change: re-export vpn routes */
9131 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9132 bgp_get_default(), bgp
);
9137 ALIAS (af_label_vpn_export
,
9138 af_no_label_vpn_export_cmd
,
9139 "no label vpn export",
9141 "label value for VRF\n"
9142 "Between current address-family and vpn\n"
9143 "For routes leaked from current address-family to vpn\n")
9145 DEFPY_YANG (af_nexthop_vpn_export
,
9146 af_nexthop_vpn_export_cmd
,
9147 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
9149 "Specify next hop to use for VRF advertised prefixes\n"
9150 "Between current address-family and vpn\n"
9151 "For routes leaked from current address-family to vpn\n"
9155 char base_xpath
[XPATH_MAXLEN
];
9163 vty_out(vty
, "%% Nexthop required\n");
9164 return CMD_WARNING_CONFIG_FAILED
;
9166 if (!sockunion2hostprefix(nexthop_su
, &p
))
9167 return CMD_WARNING_CONFIG_FAILED
;
9170 afi
= bgp_node_afi(vty
);
9171 safi
= bgp_node_safi(vty
);
9174 base_xpath
, sizeof(base_xpath
),
9175 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9176 yang_afi_safi_value2identity(afi
, safi
),
9177 bgp_afi_safi_get_container_str(afi
, safi
));
9179 if (argv_find(argv
, argc
, "no", &idx
))
9180 nb_cli_enqueue_change(vty
, "./nexthop", NB_OP_DESTROY
, NULL
);
9182 nb_cli_enqueue_change(vty
, "./nexthop", NB_OP_MODIFY
,
9185 return nb_cli_apply_changes(vty
, base_xpath
);
9188 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_nexthop(
9189 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9193 vty_out(vty
, "%*snexthop vpn export %s\n", indent
, "",
9194 yang_dnode_get_string(dnode
, NULL
));
9197 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9199 if (!strcmp(dstr
, "import")) {
9200 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9201 } else if (!strcmp(dstr
, "export")) {
9202 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9203 } else if (!strcmp(dstr
, "both")) {
9204 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9205 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9207 vty_out(vty
, "%% direction parse error\n");
9208 return CMD_WARNING_CONFIG_FAILED
;
9213 DEFPY (af_rt_vpn_imexport
,
9214 af_rt_vpn_imexport_cmd
,
9215 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9217 "Specify route target list\n"
9218 "Specify route target list\n"
9219 "Between current address-family and vpn\n"
9220 "For routes leaked from vpn to current address-family: match any\n"
9221 "For routes leaked from current address-family to vpn: set\n"
9222 "both import: match any and export: set\n"
9223 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9225 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9227 struct ecommunity
*ecom
= NULL
;
9228 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9229 vpn_policy_direction_t dir
;
9234 if (argv_find(argv
, argc
, "no", &idx
))
9237 afi
= vpn_policy_getafi(vty
, bgp
, false);
9239 return CMD_WARNING_CONFIG_FAILED
;
9241 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9242 if (ret
!= CMD_SUCCESS
)
9246 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9247 vty_out(vty
, "%% Missing RTLIST\n");
9248 return CMD_WARNING_CONFIG_FAILED
;
9250 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9251 if (ret
!= CMD_SUCCESS
) {
9256 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9260 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9263 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9265 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9266 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9267 ecommunity_dup(ecom
);
9269 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9271 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9272 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9275 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9279 ecommunity_free(&ecom
);
9284 ALIAS (af_rt_vpn_imexport
,
9285 af_no_rt_vpn_imexport_cmd
,
9286 "no <rt|route-target> vpn <import|export|both>$direction_str",
9288 "Specify route target list\n"
9289 "Specify route target list\n"
9290 "Between current address-family and vpn\n"
9291 "For routes leaked from vpn to current address-family\n"
9292 "For routes leaked from current address-family to vpn\n"
9293 "both import and export\n")
9295 DEFPY_YANG (af_route_map_vpn_imexport
,
9296 af_route_map_vpn_imexport_cmd
,
9297 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9298 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9300 "Specify route map\n"
9301 "Between current address-family and vpn\n"
9302 "For routes leaked from vpn to current address-family\n"
9303 "For routes leaked from current address-family to vpn\n"
9304 "name of route-map\n")
9306 char base_xpath
[XPATH_MAXLEN
];
9311 afi
= bgp_node_afi(vty
);
9312 safi
= bgp_node_safi(vty
);
9315 base_xpath
, sizeof(base_xpath
),
9316 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9317 yang_afi_safi_value2identity(afi
, safi
),
9318 bgp_afi_safi_get_container_str(afi
, safi
));
9320 if (argv_find(argv
, argc
, "no", &idx
)) {
9321 if (!strcmp(direction_str
, "import"))
9322 nb_cli_enqueue_change(vty
, "./rmap-import",
9323 NB_OP_DESTROY
, NULL
);
9324 else if (!strcmp(direction_str
, "export"))
9325 nb_cli_enqueue_change(vty
, "./rmap-export",
9326 NB_OP_DESTROY
, NULL
);
9328 if (!strcmp(direction_str
, "import"))
9329 nb_cli_enqueue_change(vty
, "./rmap-import",
9330 NB_OP_MODIFY
, rmap_str
);
9331 if (!strcmp(direction_str
, "export"))
9332 nb_cli_enqueue_change(vty
, "./rmap-export",
9333 NB_OP_MODIFY
, rmap_str
);
9335 return nb_cli_apply_changes(vty
, base_xpath
);
9338 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_import(
9339 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9343 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
9344 yang_dnode_get_string(dnode
, NULL
));
9347 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_export(
9348 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9352 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
9353 yang_dnode_get_string(dnode
, NULL
));
9356 ALIAS (af_route_map_vpn_imexport
,
9357 af_no_route_map_vpn_imexport_cmd
,
9358 "no route-map vpn <import|export>$direction_str",
9360 "Specify route map\n"
9361 "Between current address-family and vpn\n"
9362 "For routes leaked from vpn to current address-family\n"
9363 "For routes leaked from current address-family to vpn\n")
9365 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9366 "import vrf route-map RMAP$rmap_str",
9367 "Import routes from another VRF\n"
9368 "Vrf routes being filtered\n"
9369 "Specify route map\n"
9370 "name of route-map\n")
9372 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9373 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9375 struct bgp
*bgp_default
;
9377 afi
= vpn_policy_getafi(vty
, bgp
, true);
9379 return CMD_WARNING_CONFIG_FAILED
;
9381 bgp_default
= bgp_get_default();
9386 /* Auto-create assuming the same AS */
9387 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9388 BGP_INSTANCE_TYPE_DEFAULT
);
9392 "VRF default is not configured as a bgp instance\n");
9397 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9399 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9400 XFREE(MTYPE_ROUTE_MAP_NAME
,
9401 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9402 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9403 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9404 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9405 route_map_lookup_warn_noexist(vty
, rmap_str
);
9406 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9409 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9410 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9412 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9417 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9418 "no import vrf route-map [RMAP$rmap_str]",
9420 "Import routes from another VRF\n"
9421 "Vrf routes being filtered\n"
9422 "Specify route map\n"
9423 "name of route-map\n")
9425 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9426 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9429 afi
= vpn_policy_getafi(vty
, bgp
, true);
9431 return CMD_WARNING_CONFIG_FAILED
;
9433 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9435 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9436 XFREE(MTYPE_ROUTE_MAP_NAME
,
9437 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9438 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9439 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9441 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9442 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9443 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9445 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9450 DEFPY_YANG(bgp_imexport_vrf
,
9451 bgp_imexport_vrf_cmd
,
9452 "[no] import vrf VIEWVRFNAME$import_name",
9454 "Import routes from another VRF\n"
9455 "VRF to import from\n"
9456 "The name of the VRF\n")
9458 char base_xpath
[XPATH_MAXLEN
];
9463 if (import_name
== NULL
) {
9464 vty_out(vty
, "%% Missing import name\n");
9468 if (strcmp(import_name
, "route-map") == 0) {
9469 vty_out(vty
, "%% Must include route-map name\n");
9473 afi
= bgp_node_afi(vty
);
9474 safi
= bgp_node_safi(vty
);
9477 base_xpath
, sizeof(base_xpath
),
9478 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vrf-list[vrf='%s']",
9479 yang_afi_safi_value2identity(afi
, safi
),
9480 bgp_afi_safi_get_container_str(afi
, safi
), import_name
);
9482 if (argv_find(argv
, argc
, "no", &idx
))
9483 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
9485 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
9487 return nb_cli_apply_changes(vty
, base_xpath
);
9490 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vrfs(
9491 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9493 vty_out(vty
, " import vrf %s\n",
9494 yang_dnode_get_string(dnode
, "./vrf"));
9497 /* This command is valid only in a bgp vrf instance or the default instance */
9498 DEFPY_YANG (bgp_imexport_vpn
,
9499 bgp_imexport_vpn_cmd
,
9500 "[no] <import|export>$direction_str vpn",
9502 "Import routes to this address-family\n"
9503 "Export routes from this address-family\n"
9504 "to/from default instance VPN RIB\n")
9506 char base_xpath
[XPATH_MAXLEN
];
9511 afi
= bgp_node_afi(vty
);
9512 safi
= bgp_node_safi(vty
);
9514 if (!strcmp(direction_str
, "import")) {
9516 base_xpath
, sizeof(base_xpath
),
9517 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vpn",
9518 yang_afi_safi_value2identity(afi
, safi
),
9519 bgp_afi_safi_get_container_str(afi
, safi
));
9520 } else if (!strcmp(direction_str
, "export")) {
9522 base_xpath
, sizeof(base_xpath
),
9523 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/export-vpn",
9524 yang_afi_safi_value2identity(afi
, safi
),
9525 bgp_afi_safi_get_container_str(afi
, safi
));
9527 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9528 return CMD_WARNING_CONFIG_FAILED
;
9531 if (argv_find(argv
, argc
, "no", &idx
))
9532 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
9534 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, "true");
9536 return nb_cli_apply_changes(vty
, base_xpath
);
9539 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vpn(
9540 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9542 if (yang_dnode_get_bool(dnode
, NULL
))
9543 vty_out(vty
, " import vpn\n");
9546 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_export_vpn(
9547 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9549 if (yang_dnode_get_bool(dnode
, NULL
))
9550 vty_out(vty
, " export vpn\n");
9553 DEFPY (af_routetarget_import
,
9554 af_routetarget_import_cmd
,
9555 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9557 "Specify route target list\n"
9558 "Specify route target list\n"
9559 "Specify route target list\n"
9560 "Specify route target list\n"
9561 "Flow-spec redirect type route target\n"
9562 "Import routes to this address-family\n"
9563 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9565 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9567 struct ecommunity
*ecom
= NULL
;
9569 int idx
= 0, idx_unused
= 0;
9573 if (argv_find(argv
, argc
, "no", &idx
))
9576 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9577 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9580 afi
= vpn_policy_getafi(vty
, bgp
, false);
9582 return CMD_WARNING_CONFIG_FAILED
;
9584 if (rt6
&& afi
!= AFI_IP6
)
9585 return CMD_WARNING_CONFIG_FAILED
;
9588 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9589 vty_out(vty
, "%% Missing RTLIST\n");
9590 return CMD_WARNING_CONFIG_FAILED
;
9592 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9593 if (ret
!= CMD_SUCCESS
)
9598 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9599 ecommunity_free(&bgp
->vpn_policy
[afi
]
9600 .import_redirect_rtlist
);
9601 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9602 ecommunity_dup(ecom
);
9604 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9605 ecommunity_free(&bgp
->vpn_policy
[afi
]
9606 .import_redirect_rtlist
);
9607 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9611 ecommunity_free(&ecom
);
9616 void cli_show_bgp_global_afi_safi_header(struct vty
*vty
,
9617 struct lyd_node
*dnode
,
9620 const char *af_name
;
9624 af_name
= yang_dnode_get_string(dnode
, "./afi-safi-name");
9625 yang_afi_safi_identity2value(af_name
, &afi
, &safi
);
9627 vty_out(vty
, " !\n address-family ");
9628 if (afi
== AFI_IP
) {
9629 if (safi
== SAFI_UNICAST
)
9630 vty_out(vty
, "ipv4 unicast");
9631 else if (safi
== SAFI_LABELED_UNICAST
)
9632 vty_out(vty
, "ipv4 labeled-unicast");
9633 else if (safi
== SAFI_MULTICAST
)
9634 vty_out(vty
, "ipv4 multicast");
9635 else if (safi
== SAFI_MPLS_VPN
)
9636 vty_out(vty
, "ipv4 vpn");
9637 else if (safi
== SAFI_ENCAP
)
9638 vty_out(vty
, "ipv4 encap");
9639 else if (safi
== SAFI_FLOWSPEC
)
9640 vty_out(vty
, "ipv4 flowspec");
9641 } else if (afi
== AFI_IP6
) {
9642 if (safi
== SAFI_UNICAST
)
9643 vty_out(vty
, "ipv6 unicast");
9644 else if (safi
== SAFI_LABELED_UNICAST
)
9645 vty_out(vty
, "ipv6 labeled-unicast");
9646 else if (safi
== SAFI_MULTICAST
)
9647 vty_out(vty
, "ipv6 multicast");
9648 else if (safi
== SAFI_MPLS_VPN
)
9649 vty_out(vty
, "ipv6 vpn");
9650 else if (safi
== SAFI_ENCAP
)
9651 vty_out(vty
, "ipv6 encap");
9652 else if (safi
== SAFI_FLOWSPEC
)
9653 vty_out(vty
, "ipv6 flowspec");
9654 } else if (afi
== AFI_L2VPN
) {
9655 if (safi
== SAFI_EVPN
)
9656 vty_out(vty
, "l2vpn evpn");
9661 DEFUN_NOSH (address_family_ipv4_safi
,
9662 address_family_ipv4_safi_cmd
,
9663 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9664 "Enter Address Family command mode\n"
9666 BGP_SAFI_WITH_LABEL_HELP_STR
)
9669 safi_t safi
= SAFI_UNICAST
;
9670 const struct lyd_node
*vrf_dnode
, *bgp_glb_dnode
;
9671 const char *vrf_name
= NULL
;
9674 safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9676 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
9678 vrf_dnode
= yang_dnode_get_parent(bgp_glb_dnode
,
9679 "control-plane-protocol");
9680 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
9682 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
)
9683 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9684 && safi
!= SAFI_EVPN
) {
9686 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9687 return CMD_WARNING_CONFIG_FAILED
;
9690 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9695 DEFUN_NOSH (address_family_ipv6_safi
,
9696 address_family_ipv6_safi_cmd
,
9697 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9698 "Enter Address Family command mode\n"
9700 BGP_SAFI_WITH_LABEL_HELP_STR
)
9702 safi_t safi
= SAFI_UNICAST
;
9703 const struct lyd_node
*vrf_dnode
, *bgp_glb_dnode
;
9704 const char *vrf_name
= NULL
;
9707 safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9708 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
9710 vrf_dnode
= yang_dnode_get_parent(bgp_glb_dnode
,
9711 "control-plane-protocol");
9712 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
9714 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
)
9715 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9716 && safi
!= SAFI_EVPN
) {
9718 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9719 return CMD_WARNING_CONFIG_FAILED
;
9722 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9727 #ifdef KEEP_OLD_VPN_COMMANDS
9728 DEFUN_NOSH (address_family_vpnv4
,
9729 address_family_vpnv4_cmd
,
9730 "address-family vpnv4 [unicast]",
9731 "Enter Address Family command mode\n"
9733 "Address Family modifier\n")
9735 vty
->node
= BGP_VPNV4_NODE
;
9739 DEFUN_NOSH (address_family_vpnv6
,
9740 address_family_vpnv6_cmd
,
9741 "address-family vpnv6 [unicast]",
9742 "Enter Address Family command mode\n"
9744 "Address Family modifier\n")
9746 vty
->node
= BGP_VPNV6_NODE
;
9749 #endif /* KEEP_OLD_VPN_COMMANDS */
9751 DEFUN_NOSH (address_family_evpn
,
9752 address_family_evpn_cmd
,
9753 "address-family l2vpn evpn",
9754 "Enter Address Family command mode\n"
9756 "Address Family modifier\n")
9758 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9759 vty
->node
= BGP_EVPN_NODE
;
9763 DEFUN_NOSH (exit_address_family
,
9764 exit_address_family_cmd
,
9765 "exit-address-family",
9766 "Exit from Address Family configuration mode\n")
9768 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9769 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9770 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9771 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9772 || vty
->node
== BGP_EVPN_NODE
9773 || vty
->node
== BGP_FLOWSPECV4_NODE
9774 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9775 vty
->node
= BGP_NODE
;
9779 void cli_show_bgp_global_afi_safi_header_end(struct vty
*vty
,
9780 struct lyd_node
*dnode
9781 __attribute__((__unused__
)))
9783 vty_out(vty
, " exit-address-family\n");
9786 /* Recalculate bestpath and re-advertise a prefix */
9787 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9788 const char *ip_str
, afi_t afi
, safi_t safi
,
9789 struct prefix_rd
*prd
)
9792 struct prefix match
;
9793 struct bgp_dest
*dest
;
9794 struct bgp_dest
*rm
;
9796 struct bgp_table
*table
;
9797 struct bgp_table
*rib
;
9799 /* BGP structure lookup. */
9801 bgp
= bgp_lookup_by_name(view_name
);
9803 vty_out(vty
, "%% Can't find BGP instance %s\n",
9808 bgp
= bgp_get_default();
9810 vty_out(vty
, "%% No BGP process is configured\n");
9815 /* Check IP address argument. */
9816 ret
= str2prefix(ip_str
, &match
);
9818 vty_out(vty
, "%% address is malformed\n");
9822 match
.family
= afi2family(afi
);
9823 rib
= bgp
->rib
[afi
][safi
];
9825 if (safi
== SAFI_MPLS_VPN
) {
9826 for (dest
= bgp_table_top(rib
); dest
;
9827 dest
= bgp_route_next(dest
)) {
9828 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9830 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9833 table
= bgp_dest_get_bgp_table_info(dest
);
9837 if ((rm
= bgp_node_match(table
, &match
)) != NULL
) {
9838 const struct prefix
*rm_p
=
9839 bgp_dest_get_prefix(rm
);
9841 if (rm_p
->prefixlen
== match
.prefixlen
) {
9843 BGP_NODE_USER_CLEAR
);
9844 bgp_process(bgp
, rm
, afi
, safi
);
9846 bgp_dest_unlock_node(rm
);
9850 if ((dest
= bgp_node_match(rib
, &match
)) != NULL
) {
9851 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9853 if (dest_p
->prefixlen
== match
.prefixlen
) {
9854 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9855 bgp_process(bgp
, dest
, afi
, safi
);
9857 bgp_dest_unlock_node(dest
);
9864 /* one clear bgp command to rule them all */
9865 DEFUN (clear_ip_bgp_all
,
9866 clear_ip_bgp_all_cmd
,
9867 "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>]",
9871 BGP_INSTANCE_HELP_STR
9874 BGP_SAFI_WITH_LABEL_HELP_STR
9875 "Address Family modifier\n"
9877 "BGP IPv4 neighbor to clear\n"
9878 "BGP IPv6 neighbor to clear\n"
9879 "BGP neighbor on interface to clear\n"
9880 "Clear peers with the AS number\n"
9881 "Clear all external peers\n"
9882 "Clear all members of peer-group\n"
9883 "BGP peer-group name\n"
9888 "Push out prefix-list ORF and do inbound soft reconfig\n"
9893 afi_t afi
= AFI_UNSPEC
;
9894 safi_t safi
= SAFI_UNSPEC
;
9895 enum clear_sort clr_sort
= clear_peer
;
9896 enum bgp_clear_type clr_type
;
9897 char *clr_arg
= NULL
;
9900 char errmsg
[BUFSIZ
] = {'\0'};
9903 /* clear [ip] bgp */
9904 if (argv_find(argv
, argc
, "ip", &idx
))
9907 /* [<vrf> VIEWVRFNAME] */
9908 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9909 vrf
= argv
[idx
+ 1]->arg
;
9911 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9913 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9914 /* [<view> VIEWVRFNAME] */
9915 vrf
= argv
[idx
+ 1]->arg
;
9918 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9919 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
9920 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
9922 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
9923 if (argv_find(argv
, argc
, "*", &idx
)) {
9924 clr_sort
= clear_all
;
9925 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
9926 clr_sort
= clear_peer
;
9927 clr_arg
= argv
[idx
]->arg
;
9928 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
9929 clr_sort
= clear_peer
;
9930 clr_arg
= argv
[idx
]->arg
;
9931 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
9932 clr_sort
= clear_group
;
9934 clr_arg
= argv
[idx
]->arg
;
9935 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
9936 clr_sort
= clear_peer
;
9937 clr_arg
= argv
[idx
]->arg
;
9938 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
9939 clr_sort
= clear_peer
;
9940 clr_arg
= argv
[idx
]->arg
;
9941 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
9942 clr_sort
= clear_as
;
9943 clr_arg
= argv
[idx
]->arg
;
9944 } else if (argv_find(argv
, argc
, "external", &idx
)) {
9945 clr_sort
= clear_external
;
9948 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
9949 if (argv_find(argv
, argc
, "soft", &idx
)) {
9950 if (argv_find(argv
, argc
, "in", &idx
)
9951 || argv_find(argv
, argc
, "out", &idx
))
9952 clr_type
= strmatch(argv
[idx
]->text
, "in")
9954 : BGP_CLEAR_SOFT_OUT
;
9956 clr_type
= BGP_CLEAR_SOFT_BOTH
;
9957 } else if (argv_find(argv
, argc
, "in", &idx
)) {
9958 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
9959 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
9960 : BGP_CLEAR_SOFT_IN
;
9961 } else if (argv_find(argv
, argc
, "out", &idx
)) {
9962 clr_type
= BGP_CLEAR_SOFT_OUT
;
9964 clr_type
= BGP_CLEAR_SOFT_NONE
;
9966 ret
= bgp_clear_vty(vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
, errmsg
,
9969 vty_out(vty
, "Error description: %s\n", errmsg
);
9974 DEFUN (clear_ip_bgp_prefix
,
9975 clear_ip_bgp_prefix_cmd
,
9976 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
9980 BGP_INSTANCE_HELP_STR
9981 "Clear bestpath and re-advertise\n"
9985 char *prefix
= NULL
;
9989 /* [<view|vrf> VIEWVRFNAME] */
9990 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9991 vrf
= argv
[idx
+ 1]->arg
;
9993 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9995 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9996 /* [<view> VIEWVRFNAME] */
9997 vrf
= argv
[idx
+ 1]->arg
;
10001 prefix
= argv
[argc
- 1]->arg
;
10003 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
10006 DEFUN (clear_bgp_ipv6_safi_prefix
,
10007 clear_bgp_ipv6_safi_prefix_cmd
,
10008 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10014 "Clear bestpath and re-advertise\n"
10018 int idx_ipv6_prefix
= 0;
10019 safi_t safi
= SAFI_UNICAST
;
10020 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10021 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10023 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10024 return bgp_clear_prefix(
10025 vty
, NULL
, prefix
, AFI_IP6
,
10029 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
10030 clear_bgp_instance_ipv6_safi_prefix_cmd
,
10031 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10035 BGP_INSTANCE_HELP_STR
10038 "Clear bestpath and re-advertise\n"
10042 int idx_vrfview
= 0;
10043 int idx_ipv6_prefix
= 0;
10044 safi_t safi
= SAFI_UNICAST
;
10045 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10046 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10047 char *vrfview
= NULL
;
10049 /* [<view|vrf> VIEWVRFNAME] */
10050 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
10051 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10052 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
10054 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
10055 /* [<view> VIEWVRFNAME] */
10056 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10058 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10060 return bgp_clear_prefix(
10061 vty
, vrfview
, prefix
,
10062 AFI_IP6
, safi
, NULL
);
10065 DEFUN (show_bgp_views
,
10066 show_bgp_views_cmd
,
10067 "show [ip] bgp views",
10071 "Show the defined BGP views\n")
10073 struct list
*inst
= bm
->bgp
;
10074 struct listnode
*node
;
10077 vty_out(vty
, "Defined BGP views:\n");
10078 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10080 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10082 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
10086 return CMD_SUCCESS
;
10089 DEFUN (show_bgp_vrfs
,
10091 "show [ip] bgp vrfs [json]",
10098 char buf
[ETHER_ADDR_STRLEN
];
10099 struct list
*inst
= bm
->bgp
;
10100 struct listnode
*node
;
10102 bool uj
= use_json(argc
, argv
);
10103 json_object
*json
= NULL
;
10104 json_object
*json_vrfs
= NULL
;
10108 json
= json_object_new_object();
10109 json_vrfs
= json_object_new_object();
10112 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10113 const char *name
, *type
;
10115 struct listnode
*node2
, *nnode2
;
10116 int peers_cfg
, peers_estb
;
10117 json_object
*json_vrf
= NULL
;
10120 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10124 if (!uj
&& count
== 1) {
10126 "%4s %-5s %-16s %9s %10s %-37s\n",
10127 "Type", "Id", "routerId", "#PeersCfg",
10128 "#PeersEstb", "Name");
10129 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10130 "L3-VNI", "RouterMAC", "Interface");
10133 peers_cfg
= peers_estb
= 0;
10135 json_vrf
= json_object_new_object();
10138 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
10139 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10142 if (peer
->status
== Established
)
10146 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10147 name
= VRF_DEFAULT_NAME
;
10156 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10158 : (int64_t)bgp
->vrf_id
;
10159 char buf
[BUFSIZ
] = {0};
10161 json_object_string_add(json_vrf
, "type", type
);
10162 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
10163 json_object_string_add(json_vrf
, "routerId",
10165 &bgp
->router_id
, buf
,
10167 json_object_int_add(json_vrf
, "numConfiguredPeers",
10169 json_object_int_add(json_vrf
, "numEstablishedPeers",
10172 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
10173 json_object_string_add(
10175 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
10176 json_object_string_add(json_vrf
, "interface",
10177 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10179 json_object_object_add(json_vrfs
, name
, json_vrf
);
10181 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10183 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10184 : (int)bgp
->vrf_id
,
10185 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10186 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
10188 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
10189 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10195 json_object_object_add(json
, "vrfs", json_vrfs
);
10197 json_object_int_add(json
, "totalVrfs", count
);
10199 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10200 json
, JSON_C_TO_STRING_PRETTY
));
10201 json_object_free(json
);
10205 "\nTotal number of VRFs (including default): %d\n",
10209 return CMD_SUCCESS
;
10212 DEFUN (show_bgp_mac_hash
,
10213 show_bgp_mac_hash_cmd
,
10214 "show bgp mac hash",
10218 "Mac Address database\n")
10220 bgp_mac_dump_table(vty
);
10222 return CMD_SUCCESS
;
10225 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10227 struct vty
*vty
= (struct vty
*)args
;
10228 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10230 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10233 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10235 vty_out(vty
, "self nexthop database:\n");
10236 bgp_nexthop_show_address_hash(vty
, bgp
);
10238 vty_out(vty
, "Tunnel-ip database:\n");
10239 hash_iterate(bgp
->tip_hash
,
10240 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10244 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10245 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10246 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10247 "martian next-hops\n"
10248 "martian next-hop database\n")
10250 struct bgp
*bgp
= NULL
;
10254 /* [<vrf> VIEWVRFNAME] */
10255 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10256 name
= argv
[idx
+ 1]->arg
;
10257 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10259 } else if (argv_find(argv
, argc
, "view", &idx
))
10260 /* [<view> VIEWVRFNAME] */
10261 name
= argv
[idx
+ 1]->arg
;
10263 bgp
= bgp_lookup_by_name(name
);
10265 bgp
= bgp_get_default();
10268 vty_out(vty
, "%% No BGP process is configured\n");
10269 return CMD_WARNING
;
10271 bgp_show_martian_nexthops(vty
, bgp
);
10273 return CMD_SUCCESS
;
10276 DEFUN (show_bgp_memory
,
10277 show_bgp_memory_cmd
,
10278 "show [ip] bgp memory",
10282 "Global BGP memory statistics\n")
10284 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10285 unsigned long count
;
10287 /* RIB related usage stats */
10288 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10289 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10290 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10291 count
* sizeof(struct bgp_dest
)));
10293 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10294 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10295 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10296 count
* sizeof(struct bgp_path_info
)));
10297 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10298 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10301 memstrbuf
, sizeof(memstrbuf
),
10302 count
* sizeof(struct bgp_path_info_extra
)));
10304 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10305 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10306 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10307 count
* sizeof(struct bgp_static
)));
10309 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10310 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10311 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10312 count
* sizeof(struct bpacket
)));
10315 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10316 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10317 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10318 count
* sizeof(struct bgp_adj_in
)));
10319 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10320 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10321 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10322 count
* sizeof(struct bgp_adj_out
)));
10324 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10325 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10327 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10328 count
* sizeof(struct bgp_nexthop_cache
)));
10330 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10331 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10333 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10334 count
* sizeof(struct bgp_damp_info
)));
10337 count
= attr_count();
10338 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10339 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10340 count
* sizeof(struct attr
)));
10342 if ((count
= attr_unknown_count()))
10343 vty_out(vty
, "%ld unknown attributes\n", count
);
10345 /* AS_PATH attributes */
10346 count
= aspath_count();
10347 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10348 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10349 count
* sizeof(struct aspath
)));
10351 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10352 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10353 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10354 count
* sizeof(struct assegment
)));
10356 /* Other attributes */
10357 if ((count
= community_count()))
10358 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10359 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10360 count
* sizeof(struct community
)));
10361 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10362 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10363 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10364 count
* sizeof(struct ecommunity
)));
10365 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10367 "%ld BGP large-community entries, using %s of memory\n",
10368 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10369 count
* sizeof(struct lcommunity
)));
10371 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10372 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10373 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10374 count
* sizeof(struct cluster_list
)));
10376 /* Peer related usage */
10377 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10378 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10379 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10380 count
* sizeof(struct peer
)));
10382 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10383 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10384 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10385 count
* sizeof(struct peer_group
)));
10388 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10389 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10390 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10391 count
* sizeof(regex_t
)));
10392 return CMD_SUCCESS
;
10395 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10397 json_object
*bestpath
= json_object_new_object();
10399 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10400 json_object_string_add(bestpath
, "asPath", "ignore");
10402 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10403 json_object_string_add(bestpath
, "asPath", "confed");
10405 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10406 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10407 json_object_string_add(bestpath
, "multiPathRelax",
10410 json_object_string_add(bestpath
, "multiPathRelax",
10413 json_object_string_add(bestpath
, "multiPathRelax", "false");
10415 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10416 json_object_string_add(bestpath
, "compareRouterId", "true");
10417 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10418 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10419 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10420 json_object_string_add(bestpath
, "med", "confed");
10421 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10422 json_object_string_add(bestpath
, "med",
10423 "missing-as-worst");
10425 json_object_string_add(bestpath
, "med", "true");
10428 json_object_object_add(json
, "bestPath", bestpath
);
10431 /* Print the error code/subcode for why the peer is down */
10432 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10433 json_object
*json_peer
, bool use_json
)
10435 const char *code_str
;
10436 const char *subcode_str
;
10439 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10440 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10441 char errorcodesubcode_hexstr
[5];
10442 char errorcodesubcode_str
[256];
10444 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10445 subcode_str
= bgp_notify_subcode_str(
10447 peer
->notify
.subcode
);
10449 snprintf(errorcodesubcode_hexstr
,
10450 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10451 peer
->notify
.code
, peer
->notify
.subcode
);
10452 json_object_string_add(json_peer
,
10453 "lastErrorCodeSubcode",
10454 errorcodesubcode_hexstr
);
10455 snprintf(errorcodesubcode_str
, 255, "%s%s",
10456 code_str
, subcode_str
);
10457 json_object_string_add(json_peer
,
10458 "lastNotificationReason",
10459 errorcodesubcode_str
);
10460 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10461 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10462 && (peer
->notify
.subcode
10463 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10464 || peer
->notify
.subcode
10465 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10466 && peer
->notify
.length
) {
10468 const char *msg_str
;
10470 msg_str
= bgp_notify_admin_message(
10471 msgbuf
, sizeof(msgbuf
),
10472 (uint8_t *)peer
->notify
.data
,
10473 peer
->notify
.length
);
10475 json_object_string_add(
10477 "lastShutdownDescription",
10482 json_object_string_add(json_peer
, "lastResetDueTo",
10483 peer_down_str
[(int)peer
->last_reset
]);
10484 json_object_int_add(json_peer
, "lastResetCode",
10487 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10488 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10489 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10491 bgp_notify_subcode_str(peer
->notify
.code
,
10492 peer
->notify
.subcode
);
10493 vty_out(vty
, " Notification %s (%s%s)\n",
10494 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10497 code_str
, subcode_str
);
10499 vty_out(vty
, " %s\n",
10500 peer_down_str
[(int)peer
->last_reset
]);
10505 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10508 return ((peer
->status
!= Established
) ||
10509 !peer
->afc_recv
[afi
][safi
]);
10512 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10513 struct peer
*peer
, json_object
*json_peer
,
10514 int max_neighbor_width
, bool use_json
)
10516 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10520 if (peer_dynamic_neighbor(peer
))
10521 json_object_boolean_true_add(json_peer
,
10523 if (peer
->hostname
)
10524 json_object_string_add(json_peer
, "hostname",
10527 if (peer
->domainname
)
10528 json_object_string_add(json_peer
, "domainname",
10530 json_object_int_add(json_peer
, "connectionsEstablished",
10531 peer
->established
);
10532 json_object_int_add(json_peer
, "connectionsDropped",
10534 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10535 use_json
, json_peer
);
10536 if (peer
->status
== Established
)
10537 json_object_string_add(json_peer
, "lastResetDueTo",
10538 "AFI/SAFI Not Negotiated");
10540 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10543 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10545 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10546 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10547 peer
->hostname
, peer
->host
);
10549 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10551 /* pad the neighbor column with spaces */
10552 if (len
< max_neighbor_width
)
10553 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10555 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10557 peer_uptime(peer
->uptime
, timebuf
,
10558 BGP_UPTIME_LEN
, 0, NULL
));
10559 if (peer
->status
== Established
)
10560 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10562 bgp_show_peer_reset(vty
, peer
, NULL
,
10568 /* Show BGP peer's summary information. */
10569 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10570 bool show_failed
, bool show_established
,
10574 struct listnode
*node
, *nnode
;
10575 unsigned int count
= 0, dn_count
= 0;
10576 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10577 char neighbor_buf
[VTY_BUFSIZ
];
10578 int neighbor_col_default_width
= 16;
10579 int len
, failed_count
= 0;
10580 int max_neighbor_width
= 0;
10582 json_object
*json
= NULL
;
10583 json_object
*json_peer
= NULL
;
10584 json_object
*json_peers
= NULL
;
10585 struct peer_af
*paf
;
10586 struct bgp_filter
*filter
;
10588 /* labeled-unicast routes are installed in the unicast table so in order
10590 * display the correct PfxRcd value we must look at SAFI_UNICAST
10593 if (safi
== SAFI_LABELED_UNICAST
)
10594 pfx_rcd_safi
= SAFI_UNICAST
;
10596 pfx_rcd_safi
= safi
;
10599 json
= json_object_new_object();
10600 json_peers
= json_object_new_object();
10601 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10602 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10605 if (peer
->afc
[afi
][safi
]) {
10606 /* See if we have at least a single failed peer */
10607 if (bgp_has_peer_failed(peer
, afi
, safi
))
10611 if (peer_dynamic_neighbor(peer
))
10616 /* Loop over all neighbors that will be displayed to determine
10618 * characters are needed for the Neighbor column
10620 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10621 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10624 if (peer
->afc
[afi
][safi
]) {
10625 memset(dn_flag
, '\0', sizeof(dn_flag
));
10626 if (peer_dynamic_neighbor(peer
))
10630 && CHECK_FLAG(bgp
->flags
,
10631 BGP_FLAG_SHOW_HOSTNAME
))
10632 snprintf(neighbor_buf
,
10633 sizeof(neighbor_buf
),
10634 "%s%s(%s) ", dn_flag
,
10635 peer
->hostname
, peer
->host
);
10637 snprintf(neighbor_buf
,
10638 sizeof(neighbor_buf
), "%s%s ",
10639 dn_flag
, peer
->host
);
10641 len
= strlen(neighbor_buf
);
10643 if (len
> max_neighbor_width
)
10644 max_neighbor_width
= len
;
10646 /* See if we have at least a single failed peer */
10647 if (bgp_has_peer_failed(peer
, afi
, safi
))
10653 /* Originally we displayed the Neighbor column as 16
10654 * characters wide so make that the default
10656 if (max_neighbor_width
< neighbor_col_default_width
)
10657 max_neighbor_width
= neighbor_col_default_width
;
10660 if (show_failed
&& !failed_count
) {
10662 json_object_int_add(json
, "failedPeersCount", 0);
10663 json_object_int_add(json
, "dynamicPeers", dn_count
);
10664 json_object_int_add(json
, "totalPeers", count
);
10666 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10667 json
, JSON_C_TO_STRING_PRETTY
));
10668 json_object_free(json
);
10670 vty_out(vty
, "%% No failed BGP neighbors found\n");
10671 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
10673 return CMD_SUCCESS
;
10676 count
= 0; /* Reset the value as its used again */
10677 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10678 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10681 if (!peer
->afc
[afi
][safi
])
10685 unsigned long ents
;
10686 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10689 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10691 : (int64_t)bgp
->vrf_id
;
10693 /* Usage summary and header */
10695 char buf
[BUFSIZ
] = {0};
10697 json_object_string_add(
10699 inet_ntop(AF_INET
, &bgp
->router_id
, buf
,
10701 json_object_int_add(json
, "as", bgp
->as
);
10702 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10703 json_object_string_add(
10706 == BGP_INSTANCE_TYPE_DEFAULT
)
10711 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10712 &bgp
->router_id
, bgp
->as
,
10713 bgp
->vrf_id
== VRF_UNKNOWN
10715 : (int)bgp
->vrf_id
);
10716 vty_out(vty
, "\n");
10719 if (bgp_update_delay_configured(bgp
)) {
10721 json_object_int_add(
10722 json
, "updateDelayLimit",
10723 bgp
->v_update_delay
);
10725 if (bgp
->v_update_delay
10726 != bgp
->v_establish_wait
)
10727 json_object_int_add(
10729 "updateDelayEstablishWait",
10730 bgp
->v_establish_wait
);
10732 if (bgp_update_delay_active(bgp
)) {
10733 json_object_string_add(
10735 "updateDelayFirstNeighbor",
10736 bgp
->update_delay_begin_time
);
10737 json_object_boolean_true_add(
10739 "updateDelayInProgress");
10741 if (bgp
->update_delay_over
) {
10742 json_object_string_add(
10744 "updateDelayFirstNeighbor",
10745 bgp
->update_delay_begin_time
);
10746 json_object_string_add(
10748 "updateDelayBestpathResumed",
10749 bgp
->update_delay_end_time
);
10750 json_object_string_add(
10752 "updateDelayZebraUpdateResume",
10753 bgp
->update_delay_zebra_resume_time
);
10754 json_object_string_add(
10756 "updateDelayPeerUpdateResume",
10757 bgp
->update_delay_peers_resume_time
);
10762 "Read-only mode update-delay limit: %d seconds\n",
10763 bgp
->v_update_delay
);
10764 if (bgp
->v_update_delay
10765 != bgp
->v_establish_wait
)
10767 " Establish wait: %d seconds\n",
10768 bgp
->v_establish_wait
);
10770 if (bgp_update_delay_active(bgp
)) {
10772 " First neighbor established: %s\n",
10773 bgp
->update_delay_begin_time
);
10775 " Delay in progress\n");
10777 if (bgp
->update_delay_over
) {
10779 " First neighbor established: %s\n",
10780 bgp
->update_delay_begin_time
);
10782 " Best-paths resumed: %s\n",
10783 bgp
->update_delay_end_time
);
10785 " zebra update resumed: %s\n",
10786 bgp
->update_delay_zebra_resume_time
);
10788 " peers update resumed: %s\n",
10789 bgp
->update_delay_peers_resume_time
);
10796 if (bgp_maxmed_onstartup_configured(bgp
)
10797 && bgp
->maxmed_active
)
10798 json_object_boolean_true_add(
10799 json
, "maxMedOnStartup");
10800 if (bgp
->v_maxmed_admin
)
10801 json_object_boolean_true_add(
10802 json
, "maxMedAdministrative");
10804 json_object_int_add(
10805 json
, "tableVersion",
10806 bgp_table_version(bgp
->rib
[afi
][safi
]));
10808 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10809 json_object_int_add(json
, "ribCount", ents
);
10810 json_object_int_add(
10812 ents
* sizeof(struct bgp_dest
));
10814 ents
= bgp
->af_peer_count
[afi
][safi
];
10815 json_object_int_add(json
, "peerCount", ents
);
10816 json_object_int_add(json
, "peerMemory",
10817 ents
* sizeof(struct peer
));
10819 if ((ents
= listcount(bgp
->group
))) {
10820 json_object_int_add(
10821 json
, "peerGroupCount", ents
);
10822 json_object_int_add(
10823 json
, "peerGroupMemory",
10824 ents
* sizeof(struct
10828 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10829 BGP_CONFIG_DAMPENING
))
10830 json_object_boolean_true_add(
10831 json
, "dampeningEnabled");
10833 if (bgp_maxmed_onstartup_configured(bgp
)
10834 && bgp
->maxmed_active
)
10836 "Max-med on-startup active\n");
10837 if (bgp
->v_maxmed_admin
)
10839 "Max-med administrative active\n");
10841 vty_out(vty
, "BGP table version %" PRIu64
"\n",
10842 bgp_table_version(bgp
->rib
[afi
][safi
]));
10844 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10846 "RIB entries %ld, using %s of memory\n",
10849 memstrbuf
, sizeof(memstrbuf
),
10854 /* Peer related usage */
10855 ents
= bgp
->af_peer_count
[afi
][safi
];
10856 vty_out(vty
, "Peers %ld, using %s of memory\n",
10859 memstrbuf
, sizeof(memstrbuf
),
10860 ents
* sizeof(struct peer
)));
10862 if ((ents
= listcount(bgp
->group
)))
10864 "Peer groups %ld, using %s of memory\n",
10869 ents
* sizeof(struct
10872 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10873 BGP_CONFIG_DAMPENING
))
10874 vty_out(vty
, "Dampening enabled.\n");
10875 vty_out(vty
, "\n");
10877 /* Subtract 8 here because 'Neighbor' is
10879 vty_out(vty
, "Neighbor");
10880 vty_out(vty
, "%*s", max_neighbor_width
- 8,
10883 vty_out(vty
, "EstdCnt DropCnt ResetTime Reason\n");
10886 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc\n");
10890 paf
= peer_af_find(peer
, afi
, safi
);
10891 filter
= &peer
->filter
[afi
][safi
];
10894 /* Works for both failed & successful cases */
10895 if (peer_dynamic_neighbor(peer
))
10902 bgp_has_peer_failed(peer
, afi
, safi
)) {
10903 json_peer
= json_object_new_object();
10904 bgp_show_failed_summary(vty
, bgp
, peer
,
10905 json_peer
, 0, use_json
);
10906 } else if (!show_failed
) {
10907 if (show_established
10908 && bgp_has_peer_failed(peer
, afi
, safi
))
10911 json_peer
= json_object_new_object();
10912 if (peer_dynamic_neighbor(peer
)) {
10913 json_object_boolean_true_add(json_peer
,
10917 if (peer
->hostname
)
10918 json_object_string_add(json_peer
, "hostname",
10921 if (peer
->domainname
)
10922 json_object_string_add(json_peer
, "domainname",
10925 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
10926 json_object_int_add(json_peer
, "version", 4);
10927 json_object_int_add(json_peer
, "msgRcvd",
10928 PEER_TOTAL_RX(peer
));
10929 json_object_int_add(json_peer
, "msgSent",
10930 PEER_TOTAL_TX(peer
));
10932 atomic_size_t outq_count
, inq_count
;
10933 outq_count
= atomic_load_explicit(
10934 &peer
->obuf
->count
,
10935 memory_order_relaxed
);
10936 inq_count
= atomic_load_explicit(
10937 &peer
->ibuf
->count
,
10938 memory_order_relaxed
);
10940 json_object_int_add(json_peer
, "tableVersion",
10941 peer
->version
[afi
][safi
]);
10942 json_object_int_add(json_peer
, "outq",
10944 json_object_int_add(json_peer
, "inq",
10946 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10947 use_json
, json_peer
);
10949 json_object_int_add(json_peer
, "pfxRcd",
10950 peer
->pcount
[afi
][pfx_rcd_safi
]);
10952 if (paf
&& PAF_SUBGRP(paf
))
10953 json_object_int_add(
10954 json_peer
, "pfxSnt",
10955 (PAF_SUBGRP(paf
))->scount
);
10957 json_object_int_add(json_peer
, "pfxSnt",
10960 /* BGP FSM state */
10961 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10962 || CHECK_FLAG(peer
->bgp
->flags
,
10963 BGP_FLAG_SHUTDOWN
))
10964 json_object_string_add(json_peer
,
10967 else if (peer
->afc_recv
[afi
][safi
])
10968 json_object_string_add(
10969 json_peer
, "state",
10970 lookup_msg(bgp_status_msg
,
10971 peer
->status
, NULL
));
10972 else if (CHECK_FLAG(
10974 PEER_STATUS_PREFIX_OVERFLOW
))
10975 json_object_string_add(json_peer
,
10979 json_object_string_add(
10980 json_peer
, "state",
10981 lookup_msg(bgp_status_msg
,
10982 peer
->status
, NULL
));
10984 /* BGP peer state */
10985 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10986 || CHECK_FLAG(peer
->bgp
->flags
,
10987 BGP_FLAG_SHUTDOWN
))
10988 json_object_string_add(json_peer
,
10991 else if (CHECK_FLAG(
10993 PEER_STATUS_PREFIX_OVERFLOW
))
10994 json_object_string_add(json_peer
,
10997 else if (CHECK_FLAG(peer
->flags
,
10998 PEER_FLAG_PASSIVE
))
10999 json_object_string_add(json_peer
,
11002 else if (CHECK_FLAG(peer
->sflags
,
11003 PEER_STATUS_NSF_WAIT
))
11004 json_object_string_add(json_peer
,
11007 else if (CHECK_FLAG(
11009 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11010 && (!bgp_inbound_policy_exists(peer
,
11012 || !bgp_outbound_policy_exists(
11014 json_object_string_add(json_peer
,
11018 json_object_string_add(
11019 json_peer
, "peerState", "OK");
11021 json_object_int_add(json_peer
, "connectionsEstablished",
11022 peer
->established
);
11023 json_object_int_add(json_peer
, "connectionsDropped",
11026 json_object_string_add(
11027 json_peer
, "desc", peer
->desc
);
11029 /* Avoid creating empty peer dicts in JSON */
11030 if (json_peer
== NULL
)
11034 json_object_string_add(json_peer
, "idType",
11036 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11037 json_object_string_add(json_peer
, "idType",
11039 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11040 json_object_string_add(json_peer
, "idType",
11042 json_object_object_add(json_peers
, peer
->host
,
11046 bgp_has_peer_failed(peer
, afi
, safi
)) {
11047 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11048 max_neighbor_width
,
11050 } else if (!show_failed
) {
11051 if (show_established
11052 && bgp_has_peer_failed(peer
, afi
, safi
))
11055 memset(dn_flag
, '\0', sizeof(dn_flag
));
11056 if (peer_dynamic_neighbor(peer
)) {
11061 && CHECK_FLAG(bgp
->flags
,
11062 BGP_FLAG_SHOW_HOSTNAME
))
11063 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11067 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11069 /* pad the neighbor column with spaces */
11070 if (len
< max_neighbor_width
)
11071 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11074 atomic_size_t outq_count
, inq_count
;
11075 outq_count
= atomic_load_explicit(
11076 &peer
->obuf
->count
,
11077 memory_order_relaxed
);
11078 inq_count
= atomic_load_explicit(
11079 &peer
->ibuf
->count
,
11080 memory_order_relaxed
);
11083 "4 %10u %9u %9u %8" PRIu64
" %4zu %4zu %8s",
11084 peer
->as
, PEER_TOTAL_RX(peer
),
11085 PEER_TOTAL_TX(peer
),
11086 peer
->version
[afi
][safi
], inq_count
,
11088 peer_uptime(peer
->uptime
, timebuf
,
11089 BGP_UPTIME_LEN
, 0, NULL
));
11091 if (peer
->status
== Established
) {
11092 if (peer
->afc_recv
[afi
][safi
]) {
11095 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11096 && !bgp_inbound_policy_exists(
11098 vty_out(vty
, " %12s",
11107 vty_out(vty
, " NoNeg");
11110 if (paf
&& PAF_SUBGRP(paf
)) {
11113 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11114 && !bgp_outbound_policy_exists(
11116 vty_out(vty
, " %8s",
11126 if (CHECK_FLAG(peer
->flags
,
11127 PEER_FLAG_SHUTDOWN
)
11128 || CHECK_FLAG(peer
->bgp
->flags
,
11129 BGP_FLAG_SHUTDOWN
))
11130 vty_out(vty
, " Idle (Admin)");
11131 else if (CHECK_FLAG(
11133 PEER_STATUS_PREFIX_OVERFLOW
))
11134 vty_out(vty
, " Idle (PfxCt)");
11136 vty_out(vty
, " %12s",
11137 lookup_msg(bgp_status_msg
,
11138 peer
->status
, NULL
));
11140 vty_out(vty
, " %8u", 0);
11143 vty_out(vty
, " %s", peer
->desc
);
11145 vty_out(vty
, " N/A");
11146 vty_out(vty
, "\n");
11153 json_object_object_add(json
, "peers", json_peers
);
11154 json_object_int_add(json
, "failedPeers", failed_count
);
11155 json_object_int_add(json
, "totalPeers", count
);
11156 json_object_int_add(json
, "dynamicPeers", dn_count
);
11159 bgp_show_bestpath_json(bgp
, json
);
11161 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11162 json
, JSON_C_TO_STRING_PRETTY
));
11163 json_object_free(json
);
11166 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
11168 vty_out(vty
, "No %s neighbor is configured\n",
11169 get_afi_safi_str(afi
, safi
, false));
11173 vty_out(vty
, "* - dynamic neighbor\n");
11174 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11175 dn_count
, bgp
->dynamic_neighbors_limit
);
11179 return CMD_SUCCESS
;
11182 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11183 int safi
, bool show_failed
,
11184 bool show_established
, bool use_json
)
11187 int afi_wildcard
= (afi
== AFI_MAX
);
11188 int safi_wildcard
= (safi
== SAFI_MAX
);
11189 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11190 bool nbr_output
= false;
11192 if (use_json
&& is_wildcard
)
11193 vty_out(vty
, "{\n");
11195 afi
= 1; /* AFI_IP */
11196 while (afi
< AFI_MAX
) {
11198 safi
= 1; /* SAFI_UNICAST */
11199 while (safi
< SAFI_MAX
) {
11200 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11205 * So limit output to those afi/safi
11207 * actualy have something interesting in
11212 vty_out(vty
, ",\n");
11216 vty_out(vty
, "\"%s\":",
11217 get_afi_safi_str(afi
,
11221 vty_out(vty
, "\n%s Summary:\n",
11222 get_afi_safi_str(afi
,
11227 bgp_show_summary(vty
, bgp
, afi
, safi
,
11228 show_failed
, show_established
,
11232 if (!safi_wildcard
)
11240 if (use_json
&& is_wildcard
)
11241 vty_out(vty
, "}\n");
11242 else if (!nbr_output
) {
11244 vty_out(vty
, "{}\n");
11246 vty_out(vty
, "%% No BGP neighbors found\n");
11250 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11251 safi_t safi
, bool show_failed
,
11252 bool show_established
,
11255 struct listnode
*node
, *nnode
;
11258 bool nbr_output
= false;
11261 vty_out(vty
, "{\n");
11263 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11267 vty_out(vty
, ",\n");
11271 vty_out(vty
, "\"%s\":",
11272 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11276 vty_out(vty
, "\nInstance %s:\n",
11277 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11281 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
11282 show_established
, use_json
);
11286 vty_out(vty
, "}\n");
11287 else if (!nbr_output
)
11288 vty_out(vty
, "%% BGP instance not found\n");
11291 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11292 safi_t safi
, bool show_failed
, bool show_established
,
11298 if (strmatch(name
, "all")) {
11299 bgp_show_all_instances_summary_vty(
11300 vty
, afi
, safi
, show_failed
, show_established
,
11302 return CMD_SUCCESS
;
11304 bgp
= bgp_lookup_by_name(name
);
11308 vty_out(vty
, "{}\n");
11311 "%% BGP instance not found\n");
11312 return CMD_WARNING
;
11315 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
,
11316 show_failed
, show_established
,
11318 return CMD_SUCCESS
;
11322 bgp
= bgp_get_default();
11325 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
11326 show_established
, use_json
);
11329 vty_out(vty
, "{}\n");
11331 vty_out(vty
, "%% BGP instance not found\n");
11332 return CMD_WARNING
;
11335 return CMD_SUCCESS
;
11338 /* `show [ip] bgp summary' commands. */
11339 DEFPY (show_ip_bgp_summary
,
11340 show_ip_bgp_summary_cmd
,
11341 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] [all$all] summary [established|failed] [json$uj]",
11345 BGP_INSTANCE_HELP_STR
11347 BGP_SAFI_WITH_LABEL_HELP_STR
11348 "Display the entries for all address families\n"
11349 "Summary of BGP neighbor status\n"
11350 "Show only sessions in Established state\n"
11351 "Show only sessions not in Established state\n"
11355 afi_t afi
= AFI_MAX
;
11356 safi_t safi
= SAFI_MAX
;
11357 bool show_failed
= false;
11358 bool show_established
= false;
11362 /* show [ip] bgp */
11363 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11365 /* [<vrf> VIEWVRFNAME] */
11366 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11367 vrf
= argv
[idx
+ 1]->arg
;
11368 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11370 } else if (argv_find(argv
, argc
, "view", &idx
))
11371 /* [<view> VIEWVRFNAME] */
11372 vrf
= argv
[idx
+ 1]->arg
;
11373 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11374 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11375 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11378 if (argv_find(argv
, argc
, "failed", &idx
))
11379 show_failed
= true;
11380 if (argv_find(argv
, argc
, "established", &idx
))
11381 show_established
= true;
11383 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, show_failed
,
11384 show_established
, uj
);
11387 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11390 return get_afi_safi_json_str(afi
, safi
);
11392 return get_afi_safi_vty_str(afi
, safi
);
11396 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11397 afi_t afi
, safi_t safi
,
11398 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11399 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11400 bool use_json
, json_object
*json_pref
)
11403 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11404 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11406 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11407 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11408 json_object_string_add(json_pref
, "sendMode",
11409 "advertisedAndReceived");
11410 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11411 json_object_string_add(json_pref
, "sendMode",
11413 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11414 json_object_string_add(json_pref
, "sendMode",
11417 vty_out(vty
, " Send-mode: ");
11418 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11419 vty_out(vty
, "advertised");
11420 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11421 vty_out(vty
, "%sreceived",
11422 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11426 vty_out(vty
, "\n");
11431 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11432 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11434 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11435 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11436 json_object_string_add(json_pref
, "recvMode",
11437 "advertisedAndReceived");
11438 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11439 json_object_string_add(json_pref
, "recvMode",
11441 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11442 json_object_string_add(json_pref
, "recvMode",
11445 vty_out(vty
, " Receive-mode: ");
11446 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11447 vty_out(vty
, "advertised");
11448 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11449 vty_out(vty
, "%sreceived",
11450 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11454 vty_out(vty
, "\n");
11459 static void bgp_show_neighnor_graceful_restart_rbit(struct vty
*vty
,
11464 bool rbit_status
= false;
11467 vty_out(vty
, "\n R bit: ");
11469 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11470 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11471 && (p
->status
== Established
)) {
11473 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_BIT_RCV
))
11474 rbit_status
= true;
11476 rbit_status
= false;
11481 json_object_boolean_true_add(json
, "rBit");
11483 vty_out(vty
, "True\n");
11486 json_object_boolean_false_add(json
, "rBit");
11488 vty_out(vty
, "False\n");
11492 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11497 const char *mode
= "NotApplicable";
11500 vty_out(vty
, "\n Remote GR Mode: ");
11502 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11503 && (peer
->status
== Established
)) {
11505 if ((peer
->nsf_af_count
== 0)
11506 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11510 } else if (peer
->nsf_af_count
== 0
11511 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11515 } else if (peer
->nsf_af_count
!= 0
11516 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11523 json_object_string_add(json
, "remoteGrMode", mode
);
11525 vty_out(vty
, mode
, "\n");
11528 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11533 const char *mode
= "Invalid";
11536 vty_out(vty
, " Local GR Mode: ");
11538 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11540 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11542 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11544 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11545 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11547 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11549 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11556 json_object_string_add(json
, "localGrMode", mode
);
11558 vty_out(vty
, mode
, "\n");
11562 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11563 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11567 json_object
*json_afi_safi
= NULL
;
11568 json_object
*json_timer
= NULL
;
11569 json_object
*json_endofrib_status
= NULL
;
11570 bool eor_flag
= false;
11572 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11573 for (safi
= SAFI_UNICAST
; safi
<= SAFI_MPLS_VPN
; safi
++) {
11574 if (!peer
->afc
[afi
][safi
])
11577 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11578 || !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11582 json_afi_safi
= json_object_new_object();
11583 json_endofrib_status
= json_object_new_object();
11584 json_timer
= json_object_new_object();
11587 if (peer
->eor_stime
[afi
][safi
]
11588 >= peer
->pkt_stime
[afi
][safi
])
11594 vty_out(vty
, " %s:\n",
11595 get_afi_safi_str(afi
, safi
, false));
11597 vty_out(vty
, " F bit: ");
11600 if (peer
->nsf
[afi
][safi
]
11601 && CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11602 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11605 json_object_boolean_true_add(
11606 json_afi_safi
, "fBit");
11608 vty_out(vty
, "True\n");
11611 json_object_boolean_false_add(
11612 json_afi_safi
, "fBit");
11614 vty_out(vty
, "False\n");
11618 vty_out(vty
, " End-of-RIB sent: ");
11620 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11621 PEER_STATUS_EOR_SEND
)) {
11623 json_object_boolean_true_add(
11624 json_endofrib_status
,
11627 PRINT_EOR_JSON(eor_flag
);
11629 vty_out(vty
, "Yes\n");
11631 " End-of-RIB sent after update: ");
11633 PRINT_EOR(eor_flag
);
11637 json_object_boolean_false_add(
11638 json_endofrib_status
,
11640 json_object_boolean_false_add(
11641 json_endofrib_status
,
11642 "endOfRibSentAfterUpdate");
11644 vty_out(vty
, "No\n");
11646 " End-of-RIB sent after update: ");
11647 vty_out(vty
, "No\n");
11652 vty_out(vty
, " End-of-RIB received: ");
11654 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11655 PEER_STATUS_EOR_RECEIVED
)) {
11657 json_object_boolean_true_add(
11658 json_endofrib_status
,
11661 vty_out(vty
, "Yes\n");
11664 json_object_boolean_false_add(
11665 json_endofrib_status
,
11668 vty_out(vty
, "No\n");
11672 json_object_int_add(json_timer
,
11674 peer
->bgp
->stalepath_time
);
11676 if (peer
->t_gr_stale
!= NULL
) {
11677 json_object_int_add(
11679 "stalePathTimerRemaining",
11680 thread_timer_remain_second(
11681 peer
->t_gr_stale
));
11684 /* Display Configured Selection
11685 * Deferral only when when
11686 * Gr mode is enabled.
11688 if (CHECK_FLAG(peer
->flags
,
11689 PEER_FLAG_GRACEFUL_RESTART
)) {
11690 json_object_int_add(
11692 "selectionDeferralTimer",
11693 peer
->bgp
->stalepath_time
);
11696 if (peer
->bgp
->gr_info
[afi
][safi
]
11700 json_object_int_add(
11702 "selectionDeferralTimerRemaining",
11703 thread_timer_remain_second(
11707 .t_select_deferral
));
11710 vty_out(vty
, " Timers:\n");
11712 " Configured Stale Path Time(sec): %u\n",
11713 peer
->bgp
->stalepath_time
);
11715 if (peer
->t_gr_stale
!= NULL
)
11717 " Stale Path Remaining(sec): %ld\n",
11718 thread_timer_remain_second(
11719 peer
->t_gr_stale
));
11720 /* Display Configured Selection
11721 * Deferral only when when
11722 * Gr mode is enabled.
11724 if (CHECK_FLAG(peer
->flags
,
11725 PEER_FLAG_GRACEFUL_RESTART
))
11727 " Configured Selection Deferral Time(sec): %u\n",
11728 peer
->bgp
->select_defer_time
);
11730 if (peer
->bgp
->gr_info
[afi
][safi
]
11734 " Selection Deferral Time Remaining(sec): %ld\n",
11735 thread_timer_remain_second(
11739 .t_select_deferral
));
11742 json_object_object_add(json_afi_safi
,
11744 json_endofrib_status
);
11745 json_object_object_add(json_afi_safi
, "timers",
11747 json_object_object_add(
11748 json
, get_afi_safi_str(afi
, safi
, true),
11755 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
11761 json_object
*json_timer
= NULL
;
11763 json_timer
= json_object_new_object();
11765 json_object_int_add(json_timer
, "configuredRestartTimer",
11766 p
->bgp
->restart_time
);
11768 json_object_int_add(json_timer
, "receivedRestartTimer",
11771 if (p
->t_gr_restart
!= NULL
)
11772 json_object_int_add(
11773 json_timer
, "restartTimerRemaining",
11774 thread_timer_remain_second(p
->t_gr_restart
));
11776 json_object_object_add(json
, "timers", json_timer
);
11779 vty_out(vty
, " Timers:\n");
11780 vty_out(vty
, " Configured Restart Time(sec): %u\n",
11781 p
->bgp
->restart_time
);
11783 vty_out(vty
, " Received Restart Time(sec): %u\n",
11785 if (p
->t_gr_restart
!= NULL
)
11786 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11787 thread_timer_remain_second(p
->t_gr_restart
));
11788 if (p
->t_gr_restart
!= NULL
) {
11789 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11790 thread_timer_remain_second(p
->t_gr_restart
));
11795 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
11796 bool use_json
, json_object
*json
)
11798 char buf
[SU_ADDRSTRLEN
] = {0};
11799 char dn_flag
[2] = {0};
11800 /* '*' + v6 address of neighbor */
11801 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
11803 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11808 json_object_string_add(
11809 json
, "neighborAddr",
11810 BGP_PEER_SU_UNSPEC(p
)
11812 : sockunion2str(&p
->su
, buf
,
11815 vty_out(vty
, "BGP neighbor on %s: %s\n", p
->conf_if
,
11816 BGP_PEER_SU_UNSPEC(p
)
11818 : sockunion2str(&p
->su
, buf
,
11821 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
11825 json_object_string_add(json
, "neighborAddr",
11828 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
11831 /* more gr info in new format */
11832 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
11835 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
11836 safi_t safi
, bool use_json
,
11837 json_object
*json_neigh
)
11839 struct bgp_filter
*filter
;
11840 struct peer_af
*paf
;
11841 char orf_pfx_name
[BUFSIZ
];
11843 json_object
*json_af
= NULL
;
11844 json_object
*json_prefA
= NULL
;
11845 json_object
*json_prefB
= NULL
;
11846 json_object
*json_addr
= NULL
;
11847 json_object
*json_advmap
= NULL
;
11850 json_addr
= json_object_new_object();
11851 json_af
= json_object_new_object();
11852 filter
= &p
->filter
[afi
][safi
];
11854 if (peer_group_active(p
))
11855 json_object_string_add(json_addr
, "peerGroupMember",
11858 paf
= peer_af_find(p
, afi
, safi
);
11859 if (paf
&& PAF_SUBGRP(paf
)) {
11860 json_object_int_add(json_addr
, "updateGroupId",
11861 PAF_UPDGRP(paf
)->id
);
11862 json_object_int_add(json_addr
, "subGroupId",
11863 PAF_SUBGRP(paf
)->id
);
11864 json_object_int_add(json_addr
, "packetQueueLength",
11865 bpacket_queue_virtual_length(paf
));
11868 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11869 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11870 PEER_CAP_ORF_PREFIX_SM_RCV
)
11871 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11872 PEER_CAP_ORF_PREFIX_RM_ADV
)
11873 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11874 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11875 json_object_int_add(json_af
, "orfType",
11877 json_prefA
= json_object_new_object();
11878 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
11879 PEER_CAP_ORF_PREFIX_SM_ADV
,
11880 PEER_CAP_ORF_PREFIX_RM_ADV
,
11881 PEER_CAP_ORF_PREFIX_SM_RCV
,
11882 PEER_CAP_ORF_PREFIX_RM_RCV
,
11883 use_json
, json_prefA
);
11884 json_object_object_add(json_af
, "orfPrefixList",
11888 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11889 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11890 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11891 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11892 PEER_CAP_ORF_PREFIX_RM_ADV
)
11893 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11894 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
11895 json_object_int_add(json_af
, "orfOldType",
11896 ORF_TYPE_PREFIX_OLD
);
11897 json_prefB
= json_object_new_object();
11898 bgp_show_peer_afi_orf_cap(
11899 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
11900 PEER_CAP_ORF_PREFIX_RM_ADV
,
11901 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
11902 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
11904 json_object_object_add(json_af
, "orfOldPrefixList",
11908 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11909 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11910 PEER_CAP_ORF_PREFIX_SM_RCV
)
11911 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11912 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11913 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11914 PEER_CAP_ORF_PREFIX_RM_ADV
)
11915 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11916 PEER_CAP_ORF_PREFIX_RM_RCV
)
11917 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11918 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
11919 json_object_object_add(json_addr
, "afDependentCap",
11922 json_object_free(json_af
);
11924 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
11925 p
->host
, afi
, safi
);
11926 orf_pfx_count
= prefix_bgp_show_prefix_list(
11927 NULL
, afi
, orf_pfx_name
, use_json
);
11929 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11930 PEER_STATUS_ORF_PREFIX_SEND
)
11931 || orf_pfx_count
) {
11932 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11933 PEER_STATUS_ORF_PREFIX_SEND
))
11934 json_object_boolean_true_add(json_neigh
,
11937 json_object_int_add(json_addr
, "orfRecvCounter",
11940 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11941 PEER_STATUS_ORF_WAIT_REFRESH
))
11942 json_object_string_add(
11943 json_addr
, "orfFirstUpdate",
11944 "deferredUntilORFOrRouteRefreshRecvd");
11946 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11947 PEER_FLAG_REFLECTOR_CLIENT
))
11948 json_object_boolean_true_add(json_addr
,
11949 "routeReflectorClient");
11950 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11951 PEER_FLAG_RSERVER_CLIENT
))
11952 json_object_boolean_true_add(json_addr
,
11953 "routeServerClient");
11954 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
11955 json_object_boolean_true_add(json_addr
,
11956 "inboundSoftConfigPermit");
11958 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11959 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
11960 json_object_boolean_true_add(
11962 "privateAsNumsAllReplacedInUpdatesToNbr");
11963 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11964 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
11965 json_object_boolean_true_add(
11967 "privateAsNumsReplacedInUpdatesToNbr");
11968 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11969 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
11970 json_object_boolean_true_add(
11972 "privateAsNumsAllRemovedInUpdatesToNbr");
11973 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11974 PEER_FLAG_REMOVE_PRIVATE_AS
))
11975 json_object_boolean_true_add(
11977 "privateAsNumsRemovedInUpdatesToNbr");
11979 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
11980 json_object_boolean_true_add(
11982 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
11985 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
11986 json_object_string_add(json_addr
,
11987 "overrideASNsInOutboundUpdates",
11988 "ifAspathEqualRemoteAs");
11990 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
11991 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11992 PEER_FLAG_FORCE_NEXTHOP_SELF
))
11993 json_object_boolean_true_add(json_addr
,
11994 "routerAlwaysNextHop");
11995 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11996 PEER_FLAG_AS_PATH_UNCHANGED
))
11997 json_object_boolean_true_add(
11998 json_addr
, "unchangedAsPathPropogatedToNbr");
11999 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12000 PEER_FLAG_NEXTHOP_UNCHANGED
))
12001 json_object_boolean_true_add(
12002 json_addr
, "unchangedNextHopPropogatedToNbr");
12003 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12004 json_object_boolean_true_add(
12005 json_addr
, "unchangedMedPropogatedToNbr");
12006 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12007 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12008 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12009 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12010 PEER_FLAG_SEND_COMMUNITY
)
12011 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12012 PEER_FLAG_SEND_EXT_COMMUNITY
))
12013 json_object_string_add(json_addr
,
12014 "commAttriSentToNbr",
12015 "extendedAndStandard");
12016 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12017 PEER_FLAG_SEND_EXT_COMMUNITY
))
12018 json_object_string_add(json_addr
,
12019 "commAttriSentToNbr",
12022 json_object_string_add(json_addr
,
12023 "commAttriSentToNbr",
12026 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12027 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12028 if (p
->default_rmap
[afi
][safi
].name
)
12029 json_object_string_add(
12030 json_addr
, "defaultRouteMap",
12031 p
->default_rmap
[afi
][safi
].name
);
12033 if (paf
&& PAF_SUBGRP(paf
)
12034 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12035 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12036 json_object_boolean_true_add(json_addr
,
12039 json_object_boolean_true_add(json_addr
,
12043 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12044 if (is_evpn_enabled())
12045 json_object_boolean_true_add(
12046 json_addr
, "advertiseAllVnis");
12049 if (filter
->plist
[FILTER_IN
].name
12050 || filter
->dlist
[FILTER_IN
].name
12051 || filter
->aslist
[FILTER_IN
].name
12052 || filter
->map
[RMAP_IN
].name
)
12053 json_object_boolean_true_add(json_addr
,
12054 "inboundPathPolicyConfig");
12055 if (filter
->plist
[FILTER_OUT
].name
12056 || filter
->dlist
[FILTER_OUT
].name
12057 || filter
->aslist
[FILTER_OUT
].name
12058 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12059 json_object_boolean_true_add(
12060 json_addr
, "outboundPathPolicyConfig");
12063 if (filter
->plist
[FILTER_IN
].name
)
12064 json_object_string_add(json_addr
,
12065 "incomingUpdatePrefixFilterList",
12066 filter
->plist
[FILTER_IN
].name
);
12067 if (filter
->plist
[FILTER_OUT
].name
)
12068 json_object_string_add(json_addr
,
12069 "outgoingUpdatePrefixFilterList",
12070 filter
->plist
[FILTER_OUT
].name
);
12072 /* distribute-list */
12073 if (filter
->dlist
[FILTER_IN
].name
)
12074 json_object_string_add(
12075 json_addr
, "incomingUpdateNetworkFilterList",
12076 filter
->dlist
[FILTER_IN
].name
);
12077 if (filter
->dlist
[FILTER_OUT
].name
)
12078 json_object_string_add(
12079 json_addr
, "outgoingUpdateNetworkFilterList",
12080 filter
->dlist
[FILTER_OUT
].name
);
12083 if (filter
->aslist
[FILTER_IN
].name
)
12084 json_object_string_add(json_addr
,
12085 "incomingUpdateAsPathFilterList",
12086 filter
->aslist
[FILTER_IN
].name
);
12087 if (filter
->aslist
[FILTER_OUT
].name
)
12088 json_object_string_add(json_addr
,
12089 "outgoingUpdateAsPathFilterList",
12090 filter
->aslist
[FILTER_OUT
].name
);
12093 if (filter
->map
[RMAP_IN
].name
)
12094 json_object_string_add(
12095 json_addr
, "routeMapForIncomingAdvertisements",
12096 filter
->map
[RMAP_IN
].name
);
12097 if (filter
->map
[RMAP_OUT
].name
)
12098 json_object_string_add(
12099 json_addr
, "routeMapForOutgoingAdvertisements",
12100 filter
->map
[RMAP_OUT
].name
);
12102 /* ebgp-requires-policy (inbound) */
12103 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12104 && !bgp_inbound_policy_exists(p
, filter
))
12105 json_object_string_add(
12106 json_addr
, "inboundEbgpRequiresPolicy",
12107 "Inbound updates discarded due to missing policy");
12109 /* ebgp-requires-policy (outbound) */
12110 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12111 && (!bgp_outbound_policy_exists(p
, filter
)))
12112 json_object_string_add(
12113 json_addr
, "outboundEbgpRequiresPolicy",
12114 "Outbound updates discarded due to missing policy");
12116 /* unsuppress-map */
12117 if (filter
->usmap
.name
)
12118 json_object_string_add(json_addr
,
12119 "selectiveUnsuppressRouteMap",
12120 filter
->usmap
.name
);
12122 /* advertise-map */
12123 if (filter
->advmap
.aname
) {
12124 json_advmap
= json_object_new_object();
12125 json_object_string_add(json_advmap
, "condition",
12126 filter
->advmap
.condition
12129 json_object_string_add(json_advmap
, "conditionMap",
12130 filter
->advmap
.cname
);
12131 json_object_string_add(json_advmap
, "advertiseMap",
12132 filter
->advmap
.aname
);
12133 json_object_string_add(json_advmap
, "advertiseStatus",
12134 filter
->advmap
.update_type
12138 json_object_object_add(json_addr
, "advertiseMap",
12142 /* Receive prefix count */
12143 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12144 p
->pcount
[afi
][safi
]);
12145 if (paf
&& PAF_SUBGRP(paf
))
12146 json_object_int_add(json_addr
, "sentPrefixCounter",
12147 (PAF_SUBGRP(paf
))->scount
);
12149 /* Maximum prefix */
12150 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12151 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12152 p
->pmax_out
[afi
][safi
]);
12154 /* Maximum prefix */
12155 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12156 json_object_int_add(json_addr
, "prefixAllowedMax",
12157 p
->pmax
[afi
][safi
]);
12158 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12159 PEER_FLAG_MAX_PREFIX_WARNING
))
12160 json_object_boolean_true_add(
12161 json_addr
, "prefixAllowedMaxWarning");
12162 json_object_int_add(json_addr
,
12163 "prefixAllowedWarningThresh",
12164 p
->pmax_threshold
[afi
][safi
]);
12165 if (p
->pmax_restart
[afi
][safi
])
12166 json_object_int_add(
12168 "prefixAllowedRestartIntervalMsecs",
12169 p
->pmax_restart
[afi
][safi
] * 60000);
12171 json_object_object_add(json_neigh
,
12172 get_afi_safi_str(afi
, safi
, true),
12176 filter
= &p
->filter
[afi
][safi
];
12178 vty_out(vty
, " For address family: %s\n",
12179 get_afi_safi_str(afi
, safi
, false));
12181 if (peer_group_active(p
))
12182 vty_out(vty
, " %s peer-group member\n",
12185 paf
= peer_af_find(p
, afi
, safi
);
12186 if (paf
&& PAF_SUBGRP(paf
)) {
12187 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12188 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12189 vty_out(vty
, " Packet Queue length %d\n",
12190 bpacket_queue_virtual_length(paf
));
12192 vty_out(vty
, " Not part of any update group\n");
12194 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12195 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12196 PEER_CAP_ORF_PREFIX_SM_RCV
)
12197 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12198 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12199 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12200 PEER_CAP_ORF_PREFIX_RM_ADV
)
12201 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12202 PEER_CAP_ORF_PREFIX_RM_RCV
)
12203 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12204 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12205 vty_out(vty
, " AF-dependant capabilities:\n");
12207 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12208 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12209 PEER_CAP_ORF_PREFIX_SM_RCV
)
12210 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12211 PEER_CAP_ORF_PREFIX_RM_ADV
)
12212 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12213 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12215 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12217 bgp_show_peer_afi_orf_cap(
12218 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12219 PEER_CAP_ORF_PREFIX_RM_ADV
,
12220 PEER_CAP_ORF_PREFIX_SM_RCV
,
12221 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12223 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12224 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12225 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12226 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12227 PEER_CAP_ORF_PREFIX_RM_ADV
)
12228 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12229 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12231 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12232 ORF_TYPE_PREFIX_OLD
);
12233 bgp_show_peer_afi_orf_cap(
12234 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12235 PEER_CAP_ORF_PREFIX_RM_ADV
,
12236 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12237 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12240 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12241 p
->host
, afi
, safi
);
12242 orf_pfx_count
= prefix_bgp_show_prefix_list(
12243 NULL
, afi
, orf_pfx_name
, use_json
);
12245 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12246 PEER_STATUS_ORF_PREFIX_SEND
)
12247 || orf_pfx_count
) {
12248 vty_out(vty
, " Outbound Route Filter (ORF):");
12249 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12250 PEER_STATUS_ORF_PREFIX_SEND
))
12251 vty_out(vty
, " sent;");
12253 vty_out(vty
, " received (%d entries)",
12255 vty_out(vty
, "\n");
12257 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12258 PEER_STATUS_ORF_WAIT_REFRESH
))
12260 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12262 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12263 PEER_FLAG_REFLECTOR_CLIENT
))
12264 vty_out(vty
, " Route-Reflector Client\n");
12265 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12266 PEER_FLAG_RSERVER_CLIENT
))
12267 vty_out(vty
, " Route-Server Client\n");
12268 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12270 " Inbound soft reconfiguration allowed\n");
12272 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12273 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12275 " Private AS numbers (all) replaced in updates to this neighbor\n");
12276 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12277 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12279 " Private AS numbers replaced in updates to this neighbor\n");
12280 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12281 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12283 " Private AS numbers (all) removed in updates to this neighbor\n");
12284 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12285 PEER_FLAG_REMOVE_PRIVATE_AS
))
12287 " Private AS numbers removed in updates to this neighbor\n");
12289 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12290 vty_out(vty
, " %s\n",
12291 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12292 ->human_description
);
12294 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12296 " Override ASNs in outbound updates if aspath equals remote-as\n");
12298 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12299 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12300 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12301 vty_out(vty
, " NEXT_HOP is always this router\n");
12302 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12303 PEER_FLAG_AS_PATH_UNCHANGED
))
12305 " AS_PATH is propagated unchanged to this neighbor\n");
12306 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12307 PEER_FLAG_NEXTHOP_UNCHANGED
))
12309 " NEXT_HOP is propagated unchanged to this neighbor\n");
12310 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12312 " MED is propagated unchanged to this neighbor\n");
12313 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12314 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12315 PEER_FLAG_SEND_EXT_COMMUNITY
)
12316 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12317 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12319 " Community attribute sent to this neighbor");
12320 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12321 PEER_FLAG_SEND_COMMUNITY
)
12322 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12323 PEER_FLAG_SEND_EXT_COMMUNITY
)
12324 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12325 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12326 vty_out(vty
, "(all)\n");
12327 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12328 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12329 vty_out(vty
, "(large)\n");
12330 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12331 PEER_FLAG_SEND_EXT_COMMUNITY
))
12332 vty_out(vty
, "(extended)\n");
12334 vty_out(vty
, "(standard)\n");
12336 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12337 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12338 vty_out(vty
, " Default information originate,");
12340 if (p
->default_rmap
[afi
][safi
].name
)
12341 vty_out(vty
, " default route-map %s%s,",
12342 p
->default_rmap
[afi
][safi
].map
? "*"
12344 p
->default_rmap
[afi
][safi
].name
);
12345 if (paf
&& PAF_SUBGRP(paf
)
12346 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12347 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12348 vty_out(vty
, " default sent\n");
12350 vty_out(vty
, " default not sent\n");
12353 /* advertise-vni-all */
12354 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12355 if (is_evpn_enabled())
12356 vty_out(vty
, " advertise-all-vni\n");
12359 if (filter
->plist
[FILTER_IN
].name
12360 || filter
->dlist
[FILTER_IN
].name
12361 || filter
->aslist
[FILTER_IN
].name
12362 || filter
->map
[RMAP_IN
].name
)
12363 vty_out(vty
, " Inbound path policy configured\n");
12364 if (filter
->plist
[FILTER_OUT
].name
12365 || filter
->dlist
[FILTER_OUT
].name
12366 || filter
->aslist
[FILTER_OUT
].name
12367 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12368 vty_out(vty
, " Outbound path policy configured\n");
12371 if (filter
->plist
[FILTER_IN
].name
)
12373 " Incoming update prefix filter list is %s%s\n",
12374 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12375 filter
->plist
[FILTER_IN
].name
);
12376 if (filter
->plist
[FILTER_OUT
].name
)
12378 " Outgoing update prefix filter list is %s%s\n",
12379 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12380 filter
->plist
[FILTER_OUT
].name
);
12382 /* distribute-list */
12383 if (filter
->dlist
[FILTER_IN
].name
)
12385 " Incoming update network filter list is %s%s\n",
12386 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12387 filter
->dlist
[FILTER_IN
].name
);
12388 if (filter
->dlist
[FILTER_OUT
].name
)
12390 " Outgoing update network filter list is %s%s\n",
12391 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12392 filter
->dlist
[FILTER_OUT
].name
);
12395 if (filter
->aslist
[FILTER_IN
].name
)
12397 " Incoming update AS path filter list is %s%s\n",
12398 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12399 filter
->aslist
[FILTER_IN
].name
);
12400 if (filter
->aslist
[FILTER_OUT
].name
)
12402 " Outgoing update AS path filter list is %s%s\n",
12403 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12404 filter
->aslist
[FILTER_OUT
].name
);
12407 if (filter
->map
[RMAP_IN
].name
)
12409 " Route map for incoming advertisements is %s%s\n",
12410 filter
->map
[RMAP_IN
].map
? "*" : "",
12411 filter
->map
[RMAP_IN
].name
);
12412 if (filter
->map
[RMAP_OUT
].name
)
12414 " Route map for outgoing advertisements is %s%s\n",
12415 filter
->map
[RMAP_OUT
].map
? "*" : "",
12416 filter
->map
[RMAP_OUT
].name
);
12418 /* ebgp-requires-policy (inbound) */
12419 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12420 && !bgp_inbound_policy_exists(p
, filter
))
12422 " Inbound updates discarded due to missing policy\n");
12424 /* ebgp-requires-policy (outbound) */
12425 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12426 && !bgp_outbound_policy_exists(p
, filter
))
12428 " Outbound updates discarded due to missing policy\n");
12430 /* unsuppress-map */
12431 if (filter
->usmap
.name
)
12433 " Route map for selective unsuppress is %s%s\n",
12434 filter
->usmap
.map
? "*" : "",
12435 filter
->usmap
.name
);
12437 /* advertise-map */
12438 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12440 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12441 filter
->advmap
.condition
? "EXIST"
12443 filter
->advmap
.cmap
? "*" : "",
12444 filter
->advmap
.cname
,
12445 filter
->advmap
.amap
? "*" : "",
12446 filter
->advmap
.aname
,
12447 filter
->advmap
.update_type
== ADVERTISE
12451 /* Receive prefix count */
12452 vty_out(vty
, " %u accepted prefixes\n",
12453 p
->pcount
[afi
][safi
]);
12455 /* maximum-prefix-out */
12456 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12457 PEER_FLAG_MAX_PREFIX_OUT
))
12459 " Maximum allowed prefixes sent %u\n",
12460 p
->pmax_out
[afi
][safi
]);
12462 /* Maximum prefix */
12463 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12465 " Maximum prefixes allowed %u%s\n",
12466 p
->pmax
[afi
][safi
],
12467 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12468 PEER_FLAG_MAX_PREFIX_WARNING
)
12469 ? " (warning-only)"
12471 vty_out(vty
, " Threshold for warning message %d%%",
12472 p
->pmax_threshold
[afi
][safi
]);
12473 if (p
->pmax_restart
[afi
][safi
])
12474 vty_out(vty
, ", restart interval %d min",
12475 p
->pmax_restart
[afi
][safi
]);
12476 vty_out(vty
, "\n");
12479 vty_out(vty
, "\n");
12483 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12487 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
12488 char timebuf
[BGP_UPTIME_LEN
];
12494 json_object
*json_neigh
= NULL
;
12500 json_neigh
= json_object_new_object();
12502 memset(dn_flag
, '\0', sizeof(dn_flag
));
12503 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12507 if (p
->conf_if
) /* Configured interface name. */
12508 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
12509 BGP_PEER_SU_UNSPEC(p
)
12511 : sockunion2str(&p
->su
, buf
,
12513 else /* Configured IP address. */
12514 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12519 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12520 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12522 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12523 json_object_string_add(
12524 json_neigh
, "bgpNeighborAddr",
12525 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
12527 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12529 if (p
->change_local_as
)
12530 json_object_int_add(json_neigh
, "localAs",
12531 p
->change_local_as
);
12533 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12535 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12536 json_object_boolean_true_add(json_neigh
,
12537 "localAsNoPrepend");
12539 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12540 json_object_boolean_true_add(json_neigh
,
12541 "localAsReplaceAs");
12543 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12544 || (p
->as_type
== AS_INTERNAL
))
12545 vty_out(vty
, "remote AS %u, ", p
->as
);
12547 vty_out(vty
, "remote AS Unspecified, ");
12548 vty_out(vty
, "local AS %u%s%s, ",
12549 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12550 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12553 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12557 /* peer type internal or confed-internal */
12558 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12560 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12561 json_object_boolean_true_add(
12562 json_neigh
, "nbrConfedInternalLink");
12564 json_object_boolean_true_add(json_neigh
,
12565 "nbrInternalLink");
12567 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12568 vty_out(vty
, "confed-internal link\n");
12570 vty_out(vty
, "internal link\n");
12572 /* peer type external or confed-external */
12573 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12575 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12576 json_object_boolean_true_add(
12577 json_neigh
, "nbrConfedExternalLink");
12579 json_object_boolean_true_add(json_neigh
,
12580 "nbrExternalLink");
12582 if (bgp_confederation_peers_check(bgp
, p
->as
))
12583 vty_out(vty
, "confed-external link\n");
12585 vty_out(vty
, "external link\n");
12589 json_object_boolean_true_add(json_neigh
,
12590 "nbrUnspecifiedLink");
12592 vty_out(vty
, "unspecified link\n");
12598 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12600 vty_out(vty
, " Description: %s\n", p
->desc
);
12606 json_object_string_add(json_neigh
, "hostname",
12610 json_object_string_add(json_neigh
, "domainname",
12613 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12614 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12617 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12624 json_object_string_add(json_neigh
, "peerGroup",
12628 struct prefix prefix
, *range
= NULL
;
12630 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12631 range
= peer_group_lookup_dynamic_neighbor_range(
12632 p
->group
, &prefix
);
12635 prefix2str(range
, buf1
, sizeof(buf1
));
12636 json_object_string_add(
12638 "peerSubnetRangeGroup", buf1
);
12643 " Member of peer-group %s for session parameters\n",
12647 struct prefix prefix
, *range
= NULL
;
12649 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12650 range
= peer_group_lookup_dynamic_neighbor_range(
12651 p
->group
, &prefix
);
12655 " Belongs to the subnet range group: %pFX\n",
12663 /* Administrative shutdown. */
12664 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12665 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12666 json_object_boolean_true_add(json_neigh
,
12670 json_object_int_add(json_neigh
, "bgpVersion", 4);
12671 json_object_string_add(
12672 json_neigh
, "remoteRouterId",
12673 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12674 json_object_string_add(
12675 json_neigh
, "localRouterId",
12676 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12679 /* Confederation */
12680 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12681 && bgp_confederation_peers_check(bgp
, p
->as
))
12682 json_object_boolean_true_add(json_neigh
,
12686 json_object_string_add(
12687 json_neigh
, "bgpState",
12688 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12690 if (p
->status
== Established
) {
12693 uptime
= bgp_clock();
12694 uptime
-= p
->uptime
;
12695 epoch_tbuf
= time(NULL
) - uptime
;
12697 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
12699 json_object_string_add(json_neigh
, "bgpTimerUpString",
12700 peer_uptime(p
->uptime
, timebuf
,
12703 json_object_int_add(json_neigh
,
12704 "bgpTimerUpEstablishedEpoch",
12708 else if (p
->status
== Active
) {
12709 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12710 json_object_string_add(json_neigh
, "bgpStateIs",
12712 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12713 json_object_string_add(json_neigh
, "bgpStateIs",
12721 uptime
= bgp_clock();
12722 uptime
-= p
->readtime
;
12723 gmtime_r(&uptime
, &tm
);
12725 json_object_int_add(json_neigh
, "bgpTimerLastRead",
12726 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12727 + (tm
.tm_hour
* 3600000));
12729 uptime
= bgp_clock();
12730 uptime
-= p
->last_write
;
12731 gmtime_r(&uptime
, &tm
);
12733 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
12734 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12735 + (tm
.tm_hour
* 3600000));
12737 uptime
= bgp_clock();
12738 uptime
-= p
->update_time
;
12739 gmtime_r(&uptime
, &tm
);
12741 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
12742 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12743 + (tm
.tm_hour
* 3600000));
12745 /* Configured timer values. */
12746 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
12747 p
->v_holdtime
* 1000);
12748 json_object_int_add(json_neigh
,
12749 "bgpTimerKeepAliveIntervalMsecs",
12750 p
->v_keepalive
* 1000);
12751 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
12752 json_object_int_add(json_neigh
,
12753 "bgpTimerDelayOpenTimeMsecs",
12754 p
->v_delayopen
* 1000);
12757 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12758 json_object_int_add(json_neigh
,
12759 "bgpTimerConfiguredHoldTimeMsecs",
12760 p
->holdtime
* 1000);
12761 json_object_int_add(
12763 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12764 p
->keepalive
* 1000);
12765 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12766 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12767 json_object_int_add(json_neigh
,
12768 "bgpTimerConfiguredHoldTimeMsecs",
12769 bgp
->default_holdtime
);
12770 json_object_int_add(
12772 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12773 bgp
->default_keepalive
);
12776 /* Administrative shutdown. */
12777 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12778 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12779 vty_out(vty
, " Administratively shut down\n");
12782 vty_out(vty
, " BGP version 4");
12783 vty_out(vty
, ", remote router ID %s",
12784 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12785 vty_out(vty
, ", local router ID %s\n",
12786 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12789 /* Confederation */
12790 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12791 && bgp_confederation_peers_check(bgp
, p
->as
))
12793 " Neighbor under common administration\n");
12796 vty_out(vty
, " BGP state = %s",
12797 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12799 if (p
->status
== Established
)
12800 vty_out(vty
, ", up for %8s",
12801 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
12804 else if (p
->status
== Active
) {
12805 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12806 vty_out(vty
, " (passive)");
12807 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12808 vty_out(vty
, " (NSF passive)");
12810 vty_out(vty
, "\n");
12813 vty_out(vty
, " Last read %s",
12814 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
12816 vty_out(vty
, ", Last write %s\n",
12817 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
12820 /* Configured timer values. */
12822 " Hold time is %d, keepalive interval is %d seconds\n",
12823 p
->v_holdtime
, p
->v_keepalive
);
12824 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12825 vty_out(vty
, " Configured hold time is %d",
12827 vty_out(vty
, ", keepalive interval is %d seconds\n",
12829 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12830 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12831 vty_out(vty
, " Configured hold time is %d",
12832 bgp
->default_holdtime
);
12833 vty_out(vty
, ", keepalive interval is %d seconds\n",
12834 bgp
->default_keepalive
);
12836 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
12838 " Configured DelayOpenTime is %d seconds\n",
12842 if (p
->status
== Established
) {
12843 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
12844 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
12845 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
12846 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
12847 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
12848 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
12849 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
12850 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
12851 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
12852 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
12853 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
12854 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
12855 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
12856 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
12857 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
12858 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
12859 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
12860 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
12861 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
12862 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
12864 json_object
*json_cap
= NULL
;
12866 json_cap
= json_object_new_object();
12869 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
12870 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
12871 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
12872 && CHECK_FLAG(p
->cap
,
12874 json_object_string_add(
12875 json_cap
, "4byteAs",
12876 "advertisedAndReceived");
12877 else if (CHECK_FLAG(p
->cap
,
12879 json_object_string_add(
12880 json_cap
, "4byteAs",
12882 else if (CHECK_FLAG(p
->cap
,
12884 json_object_string_add(
12885 json_cap
, "4byteAs",
12890 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
12891 || CHECK_FLAG(p
->cap
,
12892 PEER_CAP_ADDPATH_ADV
)) {
12893 json_object
*json_add
= NULL
;
12894 const char *print_store
;
12896 json_add
= json_object_new_object();
12898 FOREACH_AFI_SAFI (afi
, safi
) {
12899 json_object
*json_sub
= NULL
;
12901 json_object_new_object();
12902 print_store
= get_afi_safi_str(
12908 PEER_CAP_ADDPATH_AF_TX_ADV
)
12912 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
12917 PEER_CAP_ADDPATH_AF_TX_ADV
)
12922 PEER_CAP_ADDPATH_AF_TX_RCV
))
12923 json_object_boolean_true_add(
12925 "txAdvertisedAndReceived");
12931 PEER_CAP_ADDPATH_AF_TX_ADV
))
12932 json_object_boolean_true_add(
12940 PEER_CAP_ADDPATH_AF_TX_RCV
))
12941 json_object_boolean_true_add(
12949 PEER_CAP_ADDPATH_AF_RX_ADV
)
12953 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
12958 PEER_CAP_ADDPATH_AF_RX_ADV
)
12963 PEER_CAP_ADDPATH_AF_RX_RCV
))
12964 json_object_boolean_true_add(
12966 "rxAdvertisedAndReceived");
12972 PEER_CAP_ADDPATH_AF_RX_ADV
))
12973 json_object_boolean_true_add(
12981 PEER_CAP_ADDPATH_AF_RX_RCV
))
12982 json_object_boolean_true_add(
12990 PEER_CAP_ADDPATH_AF_TX_ADV
)
12994 PEER_CAP_ADDPATH_AF_TX_RCV
)
12998 PEER_CAP_ADDPATH_AF_RX_ADV
)
13002 PEER_CAP_ADDPATH_AF_RX_RCV
))
13003 json_object_object_add(
13012 json_object_object_add(
13013 json_cap
, "addPath", json_add
);
13017 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
13018 || CHECK_FLAG(p
->cap
,
13019 PEER_CAP_DYNAMIC_ADV
)) {
13020 if (CHECK_FLAG(p
->cap
,
13021 PEER_CAP_DYNAMIC_ADV
)
13022 && CHECK_FLAG(p
->cap
,
13023 PEER_CAP_DYNAMIC_RCV
))
13024 json_object_string_add(
13025 json_cap
, "dynamic",
13026 "advertisedAndReceived");
13027 else if (CHECK_FLAG(
13029 PEER_CAP_DYNAMIC_ADV
))
13030 json_object_string_add(
13031 json_cap
, "dynamic",
13033 else if (CHECK_FLAG(
13035 PEER_CAP_DYNAMIC_RCV
))
13036 json_object_string_add(
13037 json_cap
, "dynamic",
13041 /* Extended nexthop */
13042 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
13043 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13044 json_object
*json_nxt
= NULL
;
13045 const char *print_store
;
13048 if (CHECK_FLAG(p
->cap
,
13050 && CHECK_FLAG(p
->cap
,
13051 PEER_CAP_ENHE_RCV
))
13052 json_object_string_add(
13055 "advertisedAndReceived");
13056 else if (CHECK_FLAG(p
->cap
,
13057 PEER_CAP_ENHE_ADV
))
13058 json_object_string_add(
13062 else if (CHECK_FLAG(p
->cap
,
13063 PEER_CAP_ENHE_RCV
))
13064 json_object_string_add(
13069 if (CHECK_FLAG(p
->cap
,
13070 PEER_CAP_ENHE_RCV
)) {
13072 json_object_new_object();
13074 for (safi
= SAFI_UNICAST
;
13075 safi
< SAFI_MAX
; safi
++) {
13080 PEER_CAP_ENHE_AF_RCV
)) {
13081 print_store
= get_afi_safi_str(
13084 json_object_string_add(
13087 "recieved"); /* misspelled for compatibility */
13090 json_object_object_add(
13092 "extendedNexthopFamililesByPeer",
13097 /* Route Refresh */
13098 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
13099 || CHECK_FLAG(p
->cap
,
13100 PEER_CAP_REFRESH_NEW_RCV
)
13101 || CHECK_FLAG(p
->cap
,
13102 PEER_CAP_REFRESH_OLD_RCV
)) {
13103 if (CHECK_FLAG(p
->cap
,
13104 PEER_CAP_REFRESH_ADV
)
13107 PEER_CAP_REFRESH_NEW_RCV
)
13110 PEER_CAP_REFRESH_OLD_RCV
))) {
13113 PEER_CAP_REFRESH_OLD_RCV
)
13116 PEER_CAP_REFRESH_NEW_RCV
))
13117 json_object_string_add(
13120 "advertisedAndReceivedOldNew");
13124 PEER_CAP_REFRESH_OLD_RCV
))
13125 json_object_string_add(
13128 "advertisedAndReceivedOld");
13130 json_object_string_add(
13133 "advertisedAndReceivedNew");
13138 PEER_CAP_REFRESH_ADV
))
13139 json_object_string_add(
13146 PEER_CAP_REFRESH_NEW_RCV
)
13149 PEER_CAP_REFRESH_OLD_RCV
))
13150 json_object_string_add(
13156 /* Multiprotocol Extensions */
13157 json_object
*json_multi
= NULL
;
13158 json_multi
= json_object_new_object();
13160 FOREACH_AFI_SAFI (afi
, safi
) {
13161 if (p
->afc_adv
[afi
][safi
]
13162 || p
->afc_recv
[afi
][safi
]) {
13163 json_object
*json_exten
= NULL
;
13165 json_object_new_object();
13167 if (p
->afc_adv
[afi
][safi
]
13168 && p
->afc_recv
[afi
][safi
])
13169 json_object_boolean_true_add(
13171 "advertisedAndReceived");
13172 else if (p
->afc_adv
[afi
][safi
])
13173 json_object_boolean_true_add(
13176 else if (p
->afc_recv
[afi
][safi
])
13177 json_object_boolean_true_add(
13181 json_object_object_add(
13183 get_afi_safi_str(afi
,
13189 json_object_object_add(
13190 json_cap
, "multiprotocolExtensions",
13193 /* Hostname capabilities */
13194 json_object
*json_hname
= NULL
;
13196 json_hname
= json_object_new_object();
13198 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13199 json_object_string_add(
13200 json_hname
, "advHostName",
13201 bgp
->peer_self
->hostname
13205 json_object_string_add(
13206 json_hname
, "advDomainName",
13207 bgp
->peer_self
->domainname
13214 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13215 json_object_string_add(
13216 json_hname
, "rcvHostName",
13217 p
->hostname
? p
->hostname
13219 json_object_string_add(
13220 json_hname
, "rcvDomainName",
13221 p
->domainname
? p
->domainname
13225 json_object_object_add(json_cap
, "hostName",
13228 /* Gracefull Restart */
13229 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
13230 || CHECK_FLAG(p
->cap
,
13231 PEER_CAP_RESTART_ADV
)) {
13232 if (CHECK_FLAG(p
->cap
,
13233 PEER_CAP_RESTART_ADV
)
13234 && CHECK_FLAG(p
->cap
,
13235 PEER_CAP_RESTART_RCV
))
13236 json_object_string_add(
13239 "advertisedAndReceived");
13240 else if (CHECK_FLAG(
13242 PEER_CAP_RESTART_ADV
))
13243 json_object_string_add(
13245 "gracefulRestartCapability",
13247 else if (CHECK_FLAG(
13249 PEER_CAP_RESTART_RCV
))
13250 json_object_string_add(
13252 "gracefulRestartCapability",
13255 if (CHECK_FLAG(p
->cap
,
13256 PEER_CAP_RESTART_RCV
)) {
13257 int restart_af_count
= 0;
13258 json_object
*json_restart
=
13261 json_object_new_object();
13263 json_object_int_add(
13265 "gracefulRestartRemoteTimerMsecs",
13266 p
->v_gr_restart
* 1000);
13268 FOREACH_AFI_SAFI (afi
, safi
) {
13273 PEER_CAP_RESTART_AF_RCV
)) {
13278 json_object_new_object();
13284 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13285 json_object_boolean_true_add(
13288 restart_af_count
++;
13289 json_object_object_add(
13298 if (!restart_af_count
) {
13299 json_object_string_add(
13301 "addressFamiliesByPeer",
13306 json_object_object_add(
13308 "addressFamiliesByPeer",
13312 json_object_object_add(json_neigh
,
13313 "neighborCapabilities",
13316 vty_out(vty
, " Neighbor capabilities:\n");
13319 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
13320 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13321 vty_out(vty
, " 4 Byte AS:");
13322 if (CHECK_FLAG(p
->cap
,
13324 vty_out(vty
, " advertised");
13325 if (CHECK_FLAG(p
->cap
,
13327 vty_out(vty
, " %sreceived",
13333 vty_out(vty
, "\n");
13337 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
13338 || CHECK_FLAG(p
->cap
,
13339 PEER_CAP_ADDPATH_ADV
)) {
13340 vty_out(vty
, " AddPath:\n");
13342 FOREACH_AFI_SAFI (afi
, safi
) {
13346 PEER_CAP_ADDPATH_AF_TX_ADV
)
13350 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13362 PEER_CAP_ADDPATH_AF_TX_ADV
))
13374 PEER_CAP_ADDPATH_AF_TX_RCV
))
13381 PEER_CAP_ADDPATH_AF_TX_ADV
)
13385 vty_out(vty
, "\n");
13391 PEER_CAP_ADDPATH_AF_RX_ADV
)
13395 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13407 PEER_CAP_ADDPATH_AF_RX_ADV
))
13419 PEER_CAP_ADDPATH_AF_RX_RCV
))
13426 PEER_CAP_ADDPATH_AF_RX_ADV
)
13430 vty_out(vty
, "\n");
13436 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
13437 || CHECK_FLAG(p
->cap
,
13438 PEER_CAP_DYNAMIC_ADV
)) {
13439 vty_out(vty
, " Dynamic:");
13440 if (CHECK_FLAG(p
->cap
,
13441 PEER_CAP_DYNAMIC_ADV
))
13442 vty_out(vty
, " advertised");
13443 if (CHECK_FLAG(p
->cap
,
13444 PEER_CAP_DYNAMIC_RCV
))
13445 vty_out(vty
, " %sreceived",
13448 PEER_CAP_DYNAMIC_ADV
)
13451 vty_out(vty
, "\n");
13454 /* Extended nexthop */
13455 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
13456 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13457 vty_out(vty
, " Extended nexthop:");
13458 if (CHECK_FLAG(p
->cap
,
13459 PEER_CAP_ENHE_ADV
))
13460 vty_out(vty
, " advertised");
13461 if (CHECK_FLAG(p
->cap
,
13462 PEER_CAP_ENHE_RCV
))
13463 vty_out(vty
, " %sreceived",
13469 vty_out(vty
, "\n");
13471 if (CHECK_FLAG(p
->cap
,
13472 PEER_CAP_ENHE_RCV
)) {
13474 " Address families by peer:\n ");
13475 for (safi
= SAFI_UNICAST
;
13476 safi
< SAFI_MAX
; safi
++)
13481 PEER_CAP_ENHE_AF_RCV
))
13491 /* Route Refresh */
13492 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
13493 || CHECK_FLAG(p
->cap
,
13494 PEER_CAP_REFRESH_NEW_RCV
)
13495 || CHECK_FLAG(p
->cap
,
13496 PEER_CAP_REFRESH_OLD_RCV
)) {
13497 vty_out(vty
, " Route refresh:");
13498 if (CHECK_FLAG(p
->cap
,
13499 PEER_CAP_REFRESH_ADV
))
13500 vty_out(vty
, " advertised");
13501 if (CHECK_FLAG(p
->cap
,
13502 PEER_CAP_REFRESH_NEW_RCV
)
13505 PEER_CAP_REFRESH_OLD_RCV
))
13506 vty_out(vty
, " %sreceived(%s)",
13509 PEER_CAP_REFRESH_ADV
)
13514 PEER_CAP_REFRESH_OLD_RCV
)
13517 PEER_CAP_REFRESH_NEW_RCV
))
13521 PEER_CAP_REFRESH_OLD_RCV
)
13525 vty_out(vty
, "\n");
13528 /* Multiprotocol Extensions */
13529 FOREACH_AFI_SAFI (afi
, safi
)
13530 if (p
->afc_adv
[afi
][safi
]
13531 || p
->afc_recv
[afi
][safi
]) {
13533 " Address Family %s:",
13538 if (p
->afc_adv
[afi
][safi
])
13541 if (p
->afc_recv
[afi
][safi
])
13548 vty_out(vty
, "\n");
13551 /* Hostname capability */
13552 vty_out(vty
, " Hostname Capability:");
13554 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13556 " advertised (name: %s,domain name: %s)",
13557 bgp
->peer_self
->hostname
13561 bgp
->peer_self
->domainname
13566 vty_out(vty
, " not advertised");
13569 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13571 " received (name: %s,domain name: %s)",
13572 p
->hostname
? p
->hostname
13574 p
->domainname
? p
->domainname
13577 vty_out(vty
, " not received");
13580 vty_out(vty
, "\n");
13582 /* Graceful Restart */
13583 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
13584 || CHECK_FLAG(p
->cap
,
13585 PEER_CAP_RESTART_ADV
)) {
13587 " Graceful Restart Capability:");
13588 if (CHECK_FLAG(p
->cap
,
13589 PEER_CAP_RESTART_ADV
))
13590 vty_out(vty
, " advertised");
13591 if (CHECK_FLAG(p
->cap
,
13592 PEER_CAP_RESTART_RCV
))
13593 vty_out(vty
, " %sreceived",
13596 PEER_CAP_RESTART_ADV
)
13599 vty_out(vty
, "\n");
13601 if (CHECK_FLAG(p
->cap
,
13602 PEER_CAP_RESTART_RCV
)) {
13603 int restart_af_count
= 0;
13606 " Remote Restart timer is %d seconds\n",
13609 " Address families by peer:\n ");
13611 FOREACH_AFI_SAFI (afi
, safi
)
13616 PEER_CAP_RESTART_AF_RCV
)) {
13630 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13632 : "not preserved");
13633 restart_af_count
++;
13635 if (!restart_af_count
)
13636 vty_out(vty
, "none");
13637 vty_out(vty
, "\n");
13639 } /* Gracefull Restart */
13644 /* graceful restart information */
13645 json_object
*json_grace
= NULL
;
13646 json_object
*json_grace_send
= NULL
;
13647 json_object
*json_grace_recv
= NULL
;
13648 int eor_send_af_count
= 0;
13649 int eor_receive_af_count
= 0;
13652 json_grace
= json_object_new_object();
13653 json_grace_send
= json_object_new_object();
13654 json_grace_recv
= json_object_new_object();
13656 if ((p
->status
== Established
)
13657 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13658 FOREACH_AFI_SAFI (afi
, safi
) {
13659 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13660 PEER_STATUS_EOR_SEND
)) {
13661 json_object_boolean_true_add(
13663 get_afi_safi_str(afi
,
13666 eor_send_af_count
++;
13669 FOREACH_AFI_SAFI (afi
, safi
) {
13671 p
->af_sflags
[afi
][safi
],
13672 PEER_STATUS_EOR_RECEIVED
)) {
13673 json_object_boolean_true_add(
13675 get_afi_safi_str(afi
,
13678 eor_receive_af_count
++;
13682 json_object_object_add(json_grace
, "endOfRibSend",
13684 json_object_object_add(json_grace
, "endOfRibRecv",
13688 if (p
->t_gr_restart
)
13689 json_object_int_add(json_grace
,
13690 "gracefulRestartTimerMsecs",
13691 thread_timer_remain_second(
13696 json_object_int_add(
13698 "gracefulStalepathTimerMsecs",
13699 thread_timer_remain_second(
13702 /* more gr info in new format */
13703 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
,
13705 json_object_object_add(
13706 json_neigh
, "gracefulRestartInfo", json_grace
);
13708 vty_out(vty
, " Graceful restart information:\n");
13709 if ((p
->status
== Established
)
13710 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13712 vty_out(vty
, " End-of-RIB send: ");
13713 FOREACH_AFI_SAFI (afi
, safi
) {
13714 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13715 PEER_STATUS_EOR_SEND
)) {
13716 vty_out(vty
, "%s%s",
13717 eor_send_af_count
? ", "
13722 eor_send_af_count
++;
13725 vty_out(vty
, "\n");
13726 vty_out(vty
, " End-of-RIB received: ");
13727 FOREACH_AFI_SAFI (afi
, safi
) {
13729 p
->af_sflags
[afi
][safi
],
13730 PEER_STATUS_EOR_RECEIVED
)) {
13731 vty_out(vty
, "%s%s",
13732 eor_receive_af_count
13735 get_afi_safi_str(afi
,
13738 eor_receive_af_count
++;
13741 vty_out(vty
, "\n");
13744 if (p
->t_gr_restart
)
13746 " The remaining time of restart timer is %ld\n",
13747 thread_timer_remain_second(
13752 " The remaining time of stalepath timer is %ld\n",
13753 thread_timer_remain_second(
13756 /* more gr info in new format */
13757 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
13761 json_object
*json_stat
= NULL
;
13762 json_stat
= json_object_new_object();
13763 /* Packet counts. */
13765 atomic_size_t outq_count
, inq_count
;
13766 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13767 memory_order_relaxed
);
13768 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13769 memory_order_relaxed
);
13771 json_object_int_add(json_stat
, "depthInq",
13772 (unsigned long)inq_count
);
13773 json_object_int_add(json_stat
, "depthOutq",
13774 (unsigned long)outq_count
);
13775 json_object_int_add(json_stat
, "opensSent",
13776 atomic_load_explicit(&p
->open_out
,
13777 memory_order_relaxed
));
13778 json_object_int_add(json_stat
, "opensRecv",
13779 atomic_load_explicit(&p
->open_in
,
13780 memory_order_relaxed
));
13781 json_object_int_add(json_stat
, "notificationsSent",
13782 atomic_load_explicit(&p
->notify_out
,
13783 memory_order_relaxed
));
13784 json_object_int_add(json_stat
, "notificationsRecv",
13785 atomic_load_explicit(&p
->notify_in
,
13786 memory_order_relaxed
));
13787 json_object_int_add(json_stat
, "updatesSent",
13788 atomic_load_explicit(&p
->update_out
,
13789 memory_order_relaxed
));
13790 json_object_int_add(json_stat
, "updatesRecv",
13791 atomic_load_explicit(&p
->update_in
,
13792 memory_order_relaxed
));
13793 json_object_int_add(json_stat
, "keepalivesSent",
13794 atomic_load_explicit(&p
->keepalive_out
,
13795 memory_order_relaxed
));
13796 json_object_int_add(json_stat
, "keepalivesRecv",
13797 atomic_load_explicit(&p
->keepalive_in
,
13798 memory_order_relaxed
));
13799 json_object_int_add(json_stat
, "routeRefreshSent",
13800 atomic_load_explicit(&p
->refresh_out
,
13801 memory_order_relaxed
));
13802 json_object_int_add(json_stat
, "routeRefreshRecv",
13803 atomic_load_explicit(&p
->refresh_in
,
13804 memory_order_relaxed
));
13805 json_object_int_add(json_stat
, "capabilitySent",
13806 atomic_load_explicit(&p
->dynamic_cap_out
,
13807 memory_order_relaxed
));
13808 json_object_int_add(json_stat
, "capabilityRecv",
13809 atomic_load_explicit(&p
->dynamic_cap_in
,
13810 memory_order_relaxed
));
13811 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
13812 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
13813 json_object_object_add(json_neigh
, "messageStats", json_stat
);
13815 atomic_size_t outq_count
, inq_count
;
13816 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13817 memory_order_relaxed
);
13818 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13819 memory_order_relaxed
);
13821 /* Packet counts. */
13822 vty_out(vty
, " Message statistics:\n");
13823 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
13824 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
13825 vty_out(vty
, " Sent Rcvd\n");
13826 vty_out(vty
, " Opens: %10d %10d\n",
13827 atomic_load_explicit(&p
->open_out
,
13828 memory_order_relaxed
),
13829 atomic_load_explicit(&p
->open_in
,
13830 memory_order_relaxed
));
13831 vty_out(vty
, " Notifications: %10d %10d\n",
13832 atomic_load_explicit(&p
->notify_out
,
13833 memory_order_relaxed
),
13834 atomic_load_explicit(&p
->notify_in
,
13835 memory_order_relaxed
));
13836 vty_out(vty
, " Updates: %10d %10d\n",
13837 atomic_load_explicit(&p
->update_out
,
13838 memory_order_relaxed
),
13839 atomic_load_explicit(&p
->update_in
,
13840 memory_order_relaxed
));
13841 vty_out(vty
, " Keepalives: %10d %10d\n",
13842 atomic_load_explicit(&p
->keepalive_out
,
13843 memory_order_relaxed
),
13844 atomic_load_explicit(&p
->keepalive_in
,
13845 memory_order_relaxed
));
13846 vty_out(vty
, " Route Refresh: %10d %10d\n",
13847 atomic_load_explicit(&p
->refresh_out
,
13848 memory_order_relaxed
),
13849 atomic_load_explicit(&p
->refresh_in
,
13850 memory_order_relaxed
));
13851 vty_out(vty
, " Capability: %10d %10d\n",
13852 atomic_load_explicit(&p
->dynamic_cap_out
,
13853 memory_order_relaxed
),
13854 atomic_load_explicit(&p
->dynamic_cap_in
,
13855 memory_order_relaxed
));
13856 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
13861 /* advertisement-interval */
13862 json_object_int_add(json_neigh
,
13863 "minBtwnAdvertisementRunsTimerMsecs",
13864 p
->v_routeadv
* 1000);
13866 /* Update-source. */
13867 if (p
->update_if
|| p
->update_source
) {
13869 json_object_string_add(json_neigh
,
13872 else if (p
->update_source
)
13873 json_object_string_add(
13874 json_neigh
, "updateSource",
13875 sockunion2str(p
->update_source
, buf1
,
13879 /* advertisement-interval */
13881 " Minimum time between advertisement runs is %d seconds\n",
13884 /* Update-source. */
13885 if (p
->update_if
|| p
->update_source
) {
13886 vty_out(vty
, " Update source is ");
13888 vty_out(vty
, "%s", p
->update_if
);
13889 else if (p
->update_source
)
13891 sockunion2str(p
->update_source
, buf1
,
13893 vty_out(vty
, "\n");
13896 vty_out(vty
, "\n");
13899 /* Address Family Information */
13900 json_object
*json_hold
= NULL
;
13903 json_hold
= json_object_new_object();
13905 FOREACH_AFI_SAFI (afi
, safi
)
13906 if (p
->afc
[afi
][safi
])
13907 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
13911 json_object_object_add(json_neigh
, "addressFamilyInfo",
13913 json_object_int_add(json_neigh
, "connectionsEstablished",
13915 json_object_int_add(json_neigh
, "connectionsDropped",
13918 vty_out(vty
, " Connections established %d; dropped %d\n",
13919 p
->established
, p
->dropped
);
13921 if (!p
->last_reset
) {
13923 json_object_string_add(json_neigh
, "lastReset",
13926 vty_out(vty
, " Last reset never\n");
13932 uptime
= bgp_clock();
13933 uptime
-= p
->resettime
;
13934 gmtime_r(&uptime
, &tm
);
13936 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
13938 + (tm
.tm_min
* 60000)
13939 + (tm
.tm_hour
* 3600000));
13940 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
13942 vty_out(vty
, " Last reset %s, ",
13943 peer_uptime(p
->resettime
, timebuf
,
13944 BGP_UPTIME_LEN
, 0, NULL
));
13946 bgp_show_peer_reset(vty
, p
, NULL
, false);
13947 if (p
->last_reset_cause_size
) {
13948 msg
= p
->last_reset_cause
;
13950 " Message received that caused BGP to send a NOTIFICATION:\n ");
13951 for (i
= 1; i
<= p
->last_reset_cause_size
;
13953 vty_out(vty
, "%02X", *msg
++);
13955 if (i
!= p
->last_reset_cause_size
) {
13957 vty_out(vty
, "\n ");
13958 } else if (i
% 4 == 0) {
13963 vty_out(vty
, "\n");
13968 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
13970 json_object_boolean_true_add(json_neigh
,
13971 "prefixesConfigExceedMax");
13974 " Peer had exceeded the max. no. of prefixes configured.\n");
13976 if (p
->t_pmax_restart
) {
13978 json_object_boolean_true_add(
13979 json_neigh
, "reducePrefixNumFrom");
13980 json_object_int_add(json_neigh
,
13981 "restartInTimerMsec",
13982 thread_timer_remain_second(
13987 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
13988 p
->host
, thread_timer_remain_second(
13989 p
->t_pmax_restart
));
13992 json_object_boolean_true_add(
13994 "reducePrefixNumAndClearIpBgp");
13997 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14002 /* EBGP Multihop and GTSM */
14003 if (p
->sort
!= BGP_PEER_IBGP
) {
14005 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14006 json_object_int_add(json_neigh
,
14007 "externalBgpNbrMaxHopsAway",
14009 else if (p
->ttl
> BGP_DEFAULT_TTL
)
14010 json_object_int_add(json_neigh
,
14011 "externalBgpNbrMaxHopsAway",
14014 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14016 " External BGP neighbor may be up to %d hops away.\n",
14018 else if (p
->ttl
> BGP_DEFAULT_TTL
)
14020 " External BGP neighbor may be up to %d hops away.\n",
14024 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
) {
14026 json_object_int_add(json_neigh
,
14027 "internalBgpNbrMaxHopsAway",
14031 " Internal BGP neighbor may be up to %d hops away.\n",
14036 /* Local address. */
14039 json_object_string_add(json_neigh
, "hostLocal",
14040 sockunion2str(p
->su_local
, buf1
,
14042 json_object_int_add(json_neigh
, "portLocal",
14043 ntohs(p
->su_local
->sin
.sin_port
));
14045 vty_out(vty
, "Local host: %s, Local port: %d\n",
14046 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
14047 ntohs(p
->su_local
->sin
.sin_port
));
14050 /* Remote address. */
14051 if (p
->su_remote
) {
14053 json_object_string_add(json_neigh
, "hostForeign",
14054 sockunion2str(p
->su_remote
, buf1
,
14056 json_object_int_add(json_neigh
, "portForeign",
14057 ntohs(p
->su_remote
->sin
.sin_port
));
14059 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
14060 sockunion2str(p
->su_remote
, buf1
,
14062 ntohs(p
->su_remote
->sin
.sin_port
));
14065 /* Nexthop display. */
14068 json_object_string_add(json_neigh
, "nexthop",
14070 &p
->nexthop
.v4
, buf1
,
14072 json_object_string_add(json_neigh
, "nexthopGlobal",
14073 inet_ntop(AF_INET6
,
14074 &p
->nexthop
.v6_global
,
14075 buf1
, sizeof(buf1
)));
14076 json_object_string_add(json_neigh
, "nexthopLocal",
14077 inet_ntop(AF_INET6
,
14078 &p
->nexthop
.v6_local
,
14079 buf1
, sizeof(buf1
)));
14080 if (p
->shared_network
)
14081 json_object_string_add(json_neigh
,
14085 json_object_string_add(json_neigh
,
14087 "nonSharedNetwork");
14089 vty_out(vty
, "Nexthop: %s\n",
14090 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
14092 vty_out(vty
, "Nexthop global: %s\n",
14093 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
14095 vty_out(vty
, "Nexthop local: %s\n",
14096 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
14098 vty_out(vty
, "BGP connection: %s\n",
14099 p
->shared_network
? "shared network"
14100 : "non shared network");
14104 /* Timer information. */
14106 json_object_int_add(json_neigh
, "connectRetryTimer",
14108 if (p
->status
== Established
&& p
->rtt
)
14109 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14112 json_object_int_add(
14113 json_neigh
, "nextStartTimerDueInMsecs",
14114 thread_timer_remain_second(p
->t_start
) * 1000);
14116 json_object_int_add(
14117 json_neigh
, "nextConnectTimerDueInMsecs",
14118 thread_timer_remain_second(p
->t_connect
)
14120 if (p
->t_routeadv
) {
14121 json_object_int_add(json_neigh
, "mraiInterval",
14123 json_object_int_add(
14124 json_neigh
, "mraiTimerExpireInMsecs",
14125 thread_timer_remain_second(p
->t_routeadv
)
14129 json_object_int_add(json_neigh
, "authenticationEnabled",
14133 json_object_string_add(json_neigh
, "readThread", "on");
14135 json_object_string_add(json_neigh
, "readThread", "off");
14137 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14138 json_object_string_add(json_neigh
, "writeThread", "on");
14140 json_object_string_add(json_neigh
, "writeThread",
14143 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14145 if (p
->status
== Established
&& p
->rtt
)
14146 vty_out(vty
, "Estimated round trip time: %d ms\n",
14149 vty_out(vty
, "Next start timer due in %ld seconds\n",
14150 thread_timer_remain_second(p
->t_start
));
14152 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14153 thread_timer_remain_second(p
->t_connect
));
14156 "MRAI (interval %u) timer expires in %ld seconds\n",
14158 thread_timer_remain_second(p
->t_routeadv
));
14160 vty_out(vty
, "Peer Authentication Enabled\n");
14162 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14163 p
->t_read
? "on" : "off",
14164 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14169 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14170 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14171 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14174 vty_out(vty
, "\n");
14176 /* BFD information. */
14177 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
14180 if (p
->conf_if
) /* Configured interface name. */
14181 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14182 else /* Configured IP address. */
14183 json_object_object_add(json
, p
->host
, json_neigh
);
14187 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14188 enum show_type type
,
14189 union sockunion
*su
,
14190 const char *conf_if
, afi_t afi
,
14193 struct listnode
*node
, *nnode
;
14196 safi_t safi
= SAFI_UNICAST
;
14197 json_object
*json
= NULL
;
14198 json_object
*json_neighbor
= NULL
;
14201 json
= json_object_new_object();
14202 json_neighbor
= json_object_new_object();
14205 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14207 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14210 if ((peer
->afc
[afi
][safi
]) == 0)
14213 if (type
== show_all
) {
14214 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14218 json_object_object_add(json
, peer
->host
,
14220 json_neighbor
= NULL
;
14223 } else if (type
== show_peer
) {
14226 && !strcmp(peer
->conf_if
, conf_if
))
14228 && !strcmp(peer
->hostname
, conf_if
))) {
14230 bgp_show_peer_gr_status(vty
, peer
,
14235 if (sockunion_same(&peer
->su
, su
)) {
14237 bgp_show_peer_gr_status(vty
, peer
,
14242 if (use_json
&& find
)
14243 json_object_object_add(json
, peer
->host
,
14248 json_neighbor
= NULL
;
14253 if (type
== show_peer
&& !find
) {
14255 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14257 vty_out(vty
, "%% No such neighbor\n");
14260 vty_out(vty
, "%s\n",
14261 json_object_to_json_string_ext(
14262 json
, JSON_C_TO_STRING_PRETTY
));
14265 json_object_free(json_neighbor
);
14266 json_object_free(json
);
14268 vty_out(vty
, "\n");
14271 return CMD_SUCCESS
;
14274 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14275 enum show_type type
, union sockunion
*su
,
14276 const char *conf_if
, bool use_json
,
14279 struct listnode
*node
, *nnode
;
14282 bool nbr_output
= false;
14283 afi_t afi
= AFI_MAX
;
14284 safi_t safi
= SAFI_MAX
;
14286 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14288 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14292 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14293 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14298 bgp_show_peer(vty
, peer
, use_json
, json
);
14304 && !strcmp(peer
->conf_if
, conf_if
))
14306 && !strcmp(peer
->hostname
, conf_if
))) {
14308 bgp_show_peer(vty
, peer
, use_json
,
14312 if (sockunion_same(&peer
->su
, su
)) {
14314 bgp_show_peer(vty
, peer
, use_json
,
14319 case show_ipv4_peer
:
14320 case show_ipv6_peer
:
14321 FOREACH_SAFI (safi
) {
14322 if (peer
->afc
[afi
][safi
]) {
14325 && !strcmp(peer
->conf_if
, conf_if
))
14327 && !strcmp(peer
->hostname
, conf_if
))) {
14329 bgp_show_peer(vty
, peer
, use_json
,
14334 if (sockunion_same(&peer
->su
, su
)) {
14336 bgp_show_peer(vty
, peer
, use_json
,
14344 case show_ipv4_all
:
14345 case show_ipv6_all
:
14346 FOREACH_SAFI (safi
) {
14347 if (peer
->afc
[afi
][safi
]) {
14348 bgp_show_peer(vty
, peer
, use_json
, json
);
14357 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14358 type
== show_ipv6_peer
) && !find
) {
14360 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14362 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14365 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14366 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14367 vty_out(vty
, "%% No BGP neighbors found\n");
14370 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14371 json
, JSON_C_TO_STRING_PRETTY
));
14373 vty_out(vty
, "\n");
14376 return CMD_SUCCESS
;
14379 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14380 enum show_type type
,
14381 const char *ip_str
,
14382 afi_t afi
, bool use_json
)
14387 union sockunion su
;
14389 bgp
= bgp_get_default();
14395 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14399 ret
= str2sockunion(ip_str
, &su
);
14401 bgp_show_neighbor_graceful_restart(
14402 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14404 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14405 NULL
, afi
, use_json
);
14407 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14411 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14412 enum show_type type
,
14413 const char *ip_str
,
14416 struct listnode
*node
, *nnode
;
14418 union sockunion su
;
14419 json_object
*json
= NULL
;
14420 int ret
, is_first
= 1;
14421 bool nbr_output
= false;
14424 vty_out(vty
, "{\n");
14426 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14429 if (!(json
= json_object_new_object())) {
14431 EC_BGP_JSON_MEM_ERROR
,
14432 "Unable to allocate memory for JSON object");
14434 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14438 json_object_int_add(json
, "vrfId",
14439 (bgp
->vrf_id
== VRF_UNKNOWN
)
14441 : (int64_t)bgp
->vrf_id
);
14442 json_object_string_add(
14444 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14449 vty_out(vty
, ",\n");
14453 vty_out(vty
, "\"%s\":",
14454 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14458 vty_out(vty
, "\nInstance %s:\n",
14459 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14464 if (type
== show_peer
|| type
== show_ipv4_peer
||
14465 type
== show_ipv6_peer
) {
14466 ret
= str2sockunion(ip_str
, &su
);
14468 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14471 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14474 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14477 json_object_free(json
);
14482 vty_out(vty
, "}\n");
14483 else if (!nbr_output
)
14484 vty_out(vty
, "%% BGP instance not found\n");
14487 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14488 enum show_type type
, const char *ip_str
,
14493 union sockunion su
;
14494 json_object
*json
= NULL
;
14497 if (strmatch(name
, "all")) {
14498 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14500 return CMD_SUCCESS
;
14502 bgp
= bgp_lookup_by_name(name
);
14505 json
= json_object_new_object();
14506 vty_out(vty
, "%s\n",
14507 json_object_to_json_string_ext(
14509 JSON_C_TO_STRING_PRETTY
));
14510 json_object_free(json
);
14513 "%% BGP instance not found\n");
14515 return CMD_WARNING
;
14519 bgp
= bgp_get_default();
14523 json
= json_object_new_object();
14525 ret
= str2sockunion(ip_str
, &su
);
14527 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14530 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14533 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14536 json_object_free(json
);
14539 vty_out(vty
, "{}\n");
14541 vty_out(vty
, "%% BGP instance not found\n");
14544 return CMD_SUCCESS
;
14549 /* "show [ip] bgp neighbors graceful-restart" commands. */
14550 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
14551 show_ip_bgp_neighbors_graceful_restart_cmd
,
14552 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14558 "Neighbor to display information about\n"
14559 "Neighbor to display information about\n"
14560 "Neighbor on BGP configured interface\n"
14564 char *sh_arg
= NULL
;
14565 enum show_type sh_type
;
14567 afi_t afi
= AFI_MAX
;
14568 bool uj
= use_json(argc
, argv
);
14570 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14575 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14576 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14577 || argv_find(argv
, argc
, "WORD", &idx
)) {
14578 sh_type
= show_peer
;
14579 sh_arg
= argv
[idx
]->arg
;
14581 sh_type
= show_all
;
14583 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14584 return CMD_SUCCESS
;
14587 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14591 /* "show [ip] bgp neighbors" commands. */
14592 DEFUN (show_ip_bgp_neighbors
,
14593 show_ip_bgp_neighbors_cmd
,
14594 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14598 BGP_INSTANCE_HELP_STR
14601 "Detailed information on TCP and BGP neighbor connections\n"
14602 "Neighbor to display information about\n"
14603 "Neighbor to display information about\n"
14604 "Neighbor on BGP configured interface\n"
14608 char *sh_arg
= NULL
;
14609 enum show_type sh_type
;
14610 afi_t afi
= AFI_MAX
;
14612 bool uj
= use_json(argc
, argv
);
14616 /* [<vrf> VIEWVRFNAME] */
14617 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14618 vrf
= argv
[idx
+ 1]->arg
;
14619 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14621 } else if (argv_find(argv
, argc
, "view", &idx
))
14622 /* [<view> VIEWVRFNAME] */
14623 vrf
= argv
[idx
+ 1]->arg
;
14627 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14628 sh_type
= show_ipv4_all
;
14630 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14631 sh_type
= show_ipv6_all
;
14634 sh_type
= show_all
;
14637 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14638 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14639 || argv_find(argv
, argc
, "WORD", &idx
)) {
14640 sh_type
= show_peer
;
14641 sh_arg
= argv
[idx
]->arg
;
14644 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14645 sh_type
= show_ipv4_peer
;
14646 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14647 sh_type
= show_ipv6_peer
;
14650 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14653 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14654 paths' and `show ip mbgp paths'. Those functions results are the
14656 DEFUN (show_ip_bgp_paths
,
14657 show_ip_bgp_paths_cmd
,
14658 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14663 "Path information\n")
14665 vty_out(vty
, "Address Refcnt Path\n");
14666 aspath_print_all_vty(vty
);
14667 return CMD_SUCCESS
;
14672 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14675 struct community
*com
;
14677 com
= (struct community
*)bucket
->data
;
14678 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14679 community_str(com
, false));
14682 /* Show BGP's community internal data. */
14683 DEFUN (show_ip_bgp_community_info
,
14684 show_ip_bgp_community_info_cmd
,
14685 "show [ip] bgp community-info",
14689 "List all bgp community information\n")
14691 vty_out(vty
, "Address Refcnt Community\n");
14693 hash_iterate(community_hash(),
14694 (void (*)(struct hash_bucket
*,
14695 void *))community_show_all_iterator
,
14698 return CMD_SUCCESS
;
14701 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14704 struct lcommunity
*lcom
;
14706 lcom
= (struct lcommunity
*)bucket
->data
;
14707 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14708 lcommunity_str(lcom
, false));
14711 /* Show BGP's community internal data. */
14712 DEFUN (show_ip_bgp_lcommunity_info
,
14713 show_ip_bgp_lcommunity_info_cmd
,
14714 "show ip bgp large-community-info",
14718 "List all bgp large-community information\n")
14720 vty_out(vty
, "Address Refcnt Large-community\n");
14722 hash_iterate(lcommunity_hash(),
14723 (void (*)(struct hash_bucket
*,
14724 void *))lcommunity_show_all_iterator
,
14727 return CMD_SUCCESS
;
14729 /* Graceful Restart */
14731 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
14738 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
14740 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
14742 switch (bgp_global_gr_mode
) {
14744 case GLOBAL_HELPER
:
14745 vty_out(vty
, "Global BGP GR Mode : Helper\n");
14749 vty_out(vty
, "Global BGP GR Mode : Restart\n");
14752 case GLOBAL_DISABLE
:
14753 vty_out(vty
, "Global BGP GR Mode : Disable\n");
14756 case GLOBAL_INVALID
:
14758 "Global BGP GR Mode Invalid\n");
14761 vty_out(vty
, "\n");
14764 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
14765 enum show_type type
,
14766 const char *ip_str
,
14767 afi_t afi
, bool use_json
)
14769 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
14772 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
14774 bgp_show_neighbor_graceful_restart_vty(
14775 vty
, type
, ip_str
, afi
, use_json
);
14778 } else if (afi
!= AFI_MAX
) {
14779 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
14782 return CMD_ERR_INCOMPLETE
;
14785 return CMD_SUCCESS
;
14787 /* Graceful Restart */
14789 DEFUN (show_ip_bgp_attr_info
,
14790 show_ip_bgp_attr_info_cmd
,
14791 "show [ip] bgp attribute-info",
14795 "List all bgp attribute information\n")
14797 attr_show_all(vty
);
14798 return CMD_SUCCESS
;
14801 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
14802 afi_t afi
, safi_t safi
,
14803 bool use_json
, json_object
*json
)
14806 struct listnode
*node
;
14808 char buf1
[INET6_ADDRSTRLEN
];
14810 vpn_policy_direction_t dir
;
14813 json_object
*json_import_vrfs
= NULL
;
14814 json_object
*json_export_vrfs
= NULL
;
14816 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14819 vty_out(vty
, "%s\n",
14820 json_object_to_json_string_ext(
14822 JSON_C_TO_STRING_PRETTY
));
14823 json_object_free(json
);
14825 return CMD_WARNING
;
14828 /* Provide context for the block */
14829 json_object_string_add(json
, "vrf", name
? name
: "default");
14830 json_object_string_add(json
, "afiSafi",
14831 get_afi_safi_str(afi
, safi
, true));
14833 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14834 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
14835 json_object_string_add(json
, "importFromVrfs", "none");
14836 json_object_string_add(json
, "importRts", "none");
14838 json_import_vrfs
= json_object_new_array();
14840 for (ALL_LIST_ELEMENTS_RO(
14841 bgp
->vpn_policy
[afi
].import_vrf
,
14843 json_object_array_add(json_import_vrfs
,
14844 json_object_new_string(vname
));
14846 json_object_object_add(json
, "importFromVrfs",
14848 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14849 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14850 ecom_str
= ecommunity_ecom2str(
14851 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14852 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14853 json_object_string_add(json
, "importRts",
14855 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14857 json_object_string_add(json
, "importRts",
14861 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14862 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
14863 json_object_string_add(json
, "exportToVrfs", "none");
14864 json_object_string_add(json
, "routeDistinguisher",
14866 json_object_string_add(json
, "exportRts", "none");
14868 json_export_vrfs
= json_object_new_array();
14870 for (ALL_LIST_ELEMENTS_RO(
14871 bgp
->vpn_policy
[afi
].export_vrf
,
14873 json_object_array_add(json_export_vrfs
,
14874 json_object_new_string(vname
));
14875 json_object_object_add(json
, "exportToVrfs",
14877 json_object_string_add(json
, "routeDistinguisher",
14878 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
14879 buf1
, RD_ADDRSTRLEN
));
14881 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
14882 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14883 ecom_str
= ecommunity_ecom2str(
14884 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14885 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14886 json_object_string_add(json
, "exportRts",
14888 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14890 json_object_string_add(json
, "exportRts",
14895 vty_out(vty
, "%s\n",
14896 json_object_to_json_string_ext(json
,
14897 JSON_C_TO_STRING_PRETTY
));
14898 json_object_free(json
);
14901 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14904 vty_out(vty
, "%% No such BGP instance exist\n");
14905 return CMD_WARNING
;
14908 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14909 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
14911 "This VRF is not importing %s routes from any other VRF\n",
14912 get_afi_safi_str(afi
, safi
, false));
14915 "This VRF is importing %s routes from the following VRFs:\n",
14916 get_afi_safi_str(afi
, safi
, false));
14918 for (ALL_LIST_ELEMENTS_RO(
14919 bgp
->vpn_policy
[afi
].import_vrf
,
14921 vty_out(vty
, " %s\n", vname
);
14923 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14925 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14926 ecom_str
= ecommunity_ecom2str(
14927 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14928 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14929 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
14931 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14933 vty_out(vty
, "Import RT(s):\n");
14936 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14937 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
14939 "This VRF is not exporting %s routes to any other VRF\n",
14940 get_afi_safi_str(afi
, safi
, false));
14943 "This VRF is exporting %s routes to the following VRFs:\n",
14944 get_afi_safi_str(afi
, safi
, false));
14946 for (ALL_LIST_ELEMENTS_RO(
14947 bgp
->vpn_policy
[afi
].export_vrf
,
14949 vty_out(vty
, " %s\n", vname
);
14951 vty_out(vty
, "RD: %s\n",
14952 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
14953 buf1
, RD_ADDRSTRLEN
));
14955 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
14956 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14957 ecom_str
= ecommunity_ecom2str(
14958 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14959 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14960 vty_out(vty
, "Export RT: %s\n", ecom_str
);
14961 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14963 vty_out(vty
, "Import RT(s):\n");
14967 return CMD_SUCCESS
;
14970 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
14971 safi_t safi
, bool use_json
)
14973 struct listnode
*node
, *nnode
;
14975 char *vrf_name
= NULL
;
14976 json_object
*json
= NULL
;
14977 json_object
*json_vrf
= NULL
;
14978 json_object
*json_vrfs
= NULL
;
14981 json
= json_object_new_object();
14982 json_vrfs
= json_object_new_object();
14985 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14987 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
14988 vrf_name
= bgp
->name
;
14991 json_vrf
= json_object_new_object();
14993 vty_out(vty
, "\nInstance %s:\n",
14994 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14995 ? VRF_DEFAULT_NAME
: bgp
->name
);
14997 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
14999 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15000 json_object_object_add(json_vrfs
,
15001 VRF_DEFAULT_NAME
, json_vrf
);
15003 json_object_object_add(json_vrfs
, vrf_name
,
15009 json_object_object_add(json
, "vrfs", json_vrfs
);
15010 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
15011 JSON_C_TO_STRING_PRETTY
));
15012 json_object_free(json
);
15015 return CMD_SUCCESS
;
15018 /* "show [ip] bgp route-leak" command. */
15019 DEFUN (show_ip_bgp_route_leak
,
15020 show_ip_bgp_route_leak_cmd
,
15021 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15025 BGP_INSTANCE_HELP_STR
15028 "Route leaking information\n"
15032 afi_t afi
= AFI_MAX
;
15033 safi_t safi
= SAFI_MAX
;
15035 bool uj
= use_json(argc
, argv
);
15037 json_object
*json
= NULL
;
15039 /* show [ip] bgp */
15040 if (argv_find(argv
, argc
, "ip", &idx
)) {
15042 safi
= SAFI_UNICAST
;
15044 /* [vrf VIEWVRFNAME] */
15045 if (argv_find(argv
, argc
, "view", &idx
)) {
15047 "%% This command is not applicable to BGP views\n");
15048 return CMD_WARNING
;
15051 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15052 vrf
= argv
[idx
+ 1]->arg
;
15053 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15056 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15057 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15058 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15061 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15063 "%% This command is applicable only for unicast ipv4|ipv6\n");
15064 return CMD_WARNING
;
15067 if (vrf
&& strmatch(vrf
, "all"))
15068 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15071 json
= json_object_new_object();
15073 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15076 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15079 struct listnode
*node
, *nnode
;
15082 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15083 vty_out(vty
, "\nInstance %s:\n",
15084 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15087 update_group_show(bgp
, afi
, safi
, vty
, 0);
15091 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15092 int safi
, uint64_t subgrp_id
)
15097 if (strmatch(name
, "all")) {
15098 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
15099 return CMD_SUCCESS
;
15101 bgp
= bgp_lookup_by_name(name
);
15104 bgp
= bgp_get_default();
15108 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
15109 return CMD_SUCCESS
;
15112 DEFUN (show_ip_bgp_updgrps
,
15113 show_ip_bgp_updgrps_cmd
,
15114 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
15118 BGP_INSTANCE_HELP_STR
15120 BGP_SAFI_WITH_LABEL_HELP_STR
15121 "Detailed info about dynamic update groups\n"
15122 "Specific subgroup to display detailed info for\n")
15125 afi_t afi
= AFI_IP6
;
15126 safi_t safi
= SAFI_UNICAST
;
15127 uint64_t subgrp_id
= 0;
15131 /* show [ip] bgp */
15132 if (argv_find(argv
, argc
, "ip", &idx
))
15134 /* [<vrf> VIEWVRFNAME] */
15135 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15136 vrf
= argv
[idx
+ 1]->arg
;
15137 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15139 } else if (argv_find(argv
, argc
, "view", &idx
))
15140 /* [<view> VIEWVRFNAME] */
15141 vrf
= argv
[idx
+ 1]->arg
;
15142 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15143 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15144 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15147 /* get subgroup id, if provided */
15149 if (argv
[idx
]->type
== VARIABLE_TKN
)
15150 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15152 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
15155 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15156 show_bgp_instance_all_ipv6_updgrps_cmd
,
15157 "show [ip] bgp <view|vrf> all update-groups",
15161 BGP_INSTANCE_ALL_HELP_STR
15162 "Detailed info about dynamic update groups\n")
15164 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15165 return CMD_SUCCESS
;
15168 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15169 show_bgp_l2vpn_evpn_updgrps_cmd
,
15170 "show [ip] bgp l2vpn evpn update-groups",
15174 "l2vpn address family\n"
15175 "evpn sub-address family\n"
15176 "Detailed info about dynamic update groups\n")
15179 uint64_t subgrp_id
= 0;
15181 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15182 return CMD_SUCCESS
;
15185 DEFUN (show_bgp_updgrps_stats
,
15186 show_bgp_updgrps_stats_cmd
,
15187 "show [ip] bgp update-groups statistics",
15191 "Detailed info about dynamic update groups\n"
15196 bgp
= bgp_get_default();
15198 update_group_show_stats(bgp
, vty
);
15200 return CMD_SUCCESS
;
15203 DEFUN (show_bgp_instance_updgrps_stats
,
15204 show_bgp_instance_updgrps_stats_cmd
,
15205 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15209 BGP_INSTANCE_HELP_STR
15210 "Detailed info about dynamic update groups\n"
15216 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15218 update_group_show_stats(bgp
, vty
);
15220 return CMD_SUCCESS
;
15223 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15224 afi_t afi
, safi_t safi
,
15225 const char *what
, uint64_t subgrp_id
)
15230 bgp
= bgp_lookup_by_name(name
);
15232 bgp
= bgp_get_default();
15235 if (!strcmp(what
, "advertise-queue"))
15236 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15238 else if (!strcmp(what
, "advertised-routes"))
15239 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15241 else if (!strcmp(what
, "packet-queue"))
15242 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15247 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15248 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15249 "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",
15250 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15252 "Detailed info about dynamic update groups\n"
15253 "Specific subgroup to display info for\n"
15254 "Advertisement queue\n"
15255 "Announced routes\n"
15258 uint64_t subgrp_id
= 0;
15262 subgrp_id
= strtoull(sgid
, NULL
, 10);
15267 afiz
= bgp_vty_afi_from_str(afi
);
15271 afiz
= bgp_vty_afi_from_str(afi
);
15272 if (afiz
!= AFI_IP
)
15274 "%% Cannot specify both 'ip' and 'ipv6'\n");
15275 return CMD_WARNING
;
15278 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15280 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15281 return CMD_SUCCESS
;
15284 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
15286 struct listnode
*node
, *nnode
;
15287 struct prefix
*range
;
15292 const char *peer_status
;
15293 const char *af_str
;
15298 conf
= group
->conf
;
15300 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15301 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15302 group
->name
, conf
->as
);
15303 } else if (conf
->as_type
== AS_INTERNAL
) {
15304 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15305 group
->name
, group
->bgp
->as
);
15307 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15310 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
15311 vty_out(vty
, " Peer-group type is internal\n");
15313 vty_out(vty
, " Peer-group type is external\n");
15315 /* Display AFs configured. */
15316 vty_out(vty
, " Configured address-families:");
15317 FOREACH_AFI_SAFI (afi
, safi
) {
15318 if (conf
->afc
[afi
][safi
]) {
15320 vty_out(vty
, " %s;", get_afi_safi_str(afi
, safi
, false));
15324 vty_out(vty
, " none\n");
15326 vty_out(vty
, "\n");
15328 /* Display listen ranges (for dynamic neighbors), if any */
15329 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15332 else if (afi
== AFI_IP6
)
15336 lr_count
= listcount(group
->listen_range
[afi
]);
15338 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
15342 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15344 vty_out(vty
, " %pFX\n", range
);
15348 /* Display group members and their status */
15349 if (listcount(group
->peer
)) {
15350 vty_out(vty
, " Peer-group members:\n");
15351 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15352 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15353 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15354 peer_status
= "Idle (Admin)";
15355 else if (CHECK_FLAG(peer
->sflags
,
15356 PEER_STATUS_PREFIX_OVERFLOW
))
15357 peer_status
= "Idle (PfxCt)";
15359 peer_status
= lookup_msg(bgp_status_msg
,
15360 peer
->status
, NULL
);
15362 dynamic
= peer_dynamic_neighbor(peer
);
15363 vty_out(vty
, " %s %s %s \n", peer
->host
,
15364 dynamic
? "(dynamic)" : "", peer_status
);
15368 return CMD_SUCCESS
;
15371 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15372 const char *group_name
)
15375 struct listnode
*node
, *nnode
;
15376 struct peer_group
*group
;
15377 bool found
= false;
15379 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15382 vty_out(vty
, "%% BGP instance not found\n");
15383 return CMD_WARNING
;
15386 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15388 if (strmatch(group
->name
, group_name
)) {
15389 bgp_show_one_peer_group(vty
, group
);
15394 bgp_show_one_peer_group(vty
, group
);
15398 if (group_name
&& !found
)
15399 vty_out(vty
, "%% No such peer-group\n");
15401 return CMD_SUCCESS
;
15404 DEFUN (show_ip_bgp_peer_groups
,
15405 show_ip_bgp_peer_groups_cmd
,
15406 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
15410 BGP_INSTANCE_HELP_STR
15411 "Detailed information on BGP peer groups\n"
15412 "Peer group name\n")
15417 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15419 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15421 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
15425 /* Redistribute VTY commands. */
15427 DEFUN_YANG (bgp_redistribute_ipv4
,
15428 bgp_redistribute_ipv4_cmd
,
15429 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15430 "Redistribute information from another routing protocol\n"
15431 FRR_IP_REDIST_HELP_STR_BGPD
)
15433 int idx_protocol
= 1;
15434 char base_xpath
[XPATH_MAXLEN
];
15436 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15437 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15438 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15439 argv
[idx_protocol
]->text
, "0");
15441 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15443 return nb_cli_apply_changes(vty
, base_xpath
);
15447 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15448 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15449 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15451 DEFUN_YANG (bgp_redistribute_ipv4_rmap
,
15452 bgp_redistribute_ipv4_rmap_cmd
,
15453 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15454 "Redistribute information from another routing protocol\n"
15455 FRR_IP_REDIST_HELP_STR_BGPD
15456 "Route map reference\n"
15457 "Pointer to route-map entries\n")
15459 int idx_protocol
= 1;
15461 char base_xpath
[XPATH_MAXLEN
];
15463 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15464 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15465 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15466 argv
[idx_protocol
]->text
, "0");
15468 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15469 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15470 argv
[idx_word
]->arg
);
15472 return nb_cli_apply_changes(vty
, base_xpath
);
15476 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15477 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15478 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15479 "Route map reference\n"
15480 "Pointer to route-map entries\n")
15482 DEFUN_YANG (bgp_redistribute_ipv4_metric
,
15483 bgp_redistribute_ipv4_metric_cmd
,
15484 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15485 "Redistribute information from another routing protocol\n"
15486 FRR_IP_REDIST_HELP_STR_BGPD
15487 "Metric for redistributed routes\n"
15488 "Default metric\n")
15490 int idx_protocol
= 1;
15491 int idx_number
= 3;
15492 char base_xpath
[XPATH_MAXLEN
];
15494 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15495 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15496 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15497 argv
[idx_protocol
]->text
, "0");
15499 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15500 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15501 argv
[idx_number
]->arg
);
15503 return nb_cli_apply_changes(vty
, base_xpath
);
15507 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15508 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15509 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15510 "Metric for redistributed routes\n"
15511 "Default metric\n")
15514 bgp_redistribute_ipv4_rmap_metric
,
15515 bgp_redistribute_ipv4_rmap_metric_cmd
,
15516 "redistribute " FRR_IP_REDIST_STR_BGPD
15517 " route-map WORD metric (0-4294967295)",
15518 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15519 "Route map reference\n"
15520 "Pointer to route-map entries\n"
15521 "Metric for redistributed routes\n"
15522 "Default metric\n")
15524 int idx_protocol
= 1;
15526 int idx_number
= 5;
15527 char base_xpath
[XPATH_MAXLEN
];
15529 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15530 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15531 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15532 argv
[idx_protocol
]->text
, "0");
15534 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15535 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15536 argv
[idx_word
]->arg
);
15537 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15538 argv
[idx_number
]->arg
);
15540 return nb_cli_apply_changes(vty
, base_xpath
);
15544 bgp_redistribute_ipv4_rmap_metric
,
15545 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15546 "redistribute " FRR_IP_REDIST_STR_BGPD
15547 " route-map WORD metric (0-4294967295)",
15548 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15549 "Route map reference\n"
15550 "Pointer to route-map entries\n"
15551 "Metric for redistributed routes\n"
15552 "Default metric\n")
15555 bgp_redistribute_ipv4_metric_rmap
,
15556 bgp_redistribute_ipv4_metric_rmap_cmd
,
15557 "redistribute " FRR_IP_REDIST_STR_BGPD
15558 " metric (0-4294967295) route-map WORD",
15559 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15560 "Metric for redistributed routes\n"
15562 "Route map reference\n"
15563 "Pointer to route-map entries\n")
15565 int idx_protocol
= 1;
15567 int idx_number
= 3;
15568 char base_xpath
[XPATH_MAXLEN
];
15570 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15571 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15572 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15573 argv
[idx_protocol
]->text
, "0");
15575 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15576 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15577 argv
[idx_number
]->arg
);
15578 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15579 argv
[idx_word
]->arg
);
15581 return nb_cli_apply_changes(vty
, base_xpath
);
15585 bgp_redistribute_ipv4_metric_rmap
,
15586 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15587 "redistribute " FRR_IP_REDIST_STR_BGPD
15588 " metric (0-4294967295) route-map WORD",
15589 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15590 "Metric for redistributed routes\n"
15592 "Route map reference\n"
15593 "Pointer to route-map entries\n")
15595 DEFUN_YANG (bgp_redistribute_ipv4_ospf
,
15596 bgp_redistribute_ipv4_ospf_cmd
,
15597 "redistribute <ospf|table> (1-65535)",
15598 "Redistribute information from another routing protocol\n"
15599 "Open Shortest Path First (OSPFv2)\n"
15600 "Non-main Kernel Routing Table\n"
15601 "Instance ID/Table ID\n")
15603 int idx_protocol
= 1;
15604 int idx_number
= 2;
15605 char base_xpath
[XPATH_MAXLEN
];
15607 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15608 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15609 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15610 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15612 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15614 return nb_cli_apply_changes(vty
, base_xpath
);
15617 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
15618 "redistribute <ospf|table> (1-65535)",
15619 "Redistribute information from another routing protocol\n"
15620 "Open Shortest Path First (OSPFv2)\n"
15621 "Non-main Kernel Routing Table\n"
15622 "Instance ID/Table ID\n")
15624 DEFUN_YANG (bgp_redistribute_ipv4_ospf_rmap
,
15625 bgp_redistribute_ipv4_ospf_rmap_cmd
,
15626 "redistribute <ospf|table> (1-65535) route-map WORD",
15627 "Redistribute information from another routing protocol\n"
15628 "Open Shortest Path First (OSPFv2)\n"
15629 "Non-main Kernel Routing Table\n"
15630 "Instance ID/Table ID\n"
15631 "Route map reference\n"
15632 "Pointer to route-map entries\n")
15634 int idx_protocol
= 1;
15635 int idx_number
= 2;
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
, argv
[idx_number
]->arg
);
15644 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15646 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15647 argv
[idx_word
]->arg
);
15649 return nb_cli_apply_changes(vty
, base_xpath
);
15652 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
15653 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
15654 "redistribute <ospf|table> (1-65535) route-map WORD",
15655 "Redistribute information from another routing protocol\n"
15656 "Open Shortest Path First (OSPFv2)\n"
15657 "Non-main Kernel Routing Table\n"
15658 "Instance ID/Table ID\n"
15659 "Route map reference\n"
15660 "Pointer to route-map entries\n")
15662 DEFUN_YANG(bgp_redistribute_ipv4_ospf_metric
,
15663 bgp_redistribute_ipv4_ospf_metric_cmd
,
15664 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15665 "Redistribute information from another routing protocol\n"
15666 "Open Shortest Path First (OSPFv2)\n"
15667 "Non-main Kernel Routing Table\n"
15668 "Instance ID/Table ID\n"
15669 "Metric for redistributed routes\n"
15670 "Default metric\n")
15672 int idx_protocol
= 1;
15673 int idx_number
= 2;
15674 int idx_number_2
= 4;
15675 char base_xpath
[XPATH_MAXLEN
];
15677 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15678 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15679 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15680 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15682 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15684 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15685 argv
[idx_number_2
]->arg
);
15687 return nb_cli_apply_changes(vty
, base_xpath
);
15690 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
15691 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
15692 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15693 "Redistribute information from another routing protocol\n"
15694 "Open Shortest Path First (OSPFv2)\n"
15695 "Non-main Kernel Routing Table\n"
15696 "Instance ID/Table ID\n"
15697 "Metric for redistributed routes\n"
15698 "Default metric\n")
15701 bgp_redistribute_ipv4_ospf_rmap_metric
,
15702 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
15703 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15704 "Redistribute information from another routing protocol\n"
15705 "Open Shortest Path First (OSPFv2)\n"
15706 "Non-main Kernel Routing Table\n"
15707 "Instance ID/Table ID\n"
15708 "Route map reference\n"
15709 "Pointer to route-map entries\n"
15710 "Metric for redistributed routes\n"
15711 "Default metric\n")
15713 int idx_protocol
= 1;
15714 int idx_number
= 2;
15716 int idx_number_2
= 6;
15717 char base_xpath
[XPATH_MAXLEN
];
15719 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15720 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15721 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15722 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15724 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15726 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15727 argv
[idx_word
]->arg
);
15728 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15729 argv
[idx_number_2
]->arg
);
15731 return nb_cli_apply_changes(vty
, base_xpath
);
15735 bgp_redistribute_ipv4_ospf_rmap_metric
,
15736 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
15737 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15738 "Redistribute information from another routing protocol\n"
15739 "Open Shortest Path First (OSPFv2)\n"
15740 "Non-main Kernel Routing Table\n"
15741 "Instance ID/Table ID\n"
15742 "Route map reference\n"
15743 "Pointer to route-map entries\n"
15744 "Metric for redistributed routes\n"
15745 "Default metric\n")
15748 bgp_redistribute_ipv4_ospf_metric_rmap
,
15749 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
15750 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15751 "Redistribute information from another routing protocol\n"
15752 "Open Shortest Path First (OSPFv2)\n"
15753 "Non-main Kernel Routing Table\n"
15754 "Instance ID/Table ID\n"
15755 "Metric for redistributed routes\n"
15757 "Route map reference\n"
15758 "Pointer to route-map entries\n")
15760 int idx_protocol
= 1;
15761 int idx_number
= 2;
15762 int idx_number_2
= 4;
15764 char base_xpath
[XPATH_MAXLEN
];
15766 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15767 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15768 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15769 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15771 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15773 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15774 argv
[idx_number_2
]->arg
);
15775 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15776 argv
[idx_word
]->arg
);
15778 return nb_cli_apply_changes(vty
, base_xpath
);
15782 bgp_redistribute_ipv4_ospf_metric_rmap
,
15783 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
15784 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15785 "Redistribute information from another routing protocol\n"
15786 "Open Shortest Path First (OSPFv2)\n"
15787 "Non-main Kernel Routing Table\n"
15788 "Instance ID/Table ID\n"
15789 "Metric for redistributed routes\n"
15791 "Route map reference\n"
15792 "Pointer to route-map entries\n")
15794 DEFUN_YANG (no_bgp_redistribute_ipv4_ospf
,
15795 no_bgp_redistribute_ipv4_ospf_cmd
,
15796 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
15798 "Redistribute information from another routing protocol\n"
15799 "Open Shortest Path First (OSPFv2)\n"
15800 "Non-main Kernel Routing Table\n"
15801 "Instance ID/Table ID\n"
15802 "Metric for redistributed routes\n"
15804 "Route map reference\n"
15805 "Pointer to route-map entries\n")
15807 int idx_protocol
= 2;
15808 int idx_number
= 3;
15809 char base_xpath
[XPATH_MAXLEN
];
15811 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15812 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15813 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15814 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15816 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
15818 return nb_cli_apply_changes(vty
, base_xpath
);
15822 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
15823 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
15825 "Redistribute information from another routing protocol\n"
15826 "Open Shortest Path First (OSPFv2)\n"
15827 "Non-main Kernel Routing Table\n"
15828 "Instance ID/Table ID\n"
15829 "Metric for redistributed routes\n"
15831 "Route map reference\n"
15832 "Pointer to route-map entries\n")
15834 DEFUN_YANG (no_bgp_redistribute_ipv4
,
15835 no_bgp_redistribute_ipv4_cmd
,
15836 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
15838 "Redistribute information from another routing protocol\n"
15839 FRR_IP_REDIST_HELP_STR_BGPD
15840 "Metric for redistributed routes\n"
15842 "Route map reference\n"
15843 "Pointer to route-map entries\n")
15845 int idx_protocol
= 2;
15846 char base_xpath
[XPATH_MAXLEN
];
15848 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15849 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15850 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15851 argv
[idx_protocol
]->text
, "0");
15853 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
15855 return nb_cli_apply_changes(vty
, base_xpath
);
15859 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
15860 "no redistribute " FRR_IP_REDIST_STR_BGPD
15861 " [{metric (0-4294967295)|route-map WORD}]",
15863 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15864 "Metric for redistributed routes\n"
15866 "Route map reference\n"
15867 "Pointer to route-map entries\n")
15869 DEFUN_YANG (bgp_redistribute_ipv6
,
15870 bgp_redistribute_ipv6_cmd
,
15871 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
15872 "Redistribute information from another routing protocol\n"
15873 FRR_IP6_REDIST_HELP_STR_BGPD
)
15875 int idx_protocol
= 1;
15876 char base_xpath
[XPATH_MAXLEN
];
15878 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15879 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15880 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15881 argv
[idx_protocol
]->text
, "0");
15883 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15885 return nb_cli_apply_changes(vty
, base_xpath
);
15888 DEFUN_YANG (bgp_redistribute_ipv6_rmap
,
15889 bgp_redistribute_ipv6_rmap_cmd
,
15890 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
15891 "Redistribute information from another routing protocol\n"
15892 FRR_IP6_REDIST_HELP_STR_BGPD
15893 "Route map reference\n"
15894 "Pointer to route-map entries\n")
15896 int idx_protocol
= 1;
15898 char base_xpath
[XPATH_MAXLEN
];
15900 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15901 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15902 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15903 argv
[idx_protocol
]->text
, "0");
15905 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15906 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15907 argv
[idx_word
]->arg
);
15909 return nb_cli_apply_changes(vty
, base_xpath
);
15912 DEFUN_YANG (bgp_redistribute_ipv6_metric
,
15913 bgp_redistribute_ipv6_metric_cmd
,
15914 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
15915 "Redistribute information from another routing protocol\n"
15916 FRR_IP6_REDIST_HELP_STR_BGPD
15917 "Metric for redistributed routes\n"
15918 "Default metric\n")
15920 int idx_protocol
= 1;
15921 int idx_number
= 3;
15922 char base_xpath
[XPATH_MAXLEN
];
15924 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15925 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15926 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15927 argv
[idx_protocol
]->text
, "0");
15929 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15930 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15931 argv
[idx_number
]->arg
);
15933 return nb_cli_apply_changes(vty
, base_xpath
);
15937 bgp_redistribute_ipv6_rmap_metric
,
15938 bgp_redistribute_ipv6_rmap_metric_cmd
,
15939 "redistribute " FRR_IP6_REDIST_STR_BGPD
15940 " route-map WORD metric (0-4294967295)",
15941 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
15942 "Route map reference\n"
15943 "Pointer to route-map entries\n"
15944 "Metric for redistributed routes\n"
15945 "Default metric\n")
15947 int idx_protocol
= 1;
15949 int idx_number
= 5;
15950 char base_xpath
[XPATH_MAXLEN
];
15952 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15953 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15954 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15955 argv
[idx_protocol
]->text
, "0");
15957 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15958 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15959 argv
[idx_word
]->arg
);
15960 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15961 argv
[idx_number
]->arg
);
15963 return nb_cli_apply_changes(vty
, base_xpath
);
15967 bgp_redistribute_ipv6_metric_rmap
,
15968 bgp_redistribute_ipv6_metric_rmap_cmd
,
15969 "redistribute " FRR_IP6_REDIST_STR_BGPD
15970 " metric (0-4294967295) route-map WORD",
15971 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
15972 "Metric for redistributed routes\n"
15974 "Route map reference\n"
15975 "Pointer to route-map entries\n")
15977 int idx_protocol
= 1;
15979 int idx_number
= 3;
15980 char base_xpath
[XPATH_MAXLEN
];
15982 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15983 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15984 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15985 argv
[idx_protocol
]->text
, "0");
15987 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15988 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15989 argv
[idx_number
]->arg
);
15990 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15991 argv
[idx_word
]->arg
);
15993 return nb_cli_apply_changes(vty
, base_xpath
);
15997 no_bgp_redistribute_ipv6
,
15998 no_bgp_redistribute_ipv6_cmd
,
15999 "no redistribute " FRR_IP6_REDIST_STR_BGPD
16000 " [{metric (0-4294967295)|route-map WORD}]",
16002 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
16003 "Metric for redistributed routes\n"
16005 "Route map reference\n"
16006 "Pointer to route-map entries\n")
16008 int idx_protocol
= 2;
16009 char base_xpath
[XPATH_MAXLEN
];
16011 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16012 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16013 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16014 argv
[idx_protocol
]->text
, "0");
16016 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
16018 return nb_cli_apply_changes(vty
, base_xpath
);
16021 void cli_show_bgp_global_afi_safi_ip_unicast_redistribution_list(
16022 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
16024 uint32_t instance
= 0;
16026 vty_out(vty
, " redistribute %s",
16027 yang_dnode_get_string(dnode
, "./route-type"));
16028 if ((instance
= yang_dnode_get_uint16(dnode
, "./route-instance")))
16029 vty_out(vty
, " %d", instance
);
16030 if (yang_dnode_exists(dnode
, "./metric"))
16031 vty_out(vty
, " metric %u",
16032 yang_dnode_get_uint32(dnode
, "./metric"));
16033 if (yang_dnode_exists(dnode
, "./rmap-policy-import"))
16034 vty_out(vty
, " route-map %s",
16035 yang_dnode_get_string(dnode
, "./rmap-policy-import"));
16036 vty_out(vty
, "\n");
16039 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16040 afi_t afi
, safi_t safi
)
16044 /* Unicast redistribution only. */
16045 if (safi
!= SAFI_UNICAST
)
16048 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16049 /* Redistribute BGP does not make sense. */
16050 if (i
!= ZEBRA_ROUTE_BGP
) {
16051 struct list
*red_list
;
16052 struct listnode
*node
;
16053 struct bgp_redist
*red
;
16055 red_list
= bgp
->redist
[afi
][i
];
16059 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16060 /* "redistribute" configuration. */
16061 vty_out(vty
, " redistribute %s",
16062 zebra_route_string(i
));
16064 vty_out(vty
, " %d", red
->instance
);
16065 if (red
->redist_metric_flag
)
16066 vty_out(vty
, " metric %u",
16067 red
->redist_metric
);
16068 if (red
->rmap
.name
)
16069 vty_out(vty
, " route-map %s",
16071 vty_out(vty
, "\n");
16077 /* peer-group helpers for config-write */
16079 static bool peergroup_flag_check(struct peer
*peer
, uint32_t flag
)
16081 if (!peer_group_active(peer
)) {
16082 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16083 return !CHECK_FLAG(peer
->flags
, flag
);
16085 return !!CHECK_FLAG(peer
->flags
, flag
);
16088 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16091 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16094 if (!peer_group_active(peer
)) {
16095 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16096 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16098 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16101 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16104 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16105 uint8_t type
, int direct
)
16107 struct bgp_filter
*filter
;
16109 if (peer_group_active(peer
))
16110 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16113 filter
= &peer
->filter
[afi
][safi
];
16115 case PEER_FT_DISTRIBUTE_LIST
:
16116 return !!(filter
->dlist
[direct
].name
);
16117 case PEER_FT_FILTER_LIST
:
16118 return !!(filter
->aslist
[direct
].name
);
16119 case PEER_FT_PREFIX_LIST
:
16120 return !!(filter
->plist
[direct
].name
);
16121 case PEER_FT_ROUTE_MAP
:
16122 return !!(filter
->map
[direct
].name
);
16123 case PEER_FT_UNSUPPRESS_MAP
:
16124 return !!(filter
->usmap
.name
);
16125 case PEER_FT_ADVERTISE_MAP
:
16126 return !!(filter
->advmap
.aname
16127 && ((filter
->advmap
.condition
== direct
)
16128 && filter
->advmap
.cname
));
16134 /* Return true if the addpath type is set for peer and different from
16137 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16140 enum bgp_addpath_strat type
, g_type
;
16142 type
= peer
->addpath_type
[afi
][safi
];
16144 if (type
!= BGP_ADDPATH_NONE
) {
16145 if (peer_group_active(peer
)) {
16146 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16148 if (type
!= g_type
)
16160 /* This is part of the address-family block (unicast only) */
16161 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16166 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16167 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16168 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16169 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16170 bgp
->vpn_policy
[afi
]
16171 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16173 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16174 bgp
->vpn_policy
[afi
]
16175 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16177 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16178 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16179 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16180 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16183 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16184 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16186 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16189 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16190 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16191 bgp
->vpn_policy
[afi
].tovpn_label
);
16194 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16195 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
16196 char buf
[RD_ADDRSTRLEN
];
16197 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
16198 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
16201 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16202 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16204 char buf
[PREFIX_STRLEN
];
16205 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16206 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16209 vty_out(vty
, "%*snexthop vpn export %s\n",
16213 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16214 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16216 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16217 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16219 char *b
= ecommunity_ecom2str(
16220 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16221 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16222 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16223 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16225 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16226 char *b
= ecommunity_ecom2str(
16227 bgp
->vpn_policy
[afi
]
16228 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16229 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16230 ECOMMUNITY_ROUTE_TARGET
);
16231 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16232 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16234 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16235 char *b
= ecommunity_ecom2str(
16236 bgp
->vpn_policy
[afi
]
16237 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16238 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16239 ECOMMUNITY_ROUTE_TARGET
);
16240 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16241 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16245 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16246 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16247 bgp
->vpn_policy
[afi
]
16248 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16250 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16251 char *b
= ecommunity_ecom2str(
16252 bgp
->vpn_policy
[afi
]
16253 .import_redirect_rtlist
,
16254 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16255 ECOMMUNITY_ROUTE_TARGET
);
16257 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16258 != ECOMMUNITY_SIZE
)
16259 vty_out(vty
, "%*srt6 redirect import %s\n",
16262 vty_out(vty
, "%*srt redirect import %s\n",
16264 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16268 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16269 afi_t afi
, safi_t safi
)
16271 struct bgp_filter
*filter
;
16275 filter
= &peer
->filter
[afi
][safi
];
16277 /* distribute-list. */
16278 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16280 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16281 filter
->dlist
[FILTER_IN
].name
);
16283 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16285 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16286 filter
->dlist
[FILTER_OUT
].name
);
16289 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16291 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16292 filter
->plist
[FILTER_IN
].name
);
16294 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16296 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16297 filter
->plist
[FILTER_OUT
].name
);
16300 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16301 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16302 filter
->map
[RMAP_IN
].name
);
16304 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16306 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16307 filter
->map
[RMAP_OUT
].name
);
16309 /* unsuppress-map */
16310 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16311 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16312 filter
->usmap
.name
);
16314 /* advertise-map : always applied in OUT direction*/
16315 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16316 CONDITION_NON_EXIST
))
16318 " neighbor %s advertise-map %s non-exist-map %s\n",
16319 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16321 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16323 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16324 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16327 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16329 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16330 filter
->aslist
[FILTER_IN
].name
);
16332 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16334 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16335 filter
->aslist
[FILTER_OUT
].name
);
16338 /* BGP peer configuration display function. */
16339 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16342 struct peer
*g_peer
= NULL
;
16343 char buf
[SU_ADDRSTRLEN
];
16345 int if_pg_printed
= false;
16346 int if_ras_printed
= false;
16348 /* Skip dynamic neighbors. */
16349 if (peer_dynamic_neighbor(peer
))
16353 addr
= peer
->conf_if
;
16357 /************************************
16358 ****** Global to the neighbor ******
16359 ************************************/
16360 if (peer
->conf_if
) {
16361 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16362 vty_out(vty
, " neighbor %s interface v6only", addr
);
16364 vty_out(vty
, " neighbor %s interface", addr
);
16366 if (peer_group_active(peer
)) {
16367 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16368 if_pg_printed
= true;
16369 } else if (peer
->as_type
== AS_SPECIFIED
) {
16370 vty_out(vty
, " remote-as %u", peer
->as
);
16371 if_ras_printed
= true;
16372 } else if (peer
->as_type
== AS_INTERNAL
) {
16373 vty_out(vty
, " remote-as internal");
16374 if_ras_printed
= true;
16375 } else if (peer
->as_type
== AS_EXTERNAL
) {
16376 vty_out(vty
, " remote-as external");
16377 if_ras_printed
= true;
16380 vty_out(vty
, "\n");
16383 /* remote-as and peer-group */
16384 /* peer is a member of a peer-group */
16385 if (peer_group_active(peer
)) {
16386 g_peer
= peer
->group
->conf
;
16388 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16389 if (peer
->as_type
== AS_SPECIFIED
) {
16390 vty_out(vty
, " neighbor %s remote-as %u\n",
16392 } else if (peer
->as_type
== AS_INTERNAL
) {
16394 " neighbor %s remote-as internal\n",
16396 } else if (peer
->as_type
== AS_EXTERNAL
) {
16398 " neighbor %s remote-as external\n",
16403 /* For swpX peers we displayed the peer-group
16404 * via 'neighbor swpX interface peer-group PGNAME' */
16405 if (!if_pg_printed
)
16406 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16407 peer
->group
->name
);
16410 /* peer is NOT a member of a peer-group */
16412 /* peer is a peer-group, declare the peer-group */
16413 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16414 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16417 if (!if_ras_printed
) {
16418 if (peer
->as_type
== AS_SPECIFIED
) {
16419 vty_out(vty
, " neighbor %s remote-as %u\n",
16421 } else if (peer
->as_type
== AS_INTERNAL
) {
16423 " neighbor %s remote-as internal\n",
16425 } else if (peer
->as_type
== AS_EXTERNAL
) {
16427 " neighbor %s remote-as external\n",
16434 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16435 vty_out(vty
, " neighbor %s local-as %u", addr
,
16436 peer
->change_local_as
);
16437 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16438 vty_out(vty
, " no-prepend");
16439 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16440 vty_out(vty
, " replace-as");
16441 vty_out(vty
, "\n");
16446 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16450 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16451 if (peer
->tx_shutdown_message
)
16452 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16453 peer
->tx_shutdown_message
);
16455 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16458 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16459 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16460 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16463 if (peer
->bfd_info
) {
16464 if (!peer_group_active(peer
) || !g_peer
->bfd_info
) {
16465 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16470 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16471 vty_out(vty
, " neighbor %s password %s\n", addr
,
16474 /* neighbor solo */
16475 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16476 if (!peer_group_active(peer
)) {
16477 vty_out(vty
, " neighbor %s solo\n", addr
);
16482 if (peer
->port
!= BGP_PORT_DEFAULT
) {
16483 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
16486 /* Local interface name */
16487 if (peer
->ifname
) {
16488 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
16492 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
16493 vty_out(vty
, " neighbor %s passive\n", addr
);
16495 /* ebgp-multihop */
16496 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
16497 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
16498 && peer
->ttl
== MAXTTL
)) {
16499 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
16500 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
16505 /* ttl-security hops */
16506 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
16507 if (!peer_group_active(peer
)
16508 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
16509 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
16510 addr
, peer
->gtsm_hops
);
16514 /* disable-connected-check */
16515 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
16516 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
16518 /* enforce-first-as */
16519 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
16520 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
16522 /* update-source */
16523 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
16524 if (peer
->update_source
)
16525 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16526 sockunion2str(peer
->update_source
, buf
,
16528 else if (peer
->update_if
)
16529 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16533 /* advertisement-interval */
16534 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
16535 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
16539 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
16540 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
16541 peer
->keepalive
, peer
->holdtime
);
16543 /* timers connect */
16544 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
16545 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16547 /* need special-case handling for changed default values due to
16548 * config profile / version (because there is no "timers bgp connect"
16549 * command, we need to save this per-peer :/)
16551 else if (!peer_group_active(peer
) && !peer
->connect
&&
16552 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
16553 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16554 peer
->bgp
->default_connect_retry
);
16556 /* timers delayopen */
16557 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
16558 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16560 /* Save config even though flag is not set if default values have been
16563 else if (!peer_group_active(peer
) && !peer
->delayopen
16564 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
16565 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16566 peer
->bgp
->default_delayopen
);
16568 /* capability dynamic */
16569 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
16570 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
16572 /* capability extended-nexthop */
16573 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
16574 if (!peer
->conf_if
) {
16575 if (CHECK_FLAG(peer
->flags_invert
,
16576 PEER_FLAG_CAPABILITY_ENHE
))
16578 " no neighbor %s capability extended-nexthop\n",
16582 " neighbor %s capability extended-nexthop\n",
16587 /* dont-capability-negotiation */
16588 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
16589 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
16591 /* override-capability */
16592 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
16593 vty_out(vty
, " neighbor %s override-capability\n", addr
);
16595 /* strict-capability-match */
16596 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
16597 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
16599 /* Sender side AS path loop detection. */
16600 if (peer
->as_path_loop_detection
)
16601 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
16604 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16605 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
16607 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16608 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
16610 " neighbor %s graceful-restart-helper\n", addr
);
16611 } else if (CHECK_FLAG(
16612 peer
->peer_gr_new_status_flag
,
16613 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
16615 " neighbor %s graceful-restart\n", addr
);
16617 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16618 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
16620 peer
->peer_gr_new_status_flag
,
16621 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
16622 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
16628 /* BGP peer configuration display function. */
16629 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
16630 struct peer
*peer
, afi_t afi
, safi_t safi
)
16632 struct peer
*g_peer
= NULL
;
16634 bool flag_scomm
, flag_secomm
, flag_slcomm
;
16636 /* Skip dynamic neighbors. */
16637 if (peer_dynamic_neighbor(peer
))
16641 addr
= peer
->conf_if
;
16645 /************************************
16646 ****** Per AF to the neighbor ******
16647 ************************************/
16648 if (peer_group_active(peer
)) {
16649 g_peer
= peer
->group
->conf
;
16651 /* If the peer-group is active but peer is not, print a 'no
16653 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
16654 vty_out(vty
, " no neighbor %s activate\n", addr
);
16657 /* If the peer-group is not active but peer is, print an
16659 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
16660 vty_out(vty
, " neighbor %s activate\n", addr
);
16663 if (peer
->afc
[afi
][safi
]) {
16664 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
16665 if (CHECK_FLAG(bgp
->flags
,
16666 BGP_FLAG_NO_DEFAULT_IPV4
)) {
16667 vty_out(vty
, " neighbor %s activate\n",
16671 vty_out(vty
, " neighbor %s activate\n", addr
);
16673 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
16674 if (!CHECK_FLAG(bgp
->flags
,
16675 BGP_FLAG_NO_DEFAULT_IPV4
)) {
16677 " no neighbor %s activate\n",
16684 /* addpath TX knobs */
16685 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
16686 switch (peer
->addpath_type
[afi
][safi
]) {
16687 case BGP_ADDPATH_ALL
:
16688 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
16691 case BGP_ADDPATH_BEST_PER_AS
:
16693 " neighbor %s addpath-tx-bestpath-per-AS\n",
16696 case BGP_ADDPATH_MAX
:
16697 case BGP_ADDPATH_NONE
:
16702 /* ORF capability. */
16703 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
16704 || peergroup_af_flag_check(peer
, afi
, safi
,
16705 PEER_FLAG_ORF_PREFIX_RM
)) {
16706 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
16708 if (peergroup_af_flag_check(peer
, afi
, safi
,
16709 PEER_FLAG_ORF_PREFIX_SM
)
16710 && peergroup_af_flag_check(peer
, afi
, safi
,
16711 PEER_FLAG_ORF_PREFIX_RM
))
16712 vty_out(vty
, " both");
16713 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16714 PEER_FLAG_ORF_PREFIX_SM
))
16715 vty_out(vty
, " send");
16717 vty_out(vty
, " receive");
16718 vty_out(vty
, "\n");
16721 /* Route reflector client. */
16722 if (peergroup_af_flag_check(peer
, afi
, safi
,
16723 PEER_FLAG_REFLECTOR_CLIENT
)) {
16724 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
16727 /* next-hop-self force */
16728 if (peergroup_af_flag_check(peer
, afi
, safi
,
16729 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
16730 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
16733 /* next-hop-self */
16734 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
16735 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
16738 /* remove-private-AS */
16739 if (peergroup_af_flag_check(peer
, afi
, safi
,
16740 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
16741 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
16745 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16746 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
16747 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
16751 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16752 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
16753 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
16756 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16757 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
16758 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
16762 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
16763 vty_out(vty
, " neighbor %s as-override\n", addr
);
16766 /* send-community print. */
16767 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16768 PEER_FLAG_SEND_COMMUNITY
);
16769 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16770 PEER_FLAG_SEND_EXT_COMMUNITY
);
16771 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16772 PEER_FLAG_SEND_LARGE_COMMUNITY
);
16774 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
16775 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
16778 vty_out(vty
, " no neighbor %s send-community\n", addr
);
16781 " no neighbor %s send-community extended\n",
16785 vty_out(vty
, " no neighbor %s send-community large\n",
16789 /* Default information */
16790 if (peergroup_af_flag_check(peer
, afi
, safi
,
16791 PEER_FLAG_DEFAULT_ORIGINATE
)) {
16792 vty_out(vty
, " neighbor %s default-originate", addr
);
16794 if (peer
->default_rmap
[afi
][safi
].name
)
16795 vty_out(vty
, " route-map %s",
16796 peer
->default_rmap
[afi
][safi
].name
);
16798 vty_out(vty
, "\n");
16801 /* Soft reconfiguration inbound. */
16802 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
16803 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
16807 /* maximum-prefix. */
16808 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
16809 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
16810 peer
->pmax
[afi
][safi
]);
16812 if (peer
->pmax_threshold
[afi
][safi
]
16813 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
16814 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
16815 if (peer_af_flag_check(peer
, afi
, safi
,
16816 PEER_FLAG_MAX_PREFIX_WARNING
))
16817 vty_out(vty
, " warning-only");
16818 if (peer
->pmax_restart
[afi
][safi
])
16819 vty_out(vty
, " restart %u",
16820 peer
->pmax_restart
[afi
][safi
]);
16821 if (peer_af_flag_check(peer
, afi
, safi
,
16822 PEER_FLAG_MAX_PREFIX_FORCE
))
16823 vty_out(vty
, " force");
16825 vty_out(vty
, "\n");
16828 /* maximum-prefix-out */
16829 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
16830 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
16831 addr
, peer
->pmax_out
[afi
][safi
]);
16833 /* Route server client. */
16834 if (peergroup_af_flag_check(peer
, afi
, safi
,
16835 PEER_FLAG_RSERVER_CLIENT
)) {
16836 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
16839 /* Nexthop-local unchanged. */
16840 if (peergroup_af_flag_check(peer
, afi
, safi
,
16841 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
16842 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
16845 /* allowas-in <1-10> */
16846 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
16847 if (peer_af_flag_check(peer
, afi
, safi
,
16848 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
16849 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
16850 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
16851 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
16853 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
16854 peer
->allowas_in
[afi
][safi
]);
16859 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
16860 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
16861 peer
->weight
[afi
][safi
]);
16864 bgp_config_write_filter(vty
, peer
, afi
, safi
);
16866 /* atribute-unchanged. */
16867 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
16868 || (safi
!= SAFI_EVPN
16869 && peer_af_flag_check(peer
, afi
, safi
,
16870 PEER_FLAG_NEXTHOP_UNCHANGED
))
16871 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
16873 if (!peer_group_active(peer
)
16874 || peergroup_af_flag_check(peer
, afi
, safi
,
16875 PEER_FLAG_AS_PATH_UNCHANGED
)
16876 || peergroup_af_flag_check(peer
, afi
, safi
,
16877 PEER_FLAG_NEXTHOP_UNCHANGED
)
16878 || peergroup_af_flag_check(peer
, afi
, safi
,
16879 PEER_FLAG_MED_UNCHANGED
)) {
16882 " neighbor %s attribute-unchanged%s%s%s\n",
16884 peer_af_flag_check(peer
, afi
, safi
,
16885 PEER_FLAG_AS_PATH_UNCHANGED
)
16888 peer_af_flag_check(peer
, afi
, safi
,
16889 PEER_FLAG_NEXTHOP_UNCHANGED
)
16892 peer_af_flag_check(peer
, afi
, safi
,
16893 PEER_FLAG_MED_UNCHANGED
)
16900 /* Address family based peer configuration display. */
16901 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
16905 struct peer_group
*group
;
16906 struct listnode
*node
, *nnode
;
16909 vty_frame(vty
, " !\n address-family ");
16910 if (afi
== AFI_IP
) {
16911 if (safi
== SAFI_UNICAST
)
16912 vty_frame(vty
, "ipv4 unicast");
16913 else if (safi
== SAFI_LABELED_UNICAST
)
16914 vty_frame(vty
, "ipv4 labeled-unicast");
16915 else if (safi
== SAFI_MULTICAST
)
16916 vty_frame(vty
, "ipv4 multicast");
16917 else if (safi
== SAFI_MPLS_VPN
)
16918 vty_frame(vty
, "ipv4 vpn");
16919 else if (safi
== SAFI_ENCAP
)
16920 vty_frame(vty
, "ipv4 encap");
16921 else if (safi
== SAFI_FLOWSPEC
)
16922 vty_frame(vty
, "ipv4 flowspec");
16923 } else if (afi
== AFI_IP6
) {
16924 if (safi
== SAFI_UNICAST
)
16925 vty_frame(vty
, "ipv6 unicast");
16926 else if (safi
== SAFI_LABELED_UNICAST
)
16927 vty_frame(vty
, "ipv6 labeled-unicast");
16928 else if (safi
== SAFI_MULTICAST
)
16929 vty_frame(vty
, "ipv6 multicast");
16930 else if (safi
== SAFI_MPLS_VPN
)
16931 vty_frame(vty
, "ipv6 vpn");
16932 else if (safi
== SAFI_ENCAP
)
16933 vty_frame(vty
, "ipv6 encap");
16934 else if (safi
== SAFI_FLOWSPEC
)
16935 vty_frame(vty
, "ipv6 flowspec");
16936 } else if (afi
== AFI_L2VPN
) {
16937 if (safi
== SAFI_EVPN
)
16938 vty_frame(vty
, "l2vpn evpn");
16940 vty_frame(vty
, "\n");
16942 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
16944 bgp_config_write_network(vty
, bgp
, afi
, safi
);
16946 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
16948 /* BGP flag dampening. */
16949 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
16950 bgp_config_write_damp(vty
, afi
, safi
);
16952 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
16953 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
16955 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
16956 /* Skip dynamic neighbors. */
16957 if (peer_dynamic_neighbor(peer
))
16960 /* Do not display doppelganger peers */
16961 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
16962 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
16965 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
16966 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
16968 if (safi
== SAFI_EVPN
)
16969 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
16971 if (safi
== SAFI_FLOWSPEC
)
16972 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
16974 if (safi
== SAFI_UNICAST
) {
16975 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
16976 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
16977 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
16979 vty_out(vty
, " export vpn\n");
16981 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
16982 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
16984 vty_out(vty
, " import vpn\n");
16986 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
16987 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
16990 for (ALL_LIST_ELEMENTS_RO(
16991 bgp
->vpn_policy
[afi
].import_vrf
, node
,
16993 vty_out(vty
, " import vrf %s\n", name
);
16997 vty_endframe(vty
, " exit-address-family\n");
17000 int bgp_config_write(struct vty
*vty
)
17003 struct peer_group
*group
;
17005 struct listnode
*node
, *nnode
;
17006 struct listnode
*mnode
, *mnnode
;
17008 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17009 vty_out(vty
, "bgp route-map delay-timer %u\n",
17010 bm
->rmap_update_timer
);
17012 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17013 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17014 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17015 vty_out(vty
, " %d", bm
->v_establish_wait
);
17016 vty_out(vty
, "\n");
17019 if (bm
->wait_for_fib
)
17020 vty_out(vty
, "bgp suppress-fib-pending\n");
17022 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17023 vty_out(vty
, "bgp graceful-shutdown\n");
17025 /* No-RIB (Zebra) option flag configuration */
17026 if (bgp_option_check(BGP_OPT_NO_FIB
))
17027 vty_out(vty
, "bgp no-rib\n");
17029 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17030 vty_out(vty
, "no bgp send-extra-data zebra\n");
17032 /* BGP configuration. */
17033 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17035 /* skip all auto created vrf as they dont have user config */
17036 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17039 /* Router bgp ASN */
17040 vty_out(vty
, "router bgp %u", bgp
->as
);
17043 vty_out(vty
, " %s %s",
17044 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17045 ? "view" : "vrf", bgp
->name
);
17046 vty_out(vty
, "\n");
17048 /* BGP fast-external-failover. */
17049 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17050 vty_out(vty
, " no bgp fast-external-failover\n");
17052 /* BGP router ID. */
17053 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17054 vty_out(vty
, " bgp router-id %pI4\n",
17055 &bgp
->router_id_static
);
17057 /* Suppress fib pending */
17058 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17059 vty_out(vty
, " bgp suppress-fib-pending\n");
17061 /* BGP log-neighbor-changes. */
17062 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17063 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17064 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17065 CHECK_FLAG(bgp
->flags
,
17066 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17070 /* BGP configuration. */
17071 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17072 vty_out(vty
, " bgp always-compare-med\n");
17074 /* RFC8212 default eBGP policy. */
17075 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17076 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17077 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17078 CHECK_FLAG(bgp
->flags
,
17079 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17083 /* draft-ietf-idr-deprecate-as-set-confed-set */
17084 if (bgp
->reject_as_sets
)
17085 vty_out(vty
, " bgp reject-as-sets\n");
17087 /* Suppress duplicate updates if the route actually not changed
17089 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17090 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17091 vty_out(vty
, " %sbgp suppress-duplicates\n",
17092 CHECK_FLAG(bgp
->flags
,
17093 BGP_FLAG_SUPPRESS_DUPLICATES
)
17097 /* BGP default ipv4-unicast. */
17098 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
))
17099 vty_out(vty
, " no bgp default ipv4-unicast\n");
17101 /* BGP default local-preference. */
17102 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17103 vty_out(vty
, " bgp default local-preference %u\n",
17104 bgp
->default_local_pref
);
17106 /* BGP default show-hostname */
17107 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17108 != SAVE_BGP_SHOW_HOSTNAME
)
17109 vty_out(vty
, " %sbgp default show-hostname\n",
17110 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17114 /* BGP default show-nexthop-hostname */
17115 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17116 != SAVE_BGP_SHOW_HOSTNAME
)
17117 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17118 CHECK_FLAG(bgp
->flags
,
17119 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17123 /* BGP default subgroup-pkt-queue-max. */
17124 if (bgp
->default_subgroup_pkt_queue_max
17125 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17126 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17127 bgp
->default_subgroup_pkt_queue_max
);
17129 /* BGP client-to-client reflection. */
17130 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17131 vty_out(vty
, " no bgp client-to-client reflection\n");
17133 /* BGP cluster ID. */
17134 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17135 vty_out(vty
, " bgp cluster-id %pI4\n",
17138 /* Disable ebgp connected nexthop check */
17139 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17141 " bgp disable-ebgp-connected-route-check\n");
17143 /* Confederation identifier*/
17144 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17145 vty_out(vty
, " bgp confederation identifier %u\n",
17148 /* Confederation peer */
17149 if (bgp
->confed_peers_cnt
> 0) {
17152 vty_out(vty
, " bgp confederation peers");
17154 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17155 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17157 vty_out(vty
, "\n");
17160 /* BGP deterministic-med. */
17161 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17162 != SAVE_BGP_DETERMINISTIC_MED
)
17163 vty_out(vty
, " %sbgp deterministic-med\n",
17164 CHECK_FLAG(bgp
->flags
,
17165 BGP_FLAG_DETERMINISTIC_MED
)
17169 /* BGP update-delay. */
17170 bgp_config_write_update_delay(vty
, bgp
);
17172 if (bgp
->v_maxmed_onstartup
17173 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17174 vty_out(vty
, " bgp max-med on-startup %u",
17175 bgp
->v_maxmed_onstartup
);
17176 if (bgp
->maxmed_onstartup_value
17177 != BGP_MAXMED_VALUE_DEFAULT
)
17178 vty_out(vty
, " %u",
17179 bgp
->maxmed_onstartup_value
);
17180 vty_out(vty
, "\n");
17182 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17183 vty_out(vty
, " bgp max-med administrative");
17184 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17185 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17186 vty_out(vty
, "\n");
17190 bgp_config_write_wpkt_quanta(vty
, bgp
);
17192 bgp_config_write_rpkt_quanta(vty
, bgp
);
17194 /* coalesce time */
17195 bgp_config_write_coalesce_time(vty
, bgp
);
17197 /* BGP per-instance graceful-shutdown */
17198 /* BGP-wide settings and per-instance settings are mutually
17201 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17202 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17203 vty_out(vty
, " bgp graceful-shutdown\n");
17205 /* BGP graceful-restart. */
17206 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17208 " bgp graceful-restart stalepath-time %u\n",
17209 bgp
->stalepath_time
);
17211 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17212 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17213 bgp
->restart_time
);
17215 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17217 " bgp graceful-restart select-defer-time %u\n",
17218 bgp
->select_defer_time
);
17220 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17221 vty_out(vty
, " bgp graceful-restart\n");
17223 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17224 vty_out(vty
, " bgp graceful-restart-disable\n");
17226 /* BGP graceful-restart Preserve State F bit. */
17227 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17229 " bgp graceful-restart preserve-fw-state\n");
17231 /* Stale timer for RIB */
17232 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17234 " bgp graceful-restart rib-stale-time %u\n",
17235 bgp
->rib_stale_time
);
17237 /* BGP bestpath method. */
17238 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17239 vty_out(vty
, " bgp bestpath as-path ignore\n");
17240 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17241 vty_out(vty
, " bgp bestpath as-path confed\n");
17243 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17244 if (CHECK_FLAG(bgp
->flags
,
17245 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17247 " bgp bestpath as-path multipath-relax as-set\n");
17250 " bgp bestpath as-path multipath-relax\n");
17254 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17256 " bgp route-reflector allow-outbound-policy\n");
17258 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17259 vty_out(vty
, " bgp bestpath compare-routerid\n");
17260 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17261 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17262 vty_out(vty
, " bgp bestpath med");
17263 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17264 vty_out(vty
, " confed");
17265 if (CHECK_FLAG(bgp
->flags
,
17266 BGP_FLAG_MED_MISSING_AS_WORST
))
17267 vty_out(vty
, " missing-as-worst");
17268 vty_out(vty
, "\n");
17271 /* Link bandwidth handling. */
17272 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17273 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17274 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17275 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17276 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17277 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17279 /* BGP network import check. */
17280 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17281 != SAVE_BGP_IMPORT_CHECK
)
17282 vty_out(vty
, " %sbgp network import-check\n",
17283 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17287 /* BGP timers configuration. */
17288 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17289 && bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17290 vty_out(vty
, " timers bgp %u %u\n",
17291 bgp
->default_keepalive
, bgp
->default_holdtime
);
17294 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17295 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17298 /* Normal neighbor configuration. */
17299 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17300 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17301 bgp_config_write_peer_global(vty
, bgp
, peer
);
17304 /* listen range and limit for dynamic BGP neighbors */
17305 bgp_config_write_listen(vty
, bgp
);
17308 * BGP default autoshutdown neighbors
17310 * This must be placed after any peer and peer-group
17311 * configuration, to avoid setting all peers to shutdown after
17312 * a daemon restart, which is undesired behavior. (see #2286)
17314 if (bgp
->autoshutdown
)
17315 vty_out(vty
, " bgp default shutdown\n");
17317 /* BGP instance administrative shutdown */
17318 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17319 vty_out(vty
, " bgp shutdown\n");
17321 /* IPv4 unicast configuration. */
17322 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17324 /* IPv4 multicast configuration. */
17325 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17327 /* IPv4 labeled-unicast configuration. */
17328 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17330 /* IPv4 VPN configuration. */
17331 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17333 /* ENCAPv4 configuration. */
17334 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17336 /* FLOWSPEC v4 configuration. */
17337 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17339 /* IPv6 unicast configuration. */
17340 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17342 /* IPv6 multicast configuration. */
17343 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17345 /* IPv6 labeled-unicast configuration. */
17346 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17347 SAFI_LABELED_UNICAST
);
17349 /* IPv6 VPN configuration. */
17350 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17352 /* ENCAPv6 configuration. */
17353 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17355 /* FLOWSPEC v6 configuration. */
17356 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17358 /* EVPN configuration. */
17359 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17361 hook_call(bgp_inst_config_write
, bgp
, vty
);
17363 #ifdef ENABLE_BGP_VNC
17364 bgp_rfapi_cfg_write(vty
, bgp
);
17367 vty_out(vty
, "!\n");
17373 /* BGP node structure. */
17374 static struct cmd_node bgp_node
= {
17377 .parent_node
= CONFIG_NODE
,
17378 .prompt
= "%s(config-router)# ",
17379 .config_write
= bgp_config_write
,
17382 static struct cmd_node bgp_ipv4_unicast_node
= {
17383 .name
= "bgp ipv4 unicast",
17384 .node
= BGP_IPV4_NODE
,
17385 .parent_node
= BGP_NODE
,
17386 .prompt
= "%s(config-router-af)# ",
17389 static struct cmd_node bgp_ipv4_multicast_node
= {
17390 .name
= "bgp ipv4 multicast",
17391 .node
= BGP_IPV4M_NODE
,
17392 .parent_node
= BGP_NODE
,
17393 .prompt
= "%s(config-router-af)# ",
17396 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
17397 .name
= "bgp ipv4 labeled unicast",
17398 .node
= BGP_IPV4L_NODE
,
17399 .parent_node
= BGP_NODE
,
17400 .prompt
= "%s(config-router-af)# ",
17403 static struct cmd_node bgp_ipv6_unicast_node
= {
17404 .name
= "bgp ipv6",
17405 .node
= BGP_IPV6_NODE
,
17406 .parent_node
= BGP_NODE
,
17407 .prompt
= "%s(config-router-af)# ",
17410 static struct cmd_node bgp_ipv6_multicast_node
= {
17411 .name
= "bgp ipv6 multicast",
17412 .node
= BGP_IPV6M_NODE
,
17413 .parent_node
= BGP_NODE
,
17414 .prompt
= "%s(config-router-af)# ",
17417 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
17418 .name
= "bgp ipv6 labeled unicast",
17419 .node
= BGP_IPV6L_NODE
,
17420 .parent_node
= BGP_NODE
,
17421 .prompt
= "%s(config-router-af)# ",
17424 static struct cmd_node bgp_vpnv4_node
= {
17425 .name
= "bgp vpnv4",
17426 .node
= BGP_VPNV4_NODE
,
17427 .parent_node
= BGP_NODE
,
17428 .prompt
= "%s(config-router-af)# ",
17431 static struct cmd_node bgp_vpnv6_node
= {
17432 .name
= "bgp vpnv6",
17433 .node
= BGP_VPNV6_NODE
,
17434 .parent_node
= BGP_NODE
,
17435 .prompt
= "%s(config-router-af-vpnv6)# ",
17438 static struct cmd_node bgp_evpn_node
= {
17439 .name
= "bgp evpn",
17440 .node
= BGP_EVPN_NODE
,
17441 .parent_node
= BGP_NODE
,
17442 .prompt
= "%s(config-router-evpn)# ",
17445 static struct cmd_node bgp_evpn_vni_node
= {
17446 .name
= "bgp evpn vni",
17447 .node
= BGP_EVPN_VNI_NODE
,
17448 .parent_node
= BGP_EVPN_NODE
,
17449 .prompt
= "%s(config-router-af-vni)# ",
17452 static struct cmd_node bgp_flowspecv4_node
= {
17453 .name
= "bgp ipv4 flowspec",
17454 .node
= BGP_FLOWSPECV4_NODE
,
17455 .parent_node
= BGP_NODE
,
17456 .prompt
= "%s(config-router-af)# ",
17459 static struct cmd_node bgp_flowspecv6_node
= {
17460 .name
= "bgp ipv6 flowspec",
17461 .node
= BGP_FLOWSPECV6_NODE
,
17462 .parent_node
= BGP_NODE
,
17463 .prompt
= "%s(config-router-af-vpnv6)# ",
17466 static void community_list_vty(void);
17468 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
17472 struct listnode
*lnbgp
, *lnpeer
;
17474 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17475 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
17476 /* only provide suggestions on the appropriate input
17478 * they'll otherwise show up multiple times */
17479 enum cmd_token_type match_type
;
17480 char *name
= peer
->host
;
17482 if (peer
->conf_if
) {
17483 match_type
= VARIABLE_TKN
;
17484 name
= peer
->conf_if
;
17485 } else if (strchr(peer
->host
, ':'))
17486 match_type
= IPV6_TKN
;
17488 match_type
= IPV4_TKN
;
17490 if (token
->type
!= match_type
)
17493 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
17498 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
17499 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
17500 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
17501 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
17502 {.completions
= NULL
}};
17504 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
17507 struct peer_group
*group
;
17508 struct listnode
*lnbgp
, *lnpeer
;
17510 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17511 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
17512 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
17517 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
17518 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
17519 {.completions
= NULL
} };
17521 void bgp_vty_init(void)
17523 cmd_variable_handler_register(bgp_var_neighbor
);
17524 cmd_variable_handler_register(bgp_var_peergroup
);
17526 /* Install bgp top node. */
17527 install_node(&bgp_node
);
17528 install_node(&bgp_ipv4_unicast_node
);
17529 install_node(&bgp_ipv4_multicast_node
);
17530 install_node(&bgp_ipv4_labeled_unicast_node
);
17531 install_node(&bgp_ipv6_unicast_node
);
17532 install_node(&bgp_ipv6_multicast_node
);
17533 install_node(&bgp_ipv6_labeled_unicast_node
);
17534 install_node(&bgp_vpnv4_node
);
17535 install_node(&bgp_vpnv6_node
);
17536 install_node(&bgp_evpn_node
);
17537 install_node(&bgp_evpn_vni_node
);
17538 install_node(&bgp_flowspecv4_node
);
17539 install_node(&bgp_flowspecv6_node
);
17541 /* Install default VTY commands to new nodes. */
17542 install_default(BGP_NODE
);
17543 install_default(BGP_IPV4_NODE
);
17544 install_default(BGP_IPV4M_NODE
);
17545 install_default(BGP_IPV4L_NODE
);
17546 install_default(BGP_IPV6_NODE
);
17547 install_default(BGP_IPV6M_NODE
);
17548 install_default(BGP_IPV6L_NODE
);
17549 install_default(BGP_VPNV4_NODE
);
17550 install_default(BGP_VPNV6_NODE
);
17551 install_default(BGP_FLOWSPECV4_NODE
);
17552 install_default(BGP_FLOWSPECV6_NODE
);
17553 install_default(BGP_EVPN_NODE
);
17554 install_default(BGP_EVPN_VNI_NODE
);
17556 /* "bgp local-mac" hidden commands. */
17557 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
17558 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
17560 /* "bgp suppress-fib-pending" global */
17561 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
17563 /* bgp route-map delay-timer commands. */
17564 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17565 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17567 /* global bgp update-delay command */
17568 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
17569 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
17571 /* global bgp graceful-shutdown command */
17572 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
17573 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
17575 /* Dummy commands (Currently not supported) */
17576 install_element(BGP_NODE
, &no_synchronization_cmd
);
17577 install_element(BGP_NODE
, &no_auto_summary_cmd
);
17579 /* "router bgp" commands. */
17580 install_element(CONFIG_NODE
, &router_bgp_cmd
);
17582 /* "no router bgp" commands. */
17583 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
17585 /* "bgp router-id" commands. */
17586 install_element(BGP_NODE
, &bgp_router_id_cmd
);
17587 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
17589 /* "bgp suppress-fib-pending" command */
17590 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
17592 /* "bgp cluster-id" commands. */
17593 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
17594 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
17596 /* "bgp no-rib" commands. */
17597 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
17598 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
17600 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
17602 /* "bgp confederation" commands. */
17603 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
17604 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
17606 /* "bgp confederation peers" commands. */
17607 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
17608 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
17610 /* bgp max-med command */
17611 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
17612 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
17613 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
17614 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
17615 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
17617 /* bgp disable-ebgp-connected-nh-check */
17618 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
17619 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
17621 /* bgp update-delay command */
17622 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
17623 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
17625 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
17626 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
17628 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
17629 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
17631 /* "maximum-paths" commands. */
17632 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
17633 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
17634 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
17635 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
17636 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
17637 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
17638 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
17639 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
17640 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
17641 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
17642 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17643 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17644 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
17645 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17646 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17648 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
17649 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
17650 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17651 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17652 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17653 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
17654 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
17655 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17656 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17657 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17659 /* "timers bgp" commands. */
17660 install_element(BGP_NODE
, &bgp_timers_cmd
);
17661 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
17663 /* route-map delay-timer commands - per instance for backwards compat.
17665 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17666 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17668 /* "bgp client-to-client reflection" commands */
17669 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
17670 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
17672 /* "bgp always-compare-med" commands */
17673 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
17674 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
17676 /* bgp ebgp-requires-policy */
17677 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
17678 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
17680 /* bgp suppress-duplicates */
17681 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
17682 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
17684 /* bgp reject-as-sets */
17685 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
17686 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
17688 /* "bgp deterministic-med" commands */
17689 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
17690 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
17692 /* "bgp graceful-restart" command */
17693 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
17694 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
17696 /* "bgp graceful-restart-disable" command */
17697 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
17698 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
17700 /* "neighbor a:b:c:d graceful-restart" command */
17701 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
17702 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
17704 /* "neighbor a:b:c:d graceful-restart-disable" command */
17705 install_element(BGP_NODE
,
17706 &bgp_neighbor_graceful_restart_disable_set_cmd
);
17707 install_element(BGP_NODE
,
17708 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
17710 /* "neighbor a:b:c:d graceful-restart-helper" command */
17711 install_element(BGP_NODE
,
17712 &bgp_neighbor_graceful_restart_helper_set_cmd
);
17713 install_element(BGP_NODE
,
17714 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
17716 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
17717 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
17718 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
17719 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
17720 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
17721 install_element(BGP_NODE
,
17722 &no_bgp_graceful_restart_select_defer_time_cmd
);
17723 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
17724 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
17726 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
17727 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
17728 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
17729 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
17731 /* "bgp graceful-shutdown" commands */
17732 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
17733 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
17735 /* "bgp fast-external-failover" commands */
17736 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
17737 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
17739 /* "bgp bestpath compare-routerid" commands */
17740 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
17741 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
17743 /* "bgp bestpath as-path ignore" commands */
17744 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
17745 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
17747 /* "bgp bestpath as-path confed" commands */
17748 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
17749 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
17751 /* "bgp bestpath as-path multipath-relax" commands */
17752 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
17753 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
17755 /* "bgp log-neighbor-changes" commands */
17756 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
17757 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
17759 /* "bgp bestpath med" commands */
17760 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
17761 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
17763 /* "bgp bestpath bandwidth" commands */
17764 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
17765 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
17767 /* "no bgp default ipv4-unicast" commands. */
17768 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
17769 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
17771 /* "bgp network import-check" commands. */
17772 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
17773 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
17774 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
17776 /* "bgp default local-preference" commands. */
17777 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
17778 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
17780 /* bgp default show-hostname */
17781 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
17782 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
17784 /* bgp default show-nexthop-hostname */
17785 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
17786 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
17788 /* "bgp default subgroup-pkt-queue-max" commands. */
17789 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
17790 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
17792 /* bgp ibgp-allow-policy-mods command */
17793 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
17794 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
17796 /* "bgp listen limit" commands. */
17797 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
17798 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
17800 /* "bgp listen range" commands. */
17801 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
17802 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
17804 /* "bgp default shutdown" command */
17805 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
17807 /* "bgp shutdown" commands */
17808 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
17809 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
17810 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
17811 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
17813 /* "neighbor remote-as" commands. */
17814 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
17815 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
17816 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
17817 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
17818 install_element(BGP_NODE
,
17819 &neighbor_interface_v6only_config_remote_as_cmd
);
17820 install_element(BGP_NODE
, &no_neighbor_cmd
);
17821 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
17823 /* "neighbor peer-group" commands. */
17824 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
17825 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
17826 install_element(BGP_NODE
,
17827 &no_neighbor_interface_peer_group_remote_as_cmd
);
17829 /* "neighbor local-as" commands. */
17830 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
17831 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
17832 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
17833 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
17835 /* "neighbor solo" commands. */
17836 install_element(BGP_NODE
, &neighbor_solo_cmd
);
17837 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
17839 /* "neighbor password" commands. */
17840 install_element(BGP_NODE
, &neighbor_password_cmd
);
17841 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
17843 /* "neighbor activate" commands. */
17844 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
17845 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
17846 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
17847 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
17848 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
17849 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
17850 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
17851 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
17852 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
17853 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
17854 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
17855 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
17857 /* "no neighbor activate" commands. */
17858 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
17859 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
17860 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
17861 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
17862 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
17863 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
17864 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
17865 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
17866 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
17867 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
17868 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
17869 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
17871 /* "neighbor peer-group" set commands. */
17872 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
17873 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17874 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17875 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17876 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17877 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17878 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17879 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17880 install_element(BGP_FLOWSPECV4_NODE
,
17881 &neighbor_set_peer_group_hidden_cmd
);
17882 install_element(BGP_FLOWSPECV6_NODE
,
17883 &neighbor_set_peer_group_hidden_cmd
);
17885 /* "no neighbor peer-group unset" commands. */
17886 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
17887 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17888 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17889 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17890 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17891 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17892 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17893 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17894 install_element(BGP_FLOWSPECV4_NODE
,
17895 &no_neighbor_set_peer_group_hidden_cmd
);
17896 install_element(BGP_FLOWSPECV6_NODE
,
17897 &no_neighbor_set_peer_group_hidden_cmd
);
17899 /* "neighbor softreconfiguration inbound" commands.*/
17900 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
17901 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
17902 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
17903 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17904 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
17905 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17906 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
17907 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17908 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
17909 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17910 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
17911 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17912 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
17913 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17914 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
17915 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17916 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
17917 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17918 install_element(BGP_FLOWSPECV4_NODE
,
17919 &neighbor_soft_reconfiguration_cmd
);
17920 install_element(BGP_FLOWSPECV4_NODE
,
17921 &no_neighbor_soft_reconfiguration_cmd
);
17922 install_element(BGP_FLOWSPECV6_NODE
,
17923 &neighbor_soft_reconfiguration_cmd
);
17924 install_element(BGP_FLOWSPECV6_NODE
,
17925 &no_neighbor_soft_reconfiguration_cmd
);
17926 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
17927 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17929 /* "neighbor attribute-unchanged" commands. */
17930 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
17931 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
17932 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
17933 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
17934 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
17935 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
17936 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
17937 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
17938 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
17939 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
17940 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
17941 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
17942 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
17943 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
17944 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
17945 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
17946 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
17947 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
17949 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
17950 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
17952 /* "nexthop-local unchanged" commands */
17953 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
17954 install_element(BGP_IPV6_NODE
,
17955 &no_neighbor_nexthop_local_unchanged_cmd
);
17957 /* "neighbor next-hop-self" commands. */
17958 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
17959 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
17960 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
17961 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
17962 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
17963 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
17964 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
17965 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
17966 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
17967 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
17968 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
17969 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
17970 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
17971 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
17972 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
17973 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
17974 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
17975 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
17976 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
17977 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
17979 /* "neighbor next-hop-self force" commands. */
17980 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
17981 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
17982 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17983 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
17984 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
17985 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17986 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17987 install_element(BGP_IPV4_NODE
,
17988 &no_neighbor_nexthop_self_all_hidden_cmd
);
17989 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
17990 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17991 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17992 install_element(BGP_IPV4M_NODE
,
17993 &no_neighbor_nexthop_self_all_hidden_cmd
);
17994 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
17995 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17996 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17997 install_element(BGP_IPV4L_NODE
,
17998 &no_neighbor_nexthop_self_all_hidden_cmd
);
17999 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18000 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18001 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18002 install_element(BGP_IPV6_NODE
,
18003 &no_neighbor_nexthop_self_all_hidden_cmd
);
18004 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
18005 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18006 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18007 install_element(BGP_IPV6M_NODE
,
18008 &no_neighbor_nexthop_self_all_hidden_cmd
);
18009 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
18010 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18011 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18012 install_element(BGP_IPV6L_NODE
,
18013 &no_neighbor_nexthop_self_all_hidden_cmd
);
18014 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18015 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18016 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18017 install_element(BGP_VPNV4_NODE
,
18018 &no_neighbor_nexthop_self_all_hidden_cmd
);
18019 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18020 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18021 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18022 install_element(BGP_VPNV6_NODE
,
18023 &no_neighbor_nexthop_self_all_hidden_cmd
);
18024 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
18025 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18027 /* "neighbor as-override" commands. */
18028 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
18029 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
18030 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
18031 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
18032 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
18033 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
18034 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
18035 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
18036 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
18037 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
18038 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
18039 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
18040 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
18041 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
18042 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
18043 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
18044 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
18045 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
18047 /* "neighbor remove-private-AS" commands. */
18048 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
18049 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
18050 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
18051 install_element(BGP_NODE
,
18052 &no_neighbor_remove_private_as_all_hidden_cmd
);
18053 install_element(BGP_NODE
,
18054 &neighbor_remove_private_as_replace_as_hidden_cmd
);
18055 install_element(BGP_NODE
,
18056 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
18057 install_element(BGP_NODE
,
18058 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18061 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18062 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
18063 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18064 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18065 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18066 install_element(BGP_IPV4_NODE
,
18067 &neighbor_remove_private_as_replace_as_cmd
);
18068 install_element(BGP_IPV4_NODE
,
18069 &no_neighbor_remove_private_as_replace_as_cmd
);
18070 install_element(BGP_IPV4_NODE
,
18071 &neighbor_remove_private_as_all_replace_as_cmd
);
18072 install_element(BGP_IPV4_NODE
,
18073 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18074 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
18075 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
18076 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
18077 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18078 install_element(BGP_IPV4M_NODE
,
18079 &neighbor_remove_private_as_replace_as_cmd
);
18080 install_element(BGP_IPV4M_NODE
,
18081 &no_neighbor_remove_private_as_replace_as_cmd
);
18082 install_element(BGP_IPV4M_NODE
,
18083 &neighbor_remove_private_as_all_replace_as_cmd
);
18084 install_element(BGP_IPV4M_NODE
,
18085 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18086 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
18087 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
18088 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
18089 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18090 install_element(BGP_IPV4L_NODE
,
18091 &neighbor_remove_private_as_replace_as_cmd
);
18092 install_element(BGP_IPV4L_NODE
,
18093 &no_neighbor_remove_private_as_replace_as_cmd
);
18094 install_element(BGP_IPV4L_NODE
,
18095 &neighbor_remove_private_as_all_replace_as_cmd
);
18096 install_element(BGP_IPV4L_NODE
,
18097 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18098 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
18099 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18100 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18101 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18102 install_element(BGP_IPV6_NODE
,
18103 &neighbor_remove_private_as_replace_as_cmd
);
18104 install_element(BGP_IPV6_NODE
,
18105 &no_neighbor_remove_private_as_replace_as_cmd
);
18106 install_element(BGP_IPV6_NODE
,
18107 &neighbor_remove_private_as_all_replace_as_cmd
);
18108 install_element(BGP_IPV6_NODE
,
18109 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18110 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
18111 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
18112 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
18113 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18114 install_element(BGP_IPV6M_NODE
,
18115 &neighbor_remove_private_as_replace_as_cmd
);
18116 install_element(BGP_IPV6M_NODE
,
18117 &no_neighbor_remove_private_as_replace_as_cmd
);
18118 install_element(BGP_IPV6M_NODE
,
18119 &neighbor_remove_private_as_all_replace_as_cmd
);
18120 install_element(BGP_IPV6M_NODE
,
18121 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18122 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
18123 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
18124 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
18125 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18126 install_element(BGP_IPV6L_NODE
,
18127 &neighbor_remove_private_as_replace_as_cmd
);
18128 install_element(BGP_IPV6L_NODE
,
18129 &no_neighbor_remove_private_as_replace_as_cmd
);
18130 install_element(BGP_IPV6L_NODE
,
18131 &neighbor_remove_private_as_all_replace_as_cmd
);
18132 install_element(BGP_IPV6L_NODE
,
18133 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18134 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
18135 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18136 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18137 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18138 install_element(BGP_VPNV4_NODE
,
18139 &neighbor_remove_private_as_replace_as_cmd
);
18140 install_element(BGP_VPNV4_NODE
,
18141 &no_neighbor_remove_private_as_replace_as_cmd
);
18142 install_element(BGP_VPNV4_NODE
,
18143 &neighbor_remove_private_as_all_replace_as_cmd
);
18144 install_element(BGP_VPNV4_NODE
,
18145 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18146 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
18147 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18148 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18149 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18150 install_element(BGP_VPNV6_NODE
,
18151 &neighbor_remove_private_as_replace_as_cmd
);
18152 install_element(BGP_VPNV6_NODE
,
18153 &no_neighbor_remove_private_as_replace_as_cmd
);
18154 install_element(BGP_VPNV6_NODE
,
18155 &neighbor_remove_private_as_all_replace_as_cmd
);
18156 install_element(BGP_VPNV6_NODE
,
18157 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18159 /* "neighbor send-community" commands.*/
18160 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
18161 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
18162 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
18163 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
18164 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
18165 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
18166 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
18167 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
18168 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
18169 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
18170 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
18171 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
18172 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
18173 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
18174 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
18175 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
18176 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
18177 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
18178 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
18179 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
18180 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
18181 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
18182 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
18183 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
18184 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
18185 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
18186 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
18187 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
18188 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
18189 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
18190 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
18191 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
18192 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
18193 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
18194 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
18195 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
18197 /* "neighbor route-reflector" commands.*/
18198 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
18199 install_element(BGP_NODE
,
18200 &no_neighbor_route_reflector_client_hidden_cmd
);
18201 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
18202 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
18203 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
18204 install_element(BGP_IPV4M_NODE
,
18205 &no_neighbor_route_reflector_client_cmd
);
18206 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
18207 install_element(BGP_IPV4L_NODE
,
18208 &no_neighbor_route_reflector_client_cmd
);
18209 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
18210 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
18211 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
18212 install_element(BGP_IPV6M_NODE
,
18213 &no_neighbor_route_reflector_client_cmd
);
18214 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
18215 install_element(BGP_IPV6L_NODE
,
18216 &no_neighbor_route_reflector_client_cmd
);
18217 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
18218 install_element(BGP_VPNV4_NODE
,
18219 &no_neighbor_route_reflector_client_cmd
);
18220 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
18221 install_element(BGP_VPNV6_NODE
,
18222 &no_neighbor_route_reflector_client_cmd
);
18223 install_element(BGP_FLOWSPECV4_NODE
,
18224 &neighbor_route_reflector_client_cmd
);
18225 install_element(BGP_FLOWSPECV4_NODE
,
18226 &no_neighbor_route_reflector_client_cmd
);
18227 install_element(BGP_FLOWSPECV6_NODE
,
18228 &neighbor_route_reflector_client_cmd
);
18229 install_element(BGP_FLOWSPECV6_NODE
,
18230 &no_neighbor_route_reflector_client_cmd
);
18231 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
18232 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
18234 /* "neighbor route-server" commands.*/
18235 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
18236 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
18237 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
18238 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
18239 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
18240 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
18241 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
18242 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
18243 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
18244 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
18245 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
18246 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
18247 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
18248 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
18249 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
18250 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
18251 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
18252 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
18253 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
18254 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
18255 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
18256 install_element(BGP_FLOWSPECV4_NODE
,
18257 &no_neighbor_route_server_client_cmd
);
18258 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
18259 install_element(BGP_FLOWSPECV6_NODE
,
18260 &no_neighbor_route_server_client_cmd
);
18262 /* "neighbor addpath-tx-all-paths" commands.*/
18263 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
18264 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
18265 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18266 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18267 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18268 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18269 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18270 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18271 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18272 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18273 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18274 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18275 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18276 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18277 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18278 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18279 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18280 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18282 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
18283 install_element(BGP_NODE
,
18284 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18285 install_element(BGP_NODE
,
18286 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18287 install_element(BGP_IPV4_NODE
,
18288 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18289 install_element(BGP_IPV4_NODE
,
18290 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18291 install_element(BGP_IPV4M_NODE
,
18292 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18293 install_element(BGP_IPV4M_NODE
,
18294 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18295 install_element(BGP_IPV4L_NODE
,
18296 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18297 install_element(BGP_IPV4L_NODE
,
18298 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18299 install_element(BGP_IPV6_NODE
,
18300 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18301 install_element(BGP_IPV6_NODE
,
18302 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18303 install_element(BGP_IPV6M_NODE
,
18304 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18305 install_element(BGP_IPV6M_NODE
,
18306 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18307 install_element(BGP_IPV6L_NODE
,
18308 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18309 install_element(BGP_IPV6L_NODE
,
18310 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18311 install_element(BGP_VPNV4_NODE
,
18312 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18313 install_element(BGP_VPNV4_NODE
,
18314 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18315 install_element(BGP_VPNV6_NODE
,
18316 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18317 install_element(BGP_VPNV6_NODE
,
18318 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18320 /* "neighbor sender-as-path-loop-detection" commands. */
18321 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
18322 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
18324 /* "neighbor passive" commands. */
18325 install_element(BGP_NODE
, &neighbor_passive_cmd
);
18326 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
18329 /* "neighbor shutdown" commands. */
18330 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
18331 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
18332 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
18333 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
18334 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
18335 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
18337 /* "neighbor capability extended-nexthop" commands.*/
18338 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
18339 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
18341 /* "neighbor capability orf prefix-list" commands.*/
18342 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
18343 install_element(BGP_NODE
,
18344 &no_neighbor_capability_orf_prefix_hidden_cmd
);
18345 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
18346 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18347 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18348 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18349 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18350 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18351 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
18352 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18353 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18354 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18355 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18356 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18358 /* "neighbor capability dynamic" commands.*/
18359 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
18360 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
18362 /* "neighbor dont-capability-negotiate" commands. */
18363 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
18364 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
18366 /* "neighbor ebgp-multihop" commands. */
18367 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
18368 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
18369 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
18371 /* "neighbor disable-connected-check" commands. */
18372 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
18373 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
18375 /* "neighbor enforce-first-as" commands. */
18376 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
18377 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
18379 /* "neighbor description" commands. */
18380 install_element(BGP_NODE
, &neighbor_description_cmd
);
18381 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
18382 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
18384 /* "neighbor update-source" commands. "*/
18385 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
18386 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
18388 /* "neighbor default-originate" commands. */
18389 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
18390 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
18391 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
18392 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
18393 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
18394 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
18395 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
18396 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
18397 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
18398 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
18399 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
18400 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
18401 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
18402 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
18403 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
18404 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
18405 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
18406 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
18407 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
18408 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
18409 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
18411 /* "neighbor port" commands. */
18412 install_element(BGP_NODE
, &neighbor_port_cmd
);
18413 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
18415 /* "neighbor weight" commands. */
18416 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
18417 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
18419 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
18420 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
18421 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
18422 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
18423 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
18424 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
18425 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
18426 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
18427 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
18428 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
18429 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
18430 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
18431 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
18432 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
18433 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
18434 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
18436 /* "neighbor override-capability" commands. */
18437 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
18438 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
18440 /* "neighbor strict-capability-match" commands. */
18441 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
18442 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
18444 /* "neighbor timers" commands. */
18445 install_element(BGP_NODE
, &neighbor_timers_cmd
);
18446 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
18448 /* "neighbor timers connect" commands. */
18449 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
18450 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
18452 /* "neighbor timers delayopen" commands. */
18453 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
18454 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
18456 /* "neighbor advertisement-interval" commands. */
18457 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
18458 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
18460 /* "neighbor interface" commands. */
18461 install_element(BGP_NODE
, &neighbor_interface_cmd
);
18462 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
18464 /* "neighbor distribute" commands. */
18465 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
18466 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
18467 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
18468 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
18469 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
18470 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
18471 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
18472 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
18473 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
18474 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
18475 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
18476 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
18477 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
18478 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
18479 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
18480 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
18481 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
18482 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
18484 /* "neighbor prefix-list" commands. */
18485 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
18486 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
18487 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
18488 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
18489 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
18490 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
18491 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
18492 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
18493 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
18494 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
18495 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
18496 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
18497 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
18498 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
18499 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
18500 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
18501 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
18502 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
18503 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
18504 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
18505 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
18506 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
18508 /* "neighbor filter-list" commands. */
18509 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
18510 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
18511 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
18512 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
18513 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
18514 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
18515 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
18516 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
18517 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
18518 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
18519 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
18520 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
18521 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
18522 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
18523 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
18524 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
18525 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
18526 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
18527 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
18528 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
18529 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
18530 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
18532 /* "neighbor route-map" commands. */
18533 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
18534 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
18535 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
18536 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
18537 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
18538 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
18539 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
18540 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
18541 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
18542 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
18543 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
18544 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
18545 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
18546 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
18547 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
18548 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
18549 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
18550 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
18551 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
18552 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
18553 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
18554 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
18555 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
18556 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
18558 /* "neighbor unsuppress-map" commands. */
18559 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
18560 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
18561 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
18562 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18563 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
18564 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18565 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
18566 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18567 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
18568 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18569 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
18570 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18571 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
18572 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18573 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
18574 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18575 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
18576 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18578 /* "neighbor advertise-map" commands. */
18579 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
18580 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
18581 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
18582 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
18583 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
18584 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
18585 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
18586 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
18587 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
18589 /* neighbor maximum-prefix-out commands. */
18590 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
18591 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18592 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18593 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18594 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18595 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18596 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18597 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18598 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18599 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18600 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18601 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18602 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18603 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18604 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18605 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18606 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18607 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18609 /* "neighbor maximum-prefix" commands. */
18610 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
18611 install_element(BGP_NODE
,
18612 &neighbor_maximum_prefix_threshold_hidden_cmd
);
18613 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
18614 install_element(BGP_NODE
,
18615 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
18616 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
18617 install_element(BGP_NODE
,
18618 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
18619 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
18620 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
18621 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18622 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18623 install_element(BGP_IPV4_NODE
,
18624 &neighbor_maximum_prefix_threshold_warning_cmd
);
18625 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18626 install_element(BGP_IPV4_NODE
,
18627 &neighbor_maximum_prefix_threshold_restart_cmd
);
18628 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18629 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
18630 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18631 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18632 install_element(BGP_IPV4M_NODE
,
18633 &neighbor_maximum_prefix_threshold_warning_cmd
);
18634 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18635 install_element(BGP_IPV4M_NODE
,
18636 &neighbor_maximum_prefix_threshold_restart_cmd
);
18637 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18638 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
18639 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18640 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18641 install_element(BGP_IPV4L_NODE
,
18642 &neighbor_maximum_prefix_threshold_warning_cmd
);
18643 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18644 install_element(BGP_IPV4L_NODE
,
18645 &neighbor_maximum_prefix_threshold_restart_cmd
);
18646 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18647 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
18648 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18649 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18650 install_element(BGP_IPV6_NODE
,
18651 &neighbor_maximum_prefix_threshold_warning_cmd
);
18652 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18653 install_element(BGP_IPV6_NODE
,
18654 &neighbor_maximum_prefix_threshold_restart_cmd
);
18655 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18656 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
18657 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18658 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18659 install_element(BGP_IPV6M_NODE
,
18660 &neighbor_maximum_prefix_threshold_warning_cmd
);
18661 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18662 install_element(BGP_IPV6M_NODE
,
18663 &neighbor_maximum_prefix_threshold_restart_cmd
);
18664 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18665 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
18666 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18667 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18668 install_element(BGP_IPV6L_NODE
,
18669 &neighbor_maximum_prefix_threshold_warning_cmd
);
18670 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18671 install_element(BGP_IPV6L_NODE
,
18672 &neighbor_maximum_prefix_threshold_restart_cmd
);
18673 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18674 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
18675 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18676 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18677 install_element(BGP_VPNV4_NODE
,
18678 &neighbor_maximum_prefix_threshold_warning_cmd
);
18679 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18680 install_element(BGP_VPNV4_NODE
,
18681 &neighbor_maximum_prefix_threshold_restart_cmd
);
18682 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18683 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
18684 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18685 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18686 install_element(BGP_VPNV6_NODE
,
18687 &neighbor_maximum_prefix_threshold_warning_cmd
);
18688 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18689 install_element(BGP_VPNV6_NODE
,
18690 &neighbor_maximum_prefix_threshold_restart_cmd
);
18691 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18693 /* "neighbor allowas-in" */
18694 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
18695 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
18696 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
18697 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
18698 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
18699 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
18700 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
18701 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
18702 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
18703 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
18704 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
18705 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
18706 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
18707 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
18708 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
18709 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
18710 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
18711 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
18712 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
18713 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
18715 /* address-family commands. */
18716 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
18717 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
18718 #ifdef KEEP_OLD_VPN_COMMANDS
18719 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
18720 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
18721 #endif /* KEEP_OLD_VPN_COMMANDS */
18723 install_element(BGP_NODE
, &address_family_evpn_cmd
);
18725 /* "exit-address-family" command. */
18726 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
18727 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
18728 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
18729 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
18730 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
18731 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
18732 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
18733 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
18734 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
18735 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
18736 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
18738 /* "clear ip bgp commands" */
18739 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
18741 /* clear ip bgp prefix */
18742 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
18743 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
18744 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
18746 /* "show [ip] bgp summary" commands. */
18747 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
18748 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
18749 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
18750 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
18751 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
18752 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
18753 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
18755 /* "show [ip] bgp neighbors" commands. */
18756 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
18758 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
18760 /* "show [ip] bgp peer-group" commands. */
18761 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
18763 /* "show [ip] bgp paths" commands. */
18764 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
18766 /* "show [ip] bgp community" commands. */
18767 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
18769 /* "show ip bgp large-community" commands. */
18770 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
18771 /* "show [ip] bgp attribute-info" commands. */
18772 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
18773 /* "show [ip] bgp route-leak" command */
18774 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
18776 /* "redistribute" commands. */
18777 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
18778 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
18779 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
18780 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
18781 install_element(BGP_NODE
,
18782 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
18783 install_element(BGP_NODE
,
18784 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
18785 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
18786 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
18787 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
18788 install_element(BGP_NODE
,
18789 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
18790 install_element(BGP_NODE
,
18791 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
18792 install_element(BGP_NODE
,
18793 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
18794 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
18795 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
18796 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
18797 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
18798 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
18799 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
18800 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
18801 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
18802 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
18803 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
18804 install_element(BGP_IPV4_NODE
,
18805 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
18806 install_element(BGP_IPV4_NODE
,
18807 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
18808 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
18809 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
18810 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
18811 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
18812 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
18813 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
18815 /* import|export vpn [route-map WORD] */
18816 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
18817 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
18819 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
18820 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
18822 /* ttl_security commands */
18823 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
18824 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
18826 /* "show [ip] bgp memory" commands. */
18827 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
18829 /* "show bgp martian next-hop" */
18830 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
18832 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
18834 /* "show [ip] bgp views" commands. */
18835 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
18837 /* "show [ip] bgp vrfs" commands. */
18838 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
18840 /* Community-list. */
18841 community_list_vty();
18843 /* vpn-policy commands */
18844 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
18845 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
18846 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
18847 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
18848 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
18849 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
18850 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
18851 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
18852 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
18853 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
18854 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
18855 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
18857 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
18858 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
18860 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
18861 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
18862 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
18863 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
18864 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
18865 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
18866 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
18867 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
18868 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
18869 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
18872 #include "memory.h"
18873 #include "bgp_regex.h"
18874 #include "bgp_clist.h"
18875 #include "bgp_ecommunity.h"
18877 /* VTY functions. */
18879 /* Direction value to string conversion. */
18880 static const char *community_direct_str(int direct
)
18883 case COMMUNITY_DENY
:
18885 case COMMUNITY_PERMIT
:
18892 /* Display error string. */
18893 static void community_list_perror(struct vty
*vty
, int ret
)
18896 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
18897 vty_out(vty
, "%% Can't find community-list\n");
18899 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
18900 vty_out(vty
, "%% Malformed community-list value\n");
18902 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
18904 "%% Community name conflict, previously defined as standard community\n");
18906 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
18908 "%% Community name conflict, previously defined as expanded community\n");
18913 /* "community-list" keyword help string. */
18914 #define COMMUNITY_LIST_STR "Add a community list entry\n"
18916 /*community-list standard */
18917 DEFUN (community_list_standard
,
18918 bgp_community_list_standard_cmd
,
18919 "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
18922 "Community list number (standard)\n"
18923 "Add an standard community-list entry\n"
18924 "Community list name\n"
18925 "Sequence number of an entry\n"
18926 "Sequence number\n"
18927 "Specify community to reject\n"
18928 "Specify community to accept\n"
18931 char *cl_name_or_number
= NULL
;
18934 int style
= COMMUNITY_LIST_STANDARD
;
18937 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
18939 seq
= argv
[idx
]->arg
;
18942 argv_find(argv
, argc
, "(1-99)", &idx
);
18943 argv_find(argv
, argc
, "WORD", &idx
);
18944 cl_name_or_number
= argv
[idx
]->arg
;
18945 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
18947 argv_find(argv
, argc
, "AA:NN", &idx
);
18948 char *str
= argv_concat(argv
, argc
, idx
);
18950 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
18953 XFREE(MTYPE_TMP
, str
);
18956 /* Display error string. */
18957 community_list_perror(vty
, ret
);
18958 return CMD_WARNING_CONFIG_FAILED
;
18961 return CMD_SUCCESS
;
18964 DEFUN (no_community_list_standard_all
,
18965 no_bgp_community_list_standard_all_cmd
,
18966 "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
18970 "Community list number (standard)\n"
18971 "Add an standard community-list entry\n"
18972 "Community list name\n"
18973 "Sequence number of an entry\n"
18974 "Sequence number\n"
18975 "Specify community to reject\n"
18976 "Specify community to accept\n"
18979 char *cl_name_or_number
= NULL
;
18982 int style
= COMMUNITY_LIST_STANDARD
;
18986 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
18988 seq
= argv
[idx
]->arg
;
18991 argv_find(argv
, argc
, "permit", &idx
);
18992 argv_find(argv
, argc
, "deny", &idx
);
18995 direct
= argv_find(argv
, argc
, "permit", &idx
)
19000 argv_find(argv
, argc
, "AA:NN", &idx
);
19001 str
= argv_concat(argv
, argc
, idx
);
19005 argv_find(argv
, argc
, "(1-99)", &idx
);
19006 argv_find(argv
, argc
, "WORD", &idx
);
19007 cl_name_or_number
= argv
[idx
]->arg
;
19009 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19012 XFREE(MTYPE_TMP
, str
);
19015 community_list_perror(vty
, ret
);
19016 return CMD_WARNING_CONFIG_FAILED
;
19019 return CMD_SUCCESS
;
19022 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
19023 "no bgp community-list <(1-99)|standard WORD>",
19024 NO_STR BGP_STR COMMUNITY_LIST_STR
19025 "Community list number (standard)\n"
19026 "Add an standard community-list entry\n"
19027 "Community list name\n")
19029 /*community-list expanded */
19030 DEFUN (community_list_expanded_all
,
19031 bgp_community_list_expanded_all_cmd
,
19032 "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19035 "Community list number (expanded)\n"
19036 "Add an expanded community-list entry\n"
19037 "Community list name\n"
19038 "Sequence number of an entry\n"
19039 "Sequence number\n"
19040 "Specify community to reject\n"
19041 "Specify community to accept\n"
19044 char *cl_name_or_number
= NULL
;
19047 int style
= COMMUNITY_LIST_EXPANDED
;
19050 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
19052 seq
= argv
[idx
]->arg
;
19056 argv_find(argv
, argc
, "(100-500)", &idx
);
19057 argv_find(argv
, argc
, "WORD", &idx
);
19058 cl_name_or_number
= argv
[idx
]->arg
;
19059 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19061 argv_find(argv
, argc
, "AA:NN", &idx
);
19062 char *str
= argv_concat(argv
, argc
, idx
);
19064 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19067 XFREE(MTYPE_TMP
, str
);
19070 /* Display error string. */
19071 community_list_perror(vty
, ret
);
19072 return CMD_WARNING_CONFIG_FAILED
;
19075 return CMD_SUCCESS
;
19078 DEFUN (no_community_list_expanded_all
,
19079 no_bgp_community_list_expanded_all_cmd
,
19080 "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19084 "Community list number (expanded)\n"
19085 "Add an expanded community-list entry\n"
19086 "Community list name\n"
19087 "Sequence number of an entry\n"
19088 "Sequence number\n"
19089 "Specify community to reject\n"
19090 "Specify community to accept\n"
19093 char *cl_name_or_number
= NULL
;
19097 int style
= COMMUNITY_LIST_EXPANDED
;
19100 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
19102 seq
= argv
[idx
]->arg
;
19105 argv_find(argv
, argc
, "permit", &idx
);
19106 argv_find(argv
, argc
, "deny", &idx
);
19109 direct
= argv_find(argv
, argc
, "permit", &idx
)
19114 argv_find(argv
, argc
, "AA:NN", &idx
);
19115 str
= argv_concat(argv
, argc
, idx
);
19119 argv_find(argv
, argc
, "(100-500)", &idx
);
19120 argv_find(argv
, argc
, "WORD", &idx
);
19121 cl_name_or_number
= argv
[idx
]->arg
;
19123 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19126 XFREE(MTYPE_TMP
, str
);
19129 community_list_perror(vty
, ret
);
19130 return CMD_WARNING_CONFIG_FAILED
;
19133 return CMD_SUCCESS
;
19136 ALIAS(no_community_list_expanded_all
,
19137 no_bgp_community_list_expanded_all_list_cmd
,
19138 "no bgp community-list <(100-500)|expanded WORD>",
19139 NO_STR BGP_STR COMMUNITY_LIST_STR
19140 "Community list number (expanded)\n"
19141 "Add an expanded community-list entry\n"
19142 "Community list name\n")
19144 /* Return configuration string of community-list entry. */
19145 static const char *community_list_config_str(struct community_entry
*entry
)
19152 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
19153 str
= community_str(entry
->u
.com
, false);
19154 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
19155 str
= lcommunity_str(entry
->u
.lcom
, false);
19157 str
= entry
->config
;
19162 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
19164 struct community_entry
*entry
;
19166 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19167 if (entry
== list
->head
) {
19168 if (all_digit(list
->name
))
19169 vty_out(vty
, "Community %s list %s\n",
19170 entry
->style
== COMMUNITY_LIST_STANDARD
19172 : "(expanded) access",
19175 vty_out(vty
, "Named Community %s list %s\n",
19176 entry
->style
== COMMUNITY_LIST_STANDARD
19182 vty_out(vty
, " %s\n",
19183 community_direct_str(entry
->direct
));
19185 vty_out(vty
, " %s %s\n",
19186 community_direct_str(entry
->direct
),
19187 community_list_config_str(entry
));
19191 DEFUN (show_community_list
,
19192 show_bgp_community_list_cmd
,
19193 "show bgp community-list",
19196 "List community-list\n")
19198 struct community_list
*list
;
19199 struct community_list_master
*cm
;
19201 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19203 return CMD_SUCCESS
;
19205 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19206 community_list_show(vty
, list
);
19208 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19209 community_list_show(vty
, list
);
19211 return CMD_SUCCESS
;
19214 DEFUN (show_community_list_arg
,
19215 show_bgp_community_list_arg_cmd
,
19216 "show bgp community-list <(1-500)|WORD> detail",
19219 "List community-list\n"
19220 "Community-list number\n"
19221 "Community-list name\n"
19222 "Detailed information on community-list\n")
19224 int idx_comm_list
= 3;
19225 struct community_list
*list
;
19227 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
19228 COMMUNITY_LIST_MASTER
);
19230 vty_out(vty
, "%% Can't find community-list\n");
19231 return CMD_WARNING
;
19234 community_list_show(vty
, list
);
19236 return CMD_SUCCESS
;
19240 * Large Community code.
19242 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
19243 struct cmd_token
**argv
, int style
,
19244 int reject_all_digit_name
)
19253 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19254 seq
= argv
[idx
]->arg
;
19257 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19260 /* All digit name check. */
19262 argv_find(argv
, argc
, "WORD", &idx
);
19263 argv_find(argv
, argc
, "(1-99)", &idx
);
19264 argv_find(argv
, argc
, "(100-500)", &idx
);
19265 cl_name
= argv
[idx
]->arg
;
19266 if (reject_all_digit_name
&& all_digit(cl_name
)) {
19267 vty_out(vty
, "%% Community name cannot have all digits\n");
19268 return CMD_WARNING_CONFIG_FAILED
;
19272 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
19273 argv_find(argv
, argc
, "LINE", &idx
);
19274 /* Concat community string argument. */
19276 str
= argv_concat(argv
, argc
, idx
);
19280 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
19282 /* Free temporary community list string allocated by
19284 XFREE(MTYPE_TMP
, str
);
19287 community_list_perror(vty
, ret
);
19288 return CMD_WARNING_CONFIG_FAILED
;
19290 return CMD_SUCCESS
;
19293 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
19294 struct cmd_token
**argv
, int style
)
19302 if (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 /* Check the list direct. */
19311 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
19312 direct
= COMMUNITY_PERMIT
;
19314 direct
= COMMUNITY_DENY
;
19317 argv_find(argv
, argc
, "LINE", &idx
);
19318 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
19319 /* Concat community string argument. */
19320 str
= argv_concat(argv
, argc
, idx
);
19324 argv_find(argv
, argc
, "(1-99)", &idx
);
19325 argv_find(argv
, argc
, "(100-500)", &idx
);
19326 argv_find(argv
, argc
, "WORD", &idx
);
19328 /* Unset community list. */
19329 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
19332 /* Free temporary community list string allocated by
19334 XFREE(MTYPE_TMP
, str
);
19337 community_list_perror(vty
, ret
);
19338 return CMD_WARNING_CONFIG_FAILED
;
19341 return CMD_SUCCESS
;
19344 /* "large-community-list" keyword help string. */
19345 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
19346 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
19348 DEFUN (lcommunity_list_standard
,
19349 bgp_lcommunity_list_standard_cmd
,
19350 "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...",
19352 LCOMMUNITY_LIST_STR
19353 "Large Community list number (standard)\n"
19354 "Sequence number of an entry\n"
19355 "Sequence number\n"
19356 "Specify large community to reject\n"
19357 "Specify large community to accept\n"
19358 LCOMMUNITY_VAL_STR
)
19360 return lcommunity_list_set_vty(vty
, argc
, argv
,
19361 LARGE_COMMUNITY_LIST_STANDARD
, 0);
19364 DEFUN (lcommunity_list_expanded
,
19365 bgp_lcommunity_list_expanded_cmd
,
19366 "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...",
19368 LCOMMUNITY_LIST_STR
19369 "Large Community list number (expanded)\n"
19370 "Sequence number of an entry\n"
19371 "Sequence number\n"
19372 "Specify large community to reject\n"
19373 "Specify large community to accept\n"
19374 "An ordered list as a regular-expression\n")
19376 return lcommunity_list_set_vty(vty
, argc
, argv
,
19377 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
19380 DEFUN (lcommunity_list_name_standard
,
19381 bgp_lcommunity_list_name_standard_cmd
,
19382 "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...",
19384 LCOMMUNITY_LIST_STR
19385 "Specify standard large-community-list\n"
19386 "Large Community list name\n"
19387 "Sequence number of an entry\n"
19388 "Sequence number\n"
19389 "Specify large community to reject\n"
19390 "Specify large community to accept\n"
19391 LCOMMUNITY_VAL_STR
)
19393 return lcommunity_list_set_vty(vty
, argc
, argv
,
19394 LARGE_COMMUNITY_LIST_STANDARD
, 1);
19397 DEFUN (lcommunity_list_name_expanded
,
19398 bgp_lcommunity_list_name_expanded_cmd
,
19399 "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...",
19401 LCOMMUNITY_LIST_STR
19402 "Specify expanded large-community-list\n"
19403 "Large Community list name\n"
19404 "Sequence number of an entry\n"
19405 "Sequence number\n"
19406 "Specify large community to reject\n"
19407 "Specify large community to accept\n"
19408 "An ordered list as a regular-expression\n")
19410 return lcommunity_list_set_vty(vty
, argc
, argv
,
19411 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
19414 DEFUN (no_lcommunity_list_all
,
19415 no_bgp_lcommunity_list_all_cmd
,
19416 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
19419 LCOMMUNITY_LIST_STR
19420 "Large Community list number (standard)\n"
19421 "Large Community list number (expanded)\n"
19422 "Large Community list name\n")
19424 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19425 LARGE_COMMUNITY_LIST_STANDARD
);
19428 DEFUN (no_lcommunity_list_name_standard_all
,
19429 no_bgp_lcommunity_list_name_standard_all_cmd
,
19430 "no bgp large-community-list standard WORD",
19433 LCOMMUNITY_LIST_STR
19434 "Specify standard large-community-list\n"
19435 "Large Community list name\n")
19437 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19438 LARGE_COMMUNITY_LIST_STANDARD
);
19441 DEFUN (no_lcommunity_list_name_expanded_all
,
19442 no_bgp_lcommunity_list_name_expanded_all_cmd
,
19443 "no bgp large-community-list expanded WORD",
19446 LCOMMUNITY_LIST_STR
19447 "Specify expanded large-community-list\n"
19448 "Large Community list name\n")
19450 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19451 LARGE_COMMUNITY_LIST_EXPANDED
);
19454 DEFUN (no_lcommunity_list_standard
,
19455 no_bgp_lcommunity_list_standard_cmd
,
19456 "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...",
19459 LCOMMUNITY_LIST_STR
19460 "Large Community list number (standard)\n"
19461 "Sequence number of an entry\n"
19462 "Sequence number\n"
19463 "Specify large community to reject\n"
19464 "Specify large community to accept\n"
19465 LCOMMUNITY_VAL_STR
)
19467 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19468 LARGE_COMMUNITY_LIST_STANDARD
);
19471 DEFUN (no_lcommunity_list_expanded
,
19472 no_bgp_lcommunity_list_expanded_cmd
,
19473 "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...",
19476 LCOMMUNITY_LIST_STR
19477 "Large Community list number (expanded)\n"
19478 "Sequence number of an entry\n"
19479 "Sequence number\n"
19480 "Specify large community to reject\n"
19481 "Specify large community to accept\n"
19482 "An ordered list as a regular-expression\n")
19484 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19485 LARGE_COMMUNITY_LIST_EXPANDED
);
19488 DEFUN (no_lcommunity_list_name_standard
,
19489 no_bgp_lcommunity_list_name_standard_cmd
,
19490 "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...",
19493 LCOMMUNITY_LIST_STR
19494 "Specify standard large-community-list\n"
19495 "Large Community list name\n"
19496 "Sequence number of an entry\n"
19497 "Sequence number\n"
19498 "Specify large community to reject\n"
19499 "Specify large community to accept\n"
19500 LCOMMUNITY_VAL_STR
)
19502 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19503 LARGE_COMMUNITY_LIST_STANDARD
);
19506 DEFUN (no_lcommunity_list_name_expanded
,
19507 no_bgp_lcommunity_list_name_expanded_cmd
,
19508 "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...",
19511 LCOMMUNITY_LIST_STR
19512 "Specify expanded large-community-list\n"
19513 "Large community list name\n"
19514 "Sequence number of an entry\n"
19515 "Sequence number\n"
19516 "Specify large community to reject\n"
19517 "Specify large community to accept\n"
19518 "An ordered list as a regular-expression\n")
19520 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19521 LARGE_COMMUNITY_LIST_EXPANDED
);
19524 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
19526 struct community_entry
*entry
;
19528 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19529 if (entry
== list
->head
) {
19530 if (all_digit(list
->name
))
19531 vty_out(vty
, "Large community %s list %s\n",
19533 LARGE_COMMUNITY_LIST_STANDARD
19535 : "(expanded) access",
19539 "Named large community %s list %s\n",
19541 LARGE_COMMUNITY_LIST_STANDARD
19547 vty_out(vty
, " %s\n",
19548 community_direct_str(entry
->direct
));
19550 vty_out(vty
, " %s %s\n",
19551 community_direct_str(entry
->direct
),
19552 community_list_config_str(entry
));
19556 DEFUN (show_lcommunity_list
,
19557 show_bgp_lcommunity_list_cmd
,
19558 "show bgp large-community-list",
19561 "List large-community list\n")
19563 struct community_list
*list
;
19564 struct community_list_master
*cm
;
19566 cm
= community_list_master_lookup(bgp_clist
,
19567 LARGE_COMMUNITY_LIST_MASTER
);
19569 return CMD_SUCCESS
;
19571 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19572 lcommunity_list_show(vty
, list
);
19574 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19575 lcommunity_list_show(vty
, list
);
19577 return CMD_SUCCESS
;
19580 DEFUN (show_lcommunity_list_arg
,
19581 show_bgp_lcommunity_list_arg_cmd
,
19582 "show bgp large-community-list <(1-500)|WORD> detail",
19585 "List large-community list\n"
19586 "Large-community-list number\n"
19587 "Large-community-list name\n"
19588 "Detailed information on large-community-list\n")
19590 struct community_list
*list
;
19592 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
19593 LARGE_COMMUNITY_LIST_MASTER
);
19595 vty_out(vty
, "%% Can't find large-community-list\n");
19596 return CMD_WARNING
;
19599 lcommunity_list_show(vty
, list
);
19601 return CMD_SUCCESS
;
19604 /* "extcommunity-list" keyword help string. */
19605 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
19606 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
19608 DEFUN (extcommunity_list_standard
,
19609 bgp_extcommunity_list_standard_cmd
,
19610 "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19612 EXTCOMMUNITY_LIST_STR
19613 "Extended Community list number (standard)\n"
19614 "Specify standard extcommunity-list\n"
19615 "Community list name\n"
19616 "Sequence number of an entry\n"
19617 "Sequence number\n"
19618 "Specify community to reject\n"
19619 "Specify community to accept\n"
19620 EXTCOMMUNITY_VAL_STR
)
19622 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19624 char *cl_number_or_name
= NULL
;
19629 argv_find(argv
, argc
, "(1-99)", &idx
);
19630 argv_find(argv
, argc
, "WORD", &idx
);
19631 cl_number_or_name
= argv
[idx
]->arg
;
19633 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19634 seq
= argv
[idx
]->arg
;
19636 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19638 argv_find(argv
, argc
, "AA:NN", &idx
);
19639 char *str
= argv_concat(argv
, argc
, idx
);
19641 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19644 XFREE(MTYPE_TMP
, str
);
19647 community_list_perror(vty
, ret
);
19648 return CMD_WARNING_CONFIG_FAILED
;
19651 return CMD_SUCCESS
;
19654 DEFUN (extcommunity_list_name_expanded
,
19655 bgp_extcommunity_list_name_expanded_cmd
,
19656 "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...",
19658 EXTCOMMUNITY_LIST_STR
19659 "Extended Community list number (expanded)\n"
19660 "Specify expanded extcommunity-list\n"
19661 "Extended Community list name\n"
19662 "Sequence number of an entry\n"
19663 "Sequence number\n"
19664 "Specify community to reject\n"
19665 "Specify community to accept\n"
19666 "An ordered list as a regular-expression\n")
19668 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
19670 char *cl_number_or_name
= NULL
;
19674 argv_find(argv
, argc
, "(100-500)", &idx
);
19675 argv_find(argv
, argc
, "WORD", &idx
);
19676 cl_number_or_name
= argv
[idx
]->arg
;
19678 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19679 seq
= argv
[idx
]->arg
;
19681 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19683 argv_find(argv
, argc
, "LINE", &idx
);
19684 char *str
= argv_concat(argv
, argc
, idx
);
19686 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19689 XFREE(MTYPE_TMP
, str
);
19692 community_list_perror(vty
, ret
);
19693 return CMD_WARNING_CONFIG_FAILED
;
19696 return CMD_SUCCESS
;
19699 DEFUN (no_extcommunity_list_standard_all
,
19700 no_bgp_extcommunity_list_standard_all_cmd
,
19701 "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19704 EXTCOMMUNITY_LIST_STR
19705 "Extended Community list number (standard)\n"
19706 "Specify standard extcommunity-list\n"
19707 "Community list name\n"
19708 "Sequence number of an entry\n"
19709 "Sequence number\n"
19710 "Specify community to reject\n"
19711 "Specify community to accept\n"
19712 EXTCOMMUNITY_VAL_STR
)
19714 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19716 char *cl_number_or_name
= NULL
;
19721 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19722 seq
= argv
[idx
]->arg
;
19725 argv_find(argv
, argc
, "permit", &idx
);
19726 argv_find(argv
, argc
, "deny", &idx
);
19728 direct
= argv_find(argv
, argc
, "permit", &idx
)
19733 argv_find(argv
, argc
, "AA:NN", &idx
);
19734 str
= argv_concat(argv
, argc
, idx
);
19738 argv_find(argv
, argc
, "(1-99)", &idx
);
19739 argv_find(argv
, argc
, "WORD", &idx
);
19740 cl_number_or_name
= argv
[idx
]->arg
;
19742 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
19743 seq
, direct
, style
);
19745 XFREE(MTYPE_TMP
, str
);
19748 community_list_perror(vty
, ret
);
19749 return CMD_WARNING_CONFIG_FAILED
;
19752 return CMD_SUCCESS
;
19755 ALIAS(no_extcommunity_list_standard_all
,
19756 no_bgp_extcommunity_list_standard_all_list_cmd
,
19757 "no bgp extcommunity-list <(1-99)|standard WORD>",
19758 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
19759 "Extended Community list number (standard)\n"
19760 "Specify standard extcommunity-list\n"
19761 "Community list name\n")
19763 DEFUN (no_extcommunity_list_expanded_all
,
19764 no_bgp_extcommunity_list_expanded_all_cmd
,
19765 "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...",
19768 EXTCOMMUNITY_LIST_STR
19769 "Extended Community list number (expanded)\n"
19770 "Specify expanded extcommunity-list\n"
19771 "Extended Community list name\n"
19772 "Sequence number of an entry\n"
19773 "Sequence number\n"
19774 "Specify community to reject\n"
19775 "Specify community to accept\n"
19776 "An ordered list as a regular-expression\n")
19778 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
19780 char *cl_number_or_name
= NULL
;
19785 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19786 seq
= argv
[idx
]->arg
;
19789 argv_find(argv
, argc
, "permit", &idx
);
19790 argv_find(argv
, argc
, "deny", &idx
);
19793 direct
= argv_find(argv
, argc
, "permit", &idx
)
19798 argv_find(argv
, argc
, "LINE", &idx
);
19799 str
= argv_concat(argv
, argc
, idx
);
19803 argv_find(argv
, argc
, "(100-500)", &idx
);
19804 argv_find(argv
, argc
, "WORD", &idx
);
19805 cl_number_or_name
= argv
[idx
]->arg
;
19807 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
19808 seq
, direct
, style
);
19810 XFREE(MTYPE_TMP
, str
);
19813 community_list_perror(vty
, ret
);
19814 return CMD_WARNING_CONFIG_FAILED
;
19817 return CMD_SUCCESS
;
19820 ALIAS(no_extcommunity_list_expanded_all
,
19821 no_bgp_extcommunity_list_expanded_all_list_cmd
,
19822 "no bgp extcommunity-list <(100-500)|expanded WORD>",
19823 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
19824 "Extended Community list number (expanded)\n"
19825 "Specify expanded extcommunity-list\n"
19826 "Extended Community list name\n")
19828 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
19830 struct community_entry
*entry
;
19832 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19833 if (entry
== list
->head
) {
19834 if (all_digit(list
->name
))
19835 vty_out(vty
, "Extended community %s list %s\n",
19836 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
19838 : "(expanded) access",
19842 "Named extended community %s list %s\n",
19843 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
19849 vty_out(vty
, " %s\n",
19850 community_direct_str(entry
->direct
));
19852 vty_out(vty
, " %s %s\n",
19853 community_direct_str(entry
->direct
),
19854 community_list_config_str(entry
));
19858 DEFUN (show_extcommunity_list
,
19859 show_bgp_extcommunity_list_cmd
,
19860 "show bgp extcommunity-list",
19863 "List extended-community list\n")
19865 struct community_list
*list
;
19866 struct community_list_master
*cm
;
19868 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
19870 return CMD_SUCCESS
;
19872 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19873 extcommunity_list_show(vty
, list
);
19875 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19876 extcommunity_list_show(vty
, list
);
19878 return CMD_SUCCESS
;
19881 DEFUN (show_extcommunity_list_arg
,
19882 show_bgp_extcommunity_list_arg_cmd
,
19883 "show bgp extcommunity-list <(1-500)|WORD> detail",
19886 "List extended-community list\n"
19887 "Extcommunity-list number\n"
19888 "Extcommunity-list name\n"
19889 "Detailed information on extcommunity-list\n")
19891 int idx_comm_list
= 3;
19892 struct community_list
*list
;
19894 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
19895 EXTCOMMUNITY_LIST_MASTER
);
19897 vty_out(vty
, "%% Can't find extcommunity-list\n");
19898 return CMD_WARNING
;
19901 extcommunity_list_show(vty
, list
);
19903 return CMD_SUCCESS
;
19906 /* Display community-list and extcommunity-list configuration. */
19907 static int community_list_config_write(struct vty
*vty
)
19909 struct community_list
*list
;
19910 struct community_entry
*entry
;
19911 struct community_list_master
*cm
;
19914 /* Community-list. */
19915 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19917 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19918 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19920 "bgp community-list %s seq %" PRId64
" %s %s\n",
19921 list
->name
, entry
->seq
,
19922 community_direct_str(entry
->direct
),
19923 community_list_config_str(entry
));
19926 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19927 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19929 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
19930 entry
->style
== COMMUNITY_LIST_STANDARD
19933 list
->name
, entry
->seq
,
19934 community_direct_str(entry
->direct
),
19935 community_list_config_str(entry
));
19939 /* Extcommunity-list. */
19940 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
19942 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19943 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19945 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
19946 list
->name
, entry
->seq
,
19947 community_direct_str(entry
->direct
),
19948 community_list_config_str(entry
));
19951 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19952 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19954 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
19955 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
19958 list
->name
, entry
->seq
,
19959 community_direct_str(entry
->direct
),
19960 community_list_config_str(entry
));
19965 /* lcommunity-list. */
19966 cm
= community_list_master_lookup(bgp_clist
,
19967 LARGE_COMMUNITY_LIST_MASTER
);
19969 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19970 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19972 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
19973 list
->name
, entry
->seq
,
19974 community_direct_str(entry
->direct
),
19975 community_list_config_str(entry
));
19978 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19979 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19981 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
19983 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
19986 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
19987 community_list_config_str(entry
));
19994 static int community_list_config_write(struct vty
*vty
);
19995 static struct cmd_node community_list_node
= {
19996 .name
= "community list",
19997 .node
= COMMUNITY_LIST_NODE
,
19999 .config_write
= community_list_config_write
,
20002 static void community_list_vty(void)
20004 install_node(&community_list_node
);
20006 /* Community-list. */
20007 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
20008 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
20009 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
20010 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
20011 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
20012 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
20013 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
20014 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
20016 /* Extcommunity-list. */
20017 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
20018 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
20019 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
20020 install_element(CONFIG_NODE
,
20021 &no_bgp_extcommunity_list_standard_all_list_cmd
);
20022 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
20023 install_element(CONFIG_NODE
,
20024 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
20025 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
20026 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
20028 /* Large Community List */
20029 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
20030 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
20031 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
20032 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
20033 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
20034 install_element(CONFIG_NODE
,
20035 &no_bgp_lcommunity_list_name_standard_all_cmd
);
20036 install_element(CONFIG_NODE
,
20037 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
20038 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
20039 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
20040 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
20041 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
20042 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
20043 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);