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 },
123 DEFINE_HOOK(bgp_inst_config_write
,
124 (struct bgp
*bgp
, struct vty
*vty
),
128 "The Graceful Restart No Operation was executed as cmd same as previous one."
130 "The Graceful Restart command used is not valid at this moment."
131 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
132 struct prefix
*range
, int exact
);
134 /* Show BGP peer's information. */
144 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
145 struct prefix
*range
, int exact
);
147 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
152 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
155 afi_t afi
, bool use_json
);
157 static int peer_and_group_lookup_nb(struct vty
*vty
, const char *peer_str
,
158 char *base_xpath
, int xpath_len
,
161 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
167 return BGP_IPV4_NODE
;
169 return BGP_IPV4M_NODE
;
170 case SAFI_LABELED_UNICAST
:
171 return BGP_IPV4L_NODE
;
173 return BGP_VPNV4_NODE
;
175 return BGP_FLOWSPECV4_NODE
;
178 return BGP_IPV4_NODE
;
184 return BGP_IPV6_NODE
;
186 return BGP_IPV6M_NODE
;
187 case SAFI_LABELED_UNICAST
:
188 return BGP_IPV6L_NODE
;
190 return BGP_VPNV6_NODE
;
192 return BGP_FLOWSPECV6_NODE
;
195 return BGP_IPV4_NODE
;
199 return BGP_EVPN_NODE
;
202 // We should never be here but to clarify the switch statement..
203 return BGP_IPV4_NODE
;
206 // Impossible to happen
207 return BGP_IPV4_NODE
;
210 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
212 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
213 return "IPv4 Unicast";
214 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
215 return "IPv4 Multicast";
216 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
217 return "IPv4 Labeled Unicast";
218 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
220 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
222 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
223 return "IPv4 Flowspec";
224 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
225 return "IPv6 Unicast";
226 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
227 return "IPv6 Multicast";
228 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
229 return "IPv6 Labeled Unicast";
230 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
232 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
234 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
235 return "IPv6 Flowspec";
236 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
243 * Please note that we have intentionally camelCased
244 * the return strings here. So if you want
245 * to use this function, please ensure you
246 * are doing this within json output
248 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
250 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
251 return "ipv4Unicast";
252 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
253 return "ipv4Multicast";
254 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
255 return "ipv4LabeledUnicast";
256 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
258 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
260 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
261 return "ipv4Flowspec";
262 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
263 return "ipv6Unicast";
264 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
265 return "ipv6Multicast";
266 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
267 return "ipv6LabeledUnicast";
268 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
270 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
272 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
273 return "ipv6Flowspec";
274 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
280 /* return string maps to afi-safi specific container names
281 * defined in bgp yang file.
283 const char *bgp_afi_safi_get_container_str(afi_t afi
, safi_t safi
)
285 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
286 return "ipv4-unicast";
287 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
288 return "ipv4-multicast";
289 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
290 return "ipv4-labeled-unicast";
291 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
292 return "l3vpn-ipv4-unicast";
293 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
294 return "ipv4-flowspec";
295 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
296 return "ipv6-unicast";
297 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
298 return "ipv6-multicast";
299 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
300 return "ipv6-labeled-unicast";
301 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
302 return "l3vpn-ipv6-unicast";
303 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
304 return "ipv6-flowspec";
305 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
311 /* Utility function to get address family from current node. */
312 afi_t
bgp_node_afi(struct vty
*vty
)
320 case BGP_FLOWSPECV6_NODE
:
333 /* Utility function to get subsequent address family from current
335 safi_t
bgp_node_safi(struct vty
*vty
)
341 safi
= SAFI_MPLS_VPN
;
345 safi
= SAFI_MULTICAST
;
352 safi
= SAFI_LABELED_UNICAST
;
354 case BGP_FLOWSPECV4_NODE
:
355 case BGP_FLOWSPECV6_NODE
:
356 safi
= SAFI_FLOWSPEC
;
366 * Converts an AFI in string form to afi_t
368 * @param afi string, one of
372 * @return the corresponding afi_t
374 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
376 afi_t afi
= AFI_MAX
; /* unknown */
377 if (strmatch(afi_str
, "ipv4"))
379 else if (strmatch(afi_str
, "ipv6"))
381 else if (strmatch(afi_str
, "l2vpn"))
386 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
390 if (argv_find(argv
, argc
, "ipv4", index
)) {
394 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
398 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
406 /* supports <unicast|multicast|vpn|labeled-unicast> */
407 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
409 safi_t safi
= SAFI_MAX
; /* unknown */
410 if (strmatch(safi_str
, "multicast"))
411 safi
= SAFI_MULTICAST
;
412 else if (strmatch(safi_str
, "unicast"))
414 else if (strmatch(safi_str
, "vpn"))
415 safi
= SAFI_MPLS_VPN
;
416 else if (strmatch(safi_str
, "evpn"))
418 else if (strmatch(safi_str
, "labeled-unicast"))
419 safi
= SAFI_LABELED_UNICAST
;
420 else if (strmatch(safi_str
, "flowspec"))
421 safi
= SAFI_FLOWSPEC
;
425 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
429 if (argv_find(argv
, argc
, "unicast", index
)) {
432 *safi
= SAFI_UNICAST
;
433 } else if (argv_find(argv
, argc
, "multicast", index
)) {
436 *safi
= SAFI_MULTICAST
;
437 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
440 *safi
= SAFI_LABELED_UNICAST
;
441 } else if (argv_find(argv
, argc
, "vpn", index
)) {
444 *safi
= SAFI_MPLS_VPN
;
445 } else if (argv_find(argv
, argc
, "evpn", index
)) {
449 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
452 *safi
= SAFI_FLOWSPEC
;
457 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
458 enum bgp_instance_type inst_type
)
460 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
462 if (ret
== BGP_CREATED
) {
463 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
464 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
466 if (DFLT_BGP_IMPORT_CHECK
)
467 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
468 if (DFLT_BGP_SHOW_HOSTNAME
)
469 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
470 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
471 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
472 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
473 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
474 if (DFLT_BGP_DETERMINISTIC_MED
)
475 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
476 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
477 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
485 * bgp_vty_find_and_parse_afi_safi_bgp
487 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
488 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
489 * to appropriate values for the calling function. This is to allow the
490 * calling function to make decisions appropriate for the show command
491 * that is being parsed.
493 * The show commands are generally of the form:
494 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
495 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
497 * Since we use argv_find if the show command in particular doesn't have:
499 * [<view|vrf> VIEWVRFNAME]
500 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
501 * The command parsing should still be ok.
503 * vty -> The vty for the command so we can output some useful data in
504 * the event of a parse error in the vrf.
505 * argv -> The command tokens
506 * argc -> How many command tokens we have
507 * idx -> The current place in the command, generally should be 0 for this
509 * afi -> The parsed afi if it was included in the show command, returned here
510 * safi -> The parsed safi if it was included in the show command, returned here
511 * bgp -> Pointer to the bgp data structure we need to fill in.
512 * use_json -> json is configured or not
514 * The function returns the correct location in the parse tree for the
517 * Returns 0 for failure to parse correctly, else the idx position of where
518 * it found the last token.
520 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
521 struct cmd_token
**argv
, int argc
,
522 int *idx
, afi_t
*afi
, safi_t
*safi
,
523 struct bgp
**bgp
, bool use_json
)
525 char *vrf_name
= NULL
;
531 if (argv_find(argv
, argc
, "ip", idx
))
534 if (argv_find(argv
, argc
, "view", idx
))
535 vrf_name
= argv
[*idx
+ 1]->arg
;
536 else if (argv_find(argv
, argc
, "vrf", idx
)) {
537 vrf_name
= argv
[*idx
+ 1]->arg
;
538 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
542 if (strmatch(vrf_name
, "all"))
545 *bgp
= bgp_lookup_by_name(vrf_name
);
548 json_object
*json
= NULL
;
549 json
= json_object_new_object();
550 json_object_string_add(
552 "View/Vrf is unknown");
554 json_object_to_json_string_ext(json
,
555 JSON_C_TO_STRING_PRETTY
));
556 json_object_free(json
);
559 vty_out(vty
, "View/Vrf %s is unknown\n",
566 *bgp
= bgp_get_default();
569 json_object
*json
= NULL
;
570 json
= json_object_new_object();
571 json_object_string_add(
573 "Default BGP instance not found");
575 json_object_to_json_string_ext(json
,
576 JSON_C_TO_STRING_PRETTY
));
577 json_object_free(json
);
581 "Default BGP instance not found\n");
587 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
588 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
594 bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
596 struct interface
*ifp
= NULL
;
598 if (su
->sa
.sa_family
== AF_INET
)
599 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
600 else if (su
->sa
.sa_family
== AF_INET6
)
601 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
602 su
->sin6
.sin6_scope_id
,
611 /* Utility function for looking up peer or peer group. */
612 /* This is used only for configuration, so disallow if attempted on
613 * a dynamic neighbor.
615 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
617 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
620 struct peer
*peer
= NULL
;
621 struct peer_group
*group
= NULL
;
627 ret
= str2sockunion(peer_str
, &su
);
629 /* IP address, locate peer. */
630 peer
= peer_lookup(bgp
, &su
);
632 /* Not IP, could match either peer configured on interface or a
634 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
636 group
= peer_group_lookup(bgp
, peer_str
);
640 if (peer_dynamic_neighbor(peer
)) {
642 "%% Operation not allowed on a dynamic neighbor\n");
652 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
657 int bgp_nb_errmsg_return(char *errmsg
, size_t errmsg_len
, int ret
)
659 const char *str
= NULL
;
662 case BGP_ERR_INVALID_VALUE
:
663 str
= "Invalid value";
665 case BGP_ERR_INVALID_FLAG
:
666 str
= "Invalid flag";
668 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
669 str
= "Peer-group has been shutdown. Activate the peer-group first";
671 case BGP_ERR_PEER_FLAG_CONFLICT
:
672 str
= "Can't set override-capability and strict-capability-match at the same time";
674 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
675 str
= "Specify remote-as or peer-group remote AS first";
677 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
678 str
= "Cannot change the peer-group. Deconfigure first";
680 case BGP_ERR_PEER_GROUP_MISMATCH
:
681 str
= "Peer is not a member of this peer-group";
683 case BGP_ERR_PEER_FILTER_CONFLICT
:
684 str
= "Prefix/distribute list can not co-exist";
686 case BGP_ERR_NOT_INTERNAL_PEER
:
687 str
= "Invalid command. Not an internal neighbor";
689 case BGP_ERR_REMOVE_PRIVATE_AS
:
690 str
= "remove-private-AS cannot be configured for IBGP peers";
692 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
693 str
= "Local-AS allowed only for EBGP peers";
695 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
696 str
= "Cannot have local-as same as BGP AS number";
698 case BGP_ERR_TCPSIG_FAILED
:
699 str
= "Error while applying TCP-Sig to session(s)";
701 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
702 str
= "ebgp-multihop and ttl-security cannot be configured together";
704 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
705 str
= "ttl-security only allowed for EBGP peers";
707 case BGP_ERR_AS_OVERRIDE
:
708 str
= "as-override cannot be configured for IBGP peers";
710 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
711 str
= "Invalid limit for number of dynamic neighbors";
713 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
714 str
= "Dynamic neighbor listen range already exists";
716 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
717 str
= "Operation not allowed on a dynamic neighbor";
719 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
720 str
= "Operation not allowed on a directly connected neighbor";
722 case BGP_ERR_PEER_SAFI_CONFLICT
:
725 case BGP_ERR_GR_INVALID_CMD
:
726 str
= "The Graceful Restart command used is not valid at this moment.";
728 case BGP_ERR_GR_OPERATION_FAILED
:
729 str
= "The Graceful Restart Operation failed due to an err.";
731 case BGP_GR_NO_OPERATION
:
734 case BGP_ERR_PEER_GROUP_MEMBER
:
735 str
= "Peer-group member cannot override remote-as of peer-group";
737 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
738 str
= "Peer-group members must be all internal or all external";
742 snprintf(errmsg
, errmsg_len
, "%s", str
);
749 int bgp_vty_return(struct vty
*vty
, int ret
)
751 const char *str
= NULL
;
754 case BGP_ERR_INVALID_VALUE
:
755 str
= "Invalid value";
757 case BGP_ERR_INVALID_FLAG
:
758 str
= "Invalid flag";
760 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
761 str
= "Peer-group has been shutdown. Activate the peer-group first";
763 case BGP_ERR_PEER_FLAG_CONFLICT
:
764 str
= "Can't set override-capability and strict-capability-match at the same time";
766 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
767 str
= "Specify remote-as or peer-group remote AS first";
769 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
770 str
= "Cannot change the peer-group. Deconfigure first";
772 case BGP_ERR_PEER_GROUP_MISMATCH
:
773 str
= "Peer is not a member of this peer-group";
775 case BGP_ERR_PEER_FILTER_CONFLICT
:
776 str
= "Prefix/distribute list can not co-exist";
778 case BGP_ERR_NOT_INTERNAL_PEER
:
779 str
= "Invalid command. Not an internal neighbor";
781 case BGP_ERR_REMOVE_PRIVATE_AS
:
782 str
= "remove-private-AS cannot be configured for IBGP peers";
784 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
785 str
= "Local-AS allowed only for EBGP peers";
787 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
788 str
= "Cannot have local-as same as BGP AS number";
790 case BGP_ERR_TCPSIG_FAILED
:
791 str
= "Error while applying TCP-Sig to session(s)";
793 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
794 str
= "ebgp-multihop and ttl-security cannot be configured together";
796 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
797 str
= "ttl-security only allowed for EBGP peers";
799 case BGP_ERR_AS_OVERRIDE
:
800 str
= "as-override cannot be configured for IBGP peers";
802 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
803 str
= "Invalid limit for number of dynamic neighbors";
805 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
806 str
= "Dynamic neighbor listen range already exists";
808 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
809 str
= "Operation not allowed on a dynamic neighbor";
811 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
812 str
= "Operation not allowed on a directly connected neighbor";
814 case BGP_ERR_PEER_SAFI_CONFLICT
:
817 case BGP_ERR_GR_INVALID_CMD
:
818 str
= "The Graceful Restart command used is not valid at this moment.";
820 case BGP_ERR_GR_OPERATION_FAILED
:
821 str
= "The Graceful Restart Operation failed due to an err.";
823 case BGP_GR_NO_OPERATION
:
828 vty_out(vty
, "%% %s\n", str
);
829 return CMD_WARNING_CONFIG_FAILED
;
834 /* BGP clear sort. */
843 static void bgp_clear_vty_error(struct peer
*peer
, afi_t afi
, safi_t safi
,
844 int error
, char *errmsg
, size_t errmsg_len
)
847 case BGP_ERR_AF_UNCONFIGURED
:
848 snprintf(errmsg
, errmsg_len
,
849 "%%BGP: Enable %s address family for the neighbor %s",
850 get_afi_safi_str(afi
, safi
, false), peer
->host
);
852 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
855 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig",
863 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
864 struct listnode
**nnode
, enum bgp_clear_type stype
)
868 /* if afi/.safi not specified, spin thru all of them */
869 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
873 FOREACH_AFI_SAFI (tmp_afi
, tmp_safi
) {
874 if (!peer
->afc
[tmp_afi
][tmp_safi
])
877 if (stype
== BGP_CLEAR_SOFT_NONE
)
878 ret
= peer_clear(peer
, nnode
);
880 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
883 /* if afi specified and safi not, spin thru safis on this afi */
884 } else if (safi
== SAFI_UNSPEC
) {
887 for (tmp_safi
= SAFI_UNICAST
;
888 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
889 if (!peer
->afc
[afi
][tmp_safi
])
892 if (stype
== BGP_CLEAR_SOFT_NONE
)
893 ret
= peer_clear(peer
, nnode
);
895 ret
= peer_clear_soft(peer
, afi
,
898 /* both afi/safi specified, let the caller know if not defined */
900 if (!peer
->afc
[afi
][safi
])
903 if (stype
== BGP_CLEAR_SOFT_NONE
)
904 ret
= peer_clear(peer
, nnode
);
906 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
912 /* `clear ip bgp' functions. */
913 static int bgp_clear(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
914 enum clear_sort sort
, enum bgp_clear_type stype
,
915 const char *arg
, char *errmsg
, size_t errmsg_len
)
921 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
923 /* Clear all neighbors. */
925 * Pass along pointer to next node to peer_clear() when walking all
926 * nodes on the BGP instance as that may get freed if it is a
929 if (sort
== clear_all
) {
930 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
932 bgp_peer_gr_flags_update(peer
);
934 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
935 gr_router_detected
= true;
937 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
941 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
945 if (gr_router_detected
946 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
947 bgp_zebra_send_capabilities(bgp
, false);
948 } else if (!gr_router_detected
949 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
950 bgp_zebra_send_capabilities(bgp
, true);
953 /* This is to apply read-only mode on this clear. */
954 if (stype
== BGP_CLEAR_SOFT_NONE
)
955 bgp
->update_delay_over
= 0;
960 /* Clear specified neighbor. */
961 if (sort
== clear_peer
) {
964 /* Make sockunion for lookup. */
965 ret
= str2sockunion(arg
, &su
);
967 peer
= peer_lookup_by_conf_if(bgp
, arg
);
969 peer
= peer_lookup_by_hostname(bgp
, arg
);
973 "Malformed address or name: %s",
979 peer
= peer_lookup(bgp
, &su
);
981 snprintf(errmsg
, errmsg_len
,
982 "%%BGP: Unknown neighbor - \"%s\"",
988 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
989 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
991 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
993 /* if afi/safi not defined for this peer, let caller know */
995 ret
= BGP_ERR_AF_UNCONFIGURED
;
998 bgp_clear_vty_error(peer
, afi
, safi
, ret
, errmsg
,
1004 /* Clear all neighbors belonging to a specific peer-group. */
1005 if (sort
== clear_group
) {
1006 struct peer_group
*group
;
1008 group
= peer_group_lookup(bgp
, arg
);
1010 snprintf(errmsg
, errmsg_len
,
1011 "%%BGP: No such peer-group %s", arg
);
1015 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1016 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1019 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1020 errmsg
, errmsg_len
);
1028 "%%BGP: No %s peer belonging to peer-group %s is configured",
1029 get_afi_safi_str(afi
, safi
, false), arg
);
1034 /* Clear all external (eBGP) neighbors. */
1035 if (sort
== clear_external
) {
1036 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1037 if (peer
->sort
== BGP_PEER_IBGP
)
1040 bgp_peer_gr_flags_update(peer
);
1042 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1043 gr_router_detected
= true;
1045 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1048 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1049 errmsg
, errmsg_len
);
1054 if (gr_router_detected
1055 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1056 bgp_zebra_send_capabilities(bgp
, false);
1057 } else if (!gr_router_detected
1058 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1059 bgp_zebra_send_capabilities(bgp
, true);
1063 snprintf(errmsg
, errmsg_len
,
1064 "%%BGP: No external %s peer is configured",
1065 get_afi_safi_str(afi
, safi
, false));
1070 /* Clear all neighbors belonging to a specific AS. */
1071 if (sort
== clear_as
) {
1072 as_t as
= strtoul(arg
, NULL
, 10);
1074 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1078 bgp_peer_gr_flags_update(peer
);
1080 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1081 gr_router_detected
= true;
1083 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1086 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1087 errmsg
, errmsg_len
);
1092 if (gr_router_detected
1093 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1094 bgp_zebra_send_capabilities(bgp
, false);
1095 } else if (!gr_router_detected
1096 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1097 bgp_zebra_send_capabilities(bgp
, true);
1101 snprintf(errmsg
, errmsg_len
,
1102 "%%BGP: No %s peer is configured with AS %s",
1103 get_afi_safi_str(afi
, safi
, false), arg
);
1111 static int bgp_clear_vty(const char *name
, afi_t afi
, safi_t safi
,
1112 enum clear_sort sort
, enum bgp_clear_type stype
,
1113 const char *arg
, char *errmsg
, size_t errmsg_len
)
1117 /* BGP structure lookup. */
1119 bgp
= bgp_lookup_by_name(name
);
1121 snprintf(errmsg
, errmsg_len
,
1122 "Can't find BGP instance %s", name
);
1126 bgp
= bgp_get_default();
1128 snprintf(errmsg
, errmsg_len
,
1129 "No BGP process is configured");
1134 return bgp_clear(bgp
, afi
, safi
, sort
, stype
, arg
, errmsg
, errmsg_len
);
1137 /* clear soft inbound */
1138 int bgp_clear_star_soft_in(const char *name
, char *errmsg
, size_t errmsg_len
)
1144 FOREACH_AFI_SAFI (afi
, safi
) {
1145 ret
= bgp_clear_vty(name
, afi
, safi
, clear_all
,
1146 BGP_CLEAR_SOFT_IN
, NULL
, errmsg
,
1148 if (ret
!= CMD_SUCCESS
)
1155 /* clear soft outbound */
1156 int bgp_clear_star_soft_out(const char *name
, char *errmsg
, size_t errmsg_len
)
1162 FOREACH_AFI_SAFI (afi
, safi
) {
1163 ret
= bgp_clear_vty(name
, afi
, safi
, clear_all
,
1164 BGP_CLEAR_SOFT_OUT
, NULL
, errmsg
,
1166 if (ret
!= CMD_SUCCESS
)
1174 #ifndef VTYSH_EXTRACT_PL
1175 #include "bgpd/bgp_vty_clippy.c"
1178 DEFUN_HIDDEN (bgp_local_mac
,
1180 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1182 "Local MAC config\n"
1183 "VxLAN Network Identifier\n"
1187 "mac-mobility sequence\n"
1197 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1198 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1199 vty_out(vty
, "%% Malformed MAC address\n");
1202 memset(&ip
, 0, sizeof(ip
));
1203 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1205 bgp
= bgp_get_default();
1207 vty_out(vty
, "Default BGP instance is not there\n");
1211 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1214 vty_out(vty
, "Internal error\n");
1221 DEFUN_HIDDEN (no_bgp_local_mac
,
1222 no_bgp_local_mac_cmd
,
1223 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1226 "Local MAC config\n"
1227 "VxLAN Network Identifier\n"
1238 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1239 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1240 vty_out(vty
, "%% Malformed MAC address\n");
1243 memset(&ip
, 0, sizeof(ip
));
1245 bgp
= bgp_get_default();
1247 vty_out(vty
, "Default BGP instance is not there\n");
1251 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1253 vty_out(vty
, "Internal error\n");
1260 DEFUN (no_synchronization
,
1261 no_synchronization_cmd
,
1262 "no synchronization",
1264 "Perform IGP synchronization\n")
1269 DEFUN (no_auto_summary
,
1270 no_auto_summary_cmd
,
1273 "Enable automatic network number summarization\n")
1278 /* "router bgp" commands. */
1279 DEFUN_YANG_NOSH(router_bgp
,
1281 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1282 ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR
)
1285 int idx_view_vrf
= 3;
1287 int ret
= CMD_SUCCESS
;
1290 const char *name
= NULL
;
1291 char as_str
[12] = {'\0'};
1292 enum bgp_instance_type inst_type
;
1293 char base_xpath
[XPATH_MAXLEN
];
1295 // "router bgp" without an ASN
1297 // Pending: Make VRF option available for ASN less config
1298 bgp
= bgp_get_default();
1301 vty_out(vty
, "%% No BGP process is configured\n");
1302 return CMD_WARNING_CONFIG_FAILED
;
1305 if (listcount(bm
->bgp
) > 1) {
1306 vty_out(vty
, "%% Please specify ASN and VRF\n");
1307 return CMD_WARNING_CONFIG_FAILED
;
1310 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1311 "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME
);
1313 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
1314 snprintf(as_str
, 12, "%d", bgp
->as
);
1315 nb_cli_enqueue_change(vty
, "./global/local-as", NB_OP_MODIFY
,
1317 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
) {
1318 nb_cli_enqueue_change(vty
,
1319 "./global/instance-type-view",
1320 NB_OP_MODIFY
, "true");
1323 nb_cli_pending_commit_check(vty
);
1324 ret
= nb_cli_apply_changes(vty
, base_xpath
);
1325 if (ret
== CMD_SUCCESS
) {
1326 VTY_PUSH_XPATH(BGP_NODE
, base_xpath
);
1329 * For backward compatibility with old commands we still
1330 * need to use the qobj infrastructure.
1332 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1340 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1341 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1343 name
= argv
[idx_vrf
]->arg
;
1345 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1346 if (strmatch(name
, VRF_DEFAULT_NAME
))
1349 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1350 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view")) {
1351 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1354 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1355 "frr-bgp:bgp", "bgp", name
? name
: VRF_DEFAULT_NAME
);
1357 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
1358 nb_cli_enqueue_change(vty
, "./global/local-as", NB_OP_MODIFY
,
1359 argv
[idx_asn
]->arg
);
1360 if (inst_type
== BGP_INSTANCE_TYPE_VIEW
) {
1361 nb_cli_enqueue_change(vty
,
1362 "./global/instance-type-view",
1363 NB_OP_MODIFY
, "true");
1366 nb_cli_pending_commit_check(vty
);
1367 ret
= nb_cli_apply_changes(vty
, base_xpath
);
1368 if (ret
== CMD_SUCCESS
) {
1369 VTY_PUSH_XPATH(BGP_NODE
, base_xpath
);
1372 * For backward compatibility with old commands we still
1373 * need to use the qobj infrastructure.
1375 bgp
= bgp_lookup(as
, name
);
1377 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1384 /* "no router bgp" commands. */
1385 DEFUN_YANG(no_router_bgp
,
1387 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1388 NO_STR ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR
)
1394 const char *name
= NULL
;
1395 char base_xpath
[XPATH_MAXLEN
];
1396 const struct lyd_node
*bgp_glb_dnode
;
1398 // "no router bgp" without an ASN
1400 // Pending: Make VRF option available for ASN less config
1401 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1402 "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME
);
1404 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
1406 if (!bgp_glb_dnode
) {
1407 vty_out(vty
, "%% No BGP process is configured\n");
1408 return CMD_WARNING_CONFIG_FAILED
;
1411 if (listcount(bm
->bgp
) > 1) {
1412 vty_out(vty
, "%% Please specify ASN and VRF\n");
1413 return CMD_WARNING_CONFIG_FAILED
;
1416 /* tcli mode bgp would not be set until apply stage. */
1417 bgp
= nb_running_get_entry(bgp_glb_dnode
, NULL
, false);
1422 vty_out(vty
, "%% Please unconfigure l3vni %u",
1424 return CMD_WARNING_CONFIG_FAILED
;
1427 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1430 name
= argv
[idx_vrf
]->arg
;
1432 /* Lookup bgp structure. */
1433 bgp
= bgp_lookup(as
, name
);
1435 vty_out(vty
, "%% Can't find BGP instance\n");
1436 return CMD_WARNING_CONFIG_FAILED
;
1440 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1442 return CMD_WARNING_CONFIG_FAILED
;
1445 /* Cannot delete default instance if vrf instances exist */
1446 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1447 struct listnode
*node
;
1448 struct bgp
*tmp_bgp
;
1450 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1451 if (tmp_bgp
->inst_type
1452 == BGP_INSTANCE_TYPE_VRF
) {
1454 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1455 return CMD_WARNING_CONFIG_FAILED
;
1460 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1461 "frr-bgp:bgp", "bgp",
1462 bgp
->name
? bgp
->name
: VRF_DEFAULT_NAME
);
1464 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
1466 return nb_cli_apply_changes(vty
, base_xpath
);
1469 void cli_show_router_bgp(struct vty
*vty
, struct lyd_node
*dnode
,
1472 const struct lyd_node
*vrf_dnode
;
1473 const char *vrf_name
;
1476 vrf_dnode
= yang_dnode_get_parent(dnode
, "control-plane-protocol");
1477 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
1478 as
= yang_dnode_get_uint32(dnode
, "./global/local-as");
1480 vty_out(vty
, "!\n");
1481 vty_out(vty
, "router bgp %u", as
);
1482 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
))
1483 vty_out(vty
, " vrf %s", vrf_name
);
1487 /* BGP router-id. */
1489 DEFPY_YANG(bgp_router_id
, bgp_router_id_cmd
, "bgp router-id A.B.C.D",
1491 "Override configured router identifier\n"
1492 "Manually configured router identifier\n")
1494 nb_cli_enqueue_change(vty
, "./global/router-id", NB_OP_MODIFY
,
1497 return nb_cli_apply_changes(vty
, NULL
);
1500 DEFPY_YANG(no_bgp_router_id
, no_bgp_router_id_cmd
, "no bgp router-id [A.B.C.D]",
1502 "Override configured router identifier\n"
1503 "Manually configured router identifier\n")
1505 nb_cli_enqueue_change(vty
, "./global/router-id", NB_OP_DESTROY
,
1506 router_id_str
? router_id_str
: NULL
);
1508 return nb_cli_apply_changes(vty
, NULL
);
1511 void cli_show_router_bgp_router_id(struct vty
*vty
, struct lyd_node
*dnode
,
1514 vty_out(vty
, " bgp router-id %s\n", yang_dnode_get_string(dnode
, NULL
));
1517 DEFPY (bgp_suppress_fib_pending
,
1518 bgp_suppress_fib_pending_cmd
,
1519 "[no] bgp suppress-fib-pending",
1522 "Advertise only routes that are programmed in kernel to peers\n")
1524 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1526 bgp_suppress_fib_pending_set(bgp
, !no
);
1531 /* BGP Cluster ID. */
1532 DEFUN_YANG(bgp_cluster_id
,
1534 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1536 "Configure Route-Reflector Cluster-id\n"
1537 "Route-Reflector Cluster-id in IP address format\n"
1538 "Route-Reflector Cluster-id as 32 bit quantity\n")
1542 nb_cli_enqueue_change(
1543 vty
, "./global/route-reflector/route-reflector-cluster-id",
1544 NB_OP_MODIFY
, argv
[idx_ipv4
]->arg
);
1546 return nb_cli_apply_changes(vty
, NULL
);
1549 DEFUN_YANG(no_bgp_cluster_id
,
1550 no_bgp_cluster_id_cmd
,
1551 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1553 "Configure Route-Reflector Cluster-id\n"
1554 "Route-Reflector Cluster-id in IP address format\n"
1555 "Route-Reflector Cluster-id as 32 bit quantity\n")
1557 nb_cli_enqueue_change(
1558 vty
, "./global/route-reflector/route-reflector-cluster-id",
1559 NB_OP_DESTROY
, NULL
);
1561 return nb_cli_apply_changes(vty
, NULL
);
1568 "Disable BGP route installation to RIB (Zebra)\n")
1570 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1572 "%% No-RIB option is already set, nothing to do here.\n");
1576 bgp_option_norib_set_runtime();
1581 DEFPY (no_bgp_norib
,
1586 "Disable BGP route installation to RIB (Zebra)\n")
1588 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1590 "%% No-RIB option is not set, nothing to do here.\n");
1594 bgp_option_norib_unset_runtime();
1599 DEFUN_YANG(bgp_confederation_identifier
,
1600 bgp_confederation_identifier_cmd
,
1601 "bgp confederation identifier (1-4294967295)",
1602 "BGP specific commands\n"
1603 "AS confederation parameters\n"
1605 "Set routing domain confederation AS\n")
1609 nb_cli_enqueue_change(vty
, "./global/confederation/identifier",
1610 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
1612 return nb_cli_apply_changes(vty
, NULL
);
1615 DEFUN_YANG(no_bgp_confederation_identifier
,
1616 no_bgp_confederation_identifier_cmd
,
1617 "no bgp confederation identifier [(1-4294967295)]",
1619 "BGP specific commands\n"
1620 "AS confederation parameters\n"
1622 "Set routing domain confederation AS\n")
1624 nb_cli_enqueue_change(vty
, "./global/confederation/identifier",
1625 NB_OP_DESTROY
, NULL
);
1627 return nb_cli_apply_changes(vty
, NULL
);
1630 void cli_show_router_bgp_confederation_identifier(struct vty
*vty
,
1631 struct lyd_node
*dnode
,
1634 vty_out(vty
, " bgp confederation identifier %u\n",
1635 yang_dnode_get_uint32(dnode
, NULL
));
1638 DEFUN_YANG(bgp_confederation_peers
,
1639 bgp_confederation_peers_cmd
,
1640 "bgp confederation peers (1-4294967295)...",
1641 "BGP specific commands\n"
1642 "AS confederation parameters\n"
1643 "Peer ASs in BGP confederation\n" AS_STR
)
1648 for (i
= idx_asn
; i
< argc
; i
++)
1649 nb_cli_enqueue_change(vty
, "./global/confederation/member-as",
1650 NB_OP_CREATE
, argv
[i
]->arg
);
1652 return nb_cli_apply_changes(vty
, NULL
);
1655 DEFUN_YANG(no_bgp_confederation_peers
,
1656 no_bgp_confederation_peers_cmd
,
1657 "no bgp confederation peers (1-4294967295)...",
1659 "BGP specific commands\n"
1660 "AS confederation parameters\n"
1661 "Peer ASs in BGP confederation\n" AS_STR
)
1666 for (i
= idx_asn
; i
< argc
; i
++)
1667 nb_cli_enqueue_change(vty
, "./global/confederation/member-as",
1668 NB_OP_DESTROY
, argv
[i
]->arg
);
1670 return nb_cli_apply_changes(vty
, NULL
);
1673 void cli_show_router_bgp_confederation_member_as(struct vty
*vty
,
1674 struct lyd_node
*dnode
,
1677 vty_out(vty
, " bgp confederation peers %u \n",
1678 yang_dnode_get_uint32(dnode
, NULL
));
1682 * Central routine for maximum-paths configuration.
1683 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1684 * @set: 1 for setting values, 0 for removing the max-paths config.
1686 int bgp_maxpaths_config_vty(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1687 int peer_type
, uint16_t maxpaths
, uint16_t options
,
1688 int set
, char *errmsg
, size_t errmsg_len
)
1693 if (maxpaths
> multipath_num
) {
1696 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1697 maxpaths
, multipath_num
);
1698 return CMD_WARNING_CONFIG_FAILED
;
1700 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1703 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1708 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1709 (set
== 1) ? "" : "un",
1710 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1711 maxpaths
, afi
, safi
);
1712 return CMD_WARNING_CONFIG_FAILED
;
1715 bgp_recalculate_all_bestpaths(bgp
);
1720 void cli_show_router_bgp_med_config(struct vty
*vty
, struct lyd_node
*dnode
,
1723 if (yang_dnode_get_bool(dnode
, "./enable-med-admin")) {
1724 uint32_t med_admin_val
;
1726 vty_out(vty
, " bgp max-med administrative");
1727 if ((med_admin_val
=
1728 yang_dnode_get_uint32(dnode
, "./max-med-admin"))
1729 != BGP_MAXMED_VALUE_DEFAULT
)
1730 vty_out(vty
, " %u", med_admin_val
);
1734 if (yang_dnode_exists(dnode
, "./max-med-onstart-up-time")) {
1735 uint32_t onstartup_val
;
1737 vty_out(vty
, " bgp max-med on-startup %u",
1738 yang_dnode_get_uint32(dnode
,
1739 "./max-med-onstart-up-time"));
1740 onstartup_val
= yang_dnode_get_uint32(
1741 dnode
, "./max-med-onstart-up-value");
1742 if (onstartup_val
!= BGP_MAXMED_VALUE_DEFAULT
)
1743 vty_out(vty
, " %u", onstartup_val
);
1749 DEFUN_YANG(bgp_maxmed_admin
,
1750 bgp_maxmed_admin_cmd
,
1751 "bgp max-med administrative ",
1753 "Advertise routes with max-med\n"
1754 "Administratively applied, for an indefinite period\n")
1756 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1757 NB_OP_MODIFY
, "true");
1759 return nb_cli_apply_changes(vty
, NULL
);
1762 DEFUN_YANG(bgp_maxmed_admin_medv
,
1763 bgp_maxmed_admin_medv_cmd
,
1764 "bgp max-med administrative (0-4294967295)",
1766 "Advertise routes with max-med\n"
1767 "Administratively applied, for an indefinite period\n"
1768 "Max MED value to be used\n")
1772 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1773 NB_OP_MODIFY
, "true");
1775 nb_cli_enqueue_change(vty
, "./global/med-config/max-med-admin",
1776 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
1778 return nb_cli_apply_changes(vty
, NULL
);
1781 DEFUN_YANG(no_bgp_maxmed_admin
,
1782 no_bgp_maxmed_admin_cmd
,
1783 "no bgp max-med administrative [(0-4294967295)]",
1785 "Advertise routes with max-med\n"
1786 "Administratively applied, for an indefinite period\n"
1787 "Max MED value to be used\n")
1789 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1790 NB_OP_MODIFY
, "false");
1792 nb_cli_enqueue_change(vty
, "./global/med-config/max-med-admin",
1793 NB_OP_MODIFY
, NULL
);
1795 return nb_cli_apply_changes(vty
, NULL
);
1798 DEFUN_YANG (bgp_maxmed_onstartup
,
1799 bgp_maxmed_onstartup_cmd
,
1800 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1802 "Advertise routes with max-med\n"
1803 "Effective on a startup\n"
1804 "Time (seconds) period for max-med\n"
1805 "Max MED value to be used\n")
1809 argv_find(argv
, argc
, "(5-86400)", &idx
);
1810 nb_cli_enqueue_change(vty
,
1811 "./global/med-config/max-med-onstart-up-time",
1812 NB_OP_MODIFY
, argv
[idx
]->arg
);
1814 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1815 nb_cli_enqueue_change(
1816 vty
, "./global/med-config/max-med-onstart-up-value",
1817 NB_OP_MODIFY
, argv
[idx
]->arg
);
1819 nb_cli_enqueue_change(
1820 vty
, "./global/med-config/max-med-onstart-up-value",
1821 NB_OP_MODIFY
, NULL
);
1823 return nb_cli_apply_changes(vty
, NULL
);
1826 DEFUN_YANG (no_bgp_maxmed_onstartup
,
1827 no_bgp_maxmed_onstartup_cmd
,
1828 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1830 "Advertise routes with max-med\n"
1831 "Effective on a startup\n"
1832 "Time (seconds) period for max-med\n"
1833 "Max MED value to be used\n")
1835 nb_cli_enqueue_change(vty
,
1836 "./global/med-config/max-med-onstart-up-time",
1837 NB_OP_DESTROY
, NULL
);
1839 nb_cli_enqueue_change(vty
,
1840 "./global/med-config/max-med-onstart-up-value",
1841 NB_OP_MODIFY
, NULL
);
1843 return nb_cli_apply_changes(vty
, NULL
);
1846 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
1847 uint16_t update_delay
,
1848 uint16_t establish_wait
)
1850 struct listnode
*node
, *nnode
;
1852 bool vrf_cfg
= false;
1855 * See if update-delay is set per-vrf and warn user to delete it
1856 * Note that we only need to check this if this is the first time
1857 * setting the global config.
1859 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
1860 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1861 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1863 "%% update-delay configuration found in vrf %s\n",
1864 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
1874 "%%Failed: global update-delay config not permitted\n");
1878 if (!establish_wait
) { /* update-delay <delay> */
1879 bm
->v_update_delay
= update_delay
;
1880 bm
->v_establish_wait
= bm
->v_update_delay
;
1882 /* update-delay <delay> <establish-wait> */
1883 if (update_delay
< establish_wait
) {
1885 "%%Failed: update-delay less than the establish-wait!\n");
1886 return CMD_WARNING_CONFIG_FAILED
;
1889 bm
->v_update_delay
= update_delay
;
1890 bm
->v_establish_wait
= establish_wait
;
1893 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1894 bgp
->v_update_delay
= bm
->v_update_delay
;
1895 bgp
->v_establish_wait
= bm
->v_establish_wait
;
1901 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
1903 struct listnode
*node
, *nnode
;
1906 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1907 bm
->v_establish_wait
= bm
->v_update_delay
;
1909 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1910 bgp
->v_update_delay
= bm
->v_update_delay
;
1911 bgp
->v_establish_wait
= bm
->v_establish_wait
;
1917 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
1918 uint16_t establish_wait
)
1920 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1922 /* if configured globally, per-instance config is not allowed */
1923 if (bm
->v_update_delay
) {
1925 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
1926 return CMD_WARNING_CONFIG_FAILED
;
1930 if (!establish_wait
) /* update-delay <delay> */
1932 bgp
->v_update_delay
= update_delay
;
1933 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1937 /* update-delay <delay> <establish-wait> */
1938 if (update_delay
< establish_wait
) {
1940 "%%Failed: update-delay less than the establish-wait!\n");
1941 return CMD_WARNING_CONFIG_FAILED
;
1944 bgp
->v_update_delay
= update_delay
;
1945 bgp
->v_establish_wait
= establish_wait
;
1950 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1952 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1954 /* If configured globally, cannot remove from one bgp instance */
1955 if (bm
->v_update_delay
) {
1957 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
1958 return CMD_WARNING_CONFIG_FAILED
;
1960 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1961 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1966 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1968 /* If configured globally, no need to display per-instance value */
1969 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
1970 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1971 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1972 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1977 /* Global update-delay configuration */
1978 DEFPY (bgp_global_update_delay
,
1979 bgp_global_update_delay_cmd
,
1980 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
1982 "Force initial delay for best-path and updates for all bgp instances\n"
1983 "Max delay in seconds\n"
1984 "Establish wait in seconds\n")
1986 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
1989 /* Global update-delay deconfiguration */
1990 DEFPY (no_bgp_global_update_delay
,
1991 no_bgp_global_update_delay_cmd
,
1992 "no bgp update-delay [(0-3600) [(1-3600)]]",
1995 "Force initial delay for best-path and updates\n"
1996 "Max delay in seconds\n"
1997 "Establish wait in seconds\n")
1999 return bgp_global_update_delay_deconfig_vty(vty
);
2002 /* Update-delay configuration */
2004 DEFPY (bgp_update_delay
,
2005 bgp_update_delay_cmd
,
2006 "update-delay (0-3600)$delay [(1-3600)$wait]",
2007 "Force initial delay for best-path and updates\n"
2008 "Max delay in seconds\n"
2009 "Establish wait in seconds\n")
2011 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2014 /* Update-delay deconfiguration */
2015 DEFPY (no_bgp_update_delay
,
2016 no_bgp_update_delay_cmd
,
2017 "no update-delay [(0-3600) [(1-3600)]]",
2019 "Force initial delay for best-path and updates\n"
2020 "Max delay in seconds\n"
2021 "Establish wait in seconds\n")
2023 return bgp_update_delay_deconfig_vty(vty
);
2027 int bgp_wpkt_quanta_config_vty(struct bgp
*bgp
, uint32_t quanta
, bool set
)
2029 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2030 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2035 int bgp_rpkt_quanta_config_vty(struct bgp
*bgp
, uint32_t quanta
, bool set
)
2037 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2038 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2043 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2046 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2047 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2048 vty_out(vty
, " write-quanta %d\n", quanta
);
2051 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2054 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2055 if (quanta
!= BGP_READ_PACKET_MAX
)
2056 vty_out(vty
, " read-quanta %d\n", quanta
);
2059 /* Packet quanta configuration
2061 * XXX: The value set here controls the size of a stack buffer in the IO
2062 * thread. When changing these limits be careful to prevent stack overflow.
2064 * Furthermore, the maximums used here should correspond to
2065 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2067 DEFPY_YANG (bgp_wpkt_quanta
,
2068 bgp_wpkt_quanta_cmd
,
2069 "[no] write-quanta (1-64)$quanta",
2071 "How many packets to write to peer socket per run\n"
2072 "Number of packets\n")
2075 nb_cli_enqueue_change(
2077 "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta",
2078 NB_OP_MODIFY
, quanta_str
);
2080 nb_cli_enqueue_change(
2082 "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta",
2083 NB_OP_MODIFY
, NULL
);
2085 return nb_cli_apply_changes(vty
, NULL
);
2088 DEFPY_YANG (bgp_rpkt_quanta
,
2089 bgp_rpkt_quanta_cmd
,
2090 "[no] read-quanta (1-10)$quanta",
2092 "How many packets to read from peer socket per I/O cycle\n"
2093 "Number of packets\n")
2096 nb_cli_enqueue_change(
2098 "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta",
2099 NB_OP_MODIFY
, quanta_str
);
2101 nb_cli_enqueue_change(
2103 "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta",
2104 NB_OP_MODIFY
, NULL
);
2106 return nb_cli_apply_changes(vty
, NULL
);
2109 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2111 if (!bgp
->heuristic_coalesce
)
2112 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2115 void cli_show_router_global_update_group_config_coalesce_time(
2116 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2118 vty_out(vty
, " coalesce-time %u\n", yang_dnode_get_uint32(dnode
, NULL
));
2122 DEFUN_YANG (bgp_coalesce_time
,
2123 bgp_coalesce_time_cmd
,
2124 "coalesce-time (0-4294967295)",
2125 "Subgroup coalesce timer\n"
2126 "Subgroup coalesce timer value (in ms)\n")
2130 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
2131 nb_cli_enqueue_change(
2132 vty
, "./global/global-update-group-config/coalesce-time",
2133 NB_OP_MODIFY
, argv
[idx
]->arg
);
2135 return nb_cli_apply_changes(vty
, NULL
);
2138 DEFUN_YANG(no_bgp_coalesce_time
,
2139 no_bgp_coalesce_time_cmd
,
2140 "no coalesce-time (0-4294967295)",
2142 "Subgroup coalesce timer\n"
2143 "Subgroup coalesce timer value (in ms)\n")
2145 nb_cli_enqueue_change(
2146 vty
, "./global/global-update-group-config/coalesce-time",
2147 NB_OP_MODIFY
, NULL
);
2149 return nb_cli_apply_changes(vty
, NULL
);
2152 /* Maximum-paths configuration */
2153 DEFUN_YANG (bgp_maxpaths
,
2155 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2156 "Forward packets over multiple paths\n"
2157 "Number of paths\n")
2160 char base_xpath
[XPATH_MAXLEN
];
2164 afi
= bgp_node_afi(vty
);
2165 safi
= bgp_node_safi(vty
);
2168 base_xpath
, sizeof(base_xpath
),
2169 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ebgp/maximum-paths",
2170 yang_afi_safi_value2identity(afi
, safi
),
2171 bgp_afi_safi_get_container_str(afi
, safi
));
2173 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2174 argv
[idx_number
]->arg
);
2176 return nb_cli_apply_changes(vty
, NULL
);
2179 void cli_show_bgp_global_afi_safi_unicast_use_multiple_paths_ebgp_maximum_paths(
2180 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2182 vty_out(vty
, " maximum-paths %d\n",
2183 yang_dnode_get_uint16(dnode
, NULL
));
2186 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2187 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2188 "Forward packets over multiple paths\n"
2189 "Number of paths\n")
2191 DEFUN_YANG (bgp_maxpaths_ibgp
,
2192 bgp_maxpaths_ibgp_cmd
,
2193 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2194 "Forward packets over multiple paths\n"
2196 "Number of paths\n")
2199 char base_xpath
[XPATH_MAXLEN
];
2203 afi
= bgp_node_afi(vty
);
2204 safi
= bgp_node_safi(vty
);
2207 base_xpath
, sizeof(base_xpath
),
2208 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2209 yang_afi_safi_value2identity(afi
, safi
),
2210 bgp_afi_safi_get_container_str(afi
, safi
));
2212 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2213 argv
[idx_number
]->arg
);
2215 return nb_cli_apply_changes(vty
, NULL
);
2218 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2219 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2220 "Forward packets over multiple paths\n"
2222 "Number of paths\n")
2224 DEFUN_YANG (bgp_maxpaths_ibgp_cluster
,
2225 bgp_maxpaths_ibgp_cluster_cmd
,
2226 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2227 "Forward packets over multiple paths\n"
2230 "Match the cluster length\n")
2233 char base_xpath
[XPATH_MAXLEN
];
2237 afi
= bgp_node_afi(vty
);
2238 safi
= bgp_node_safi(vty
);
2241 base_xpath
, sizeof(base_xpath
),
2242 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2243 yang_afi_safi_value2identity(afi
, safi
),
2244 bgp_afi_safi_get_container_str(afi
, safi
));
2246 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2247 argv
[idx_number
]->arg
);
2250 base_xpath
, sizeof(base_xpath
),
2251 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/cluster-length-list",
2252 yang_afi_safi_value2identity(afi
, safi
),
2253 bgp_afi_safi_get_container_str(afi
, safi
));
2255 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, "true");
2257 return nb_cli_apply_changes(vty
, NULL
);
2260 void cli_show_bgp_global_afi_safi_ip_unicast_use_multiple_paths_ibgp_maximum_paths(
2261 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2263 vty_out(vty
, " maximum-paths ibgp %d",
2264 yang_dnode_get_uint16(dnode
, "./maximum-paths"));
2265 if (yang_dnode_get_bool(dnode
, "./cluster-length-list"))
2266 vty_out(vty
, " equal-cluster-length");
2270 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2271 "maximum-paths ibgp " CMD_RANGE_STR(
2272 1, MULTIPATH_NUM
) " equal-cluster-length",
2273 "Forward packets over multiple paths\n"
2276 "Match the cluster length\n")
2278 DEFUN_YANG (no_bgp_maxpaths
,
2279 no_bgp_maxpaths_cmd
,
2280 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2282 "Forward packets over multiple paths\n"
2283 "Number of paths\n")
2285 char base_xpath
[XPATH_MAXLEN
];
2289 afi
= bgp_node_afi(vty
);
2290 safi
= bgp_node_safi(vty
);
2293 base_xpath
, sizeof(base_xpath
),
2294 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ebgp/maximum-paths",
2295 yang_afi_safi_value2identity(afi
, safi
),
2296 bgp_afi_safi_get_container_str(afi
, safi
));
2298 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, NULL
);
2300 return nb_cli_apply_changes(vty
, NULL
);
2303 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2304 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2305 "Forward packets over multiple paths\n"
2306 "Number of paths\n")
2308 DEFUN_YANG (no_bgp_maxpaths_ibgp
,
2309 no_bgp_maxpaths_ibgp_cmd
,
2310 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2312 "Forward packets over multiple paths\n"
2315 "Match the cluster length\n")
2317 char base_xpath
[XPATH_MAXLEN
];
2321 afi
= bgp_node_afi(vty
);
2322 safi
= bgp_node_safi(vty
);
2325 base_xpath
, sizeof(base_xpath
),
2326 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2327 yang_afi_safi_value2identity(afi
, safi
),
2328 bgp_afi_safi_get_container_str(afi
, safi
));
2330 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, NULL
);
2333 base_xpath
, sizeof(base_xpath
),
2334 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/cluster-length-list",
2335 yang_afi_safi_value2identity(afi
, safi
),
2336 bgp_afi_safi_get_container_str(afi
, safi
));
2338 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, "false");
2340 return nb_cli_apply_changes(vty
, NULL
);
2343 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2344 "no maximum-paths ibgp [" CMD_RANGE_STR(
2345 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2347 "Forward packets over multiple paths\n"
2350 "Match the cluster length\n")
2352 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2353 afi_t afi
, safi_t safi
)
2355 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2356 vty_out(vty
, " maximum-paths %d\n",
2357 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2360 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2361 vty_out(vty
, " maximum-paths ibgp %d",
2362 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2363 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
2364 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
2365 vty_out(vty
, " equal-cluster-length");
2372 DEFUN_YANG (bgp_timers
,
2374 "timers bgp (0-65535) (0-65535)",
2375 "Adjust routing timers\n"
2377 "Keepalive interval\n"
2381 int idx_number_2
= 3;
2383 nb_cli_enqueue_change(vty
, "./global/global-config-timers/keepalive",
2384 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
2385 nb_cli_enqueue_change(vty
, "./global/global-config-timers/hold-time",
2386 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
2388 return nb_cli_apply_changes(vty
, NULL
);
2391 DEFUN_YANG (no_bgp_timers
,
2393 "no timers bgp [(0-65535) (0-65535)]",
2395 "Adjust routing timers\n"
2397 "Keepalive interval\n"
2400 nb_cli_enqueue_change(vty
, "./global/global-config-timers/keepalive",
2401 NB_OP_DESTROY
, NULL
);
2402 nb_cli_enqueue_change(vty
, "./global/global-config-timers/hold-time",
2403 NB_OP_DESTROY
, NULL
);
2405 return nb_cli_apply_changes(vty
, NULL
);
2408 void cli_show_router_bgp_route_reflector(struct vty
*vty
,
2409 struct lyd_node
*dnode
,
2412 if (yang_dnode_get_bool(dnode
, "./no-client-reflect"))
2413 vty_out(vty
, " no bgp client-to-client reflection\n");
2415 if (yang_dnode_get_bool(dnode
, "./allow-outbound-policy"))
2416 vty_out(vty
, " bgp route-reflector allow-outbound-policy\n");
2418 if (yang_dnode_exists(dnode
, "./route-reflector-cluster-id"))
2419 vty_out(vty
, " bgp cluster-id %s\n",
2420 yang_dnode_get_string(dnode
,
2421 "./route-reflector-cluster-id"));
2424 DEFUN_YANG(bgp_client_to_client_reflection
,
2425 bgp_client_to_client_reflection_cmd
,
2426 "bgp client-to-client reflection",
2427 "BGP specific commands\n"
2428 "Configure client to client route reflection\n"
2429 "reflection of routes allowed\n")
2431 nb_cli_enqueue_change(vty
, "./global/route-reflector/no-client-reflect",
2432 NB_OP_MODIFY
, "false");
2434 return nb_cli_apply_changes(vty
, NULL
);
2437 DEFUN_YANG(no_bgp_client_to_client_reflection
,
2438 no_bgp_client_to_client_reflection_cmd
,
2439 "no bgp client-to-client reflection",
2441 "BGP specific commands\n"
2442 "Configure client to client route reflection\n"
2443 "reflection of routes allowed\n")
2445 nb_cli_enqueue_change(vty
, "./global/route-reflector/no-client-reflect",
2446 NB_OP_MODIFY
, "true");
2448 return nb_cli_apply_changes(vty
, NULL
);
2451 void cli_show_router_bgp_route_selection(struct vty
*vty
,
2452 struct lyd_node
*dnode
,
2456 if (yang_dnode_get_bool(dnode
, "./always-compare-med"))
2457 vty_out(vty
, " bgp always-compare-med\n");
2459 if (yang_dnode_get_bool(dnode
, "./ignore-as-path-length"))
2460 vty_out(vty
, " bgp bestpath as-path ignore\n");
2462 if (yang_dnode_get_bool(dnode
, "./aspath-confed"))
2463 vty_out(vty
, " bgp bestpath as-path confed\n");
2465 if (yang_dnode_get_bool(dnode
, "./external-compare-router-id"))
2466 vty_out(vty
, " bgp bestpath compare-routerid\n");
2468 if (yang_dnode_get_bool(dnode
, "./allow-multiple-as")) {
2469 if (yang_dnode_get_bool(dnode
, "./multi-path-as-set"))
2471 " bgp bestpath as-path multipath-relax as-set\n");
2473 vty_out(vty
, " bgp bestpath as-path multipath-relax\n");
2476 if (yang_dnode_get_bool(dnode
, "./deterministic-med"))
2477 vty_out(vty
, " bgp deterministic-med\n");
2479 if (yang_dnode_get_bool(dnode
, "./confed-med")
2480 || yang_dnode_get_bool(dnode
, "./missing-as-worst-med")) {
2481 vty_out(vty
, " bgp bestpath med");
2482 if (yang_dnode_get_bool(dnode
, "./confed-med"))
2483 vty_out(vty
, " confed");
2484 if (yang_dnode_get_bool(dnode
, "./missing-as-worst-med"))
2485 vty_out(vty
, " missing-as-worst");
2490 /* "bgp always-compare-med" configuration. */
2491 DEFUN_YANG(bgp_always_compare_med
,
2492 bgp_always_compare_med_cmd
,
2493 "bgp always-compare-med",
2494 "BGP specific commands\n"
2495 "Allow comparing MED from different neighbors\n")
2497 nb_cli_enqueue_change(
2498 vty
, "./global/route-selection-options/always-compare-med",
2499 NB_OP_MODIFY
, "true");
2501 return nb_cli_apply_changes(vty
, NULL
);
2504 DEFUN_YANG(no_bgp_always_compare_med
,
2505 no_bgp_always_compare_med_cmd
,
2506 "no bgp always-compare-med",
2508 "BGP specific commands\n"
2509 "Allow comparing MED from different neighbors\n")
2511 nb_cli_enqueue_change(
2512 vty
, "./global/route-selection-options/always-compare-med",
2513 NB_OP_MODIFY
, "false");
2515 return nb_cli_apply_changes(vty
, NULL
);
2518 DEFUN_YANG(bgp_ebgp_requires_policy
,
2519 bgp_ebgp_requires_policy_cmd
,
2520 "bgp ebgp-requires-policy",
2521 "BGP specific commands\n"
2522 "Require in and out policy for eBGP peers (RFC8212)\n")
2524 nb_cli_enqueue_change(vty
, "./global/ebgp-requires-policy",
2525 NB_OP_MODIFY
, "true");
2526 return nb_cli_apply_changes(vty
, NULL
);
2529 DEFUN_YANG(no_bgp_ebgp_requires_policy
,
2530 no_bgp_ebgp_requires_policy_cmd
,
2531 "no bgp ebgp-requires-policy",
2533 "BGP specific commands\n"
2534 "Require in and out policy for eBGP peers (RFC8212)\n")
2536 nb_cli_enqueue_change(vty
, "./global/ebgp-requires-policy",
2537 NB_OP_MODIFY
, "false");
2538 return nb_cli_apply_changes(vty
, NULL
);
2541 void cli_show_router_bgp_ebgp_requires_policy(struct vty
*vty
,
2542 struct lyd_node
*dnode
,
2545 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_EBGP_REQUIRES_POLICY
)
2546 vty_out(vty
, " bgp ebgp-requires-policy\n");
2549 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2550 "bgp reject-as-sets",
2551 "BGP specific commands\n"
2552 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2554 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2555 struct listnode
*node
, *nnode
;
2558 bgp
->reject_as_sets
= true;
2560 /* Reset existing BGP sessions to reject routes
2561 * with aspath containing AS_SET or AS_CONFED_SET.
2563 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2564 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2565 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2566 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2567 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2574 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2575 "no bgp reject-as-sets",
2577 "BGP specific commands\n"
2578 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2580 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2581 struct listnode
*node
, *nnode
;
2584 bgp
->reject_as_sets
= false;
2586 /* Reset existing BGP sessions to reject routes
2587 * with aspath containing AS_SET or AS_CONFED_SET.
2589 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2590 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2591 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2592 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2593 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2600 /* "bgp deterministic-med" configuration. */
2601 DEFUN_YANG (bgp_deterministic_med
,
2602 bgp_deterministic_med_cmd
,
2603 "bgp deterministic-med",
2604 "BGP specific commands\n"
2605 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2607 nb_cli_enqueue_change(
2608 vty
, "./global/route-selection-options/deterministic-med",
2609 NB_OP_MODIFY
, "true");
2611 return nb_cli_apply_changes(vty
, NULL
);
2614 DEFUN_YANG (no_bgp_deterministic_med
,
2615 no_bgp_deterministic_med_cmd
,
2616 "no bgp deterministic-med",
2618 "BGP specific commands\n"
2619 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2621 nb_cli_enqueue_change(
2622 vty
, "./global/route-selection-options/deterministic-med",
2623 NB_OP_MODIFY
, "false");
2625 return nb_cli_apply_changes(vty
, NULL
);
2628 /* "bgp graceful-restart mode" configuration. */
2629 DEFUN (bgp_graceful_restart
,
2630 bgp_graceful_restart_cmd
,
2631 "bgp graceful-restart",
2632 "BGP specific commands\n"
2636 int ret
= BGP_GR_FAILURE
;
2638 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2639 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2641 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2643 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2645 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2648 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2649 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2651 "Graceful restart configuration changed, reset all peers to take effect\n");
2652 return bgp_vty_return(vty
, ret
);
2655 DEFUN (no_bgp_graceful_restart
,
2656 no_bgp_graceful_restart_cmd
,
2657 "no bgp graceful-restart",
2659 "BGP specific commands\n"
2663 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2665 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2666 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2668 int ret
= BGP_GR_FAILURE
;
2670 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2672 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2675 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2676 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2678 "Graceful restart configuration changed, reset all peers to take effect\n");
2680 return bgp_vty_return(vty
, ret
);
2683 DEFUN (bgp_graceful_restart_stalepath_time
,
2684 bgp_graceful_restart_stalepath_time_cmd
,
2685 "bgp graceful-restart stalepath-time (1-4095)",
2686 "BGP specific commands\n"
2687 "Graceful restart capability parameters\n"
2688 "Set the max time to hold onto restarting peer's stale paths\n"
2689 "Delay value (seconds)\n")
2691 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2695 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2696 bgp
->stalepath_time
= stalepath
;
2700 DEFUN (bgp_graceful_restart_restart_time
,
2701 bgp_graceful_restart_restart_time_cmd
,
2702 "bgp graceful-restart restart-time (1-4095)",
2703 "BGP specific commands\n"
2704 "Graceful restart capability parameters\n"
2705 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2706 "Delay value (seconds)\n")
2708 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2712 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2713 bgp
->restart_time
= restart
;
2717 DEFUN (bgp_graceful_restart_select_defer_time
,
2718 bgp_graceful_restart_select_defer_time_cmd
,
2719 "bgp graceful-restart select-defer-time (0-3600)",
2720 "BGP specific commands\n"
2721 "Graceful restart capability parameters\n"
2722 "Set the time to defer the BGP route selection after restart\n"
2723 "Delay value (seconds, 0 - disable)\n")
2725 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2727 uint32_t defer_time
;
2729 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2730 bgp
->select_defer_time
= defer_time
;
2731 if (defer_time
== 0)
2732 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2734 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2739 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2740 no_bgp_graceful_restart_stalepath_time_cmd
,
2741 "no bgp graceful-restart stalepath-time [(1-4095)]",
2743 "BGP specific commands\n"
2744 "Graceful restart capability parameters\n"
2745 "Set the max time to hold onto restarting peer's stale paths\n"
2746 "Delay value (seconds)\n")
2748 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2750 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2754 DEFUN (no_bgp_graceful_restart_restart_time
,
2755 no_bgp_graceful_restart_restart_time_cmd
,
2756 "no bgp graceful-restart restart-time [(1-4095)]",
2758 "BGP specific commands\n"
2759 "Graceful restart capability parameters\n"
2760 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2761 "Delay value (seconds)\n")
2763 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2765 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2769 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2770 no_bgp_graceful_restart_select_defer_time_cmd
,
2771 "no bgp graceful-restart select-defer-time [(0-3600)]",
2773 "BGP specific commands\n"
2774 "Graceful restart capability parameters\n"
2775 "Set the time to defer the BGP route selection after restart\n"
2776 "Delay value (seconds)\n")
2778 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2780 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2781 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2786 DEFUN (bgp_graceful_restart_preserve_fw
,
2787 bgp_graceful_restart_preserve_fw_cmd
,
2788 "bgp graceful-restart preserve-fw-state",
2789 "BGP specific commands\n"
2790 "Graceful restart capability parameters\n"
2791 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2793 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2794 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2798 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2799 no_bgp_graceful_restart_preserve_fw_cmd
,
2800 "no bgp graceful-restart preserve-fw-state",
2802 "BGP specific commands\n"
2803 "Graceful restart capability parameters\n"
2804 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2806 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2807 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2811 DEFUN (bgp_graceful_restart_disable
,
2812 bgp_graceful_restart_disable_cmd
,
2813 "bgp graceful-restart-disable",
2814 "BGP specific commands\n"
2817 int ret
= BGP_GR_FAILURE
;
2819 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2821 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
2823 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2825 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
2827 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
2830 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2832 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
2834 "Graceful restart configuration changed, reset all peers to take effect\n");
2836 return bgp_vty_return(vty
, ret
);
2839 DEFUN (no_bgp_graceful_restart_disable
,
2840 no_bgp_graceful_restart_disable_cmd
,
2841 "no bgp graceful-restart-disable",
2843 "BGP specific commands\n"
2847 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2849 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2851 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
2853 int ret
= BGP_GR_FAILURE
;
2855 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
2857 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2860 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2862 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
2864 "Graceful restart configuration changed, reset all peers to take effect\n");
2866 return bgp_vty_return(vty
, ret
);
2869 DEFUN (bgp_neighbor_graceful_restart_set
,
2870 bgp_neighbor_graceful_restart_set_cmd
,
2871 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
2879 int ret
= BGP_GR_FAILURE
;
2881 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2883 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2885 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
2887 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2889 return CMD_WARNING_CONFIG_FAILED
;
2891 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
2893 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2894 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2896 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2898 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
2900 "Graceful restart configuration changed, reset this peer to take effect\n");
2902 return bgp_vty_return(vty
, ret
);
2905 DEFUN (no_bgp_neighbor_graceful_restart
,
2906 no_bgp_neighbor_graceful_restart_set_cmd
,
2907 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
2915 int ret
= BGP_GR_FAILURE
;
2918 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2920 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2922 return CMD_WARNING_CONFIG_FAILED
;
2924 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2926 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
2928 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
2930 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2931 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2933 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2935 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
2937 "Graceful restart configuration changed, reset this peer to take effect\n");
2939 return bgp_vty_return(vty
, ret
);
2942 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
2943 bgp_neighbor_graceful_restart_helper_set_cmd
,
2944 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
2947 GR_NEIGHBOR_HELPER_CMD
2952 int ret
= BGP_GR_FAILURE
;
2954 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2956 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2958 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
2960 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2963 return CMD_WARNING_CONFIG_FAILED
;
2966 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
2968 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2969 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2971 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2973 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
2975 "Graceful restart configuration changed, reset this peer to take effect\n");
2977 return bgp_vty_return(vty
, ret
);
2980 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
2981 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
2982 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
2986 NO_GR_NEIGHBOR_HELPER_CMD
2990 int ret
= BGP_GR_FAILURE
;
2993 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2995 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2997 return CMD_WARNING_CONFIG_FAILED
;
2999 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3001 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3003 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3005 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3006 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3008 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3010 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3012 "Graceful restart configuration changed, reset this peer to take effect\n");
3014 return bgp_vty_return(vty
, ret
);
3017 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3018 bgp_neighbor_graceful_restart_disable_set_cmd
,
3019 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3022 GR_NEIGHBOR_DISABLE_CMD
3027 int ret
= BGP_GR_FAILURE
;
3029 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3031 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3033 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3035 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3037 return CMD_WARNING_CONFIG_FAILED
;
3039 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3041 if (peer
->bgp
->t_startup
)
3042 bgp_peer_gr_flags_update(peer
);
3044 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3045 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3047 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3049 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3051 "Graceful restart configuration changed, reset this peer to take effect\n");
3053 return bgp_vty_return(vty
, ret
);
3056 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3057 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3058 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3062 NO_GR_NEIGHBOR_DISABLE_CMD
3066 int ret
= BGP_GR_FAILURE
;
3069 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3071 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3073 return CMD_WARNING_CONFIG_FAILED
;
3075 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3077 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3079 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3081 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3082 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3084 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3086 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3088 "Graceful restart configuration changed, reset this peer to take effect\n");
3090 return bgp_vty_return(vty
, ret
);
3093 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3094 bgp_graceful_restart_disable_eor_cmd
,
3095 "bgp graceful-restart disable-eor",
3096 "BGP specific commands\n"
3097 "Graceful restart configuration parameters\n"
3098 "Disable EOR Check\n")
3100 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3101 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3106 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3107 no_bgp_graceful_restart_disable_eor_cmd
,
3108 "no bgp graceful-restart disable-eor",
3110 "BGP specific commands\n"
3111 "Graceful restart configuration parameters\n"
3112 "Disable EOR Check\n")
3114 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3115 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3120 DEFUN (bgp_graceful_restart_rib_stale_time
,
3121 bgp_graceful_restart_rib_stale_time_cmd
,
3122 "bgp graceful-restart rib-stale-time (1-3600)",
3123 "BGP specific commands\n"
3124 "Graceful restart configuration parameters\n"
3125 "Specify the stale route removal timer in rib\n"
3126 "Delay value (seconds)\n")
3128 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3130 uint32_t stale_time
;
3132 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3133 bgp
->rib_stale_time
= stale_time
;
3134 /* Send the stale timer update message to RIB */
3135 if (bgp_zebra_stale_timer_update(bgp
))
3141 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3142 no_bgp_graceful_restart_rib_stale_time_cmd
,
3143 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3145 "BGP specific commands\n"
3146 "Graceful restart configuration parameters\n"
3147 "Specify the stale route removal timer in rib\n"
3148 "Delay value (seconds)\n")
3150 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3152 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3153 /* Send the stale timer update message to RIB */
3154 if (bgp_zebra_stale_timer_update(bgp
))
3160 static inline int bgp_initiate_graceful_shut_unshut(struct bgp
*bgp
,
3164 bgp_static_redo_import_check(bgp
);
3165 bgp_redistribute_redo(bgp
);
3166 if (bgp_clear_star_soft_out(bgp
->name
, errmsg
, errmsg_len
) < 0)
3168 if (bgp_clear_star_soft_in(bgp
->name
, errmsg
, errmsg_len
) < 0)
3174 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3176 struct listnode
*node
, *nnode
;
3178 bool vrf_cfg
= false;
3179 char errmsg
[BUFSIZ
] = {'\0'};
3181 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3184 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3185 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3186 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3188 "%% graceful-shutdown configuration found in vrf %s\n",
3189 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3190 VRF_DEFAULT_NAME
: bgp
->name
);
3197 "%%Failed: global graceful-shutdown not permitted\n");
3201 /* Set flag globally */
3202 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3204 /* Initiate processing for all BGP instances. */
3205 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3206 if (bgp_initiate_graceful_shut_unshut(bgp
, errmsg
,
3210 vty_out(vty
, "%s\n", errmsg
);
3216 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3218 struct listnode
*node
, *nnode
;
3220 char errmsg
[BUFSIZ
] = {'\0'};
3222 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3225 /* Unset flag globally */
3226 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3228 /* Initiate processing for all BGP instances. */
3229 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3230 if (bgp_initiate_graceful_shut_unshut(bgp
, errmsg
,
3234 vty_out(vty
, "%s\n", errmsg
);
3240 /* "bgp graceful-shutdown" configuration */
3241 DEFUN (bgp_graceful_shutdown
,
3242 bgp_graceful_shutdown_cmd
,
3243 "bgp graceful-shutdown",
3245 "Graceful shutdown parameters\n")
3247 if (vty
->node
== CONFIG_NODE
)
3248 return bgp_global_graceful_shutdown_config_vty(vty
);
3250 nb_cli_enqueue_change(vty
, "./global/graceful-shutdown/enable",
3251 NB_OP_MODIFY
, "true");
3253 return nb_cli_apply_changes(vty
, NULL
);
3256 DEFUN_YANG (no_bgp_graceful_shutdown
,
3257 no_bgp_graceful_shutdown_cmd
,
3258 "no bgp graceful-shutdown",
3261 "Graceful shutdown parameters\n")
3263 if (vty
->node
== CONFIG_NODE
)
3264 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3266 nb_cli_enqueue_change(vty
, "./global/graceful-shutdown/enable",
3267 NB_OP_MODIFY
, "false");
3269 return nb_cli_apply_changes(vty
, NULL
);
3272 void cli_show_router_bgp_graceful_shutdown(struct vty
*vty
,
3273 struct lyd_node
*dnode
,
3276 if (yang_dnode_get_bool(dnode
, NULL
))
3277 vty_out(vty
, " bgp graceful-shutdown\n");
3280 /* "bgp fast-external-failover" configuration. */
3281 DEFUN_YANG (bgp_fast_external_failover
,
3282 bgp_fast_external_failover_cmd
,
3283 "bgp fast-external-failover",
3285 "Immediately reset session if a link to a directly connected external peer goes down\n")
3287 nb_cli_enqueue_change(vty
, "./global/fast-external-failover",
3288 NB_OP_MODIFY
, "false");
3290 return nb_cli_apply_changes(vty
, NULL
);
3293 DEFUN_YANG (no_bgp_fast_external_failover
,
3294 no_bgp_fast_external_failover_cmd
,
3295 "no bgp fast-external-failover",
3298 "Immediately reset session if a link to a directly connected external peer goes down\n")
3300 nb_cli_enqueue_change(vty
, "./global/fast-external-failover",
3301 NB_OP_MODIFY
, "true");
3303 return nb_cli_apply_changes(vty
, NULL
);
3306 void cli_show_router_bgp_fast_external_failover(struct vty
*vty
,
3307 struct lyd_node
*dnode
,
3310 if (!yang_dnode_get_bool(dnode
, NULL
))
3311 vty_out(vty
, " no bgp fast-external-failover\n");
3314 /* "bgp bestpath compare-routerid" configuration. */
3315 DEFUN_YANG(bgp_bestpath_compare_router_id
,
3316 bgp_bestpath_compare_router_id_cmd
,
3317 "bgp bestpath compare-routerid",
3318 "BGP specific commands\n"
3319 "Change the default bestpath selection\n"
3320 "Compare router-id for identical EBGP paths\n")
3322 nb_cli_enqueue_change(
3324 "./global/route-selection-options/external-compare-router-id",
3325 NB_OP_MODIFY
, "true");
3327 return nb_cli_apply_changes(vty
, NULL
);
3330 DEFUN_YANG(no_bgp_bestpath_compare_router_id
,
3331 no_bgp_bestpath_compare_router_id_cmd
,
3332 "no bgp bestpath compare-routerid",
3334 "BGP specific commands\n"
3335 "Change the default bestpath selection\n"
3336 "Compare router-id for identical EBGP paths\n")
3338 nb_cli_enqueue_change(
3340 "./global/route-selection-options/external-compare-router-id",
3341 NB_OP_MODIFY
, "false");
3343 return nb_cli_apply_changes(vty
, NULL
);
3346 /* "bgp bestpath as-path ignore" configuration. */
3347 DEFUN_YANG(bgp_bestpath_aspath_ignore
,
3348 bgp_bestpath_aspath_ignore_cmd
,
3349 "bgp bestpath as-path ignore",
3350 "BGP specific commands\n"
3351 "Change the default bestpath selection\n"
3352 "AS-path attribute\n"
3353 "Ignore as-path length in selecting a route\n")
3355 nb_cli_enqueue_change(
3356 vty
, "./global/route-selection-options/ignore-as-path-length",
3357 NB_OP_MODIFY
, "true");
3359 return nb_cli_apply_changes(vty
, NULL
);
3362 DEFUN_YANG(no_bgp_bestpath_aspath_ignore
,
3363 no_bgp_bestpath_aspath_ignore_cmd
,
3364 "no bgp bestpath as-path ignore",
3366 "BGP specific commands\n"
3367 "Change the default bestpath selection\n"
3368 "AS-path attribute\n"
3369 "Ignore as-path length in selecting a route\n")
3371 nb_cli_enqueue_change(
3372 vty
, "./global/route-selection-options/ignore-as-path-length",
3373 NB_OP_MODIFY
, "false");
3375 return nb_cli_apply_changes(vty
, NULL
);
3378 /* "bgp bestpath as-path confed" configuration. */
3379 DEFUN_YANG (bgp_bestpath_aspath_confed
,
3380 bgp_bestpath_aspath_confed_cmd
,
3381 "bgp bestpath as-path confed",
3382 "BGP specific commands\n"
3383 "Change the default bestpath selection\n"
3384 "AS-path attribute\n"
3385 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3387 nb_cli_enqueue_change(vty
,
3388 "./global/route-selection-options/aspath-confed",
3389 NB_OP_MODIFY
, "true");
3391 return nb_cli_apply_changes(vty
, NULL
);
3394 DEFUN_YANG (no_bgp_bestpath_aspath_confed
,
3395 no_bgp_bestpath_aspath_confed_cmd
,
3396 "no bgp bestpath as-path confed",
3398 "BGP specific commands\n"
3399 "Change the default bestpath selection\n"
3400 "AS-path attribute\n"
3401 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3403 nb_cli_enqueue_change(vty
,
3404 "./global/route-selection-options/aspath-confed",
3405 NB_OP_MODIFY
, "false");
3407 return nb_cli_apply_changes(vty
, NULL
);
3410 /* "bgp bestpath as-path multipath-relax" configuration. */
3411 DEFUN_YANG (bgp_bestpath_aspath_multipath_relax
,
3412 bgp_bestpath_aspath_multipath_relax_cmd
,
3413 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3414 "BGP specific commands\n"
3415 "Change the default bestpath selection\n"
3416 "AS-path attribute\n"
3417 "Allow load sharing across routes that have different AS paths (but same length)\n"
3418 "Generate an AS_SET\n"
3419 "Do not generate an AS_SET\n")
3423 nb_cli_enqueue_change(
3424 vty
, "./global/route-selection-options/allow-multiple-as",
3425 NB_OP_MODIFY
, "true");
3426 if (argv_find(argv
, argc
, "as-set", &idx
))
3427 nb_cli_enqueue_change(
3429 "./global/route-selection-options/multi-path-as-set",
3430 NB_OP_MODIFY
, "true");
3432 nb_cli_enqueue_change(
3434 "./global/route-selection-options/multi-path-as-set",
3435 NB_OP_MODIFY
, "false");
3437 return nb_cli_apply_changes(vty
, NULL
);
3440 DEFUN_YANG (no_bgp_bestpath_aspath_multipath_relax
,
3441 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3442 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3444 "BGP specific commands\n"
3445 "Change the default bestpath selection\n"
3446 "AS-path attribute\n"
3447 "Allow load sharing across routes that have different AS paths (but same length)\n"
3448 "Generate an AS_SET\n"
3449 "Do not generate an AS_SET\n")
3451 nb_cli_enqueue_change(
3452 vty
, "./global/route-selection-options/allow-multiple-as",
3453 NB_OP_MODIFY
, "false");
3454 nb_cli_enqueue_change(
3455 vty
, "./global/route-selection-options/multi-path-as-set",
3456 NB_OP_MODIFY
, "false");
3458 return nb_cli_apply_changes(vty
, NULL
);
3461 /* "bgp log-neighbor-changes" configuration. */
3462 DEFUN_YANG(bgp_log_neighbor_changes
,
3463 bgp_log_neighbor_changes_cmd
,
3464 "bgp log-neighbor-changes",
3465 "BGP specific commands\n"
3466 "Log neighbor up/down and reset reason\n")
3468 nb_cli_enqueue_change(
3469 vty
, "./global/global-neighbor-config/log-neighbor-changes",
3470 NB_OP_MODIFY
, "true");
3472 return nb_cli_apply_changes(vty
, NULL
);
3475 DEFUN_YANG(no_bgp_log_neighbor_changes
,
3476 no_bgp_log_neighbor_changes_cmd
,
3477 "no bgp log-neighbor-changes",
3479 "BGP specific commands\n"
3480 "Log neighbor up/down and reset reason\n")
3482 nb_cli_enqueue_change(
3483 vty
, "./global/global-neighbor-config/log-neighbor-changes",
3484 NB_OP_MODIFY
, "false");
3486 return nb_cli_apply_changes(vty
, NULL
);
3489 /* "bgp bestpath med" configuration. */
3490 DEFUN_YANG (bgp_bestpath_med
,
3491 bgp_bestpath_med_cmd
,
3492 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3493 "BGP specific commands\n"
3494 "Change the default bestpath selection\n"
3496 "Compare MED among confederation paths\n"
3497 "Treat missing MED as the least preferred one\n"
3498 "Treat missing MED as the least preferred one\n"
3499 "Compare MED among confederation paths\n")
3502 bool confed
= false;
3503 bool worst_med
= false;
3506 if (argv_find(argv
, argc
, "confed", &idx
))
3509 nb_cli_enqueue_change(vty
,
3510 "./global/route-selection-options/confed-med",
3511 NB_OP_MODIFY
, confed
? "true" : "false");
3514 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3517 nb_cli_enqueue_change(
3518 vty
, "./global/route-selection-options/missing-as-worst-med",
3519 NB_OP_MODIFY
, worst_med
? "true" : "false");
3521 return nb_cli_apply_changes(vty
, NULL
);
3524 DEFUN_YANG (no_bgp_bestpath_med
,
3525 no_bgp_bestpath_med_cmd
,
3526 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3528 "BGP specific commands\n"
3529 "Change the default bestpath selection\n"
3531 "Compare MED among confederation paths\n"
3532 "Treat missing MED as the least preferred one\n"
3533 "Treat missing MED as the least preferred one\n"
3534 "Compare MED among confederation paths\n")
3538 if (argv_find(argv
, argc
, "confed", &idx
))
3539 nb_cli_enqueue_change(
3540 vty
, "./global/route-selection-options/confed-med",
3541 NB_OP_MODIFY
, "false");
3544 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3545 nb_cli_enqueue_change(
3547 "./global/route-selection-options/missing-as-worst-med",
3548 NB_OP_MODIFY
, "false");
3550 return nb_cli_apply_changes(vty
, NULL
);
3553 /* "bgp bestpath bandwidth" configuration. */
3554 DEFPY (bgp_bestpath_bw
,
3555 bgp_bestpath_bw_cmd
,
3556 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3557 "BGP specific commands\n"
3558 "Change the default bestpath selection\n"
3559 "Link Bandwidth attribute\n"
3560 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3561 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3562 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3564 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3569 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3570 return CMD_ERR_INCOMPLETE
;
3572 if (!strcmp(bw_cfg
, "ignore"))
3573 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3574 else if (!strcmp(bw_cfg
, "skip-missing"))
3575 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3576 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3577 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3579 return CMD_ERR_NO_MATCH
;
3581 /* This config is used in route install, so redo that. */
3582 FOREACH_AFI_SAFI (afi
, safi
) {
3583 if (!bgp_fibupd_safi(safi
))
3585 bgp_zebra_announce_table(bgp
, afi
, safi
);
3591 DEFPY (no_bgp_bestpath_bw
,
3592 no_bgp_bestpath_bw_cmd
,
3593 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3595 "BGP specific commands\n"
3596 "Change the default bestpath selection\n"
3597 "Link Bandwidth attribute\n"
3598 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3599 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3600 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3602 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3606 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3608 /* This config is used in route install, so redo that. */
3609 FOREACH_AFI_SAFI (afi
, safi
) {
3610 if (!bgp_fibupd_safi(safi
))
3612 bgp_zebra_announce_table(bgp
, afi
, safi
);
3617 /* "no bgp default ipv4-unicast". */
3618 DEFUN (no_bgp_default_ipv4_unicast
,
3619 no_bgp_default_ipv4_unicast_cmd
,
3620 "no bgp default ipv4-unicast",
3622 "BGP specific commands\n"
3623 "Configure BGP defaults\n"
3624 "Activate ipv4-unicast for a peer by default\n")
3626 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3627 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
);
3631 DEFUN (bgp_default_ipv4_unicast
,
3632 bgp_default_ipv4_unicast_cmd
,
3633 "bgp default ipv4-unicast",
3634 "BGP specific commands\n"
3635 "Configure BGP defaults\n"
3636 "Activate ipv4-unicast for a peer by default\n")
3638 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3639 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
);
3643 /* Display hostname in certain command outputs */
3644 DEFUN_YANG (bgp_default_show_hostname
,
3645 bgp_default_show_hostname_cmd
,
3646 "bgp default show-hostname",
3647 "BGP specific commands\n"
3648 "Configure BGP defaults\n"
3649 "Show hostname in certain command outputs\n")
3651 nb_cli_enqueue_change(vty
, "./global/show-hostname", NB_OP_MODIFY
,
3654 return nb_cli_apply_changes(vty
, NULL
);
3657 DEFUN_YANG(no_bgp_default_show_hostname
,
3658 no_bgp_default_show_hostname_cmd
,
3659 "no bgp default show-hostname",
3661 "BGP specific commands\n"
3662 "Configure BGP defaults\n"
3663 "Show hostname in certain command outputs\n")
3665 nb_cli_enqueue_change(vty
, "./global/show-hostname", NB_OP_MODIFY
,
3668 return nb_cli_apply_changes(vty
, NULL
);
3671 void cli_show_router_bgp_show_hostname(struct vty
*vty
, struct lyd_node
*dnode
,
3674 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SHOW_HOSTNAME
)
3675 vty_out(vty
, " bgp default show-hostname\n");
3678 /* Display hostname in certain command outputs */
3679 DEFUN_YANG(bgp_default_show_nexthop_hostname
,
3680 bgp_default_show_nexthop_hostname_cmd
,
3681 "bgp default show-nexthop-hostname",
3682 "BGP specific commands\n"
3683 "Configure BGP defaults\n"
3684 "Show hostname for nexthop in certain command outputs\n")
3686 nb_cli_enqueue_change(vty
, "./global/show-nexthop-hostname",
3687 NB_OP_MODIFY
, "true");
3689 return nb_cli_apply_changes(vty
, NULL
);
3692 DEFUN (no_bgp_default_show_nexthop_hostname
,
3693 no_bgp_default_show_nexthop_hostname_cmd
,
3694 "no bgp default show-nexthop-hostname",
3696 "BGP specific commands\n"
3697 "Configure BGP defaults\n"
3698 "Show hostname for nexthop in certain command outputs\n")
3700 nb_cli_enqueue_change(vty
, "./global/show-nexthop-hostname",
3701 NB_OP_MODIFY
, "false");
3703 return nb_cli_apply_changes(vty
, NULL
);
3706 void cli_show_router_bgp_show_nexthop_hostname(struct vty
*vty
,
3707 struct lyd_node
*dnode
,
3710 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SHOW_HOSTNAME
)
3711 vty_out(vty
, " bgp default show-nexthop-hostname\n");
3714 /* "bgp network import-check" configuration. */
3715 DEFUN_YANG(bgp_network_import_check
,
3716 bgp_network_import_check_cmd
,
3717 "bgp network import-check",
3718 "BGP specific commands\n"
3719 "BGP network command\n"
3720 "Check BGP network route exists in IGP\n")
3722 nb_cli_enqueue_change(vty
, "./global/import-check", NB_OP_MODIFY
,
3725 return nb_cli_apply_changes(vty
, NULL
);
3728 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
3729 "bgp network import-check exact",
3730 "BGP specific commands\n"
3731 "BGP network command\n"
3732 "Check BGP network route exists in IGP\n"
3733 "Match route precisely\n")
3735 DEFUN_YANG(no_bgp_network_import_check
,
3736 no_bgp_network_import_check_cmd
,
3737 "no bgp network import-check",
3739 "BGP specific commands\n"
3740 "BGP network command\n"
3741 "Check BGP network route exists in IGP\n")
3743 nb_cli_enqueue_change(vty
, "./global/import-check", NB_OP_MODIFY
,
3746 return nb_cli_apply_changes(vty
, NULL
);
3749 void cli_show_router_bgp_import_check(struct vty
*vty
, struct lyd_node
*dnode
,
3752 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_IMPORT_CHECK
)
3753 vty_out(vty
, " bgp network import-check\n");
3756 DEFUN_YANG(bgp_default_local_preference
,
3757 bgp_default_local_preference_cmd
,
3758 "bgp default local-preference (0-4294967295)",
3759 "BGP specific commands\n"
3760 "Configure BGP defaults\n"
3761 "local preference (higher=more preferred)\n"
3762 "Configure default local preference value\n")
3766 nb_cli_enqueue_change(vty
, "./global/local-pref", NB_OP_MODIFY
,
3767 argv
[idx_number
]->arg
);
3769 return nb_cli_apply_changes(vty
, NULL
);
3772 DEFUN_YANG(no_bgp_default_local_preference
,
3773 no_bgp_default_local_preference_cmd
,
3774 "no bgp default local-preference [(0-4294967295)]",
3776 "BGP specific commands\n"
3777 "Configure BGP defaults\n"
3778 "local preference (higher=more preferred)\n"
3779 "Configure default local preference value\n")
3781 nb_cli_enqueue_change(vty
, "./global/local-pref", NB_OP_MODIFY
, NULL
);
3783 return nb_cli_apply_changes(vty
, NULL
);
3786 void cli_show_router_bgp_local_pref(struct vty
*vty
, struct lyd_node
*dnode
,
3789 vty_out(vty
, " bgp default local-preference %u\n",
3790 yang_dnode_get_uint32(dnode
, NULL
));
3794 DEFUN_YANG(bgp_default_subgroup_pkt_queue_max
,
3795 bgp_default_subgroup_pkt_queue_max_cmd
,
3796 "bgp default subgroup-pkt-queue-max (20-100)",
3797 "BGP specific commands\n"
3798 "Configure BGP defaults\n"
3799 "subgroup-pkt-queue-max\n"
3800 "Configure subgroup packet queue max\n")
3804 nb_cli_enqueue_change(
3806 "./global/global-update-group-config/subgroup-pkt-queue-size",
3807 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
3809 return nb_cli_apply_changes(vty
, NULL
);
3812 DEFUN_YANG(no_bgp_default_subgroup_pkt_queue_max
,
3813 no_bgp_default_subgroup_pkt_queue_max_cmd
,
3814 "no bgp default subgroup-pkt-queue-max [(20-100)]",
3816 "BGP specific commands\n"
3817 "Configure BGP defaults\n"
3818 "subgroup-pkt-queue-max\n"
3819 "Configure subgroup packet queue max\n")
3821 nb_cli_enqueue_change(
3823 "./global/global-update-group-config/subgroup-pkt-queue-size",
3824 NB_OP_MODIFY
, NULL
);
3826 return nb_cli_apply_changes(vty
, NULL
);
3829 void cli_show_router_global_update_group_config_subgroup_pkt_queue_size(
3830 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
3832 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
3833 yang_dnode_get_uint32(dnode
, NULL
));
3836 DEFUN_YANG(bgp_rr_allow_outbound_policy
,
3837 bgp_rr_allow_outbound_policy_cmd
,
3838 "bgp route-reflector allow-outbound-policy",
3839 "BGP specific commands\n"
3840 "Allow modifications made by out route-map\n"
3841 "on ibgp neighbors\n")
3843 nb_cli_enqueue_change(vty
,
3844 "./global/route-reflector/allow-outbound-policy",
3845 NB_OP_MODIFY
, "true");
3847 return nb_cli_apply_changes(vty
, NULL
);
3850 DEFUN_YANG(no_bgp_rr_allow_outbound_policy
,
3851 no_bgp_rr_allow_outbound_policy_cmd
,
3852 "no bgp route-reflector allow-outbound-policy",
3854 "BGP specific commands\n"
3855 "Allow modifications made by out route-map\n"
3856 "on ibgp neighbors\n")
3858 nb_cli_enqueue_change(vty
,
3859 "./global/route-reflector/allow-outbound-policy",
3860 NB_OP_MODIFY
, "false");
3862 return nb_cli_apply_changes(vty
, NULL
);
3866 void cli_show_router_global_neighbor_config(struct vty
*vty
,
3867 struct lyd_node
*dnode
,
3870 uint32_t write_quanta
, read_quanta
;
3872 if (yang_dnode_get_bool(dnode
, "./log-neighbor-changes"))
3873 vty_out(vty
, " bgp log-neighbor-changes\n");
3875 if (yang_dnode_exists(dnode
, "./dynamic-neighbors-limit")) {
3876 uint32_t listen_limit
= yang_dnode_get_uint32(
3877 dnode
, "./dynamic-neighbors-limit");
3878 vty_out(vty
, " bgp listen limit %u\n", listen_limit
);
3881 write_quanta
= yang_dnode_get_uint32(
3882 dnode
, "./packet-quanta-config/wpkt-quanta");
3883 if (write_quanta
!= BGP_WRITE_PACKET_MAX
)
3884 vty_out(vty
, " write-quanta %d\n", write_quanta
);
3886 read_quanta
= yang_dnode_get_uint32(
3887 dnode
, "./packet-quanta-config/rpkt-quanta");
3889 if (read_quanta
!= BGP_READ_PACKET_MAX
)
3890 vty_out(vty
, " read-quanta %d\n", read_quanta
);
3893 DEFUN_YANG(bgp_listen_limit
,
3894 bgp_listen_limit_cmd
,
3895 "bgp listen limit (1-5000)",
3896 "BGP specific commands\n"
3897 "BGP Dynamic Neighbors listen commands\n"
3898 "Maximum number of BGP Dynamic Neighbors that can be created\n"
3899 "Configure Dynamic Neighbors listen limit value\n")
3903 nb_cli_enqueue_change(
3904 vty
, "./global/global-neighbor-config/dynamic-neighbors-limit",
3905 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
3907 return nb_cli_apply_changes(vty
, NULL
);
3910 DEFUN_YANG(no_bgp_listen_limit
,
3911 no_bgp_listen_limit_cmd
,
3912 "no bgp listen limit [(1-5000)]",
3914 "BGP specific commands\n"
3915 "BGP Dynamic Neighbors listen commands\n"
3916 "Maximum number of BGP Dynamic Neighbors that can be created\n"
3917 "Configure Dynamic Neighbors listen limit value\n")
3919 nb_cli_enqueue_change(
3920 vty
, "./global/global-neighbor-config/dynamic-neighbors-limit",
3921 NB_OP_DESTROY
, NULL
);
3923 return nb_cli_apply_changes(vty
, NULL
);
3928 * Check if this listen range is already configured. Check for exact
3929 * match or overlap based on input.
3931 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
3932 struct prefix
*range
, int exact
)
3934 struct listnode
*node
, *nnode
;
3935 struct listnode
*node1
, *nnode1
;
3936 struct peer_group
*group
;
3941 afi
= family2afi(range
->family
);
3942 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
3943 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
3946 match
= prefix_same(range
, lr
);
3948 match
= (prefix_match(range
, lr
)
3949 || prefix_match(lr
, range
));
3958 DEFUN (bgp_listen_range
,
3959 bgp_listen_range_cmd
,
3960 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
3961 "BGP specific commands\n"
3962 "Configure BGP dynamic neighbors listen range\n"
3963 "Configure BGP dynamic neighbors listen range\n"
3965 "Member of the peer-group\n"
3966 "Peer-group name\n")
3968 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3969 struct prefix range
;
3970 struct peer_group
*group
, *existing_group
;
3975 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
3976 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
3977 char *prefix
= argv
[idx
]->arg
;
3978 argv_find(argv
, argc
, "PGNAME", &idx
);
3979 char *peergroup
= argv
[idx
]->arg
;
3981 /* Convert IP prefix string to struct prefix. */
3982 ret
= str2prefix(prefix
, &range
);
3984 vty_out(vty
, "%% Malformed listen range\n");
3985 return CMD_WARNING_CONFIG_FAILED
;
3988 afi
= family2afi(range
.family
);
3990 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
3992 "%% Malformed listen range (link-local address)\n");
3993 return CMD_WARNING_CONFIG_FAILED
;
3998 /* Check if same listen range is already configured. */
3999 existing_group
= listen_range_exists(bgp
, &range
, 1);
4000 if (existing_group
) {
4001 if (strcmp(existing_group
->name
, peergroup
) == 0)
4005 "%% Same listen range is attached to peer-group %s\n",
4006 existing_group
->name
);
4007 return CMD_WARNING_CONFIG_FAILED
;
4011 /* Check if an overlapping listen range exists. */
4012 if (listen_range_exists(bgp
, &range
, 0)) {
4014 "%% Listen range overlaps with existing listen range\n");
4015 return CMD_WARNING_CONFIG_FAILED
;
4018 group
= peer_group_lookup(bgp
, peergroup
);
4020 vty_out(vty
, "%% Configure the peer-group first\n");
4021 return CMD_WARNING_CONFIG_FAILED
;
4024 ret
= peer_group_listen_range_add(group
, &range
);
4025 return bgp_vty_return(vty
, ret
);
4028 DEFUN (no_bgp_listen_range
,
4029 no_bgp_listen_range_cmd
,
4030 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4032 "BGP specific commands\n"
4033 "Unconfigure BGP dynamic neighbors listen range\n"
4034 "Unconfigure BGP dynamic neighbors listen range\n"
4036 "Member of the peer-group\n"
4037 "Peer-group name\n")
4039 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4040 struct prefix range
;
4041 struct peer_group
*group
;
4046 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4047 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4048 char *prefix
= argv
[idx
]->arg
;
4049 argv_find(argv
, argc
, "PGNAME", &idx
);
4050 char *peergroup
= argv
[idx
]->arg
;
4052 /* Convert IP prefix string to struct prefix. */
4053 ret
= str2prefix(prefix
, &range
);
4055 vty_out(vty
, "%% Malformed listen range\n");
4056 return CMD_WARNING_CONFIG_FAILED
;
4059 afi
= family2afi(range
.family
);
4061 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4063 "%% Malformed listen range (link-local address)\n");
4064 return CMD_WARNING_CONFIG_FAILED
;
4069 group
= peer_group_lookup(bgp
, peergroup
);
4071 vty_out(vty
, "%% Peer-group does not exist\n");
4072 return CMD_WARNING_CONFIG_FAILED
;
4075 ret
= peer_group_listen_range_del(group
, &range
);
4076 return bgp_vty_return(vty
, ret
);
4079 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4081 struct peer_group
*group
;
4082 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4083 struct prefix
*range
;
4086 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4087 vty_out(vty
, " bgp listen limit %d\n",
4088 bgp
->dynamic_neighbors_limit
);
4090 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4091 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4092 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4095 " bgp listen range %pFX peer-group %s\n",
4096 range
, group
->name
);
4103 DEFUN_YANG(bgp_disable_connected_route_check
,
4104 bgp_disable_connected_route_check_cmd
,
4105 "bgp disable-ebgp-connected-route-check",
4106 "BGP specific commands\n"
4107 "Disable checking if nexthop is connected on ebgp sessions\n")
4109 nb_cli_enqueue_change(vty
,
4110 "./global/ebgp-multihop-connected-route-check",
4111 NB_OP_MODIFY
, "true");
4113 return nb_cli_apply_changes(vty
, NULL
);
4116 DEFUN_YANG(no_bgp_disable_connected_route_check
,
4117 no_bgp_disable_connected_route_check_cmd
,
4118 "no bgp disable-ebgp-connected-route-check",
4120 "BGP specific commands\n"
4121 "Disable checking if nexthop is connected on ebgp sessions\n")
4123 nb_cli_enqueue_change(vty
,
4124 "./global/ebgp-multihop-connected-route-check",
4125 NB_OP_MODIFY
, "false");
4127 return nb_cli_apply_changes(vty
, NULL
);
4130 void cli_show_router_global_ebgp_multihop_connected_route_check(
4131 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
4133 if (yang_dnode_get_bool(dnode
, NULL
))
4134 vty_out(vty
, " bgp disable-ebgp-connected-route-check\n");
4137 DEFUN_YANG(bgp_default_shutdown
,
4138 bgp_default_shutdown_cmd
,
4139 "[no] bgp default shutdown",
4141 "Configure BGP defaults\n"
4142 "Apply administrative shutdown to newly configured peers\n")
4144 nb_cli_enqueue_change(vty
, "./global/default-shutdown", NB_OP_MODIFY
,
4145 strmatch(argv
[0]->text
, "no") ? "false" : "true");
4147 return nb_cli_apply_changes(vty
, NULL
);
4150 void cli_show_router_bgp_default_shutdown(struct vty
*vty
,
4151 struct lyd_node
*dnode
,
4154 if (yang_dnode_get_bool(dnode
, NULL
))
4155 vty_out(vty
, " bgp default shutdown\n");
4158 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4160 "Administrative shutdown of the BGP instance\n"
4161 "Add a shutdown message (RFC 8203)\n"
4162 "Shutdown message\n")
4164 char *msgstr
= NULL
;
4166 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4169 msgstr
= argv_concat(argv
, argc
, 3);
4171 bgp_shutdown_enable(bgp
, msgstr
);
4172 XFREE(MTYPE_TMP
, msgstr
);
4177 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4178 BGP_STR
"Administrative shutdown of the BGP instance\n")
4180 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4182 bgp_shutdown_enable(bgp
, NULL
);
4187 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4188 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4190 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4192 bgp_shutdown_disable(bgp
);
4197 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4198 "no bgp shutdown message MSG...", NO_STR BGP_STR
4199 "Administrative shutdown of the BGP instance\n"
4200 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4202 DEFUN_YANG(neighbor_remote_as
,
4203 neighbor_remote_as_cmd
,
4204 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4205 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4206 "Specify a BGP neighbor\n" AS_STR
4207 "Internal BGP peer\n"
4208 "External BGP peer\n")
4211 int idx_remote_as
= 3;
4212 char base_xpath
[XPATH_MAXLEN
];
4213 char unnbr_xpath
[XPATH_MAXLEN
];
4214 char prgrp_xpath
[XPATH_MAXLEN
];
4216 const char *as_type_str
= "as-specified";
4218 if (str2sockunion(argv
[idx_peer
]->arg
, &su
) < 0) {
4219 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
4220 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, argv
[idx_peer
]->arg
, "");
4222 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
4223 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
, "");
4225 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4226 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4227 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4228 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
,
4229 "%s%s", VTY_CURR_XPATH
,
4231 snprintf(base_xpath
, sizeof(base_xpath
),
4232 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
,
4236 "%% Create the peer-group or interface first\n");
4237 return CMD_WARNING_CONFIG_FAILED
;
4240 snprintf(base_xpath
, sizeof(base_xpath
),
4241 FRR_BGP_NEIGHBOR_NUM_XPATH
, argv
[idx_peer
]->arg
, "");
4244 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4245 as_type_str
= "internal";
4246 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4247 as_type_str
= "external";
4249 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4250 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4252 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4253 NB_OP_MODIFY
, as_type_str
);
4255 return nb_cli_apply_changes(vty
, base_xpath
);
4258 int peer_conf_interface_create(struct bgp
*bgp
, const char *conf_if
, afi_t afi
,
4259 safi_t safi
, bool v6only
,
4260 const char *peer_group_name
, int as_type
,
4261 as_t as
, char *errmsg
, size_t errmsg_len
)
4264 struct peer_group
*group
;
4267 group
= peer_group_lookup(bgp
, conf_if
);
4270 snprintf(errmsg
, errmsg_len
,
4271 "Name conflict with peer-group \n");
4275 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4277 if (as_type
!= AS_UNSPECIFIED
)
4278 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
4281 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
)
4282 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
4283 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
4284 as_type
, 0, 0, NULL
);
4286 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
4287 as_type
, afi
, safi
, NULL
);
4290 snprintf(errmsg
, errmsg_len
,
4291 "BGP failed to create peer\n");
4296 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4298 /* Request zebra to initiate IPv6 RAs on this interface. We do
4300 * any unnumbered peer in order to not worry about run-time
4302 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4304 * gets deleted later etc.)
4307 bgp_zebra_initiate_radv(bgp
, peer
);
4310 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4311 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4313 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4315 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4317 /* v6only flag changed. Reset bgp seesion */
4318 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4319 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4320 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4321 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4323 bgp_session_reset(peer
);
4326 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4327 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4328 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4329 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4332 if (peer_group_name
) {
4333 group
= peer_group_lookup(bgp
, peer_group_name
);
4335 snprintf(errmsg
, errmsg_len
,
4336 "Configure the peer-group first\n");
4340 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4343 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
4346 DEFUN_YANG(neighbor_interface_config
,
4347 neighbor_interface_config_cmd
,
4348 "neighbor WORD interface [peer-group PGNAME]",
4350 "Interface name or neighbor tag\n"
4351 "Enable BGP on interface\n"
4352 "Member of the peer-group\n"
4353 "Peer-group name\n")
4356 int idx_peer_group_word
= 4;
4357 char base_xpath
[XPATH_MAXLEN
];
4359 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4360 argv
[idx_word
]->arg
, "");
4362 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4363 if (argc
> idx_peer_group_word
)
4364 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_MODIFY
,
4365 argv
[idx_peer_group_word
]->arg
);
4367 return nb_cli_apply_changes(vty
, base_xpath
);
4370 DEFUN_YANG(neighbor_interface_config_v6only
,
4371 neighbor_interface_config_v6only_cmd
,
4372 "neighbor WORD interface v6only [peer-group PGNAME]",
4374 "Interface name or neighbor tag\n"
4375 "Enable BGP on interface\n"
4376 "Enable BGP with v6 link-local only\n"
4377 "Member of the peer-group\n"
4378 "Peer-group name\n")
4381 int idx_peer_group_word
= 5;
4382 char base_xpath
[XPATH_MAXLEN
];
4384 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4385 argv
[idx_word
]->arg
, "");
4387 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4388 if (argc
> idx_peer_group_word
)
4389 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_MODIFY
,
4390 argv
[idx_peer_group_word
]->arg
);
4392 nb_cli_enqueue_change(vty
, "./v6only", NB_OP_MODIFY
, "true");
4394 return nb_cli_apply_changes(vty
, base_xpath
);
4399 neighbor_interface_config_remote_as
,
4400 neighbor_interface_config_remote_as_cmd
,
4401 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4403 "Interface name or neighbor tag\n"
4404 "Enable BGP on interface\n"
4405 "Specify a BGP neighbor\n" AS_STR
4406 "Internal BGP peer\n"
4407 "External BGP peer\n")
4410 int idx_remote_as
= 4;
4411 char base_xpath
[XPATH_MAXLEN
];
4412 const char *as_type_str
= "as-specified";
4414 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4415 argv
[idx_word
]->arg
, "");
4417 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4419 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4420 as_type_str
= "internal";
4421 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4422 as_type_str
= "external";
4424 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4425 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4427 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4428 NB_OP_MODIFY
, as_type_str
);
4430 return nb_cli_apply_changes(vty
, base_xpath
);
4434 neighbor_interface_v6only_config_remote_as
,
4435 neighbor_interface_v6only_config_remote_as_cmd
,
4436 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4438 "Interface name or neighbor tag\n"
4439 "Enable BGP with v6 link-local only\n"
4440 "Enable BGP on interface\n"
4441 "Specify a BGP neighbor\n" AS_STR
4442 "Internal BGP peer\n"
4443 "External BGP peer\n")
4446 int idx_remote_as
= 5;
4447 char base_xpath
[XPATH_MAXLEN
];
4448 const char *as_type_str
= "as-specified";
4450 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4451 argv
[idx_word
]->arg
, "");
4453 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4455 nb_cli_enqueue_change(vty
, "./v6only", NB_OP_MODIFY
, "true");
4457 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4458 as_type_str
= "internal";
4459 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4460 as_type_str
= "external";
4462 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4463 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4465 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4466 NB_OP_MODIFY
, as_type_str
);
4468 return nb_cli_apply_changes(vty
, base_xpath
);
4471 DEFUN_YANG(neighbor_peer_group
, neighbor_peer_group_cmd
,
4472 "neighbor WORD peer-group",
4474 "Interface name or neighbor tag\n"
4475 "Configure peer-group\n")
4477 char base_xpath
[XPATH_MAXLEN
];
4480 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4481 argv
[idx_word
]->arg
, "");
4483 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4485 return nb_cli_apply_changes(vty
, base_xpath
);
4488 DEFUN_YANG(no_neighbor
,
4490 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4493 "Specify a BGP neighbor\n" AS_STR
4494 "Internal BGP peer\n"
4495 "External BGP peer\n")
4498 char base_xpath
[XPATH_MAXLEN
];
4499 char num_xpath
[XPATH_MAXLEN
];
4500 char unnbr_xpath
[XPATH_MAXLEN
];
4501 char prgrp_xpath
[XPATH_MAXLEN
];
4504 if (str2sockunion(argv
[idx_peer
]->arg
, &su
) == 0) {
4505 snprintf(num_xpath
, sizeof(num_xpath
),
4506 FRR_BGP_NEIGHBOR_NUM_XPATH
, argv
[idx_peer
]->arg
, "");
4507 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4508 VTY_CURR_XPATH
, num_xpath
+ 1)) {
4509 strlcpy(base_xpath
, num_xpath
, sizeof(base_xpath
));
4512 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
4513 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, argv
[idx_peer
]->arg
, "");
4515 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
4516 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
, "");
4518 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4519 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4520 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4521 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
,
4522 "%s%s", VTY_CURR_XPATH
,
4524 strlcpy(base_xpath
, prgrp_xpath
, sizeof(base_xpath
));
4527 "%% Create the peer-group or interface first\n");
4528 return CMD_WARNING_CONFIG_FAILED
;
4532 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_DESTROY
, NULL
);
4534 return nb_cli_apply_changes(vty
, NULL
);
4537 DEFUN_YANG(no_neighbor_interface_config
,
4538 no_neighbor_interface_config_cmd
,
4539 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4542 "Configure BGP on interface\n"
4543 "Enable BGP with v6 link-local only\n"
4544 "Member of the peer-group\n"
4546 "Specify a BGP neighbor\n" AS_STR
4547 "Internal BGP peer\n"
4548 "External BGP peer\n")
4551 char base_xpath
[XPATH_MAXLEN
];
4553 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4554 argv
[idx_word
]->arg
, "");
4556 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
4558 return nb_cli_apply_changes(vty
, base_xpath
);
4561 DEFUN_YANG(no_neighbor_peer_group
,
4562 no_neighbor_peer_group_cmd
,
4563 "no neighbor WORD peer-group",
4566 "Configure peer-group\n")
4568 char base_xpath
[XPATH_MAXLEN
];
4571 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4572 argv
[idx_word
]->arg
, "");
4574 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
4576 return nb_cli_apply_changes(vty
, base_xpath
);
4579 DEFUN_YANG(no_neighbor_interface_peer_group_remote_as
,
4580 no_neighbor_interface_peer_group_remote_as_cmd
,
4581 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4583 "Interface name or neighbor tag\n"
4584 "Specify a BGP neighbor\n" AS_STR
4585 "Internal BGP peer\n"
4586 "External BGP peer\n")
4589 char base_xpath
[XPATH_MAXLEN
];
4590 char unnbr_xpath
[XPATH_MAXLEN
];
4591 char prgrp_xpath
[XPATH_MAXLEN
];
4593 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4594 argv
[idx_peer
]->arg
, "");
4596 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4597 argv
[idx_peer
]->arg
, "");
4599 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4600 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4601 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4602 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4603 VTY_CURR_XPATH
, prgrp_xpath
+ 1)) {
4604 strlcpy(base_xpath
, prgrp_xpath
, sizeof(base_xpath
));
4606 vty_out(vty
, "%% Create the peer-group or interface first\n");
4607 return CMD_WARNING_CONFIG_FAILED
;
4610 strlcat(base_xpath
, "/neighbor-remote-as/remote-as-type",
4611 sizeof(base_xpath
));
4613 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_DESTROY
, NULL
);
4615 return nb_cli_apply_changes(vty
, NULL
);
4618 DEFUN_YANG(neighbor_local_as
,
4619 neighbor_local_as_cmd
,
4620 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4621 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4622 "Specify a local-as number\n"
4623 "AS number used as local AS\n")
4627 char base_xpath
[XPATH_MAXLEN
];
4629 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4630 sizeof(base_xpath
), NULL
)
4632 return CMD_WARNING_CONFIG_FAILED
;
4634 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4635 argv
[idx_number
]->arg
);
4637 return nb_cli_apply_changes(vty
, base_xpath
);
4641 neighbor_local_as_no_prepend
, neighbor_local_as_no_prepend_cmd
,
4642 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4643 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4644 "Specify a local-as number\n"
4645 "AS number used as local AS\n"
4646 "Do not prepend local-as to updates from ebgp peers\n")
4650 char base_xpath
[XPATH_MAXLEN
];
4652 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4653 sizeof(base_xpath
), NULL
)
4655 return CMD_WARNING_CONFIG_FAILED
;
4657 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4658 argv
[idx_number
]->arg
);
4659 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4662 return nb_cli_apply_changes(vty
, base_xpath
);
4666 neighbor_local_as_no_prepend_replace_as
,
4667 neighbor_local_as_no_prepend_replace_as_cmd
,
4668 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4669 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4670 "Specify a local-as number\n"
4671 "AS number used as local AS\n"
4672 "Do not prepend local-as to updates from ebgp peers\n"
4673 "Do not prepend local-as to updates from ibgp peers\n")
4677 char base_xpath
[XPATH_MAXLEN
];
4679 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4680 sizeof(base_xpath
), NULL
)
4682 return CMD_WARNING_CONFIG_FAILED
;
4684 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4685 argv
[idx_number
]->arg
);
4686 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4688 nb_cli_enqueue_change(vty
, "./local-as/no-replace-as", NB_OP_MODIFY
,
4691 return nb_cli_apply_changes(vty
, base_xpath
);
4694 DEFUN_YANG(no_neighbor_local_as
,
4695 no_neighbor_local_as_cmd
,
4696 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4697 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4698 "Specify a local-as number\n"
4699 "AS number used as local AS\n"
4700 "Do not prepend local-as to updates from ebgp peers\n"
4701 "Do not prepend local-as to updates from ibgp peers\n")
4704 char base_xpath
[XPATH_MAXLEN
];
4706 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4707 sizeof(base_xpath
), NULL
)
4709 return CMD_WARNING_CONFIG_FAILED
;
4711 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_DESTROY
, NULL
);
4712 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4714 nb_cli_enqueue_change(vty
, "./local-as/no-replace-as", NB_OP_MODIFY
,
4717 return nb_cli_apply_changes(vty
, base_xpath
);
4721 DEFUN (neighbor_solo
,
4723 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4726 "Solo peer - part of its own update group\n")
4732 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4734 return CMD_WARNING_CONFIG_FAILED
;
4736 ret
= update_group_adjust_soloness(peer
, 1);
4737 return bgp_vty_return(vty
, ret
);
4740 DEFUN (no_neighbor_solo
,
4741 no_neighbor_solo_cmd
,
4742 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4746 "Solo peer - part of its own update group\n")
4752 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4754 return CMD_WARNING_CONFIG_FAILED
;
4756 ret
= update_group_adjust_soloness(peer
, 0);
4757 return bgp_vty_return(vty
, ret
);
4760 DEFUN_YANG(neighbor_password
,
4761 neighbor_password_cmd
,
4762 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
4763 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4769 char base_xpath
[XPATH_MAXLEN
];
4771 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4772 sizeof(base_xpath
), NULL
)
4774 return CMD_WARNING_CONFIG_FAILED
;
4776 nb_cli_enqueue_change(vty
, "./password", NB_OP_MODIFY
,
4777 argv
[idx_line
]->arg
);
4779 return nb_cli_apply_changes(vty
, base_xpath
);
4782 DEFUN_YANG(no_neighbor_password
,
4783 no_neighbor_password_cmd
,
4784 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
4785 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4790 char base_xpath
[XPATH_MAXLEN
];
4792 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4793 sizeof(base_xpath
), NULL
)
4795 return CMD_WARNING_CONFIG_FAILED
;
4797 nb_cli_enqueue_change(vty
, "./password", NB_OP_DESTROY
, NULL
);
4799 return nb_cli_apply_changes(vty
, base_xpath
);
4802 DEFUN_YANG(neighbor_activate
,
4803 neighbor_activate_cmd
,
4804 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4805 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4806 "Enable the Address Family for this Neighbor\n")
4809 char base_xpath
[XPATH_MAXLEN
];
4810 char af_xpath
[XPATH_MAXLEN
];
4811 afi_t afi
= bgp_node_afi(vty
);
4812 safi_t safi
= bgp_node_safi(vty
);
4814 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
4815 yang_afi_safi_value2identity(afi
, safi
));
4816 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4817 sizeof(base_xpath
), af_xpath
)
4819 return CMD_WARNING_CONFIG_FAILED
;
4821 nb_cli_enqueue_change(vty
, "./enabled", NB_OP_MODIFY
, "true");
4823 return nb_cli_apply_changes(vty
, base_xpath
);
4826 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
4827 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4828 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4829 "Enable the Address Family for this Neighbor\n")
4831 DEFUN_YANG(no_neighbor_activate
,
4832 no_neighbor_activate_cmd
,
4833 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4836 "Enable the Address Family for this Neighbor\n")
4839 char base_xpath
[XPATH_MAXLEN
];
4840 char af_xpath
[XPATH_MAXLEN
];
4841 afi_t afi
= bgp_node_afi(vty
);
4842 safi_t safi
= bgp_node_safi(vty
);
4844 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
4845 yang_afi_safi_value2identity(afi
, safi
));
4847 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4848 sizeof(base_xpath
), af_xpath
)
4850 return CMD_WARNING_CONFIG_FAILED
;
4852 nb_cli_enqueue_change(vty
, "./enabled", NB_OP_MODIFY
, "false");
4854 return nb_cli_apply_changes(vty
, base_xpath
);
4857 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
4858 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4859 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4860 "Enable the Address Family for this Neighbor\n")
4862 DEFUN_YANG (neighbor_set_peer_group
,
4863 neighbor_set_peer_group_cmd
,
4864 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4867 "Member of the peer-group\n"
4868 "Peer-group name\n")
4872 char base_xpath
[XPATH_MAXLEN
];
4874 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4875 sizeof(base_xpath
), NULL
)
4877 return CMD_WARNING_CONFIG_FAILED
;
4879 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_MODIFY
,
4880 argv
[idx_word
]->arg
);
4882 return nb_cli_apply_changes(vty
, base_xpath
);
4885 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
4886 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4887 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4888 "Member of the peer-group\n"
4889 "Peer-group name\n")
4891 DEFUN_YANG (no_neighbor_set_peer_group
,
4892 no_neighbor_set_peer_group_cmd
,
4893 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4897 "Member of the peer-group\n"
4898 "Peer-group name\n")
4901 char base_xpath
[XPATH_MAXLEN
];
4903 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4904 sizeof(base_xpath
), NULL
)
4906 return CMD_WARNING_CONFIG_FAILED
;
4908 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_DESTROY
, NULL
);
4910 return nb_cli_apply_changes(vty
, base_xpath
);
4913 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
4914 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4915 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4916 "Member of the peer-group\n"
4917 "Peer-group name\n")
4919 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
4920 uint32_t flag
, int set
)
4925 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4927 return CMD_WARNING_CONFIG_FAILED
;
4930 * If 'neighbor <interface>', then this is for directly connected peers,
4931 * we should not accept disable-connected-check.
4933 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
4935 "%s is directly connected peer, cannot accept disable-connected-check\n",
4937 return CMD_WARNING_CONFIG_FAILED
;
4940 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
4941 peer_tx_shutdown_message_unset(peer
);
4944 ret
= peer_flag_set(peer
, flag
);
4946 ret
= peer_flag_unset(peer
, flag
);
4948 return bgp_vty_return(vty
, ret
);
4951 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
4953 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
4956 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
4959 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
4962 int peer_flag_modify_nb(struct bgp
*bgp
, const char *ip_str
, struct peer
*peer
,
4963 uint32_t flag
, bool set
, char *errmsg
,
4969 * If 'neighbor <interface>', then this is for directly connected peers,
4970 * we should not accept disable-connected-check.
4972 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
4975 "%s is directly connected peer, cannot accept disable-connected-check\n",
4980 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
4981 peer_tx_shutdown_message_unset(peer
);
4984 ret
= peer_flag_set(peer
, flag
);
4986 ret
= peer_flag_unset(peer
, flag
);
4988 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
4991 /* neighbor passive. */
4992 DEFUN_YANG(neighbor_passive
,
4993 neighbor_passive_cmd
,
4994 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
4997 "Don't send open messages to this neighbor\n")
5000 char base_xpath
[XPATH_MAXLEN
];
5002 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5003 sizeof(base_xpath
), NULL
)
5005 return CMD_WARNING_CONFIG_FAILED
;
5007 nb_cli_enqueue_change(vty
, "./passive-mode", NB_OP_MODIFY
, "true");
5009 return nb_cli_apply_changes(vty
, base_xpath
);
5012 DEFUN_YANG(no_neighbor_passive
,
5013 no_neighbor_passive_cmd
,
5014 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5017 "Don't send open messages to this neighbor\n")
5020 char base_xpath
[XPATH_MAXLEN
];
5022 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5023 sizeof(base_xpath
), NULL
)
5025 return CMD_WARNING_CONFIG_FAILED
;
5027 nb_cli_enqueue_change(vty
, "./passive-mode", NB_OP_MODIFY
, "false");
5029 return nb_cli_apply_changes(vty
, base_xpath
);
5032 /* neighbor shutdown. */
5033 DEFUN_YANG(neighbor_shutdown_msg
,
5034 neighbor_shutdown_msg_cmd
,
5035 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5036 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5037 "Administratively shut down this neighbor\n"
5038 "Add a shutdown message (RFC 8203)\n"
5039 "Shutdown message\n")
5042 char base_xpath
[XPATH_MAXLEN
];
5044 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5045 sizeof(base_xpath
), NULL
)
5047 return CMD_WARNING_CONFIG_FAILED
;
5052 message
= argv_concat(argv
, argc
, 4);
5053 nb_cli_enqueue_change(vty
, "./admin-shutdown/message",
5054 NB_OP_MODIFY
, message
);
5057 nb_cli_enqueue_change(vty
, "./admin-shutdown/enable", NB_OP_MODIFY
,
5060 return nb_cli_apply_changes(vty
, base_xpath
);
5063 ALIAS_YANG(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5064 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5065 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5066 "Administratively shut down this neighbor\n")
5068 DEFUN_YANG(no_neighbor_shutdown_msg
,
5069 no_neighbor_shutdown_msg_cmd
,
5070 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5073 "Administratively shut down this neighbor\n"
5074 "Remove a shutdown message (RFC 8203)\n"
5075 "Shutdown message\n")
5078 char base_xpath
[XPATH_MAXLEN
];
5080 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5081 sizeof(base_xpath
), NULL
)
5083 return CMD_WARNING_CONFIG_FAILED
;
5085 nb_cli_enqueue_change(vty
, "./admin-shutdown/enable", NB_OP_MODIFY
,
5088 return nb_cli_apply_changes(vty
, base_xpath
);
5091 ALIAS_YANG(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5092 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5093 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5094 "Administratively shut down this neighbor\n")
5096 DEFUN(neighbor_shutdown_rtt
,
5097 neighbor_shutdown_rtt_cmd
,
5098 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5101 "Administratively shut down this neighbor\n"
5102 "Shutdown if round-trip-time is higher than expected\n"
5103 "Round-trip-time in milliseconds\n"
5104 "Specify the number of keepalives before shutdown\n"
5105 "The number of keepalives with higher RTT to shutdown\n")
5112 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5115 return CMD_WARNING_CONFIG_FAILED
;
5117 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5119 if (argv_find(argv
, argc
, "count", &idx_count
))
5120 peer
->rtt_keepalive_conf
=
5121 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5123 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5124 PEER_FLAG_RTT_SHUTDOWN
);
5127 DEFUN(no_neighbor_shutdown_rtt
,
5128 no_neighbor_shutdown_rtt_cmd
,
5129 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5133 "Administratively shut down this neighbor\n"
5134 "Shutdown if round-trip-time is higher than expected\n"
5135 "Round-trip-time in milliseconds\n"
5136 "Specify the number of keepalives before shutdown\n"
5137 "The number of keepalives with higher RTT to shutdown\n")
5142 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5145 return CMD_WARNING_CONFIG_FAILED
;
5147 peer
->rtt_expected
= 0;
5148 peer
->rtt_keepalive_conf
= 1;
5150 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5151 PEER_FLAG_RTT_SHUTDOWN
);
5154 /* neighbor capability dynamic. */
5155 DEFUN_YANG (neighbor_capability_dynamic
,
5156 neighbor_capability_dynamic_cmd
,
5157 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5160 "Advertise capability to the peer\n"
5161 "Advertise dynamic capability to this neighbor\n")
5164 char base_xpath
[XPATH_MAXLEN
];
5166 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5167 sizeof(base_xpath
), NULL
)
5169 return CMD_WARNING_CONFIG_FAILED
;
5171 nb_cli_enqueue_change(vty
, "./capability-options/dynamic-capability",
5172 NB_OP_MODIFY
, "true");
5174 return nb_cli_apply_changes(vty
, base_xpath
);
5177 DEFUN_YANG (no_neighbor_capability_dynamic
,
5178 no_neighbor_capability_dynamic_cmd
,
5179 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5183 "Advertise capability to the peer\n"
5184 "Advertise dynamic capability to this neighbor\n")
5187 char base_xpath
[XPATH_MAXLEN
];
5189 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5190 sizeof(base_xpath
), NULL
)
5192 return CMD_WARNING_CONFIG_FAILED
;
5194 nb_cli_enqueue_change(vty
, "./capability-options/dynamic-capability",
5195 NB_OP_MODIFY
, "false");
5197 return nb_cli_apply_changes(vty
, base_xpath
);
5200 /* neighbor dont-capability-negotiate */
5201 DEFUN (neighbor_dont_capability_negotiate
,
5202 neighbor_dont_capability_negotiate_cmd
,
5203 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5206 "Do not perform capability negotiation\n")
5209 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5210 PEER_FLAG_DONT_CAPABILITY
);
5213 DEFUN (no_neighbor_dont_capability_negotiate
,
5214 no_neighbor_dont_capability_negotiate_cmd
,
5215 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5219 "Do not perform capability negotiation\n")
5222 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5223 PEER_FLAG_DONT_CAPABILITY
);
5226 /* neighbor capability extended next hop encoding */
5227 DEFUN_YANG (neighbor_capability_enhe
,
5228 neighbor_capability_enhe_cmd
,
5229 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5232 "Advertise capability to the peer\n"
5233 "Advertise extended next-hop capability to the peer\n")
5236 char base_xpath
[XPATH_MAXLEN
];
5238 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5239 sizeof(base_xpath
), NULL
)
5241 return CMD_WARNING_CONFIG_FAILED
;
5243 nb_cli_enqueue_change(
5244 vty
, "./capability-options/extended-nexthop-capability",
5245 NB_OP_MODIFY
, "true");
5247 return nb_cli_apply_changes(vty
, base_xpath
);
5250 DEFUN_YANG (no_neighbor_capability_enhe
,
5251 no_neighbor_capability_enhe_cmd
,
5252 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5256 "Advertise capability to the peer\n"
5257 "Advertise extended next-hop capability to the peer\n")
5260 char base_xpath
[XPATH_MAXLEN
];
5262 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5263 sizeof(base_xpath
), NULL
)
5265 return CMD_WARNING_CONFIG_FAILED
;
5267 nb_cli_enqueue_change(
5268 vty
, "./capability-options/extended-nexthop-capability",
5269 NB_OP_MODIFY
, "false");
5271 return nb_cli_apply_changes(vty
, base_xpath
);
5274 int peer_af_flag_modify_nb(struct peer
*peer
, afi_t afi
, safi_t safi
,
5275 uint32_t flag
, int set
, char *errmsg
,
5281 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5283 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5285 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
5288 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5289 afi_t afi
, safi_t safi
, uint32_t flag
,
5295 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5297 return CMD_WARNING_CONFIG_FAILED
;
5300 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5302 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5304 return bgp_vty_return(vty
, ret
);
5307 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5308 afi_t afi
, safi_t safi
, uint32_t flag
)
5310 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5313 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5314 afi_t afi
, safi_t safi
, uint32_t flag
)
5316 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5319 /* neighbor capability orf prefix-list. */
5320 DEFUN (neighbor_capability_orf_prefix
,
5321 neighbor_capability_orf_prefix_cmd
,
5322 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5325 "Advertise capability to the peer\n"
5326 "Advertise ORF capability to the peer\n"
5327 "Advertise prefixlist ORF capability to this neighbor\n"
5328 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5329 "Capability to RECEIVE the ORF from this neighbor\n"
5330 "Capability to SEND the ORF to this neighbor\n")
5332 int idx_send_recv
= 5;
5333 char *peer_str
= argv
[1]->arg
;
5335 afi_t afi
= bgp_node_afi(vty
);
5336 safi_t safi
= bgp_node_safi(vty
);
5338 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5340 return CMD_WARNING_CONFIG_FAILED
;
5342 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5343 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5344 PEER_FLAG_ORF_PREFIX_SM
);
5346 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5347 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5348 PEER_FLAG_ORF_PREFIX_RM
);
5350 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5351 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5352 PEER_FLAG_ORF_PREFIX_SM
)
5353 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5354 PEER_FLAG_ORF_PREFIX_RM
);
5356 return CMD_WARNING_CONFIG_FAILED
;
5360 neighbor_capability_orf_prefix
,
5361 neighbor_capability_orf_prefix_hidden_cmd
,
5362 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5363 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5364 "Advertise capability to the peer\n"
5365 "Advertise ORF capability to the peer\n"
5366 "Advertise prefixlist ORF capability to this neighbor\n"
5367 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5368 "Capability to RECEIVE the ORF from this neighbor\n"
5369 "Capability to SEND the ORF to this neighbor\n")
5371 DEFUN (no_neighbor_capability_orf_prefix
,
5372 no_neighbor_capability_orf_prefix_cmd
,
5373 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5377 "Advertise capability to the peer\n"
5378 "Advertise ORF capability to the peer\n"
5379 "Advertise prefixlist ORF capability to this neighbor\n"
5380 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5381 "Capability to RECEIVE the ORF from this neighbor\n"
5382 "Capability to SEND the ORF to this neighbor\n")
5384 int idx_send_recv
= 6;
5385 char *peer_str
= argv
[2]->arg
;
5387 afi_t afi
= bgp_node_afi(vty
);
5388 safi_t safi
= bgp_node_safi(vty
);
5390 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5392 return CMD_WARNING_CONFIG_FAILED
;
5394 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5395 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5396 PEER_FLAG_ORF_PREFIX_SM
);
5398 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5399 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5400 PEER_FLAG_ORF_PREFIX_RM
);
5402 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5403 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5404 PEER_FLAG_ORF_PREFIX_SM
)
5405 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5406 PEER_FLAG_ORF_PREFIX_RM
);
5408 return CMD_WARNING_CONFIG_FAILED
;
5412 no_neighbor_capability_orf_prefix
,
5413 no_neighbor_capability_orf_prefix_hidden_cmd
,
5414 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5415 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5416 "Advertise capability to the peer\n"
5417 "Advertise ORF capability to the peer\n"
5418 "Advertise prefixlist ORF capability to this neighbor\n"
5419 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5420 "Capability to RECEIVE the ORF from this neighbor\n"
5421 "Capability to SEND the ORF to this neighbor\n")
5423 /* neighbor next-hop-self. */
5424 DEFUN_YANG (neighbor_nexthop_self
,
5425 neighbor_nexthop_self_cmd
,
5426 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5429 "Disable the next hop calculation for this neighbor\n")
5432 char base_xpath
[XPATH_MAXLEN
];
5433 char af_xpath
[XPATH_MAXLEN
];
5434 char attr_xpath
[XPATH_MAXLEN
];
5435 afi_t afi
= bgp_node_afi(vty
);
5436 safi_t safi
= bgp_node_safi(vty
);
5439 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5440 yang_afi_safi_value2identity(afi
, safi
));
5442 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5443 sizeof(base_xpath
), af_xpath
)
5445 return CMD_WARNING_CONFIG_FAILED
;
5447 snprintf(attr_xpath
, sizeof(attr_xpath
),
5448 "./%s/nexthop-self/next-hop-self",
5449 bgp_afi_safi_get_container_str(afi
, safi
));
5451 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5453 return nb_cli_apply_changes(vty
, base_xpath
);
5456 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5457 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5458 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5459 "Disable the next hop calculation for this neighbor\n")
5461 /* neighbor next-hop-self. */
5462 DEFUN_YANG(neighbor_nexthop_self_force
,
5463 neighbor_nexthop_self_force_cmd
,
5464 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5467 "Disable the next hop calculation for this neighbor\n"
5468 "Set the next hop to self for reflected routes\n")
5471 char base_xpath
[XPATH_MAXLEN
];
5472 char af_xpath
[XPATH_MAXLEN
];
5473 char attr_xpath
[XPATH_MAXLEN
];
5474 afi_t afi
= bgp_node_afi(vty
);
5475 safi_t safi
= bgp_node_safi(vty
);
5478 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5479 yang_afi_safi_value2identity(afi
, safi
));
5481 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5482 sizeof(base_xpath
), af_xpath
)
5484 return CMD_WARNING_CONFIG_FAILED
;
5486 snprintf(attr_xpath
, sizeof(attr_xpath
),
5487 "./%s/nexthop-self/next-hop-self-force",
5488 bgp_afi_safi_get_container_str(afi
, safi
));
5490 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5492 return nb_cli_apply_changes(vty
, base_xpath
);
5495 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5496 neighbor_nexthop_self_force_hidden_cmd
,
5497 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5498 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5499 "Disable the next hop calculation for this neighbor\n"
5500 "Set the next hop to self for reflected routes\n")
5502 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5503 neighbor_nexthop_self_all_hidden_cmd
,
5504 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5505 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5506 "Disable the next hop calculation for this neighbor\n"
5507 "Set the next hop to self for reflected routes\n")
5509 DEFUN_YANG (no_neighbor_nexthop_self
,
5510 no_neighbor_nexthop_self_cmd
,
5511 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5515 "Disable the next hop calculation for this neighbor\n")
5518 char base_xpath
[XPATH_MAXLEN
];
5519 char af_xpath
[XPATH_MAXLEN
];
5520 char attr_xpath
[XPATH_MAXLEN
];
5521 afi_t afi
= bgp_node_afi(vty
);
5522 safi_t safi
= bgp_node_safi(vty
);
5524 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5525 yang_afi_safi_value2identity(afi
, safi
));
5527 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5528 sizeof(base_xpath
), af_xpath
)
5530 return CMD_WARNING_CONFIG_FAILED
;
5532 snprintf(attr_xpath
, sizeof(attr_xpath
),
5533 "./%s/nexthop-self/next-hop-self",
5534 bgp_afi_safi_get_container_str(afi
, safi
));
5536 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5538 return nb_cli_apply_changes(vty
, base_xpath
);
5541 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5542 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5543 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5544 "Disable the next hop calculation for this neighbor\n")
5546 DEFUN_YANG (no_neighbor_nexthop_self_force
,
5547 no_neighbor_nexthop_self_force_cmd
,
5548 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5552 "Disable the next hop calculation for this neighbor\n"
5553 "Set the next hop to self for reflected routes\n")
5556 char base_xpath
[XPATH_MAXLEN
];
5557 char af_xpath
[XPATH_MAXLEN
];
5558 char attr_xpath
[XPATH_MAXLEN
];
5559 afi_t afi
= bgp_node_afi(vty
);
5560 safi_t safi
= bgp_node_safi(vty
);
5563 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5564 yang_afi_safi_value2identity(afi
, safi
));
5566 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5567 sizeof(base_xpath
), af_xpath
)
5569 return CMD_WARNING_CONFIG_FAILED
;
5571 snprintf(attr_xpath
, sizeof(attr_xpath
),
5572 "./%s/nexthop-self/next-hop-self-force",
5573 bgp_afi_safi_get_container_str(afi
, safi
));
5575 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5577 return nb_cli_apply_changes(vty
, base_xpath
);
5580 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5581 no_neighbor_nexthop_self_force_hidden_cmd
,
5582 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5583 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5584 "Disable the next hop calculation for this neighbor\n"
5585 "Set the next hop to self for reflected routes\n")
5587 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5588 no_neighbor_nexthop_self_all_hidden_cmd
,
5589 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5590 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5591 "Disable the next hop calculation for this neighbor\n"
5592 "Set the next hop to self for reflected routes\n")
5594 /* neighbor as-override */
5595 DEFUN_YANG (neighbor_as_override
,
5596 neighbor_as_override_cmd
,
5597 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5600 "Override ASNs in outbound updates if aspath equals remote-as\n")
5603 char base_xpath
[XPATH_MAXLEN
];
5604 char af_xpath
[XPATH_MAXLEN
];
5605 char attr_xpath
[XPATH_MAXLEN
];
5606 afi_t afi
= bgp_node_afi(vty
);
5607 safi_t safi
= bgp_node_safi(vty
);
5609 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5610 yang_afi_safi_value2identity(afi
, safi
));
5612 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5613 sizeof(base_xpath
), af_xpath
)
5615 return CMD_WARNING_CONFIG_FAILED
;
5617 snprintf(attr_xpath
, sizeof(attr_xpath
),
5618 "./%s/as-path-options/replace-peer-as",
5619 bgp_afi_safi_get_container_str(afi
, safi
));
5621 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5623 return nb_cli_apply_changes(vty
, base_xpath
);
5626 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5627 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5628 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5629 "Override ASNs in outbound updates if aspath equals remote-as\n")
5631 DEFUN_YANG (no_neighbor_as_override
,
5632 no_neighbor_as_override_cmd
,
5633 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5637 "Override ASNs in outbound updates if aspath equals remote-as\n")
5640 char base_xpath
[XPATH_MAXLEN
];
5641 char af_xpath
[XPATH_MAXLEN
];
5642 char attr_xpath
[XPATH_MAXLEN
];
5643 afi_t afi
= bgp_node_afi(vty
);
5644 safi_t safi
= bgp_node_safi(vty
);
5646 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5647 yang_afi_safi_value2identity(afi
, safi
));
5649 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5650 sizeof(base_xpath
), af_xpath
)
5652 return CMD_WARNING_CONFIG_FAILED
;
5654 snprintf(attr_xpath
, sizeof(attr_xpath
),
5655 "./%s/as-path-options/replace-peer-as",
5656 bgp_afi_safi_get_container_str(afi
, safi
));
5658 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5660 return nb_cli_apply_changes(vty
, base_xpath
);
5663 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5664 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5665 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5666 "Override ASNs in outbound updates if aspath equals remote-as\n")
5668 /* neighbor remove-private-AS. */
5669 DEFUN_YANG (neighbor_remove_private_as
,
5670 neighbor_remove_private_as_cmd
,
5671 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5674 "Remove private ASNs in outbound updates\n")
5677 char base_xpath
[XPATH_MAXLEN
];
5678 char af_xpath
[XPATH_MAXLEN
];
5679 char attr_xpath
[XPATH_MAXLEN
];
5680 afi_t afi
= bgp_node_afi(vty
);
5681 safi_t safi
= bgp_node_safi(vty
);
5683 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5684 yang_afi_safi_value2identity(afi
, safi
));
5686 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5687 sizeof(base_xpath
), af_xpath
)
5689 return CMD_WARNING_CONFIG_FAILED
;
5691 snprintf(attr_xpath
, sizeof(attr_xpath
),
5692 "./%s/private-as/remove-private-as",
5693 bgp_afi_safi_get_container_str(afi
, safi
));
5695 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5697 return nb_cli_apply_changes(vty
, base_xpath
);
5700 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5701 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5702 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5703 "Remove private ASNs in outbound updates\n")
5705 DEFUN_YANG (neighbor_remove_private_as_all
,
5706 neighbor_remove_private_as_all_cmd
,
5707 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5710 "Remove private ASNs in outbound updates\n"
5711 "Apply to all AS numbers\n")
5714 char base_xpath
[XPATH_MAXLEN
];
5715 char af_xpath
[XPATH_MAXLEN
];
5716 char attr_xpath
[XPATH_MAXLEN
];
5717 afi_t afi
= bgp_node_afi(vty
);
5718 safi_t safi
= bgp_node_safi(vty
);
5721 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5722 yang_afi_safi_value2identity(afi
, safi
));
5724 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5725 sizeof(base_xpath
), af_xpath
)
5727 return CMD_WARNING_CONFIG_FAILED
;
5729 snprintf(attr_xpath
, sizeof(attr_xpath
),
5730 "./%s/private-as/remove-private-as-all",
5731 bgp_afi_safi_get_container_str(afi
, safi
));
5733 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5735 return nb_cli_apply_changes(vty
, base_xpath
);
5738 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5739 neighbor_remove_private_as_all_hidden_cmd
,
5740 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5741 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5742 "Remove private ASNs in outbound updates\n"
5743 "Apply to all AS numbers")
5745 DEFUN_YANG (neighbor_remove_private_as_replace_as
,
5746 neighbor_remove_private_as_replace_as_cmd
,
5747 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5750 "Remove private ASNs in outbound updates\n"
5751 "Replace private ASNs with our ASN in outbound updates\n")
5754 char base_xpath
[XPATH_MAXLEN
];
5755 char af_xpath
[XPATH_MAXLEN
];
5756 char attr_xpath
[XPATH_MAXLEN
];
5757 afi_t afi
= bgp_node_afi(vty
);
5758 safi_t safi
= bgp_node_safi(vty
);
5761 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5762 yang_afi_safi_value2identity(afi
, safi
));
5764 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5765 sizeof(base_xpath
), af_xpath
)
5767 return CMD_WARNING_CONFIG_FAILED
;
5769 snprintf(attr_xpath
, sizeof(attr_xpath
),
5770 "./%s/private-as/remove-private-as-replace",
5771 bgp_afi_safi_get_container_str(afi
, safi
));
5773 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5775 return nb_cli_apply_changes(vty
, base_xpath
);
5778 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5779 neighbor_remove_private_as_replace_as_hidden_cmd
,
5780 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5781 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5782 "Remove private ASNs in outbound updates\n"
5783 "Replace private ASNs with our ASN in outbound updates\n")
5785 DEFUN_YANG (neighbor_remove_private_as_all_replace_as
,
5786 neighbor_remove_private_as_all_replace_as_cmd
,
5787 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5790 "Remove private ASNs in outbound updates\n"
5791 "Apply to all AS numbers\n"
5792 "Replace private ASNs with our ASN in outbound updates\n")
5795 char base_xpath
[XPATH_MAXLEN
];
5796 char af_xpath
[XPATH_MAXLEN
];
5797 char attr_xpath
[XPATH_MAXLEN
];
5798 afi_t afi
= bgp_node_afi(vty
);
5799 safi_t safi
= bgp_node_safi(vty
);
5802 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5803 yang_afi_safi_value2identity(afi
, safi
));
5805 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5806 sizeof(base_xpath
), af_xpath
)
5808 return CMD_WARNING_CONFIG_FAILED
;
5810 snprintf(attr_xpath
, sizeof(attr_xpath
),
5811 "./%s/private-as/remove-private-as-all-replace",
5812 bgp_afi_safi_get_container_str(afi
, safi
));
5814 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5816 return nb_cli_apply_changes(vty
, base_xpath
);
5820 neighbor_remove_private_as_all_replace_as
,
5821 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5822 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5823 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5824 "Remove private ASNs in outbound updates\n"
5825 "Apply to all AS numbers\n"
5826 "Replace private ASNs with our ASN in outbound updates\n")
5828 DEFUN_YANG (no_neighbor_remove_private_as
,
5829 no_neighbor_remove_private_as_cmd
,
5830 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5834 "Remove private ASNs in outbound updates\n")
5837 char base_xpath
[XPATH_MAXLEN
];
5838 char af_xpath
[XPATH_MAXLEN
];
5839 char attr_xpath
[XPATH_MAXLEN
];
5840 afi_t afi
= bgp_node_afi(vty
);
5841 safi_t safi
= bgp_node_safi(vty
);
5843 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5844 yang_afi_safi_value2identity(afi
, safi
));
5846 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5847 sizeof(base_xpath
), af_xpath
)
5849 return CMD_WARNING_CONFIG_FAILED
;
5851 snprintf(attr_xpath
, sizeof(attr_xpath
),
5852 "./%s/private-as/remove-private-as",
5853 bgp_afi_safi_get_container_str(afi
, safi
));
5855 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5857 return nb_cli_apply_changes(vty
, base_xpath
);
5860 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5861 no_neighbor_remove_private_as_hidden_cmd
,
5862 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5863 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5864 "Remove private ASNs in outbound updates\n")
5866 DEFUN_YANG (no_neighbor_remove_private_as_all
,
5867 no_neighbor_remove_private_as_all_cmd
,
5868 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5872 "Remove private ASNs in outbound updates\n"
5873 "Apply to all AS numbers\n")
5876 char base_xpath
[XPATH_MAXLEN
];
5877 char af_xpath
[XPATH_MAXLEN
];
5878 char attr_xpath
[XPATH_MAXLEN
];
5879 afi_t afi
= bgp_node_afi(vty
);
5880 safi_t safi
= bgp_node_safi(vty
);
5883 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5884 yang_afi_safi_value2identity(afi
, safi
));
5886 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5887 sizeof(base_xpath
), af_xpath
)
5889 return CMD_WARNING_CONFIG_FAILED
;
5891 snprintf(attr_xpath
, sizeof(attr_xpath
),
5892 "./%s/private-as/remove-private-as-all",
5893 bgp_afi_safi_get_container_str(afi
, safi
));
5895 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5897 return nb_cli_apply_changes(vty
, base_xpath
);
5900 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5901 no_neighbor_remove_private_as_all_hidden_cmd
,
5902 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5903 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5904 "Remove private ASNs in outbound updates\n"
5905 "Apply to all AS numbers\n")
5907 DEFUN_YANG (no_neighbor_remove_private_as_replace_as
,
5908 no_neighbor_remove_private_as_replace_as_cmd
,
5909 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5913 "Remove private ASNs in outbound updates\n"
5914 "Replace private ASNs with our ASN in outbound updates\n")
5917 char base_xpath
[XPATH_MAXLEN
];
5918 char af_xpath
[XPATH_MAXLEN
];
5919 char attr_xpath
[XPATH_MAXLEN
];
5920 afi_t afi
= bgp_node_afi(vty
);
5921 safi_t safi
= bgp_node_safi(vty
);
5924 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5925 yang_afi_safi_value2identity(afi
, safi
));
5927 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5928 sizeof(base_xpath
), af_xpath
)
5930 return CMD_WARNING_CONFIG_FAILED
;
5932 snprintf(attr_xpath
, sizeof(attr_xpath
),
5933 "./%s/private-as/remove-private-as-replace",
5934 bgp_afi_safi_get_container_str(afi
, safi
));
5936 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5938 return nb_cli_apply_changes(vty
, base_xpath
);
5941 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
5942 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
5943 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5944 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5945 "Remove private ASNs in outbound updates\n"
5946 "Replace private ASNs with our ASN in outbound updates\n")
5948 DEFUN_YANG (no_neighbor_remove_private_as_all_replace_as
,
5949 no_neighbor_remove_private_as_all_replace_as_cmd
,
5950 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5954 "Remove private ASNs in outbound updates\n"
5955 "Apply to all AS numbers\n"
5956 "Replace private ASNs with our ASN in outbound updates\n")
5959 char base_xpath
[XPATH_MAXLEN
];
5960 char af_xpath
[XPATH_MAXLEN
];
5961 char attr_xpath
[XPATH_MAXLEN
];
5962 afi_t afi
= bgp_node_afi(vty
);
5963 safi_t safi
= bgp_node_safi(vty
);
5966 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5967 yang_afi_safi_value2identity(afi
, safi
));
5969 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5970 sizeof(base_xpath
), af_xpath
)
5972 return CMD_WARNING_CONFIG_FAILED
;
5974 snprintf(attr_xpath
, sizeof(attr_xpath
),
5975 "./%s/private-as/remove-private-as-all-replace",
5976 bgp_afi_safi_get_container_str(afi
, safi
));
5978 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5980 return nb_cli_apply_changes(vty
, base_xpath
);
5984 no_neighbor_remove_private_as_all_replace_as
,
5985 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5986 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5987 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5988 "Remove private ASNs in outbound updates\n"
5989 "Apply to all AS numbers\n"
5990 "Replace private ASNs with our ASN in outbound updates\n")
5993 /* neighbor send-community. */
5994 DEFUN_YANG (neighbor_send_community
,
5995 neighbor_send_community_cmd
,
5996 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5999 "Send Community attribute to this neighbor\n")
6003 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6005 PEER_FLAG_SEND_COMMUNITY
);
6008 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
6009 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6010 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6011 "Send Community attribute to this neighbor\n")
6013 DEFUN_YANG (no_neighbor_send_community
,
6014 no_neighbor_send_community_cmd
,
6015 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6019 "Send Community attribute to this neighbor\n")
6023 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6024 bgp_node_afi(vty
), bgp_node_safi(vty
),
6025 PEER_FLAG_SEND_COMMUNITY
);
6028 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
6029 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6030 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6031 "Send Community attribute to this neighbor\n")
6033 /* neighbor send-community extended. */
6034 DEFUN_YANG (neighbor_send_community_type
,
6035 neighbor_send_community_type_cmd
,
6036 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6039 "Send Community attribute to this neighbor\n"
6040 "Send Standard and Extended Community attributes\n"
6041 "Send Standard, Large and Extended Community attributes\n"
6042 "Send Extended Community attributes\n"
6043 "Send Standard Community attributes\n"
6044 "Send Large Community attributes\n")
6046 const char *type
= argv
[argc
- 1]->text
;
6047 char *peer_str
= argv
[1]->arg
;
6048 char base_xpath
[XPATH_MAXLEN
];
6049 char af_xpath
[XPATH_MAXLEN
];
6050 char std_xpath
[XPATH_MAXLEN
];
6051 char ext_xpath
[XPATH_MAXLEN
];
6052 char lrg_xpath
[XPATH_MAXLEN
];
6053 afi_t afi
= bgp_node_afi(vty
);
6054 safi_t safi
= bgp_node_safi(vty
);
6056 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6057 yang_afi_safi_value2identity(afi
, safi
));
6059 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6060 sizeof(base_xpath
), af_xpath
)
6062 return CMD_WARNING_CONFIG_FAILED
;
6064 if (strmatch(type
, "standard")) {
6065 snprintf(std_xpath
, sizeof(std_xpath
),
6066 "./%s/send-community/send-community",
6067 bgp_afi_safi_get_container_str(afi
, safi
));
6069 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6072 if (strmatch(type
, "extended")) {
6073 snprintf(ext_xpath
, sizeof(ext_xpath
),
6074 "./%s/send-community/send-ext-community",
6075 bgp_afi_safi_get_container_str(afi
, safi
));
6077 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6080 if (strmatch(type
, "large")) {
6081 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6082 "./%s/send-community/send-large-community",
6083 bgp_afi_safi_get_container_str(afi
, safi
));
6085 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "true");
6088 if (strmatch(type
, "both")) {
6089 snprintf(std_xpath
, sizeof(std_xpath
),
6090 "./%s/send-community/send-community",
6091 bgp_afi_safi_get_container_str(afi
, safi
));
6093 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6095 snprintf(ext_xpath
, sizeof(ext_xpath
),
6096 "./%s/send-community/send-ext-community",
6097 bgp_afi_safi_get_container_str(afi
, safi
));
6099 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6102 if (strmatch(type
, "all")) {
6103 snprintf(std_xpath
, sizeof(std_xpath
),
6104 "./%s/send-community/send-community",
6105 bgp_afi_safi_get_container_str(afi
, safi
));
6107 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6109 snprintf(ext_xpath
, sizeof(ext_xpath
),
6110 "./%s/send-community/send-ext-community",
6111 bgp_afi_safi_get_container_str(afi
, safi
));
6113 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6115 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6116 "./%s/send-community/send-large-community",
6117 bgp_afi_safi_get_container_str(afi
, safi
));
6119 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "true");
6122 return nb_cli_apply_changes(vty
, base_xpath
);
6126 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6127 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6128 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6129 "Send Community attribute to this neighbor\n"
6130 "Send Standard and Extended Community attributes\n"
6131 "Send Standard, Large and Extended Community attributes\n"
6132 "Send Extended Community attributes\n"
6133 "Send Standard Community attributes\n"
6134 "Send Large Community attributes\n")
6136 DEFUN_YANG (no_neighbor_send_community_type
,
6137 no_neighbor_send_community_type_cmd
,
6138 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6142 "Send Community attribute to this neighbor\n"
6143 "Send Standard and Extended Community attributes\n"
6144 "Send Standard, Large and Extended Community attributes\n"
6145 "Send Extended Community attributes\n"
6146 "Send Standard Community attributes\n"
6147 "Send Large Community attributes\n")
6149 const char *type
= argv
[argc
- 1]->text
;
6150 char *peer_str
= argv
[2]->arg
;
6151 char base_xpath
[XPATH_MAXLEN
];
6152 char af_xpath
[XPATH_MAXLEN
];
6153 char std_xpath
[XPATH_MAXLEN
];
6154 char ext_xpath
[XPATH_MAXLEN
];
6155 char lrg_xpath
[XPATH_MAXLEN
];
6156 afi_t afi
= bgp_node_afi(vty
);
6157 safi_t safi
= bgp_node_safi(vty
);
6159 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6160 yang_afi_safi_value2identity(afi
, safi
));
6162 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6163 sizeof(base_xpath
), af_xpath
)
6165 return CMD_WARNING_CONFIG_FAILED
;
6167 if (strmatch(type
, "standard")) {
6168 snprintf(std_xpath
, sizeof(std_xpath
),
6169 "./%s/send-community/send-community",
6170 bgp_afi_safi_get_container_str(afi
, safi
));
6172 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6175 if (strmatch(type
, "extended")) {
6176 snprintf(ext_xpath
, sizeof(ext_xpath
),
6177 "./%s/send-community/send-ext-community",
6178 bgp_afi_safi_get_container_str(afi
, safi
));
6180 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6183 if (strmatch(type
, "large")) {
6184 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6185 "./%s/send-community/send-large-community",
6186 bgp_afi_safi_get_container_str(afi
, safi
));
6188 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "false");
6191 if (strmatch(type
, "both")) {
6192 snprintf(std_xpath
, sizeof(std_xpath
),
6193 "./%s/send-community/send-community",
6194 bgp_afi_safi_get_container_str(afi
, safi
));
6196 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6198 snprintf(ext_xpath
, sizeof(ext_xpath
),
6199 "./%s/send-community/send-ext-community",
6200 bgp_afi_safi_get_container_str(afi
, safi
));
6202 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6205 if (strmatch(type
, "all")) {
6206 snprintf(std_xpath
, sizeof(std_xpath
),
6207 "./%s/send-community/send-community",
6208 bgp_afi_safi_get_container_str(afi
, safi
));
6210 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6212 snprintf(ext_xpath
, sizeof(ext_xpath
),
6213 "./%s/send-community/send-ext-community",
6214 bgp_afi_safi_get_container_str(afi
, safi
));
6216 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6218 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6219 "./%s/send-community/send-large-community",
6220 bgp_afi_safi_get_container_str(afi
, safi
));
6222 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "false");
6225 return nb_cli_apply_changes(vty
, base_xpath
);
6229 no_neighbor_send_community_type
,
6230 no_neighbor_send_community_type_hidden_cmd
,
6231 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6232 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6233 "Send Community attribute to this neighbor\n"
6234 "Send Standard and Extended Community attributes\n"
6235 "Send Standard, Large and Extended Community attributes\n"
6236 "Send Extended Community attributes\n"
6237 "Send Standard Community attributes\n"
6238 "Send Large Community attributes\n")
6240 /* neighbor soft-reconfig. */
6241 DEFUN_YANG (neighbor_soft_reconfiguration
,
6242 neighbor_soft_reconfiguration_cmd
,
6243 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6244 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6245 "Per neighbor soft reconfiguration\n"
6246 "Allow inbound soft reconfiguration for this neighbor\n")
6249 char base_xpath
[XPATH_MAXLEN
];
6250 char af_xpath
[XPATH_MAXLEN
];
6251 char soft_xpath
[XPATH_MAXLEN
];
6252 afi_t afi
= bgp_node_afi(vty
);
6253 safi_t safi
= bgp_node_safi(vty
);
6256 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6257 yang_afi_safi_value2identity(afi
, safi
));
6259 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6260 sizeof(base_xpath
), af_xpath
)
6262 return CMD_WARNING_CONFIG_FAILED
;
6264 snprintf(soft_xpath
, sizeof(soft_xpath
), "./%s/soft-reconfiguration",
6265 bgp_afi_safi_get_container_str(afi
, safi
));
6267 nb_cli_enqueue_change(vty
, soft_xpath
, NB_OP_MODIFY
, "true");
6269 return nb_cli_apply_changes(vty
, base_xpath
);
6272 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6273 neighbor_soft_reconfiguration_hidden_cmd
,
6274 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6275 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6276 "Per neighbor soft reconfiguration\n"
6277 "Allow inbound soft reconfiguration for this neighbor\n")
6279 DEFUN_YANG (no_neighbor_soft_reconfiguration
,
6280 no_neighbor_soft_reconfiguration_cmd
,
6281 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6282 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6283 "Per neighbor soft reconfiguration\n"
6284 "Allow inbound soft reconfiguration for this neighbor\n")
6287 char base_xpath
[XPATH_MAXLEN
];
6288 char af_xpath
[XPATH_MAXLEN
];
6289 char soft_xpath
[XPATH_MAXLEN
];
6290 afi_t afi
= bgp_node_afi(vty
);
6291 safi_t safi
= bgp_node_safi(vty
);
6293 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6294 yang_afi_safi_value2identity(afi
, safi
));
6296 snprintf(soft_xpath
, sizeof(soft_xpath
), "./%s/soft-reconfiguration",
6297 bgp_afi_safi_get_container_str(afi
, safi
));
6299 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6300 sizeof(base_xpath
), af_xpath
)
6302 return CMD_WARNING_CONFIG_FAILED
;
6304 nb_cli_enqueue_change(vty
, soft_xpath
, NB_OP_MODIFY
, "false");
6306 return nb_cli_apply_changes(vty
, base_xpath
);
6309 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6310 no_neighbor_soft_reconfiguration_hidden_cmd
,
6311 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6312 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6313 "Per neighbor soft reconfiguration\n"
6314 "Allow inbound soft reconfiguration for this neighbor\n")
6316 DEFUN_YANG (neighbor_route_reflector_client
,
6317 neighbor_route_reflector_client_cmd
,
6318 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6321 "Configure a neighbor as Route Reflector client\n")
6324 char base_xpath
[XPATH_MAXLEN
];
6325 char af_xpath
[XPATH_MAXLEN
];
6326 char attr_xpath
[XPATH_MAXLEN
];
6327 afi_t afi
= bgp_node_afi(vty
);
6328 safi_t safi
= bgp_node_safi(vty
);
6330 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6331 yang_afi_safi_value2identity(afi
, safi
));
6333 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6334 sizeof(base_xpath
), af_xpath
)
6336 return CMD_WARNING_CONFIG_FAILED
;
6338 snprintf(attr_xpath
, sizeof(attr_xpath
),
6339 "./%s/route-reflector/route-reflector-client",
6340 bgp_afi_safi_get_container_str(afi
, safi
));
6342 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6344 return nb_cli_apply_changes(vty
, base_xpath
);
6347 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6348 neighbor_route_reflector_client_hidden_cmd
,
6349 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6350 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6351 "Configure a neighbor as Route Reflector client\n")
6353 DEFUN_YANG (no_neighbor_route_reflector_client
,
6354 no_neighbor_route_reflector_client_cmd
,
6355 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6359 "Configure a neighbor as Route Reflector client\n")
6362 char base_xpath
[XPATH_MAXLEN
];
6363 char af_xpath
[XPATH_MAXLEN
];
6364 char attr_xpath
[XPATH_MAXLEN
];
6365 afi_t afi
= bgp_node_afi(vty
);
6366 safi_t safi
= bgp_node_safi(vty
);
6368 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6369 yang_afi_safi_value2identity(afi
, safi
));
6371 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6372 sizeof(base_xpath
), af_xpath
)
6374 return CMD_WARNING_CONFIG_FAILED
;
6376 snprintf(attr_xpath
, sizeof(attr_xpath
),
6377 "./%s/route-reflector/route-reflector-client",
6378 bgp_afi_safi_get_container_str(afi
, safi
));
6380 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6382 return nb_cli_apply_changes(vty
, base_xpath
);
6385 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6386 no_neighbor_route_reflector_client_hidden_cmd
,
6387 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6388 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6389 "Configure a neighbor as Route Reflector client\n")
6391 /* neighbor route-server-client. */
6392 DEFUN_YANG (neighbor_route_server_client
,
6393 neighbor_route_server_client_cmd
,
6394 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6397 "Configure a neighbor as Route Server client\n")
6400 char base_xpath
[XPATH_MAXLEN
];
6401 char af_xpath
[XPATH_MAXLEN
];
6402 char attr_xpath
[XPATH_MAXLEN
];
6403 afi_t afi
= bgp_node_afi(vty
);
6404 safi_t safi
= bgp_node_safi(vty
);
6406 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6407 yang_afi_safi_value2identity(afi
, safi
));
6409 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6410 sizeof(base_xpath
), af_xpath
)
6412 return CMD_WARNING_CONFIG_FAILED
;
6414 snprintf(attr_xpath
, sizeof(attr_xpath
),
6415 "./%s/route-server/route-server-client",
6416 bgp_afi_safi_get_container_str(afi
, safi
));
6418 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6420 return nb_cli_apply_changes(vty
, base_xpath
);
6423 ALIAS_HIDDEN(neighbor_route_server_client
,
6424 neighbor_route_server_client_hidden_cmd
,
6425 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6426 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6427 "Configure a neighbor as Route Server client\n")
6429 DEFUN_YANG (no_neighbor_route_server_client
,
6430 no_neighbor_route_server_client_cmd
,
6431 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6435 "Configure a neighbor as Route Server client\n")
6438 char base_xpath
[XPATH_MAXLEN
];
6439 char af_xpath
[XPATH_MAXLEN
];
6440 char attr_xpath
[XPATH_MAXLEN
];
6441 afi_t afi
= bgp_node_afi(vty
);
6442 safi_t safi
= bgp_node_safi(vty
);
6444 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6445 yang_afi_safi_value2identity(afi
, safi
));
6447 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6448 sizeof(base_xpath
), af_xpath
)
6450 return CMD_WARNING_CONFIG_FAILED
;
6452 snprintf(attr_xpath
, sizeof(attr_xpath
),
6453 "./%s/route-server/route-server-client",
6454 bgp_afi_safi_get_container_str(afi
, safi
));
6456 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6458 return nb_cli_apply_changes(vty
, base_xpath
);
6461 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6462 no_neighbor_route_server_client_hidden_cmd
,
6463 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6464 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6465 "Configure a neighbor as Route Server client\n")
6467 DEFUN (neighbor_nexthop_local_unchanged
,
6468 neighbor_nexthop_local_unchanged_cmd
,
6469 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6472 "Configure treatment of outgoing link-local nexthop attribute\n"
6473 "Leave link-local nexthop unchanged for this peer\n")
6476 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6478 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6481 DEFUN (no_neighbor_nexthop_local_unchanged
,
6482 no_neighbor_nexthop_local_unchanged_cmd
,
6483 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6487 "Configure treatment of outgoing link-local-nexthop attribute\n"
6488 "Leave link-local nexthop unchanged for this peer\n")
6491 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6492 bgp_node_afi(vty
), bgp_node_safi(vty
),
6493 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6496 DEFUN_YANG (neighbor_attr_unchanged
,
6497 neighbor_attr_unchanged_cmd
,
6498 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6501 "BGP attribute is propagated unchanged to this neighbor\n"
6502 "As-path attribute\n"
6503 "Nexthop attribute\n"
6507 char *peer_str
= argv
[1]->arg
;
6508 bool aspath
= false;
6509 bool nexthop
= false;
6511 afi_t afi
= bgp_node_afi(vty
);
6512 safi_t safi
= bgp_node_safi(vty
);
6513 char base_xpath
[XPATH_MAXLEN
];
6514 char af_xpath
[XPATH_MAXLEN
];
6515 char as_xpath
[XPATH_MAXLEN
];
6516 char nxthop_xpath
[XPATH_MAXLEN
];
6517 char med_xpath
[XPATH_MAXLEN
];
6519 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6520 yang_afi_safi_value2identity(afi
, safi
));
6522 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6523 sizeof(base_xpath
), af_xpath
)
6525 return CMD_WARNING_CONFIG_FAILED
;
6527 if (argv_find(argv
, argc
, "as-path", &idx
))
6531 if (argv_find(argv
, argc
, "next-hop", &idx
))
6535 if (argv_find(argv
, argc
, "med", &idx
))
6538 snprintf(as_xpath
, sizeof(as_xpath
),
6539 "./%s/attr-unchanged/as-path-unchanged",
6540 bgp_afi_safi_get_container_str(afi
, safi
));
6541 snprintf(nxthop_xpath
, sizeof(nxthop_xpath
),
6542 "./%s/attr-unchanged/next-hop-unchanged",
6543 bgp_afi_safi_get_container_str(afi
, safi
));
6544 snprintf(med_xpath
, sizeof(med_xpath
),
6545 "./%s/attr-unchanged/med-unchanged",
6546 bgp_afi_safi_get_container_str(afi
, safi
));
6548 /* no flags means all of them! */
6549 if (!aspath
&& !nexthop
&& !med
) {
6550 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "true");
6551 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "true");
6552 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "true");
6555 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
,
6558 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
,
6562 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
,
6565 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
,
6569 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
,
6572 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
,
6576 return nb_cli_apply_changes(vty
, base_xpath
);
6580 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6581 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6582 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6583 "BGP attribute is propagated unchanged to this neighbor\n"
6584 "As-path attribute\n"
6585 "Nexthop attribute\n"
6588 DEFUN_YANG (no_neighbor_attr_unchanged
,
6589 no_neighbor_attr_unchanged_cmd
,
6590 "no 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
[2]->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
, "false");
6644 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "false");
6645 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "false");
6649 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "false");
6652 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "false");
6655 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "false");
6657 return nb_cli_apply_changes(vty
, base_xpath
);
6661 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6662 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6663 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6664 "BGP attribute is propagated unchanged to this neighbor\n"
6665 "As-path attribute\n"
6666 "Nexthop attribute\n"
6669 /* neighbor ebgp-multihop. */
6670 DEFUN_YANG (neighbor_ebgp_multihop
,
6671 neighbor_ebgp_multihop_cmd
,
6672 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6673 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6674 "Allow EBGP neighbors not on directly connected networks\n")
6677 char base_xpath
[XPATH_MAXLEN
];
6679 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6680 sizeof(base_xpath
), NULL
)
6682 return CMD_WARNING_CONFIG_FAILED
;
6684 nb_cli_enqueue_change(vty
, "./ebgp-multihop/enabled", NB_OP_MODIFY
,
6687 return nb_cli_apply_changes(vty
, base_xpath
);
6690 DEFUN_YANG (neighbor_ebgp_multihop_ttl
,
6691 neighbor_ebgp_multihop_ttl_cmd
,
6692 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6693 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6694 "Allow EBGP neighbors not on directly connected networks\n"
6695 "maximum hop count\n")
6699 char base_xpath
[XPATH_MAXLEN
];
6701 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6702 sizeof(base_xpath
), NULL
)
6704 return CMD_WARNING_CONFIG_FAILED
;
6706 nb_cli_enqueue_change(vty
, "./ebgp-multihop/multihop-ttl", NB_OP_MODIFY
,
6707 argv
[idx_number
]->arg
);
6709 return nb_cli_apply_changes(vty
, base_xpath
);
6712 DEFUN_YANG (no_neighbor_ebgp_multihop
,
6713 no_neighbor_ebgp_multihop_cmd
,
6714 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6715 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6716 "Allow EBGP neighbors not on directly connected networks\n"
6717 "maximum hop count\n")
6720 char base_xpath
[XPATH_MAXLEN
];
6722 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6723 sizeof(base_xpath
), NULL
)
6725 return CMD_WARNING_CONFIG_FAILED
;
6728 nb_cli_enqueue_change(vty
, "./ebgp-multihop/multihop-ttl",
6729 NB_OP_DESTROY
, NULL
);
6731 nb_cli_enqueue_change(vty
, "./ebgp-multihop/enabled",
6732 NB_OP_MODIFY
, "false");
6734 return nb_cli_apply_changes(vty
, base_xpath
);
6738 /* disable-connected-check */
6739 DEFUN_YANG (neighbor_disable_connected_check
,
6740 neighbor_disable_connected_check_cmd
,
6741 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6742 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6743 "one-hop away EBGP peer using loopback address\n"
6744 "Enforce EBGP neighbors perform multihop\n")
6747 char base_xpath
[XPATH_MAXLEN
];
6749 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6750 sizeof(base_xpath
), NULL
)
6752 return CMD_WARNING_CONFIG_FAILED
;
6754 nb_cli_enqueue_change(vty
, "./ebgp-multihop/disable-connected-check",
6755 NB_OP_MODIFY
, "true");
6757 return nb_cli_apply_changes(vty
, base_xpath
);
6760 DEFUN_YANG (no_neighbor_disable_connected_check
,
6761 no_neighbor_disable_connected_check_cmd
,
6762 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6763 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6764 "one-hop away EBGP peer using loopback address\n"
6765 "Enforce EBGP neighbors perform multihop\n")
6768 char base_xpath
[XPATH_MAXLEN
];
6770 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6771 sizeof(base_xpath
), NULL
)
6773 return CMD_WARNING_CONFIG_FAILED
;
6775 nb_cli_enqueue_change(vty
, "./ebgp-multihop/disable-connected-check",
6776 NB_OP_MODIFY
, "false");
6778 return nb_cli_apply_changes(vty
, base_xpath
);
6782 /* enforce-first-as */
6783 DEFUN_YANG (neighbor_enforce_first_as
,
6784 neighbor_enforce_first_as_cmd
,
6785 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6786 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6787 "Enforce the first AS for EBGP routes\n")
6790 char base_xpath
[XPATH_MAXLEN
];
6792 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6793 sizeof(base_xpath
), NULL
)
6795 return CMD_WARNING_CONFIG_FAILED
;
6797 nb_cli_enqueue_change(vty
, "./enforce-first-as", NB_OP_MODIFY
, "true");
6799 return nb_cli_apply_changes(vty
, base_xpath
);
6802 DEFUN_YANG (no_neighbor_enforce_first_as
,
6803 no_neighbor_enforce_first_as_cmd
,
6804 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6805 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6806 "Enforce the first AS for EBGP routes\n")
6809 char base_xpath
[XPATH_MAXLEN
];
6811 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6812 sizeof(base_xpath
), NULL
)
6814 return CMD_WARNING_CONFIG_FAILED
;
6816 nb_cli_enqueue_change(vty
, "./enforce-first-as", NB_OP_MODIFY
, "false");
6818 return nb_cli_apply_changes(vty
, base_xpath
);
6821 static int peer_and_group_lookup_nb(struct vty
*vty
, const char *peer_str
,
6822 char *base_xpath
, int xpath_len
,
6826 char num_xpath
[XPATH_MAXLEN
];
6827 char unnbr_xpath
[XPATH_MAXLEN
];
6828 char prgrp_xpath
[XPATH_MAXLEN
];
6830 if (str2sockunion(peer_str
, &su
) == 0) {
6831 snprintf(num_xpath
, sizeof(num_xpath
),
6832 "/neighbors/neighbor[remote-address='%s']", peer_str
);
6833 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
6834 VTY_CURR_XPATH
, num_xpath
)) {
6835 snprintf(base_xpath
, xpath_len
,
6836 FRR_BGP_NEIGHBOR_NUM_XPATH
, peer_str
,
6837 xpath
? xpath
: "");
6840 "%% Specify remote-as or peer-group commands first\n");
6845 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
6846 "/neighbors/unnumbered-neighbor[interface='%s']",
6849 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
6850 "/peer-groups/peer-group[peer-group-name='%s']",
6853 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
6854 VTY_CURR_XPATH
, unnbr_xpath
)) {
6855 snprintf(base_xpath
, xpath_len
,
6856 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, peer_str
,
6857 xpath
? xpath
: "");
6858 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
,
6859 "%s%s", VTY_CURR_XPATH
,
6861 snprintf(base_xpath
, xpath_len
,
6862 FRR_BGP_PEER_GROUP_XPATH
, peer_str
,
6863 xpath
? xpath
: "");
6866 "%% Create the peer-group or interface first\n");
6874 DEFUN_YANG (neighbor_description
,
6875 neighbor_description_cmd
,
6876 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6877 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6878 "Neighbor specific description\n"
6879 "Up to 80 characters describing this neighbor\n")
6884 char base_xpath
[XPATH_MAXLEN
];
6887 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6888 sizeof(base_xpath
), NULL
)
6890 return CMD_WARNING_CONFIG_FAILED
;
6892 str
= argv_concat(argv
, argc
, idx_line
);
6894 nb_cli_enqueue_change(vty
, "./description", NB_OP_MODIFY
, str
);
6896 ret
= nb_cli_apply_changes(vty
, base_xpath
);
6898 XFREE(MTYPE_TMP
, str
);
6903 DEFUN_YANG (no_neighbor_description
,
6904 no_neighbor_description_cmd
,
6905 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6906 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6907 "Neighbor specific description\n")
6910 char base_xpath
[XPATH_MAXLEN
];
6912 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6913 sizeof(base_xpath
), NULL
)
6915 return CMD_WARNING_CONFIG_FAILED
;
6917 nb_cli_enqueue_change(vty
, "./description", NB_OP_DESTROY
, NULL
);
6919 return nb_cli_apply_changes(vty
, base_xpath
);
6922 ALIAS_YANG(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6923 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6924 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6925 "Neighbor specific description\n"
6926 "Up to 80 characters describing this neighbor\n")
6928 #define BGP_UPDATE_SOURCE_HELP_STR \
6931 "Interface name (requires zebra to be running)\n"
6933 DEFUN_YANG (neighbor_update_source
,
6934 neighbor_update_source_cmd
,
6935 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6936 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6937 "Source of routing updates\n"
6938 BGP_UPDATE_SOURCE_HELP_STR
)
6943 char base_xpath
[XPATH_MAXLEN
];
6945 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6946 sizeof(base_xpath
), NULL
)
6948 return CMD_WARNING_CONFIG_FAILED
;
6950 if (str2sockunion(argv
[idx_peer_2
]->arg
, &su
) == 0)
6951 nb_cli_enqueue_change(vty
, "./update-source/ip", NB_OP_MODIFY
,
6952 argv
[idx_peer_2
]->arg
);
6954 nb_cli_enqueue_change(vty
, "./update-source/interface",
6955 NB_OP_MODIFY
, argv
[idx_peer_2
]->arg
);
6957 return nb_cli_apply_changes(vty
, base_xpath
);
6960 DEFUN_YANG (no_neighbor_update_source
,
6961 no_neighbor_update_source_cmd
,
6962 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6965 "Source of routing updates\n"
6966 BGP_UPDATE_SOURCE_HELP_STR
)
6969 char base_xpath
[XPATH_MAXLEN
];
6971 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6972 sizeof(base_xpath
), NULL
)
6974 return CMD_WARNING_CONFIG_FAILED
;
6976 nb_cli_enqueue_change(vty
, "./update-source/ip", NB_OP_DESTROY
, NULL
);
6977 nb_cli_enqueue_change(vty
, "./update-source/interface", NB_OP_DESTROY
,
6980 return nb_cli_apply_changes(vty
, base_xpath
);
6983 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
6984 afi_t afi
, safi_t safi
,
6985 const char *rmap
, int set
)
6989 struct route_map
*route_map
= NULL
;
6991 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6993 return CMD_WARNING_CONFIG_FAILED
;
6997 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
6998 ret
= peer_default_originate_set(peer
, afi
, safi
,
7001 ret
= peer_default_originate_unset(peer
, afi
, safi
);
7003 return bgp_vty_return(vty
, ret
);
7006 /* neighbor default-originate. */
7007 DEFUN (neighbor_default_originate
,
7008 neighbor_default_originate_cmd
,
7009 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
7012 "Originate default route to this neighbor\n")
7015 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
7017 bgp_node_safi(vty
), NULL
, 1);
7020 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
7021 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
7022 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7023 "Originate default route to this neighbor\n")
7025 DEFUN (neighbor_default_originate_rmap
,
7026 neighbor_default_originate_rmap_cmd
,
7027 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
7030 "Originate default route to this neighbor\n"
7031 "Route-map to specify criteria to originate default\n"
7036 return peer_default_originate_set_vty(
7037 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7038 argv
[idx_word
]->arg
, 1);
7042 neighbor_default_originate_rmap
,
7043 neighbor_default_originate_rmap_hidden_cmd
,
7044 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
7045 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7046 "Originate default route to this neighbor\n"
7047 "Route-map to specify criteria to originate default\n"
7050 DEFUN (no_neighbor_default_originate
,
7051 no_neighbor_default_originate_cmd
,
7052 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
7056 "Originate default route to this neighbor\n"
7057 "Route-map to specify criteria to originate default\n"
7061 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
7063 bgp_node_safi(vty
), NULL
, 0);
7067 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
7068 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
7069 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7070 "Originate default route to this neighbor\n"
7071 "Route-map to specify criteria to originate default\n"
7075 /* Set specified peer's BGP port. */
7076 DEFUN_YANG (neighbor_port
,
7078 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
7081 "Neighbor's BGP port\n"
7082 "TCP port number\n")
7086 char base_xpath
[XPATH_MAXLEN
];
7088 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7089 argv
[idx_ip
]->arg
, "");
7091 nb_cli_enqueue_change(vty
, "./local-port", NB_OP_MODIFY
,
7092 argv
[idx_number
]->arg
);
7094 return nb_cli_apply_changes(vty
, base_xpath
);
7097 DEFUN_YANG (no_neighbor_port
,
7098 no_neighbor_port_cmd
,
7099 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
7100 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR
7101 "Neighbor's BGP port\n"
7102 "TCP port number\n")
7105 char base_xpath
[XPATH_MAXLEN
];
7107 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7108 argv
[idx_ip
]->arg
, "");
7110 nb_cli_enqueue_change(vty
, "./local-port", NB_OP_DESTROY
, NULL
);
7112 return nb_cli_apply_changes(vty
, base_xpath
);
7115 DEFUN_YANG (neighbor_weight
,
7116 neighbor_weight_cmd
,
7117 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7118 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7119 "Set default weight for routes from this neighbor\n"
7124 char base_xpath
[XPATH_MAXLEN
];
7125 char af_xpath
[XPATH_MAXLEN
];
7126 char attr_xpath
[XPATH_MAXLEN
];
7127 afi_t afi
= bgp_node_afi(vty
);
7128 safi_t safi
= bgp_node_safi(vty
);
7130 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
7131 yang_afi_safi_value2identity(afi
, safi
));
7133 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7134 sizeof(base_xpath
), af_xpath
)
7136 return CMD_WARNING_CONFIG_FAILED
;
7138 snprintf(attr_xpath
, sizeof(attr_xpath
), "./%s/weight/weight-attribute",
7139 bgp_afi_safi_get_container_str(afi
, safi
));
7141 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
,
7142 argv
[idx_number
]->arg
);
7144 return nb_cli_apply_changes(vty
, base_xpath
);
7147 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
7148 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7149 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7150 "Set default weight for routes from this neighbor\n"
7153 DEFUN_YANG (no_neighbor_weight
,
7154 no_neighbor_weight_cmd
,
7155 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7156 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7157 "Set default weight for routes from this neighbor\n"
7161 char base_xpath
[XPATH_MAXLEN
];
7162 char af_xpath
[XPATH_MAXLEN
];
7163 char attr_xpath
[XPATH_MAXLEN
];
7164 afi_t afi
= bgp_node_afi(vty
);
7165 safi_t safi
= bgp_node_safi(vty
);
7167 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
7168 yang_afi_safi_value2identity(afi
, safi
));
7170 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7171 sizeof(base_xpath
), af_xpath
)
7173 return CMD_WARNING_CONFIG_FAILED
;
7175 snprintf(attr_xpath
, sizeof(attr_xpath
), "./%s/weight/weight-attribute",
7176 bgp_afi_safi_get_container_str(afi
, safi
));
7178 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_DESTROY
, NULL
);
7180 return nb_cli_apply_changes(vty
, base_xpath
);
7183 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
7184 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7185 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7186 "Set default weight for routes from this neighbor\n"
7190 /* Override capability negotiation. */
7191 DEFUN_YANG (neighbor_override_capability
,
7192 neighbor_override_capability_cmd
,
7193 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7196 "Override capability negotiation result\n")
7199 char base_xpath
[XPATH_MAXLEN
];
7201 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7202 sizeof(base_xpath
), NULL
)
7204 return CMD_WARNING_CONFIG_FAILED
;
7206 nb_cli_enqueue_change(
7207 vty
, "./capability-options/override-capability",
7208 NB_OP_MODIFY
, "true");
7210 return nb_cli_apply_changes(vty
, base_xpath
);
7213 DEFUN_YANG (no_neighbor_override_capability
,
7214 no_neighbor_override_capability_cmd
,
7215 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7219 "Override capability negotiation result\n")
7222 char base_xpath
[XPATH_MAXLEN
];
7224 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7225 sizeof(base_xpath
), NULL
)
7227 return CMD_WARNING_CONFIG_FAILED
;
7229 nb_cli_enqueue_change(
7230 vty
, "./capability-options/override-capability",
7231 NB_OP_MODIFY
, "false");
7233 return nb_cli_apply_changes(vty
, base_xpath
);
7236 DEFUN_YANG (neighbor_strict_capability
,
7237 neighbor_strict_capability_cmd
,
7238 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7241 "Strict capability negotiation match\n")
7244 char base_xpath
[XPATH_MAXLEN
];
7246 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7247 sizeof(base_xpath
), NULL
)
7249 return CMD_WARNING_CONFIG_FAILED
;
7251 nb_cli_enqueue_change(
7252 vty
, "./capability-options/strict-capability",
7253 NB_OP_MODIFY
, "true");
7255 return nb_cli_apply_changes(vty
, base_xpath
);
7258 DEFUN_YANG (no_neighbor_strict_capability
,
7259 no_neighbor_strict_capability_cmd
,
7260 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7264 "Strict capability negotiation match\n")
7267 char base_xpath
[XPATH_MAXLEN
];
7269 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7270 sizeof(base_xpath
), NULL
)
7272 return CMD_WARNING_CONFIG_FAILED
;
7274 nb_cli_enqueue_change(
7275 vty
, "./capability-options/strict-capability",
7276 NB_OP_MODIFY
, "false");
7278 return nb_cli_apply_changes(vty
, base_xpath
);
7281 DEFUN_YANG (neighbor_timers
,
7282 neighbor_timers_cmd
,
7283 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7284 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7285 "BGP per neighbor timers\n"
7286 "Keepalive interval\n"
7291 int idx_number_2
= 4;
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(vty
, "./timers/keepalive", NB_OP_MODIFY
,
7300 argv
[idx_number
]->arg
);
7302 nb_cli_enqueue_change(vty
, "./timers/hold-time", NB_OP_MODIFY
,
7303 argv
[idx_number_2
]->arg
);
7305 return nb_cli_apply_changes(vty
, base_xpath
);
7308 DEFUN_YANG (no_neighbor_timers
,
7309 no_neighbor_timers_cmd
,
7310 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7311 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7312 "BGP per neighbor timers\n"
7313 "Keepalive interval\n"
7317 char base_xpath
[XPATH_MAXLEN
];
7319 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7320 sizeof(base_xpath
), NULL
)
7322 return CMD_WARNING_CONFIG_FAILED
;
7324 nb_cli_enqueue_change(vty
, "./timers/hold-time", NB_OP_DESTROY
, NULL
);
7326 nb_cli_enqueue_change(vty
, "./timers/keepalive", NB_OP_DESTROY
, NULL
);
7328 return nb_cli_apply_changes(vty
, base_xpath
);
7331 DEFUN_YANG (neighbor_timers_connect
,
7332 neighbor_timers_connect_cmd
,
7333 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7334 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7335 "BGP per neighbor timers\n"
7336 "BGP connect timer\n"
7341 char base_xpath
[XPATH_MAXLEN
];
7343 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7344 sizeof(base_xpath
), NULL
)
7346 return CMD_WARNING_CONFIG_FAILED
;
7348 nb_cli_enqueue_change(vty
, "./timers/connect-time", NB_OP_MODIFY
,
7349 argv
[idx_number
]->arg
);
7351 return nb_cli_apply_changes(vty
, base_xpath
);
7354 DEFUN_YANG (no_neighbor_timers_connect
,
7355 no_neighbor_timers_connect_cmd
,
7356 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7357 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7358 "BGP per neighbor timers\n"
7359 "BGP connect timer\n"
7363 char base_xpath
[XPATH_MAXLEN
];
7365 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7366 sizeof(base_xpath
), NULL
)
7368 return CMD_WARNING_CONFIG_FAILED
;
7370 nb_cli_enqueue_change(vty
, "./timers/connect-time", NB_OP_DESTROY
,
7373 return nb_cli_apply_changes(vty
, base_xpath
);
7376 DEFPY (neighbor_timers_delayopen
,
7377 neighbor_timers_delayopen_cmd
,
7378 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7381 "BGP per neighbor timers\n"
7382 "RFC 4271 DelayOpenTimer\n"
7383 "DelayOpenTime timer interval\n")
7387 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7389 return CMD_WARNING_CONFIG_FAILED
;
7392 if (peer_timers_delayopen_unset(peer
))
7393 return CMD_WARNING_CONFIG_FAILED
;
7395 if (peer_timers_delayopen_set(peer
, interval
))
7396 return CMD_WARNING_CONFIG_FAILED
;
7402 DEFPY (no_neighbor_timers_delayopen
,
7403 no_neighbor_timers_delayopen_cmd
,
7404 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7408 "BGP per neighbor timers\n"
7409 "RFC 4271 DelayOpenTimer\n"
7410 "DelayOpenTime timer interval\n")
7414 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7416 return CMD_WARNING_CONFIG_FAILED
;
7418 if (peer_timers_delayopen_unset(peer
))
7419 return CMD_WARNING_CONFIG_FAILED
;
7424 DEFUN_YANG (neighbor_advertise_interval
,
7425 neighbor_advertise_interval_cmd
,
7426 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7427 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7428 "Minimum interval between sending BGP routing updates\n"
7429 "time in seconds\n")
7433 char base_xpath
[XPATH_MAXLEN
];
7435 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7436 sizeof(base_xpath
), NULL
)
7438 return CMD_WARNING_CONFIG_FAILED
;
7440 nb_cli_enqueue_change(vty
, "./timers/advertise-interval", NB_OP_MODIFY
,
7441 argv
[idx_number
]->arg
);
7443 return nb_cli_apply_changes(vty
, base_xpath
);
7446 DEFUN_YANG (no_neighbor_advertise_interval
,
7447 no_neighbor_advertise_interval_cmd
,
7448 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7449 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7450 "Minimum interval between sending BGP routing updates\n"
7451 "time in seconds\n")
7454 char base_xpath
[XPATH_MAXLEN
];
7456 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7457 sizeof(base_xpath
), NULL
)
7459 return CMD_WARNING_CONFIG_FAILED
;
7461 nb_cli_enqueue_change(vty
, "./timers/advertise-interval", NB_OP_DESTROY
,
7464 return nb_cli_apply_changes(vty
, base_xpath
);
7468 /* Time to wait before processing route-map updates */
7469 DEFUN (bgp_set_route_map_delay_timer
,
7470 bgp_set_route_map_delay_timer_cmd
,
7471 "bgp route-map delay-timer (0-600)",
7473 "BGP route-map delay timer\n"
7474 "Time in secs to wait before processing route-map changes\n"
7475 "0 disables the timer, no route updates happen when route-maps change\n")
7478 uint32_t rmap_delay_timer
;
7480 if (argv
[idx_number
]->arg
) {
7481 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7482 bm
->rmap_update_timer
= rmap_delay_timer
;
7484 /* if the dynamic update handling is being disabled, and a timer
7486 * running, stop the timer and act as if the timer has already
7489 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7490 BGP_TIMER_OFF(bm
->t_rmap_update
);
7491 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7496 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7497 return CMD_WARNING_CONFIG_FAILED
;
7501 DEFUN (no_bgp_set_route_map_delay_timer
,
7502 no_bgp_set_route_map_delay_timer_cmd
,
7503 "no bgp route-map delay-timer [(0-600)]",
7506 "Default BGP route-map delay timer\n"
7507 "Reset to default time to wait for processing route-map changes\n"
7508 "0 disables the timer, no route updates happen when route-maps change\n")
7511 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7516 DEFUN_YANG (neighbor_interface
,
7517 neighbor_interface_cmd
,
7518 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7519 NEIGHBOR_STR NEIGHBOR_ADDR_STR
7525 char base_xpath
[XPATH_MAXLEN
];
7527 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7528 argv
[idx_ip
]->arg
, "");
7530 nb_cli_enqueue_change(vty
, "./local-interface", NB_OP_MODIFY
,
7531 argv
[idx_word
]->arg
);
7533 return nb_cli_apply_changes(vty
, base_xpath
);
7536 DEFUN_YANG (no_neighbor_interface
,
7537 no_neighbor_interface_cmd
,
7538 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
7539 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7544 char base_xpath
[XPATH_MAXLEN
];
7546 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7547 argv
[idx_peer
]->arg
, "");
7549 nb_cli_enqueue_change(vty
, "./local-interface", NB_OP_DESTROY
, NULL
);
7551 return nb_cli_apply_changes(vty
, base_xpath
);
7554 DEFUN (neighbor_distribute_list
,
7555 neighbor_distribute_list_cmd
,
7556 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7559 "Filter updates to/from this neighbor\n"
7560 "IP access-list number\n"
7561 "IP access-list number (expanded range)\n"
7562 "IP Access-list name\n"
7563 "Filter incoming updates\n"
7564 "Filter outgoing updates\n")
7571 const char *pstr
= argv
[idx_peer
]->arg
;
7572 const char *acl
= argv
[idx_acl
]->arg
;
7573 const char *inout
= argv
[argc
- 1]->text
;
7575 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7577 return CMD_WARNING_CONFIG_FAILED
;
7579 /* Check filter direction. */
7580 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7581 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7584 return bgp_vty_return(vty
, ret
);
7588 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7589 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7590 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7591 "Filter updates to/from this neighbor\n"
7592 "IP access-list number\n"
7593 "IP access-list number (expanded range)\n"
7594 "IP Access-list name\n"
7595 "Filter incoming updates\n"
7596 "Filter outgoing updates\n")
7598 DEFUN (no_neighbor_distribute_list
,
7599 no_neighbor_distribute_list_cmd
,
7600 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7604 "Filter updates to/from this neighbor\n"
7605 "IP access-list number\n"
7606 "IP access-list number (expanded range)\n"
7607 "IP Access-list name\n"
7608 "Filter incoming updates\n"
7609 "Filter outgoing updates\n")
7615 const char *pstr
= argv
[idx_peer
]->arg
;
7616 const char *inout
= argv
[argc
- 1]->text
;
7618 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7620 return CMD_WARNING_CONFIG_FAILED
;
7622 /* Check filter direction. */
7623 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7624 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7627 return bgp_vty_return(vty
, ret
);
7631 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7632 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7633 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7634 "Filter updates to/from this neighbor\n"
7635 "IP access-list number\n"
7636 "IP access-list number (expanded range)\n"
7637 "IP Access-list name\n"
7638 "Filter incoming updates\n"
7639 "Filter outgoing updates\n")
7641 /* Set prefix list to the peer. */
7642 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7643 afi_t afi
, safi_t safi
,
7644 const char *name_str
,
7645 const char *direct_str
)
7648 int direct
= FILTER_IN
;
7651 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7653 return CMD_WARNING_CONFIG_FAILED
;
7655 /* Check filter direction. */
7656 if (strncmp(direct_str
, "i", 1) == 0)
7658 else if (strncmp(direct_str
, "o", 1) == 0)
7659 direct
= FILTER_OUT
;
7661 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7663 return bgp_vty_return(vty
, ret
);
7666 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7667 afi_t afi
, safi_t safi
,
7668 const char *direct_str
)
7672 int direct
= FILTER_IN
;
7674 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7676 return CMD_WARNING_CONFIG_FAILED
;
7678 /* Check filter direction. */
7679 if (strncmp(direct_str
, "i", 1) == 0)
7681 else if (strncmp(direct_str
, "o", 1) == 0)
7682 direct
= FILTER_OUT
;
7684 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7686 return bgp_vty_return(vty
, ret
);
7689 DEFUN (neighbor_prefix_list
,
7690 neighbor_prefix_list_cmd
,
7691 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7694 "Filter updates to/from this neighbor\n"
7695 "Name of a prefix list\n"
7696 "Filter incoming updates\n"
7697 "Filter outgoing updates\n")
7702 return peer_prefix_list_set_vty(
7703 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7704 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7707 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7708 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7709 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7710 "Filter updates to/from this neighbor\n"
7711 "Name of a prefix list\n"
7712 "Filter incoming updates\n"
7713 "Filter outgoing updates\n")
7715 DEFUN (no_neighbor_prefix_list
,
7716 no_neighbor_prefix_list_cmd
,
7717 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7721 "Filter updates to/from this neighbor\n"
7722 "Name of a prefix list\n"
7723 "Filter incoming updates\n"
7724 "Filter outgoing updates\n")
7728 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7729 bgp_node_afi(vty
), bgp_node_safi(vty
),
7730 argv
[idx_in_out
]->arg
);
7733 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7734 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7735 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7736 "Filter updates to/from this neighbor\n"
7737 "Name of a prefix list\n"
7738 "Filter incoming updates\n"
7739 "Filter outgoing updates\n")
7741 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7742 safi_t safi
, const char *name_str
,
7743 const char *direct_str
)
7747 int direct
= FILTER_IN
;
7749 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7751 return CMD_WARNING_CONFIG_FAILED
;
7753 /* Check filter direction. */
7754 if (strncmp(direct_str
, "i", 1) == 0)
7756 else if (strncmp(direct_str
, "o", 1) == 0)
7757 direct
= FILTER_OUT
;
7759 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7761 return bgp_vty_return(vty
, ret
);
7764 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7765 safi_t safi
, const char *direct_str
)
7769 int direct
= FILTER_IN
;
7771 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7773 return CMD_WARNING_CONFIG_FAILED
;
7775 /* Check filter direction. */
7776 if (strncmp(direct_str
, "i", 1) == 0)
7778 else if (strncmp(direct_str
, "o", 1) == 0)
7779 direct
= FILTER_OUT
;
7781 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7783 return bgp_vty_return(vty
, ret
);
7786 DEFUN (neighbor_filter_list
,
7787 neighbor_filter_list_cmd
,
7788 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7791 "Establish BGP filters\n"
7792 "AS path access-list name\n"
7793 "Filter incoming routes\n"
7794 "Filter outgoing routes\n")
7799 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7800 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7801 argv
[idx_in_out
]->arg
);
7804 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7805 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7806 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7807 "Establish BGP filters\n"
7808 "AS path access-list name\n"
7809 "Filter incoming routes\n"
7810 "Filter outgoing routes\n")
7812 DEFUN (no_neighbor_filter_list
,
7813 no_neighbor_filter_list_cmd
,
7814 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7818 "Establish BGP filters\n"
7819 "AS path access-list name\n"
7820 "Filter incoming routes\n"
7821 "Filter outgoing routes\n")
7825 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7826 bgp_node_afi(vty
), bgp_node_safi(vty
),
7827 argv
[idx_in_out
]->arg
);
7830 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7831 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7832 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7833 "Establish BGP filters\n"
7834 "AS path access-list name\n"
7835 "Filter incoming routes\n"
7836 "Filter outgoing routes\n")
7838 /* Set advertise-map to the peer. */
7839 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7840 afi_t afi
, safi_t safi
,
7841 const char *advertise_str
,
7842 const char *condition_str
, bool condition
,
7845 int ret
= CMD_WARNING_CONFIG_FAILED
;
7847 struct route_map
*advertise_map
;
7848 struct route_map
*condition_map
;
7850 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7854 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7855 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7858 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7859 advertise_map
, condition_str
,
7860 condition_map
, condition
);
7862 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7863 advertise_map
, condition_str
,
7864 condition_map
, condition
);
7866 return bgp_vty_return(vty
, ret
);
7869 DEFPY (neighbor_advertise_map
,
7870 neighbor_advertise_map_cmd
,
7871 "[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",
7875 "Route-map to conditionally advertise routes\n"
7876 "Name of advertise map\n"
7877 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7878 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7879 "Name of the exist or non exist map\n")
7881 bool condition
= CONDITION_EXIST
;
7883 if (!strcmp(exist
, "non-exist-map"))
7884 condition
= CONDITION_NON_EXIST
;
7886 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7887 bgp_node_safi(vty
), advertise_str
,
7888 condition_str
, condition
, !no
);
7891 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7892 "[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",
7893 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7894 "Route-map to conditionally advertise routes\n"
7895 "Name of advertise map\n"
7896 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7897 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7898 "Name of the exist or non exist map\n")
7900 /* Set route-map to the peer. */
7901 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7902 afi_t afi
, safi_t safi
, const char *name_str
,
7903 const char *direct_str
)
7907 int direct
= RMAP_IN
;
7908 struct route_map
*route_map
;
7910 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7912 return CMD_WARNING_CONFIG_FAILED
;
7914 /* Check filter direction. */
7915 if (strncmp(direct_str
, "in", 2) == 0)
7917 else if (strncmp(direct_str
, "o", 1) == 0)
7920 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7921 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7923 return bgp_vty_return(vty
, ret
);
7926 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7927 afi_t afi
, safi_t safi
,
7928 const char *direct_str
)
7932 int direct
= RMAP_IN
;
7934 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7936 return CMD_WARNING_CONFIG_FAILED
;
7938 /* Check filter direction. */
7939 if (strncmp(direct_str
, "in", 2) == 0)
7941 else if (strncmp(direct_str
, "o", 1) == 0)
7944 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7946 return bgp_vty_return(vty
, ret
);
7949 DEFUN (neighbor_route_map
,
7950 neighbor_route_map_cmd
,
7951 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7954 "Apply route map to neighbor\n"
7955 "Name of route map\n"
7956 "Apply map to incoming routes\n"
7957 "Apply map to outbound routes\n")
7962 return peer_route_map_set_vty(
7963 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7964 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7967 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7968 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7969 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7970 "Apply route map to neighbor\n"
7971 "Name of route map\n"
7972 "Apply map to incoming routes\n"
7973 "Apply map to outbound routes\n")
7975 DEFUN (no_neighbor_route_map
,
7976 no_neighbor_route_map_cmd
,
7977 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7981 "Apply route map to neighbor\n"
7982 "Name of route map\n"
7983 "Apply map to incoming routes\n"
7984 "Apply map to outbound routes\n")
7988 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7989 bgp_node_afi(vty
), bgp_node_safi(vty
),
7990 argv
[idx_in_out
]->arg
);
7993 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7994 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7995 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7996 "Apply route map to neighbor\n"
7997 "Name of route map\n"
7998 "Apply map to incoming routes\n"
7999 "Apply map to outbound routes\n")
8001 /* Set unsuppress-map to the peer. */
8002 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
8003 afi_t afi
, safi_t safi
,
8004 const char *name_str
)
8008 struct route_map
*route_map
;
8010 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8012 return CMD_WARNING_CONFIG_FAILED
;
8014 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
8015 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
8017 return bgp_vty_return(vty
, ret
);
8020 /* Unset route-map from the peer. */
8021 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
8022 afi_t afi
, safi_t safi
)
8027 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8029 return CMD_WARNING_CONFIG_FAILED
;
8031 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
8033 return bgp_vty_return(vty
, ret
);
8036 DEFUN (neighbor_unsuppress_map
,
8037 neighbor_unsuppress_map_cmd
,
8038 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8041 "Route-map to selectively unsuppress suppressed routes\n"
8042 "Name of route map\n")
8046 return peer_unsuppress_map_set_vty(
8047 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8048 argv
[idx_word
]->arg
);
8051 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
8052 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8053 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8054 "Route-map to selectively unsuppress suppressed routes\n"
8055 "Name of route map\n")
8057 DEFUN (no_neighbor_unsuppress_map
,
8058 no_neighbor_unsuppress_map_cmd
,
8059 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8063 "Route-map to selectively unsuppress suppressed routes\n"
8064 "Name of route map\n")
8067 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
8069 bgp_node_safi(vty
));
8072 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
8073 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8074 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8075 "Route-map to selectively unsuppress suppressed routes\n"
8076 "Name of route map\n")
8078 /* Maximum number of prefix to be sent to the neighbor. */
8079 DEFUN_YANG(neighbor_maximum_prefix_out
,
8080 neighbor_maximum_prefix_out_cmd
,
8081 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
8082 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8083 "Maximum number of prefixes to be sent to this peer\n"
8084 "Maximum no. of prefix limit\n")
8086 char base_xpath
[XPATH_MAXLEN
];
8087 char af_xpath
[XPATH_MAXLEN
];
8088 char attr_xpath
[XPATH_MAXLEN
];
8091 afi_t afi
= bgp_node_afi(vty
);
8092 safi_t safi
= bgp_node_safi(vty
);
8094 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8095 yang_afi_safi_value2identity(afi
, safi
));
8096 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8097 sizeof(base_xpath
), af_xpath
)
8099 return CMD_WARNING_CONFIG_FAILED
;
8101 snprintf(attr_xpath
, sizeof(attr_xpath
),
8102 "/%s/prefix-limit/direction-list[direction='out']",
8103 bgp_afi_safi_get_container_str(afi
, safi
));
8104 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8106 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8108 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8109 argv
[idx_number
]->arg
);
8111 return nb_cli_apply_changes(vty
, base_xpath
);
8114 DEFUN_YANG(no_neighbor_maximum_prefix_out
,
8115 no_neighbor_maximum_prefix_out_cmd
,
8116 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out",
8117 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8118 "Maximum number of prefixes to be sent to this peer\n")
8120 char base_xpath
[XPATH_MAXLEN
];
8121 char af_xpath
[XPATH_MAXLEN
];
8122 char attr_xpath
[XPATH_MAXLEN
];
8124 afi_t afi
= bgp_node_afi(vty
);
8125 safi_t safi
= bgp_node_safi(vty
);
8127 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8128 yang_afi_safi_value2identity(afi
, safi
));
8129 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8130 sizeof(base_xpath
), af_xpath
)
8132 return CMD_WARNING_CONFIG_FAILED
;
8134 snprintf(attr_xpath
, sizeof(attr_xpath
),
8135 "/%s/prefix-limit/direction-list[direction='out']",
8136 bgp_afi_safi_get_container_str(afi
, safi
));
8137 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8139 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
8141 return nb_cli_apply_changes(vty
, base_xpath
);
8144 /* Maximum number of prefix configuration. Prefix count is different
8145 for each peer configuration. So this configuration can be set for
8146 each peer configuration. */
8147 DEFUN_YANG(neighbor_maximum_prefix
,
8148 neighbor_maximum_prefix_cmd
,
8149 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8150 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8151 "Maximum number of prefix accept from this peer\n"
8152 "maximum no. of prefix limit\n"
8153 "Force checking all received routes not only accepted\n")
8158 char base_xpath
[XPATH_MAXLEN
];
8159 char af_xpath
[XPATH_MAXLEN
];
8160 char attr_xpath
[XPATH_MAXLEN
];
8161 afi_t afi
= bgp_node_afi(vty
);
8162 safi_t safi
= bgp_node_safi(vty
);
8164 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8165 yang_afi_safi_value2identity(afi
, safi
));
8166 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8167 sizeof(base_xpath
), af_xpath
)
8169 return CMD_WARNING_CONFIG_FAILED
;
8171 snprintf(attr_xpath
, sizeof(attr_xpath
),
8172 "/%s/prefix-limit/direction-list[direction='in']",
8173 bgp_afi_safi_get_container_str(afi
, safi
));
8174 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8176 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8178 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8179 argv
[idx_number
]->arg
);
8180 if (argv_find(argv
, argc
, "force", &idx_force
))
8181 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8184 return nb_cli_apply_changes(vty
, base_xpath
);
8187 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8188 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8189 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8190 "Maximum number of prefix accept from this peer\n"
8191 "maximum no. of prefix limit\n"
8192 "Force checking all received routes not only accepted\n")
8194 DEFUN_YANG(neighbor_maximum_prefix_threshold
,
8195 neighbor_maximum_prefix_threshold_cmd
,
8196 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8197 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8198 "Maximum number of prefix accept from this peer\n"
8199 "maximum no. of prefix limit\n"
8200 "Threshold value (%) at which to generate a warning msg\n"
8201 "Force checking all received routes not only accepted\n")
8205 int idx_number_2
= 4;
8207 char base_xpath
[XPATH_MAXLEN
];
8208 char af_xpath
[XPATH_MAXLEN
];
8209 char attr_xpath
[XPATH_MAXLEN
];
8210 afi_t afi
= bgp_node_afi(vty
);
8211 safi_t safi
= bgp_node_safi(vty
);
8213 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8214 yang_afi_safi_value2identity(afi
, safi
));
8215 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8216 sizeof(base_xpath
), af_xpath
)
8218 return CMD_WARNING_CONFIG_FAILED
;
8220 snprintf(attr_xpath
, sizeof(attr_xpath
),
8221 "/%s/prefix-limit/direction-list[direction='in']",
8222 bgp_afi_safi_get_container_str(afi
, safi
));
8223 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8225 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8227 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8228 argv
[idx_number
]->arg
);
8230 nb_cli_enqueue_change(vty
, "./options/shutdown-threshold-pct",
8231 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8233 if (argv_find(argv
, argc
, "force", &idx_force
))
8234 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8237 return nb_cli_apply_changes(vty
, base_xpath
);
8241 neighbor_maximum_prefix_threshold
,
8242 neighbor_maximum_prefix_threshold_hidden_cmd
,
8243 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8244 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8245 "Maximum number of prefix accept from this peer\n"
8246 "maximum no. of prefix limit\n"
8247 "Threshold value (%) at which to generate a warning msg\n"
8248 "Force checking all received routes not only accepted\n")
8250 DEFUN_YANG(neighbor_maximum_prefix_warning
,
8251 neighbor_maximum_prefix_warning_cmd
,
8252 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8253 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8254 "Maximum number of prefix accept from this peer\n"
8255 "maximum no. of prefix limit\n"
8256 "Only give warning message when limit is exceeded\n"
8257 "Force checking all received routes not only accepted\n")
8262 char base_xpath
[XPATH_MAXLEN
];
8263 char af_xpath
[XPATH_MAXLEN
];
8264 char attr_xpath
[XPATH_MAXLEN
];
8265 afi_t afi
= bgp_node_afi(vty
);
8266 safi_t safi
= bgp_node_safi(vty
);
8268 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8269 yang_afi_safi_value2identity(afi
, safi
));
8270 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8271 sizeof(base_xpath
), af_xpath
)
8273 return CMD_WARNING_CONFIG_FAILED
;
8275 snprintf(attr_xpath
, sizeof(attr_xpath
),
8276 "/%s/prefix-limit/direction-list[direction='in']",
8277 bgp_afi_safi_get_container_str(afi
, safi
));
8278 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8280 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8282 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8283 argv
[idx_number
]->arg
);
8285 nb_cli_enqueue_change(vty
, "./options/warning-only", NB_OP_MODIFY
,
8287 if (argv_find(argv
, argc
, "force", &idx_force
))
8288 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8291 return nb_cli_apply_changes(vty
, base_xpath
);
8295 neighbor_maximum_prefix_warning
,
8296 neighbor_maximum_prefix_warning_hidden_cmd
,
8297 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8298 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8299 "Maximum number of prefix accept from this peer\n"
8300 "maximum no. of prefix limit\n"
8301 "Only give warning message when limit is exceeded\n"
8302 "Force checking all received routes not only accepted\n")
8304 DEFUN_YANG(neighbor_maximum_prefix_threshold_warning
,
8305 neighbor_maximum_prefix_threshold_warning_cmd
,
8306 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8307 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8308 "Maximum number of prefix accept from this peer\n"
8309 "maximum no. of prefix limit\n"
8310 "Threshold value (%) at which to generate a warning msg\n"
8311 "Only give warning message when limit is exceeded\n"
8312 "Force checking all received routes not only accepted\n")
8316 int idx_number_2
= 4;
8318 char base_xpath
[XPATH_MAXLEN
];
8319 char af_xpath
[XPATH_MAXLEN
];
8320 char attr_xpath
[XPATH_MAXLEN
];
8321 afi_t afi
= bgp_node_afi(vty
);
8322 safi_t safi
= bgp_node_safi(vty
);
8324 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8325 yang_afi_safi_value2identity(afi
, safi
));
8326 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8327 sizeof(base_xpath
), af_xpath
)
8329 return CMD_WARNING_CONFIG_FAILED
;
8331 snprintf(attr_xpath
, sizeof(attr_xpath
),
8332 "/%s/prefix-limit/direction-list[direction='in']",
8333 bgp_afi_safi_get_container_str(afi
, safi
));
8334 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8336 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8338 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8339 argv
[idx_number
]->arg
);
8340 nb_cli_enqueue_change(vty
, "./options/tw-shutdown-threshold-pct",
8341 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8342 nb_cli_enqueue_change(vty
, "./options/tw-warning-only", NB_OP_MODIFY
,
8344 if (argv_find(argv
, argc
, "force", &idx_force
))
8345 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8348 return nb_cli_apply_changes(vty
, base_xpath
);
8352 neighbor_maximum_prefix_threshold_warning
,
8353 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8354 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8355 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8356 "Maximum number of prefix accept from this peer\n"
8357 "maximum no. of prefix limit\n"
8358 "Threshold value (%) at which to generate a warning msg\n"
8359 "Only give warning message when limit is exceeded\n"
8360 "Force checking all received routes not only accepted\n")
8362 DEFUN_YANG(neighbor_maximum_prefix_restart
,
8363 neighbor_maximum_prefix_restart_cmd
,
8364 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8365 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8366 "Maximum number of prefix accept from this peer\n"
8367 "maximum no. of prefix limit\n"
8368 "Restart bgp connection after limit is exceeded\n"
8369 "Restart interval in minutes\n"
8370 "Force checking all received routes not only accepted\n")
8374 int idx_number_2
= 5;
8376 char base_xpath
[XPATH_MAXLEN
];
8377 char af_xpath
[XPATH_MAXLEN
];
8378 char attr_xpath
[XPATH_MAXLEN
];
8379 afi_t afi
= bgp_node_afi(vty
);
8380 safi_t safi
= bgp_node_safi(vty
);
8382 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8383 yang_afi_safi_value2identity(afi
, safi
));
8384 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8385 sizeof(base_xpath
), af_xpath
)
8387 return CMD_WARNING_CONFIG_FAILED
;
8389 snprintf(attr_xpath
, sizeof(attr_xpath
),
8390 "/%s/prefix-limit/direction-list[direction='in']",
8391 bgp_afi_safi_get_container_str(afi
, safi
));
8392 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8394 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8396 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8397 argv
[idx_number
]->arg
);
8398 nb_cli_enqueue_change(vty
, "./options/restart-timer", NB_OP_MODIFY
,
8399 argv
[idx_number_2
]->arg
);
8400 if (argv_find(argv
, argc
, "force", &idx_force
))
8401 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8404 return nb_cli_apply_changes(vty
, base_xpath
);
8408 neighbor_maximum_prefix_restart
,
8409 neighbor_maximum_prefix_restart_hidden_cmd
,
8410 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8411 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8412 "Maximum number of prefix accept from this peer\n"
8413 "maximum no. of prefix limit\n"
8414 "Restart bgp connection after limit is exceeded\n"
8415 "Restart interval in minutes\n"
8416 "Force checking all received routes not only accepted\n")
8418 DEFUN_YANG(neighbor_maximum_prefix_threshold_restart
,
8419 neighbor_maximum_prefix_threshold_restart_cmd
,
8420 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8421 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8422 "Maximum number of prefixes to accept from this peer\n"
8423 "maximum no. of prefix limit\n"
8424 "Threshold value (%) at which to generate a warning msg\n"
8425 "Restart bgp connection after limit is exceeded\n"
8426 "Restart interval in minutes\n"
8427 "Force checking all received routes not only accepted\n")
8431 int idx_number_2
= 4;
8432 int idx_number_3
= 6;
8434 char base_xpath
[XPATH_MAXLEN
];
8435 char af_xpath
[XPATH_MAXLEN
];
8436 char attr_xpath
[XPATH_MAXLEN
];
8437 afi_t afi
= bgp_node_afi(vty
);
8438 safi_t safi
= bgp_node_safi(vty
);
8440 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8441 yang_afi_safi_value2identity(afi
, safi
));
8442 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8443 sizeof(base_xpath
), af_xpath
)
8445 return CMD_WARNING_CONFIG_FAILED
;
8447 snprintf(attr_xpath
, sizeof(attr_xpath
),
8448 "/%s/prefix-limit/direction-list[direction='in']",
8449 bgp_afi_safi_get_container_str(afi
, safi
));
8450 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8452 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8454 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8455 argv
[idx_number
]->arg
);
8456 nb_cli_enqueue_change(vty
, "./options/tr-shutdown-threshold-pct",
8457 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8458 nb_cli_enqueue_change(vty
, "./options/tr-restart-timer", NB_OP_MODIFY
,
8459 argv
[idx_number_3
]->arg
);
8460 if (argv_find(argv
, argc
, "force", &idx_force
))
8461 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8464 return nb_cli_apply_changes(vty
, base_xpath
);
8468 neighbor_maximum_prefix_threshold_restart
,
8469 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8470 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8471 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8472 "Maximum number of prefixes to accept from this peer\n"
8473 "maximum no. of prefix limit\n"
8474 "Threshold value (%) at which to generate a warning msg\n"
8475 "Restart bgp connection after limit is exceeded\n"
8476 "Restart interval in minutes\n"
8477 "Force checking all received routes not only accepted\n")
8479 DEFUN_YANG(no_neighbor_maximum_prefix
,
8480 no_neighbor_maximum_prefix_cmd
,
8481 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8482 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8483 "Maximum number of prefixes to accept from this peer\n"
8484 "maximum no. of prefix limit\n"
8485 "Threshold value (%) at which to generate a warning msg\n"
8486 "Restart bgp connection after limit is exceeded\n"
8487 "Restart interval in minutes\n"
8488 "Only give warning message when limit is exceeded\n"
8489 "Force checking all received routes not only accepted\n")
8492 char base_xpath
[XPATH_MAXLEN
];
8493 char af_xpath
[XPATH_MAXLEN
];
8494 char attr_xpath
[XPATH_MAXLEN
];
8495 afi_t afi
= bgp_node_afi(vty
);
8496 safi_t safi
= bgp_node_safi(vty
);
8498 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8499 yang_afi_safi_value2identity(afi
, safi
));
8500 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8501 sizeof(base_xpath
), af_xpath
)
8503 return CMD_WARNING_CONFIG_FAILED
;
8505 snprintf(attr_xpath
, sizeof(attr_xpath
),
8506 "/%s/prefix-limit/direction-list[direction='in']",
8507 bgp_afi_safi_get_container_str(afi
, safi
));
8508 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8510 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
8512 return nb_cli_apply_changes(vty
, base_xpath
);
8516 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8517 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8518 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8519 "Maximum number of prefixes to accept from this peer\n"
8520 "maximum no. of prefix limit\n"
8521 "Threshold value (%) at which to generate a warning msg\n"
8522 "Restart bgp connection after limit is exceeded\n"
8523 "Restart interval in minutes\n"
8524 "Only give warning message when limit is exceeded\n"
8525 "Force checking all received routes not only accepted\n")
8528 /* "neighbor allowas-in" */
8529 DEFUN (neighbor_allowas_in
,
8530 neighbor_allowas_in_cmd
,
8531 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8534 "Accept as-path with my AS present in it\n"
8535 "Number of occurrences of AS number\n"
8536 "Only accept my AS in the as-path if the route was originated in my AS\n")
8539 int idx_number_origin
= 3;
8545 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8547 return CMD_WARNING_CONFIG_FAILED
;
8549 if (argc
<= idx_number_origin
)
8552 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8555 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8558 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8561 return bgp_vty_return(vty
, ret
);
8565 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8566 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8567 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8568 "Accept as-path with my AS present in it\n"
8569 "Number of occurrences of AS number\n"
8570 "Only accept my AS in the as-path if the route was originated in my AS\n")
8572 DEFUN (no_neighbor_allowas_in
,
8573 no_neighbor_allowas_in_cmd
,
8574 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8578 "allow local ASN appears in aspath attribute\n"
8579 "Number of occurrences of AS number\n"
8580 "Only accept my AS in the as-path if the route was originated in my AS\n")
8586 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8588 return CMD_WARNING_CONFIG_FAILED
;
8590 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8591 bgp_node_safi(vty
));
8593 return bgp_vty_return(vty
, ret
);
8597 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8598 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8599 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8600 "allow local ASN appears in aspath attribute\n"
8601 "Number of occurrences of AS number\n"
8602 "Only accept my AS in the as-path if the route was originated in my AS\n")
8604 DEFUN_YANG (neighbor_ttl_security
,
8605 neighbor_ttl_security_cmd
,
8606 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8609 "BGP ttl-security parameters\n"
8610 "Specify the maximum number of hops to the BGP peer\n"
8611 "Number of hops to BGP peer\n")
8615 char base_xpath
[XPATH_MAXLEN
];
8617 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8618 sizeof(base_xpath
), NULL
)
8620 return CMD_WARNING_CONFIG_FAILED
;
8622 nb_cli_enqueue_change(vty
, "./ttl-security", NB_OP_MODIFY
,
8623 argv
[idx_number
]->arg
);
8625 return nb_cli_apply_changes(vty
, base_xpath
);
8628 DEFUN_YANG(no_neighbor_ttl_security
,
8629 no_neighbor_ttl_security_cmd
,
8630 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8631 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8632 "BGP ttl-security parameters\n"
8633 "Specify the maximum number of hops to the BGP peer\n"
8634 "Number of hops to BGP peer\n")
8637 char base_xpath
[XPATH_MAXLEN
];
8639 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8640 sizeof(base_xpath
), NULL
)
8642 return CMD_WARNING_CONFIG_FAILED
;
8644 nb_cli_enqueue_change(vty
, "./ttl-security", NB_OP_DESTROY
, NULL
);
8646 return nb_cli_apply_changes(vty
, base_xpath
);
8649 DEFUN (neighbor_addpath_tx_all_paths
,
8650 neighbor_addpath_tx_all_paths_cmd
,
8651 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8654 "Use addpath to advertise all paths to a neighbor\n")
8659 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8661 return CMD_WARNING_CONFIG_FAILED
;
8663 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8668 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8669 neighbor_addpath_tx_all_paths_hidden_cmd
,
8670 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8671 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8672 "Use addpath to advertise all paths to a neighbor\n")
8674 DEFUN (no_neighbor_addpath_tx_all_paths
,
8675 no_neighbor_addpath_tx_all_paths_cmd
,
8676 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8680 "Use addpath to advertise all paths to a neighbor\n")
8685 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8687 return CMD_WARNING_CONFIG_FAILED
;
8689 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8690 != BGP_ADDPATH_ALL
) {
8692 "%% Peer not currently configured to transmit all paths.");
8693 return CMD_WARNING_CONFIG_FAILED
;
8696 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8702 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8703 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8704 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8705 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8706 "Use addpath to advertise all paths to a neighbor\n")
8708 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8709 neighbor_addpath_tx_bestpath_per_as_cmd
,
8710 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8713 "Use addpath to advertise the bestpath per each neighboring AS\n")
8718 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8720 return CMD_WARNING_CONFIG_FAILED
;
8722 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8723 BGP_ADDPATH_BEST_PER_AS
);
8728 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8729 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8730 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8731 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8732 "Use addpath to advertise the bestpath per each neighboring AS\n")
8734 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8735 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8736 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8740 "Use addpath to advertise the bestpath per each neighboring AS\n")
8745 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8747 return CMD_WARNING_CONFIG_FAILED
;
8749 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8750 != BGP_ADDPATH_BEST_PER_AS
) {
8752 "%% Peer not currently configured to transmit all best path per as.");
8753 return CMD_WARNING_CONFIG_FAILED
;
8756 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8762 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8763 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8764 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8765 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8766 "Use addpath to advertise the bestpath per each neighboring AS\n")
8769 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8770 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8773 "Detect AS loops before sending to neighbor\n")
8777 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8779 return CMD_WARNING_CONFIG_FAILED
;
8781 peer
->as_path_loop_detection
= true;
8787 no_neighbor_aspath_loop_detection
,
8788 no_neighbor_aspath_loop_detection_cmd
,
8789 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8793 "Detect AS loops before sending to neighbor\n")
8797 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8799 return CMD_WARNING_CONFIG_FAILED
;
8801 peer
->as_path_loop_detection
= false;
8806 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8807 struct ecommunity
**list
, bool is_rt6
)
8809 struct ecommunity
*ecom
= NULL
;
8810 struct ecommunity
*ecomadd
;
8812 for (; argc
; --argc
, ++argv
) {
8814 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8815 ECOMMUNITY_ROUTE_TARGET
,
8818 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8819 ECOMMUNITY_ROUTE_TARGET
,
8822 vty_out(vty
, "Malformed community-list value\n");
8824 ecommunity_free(&ecom
);
8825 return CMD_WARNING_CONFIG_FAILED
;
8829 ecommunity_merge(ecom
, ecomadd
);
8830 ecommunity_free(&ecomadd
);
8837 ecommunity_free(&*list
);
8844 bool vpn_policy_check_import(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
8845 bool v2vimport
, char *errmsg
, size_t errmsg_len
)
8848 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8849 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8850 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8851 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8853 errmsg
, errmsg_len
, "%s",
8854 "%% error: Please unconfigure import vrf commands before using vpn commands");
8858 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8859 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8860 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8861 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8863 errmsg
, errmsg_len
, "%s",
8864 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands");
8872 * v2vimport is true if we are handling a `import vrf ...` command
8874 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8878 switch (vty
->node
) {
8887 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8892 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8893 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8894 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8895 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8897 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8901 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8902 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8903 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8904 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8906 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8915 af_rd_vpn_export_cmd
,
8916 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8918 "Specify route distinguisher\n"
8919 "Between current address-family and vpn\n"
8920 "For routes leaked from current address-family to vpn\n"
8921 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8923 char base_xpath
[XPATH_MAXLEN
];
8928 afi
= bgp_node_afi(vty
);
8929 safi
= bgp_node_safi(vty
);
8932 base_xpath
, sizeof(base_xpath
),
8933 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
8934 yang_afi_safi_value2identity(afi
, safi
),
8935 bgp_afi_safi_get_container_str(afi
, safi
));
8937 if (argv_find(argv
, argc
, "no", &idx
))
8938 nb_cli_enqueue_change(vty
, "./rd", NB_OP_DESTROY
, NULL
);
8940 nb_cli_enqueue_change(vty
, "./rd", NB_OP_MODIFY
, rd_str
);
8942 return nb_cli_apply_changes(vty
, base_xpath
);
8945 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rd(
8946 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
8950 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
8951 yang_dnode_get_string(dnode
, NULL
));
8954 ALIAS (af_rd_vpn_export
,
8955 af_no_rd_vpn_export_cmd
,
8958 "Specify route distinguisher\n"
8959 "Between current address-family and vpn\n"
8960 "For routes leaked from current address-family to vpn\n")
8962 DEFPY (af_label_vpn_export
,
8963 af_label_vpn_export_cmd
,
8964 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
8966 "label value for VRF\n"
8967 "Between current address-family and vpn\n"
8968 "For routes leaked from current address-family to vpn\n"
8969 "Label Value <0-1048575>\n"
8970 "Automatically assign a label\n")
8972 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8973 mpls_label_t label
= MPLS_LABEL_NONE
;
8978 if (argv_find(argv
, argc
, "no", &idx
))
8981 /* If "no ...", squash trailing parameter */
8987 label
= label_val
; /* parser should force unsigned */
8990 afi
= vpn_policy_getafi(vty
, bgp
, false);
8992 return CMD_WARNING_CONFIG_FAILED
;
8995 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8996 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
9001 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9003 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9004 bgp_get_default(), bgp
);
9006 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9007 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
9009 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
9012 * label has previously been automatically
9013 * assigned by labelpool: release it
9015 * NB if tovpn_label == MPLS_LABEL_NONE it
9016 * means the automatic assignment is in flight
9017 * and therefore the labelpool callback must
9018 * detect that the auto label is not needed.
9021 bgp_lp_release(LP_TYPE_VRF
,
9022 &bgp
->vpn_policy
[afi
],
9023 bgp
->vpn_policy
[afi
].tovpn_label
);
9025 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9026 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9029 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
9031 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9032 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9033 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
9034 vpn_leak_label_callback
);
9037 /* post-change: re-export vpn routes */
9038 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9039 bgp_get_default(), bgp
);
9044 ALIAS (af_label_vpn_export
,
9045 af_no_label_vpn_export_cmd
,
9046 "no label vpn export",
9048 "label value for VRF\n"
9049 "Between current address-family and vpn\n"
9050 "For routes leaked from current address-family to vpn\n")
9052 DEFPY_YANG (af_nexthop_vpn_export
,
9053 af_nexthop_vpn_export_cmd
,
9054 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
9056 "Specify next hop to use for VRF advertised prefixes\n"
9057 "Between current address-family and vpn\n"
9058 "For routes leaked from current address-family to vpn\n"
9062 char base_xpath
[XPATH_MAXLEN
];
9070 vty_out(vty
, "%% Nexthop required\n");
9071 return CMD_WARNING_CONFIG_FAILED
;
9073 if (!sockunion2hostprefix(nexthop_su
, &p
))
9074 return CMD_WARNING_CONFIG_FAILED
;
9077 afi
= bgp_node_afi(vty
);
9078 safi
= bgp_node_safi(vty
);
9081 base_xpath
, sizeof(base_xpath
),
9082 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9083 yang_afi_safi_value2identity(afi
, safi
),
9084 bgp_afi_safi_get_container_str(afi
, safi
));
9086 if (argv_find(argv
, argc
, "no", &idx
))
9087 nb_cli_enqueue_change(vty
, "./nexthop", NB_OP_DESTROY
, NULL
);
9089 nb_cli_enqueue_change(vty
, "./nexthop", NB_OP_MODIFY
,
9092 return nb_cli_apply_changes(vty
, base_xpath
);
9095 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_nexthop(
9096 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9100 vty_out(vty
, "%*snexthop vpn export %s\n", indent
, "",
9101 yang_dnode_get_string(dnode
, NULL
));
9104 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9106 if (!strcmp(dstr
, "import")) {
9107 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9108 } else if (!strcmp(dstr
, "export")) {
9109 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9110 } else if (!strcmp(dstr
, "both")) {
9111 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9112 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9114 vty_out(vty
, "%% direction parse error\n");
9115 return CMD_WARNING_CONFIG_FAILED
;
9120 DEFPY (af_rt_vpn_imexport
,
9121 af_rt_vpn_imexport_cmd
,
9122 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9124 "Specify route target list\n"
9125 "Specify route target list\n"
9126 "Between current address-family and vpn\n"
9127 "For routes leaked from vpn to current address-family: match any\n"
9128 "For routes leaked from current address-family to vpn: set\n"
9129 "both import: match any and export: set\n"
9130 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9132 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9134 struct ecommunity
*ecom
= NULL
;
9135 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9136 vpn_policy_direction_t dir
;
9141 if (argv_find(argv
, argc
, "no", &idx
))
9144 afi
= vpn_policy_getafi(vty
, bgp
, false);
9146 return CMD_WARNING_CONFIG_FAILED
;
9148 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9149 if (ret
!= CMD_SUCCESS
)
9153 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9154 vty_out(vty
, "%% Missing RTLIST\n");
9155 return CMD_WARNING_CONFIG_FAILED
;
9157 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9158 if (ret
!= CMD_SUCCESS
) {
9163 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9167 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9170 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9172 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9173 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9174 ecommunity_dup(ecom
);
9176 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9178 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9179 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9182 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9186 ecommunity_free(&ecom
);
9191 ALIAS (af_rt_vpn_imexport
,
9192 af_no_rt_vpn_imexport_cmd
,
9193 "no <rt|route-target> vpn <import|export|both>$direction_str",
9195 "Specify route target list\n"
9196 "Specify route target list\n"
9197 "Between current address-family and vpn\n"
9198 "For routes leaked from vpn to current address-family\n"
9199 "For routes leaked from current address-family to vpn\n"
9200 "both import and export\n")
9202 DEFPY_YANG (af_route_map_vpn_imexport
,
9203 af_route_map_vpn_imexport_cmd
,
9204 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9205 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9207 "Specify route map\n"
9208 "Between current address-family and vpn\n"
9209 "For routes leaked from vpn to current address-family\n"
9210 "For routes leaked from current address-family to vpn\n"
9211 "name of route-map\n")
9213 char base_xpath
[XPATH_MAXLEN
];
9218 afi
= bgp_node_afi(vty
);
9219 safi
= bgp_node_safi(vty
);
9222 base_xpath
, sizeof(base_xpath
),
9223 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9224 yang_afi_safi_value2identity(afi
, safi
),
9225 bgp_afi_safi_get_container_str(afi
, safi
));
9227 if (argv_find(argv
, argc
, "no", &idx
)) {
9228 if (!strcmp(direction_str
, "import"))
9229 nb_cli_enqueue_change(vty
, "./rmap-import",
9230 NB_OP_DESTROY
, NULL
);
9231 else if (!strcmp(direction_str
, "export"))
9232 nb_cli_enqueue_change(vty
, "./rmap-export",
9233 NB_OP_DESTROY
, NULL
);
9235 if (!strcmp(direction_str
, "import"))
9236 nb_cli_enqueue_change(vty
, "./rmap-import",
9237 NB_OP_MODIFY
, rmap_str
);
9238 if (!strcmp(direction_str
, "export"))
9239 nb_cli_enqueue_change(vty
, "./rmap-export",
9240 NB_OP_MODIFY
, rmap_str
);
9242 return nb_cli_apply_changes(vty
, base_xpath
);
9245 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_import(
9246 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9250 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
9251 yang_dnode_get_string(dnode
, NULL
));
9254 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_export(
9255 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9259 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
9260 yang_dnode_get_string(dnode
, NULL
));
9263 ALIAS (af_route_map_vpn_imexport
,
9264 af_no_route_map_vpn_imexport_cmd
,
9265 "no route-map vpn <import|export>$direction_str",
9267 "Specify route map\n"
9268 "Between current address-family and vpn\n"
9269 "For routes leaked from vpn to current address-family\n"
9270 "For routes leaked from current address-family to vpn\n")
9272 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9273 "import vrf route-map RMAP$rmap_str",
9274 "Import routes from another VRF\n"
9275 "Vrf routes being filtered\n"
9276 "Specify route map\n"
9277 "name of route-map\n")
9279 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9280 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9282 struct bgp
*bgp_default
;
9284 afi
= vpn_policy_getafi(vty
, bgp
, true);
9286 return CMD_WARNING_CONFIG_FAILED
;
9288 bgp_default
= bgp_get_default();
9293 /* Auto-create assuming the same AS */
9294 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9295 BGP_INSTANCE_TYPE_DEFAULT
);
9299 "VRF default is not configured as a bgp instance\n");
9304 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9306 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9307 XFREE(MTYPE_ROUTE_MAP_NAME
,
9308 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9309 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9310 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9311 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9312 route_map_lookup_warn_noexist(vty
, rmap_str
);
9313 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9316 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9317 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9319 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9324 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9325 "no import vrf route-map [RMAP$rmap_str]",
9327 "Import routes from another VRF\n"
9328 "Vrf routes being filtered\n"
9329 "Specify route map\n"
9330 "name of route-map\n")
9332 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9333 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9336 afi
= vpn_policy_getafi(vty
, bgp
, true);
9338 return CMD_WARNING_CONFIG_FAILED
;
9340 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9342 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9343 XFREE(MTYPE_ROUTE_MAP_NAME
,
9344 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9345 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9346 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9348 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9349 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9350 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9352 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9357 DEFPY_YANG(bgp_imexport_vrf
,
9358 bgp_imexport_vrf_cmd
,
9359 "[no] import vrf VIEWVRFNAME$import_name",
9361 "Import routes from another VRF\n"
9362 "VRF to import from\n"
9363 "The name of the VRF\n")
9365 char base_xpath
[XPATH_MAXLEN
];
9370 if (import_name
== NULL
) {
9371 vty_out(vty
, "%% Missing import name\n");
9375 if (strcmp(import_name
, "route-map") == 0) {
9376 vty_out(vty
, "%% Must include route-map name\n");
9380 afi
= bgp_node_afi(vty
);
9381 safi
= bgp_node_safi(vty
);
9384 base_xpath
, sizeof(base_xpath
),
9385 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vrf-list[vrf='%s']",
9386 yang_afi_safi_value2identity(afi
, safi
),
9387 bgp_afi_safi_get_container_str(afi
, safi
), import_name
);
9389 if (argv_find(argv
, argc
, "no", &idx
))
9390 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
9392 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
9394 return nb_cli_apply_changes(vty
, base_xpath
);
9397 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vrfs(
9398 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9400 vty_out(vty
, " import vrf %s\n",
9401 yang_dnode_get_string(dnode
, "./vrf"));
9404 /* This command is valid only in a bgp vrf instance or the default instance */
9405 DEFPY_YANG (bgp_imexport_vpn
,
9406 bgp_imexport_vpn_cmd
,
9407 "[no] <import|export>$direction_str vpn",
9409 "Import routes to this address-family\n"
9410 "Export routes from this address-family\n"
9411 "to/from default instance VPN RIB\n")
9413 char base_xpath
[XPATH_MAXLEN
];
9418 afi
= bgp_node_afi(vty
);
9419 safi
= bgp_node_safi(vty
);
9421 if (!strcmp(direction_str
, "import")) {
9423 base_xpath
, sizeof(base_xpath
),
9424 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vpn",
9425 yang_afi_safi_value2identity(afi
, safi
),
9426 bgp_afi_safi_get_container_str(afi
, safi
));
9427 } else if (!strcmp(direction_str
, "export")) {
9429 base_xpath
, sizeof(base_xpath
),
9430 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/export-vpn",
9431 yang_afi_safi_value2identity(afi
, safi
),
9432 bgp_afi_safi_get_container_str(afi
, safi
));
9434 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9435 return CMD_WARNING_CONFIG_FAILED
;
9438 if (argv_find(argv
, argc
, "no", &idx
))
9439 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
9441 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, "true");
9443 return nb_cli_apply_changes(vty
, base_xpath
);
9446 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vpn(
9447 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9449 if (yang_dnode_get_bool(dnode
, NULL
))
9450 vty_out(vty
, " import vpn\n");
9453 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_export_vpn(
9454 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9456 if (yang_dnode_get_bool(dnode
, NULL
))
9457 vty_out(vty
, " export vpn\n");
9460 DEFPY (af_routetarget_import
,
9461 af_routetarget_import_cmd
,
9462 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9464 "Specify route target list\n"
9465 "Specify route target list\n"
9466 "Specify route target list\n"
9467 "Specify route target list\n"
9468 "Flow-spec redirect type route target\n"
9469 "Import routes to this address-family\n"
9470 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9472 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9474 struct ecommunity
*ecom
= NULL
;
9476 int idx
= 0, idx_unused
= 0;
9480 if (argv_find(argv
, argc
, "no", &idx
))
9483 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9484 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9487 afi
= vpn_policy_getafi(vty
, bgp
, false);
9489 return CMD_WARNING_CONFIG_FAILED
;
9491 if (rt6
&& afi
!= AFI_IP6
)
9492 return CMD_WARNING_CONFIG_FAILED
;
9495 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9496 vty_out(vty
, "%% Missing RTLIST\n");
9497 return CMD_WARNING_CONFIG_FAILED
;
9499 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9500 if (ret
!= CMD_SUCCESS
)
9505 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9506 ecommunity_free(&bgp
->vpn_policy
[afi
]
9507 .import_redirect_rtlist
);
9508 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9509 ecommunity_dup(ecom
);
9511 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9512 ecommunity_free(&bgp
->vpn_policy
[afi
]
9513 .import_redirect_rtlist
);
9514 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9518 ecommunity_free(&ecom
);
9523 void cli_show_bgp_global_afi_safi_header(struct vty
*vty
,
9524 struct lyd_node
*dnode
,
9527 const char *af_name
;
9531 af_name
= yang_dnode_get_string(dnode
, "./afi-safi-name");
9532 yang_afi_safi_identity2value(af_name
, &afi
, &safi
);
9534 vty_out(vty
, " !\n address-family ");
9535 if (afi
== AFI_IP
) {
9536 if (safi
== SAFI_UNICAST
)
9537 vty_out(vty
, "ipv4 unicast");
9538 else if (safi
== SAFI_LABELED_UNICAST
)
9539 vty_out(vty
, "ipv4 labeled-unicast");
9540 else if (safi
== SAFI_MULTICAST
)
9541 vty_out(vty
, "ipv4 multicast");
9542 else if (safi
== SAFI_MPLS_VPN
)
9543 vty_out(vty
, "ipv4 vpn");
9544 else if (safi
== SAFI_ENCAP
)
9545 vty_out(vty
, "ipv4 encap");
9546 else if (safi
== SAFI_FLOWSPEC
)
9547 vty_out(vty
, "ipv4 flowspec");
9548 } else if (afi
== AFI_IP6
) {
9549 if (safi
== SAFI_UNICAST
)
9550 vty_out(vty
, "ipv6 unicast");
9551 else if (safi
== SAFI_LABELED_UNICAST
)
9552 vty_out(vty
, "ipv6 labeled-unicast");
9553 else if (safi
== SAFI_MULTICAST
)
9554 vty_out(vty
, "ipv6 multicast");
9555 else if (safi
== SAFI_MPLS_VPN
)
9556 vty_out(vty
, "ipv6 vpn");
9557 else if (safi
== SAFI_ENCAP
)
9558 vty_out(vty
, "ipv6 encap");
9559 else if (safi
== SAFI_FLOWSPEC
)
9560 vty_out(vty
, "ipv6 flowspec");
9561 } else if (afi
== AFI_L2VPN
) {
9562 if (safi
== SAFI_EVPN
)
9563 vty_out(vty
, "l2vpn evpn");
9568 DEFUN_NOSH (address_family_ipv4_safi
,
9569 address_family_ipv4_safi_cmd
,
9570 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9571 "Enter Address Family command mode\n"
9573 BGP_SAFI_WITH_LABEL_HELP_STR
)
9576 safi_t safi
= SAFI_UNICAST
;
9577 const struct lyd_node
*vrf_dnode
, *bgp_glb_dnode
;
9578 const char *vrf_name
= NULL
;
9581 safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9583 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
9585 vrf_dnode
= yang_dnode_get_parent(bgp_glb_dnode
,
9586 "control-plane-protocol");
9587 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
9589 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
)
9590 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9591 && safi
!= SAFI_EVPN
) {
9593 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9594 return CMD_WARNING_CONFIG_FAILED
;
9597 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9602 DEFUN_NOSH (address_family_ipv6_safi
,
9603 address_family_ipv6_safi_cmd
,
9604 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9605 "Enter Address Family command mode\n"
9607 BGP_SAFI_WITH_LABEL_HELP_STR
)
9609 safi_t safi
= SAFI_UNICAST
;
9610 const struct lyd_node
*vrf_dnode
, *bgp_glb_dnode
;
9611 const char *vrf_name
= NULL
;
9614 safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9615 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
9617 vrf_dnode
= yang_dnode_get_parent(bgp_glb_dnode
,
9618 "control-plane-protocol");
9619 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
9621 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
)
9622 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9623 && safi
!= SAFI_EVPN
) {
9625 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9626 return CMD_WARNING_CONFIG_FAILED
;
9629 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9634 #ifdef KEEP_OLD_VPN_COMMANDS
9635 DEFUN_NOSH (address_family_vpnv4
,
9636 address_family_vpnv4_cmd
,
9637 "address-family vpnv4 [unicast]",
9638 "Enter Address Family command mode\n"
9640 "Address Family modifier\n")
9642 vty
->node
= BGP_VPNV4_NODE
;
9646 DEFUN_NOSH (address_family_vpnv6
,
9647 address_family_vpnv6_cmd
,
9648 "address-family vpnv6 [unicast]",
9649 "Enter Address Family command mode\n"
9651 "Address Family modifier\n")
9653 vty
->node
= BGP_VPNV6_NODE
;
9656 #endif /* KEEP_OLD_VPN_COMMANDS */
9658 DEFUN_NOSH (address_family_evpn
,
9659 address_family_evpn_cmd
,
9660 "address-family l2vpn evpn",
9661 "Enter Address Family command mode\n"
9663 "Address Family modifier\n")
9665 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9666 vty
->node
= BGP_EVPN_NODE
;
9670 DEFUN_NOSH (exit_address_family
,
9671 exit_address_family_cmd
,
9672 "exit-address-family",
9673 "Exit from Address Family configuration mode\n")
9675 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9676 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9677 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9678 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9679 || vty
->node
== BGP_EVPN_NODE
9680 || vty
->node
== BGP_FLOWSPECV4_NODE
9681 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9682 vty
->node
= BGP_NODE
;
9686 void cli_show_bgp_global_afi_safi_header_end(struct vty
*vty
,
9687 struct lyd_node
*dnode
9688 __attribute__((__unused__
)))
9690 vty_out(vty
, " exit-address-family\n");
9693 /* Recalculate bestpath and re-advertise a prefix */
9694 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9695 const char *ip_str
, afi_t afi
, safi_t safi
,
9696 struct prefix_rd
*prd
)
9699 struct prefix match
;
9700 struct bgp_dest
*dest
;
9701 struct bgp_dest
*rm
;
9703 struct bgp_table
*table
;
9704 struct bgp_table
*rib
;
9706 /* BGP structure lookup. */
9708 bgp
= bgp_lookup_by_name(view_name
);
9710 vty_out(vty
, "%% Can't find BGP instance %s\n",
9715 bgp
= bgp_get_default();
9717 vty_out(vty
, "%% No BGP process is configured\n");
9722 /* Check IP address argument. */
9723 ret
= str2prefix(ip_str
, &match
);
9725 vty_out(vty
, "%% address is malformed\n");
9729 match
.family
= afi2family(afi
);
9730 rib
= bgp
->rib
[afi
][safi
];
9732 if (safi
== SAFI_MPLS_VPN
) {
9733 for (dest
= bgp_table_top(rib
); dest
;
9734 dest
= bgp_route_next(dest
)) {
9735 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9737 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9740 table
= bgp_dest_get_bgp_table_info(dest
);
9744 if ((rm
= bgp_node_match(table
, &match
)) != NULL
) {
9745 const struct prefix
*rm_p
=
9746 bgp_dest_get_prefix(rm
);
9748 if (rm_p
->prefixlen
== match
.prefixlen
) {
9750 BGP_NODE_USER_CLEAR
);
9751 bgp_process(bgp
, rm
, afi
, safi
);
9753 bgp_dest_unlock_node(rm
);
9757 if ((dest
= bgp_node_match(rib
, &match
)) != NULL
) {
9758 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9760 if (dest_p
->prefixlen
== match
.prefixlen
) {
9761 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9762 bgp_process(bgp
, dest
, afi
, safi
);
9764 bgp_dest_unlock_node(dest
);
9771 /* one clear bgp command to rule them all */
9772 DEFUN (clear_ip_bgp_all
,
9773 clear_ip_bgp_all_cmd
,
9774 "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>]",
9778 BGP_INSTANCE_HELP_STR
9781 BGP_SAFI_WITH_LABEL_HELP_STR
9782 "Address Family modifier\n"
9784 "BGP IPv4 neighbor to clear\n"
9785 "BGP IPv6 neighbor to clear\n"
9786 "BGP neighbor on interface to clear\n"
9787 "Clear peers with the AS number\n"
9788 "Clear all external peers\n"
9789 "Clear all members of peer-group\n"
9790 "BGP peer-group name\n"
9795 "Push out prefix-list ORF and do inbound soft reconfig\n"
9800 afi_t afi
= AFI_UNSPEC
;
9801 safi_t safi
= SAFI_UNSPEC
;
9802 enum clear_sort clr_sort
= clear_peer
;
9803 enum bgp_clear_type clr_type
;
9804 char *clr_arg
= NULL
;
9807 char errmsg
[BUFSIZ
] = {'\0'};
9810 /* clear [ip] bgp */
9811 if (argv_find(argv
, argc
, "ip", &idx
))
9814 /* [<vrf> VIEWVRFNAME] */
9815 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9816 vrf
= argv
[idx
+ 1]->arg
;
9818 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9820 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9821 /* [<view> VIEWVRFNAME] */
9822 vrf
= argv
[idx
+ 1]->arg
;
9825 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9826 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
9827 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
9829 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
9830 if (argv_find(argv
, argc
, "*", &idx
)) {
9831 clr_sort
= clear_all
;
9832 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
9833 clr_sort
= clear_peer
;
9834 clr_arg
= argv
[idx
]->arg
;
9835 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
9836 clr_sort
= clear_peer
;
9837 clr_arg
= argv
[idx
]->arg
;
9838 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
9839 clr_sort
= clear_group
;
9841 clr_arg
= argv
[idx
]->arg
;
9842 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
9843 clr_sort
= clear_peer
;
9844 clr_arg
= argv
[idx
]->arg
;
9845 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
9846 clr_sort
= clear_peer
;
9847 clr_arg
= argv
[idx
]->arg
;
9848 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
9849 clr_sort
= clear_as
;
9850 clr_arg
= argv
[idx
]->arg
;
9851 } else if (argv_find(argv
, argc
, "external", &idx
)) {
9852 clr_sort
= clear_external
;
9855 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
9856 if (argv_find(argv
, argc
, "soft", &idx
)) {
9857 if (argv_find(argv
, argc
, "in", &idx
)
9858 || argv_find(argv
, argc
, "out", &idx
))
9859 clr_type
= strmatch(argv
[idx
]->text
, "in")
9861 : BGP_CLEAR_SOFT_OUT
;
9863 clr_type
= BGP_CLEAR_SOFT_BOTH
;
9864 } else if (argv_find(argv
, argc
, "in", &idx
)) {
9865 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
9866 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
9867 : BGP_CLEAR_SOFT_IN
;
9868 } else if (argv_find(argv
, argc
, "out", &idx
)) {
9869 clr_type
= BGP_CLEAR_SOFT_OUT
;
9871 clr_type
= BGP_CLEAR_SOFT_NONE
;
9873 ret
= bgp_clear_vty(vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
, errmsg
,
9876 vty_out(vty
, "Error description: %s\n", errmsg
);
9881 DEFUN (clear_ip_bgp_prefix
,
9882 clear_ip_bgp_prefix_cmd
,
9883 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
9887 BGP_INSTANCE_HELP_STR
9888 "Clear bestpath and re-advertise\n"
9892 char *prefix
= NULL
;
9896 /* [<view|vrf> VIEWVRFNAME] */
9897 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9898 vrf
= argv
[idx
+ 1]->arg
;
9900 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9902 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9903 /* [<view> VIEWVRFNAME] */
9904 vrf
= argv
[idx
+ 1]->arg
;
9908 prefix
= argv
[argc
- 1]->arg
;
9910 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
9913 DEFUN (clear_bgp_ipv6_safi_prefix
,
9914 clear_bgp_ipv6_safi_prefix_cmd
,
9915 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9921 "Clear bestpath and re-advertise\n"
9925 int idx_ipv6_prefix
= 0;
9926 safi_t safi
= SAFI_UNICAST
;
9927 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9928 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9930 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9931 return bgp_clear_prefix(
9932 vty
, NULL
, prefix
, AFI_IP6
,
9936 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
9937 clear_bgp_instance_ipv6_safi_prefix_cmd
,
9938 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9942 BGP_INSTANCE_HELP_STR
9945 "Clear bestpath and re-advertise\n"
9949 int idx_vrfview
= 0;
9950 int idx_ipv6_prefix
= 0;
9951 safi_t safi
= SAFI_UNICAST
;
9952 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9953 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9954 char *vrfview
= NULL
;
9956 /* [<view|vrf> VIEWVRFNAME] */
9957 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
9958 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9959 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
9961 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
9962 /* [<view> VIEWVRFNAME] */
9963 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9965 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9967 return bgp_clear_prefix(
9968 vty
, vrfview
, prefix
,
9969 AFI_IP6
, safi
, NULL
);
9972 DEFUN (show_bgp_views
,
9974 "show [ip] bgp views",
9978 "Show the defined BGP views\n")
9980 struct list
*inst
= bm
->bgp
;
9981 struct listnode
*node
;
9984 vty_out(vty
, "Defined BGP views:\n");
9985 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
9987 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
9989 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
9996 DEFUN (show_bgp_vrfs
,
9998 "show [ip] bgp vrfs [json]",
10005 char buf
[ETHER_ADDR_STRLEN
];
10006 struct list
*inst
= bm
->bgp
;
10007 struct listnode
*node
;
10009 bool uj
= use_json(argc
, argv
);
10010 json_object
*json
= NULL
;
10011 json_object
*json_vrfs
= NULL
;
10015 json
= json_object_new_object();
10016 json_vrfs
= json_object_new_object();
10019 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10020 const char *name
, *type
;
10022 struct listnode
*node2
, *nnode2
;
10023 int peers_cfg
, peers_estb
;
10024 json_object
*json_vrf
= NULL
;
10027 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10031 if (!uj
&& count
== 1) {
10033 "%4s %-5s %-16s %9s %10s %-37s\n",
10034 "Type", "Id", "routerId", "#PeersCfg",
10035 "#PeersEstb", "Name");
10036 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10037 "L3-VNI", "RouterMAC", "Interface");
10040 peers_cfg
= peers_estb
= 0;
10042 json_vrf
= json_object_new_object();
10045 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
10046 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10049 if (peer
->status
== Established
)
10053 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10054 name
= VRF_DEFAULT_NAME
;
10063 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10065 : (int64_t)bgp
->vrf_id
;
10066 char buf
[BUFSIZ
] = {0};
10068 json_object_string_add(json_vrf
, "type", type
);
10069 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
10070 json_object_string_add(json_vrf
, "routerId",
10072 &bgp
->router_id
, buf
,
10074 json_object_int_add(json_vrf
, "numConfiguredPeers",
10076 json_object_int_add(json_vrf
, "numEstablishedPeers",
10079 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
10080 json_object_string_add(
10082 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
10083 json_object_string_add(json_vrf
, "interface",
10084 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10086 json_object_object_add(json_vrfs
, name
, json_vrf
);
10088 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10090 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10091 : (int)bgp
->vrf_id
,
10092 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10093 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
10095 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
10096 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10102 json_object_object_add(json
, "vrfs", json_vrfs
);
10104 json_object_int_add(json
, "totalVrfs", count
);
10106 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10107 json
, JSON_C_TO_STRING_PRETTY
));
10108 json_object_free(json
);
10112 "\nTotal number of VRFs (including default): %d\n",
10116 return CMD_SUCCESS
;
10119 DEFUN (show_bgp_mac_hash
,
10120 show_bgp_mac_hash_cmd
,
10121 "show bgp mac hash",
10125 "Mac Address database\n")
10127 bgp_mac_dump_table(vty
);
10129 return CMD_SUCCESS
;
10132 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10134 struct vty
*vty
= (struct vty
*)args
;
10135 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10137 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10140 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10142 vty_out(vty
, "self nexthop database:\n");
10143 bgp_nexthop_show_address_hash(vty
, bgp
);
10145 vty_out(vty
, "Tunnel-ip database:\n");
10146 hash_iterate(bgp
->tip_hash
,
10147 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10151 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10152 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10153 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10154 "martian next-hops\n"
10155 "martian next-hop database\n")
10157 struct bgp
*bgp
= NULL
;
10161 /* [<vrf> VIEWVRFNAME] */
10162 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10163 name
= argv
[idx
+ 1]->arg
;
10164 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10166 } else if (argv_find(argv
, argc
, "view", &idx
))
10167 /* [<view> VIEWVRFNAME] */
10168 name
= argv
[idx
+ 1]->arg
;
10170 bgp
= bgp_lookup_by_name(name
);
10172 bgp
= bgp_get_default();
10175 vty_out(vty
, "%% No BGP process is configured\n");
10176 return CMD_WARNING
;
10178 bgp_show_martian_nexthops(vty
, bgp
);
10180 return CMD_SUCCESS
;
10183 DEFUN (show_bgp_memory
,
10184 show_bgp_memory_cmd
,
10185 "show [ip] bgp memory",
10189 "Global BGP memory statistics\n")
10191 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10192 unsigned long count
;
10194 /* RIB related usage stats */
10195 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10196 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10197 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10198 count
* sizeof(struct bgp_dest
)));
10200 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10201 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10202 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10203 count
* sizeof(struct bgp_path_info
)));
10204 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10205 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10208 memstrbuf
, sizeof(memstrbuf
),
10209 count
* sizeof(struct bgp_path_info_extra
)));
10211 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10212 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10213 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10214 count
* sizeof(struct bgp_static
)));
10216 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10217 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10218 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10219 count
* sizeof(struct bpacket
)));
10222 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10223 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10224 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10225 count
* sizeof(struct bgp_adj_in
)));
10226 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10227 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10228 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10229 count
* sizeof(struct bgp_adj_out
)));
10231 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10232 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10234 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10235 count
* sizeof(struct bgp_nexthop_cache
)));
10237 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10238 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10240 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10241 count
* sizeof(struct bgp_damp_info
)));
10244 count
= attr_count();
10245 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10246 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10247 count
* sizeof(struct attr
)));
10249 if ((count
= attr_unknown_count()))
10250 vty_out(vty
, "%ld unknown attributes\n", count
);
10252 /* AS_PATH attributes */
10253 count
= aspath_count();
10254 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10255 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10256 count
* sizeof(struct aspath
)));
10258 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10259 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10260 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10261 count
* sizeof(struct assegment
)));
10263 /* Other attributes */
10264 if ((count
= community_count()))
10265 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10266 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10267 count
* sizeof(struct community
)));
10268 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10269 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10270 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10271 count
* sizeof(struct ecommunity
)));
10272 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10274 "%ld BGP large-community entries, using %s of memory\n",
10275 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10276 count
* sizeof(struct lcommunity
)));
10278 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10279 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10280 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10281 count
* sizeof(struct cluster_list
)));
10283 /* Peer related usage */
10284 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10285 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10286 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10287 count
* sizeof(struct peer
)));
10289 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10290 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10291 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10292 count
* sizeof(struct peer_group
)));
10295 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10296 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10297 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10298 count
* sizeof(regex_t
)));
10299 return CMD_SUCCESS
;
10302 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10304 json_object
*bestpath
= json_object_new_object();
10306 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10307 json_object_string_add(bestpath
, "asPath", "ignore");
10309 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10310 json_object_string_add(bestpath
, "asPath", "confed");
10312 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10313 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10314 json_object_string_add(bestpath
, "multiPathRelax",
10317 json_object_string_add(bestpath
, "multiPathRelax",
10320 json_object_string_add(bestpath
, "multiPathRelax", "false");
10322 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10323 json_object_string_add(bestpath
, "compareRouterId", "true");
10324 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10325 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10326 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10327 json_object_string_add(bestpath
, "med", "confed");
10328 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10329 json_object_string_add(bestpath
, "med",
10330 "missing-as-worst");
10332 json_object_string_add(bestpath
, "med", "true");
10335 json_object_object_add(json
, "bestPath", bestpath
);
10338 /* Print the error code/subcode for why the peer is down */
10339 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10340 json_object
*json_peer
, bool use_json
)
10342 const char *code_str
;
10343 const char *subcode_str
;
10346 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10347 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10348 char errorcodesubcode_hexstr
[5];
10349 char errorcodesubcode_str
[256];
10351 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10352 subcode_str
= bgp_notify_subcode_str(
10354 peer
->notify
.subcode
);
10356 snprintf(errorcodesubcode_hexstr
,
10357 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10358 peer
->notify
.code
, peer
->notify
.subcode
);
10359 json_object_string_add(json_peer
,
10360 "lastErrorCodeSubcode",
10361 errorcodesubcode_hexstr
);
10362 snprintf(errorcodesubcode_str
, 255, "%s%s",
10363 code_str
, subcode_str
);
10364 json_object_string_add(json_peer
,
10365 "lastNotificationReason",
10366 errorcodesubcode_str
);
10367 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10368 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10369 && (peer
->notify
.subcode
10370 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10371 || peer
->notify
.subcode
10372 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10373 && peer
->notify
.length
) {
10375 const char *msg_str
;
10377 msg_str
= bgp_notify_admin_message(
10378 msgbuf
, sizeof(msgbuf
),
10379 (uint8_t *)peer
->notify
.data
,
10380 peer
->notify
.length
);
10382 json_object_string_add(
10384 "lastShutdownDescription",
10389 json_object_string_add(json_peer
, "lastResetDueTo",
10390 peer_down_str
[(int)peer
->last_reset
]);
10391 json_object_int_add(json_peer
, "lastResetCode",
10394 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10395 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10396 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10398 bgp_notify_subcode_str(peer
->notify
.code
,
10399 peer
->notify
.subcode
);
10400 vty_out(vty
, " Notification %s (%s%s)\n",
10401 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10404 code_str
, subcode_str
);
10406 vty_out(vty
, " %s\n",
10407 peer_down_str
[(int)peer
->last_reset
]);
10412 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10415 return ((peer
->status
!= Established
) ||
10416 !peer
->afc_recv
[afi
][safi
]);
10419 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10420 struct peer
*peer
, json_object
*json_peer
,
10421 int max_neighbor_width
, bool use_json
)
10423 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10427 if (peer_dynamic_neighbor(peer
))
10428 json_object_boolean_true_add(json_peer
,
10430 if (peer
->hostname
)
10431 json_object_string_add(json_peer
, "hostname",
10434 if (peer
->domainname
)
10435 json_object_string_add(json_peer
, "domainname",
10437 json_object_int_add(json_peer
, "connectionsEstablished",
10438 peer
->established
);
10439 json_object_int_add(json_peer
, "connectionsDropped",
10441 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10442 use_json
, json_peer
);
10443 if (peer
->status
== Established
)
10444 json_object_string_add(json_peer
, "lastResetDueTo",
10445 "AFI/SAFI Not Negotiated");
10447 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10450 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10452 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10453 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10454 peer
->hostname
, peer
->host
);
10456 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10458 /* pad the neighbor column with spaces */
10459 if (len
< max_neighbor_width
)
10460 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10462 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10464 peer_uptime(peer
->uptime
, timebuf
,
10465 BGP_UPTIME_LEN
, 0, NULL
));
10466 if (peer
->status
== Established
)
10467 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10469 bgp_show_peer_reset(vty
, peer
, NULL
,
10475 /* Show BGP peer's summary information. */
10476 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10477 bool show_failed
, bool show_established
,
10481 struct listnode
*node
, *nnode
;
10482 unsigned int count
= 0, dn_count
= 0;
10483 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10484 char neighbor_buf
[VTY_BUFSIZ
];
10485 int neighbor_col_default_width
= 16;
10486 int len
, failed_count
= 0;
10487 int max_neighbor_width
= 0;
10489 json_object
*json
= NULL
;
10490 json_object
*json_peer
= NULL
;
10491 json_object
*json_peers
= NULL
;
10492 struct peer_af
*paf
;
10493 struct bgp_filter
*filter
;
10495 /* labeled-unicast routes are installed in the unicast table so in order
10497 * display the correct PfxRcd value we must look at SAFI_UNICAST
10500 if (safi
== SAFI_LABELED_UNICAST
)
10501 pfx_rcd_safi
= SAFI_UNICAST
;
10503 pfx_rcd_safi
= safi
;
10506 json
= json_object_new_object();
10507 json_peers
= json_object_new_object();
10508 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10509 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10512 if (peer
->afc
[afi
][safi
]) {
10513 /* See if we have at least a single failed peer */
10514 if (bgp_has_peer_failed(peer
, afi
, safi
))
10518 if (peer_dynamic_neighbor(peer
))
10523 /* Loop over all neighbors that will be displayed to determine
10525 * characters are needed for the Neighbor column
10527 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10528 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10531 if (peer
->afc
[afi
][safi
]) {
10532 memset(dn_flag
, '\0', sizeof(dn_flag
));
10533 if (peer_dynamic_neighbor(peer
))
10537 && CHECK_FLAG(bgp
->flags
,
10538 BGP_FLAG_SHOW_HOSTNAME
))
10539 snprintf(neighbor_buf
,
10540 sizeof(neighbor_buf
),
10541 "%s%s(%s) ", dn_flag
,
10542 peer
->hostname
, peer
->host
);
10544 snprintf(neighbor_buf
,
10545 sizeof(neighbor_buf
), "%s%s ",
10546 dn_flag
, peer
->host
);
10548 len
= strlen(neighbor_buf
);
10550 if (len
> max_neighbor_width
)
10551 max_neighbor_width
= len
;
10553 /* See if we have at least a single failed peer */
10554 if (bgp_has_peer_failed(peer
, afi
, safi
))
10560 /* Originally we displayed the Neighbor column as 16
10561 * characters wide so make that the default
10563 if (max_neighbor_width
< neighbor_col_default_width
)
10564 max_neighbor_width
= neighbor_col_default_width
;
10567 if (show_failed
&& !failed_count
) {
10569 json_object_int_add(json
, "failedPeersCount", 0);
10570 json_object_int_add(json
, "dynamicPeers", dn_count
);
10571 json_object_int_add(json
, "totalPeers", count
);
10573 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10574 json
, JSON_C_TO_STRING_PRETTY
));
10575 json_object_free(json
);
10577 vty_out(vty
, "%% No failed BGP neighbors found\n");
10578 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
10580 return CMD_SUCCESS
;
10583 count
= 0; /* Reset the value as its used again */
10584 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10585 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10588 if (!peer
->afc
[afi
][safi
])
10592 unsigned long ents
;
10593 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10596 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10598 : (int64_t)bgp
->vrf_id
;
10600 /* Usage summary and header */
10602 char buf
[BUFSIZ
] = {0};
10604 json_object_string_add(
10606 inet_ntop(AF_INET
, &bgp
->router_id
, buf
,
10608 json_object_int_add(json
, "as", bgp
->as
);
10609 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10610 json_object_string_add(
10613 == BGP_INSTANCE_TYPE_DEFAULT
)
10618 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10619 &bgp
->router_id
, bgp
->as
,
10620 bgp
->vrf_id
== VRF_UNKNOWN
10622 : (int)bgp
->vrf_id
);
10623 vty_out(vty
, "\n");
10626 if (bgp_update_delay_configured(bgp
)) {
10628 json_object_int_add(
10629 json
, "updateDelayLimit",
10630 bgp
->v_update_delay
);
10632 if (bgp
->v_update_delay
10633 != bgp
->v_establish_wait
)
10634 json_object_int_add(
10636 "updateDelayEstablishWait",
10637 bgp
->v_establish_wait
);
10639 if (bgp_update_delay_active(bgp
)) {
10640 json_object_string_add(
10642 "updateDelayFirstNeighbor",
10643 bgp
->update_delay_begin_time
);
10644 json_object_boolean_true_add(
10646 "updateDelayInProgress");
10648 if (bgp
->update_delay_over
) {
10649 json_object_string_add(
10651 "updateDelayFirstNeighbor",
10652 bgp
->update_delay_begin_time
);
10653 json_object_string_add(
10655 "updateDelayBestpathResumed",
10656 bgp
->update_delay_end_time
);
10657 json_object_string_add(
10659 "updateDelayZebraUpdateResume",
10660 bgp
->update_delay_zebra_resume_time
);
10661 json_object_string_add(
10663 "updateDelayPeerUpdateResume",
10664 bgp
->update_delay_peers_resume_time
);
10669 "Read-only mode update-delay limit: %d seconds\n",
10670 bgp
->v_update_delay
);
10671 if (bgp
->v_update_delay
10672 != bgp
->v_establish_wait
)
10674 " Establish wait: %d seconds\n",
10675 bgp
->v_establish_wait
);
10677 if (bgp_update_delay_active(bgp
)) {
10679 " First neighbor established: %s\n",
10680 bgp
->update_delay_begin_time
);
10682 " Delay in progress\n");
10684 if (bgp
->update_delay_over
) {
10686 " First neighbor established: %s\n",
10687 bgp
->update_delay_begin_time
);
10689 " Best-paths resumed: %s\n",
10690 bgp
->update_delay_end_time
);
10692 " zebra update resumed: %s\n",
10693 bgp
->update_delay_zebra_resume_time
);
10695 " peers update resumed: %s\n",
10696 bgp
->update_delay_peers_resume_time
);
10703 if (bgp_maxmed_onstartup_configured(bgp
)
10704 && bgp
->maxmed_active
)
10705 json_object_boolean_true_add(
10706 json
, "maxMedOnStartup");
10707 if (bgp
->v_maxmed_admin
)
10708 json_object_boolean_true_add(
10709 json
, "maxMedAdministrative");
10711 json_object_int_add(
10712 json
, "tableVersion",
10713 bgp_table_version(bgp
->rib
[afi
][safi
]));
10715 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10716 json_object_int_add(json
, "ribCount", ents
);
10717 json_object_int_add(
10719 ents
* sizeof(struct bgp_dest
));
10721 ents
= bgp
->af_peer_count
[afi
][safi
];
10722 json_object_int_add(json
, "peerCount", ents
);
10723 json_object_int_add(json
, "peerMemory",
10724 ents
* sizeof(struct peer
));
10726 if ((ents
= listcount(bgp
->group
))) {
10727 json_object_int_add(
10728 json
, "peerGroupCount", ents
);
10729 json_object_int_add(
10730 json
, "peerGroupMemory",
10731 ents
* sizeof(struct
10735 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10736 BGP_CONFIG_DAMPENING
))
10737 json_object_boolean_true_add(
10738 json
, "dampeningEnabled");
10740 if (bgp_maxmed_onstartup_configured(bgp
)
10741 && bgp
->maxmed_active
)
10743 "Max-med on-startup active\n");
10744 if (bgp
->v_maxmed_admin
)
10746 "Max-med administrative active\n");
10748 vty_out(vty
, "BGP table version %" PRIu64
"\n",
10749 bgp_table_version(bgp
->rib
[afi
][safi
]));
10751 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10753 "RIB entries %ld, using %s of memory\n",
10756 memstrbuf
, sizeof(memstrbuf
),
10761 /* Peer related usage */
10762 ents
= bgp
->af_peer_count
[afi
][safi
];
10763 vty_out(vty
, "Peers %ld, using %s of memory\n",
10766 memstrbuf
, sizeof(memstrbuf
),
10767 ents
* sizeof(struct peer
)));
10769 if ((ents
= listcount(bgp
->group
)))
10771 "Peer groups %ld, using %s of memory\n",
10776 ents
* sizeof(struct
10779 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10780 BGP_CONFIG_DAMPENING
))
10781 vty_out(vty
, "Dampening enabled.\n");
10782 vty_out(vty
, "\n");
10784 /* Subtract 8 here because 'Neighbor' is
10786 vty_out(vty
, "Neighbor");
10787 vty_out(vty
, "%*s", max_neighbor_width
- 8,
10790 vty_out(vty
, "EstdCnt DropCnt ResetTime Reason\n");
10793 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc\n");
10797 paf
= peer_af_find(peer
, afi
, safi
);
10798 filter
= &peer
->filter
[afi
][safi
];
10801 /* Works for both failed & successful cases */
10802 if (peer_dynamic_neighbor(peer
))
10809 bgp_has_peer_failed(peer
, afi
, safi
)) {
10810 json_peer
= json_object_new_object();
10811 bgp_show_failed_summary(vty
, bgp
, peer
,
10812 json_peer
, 0, use_json
);
10813 } else if (!show_failed
) {
10814 if (show_established
10815 && bgp_has_peer_failed(peer
, afi
, safi
))
10818 json_peer
= json_object_new_object();
10819 if (peer_dynamic_neighbor(peer
)) {
10820 json_object_boolean_true_add(json_peer
,
10824 if (peer
->hostname
)
10825 json_object_string_add(json_peer
, "hostname",
10828 if (peer
->domainname
)
10829 json_object_string_add(json_peer
, "domainname",
10832 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
10833 json_object_int_add(json_peer
, "version", 4);
10834 json_object_int_add(json_peer
, "msgRcvd",
10835 PEER_TOTAL_RX(peer
));
10836 json_object_int_add(json_peer
, "msgSent",
10837 PEER_TOTAL_TX(peer
));
10839 atomic_size_t outq_count
, inq_count
;
10840 outq_count
= atomic_load_explicit(
10841 &peer
->obuf
->count
,
10842 memory_order_relaxed
);
10843 inq_count
= atomic_load_explicit(
10844 &peer
->ibuf
->count
,
10845 memory_order_relaxed
);
10847 json_object_int_add(json_peer
, "tableVersion",
10848 peer
->version
[afi
][safi
]);
10849 json_object_int_add(json_peer
, "outq",
10851 json_object_int_add(json_peer
, "inq",
10853 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10854 use_json
, json_peer
);
10856 json_object_int_add(json_peer
, "pfxRcd",
10857 peer
->pcount
[afi
][pfx_rcd_safi
]);
10859 if (paf
&& PAF_SUBGRP(paf
))
10860 json_object_int_add(
10861 json_peer
, "pfxSnt",
10862 (PAF_SUBGRP(paf
))->scount
);
10864 json_object_int_add(json_peer
, "pfxSnt",
10867 /* BGP FSM state */
10868 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10869 || CHECK_FLAG(peer
->bgp
->flags
,
10870 BGP_FLAG_SHUTDOWN
))
10871 json_object_string_add(json_peer
,
10874 else if (peer
->afc_recv
[afi
][safi
])
10875 json_object_string_add(
10876 json_peer
, "state",
10877 lookup_msg(bgp_status_msg
,
10878 peer
->status
, NULL
));
10879 else if (CHECK_FLAG(
10881 PEER_STATUS_PREFIX_OVERFLOW
))
10882 json_object_string_add(json_peer
,
10886 json_object_string_add(
10887 json_peer
, "state",
10888 lookup_msg(bgp_status_msg
,
10889 peer
->status
, NULL
));
10891 /* BGP peer state */
10892 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10893 || CHECK_FLAG(peer
->bgp
->flags
,
10894 BGP_FLAG_SHUTDOWN
))
10895 json_object_string_add(json_peer
,
10898 else if (CHECK_FLAG(
10900 PEER_STATUS_PREFIX_OVERFLOW
))
10901 json_object_string_add(json_peer
,
10904 else if (CHECK_FLAG(peer
->flags
,
10905 PEER_FLAG_PASSIVE
))
10906 json_object_string_add(json_peer
,
10909 else if (CHECK_FLAG(peer
->sflags
,
10910 PEER_STATUS_NSF_WAIT
))
10911 json_object_string_add(json_peer
,
10914 else if (CHECK_FLAG(
10916 BGP_FLAG_EBGP_REQUIRES_POLICY
)
10917 && (!bgp_inbound_policy_exists(peer
,
10919 || !bgp_outbound_policy_exists(
10921 json_object_string_add(json_peer
,
10925 json_object_string_add(
10926 json_peer
, "peerState", "OK");
10928 json_object_int_add(json_peer
, "connectionsEstablished",
10929 peer
->established
);
10930 json_object_int_add(json_peer
, "connectionsDropped",
10933 json_object_string_add(
10934 json_peer
, "desc", peer
->desc
);
10936 /* Avoid creating empty peer dicts in JSON */
10937 if (json_peer
== NULL
)
10941 json_object_string_add(json_peer
, "idType",
10943 else if (peer
->su
.sa
.sa_family
== AF_INET
)
10944 json_object_string_add(json_peer
, "idType",
10946 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
10947 json_object_string_add(json_peer
, "idType",
10949 json_object_object_add(json_peers
, peer
->host
,
10953 bgp_has_peer_failed(peer
, afi
, safi
)) {
10954 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
10955 max_neighbor_width
,
10957 } else if (!show_failed
) {
10958 if (show_established
10959 && bgp_has_peer_failed(peer
, afi
, safi
))
10962 memset(dn_flag
, '\0', sizeof(dn_flag
));
10963 if (peer_dynamic_neighbor(peer
)) {
10968 && CHECK_FLAG(bgp
->flags
,
10969 BGP_FLAG_SHOW_HOSTNAME
))
10970 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10974 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10976 /* pad the neighbor column with spaces */
10977 if (len
< max_neighbor_width
)
10978 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10981 atomic_size_t outq_count
, inq_count
;
10982 outq_count
= atomic_load_explicit(
10983 &peer
->obuf
->count
,
10984 memory_order_relaxed
);
10985 inq_count
= atomic_load_explicit(
10986 &peer
->ibuf
->count
,
10987 memory_order_relaxed
);
10990 "4 %10u %9u %9u %8" PRIu64
" %4zu %4zu %8s",
10991 peer
->as
, PEER_TOTAL_RX(peer
),
10992 PEER_TOTAL_TX(peer
),
10993 peer
->version
[afi
][safi
], inq_count
,
10995 peer_uptime(peer
->uptime
, timebuf
,
10996 BGP_UPTIME_LEN
, 0, NULL
));
10998 if (peer
->status
== Established
) {
10999 if (peer
->afc_recv
[afi
][safi
]) {
11002 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11003 && !bgp_inbound_policy_exists(
11005 vty_out(vty
, " %12s",
11014 vty_out(vty
, " NoNeg");
11017 if (paf
&& PAF_SUBGRP(paf
)) {
11020 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11021 && !bgp_outbound_policy_exists(
11023 vty_out(vty
, " %8s",
11033 if (CHECK_FLAG(peer
->flags
,
11034 PEER_FLAG_SHUTDOWN
)
11035 || CHECK_FLAG(peer
->bgp
->flags
,
11036 BGP_FLAG_SHUTDOWN
))
11037 vty_out(vty
, " Idle (Admin)");
11038 else if (CHECK_FLAG(
11040 PEER_STATUS_PREFIX_OVERFLOW
))
11041 vty_out(vty
, " Idle (PfxCt)");
11043 vty_out(vty
, " %12s",
11044 lookup_msg(bgp_status_msg
,
11045 peer
->status
, NULL
));
11047 vty_out(vty
, " %8u", 0);
11050 vty_out(vty
, " %s", peer
->desc
);
11052 vty_out(vty
, " N/A");
11053 vty_out(vty
, "\n");
11060 json_object_object_add(json
, "peers", json_peers
);
11061 json_object_int_add(json
, "failedPeers", failed_count
);
11062 json_object_int_add(json
, "totalPeers", count
);
11063 json_object_int_add(json
, "dynamicPeers", dn_count
);
11066 bgp_show_bestpath_json(bgp
, json
);
11068 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11069 json
, JSON_C_TO_STRING_PRETTY
));
11070 json_object_free(json
);
11073 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
11075 vty_out(vty
, "No %s neighbor is configured\n",
11076 get_afi_safi_str(afi
, safi
, false));
11080 vty_out(vty
, "* - dynamic neighbor\n");
11081 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11082 dn_count
, bgp
->dynamic_neighbors_limit
);
11086 return CMD_SUCCESS
;
11089 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11090 int safi
, bool show_failed
,
11091 bool show_established
, bool use_json
)
11094 int afi_wildcard
= (afi
== AFI_MAX
);
11095 int safi_wildcard
= (safi
== SAFI_MAX
);
11096 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11097 bool nbr_output
= false;
11099 if (use_json
&& is_wildcard
)
11100 vty_out(vty
, "{\n");
11102 afi
= 1; /* AFI_IP */
11103 while (afi
< AFI_MAX
) {
11105 safi
= 1; /* SAFI_UNICAST */
11106 while (safi
< SAFI_MAX
) {
11107 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11112 * So limit output to those afi/safi
11114 * actualy have something interesting in
11119 vty_out(vty
, ",\n");
11123 vty_out(vty
, "\"%s\":",
11124 get_afi_safi_str(afi
,
11128 vty_out(vty
, "\n%s Summary:\n",
11129 get_afi_safi_str(afi
,
11134 bgp_show_summary(vty
, bgp
, afi
, safi
,
11135 show_failed
, show_established
,
11139 if (!safi_wildcard
)
11147 if (use_json
&& is_wildcard
)
11148 vty_out(vty
, "}\n");
11149 else if (!nbr_output
) {
11151 vty_out(vty
, "{}\n");
11153 vty_out(vty
, "%% No BGP neighbors found\n");
11157 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11158 safi_t safi
, bool show_failed
,
11159 bool show_established
,
11162 struct listnode
*node
, *nnode
;
11165 bool nbr_output
= false;
11168 vty_out(vty
, "{\n");
11170 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11174 vty_out(vty
, ",\n");
11178 vty_out(vty
, "\"%s\":",
11179 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11183 vty_out(vty
, "\nInstance %s:\n",
11184 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11188 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
11189 show_established
, use_json
);
11193 vty_out(vty
, "}\n");
11194 else if (!nbr_output
)
11195 vty_out(vty
, "%% BGP instance not found\n");
11198 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11199 safi_t safi
, bool show_failed
, bool show_established
,
11205 if (strmatch(name
, "all")) {
11206 bgp_show_all_instances_summary_vty(
11207 vty
, afi
, safi
, show_failed
, show_established
,
11209 return CMD_SUCCESS
;
11211 bgp
= bgp_lookup_by_name(name
);
11215 vty_out(vty
, "{}\n");
11218 "%% BGP instance not found\n");
11219 return CMD_WARNING
;
11222 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
,
11223 show_failed
, show_established
,
11225 return CMD_SUCCESS
;
11229 bgp
= bgp_get_default();
11232 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
11233 show_established
, use_json
);
11236 vty_out(vty
, "{}\n");
11238 vty_out(vty
, "%% BGP instance not found\n");
11239 return CMD_WARNING
;
11242 return CMD_SUCCESS
;
11245 /* `show [ip] bgp summary' commands. */
11246 DEFPY (show_ip_bgp_summary
,
11247 show_ip_bgp_summary_cmd
,
11248 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] [all$all] summary [established|failed] [json$uj]",
11252 BGP_INSTANCE_HELP_STR
11254 BGP_SAFI_WITH_LABEL_HELP_STR
11255 "Display the entries for all address families\n"
11256 "Summary of BGP neighbor status\n"
11257 "Show only sessions in Established state\n"
11258 "Show only sessions not in Established state\n"
11262 afi_t afi
= AFI_MAX
;
11263 safi_t safi
= SAFI_MAX
;
11264 bool show_failed
= false;
11265 bool show_established
= false;
11269 /* show [ip] bgp */
11270 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11272 /* [<vrf> VIEWVRFNAME] */
11273 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11274 vrf
= argv
[idx
+ 1]->arg
;
11275 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11277 } else if (argv_find(argv
, argc
, "view", &idx
))
11278 /* [<view> VIEWVRFNAME] */
11279 vrf
= argv
[idx
+ 1]->arg
;
11280 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11281 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11282 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11285 if (argv_find(argv
, argc
, "failed", &idx
))
11286 show_failed
= true;
11287 if (argv_find(argv
, argc
, "established", &idx
))
11288 show_established
= true;
11290 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, show_failed
,
11291 show_established
, uj
);
11294 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11297 return get_afi_safi_json_str(afi
, safi
);
11299 return get_afi_safi_vty_str(afi
, safi
);
11303 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11304 afi_t afi
, safi_t safi
,
11305 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11306 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11307 bool use_json
, json_object
*json_pref
)
11310 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11311 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11313 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11314 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11315 json_object_string_add(json_pref
, "sendMode",
11316 "advertisedAndReceived");
11317 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11318 json_object_string_add(json_pref
, "sendMode",
11320 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11321 json_object_string_add(json_pref
, "sendMode",
11324 vty_out(vty
, " Send-mode: ");
11325 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11326 vty_out(vty
, "advertised");
11327 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11328 vty_out(vty
, "%sreceived",
11329 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11333 vty_out(vty
, "\n");
11338 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11339 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11341 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11342 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11343 json_object_string_add(json_pref
, "recvMode",
11344 "advertisedAndReceived");
11345 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11346 json_object_string_add(json_pref
, "recvMode",
11348 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11349 json_object_string_add(json_pref
, "recvMode",
11352 vty_out(vty
, " Receive-mode: ");
11353 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11354 vty_out(vty
, "advertised");
11355 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11356 vty_out(vty
, "%sreceived",
11357 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11361 vty_out(vty
, "\n");
11366 static void bgp_show_neighnor_graceful_restart_rbit(struct vty
*vty
,
11371 bool rbit_status
= false;
11374 vty_out(vty
, "\n R bit: ");
11376 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11377 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11378 && (p
->status
== Established
)) {
11380 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_BIT_RCV
))
11381 rbit_status
= true;
11383 rbit_status
= false;
11388 json_object_boolean_true_add(json
, "rBit");
11390 vty_out(vty
, "True\n");
11393 json_object_boolean_false_add(json
, "rBit");
11395 vty_out(vty
, "False\n");
11399 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11404 const char *mode
= "NotApplicable";
11407 vty_out(vty
, "\n Remote GR Mode: ");
11409 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11410 && (peer
->status
== Established
)) {
11412 if ((peer
->nsf_af_count
== 0)
11413 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11417 } else if (peer
->nsf_af_count
== 0
11418 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11422 } else if (peer
->nsf_af_count
!= 0
11423 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11430 json_object_string_add(json
, "remoteGrMode", mode
);
11432 vty_out(vty
, mode
, "\n");
11435 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11440 const char *mode
= "Invalid";
11443 vty_out(vty
, " Local GR Mode: ");
11445 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11447 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11449 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11451 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11452 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11454 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11456 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11463 json_object_string_add(json
, "localGrMode", mode
);
11465 vty_out(vty
, mode
, "\n");
11469 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11470 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11474 json_object
*json_afi_safi
= NULL
;
11475 json_object
*json_timer
= NULL
;
11476 json_object
*json_endofrib_status
= NULL
;
11477 bool eor_flag
= false;
11479 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11480 for (safi
= SAFI_UNICAST
; safi
<= SAFI_MPLS_VPN
; safi
++) {
11481 if (!peer
->afc
[afi
][safi
])
11484 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11485 || !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11489 json_afi_safi
= json_object_new_object();
11490 json_endofrib_status
= json_object_new_object();
11491 json_timer
= json_object_new_object();
11494 if (peer
->eor_stime
[afi
][safi
]
11495 >= peer
->pkt_stime
[afi
][safi
])
11501 vty_out(vty
, " %s:\n",
11502 get_afi_safi_str(afi
, safi
, false));
11504 vty_out(vty
, " F bit: ");
11507 if (peer
->nsf
[afi
][safi
]
11508 && CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11509 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11512 json_object_boolean_true_add(
11513 json_afi_safi
, "fBit");
11515 vty_out(vty
, "True\n");
11518 json_object_boolean_false_add(
11519 json_afi_safi
, "fBit");
11521 vty_out(vty
, "False\n");
11525 vty_out(vty
, " End-of-RIB sent: ");
11527 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11528 PEER_STATUS_EOR_SEND
)) {
11530 json_object_boolean_true_add(
11531 json_endofrib_status
,
11534 PRINT_EOR_JSON(eor_flag
);
11536 vty_out(vty
, "Yes\n");
11538 " End-of-RIB sent after update: ");
11540 PRINT_EOR(eor_flag
);
11544 json_object_boolean_false_add(
11545 json_endofrib_status
,
11547 json_object_boolean_false_add(
11548 json_endofrib_status
,
11549 "endOfRibSentAfterUpdate");
11551 vty_out(vty
, "No\n");
11553 " End-of-RIB sent after update: ");
11554 vty_out(vty
, "No\n");
11559 vty_out(vty
, " End-of-RIB received: ");
11561 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11562 PEER_STATUS_EOR_RECEIVED
)) {
11564 json_object_boolean_true_add(
11565 json_endofrib_status
,
11568 vty_out(vty
, "Yes\n");
11571 json_object_boolean_false_add(
11572 json_endofrib_status
,
11575 vty_out(vty
, "No\n");
11579 json_object_int_add(json_timer
,
11581 peer
->bgp
->stalepath_time
);
11583 if (peer
->t_gr_stale
!= NULL
) {
11584 json_object_int_add(
11586 "stalePathTimerRemaining",
11587 thread_timer_remain_second(
11588 peer
->t_gr_stale
));
11591 /* Display Configured Selection
11592 * Deferral only when when
11593 * Gr mode is enabled.
11595 if (CHECK_FLAG(peer
->flags
,
11596 PEER_FLAG_GRACEFUL_RESTART
)) {
11597 json_object_int_add(
11599 "selectionDeferralTimer",
11600 peer
->bgp
->stalepath_time
);
11603 if (peer
->bgp
->gr_info
[afi
][safi
]
11607 json_object_int_add(
11609 "selectionDeferralTimerRemaining",
11610 thread_timer_remain_second(
11614 .t_select_deferral
));
11617 vty_out(vty
, " Timers:\n");
11619 " Configured Stale Path Time(sec): %u\n",
11620 peer
->bgp
->stalepath_time
);
11622 if (peer
->t_gr_stale
!= NULL
)
11624 " Stale Path Remaining(sec): %ld\n",
11625 thread_timer_remain_second(
11626 peer
->t_gr_stale
));
11627 /* Display Configured Selection
11628 * Deferral only when when
11629 * Gr mode is enabled.
11631 if (CHECK_FLAG(peer
->flags
,
11632 PEER_FLAG_GRACEFUL_RESTART
))
11634 " Configured Selection Deferral Time(sec): %u\n",
11635 peer
->bgp
->select_defer_time
);
11637 if (peer
->bgp
->gr_info
[afi
][safi
]
11641 " Selection Deferral Time Remaining(sec): %ld\n",
11642 thread_timer_remain_second(
11646 .t_select_deferral
));
11649 json_object_object_add(json_afi_safi
,
11651 json_endofrib_status
);
11652 json_object_object_add(json_afi_safi
, "timers",
11654 json_object_object_add(
11655 json
, get_afi_safi_str(afi
, safi
, true),
11662 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
11668 json_object
*json_timer
= NULL
;
11670 json_timer
= json_object_new_object();
11672 json_object_int_add(json_timer
, "configuredRestartTimer",
11673 p
->bgp
->restart_time
);
11675 json_object_int_add(json_timer
, "receivedRestartTimer",
11678 if (p
->t_gr_restart
!= NULL
)
11679 json_object_int_add(
11680 json_timer
, "restartTimerRemaining",
11681 thread_timer_remain_second(p
->t_gr_restart
));
11683 json_object_object_add(json
, "timers", json_timer
);
11686 vty_out(vty
, " Timers:\n");
11687 vty_out(vty
, " Configured Restart Time(sec): %u\n",
11688 p
->bgp
->restart_time
);
11690 vty_out(vty
, " Received Restart Time(sec): %u\n",
11692 if (p
->t_gr_restart
!= NULL
)
11693 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11694 thread_timer_remain_second(p
->t_gr_restart
));
11695 if (p
->t_gr_restart
!= NULL
) {
11696 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11697 thread_timer_remain_second(p
->t_gr_restart
));
11702 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
11703 bool use_json
, json_object
*json
)
11705 char buf
[SU_ADDRSTRLEN
] = {0};
11706 char dn_flag
[2] = {0};
11707 /* '*' + v6 address of neighbor */
11708 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
11710 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11715 json_object_string_add(
11716 json
, "neighborAddr",
11717 BGP_PEER_SU_UNSPEC(p
)
11719 : sockunion2str(&p
->su
, buf
,
11722 vty_out(vty
, "BGP neighbor on %s: %s\n", p
->conf_if
,
11723 BGP_PEER_SU_UNSPEC(p
)
11725 : sockunion2str(&p
->su
, buf
,
11728 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
11732 json_object_string_add(json
, "neighborAddr",
11735 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
11738 /* more gr info in new format */
11739 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
11742 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
11743 safi_t safi
, bool use_json
,
11744 json_object
*json_neigh
)
11746 struct bgp_filter
*filter
;
11747 struct peer_af
*paf
;
11748 char orf_pfx_name
[BUFSIZ
];
11750 json_object
*json_af
= NULL
;
11751 json_object
*json_prefA
= NULL
;
11752 json_object
*json_prefB
= NULL
;
11753 json_object
*json_addr
= NULL
;
11754 json_object
*json_advmap
= NULL
;
11757 json_addr
= json_object_new_object();
11758 json_af
= json_object_new_object();
11759 filter
= &p
->filter
[afi
][safi
];
11761 if (peer_group_active(p
))
11762 json_object_string_add(json_addr
, "peerGroupMember",
11765 paf
= peer_af_find(p
, afi
, safi
);
11766 if (paf
&& PAF_SUBGRP(paf
)) {
11767 json_object_int_add(json_addr
, "updateGroupId",
11768 PAF_UPDGRP(paf
)->id
);
11769 json_object_int_add(json_addr
, "subGroupId",
11770 PAF_SUBGRP(paf
)->id
);
11771 json_object_int_add(json_addr
, "packetQueueLength",
11772 bpacket_queue_virtual_length(paf
));
11775 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11776 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11777 PEER_CAP_ORF_PREFIX_SM_RCV
)
11778 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11779 PEER_CAP_ORF_PREFIX_RM_ADV
)
11780 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11781 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11782 json_object_int_add(json_af
, "orfType",
11784 json_prefA
= json_object_new_object();
11785 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
11786 PEER_CAP_ORF_PREFIX_SM_ADV
,
11787 PEER_CAP_ORF_PREFIX_RM_ADV
,
11788 PEER_CAP_ORF_PREFIX_SM_RCV
,
11789 PEER_CAP_ORF_PREFIX_RM_RCV
,
11790 use_json
, json_prefA
);
11791 json_object_object_add(json_af
, "orfPrefixList",
11795 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11796 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11797 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11798 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11799 PEER_CAP_ORF_PREFIX_RM_ADV
)
11800 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11801 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
11802 json_object_int_add(json_af
, "orfOldType",
11803 ORF_TYPE_PREFIX_OLD
);
11804 json_prefB
= json_object_new_object();
11805 bgp_show_peer_afi_orf_cap(
11806 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
11807 PEER_CAP_ORF_PREFIX_RM_ADV
,
11808 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
11809 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
11811 json_object_object_add(json_af
, "orfOldPrefixList",
11815 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11816 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11817 PEER_CAP_ORF_PREFIX_SM_RCV
)
11818 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11819 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11820 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11821 PEER_CAP_ORF_PREFIX_RM_ADV
)
11822 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11823 PEER_CAP_ORF_PREFIX_RM_RCV
)
11824 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11825 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
11826 json_object_object_add(json_addr
, "afDependentCap",
11829 json_object_free(json_af
);
11831 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
11832 p
->host
, afi
, safi
);
11833 orf_pfx_count
= prefix_bgp_show_prefix_list(
11834 NULL
, afi
, orf_pfx_name
, use_json
);
11836 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11837 PEER_STATUS_ORF_PREFIX_SEND
)
11838 || orf_pfx_count
) {
11839 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11840 PEER_STATUS_ORF_PREFIX_SEND
))
11841 json_object_boolean_true_add(json_neigh
,
11844 json_object_int_add(json_addr
, "orfRecvCounter",
11847 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11848 PEER_STATUS_ORF_WAIT_REFRESH
))
11849 json_object_string_add(
11850 json_addr
, "orfFirstUpdate",
11851 "deferredUntilORFOrRouteRefreshRecvd");
11853 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11854 PEER_FLAG_REFLECTOR_CLIENT
))
11855 json_object_boolean_true_add(json_addr
,
11856 "routeReflectorClient");
11857 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11858 PEER_FLAG_RSERVER_CLIENT
))
11859 json_object_boolean_true_add(json_addr
,
11860 "routeServerClient");
11861 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
11862 json_object_boolean_true_add(json_addr
,
11863 "inboundSoftConfigPermit");
11865 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11866 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
11867 json_object_boolean_true_add(
11869 "privateAsNumsAllReplacedInUpdatesToNbr");
11870 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11871 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
11872 json_object_boolean_true_add(
11874 "privateAsNumsReplacedInUpdatesToNbr");
11875 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11876 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
11877 json_object_boolean_true_add(
11879 "privateAsNumsAllRemovedInUpdatesToNbr");
11880 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11881 PEER_FLAG_REMOVE_PRIVATE_AS
))
11882 json_object_boolean_true_add(
11884 "privateAsNumsRemovedInUpdatesToNbr");
11886 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
11887 json_object_boolean_true_add(
11889 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
11892 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
11893 json_object_string_add(json_addr
,
11894 "overrideASNsInOutboundUpdates",
11895 "ifAspathEqualRemoteAs");
11897 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
11898 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11899 PEER_FLAG_FORCE_NEXTHOP_SELF
))
11900 json_object_boolean_true_add(json_addr
,
11901 "routerAlwaysNextHop");
11902 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11903 PEER_FLAG_AS_PATH_UNCHANGED
))
11904 json_object_boolean_true_add(
11905 json_addr
, "unchangedAsPathPropogatedToNbr");
11906 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11907 PEER_FLAG_NEXTHOP_UNCHANGED
))
11908 json_object_boolean_true_add(
11909 json_addr
, "unchangedNextHopPropogatedToNbr");
11910 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
11911 json_object_boolean_true_add(
11912 json_addr
, "unchangedMedPropogatedToNbr");
11913 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
11914 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11915 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
11916 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11917 PEER_FLAG_SEND_COMMUNITY
)
11918 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
11919 PEER_FLAG_SEND_EXT_COMMUNITY
))
11920 json_object_string_add(json_addr
,
11921 "commAttriSentToNbr",
11922 "extendedAndStandard");
11923 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11924 PEER_FLAG_SEND_EXT_COMMUNITY
))
11925 json_object_string_add(json_addr
,
11926 "commAttriSentToNbr",
11929 json_object_string_add(json_addr
,
11930 "commAttriSentToNbr",
11933 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11934 PEER_FLAG_DEFAULT_ORIGINATE
)) {
11935 if (p
->default_rmap
[afi
][safi
].name
)
11936 json_object_string_add(
11937 json_addr
, "defaultRouteMap",
11938 p
->default_rmap
[afi
][safi
].name
);
11940 if (paf
&& PAF_SUBGRP(paf
)
11941 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
11942 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
11943 json_object_boolean_true_add(json_addr
,
11946 json_object_boolean_true_add(json_addr
,
11950 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
11951 if (is_evpn_enabled())
11952 json_object_boolean_true_add(
11953 json_addr
, "advertiseAllVnis");
11956 if (filter
->plist
[FILTER_IN
].name
11957 || filter
->dlist
[FILTER_IN
].name
11958 || filter
->aslist
[FILTER_IN
].name
11959 || filter
->map
[RMAP_IN
].name
)
11960 json_object_boolean_true_add(json_addr
,
11961 "inboundPathPolicyConfig");
11962 if (filter
->plist
[FILTER_OUT
].name
11963 || filter
->dlist
[FILTER_OUT
].name
11964 || filter
->aslist
[FILTER_OUT
].name
11965 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
11966 json_object_boolean_true_add(
11967 json_addr
, "outboundPathPolicyConfig");
11970 if (filter
->plist
[FILTER_IN
].name
)
11971 json_object_string_add(json_addr
,
11972 "incomingUpdatePrefixFilterList",
11973 filter
->plist
[FILTER_IN
].name
);
11974 if (filter
->plist
[FILTER_OUT
].name
)
11975 json_object_string_add(json_addr
,
11976 "outgoingUpdatePrefixFilterList",
11977 filter
->plist
[FILTER_OUT
].name
);
11979 /* distribute-list */
11980 if (filter
->dlist
[FILTER_IN
].name
)
11981 json_object_string_add(
11982 json_addr
, "incomingUpdateNetworkFilterList",
11983 filter
->dlist
[FILTER_IN
].name
);
11984 if (filter
->dlist
[FILTER_OUT
].name
)
11985 json_object_string_add(
11986 json_addr
, "outgoingUpdateNetworkFilterList",
11987 filter
->dlist
[FILTER_OUT
].name
);
11990 if (filter
->aslist
[FILTER_IN
].name
)
11991 json_object_string_add(json_addr
,
11992 "incomingUpdateAsPathFilterList",
11993 filter
->aslist
[FILTER_IN
].name
);
11994 if (filter
->aslist
[FILTER_OUT
].name
)
11995 json_object_string_add(json_addr
,
11996 "outgoingUpdateAsPathFilterList",
11997 filter
->aslist
[FILTER_OUT
].name
);
12000 if (filter
->map
[RMAP_IN
].name
)
12001 json_object_string_add(
12002 json_addr
, "routeMapForIncomingAdvertisements",
12003 filter
->map
[RMAP_IN
].name
);
12004 if (filter
->map
[RMAP_OUT
].name
)
12005 json_object_string_add(
12006 json_addr
, "routeMapForOutgoingAdvertisements",
12007 filter
->map
[RMAP_OUT
].name
);
12009 /* ebgp-requires-policy (inbound) */
12010 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12011 && !bgp_inbound_policy_exists(p
, filter
))
12012 json_object_string_add(
12013 json_addr
, "inboundEbgpRequiresPolicy",
12014 "Inbound updates discarded due to missing policy");
12016 /* ebgp-requires-policy (outbound) */
12017 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12018 && (!bgp_outbound_policy_exists(p
, filter
)))
12019 json_object_string_add(
12020 json_addr
, "outboundEbgpRequiresPolicy",
12021 "Outbound updates discarded due to missing policy");
12023 /* unsuppress-map */
12024 if (filter
->usmap
.name
)
12025 json_object_string_add(json_addr
,
12026 "selectiveUnsuppressRouteMap",
12027 filter
->usmap
.name
);
12029 /* advertise-map */
12030 if (filter
->advmap
.aname
) {
12031 json_advmap
= json_object_new_object();
12032 json_object_string_add(json_advmap
, "condition",
12033 filter
->advmap
.condition
12036 json_object_string_add(json_advmap
, "conditionMap",
12037 filter
->advmap
.cname
);
12038 json_object_string_add(json_advmap
, "advertiseMap",
12039 filter
->advmap
.aname
);
12040 json_object_string_add(json_advmap
, "advertiseStatus",
12041 filter
->advmap
.update_type
12045 json_object_object_add(json_addr
, "advertiseMap",
12049 /* Receive prefix count */
12050 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12051 p
->pcount
[afi
][safi
]);
12052 if (paf
&& PAF_SUBGRP(paf
))
12053 json_object_int_add(json_addr
, "sentPrefixCounter",
12054 (PAF_SUBGRP(paf
))->scount
);
12056 /* Maximum prefix */
12057 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12058 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12059 p
->pmax_out
[afi
][safi
]);
12061 /* Maximum prefix */
12062 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12063 json_object_int_add(json_addr
, "prefixAllowedMax",
12064 p
->pmax
[afi
][safi
]);
12065 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12066 PEER_FLAG_MAX_PREFIX_WARNING
))
12067 json_object_boolean_true_add(
12068 json_addr
, "prefixAllowedMaxWarning");
12069 json_object_int_add(json_addr
,
12070 "prefixAllowedWarningThresh",
12071 p
->pmax_threshold
[afi
][safi
]);
12072 if (p
->pmax_restart
[afi
][safi
])
12073 json_object_int_add(
12075 "prefixAllowedRestartIntervalMsecs",
12076 p
->pmax_restart
[afi
][safi
] * 60000);
12078 json_object_object_add(json_neigh
,
12079 get_afi_safi_str(afi
, safi
, true),
12083 filter
= &p
->filter
[afi
][safi
];
12085 vty_out(vty
, " For address family: %s\n",
12086 get_afi_safi_str(afi
, safi
, false));
12088 if (peer_group_active(p
))
12089 vty_out(vty
, " %s peer-group member\n",
12092 paf
= peer_af_find(p
, afi
, safi
);
12093 if (paf
&& PAF_SUBGRP(paf
)) {
12094 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12095 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12096 vty_out(vty
, " Packet Queue length %d\n",
12097 bpacket_queue_virtual_length(paf
));
12099 vty_out(vty
, " Not part of any update group\n");
12101 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12102 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12103 PEER_CAP_ORF_PREFIX_SM_RCV
)
12104 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12105 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12106 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12107 PEER_CAP_ORF_PREFIX_RM_ADV
)
12108 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12109 PEER_CAP_ORF_PREFIX_RM_RCV
)
12110 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12111 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12112 vty_out(vty
, " AF-dependant capabilities:\n");
12114 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12115 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12116 PEER_CAP_ORF_PREFIX_SM_RCV
)
12117 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12118 PEER_CAP_ORF_PREFIX_RM_ADV
)
12119 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12120 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12122 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12124 bgp_show_peer_afi_orf_cap(
12125 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12126 PEER_CAP_ORF_PREFIX_RM_ADV
,
12127 PEER_CAP_ORF_PREFIX_SM_RCV
,
12128 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12130 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12131 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12132 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12133 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12134 PEER_CAP_ORF_PREFIX_RM_ADV
)
12135 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12136 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12138 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12139 ORF_TYPE_PREFIX_OLD
);
12140 bgp_show_peer_afi_orf_cap(
12141 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12142 PEER_CAP_ORF_PREFIX_RM_ADV
,
12143 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12144 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12147 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12148 p
->host
, afi
, safi
);
12149 orf_pfx_count
= prefix_bgp_show_prefix_list(
12150 NULL
, afi
, orf_pfx_name
, use_json
);
12152 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12153 PEER_STATUS_ORF_PREFIX_SEND
)
12154 || orf_pfx_count
) {
12155 vty_out(vty
, " Outbound Route Filter (ORF):");
12156 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12157 PEER_STATUS_ORF_PREFIX_SEND
))
12158 vty_out(vty
, " sent;");
12160 vty_out(vty
, " received (%d entries)",
12162 vty_out(vty
, "\n");
12164 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12165 PEER_STATUS_ORF_WAIT_REFRESH
))
12167 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12169 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12170 PEER_FLAG_REFLECTOR_CLIENT
))
12171 vty_out(vty
, " Route-Reflector Client\n");
12172 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12173 PEER_FLAG_RSERVER_CLIENT
))
12174 vty_out(vty
, " Route-Server Client\n");
12175 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12177 " Inbound soft reconfiguration allowed\n");
12179 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12180 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12182 " Private AS numbers (all) replaced in updates to this neighbor\n");
12183 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12184 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12186 " Private AS numbers replaced in updates to this neighbor\n");
12187 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12188 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12190 " Private AS numbers (all) removed in updates to this neighbor\n");
12191 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12192 PEER_FLAG_REMOVE_PRIVATE_AS
))
12194 " Private AS numbers removed in updates to this neighbor\n");
12196 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12197 vty_out(vty
, " %s\n",
12198 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12199 ->human_description
);
12201 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12203 " Override ASNs in outbound updates if aspath equals remote-as\n");
12205 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12206 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12207 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12208 vty_out(vty
, " NEXT_HOP is always this router\n");
12209 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12210 PEER_FLAG_AS_PATH_UNCHANGED
))
12212 " AS_PATH is propagated unchanged to this neighbor\n");
12213 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12214 PEER_FLAG_NEXTHOP_UNCHANGED
))
12216 " NEXT_HOP is propagated unchanged to this neighbor\n");
12217 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12219 " MED is propagated unchanged to this neighbor\n");
12220 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12221 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12222 PEER_FLAG_SEND_EXT_COMMUNITY
)
12223 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12224 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12226 " Community attribute sent to this neighbor");
12227 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12228 PEER_FLAG_SEND_COMMUNITY
)
12229 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12230 PEER_FLAG_SEND_EXT_COMMUNITY
)
12231 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12232 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12233 vty_out(vty
, "(all)\n");
12234 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12235 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12236 vty_out(vty
, "(large)\n");
12237 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12238 PEER_FLAG_SEND_EXT_COMMUNITY
))
12239 vty_out(vty
, "(extended)\n");
12241 vty_out(vty
, "(standard)\n");
12243 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12244 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12245 vty_out(vty
, " Default information originate,");
12247 if (p
->default_rmap
[afi
][safi
].name
)
12248 vty_out(vty
, " default route-map %s%s,",
12249 p
->default_rmap
[afi
][safi
].map
? "*"
12251 p
->default_rmap
[afi
][safi
].name
);
12252 if (paf
&& PAF_SUBGRP(paf
)
12253 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12254 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12255 vty_out(vty
, " default sent\n");
12257 vty_out(vty
, " default not sent\n");
12260 /* advertise-vni-all */
12261 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12262 if (is_evpn_enabled())
12263 vty_out(vty
, " advertise-all-vni\n");
12266 if (filter
->plist
[FILTER_IN
].name
12267 || filter
->dlist
[FILTER_IN
].name
12268 || filter
->aslist
[FILTER_IN
].name
12269 || filter
->map
[RMAP_IN
].name
)
12270 vty_out(vty
, " Inbound path policy configured\n");
12271 if (filter
->plist
[FILTER_OUT
].name
12272 || filter
->dlist
[FILTER_OUT
].name
12273 || filter
->aslist
[FILTER_OUT
].name
12274 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12275 vty_out(vty
, " Outbound path policy configured\n");
12278 if (filter
->plist
[FILTER_IN
].name
)
12280 " Incoming update prefix filter list is %s%s\n",
12281 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12282 filter
->plist
[FILTER_IN
].name
);
12283 if (filter
->plist
[FILTER_OUT
].name
)
12285 " Outgoing update prefix filter list is %s%s\n",
12286 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12287 filter
->plist
[FILTER_OUT
].name
);
12289 /* distribute-list */
12290 if (filter
->dlist
[FILTER_IN
].name
)
12292 " Incoming update network filter list is %s%s\n",
12293 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12294 filter
->dlist
[FILTER_IN
].name
);
12295 if (filter
->dlist
[FILTER_OUT
].name
)
12297 " Outgoing update network filter list is %s%s\n",
12298 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12299 filter
->dlist
[FILTER_OUT
].name
);
12302 if (filter
->aslist
[FILTER_IN
].name
)
12304 " Incoming update AS path filter list is %s%s\n",
12305 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12306 filter
->aslist
[FILTER_IN
].name
);
12307 if (filter
->aslist
[FILTER_OUT
].name
)
12309 " Outgoing update AS path filter list is %s%s\n",
12310 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12311 filter
->aslist
[FILTER_OUT
].name
);
12314 if (filter
->map
[RMAP_IN
].name
)
12316 " Route map for incoming advertisements is %s%s\n",
12317 filter
->map
[RMAP_IN
].map
? "*" : "",
12318 filter
->map
[RMAP_IN
].name
);
12319 if (filter
->map
[RMAP_OUT
].name
)
12321 " Route map for outgoing advertisements is %s%s\n",
12322 filter
->map
[RMAP_OUT
].map
? "*" : "",
12323 filter
->map
[RMAP_OUT
].name
);
12325 /* ebgp-requires-policy (inbound) */
12326 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12327 && !bgp_inbound_policy_exists(p
, filter
))
12329 " Inbound updates discarded due to missing policy\n");
12331 /* ebgp-requires-policy (outbound) */
12332 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12333 && !bgp_outbound_policy_exists(p
, filter
))
12335 " Outbound updates discarded due to missing policy\n");
12337 /* unsuppress-map */
12338 if (filter
->usmap
.name
)
12340 " Route map for selective unsuppress is %s%s\n",
12341 filter
->usmap
.map
? "*" : "",
12342 filter
->usmap
.name
);
12344 /* advertise-map */
12345 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12347 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12348 filter
->advmap
.condition
? "EXIST"
12350 filter
->advmap
.cmap
? "*" : "",
12351 filter
->advmap
.cname
,
12352 filter
->advmap
.amap
? "*" : "",
12353 filter
->advmap
.aname
,
12354 filter
->advmap
.update_type
== ADVERTISE
12358 /* Receive prefix count */
12359 vty_out(vty
, " %u accepted prefixes\n",
12360 p
->pcount
[afi
][safi
]);
12362 /* maximum-prefix-out */
12363 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12364 PEER_FLAG_MAX_PREFIX_OUT
))
12366 " Maximum allowed prefixes sent %u\n",
12367 p
->pmax_out
[afi
][safi
]);
12369 /* Maximum prefix */
12370 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12372 " Maximum prefixes allowed %u%s\n",
12373 p
->pmax
[afi
][safi
],
12374 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12375 PEER_FLAG_MAX_PREFIX_WARNING
)
12376 ? " (warning-only)"
12378 vty_out(vty
, " Threshold for warning message %d%%",
12379 p
->pmax_threshold
[afi
][safi
]);
12380 if (p
->pmax_restart
[afi
][safi
])
12381 vty_out(vty
, ", restart interval %d min",
12382 p
->pmax_restart
[afi
][safi
]);
12383 vty_out(vty
, "\n");
12386 vty_out(vty
, "\n");
12390 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12394 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
12395 char timebuf
[BGP_UPTIME_LEN
];
12401 json_object
*json_neigh
= NULL
;
12407 json_neigh
= json_object_new_object();
12409 memset(dn_flag
, '\0', sizeof(dn_flag
));
12410 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12414 if (p
->conf_if
) /* Configured interface name. */
12415 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
12416 BGP_PEER_SU_UNSPEC(p
)
12418 : sockunion2str(&p
->su
, buf
,
12420 else /* Configured IP address. */
12421 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12426 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12427 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12429 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12430 json_object_string_add(
12431 json_neigh
, "bgpNeighborAddr",
12432 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
12434 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12436 if (p
->change_local_as
)
12437 json_object_int_add(json_neigh
, "localAs",
12438 p
->change_local_as
);
12440 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12442 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12443 json_object_boolean_true_add(json_neigh
,
12444 "localAsNoPrepend");
12446 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12447 json_object_boolean_true_add(json_neigh
,
12448 "localAsReplaceAs");
12450 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12451 || (p
->as_type
== AS_INTERNAL
))
12452 vty_out(vty
, "remote AS %u, ", p
->as
);
12454 vty_out(vty
, "remote AS Unspecified, ");
12455 vty_out(vty
, "local AS %u%s%s, ",
12456 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12457 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12460 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12464 /* peer type internal or confed-internal */
12465 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12467 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12468 json_object_boolean_true_add(
12469 json_neigh
, "nbrConfedInternalLink");
12471 json_object_boolean_true_add(json_neigh
,
12472 "nbrInternalLink");
12474 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12475 vty_out(vty
, "confed-internal link\n");
12477 vty_out(vty
, "internal link\n");
12479 /* peer type external or confed-external */
12480 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12482 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12483 json_object_boolean_true_add(
12484 json_neigh
, "nbrConfedExternalLink");
12486 json_object_boolean_true_add(json_neigh
,
12487 "nbrExternalLink");
12489 if (bgp_confederation_peers_check(bgp
, p
->as
))
12490 vty_out(vty
, "confed-external link\n");
12492 vty_out(vty
, "external link\n");
12496 json_object_boolean_true_add(json_neigh
,
12497 "nbrUnspecifiedLink");
12499 vty_out(vty
, "unspecified link\n");
12505 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12507 vty_out(vty
, " Description: %s\n", p
->desc
);
12513 json_object_string_add(json_neigh
, "hostname",
12517 json_object_string_add(json_neigh
, "domainname",
12520 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12521 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12524 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12531 json_object_string_add(json_neigh
, "peerGroup",
12535 struct prefix prefix
, *range
= NULL
;
12537 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12538 range
= peer_group_lookup_dynamic_neighbor_range(
12539 p
->group
, &prefix
);
12542 prefix2str(range
, buf1
, sizeof(buf1
));
12543 json_object_string_add(
12545 "peerSubnetRangeGroup", buf1
);
12550 " Member of peer-group %s for session parameters\n",
12554 struct prefix prefix
, *range
= NULL
;
12556 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12557 range
= peer_group_lookup_dynamic_neighbor_range(
12558 p
->group
, &prefix
);
12562 " Belongs to the subnet range group: %pFX\n",
12570 /* Administrative shutdown. */
12571 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12572 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12573 json_object_boolean_true_add(json_neigh
,
12577 json_object_int_add(json_neigh
, "bgpVersion", 4);
12578 json_object_string_add(
12579 json_neigh
, "remoteRouterId",
12580 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12581 json_object_string_add(
12582 json_neigh
, "localRouterId",
12583 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12586 /* Confederation */
12587 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12588 && bgp_confederation_peers_check(bgp
, p
->as
))
12589 json_object_boolean_true_add(json_neigh
,
12593 json_object_string_add(
12594 json_neigh
, "bgpState",
12595 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12597 if (p
->status
== Established
) {
12600 uptime
= bgp_clock();
12601 uptime
-= p
->uptime
;
12602 epoch_tbuf
= time(NULL
) - uptime
;
12604 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
12606 json_object_string_add(json_neigh
, "bgpTimerUpString",
12607 peer_uptime(p
->uptime
, timebuf
,
12610 json_object_int_add(json_neigh
,
12611 "bgpTimerUpEstablishedEpoch",
12615 else if (p
->status
== Active
) {
12616 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12617 json_object_string_add(json_neigh
, "bgpStateIs",
12619 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12620 json_object_string_add(json_neigh
, "bgpStateIs",
12628 uptime
= bgp_clock();
12629 uptime
-= p
->readtime
;
12630 gmtime_r(&uptime
, &tm
);
12632 json_object_int_add(json_neigh
, "bgpTimerLastRead",
12633 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12634 + (tm
.tm_hour
* 3600000));
12636 uptime
= bgp_clock();
12637 uptime
-= p
->last_write
;
12638 gmtime_r(&uptime
, &tm
);
12640 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
12641 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12642 + (tm
.tm_hour
* 3600000));
12644 uptime
= bgp_clock();
12645 uptime
-= p
->update_time
;
12646 gmtime_r(&uptime
, &tm
);
12648 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
12649 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12650 + (tm
.tm_hour
* 3600000));
12652 /* Configured timer values. */
12653 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
12654 p
->v_holdtime
* 1000);
12655 json_object_int_add(json_neigh
,
12656 "bgpTimerKeepAliveIntervalMsecs",
12657 p
->v_keepalive
* 1000);
12658 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
12659 json_object_int_add(json_neigh
,
12660 "bgpTimerDelayOpenTimeMsecs",
12661 p
->v_delayopen
* 1000);
12664 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12665 json_object_int_add(json_neigh
,
12666 "bgpTimerConfiguredHoldTimeMsecs",
12667 p
->holdtime
* 1000);
12668 json_object_int_add(
12670 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12671 p
->keepalive
* 1000);
12672 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12673 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12674 json_object_int_add(json_neigh
,
12675 "bgpTimerConfiguredHoldTimeMsecs",
12676 bgp
->default_holdtime
);
12677 json_object_int_add(
12679 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12680 bgp
->default_keepalive
);
12683 /* Administrative shutdown. */
12684 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12685 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12686 vty_out(vty
, " Administratively shut down\n");
12689 vty_out(vty
, " BGP version 4");
12690 vty_out(vty
, ", remote router ID %s",
12691 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12692 vty_out(vty
, ", local router ID %s\n",
12693 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12696 /* Confederation */
12697 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12698 && bgp_confederation_peers_check(bgp
, p
->as
))
12700 " Neighbor under common administration\n");
12703 vty_out(vty
, " BGP state = %s",
12704 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12706 if (p
->status
== Established
)
12707 vty_out(vty
, ", up for %8s",
12708 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
12711 else if (p
->status
== Active
) {
12712 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12713 vty_out(vty
, " (passive)");
12714 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12715 vty_out(vty
, " (NSF passive)");
12717 vty_out(vty
, "\n");
12720 vty_out(vty
, " Last read %s",
12721 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
12723 vty_out(vty
, ", Last write %s\n",
12724 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
12727 /* Configured timer values. */
12729 " Hold time is %d, keepalive interval is %d seconds\n",
12730 p
->v_holdtime
, p
->v_keepalive
);
12731 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12732 vty_out(vty
, " Configured hold time is %d",
12734 vty_out(vty
, ", keepalive interval is %d seconds\n",
12736 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12737 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12738 vty_out(vty
, " Configured hold time is %d",
12739 bgp
->default_holdtime
);
12740 vty_out(vty
, ", keepalive interval is %d seconds\n",
12741 bgp
->default_keepalive
);
12743 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
12745 " Configured DelayOpenTime is %d seconds\n",
12749 if (p
->status
== Established
) {
12750 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
12751 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
12752 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
12753 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
12754 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
12755 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
12756 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
12757 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
12758 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
12759 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
12760 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
12761 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
12762 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
12763 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
12764 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
12765 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
12766 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
12767 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
12768 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
12769 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
12771 json_object
*json_cap
= NULL
;
12773 json_cap
= json_object_new_object();
12776 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
12777 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
12778 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
12779 && CHECK_FLAG(p
->cap
,
12781 json_object_string_add(
12782 json_cap
, "4byteAs",
12783 "advertisedAndReceived");
12784 else if (CHECK_FLAG(p
->cap
,
12786 json_object_string_add(
12787 json_cap
, "4byteAs",
12789 else if (CHECK_FLAG(p
->cap
,
12791 json_object_string_add(
12792 json_cap
, "4byteAs",
12797 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
12798 || CHECK_FLAG(p
->cap
,
12799 PEER_CAP_ADDPATH_ADV
)) {
12800 json_object
*json_add
= NULL
;
12801 const char *print_store
;
12803 json_add
= json_object_new_object();
12805 FOREACH_AFI_SAFI (afi
, safi
) {
12806 json_object
*json_sub
= NULL
;
12808 json_object_new_object();
12809 print_store
= get_afi_safi_str(
12815 PEER_CAP_ADDPATH_AF_TX_ADV
)
12819 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
12824 PEER_CAP_ADDPATH_AF_TX_ADV
)
12829 PEER_CAP_ADDPATH_AF_TX_RCV
))
12830 json_object_boolean_true_add(
12832 "txAdvertisedAndReceived");
12838 PEER_CAP_ADDPATH_AF_TX_ADV
))
12839 json_object_boolean_true_add(
12847 PEER_CAP_ADDPATH_AF_TX_RCV
))
12848 json_object_boolean_true_add(
12856 PEER_CAP_ADDPATH_AF_RX_ADV
)
12860 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
12865 PEER_CAP_ADDPATH_AF_RX_ADV
)
12870 PEER_CAP_ADDPATH_AF_RX_RCV
))
12871 json_object_boolean_true_add(
12873 "rxAdvertisedAndReceived");
12879 PEER_CAP_ADDPATH_AF_RX_ADV
))
12880 json_object_boolean_true_add(
12888 PEER_CAP_ADDPATH_AF_RX_RCV
))
12889 json_object_boolean_true_add(
12897 PEER_CAP_ADDPATH_AF_TX_ADV
)
12901 PEER_CAP_ADDPATH_AF_TX_RCV
)
12905 PEER_CAP_ADDPATH_AF_RX_ADV
)
12909 PEER_CAP_ADDPATH_AF_RX_RCV
))
12910 json_object_object_add(
12919 json_object_object_add(
12920 json_cap
, "addPath", json_add
);
12924 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
12925 || CHECK_FLAG(p
->cap
,
12926 PEER_CAP_DYNAMIC_ADV
)) {
12927 if (CHECK_FLAG(p
->cap
,
12928 PEER_CAP_DYNAMIC_ADV
)
12929 && CHECK_FLAG(p
->cap
,
12930 PEER_CAP_DYNAMIC_RCV
))
12931 json_object_string_add(
12932 json_cap
, "dynamic",
12933 "advertisedAndReceived");
12934 else if (CHECK_FLAG(
12936 PEER_CAP_DYNAMIC_ADV
))
12937 json_object_string_add(
12938 json_cap
, "dynamic",
12940 else if (CHECK_FLAG(
12942 PEER_CAP_DYNAMIC_RCV
))
12943 json_object_string_add(
12944 json_cap
, "dynamic",
12948 /* Extended nexthop */
12949 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
12950 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
12951 json_object
*json_nxt
= NULL
;
12952 const char *print_store
;
12955 if (CHECK_FLAG(p
->cap
,
12957 && CHECK_FLAG(p
->cap
,
12958 PEER_CAP_ENHE_RCV
))
12959 json_object_string_add(
12962 "advertisedAndReceived");
12963 else if (CHECK_FLAG(p
->cap
,
12964 PEER_CAP_ENHE_ADV
))
12965 json_object_string_add(
12969 else if (CHECK_FLAG(p
->cap
,
12970 PEER_CAP_ENHE_RCV
))
12971 json_object_string_add(
12976 if (CHECK_FLAG(p
->cap
,
12977 PEER_CAP_ENHE_RCV
)) {
12979 json_object_new_object();
12981 for (safi
= SAFI_UNICAST
;
12982 safi
< SAFI_MAX
; safi
++) {
12987 PEER_CAP_ENHE_AF_RCV
)) {
12988 print_store
= get_afi_safi_str(
12991 json_object_string_add(
12994 "recieved"); /* misspelled for compatibility */
12997 json_object_object_add(
12999 "extendedNexthopFamililesByPeer",
13004 /* Route Refresh */
13005 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
13006 || CHECK_FLAG(p
->cap
,
13007 PEER_CAP_REFRESH_NEW_RCV
)
13008 || CHECK_FLAG(p
->cap
,
13009 PEER_CAP_REFRESH_OLD_RCV
)) {
13010 if (CHECK_FLAG(p
->cap
,
13011 PEER_CAP_REFRESH_ADV
)
13014 PEER_CAP_REFRESH_NEW_RCV
)
13017 PEER_CAP_REFRESH_OLD_RCV
))) {
13020 PEER_CAP_REFRESH_OLD_RCV
)
13023 PEER_CAP_REFRESH_NEW_RCV
))
13024 json_object_string_add(
13027 "advertisedAndReceivedOldNew");
13031 PEER_CAP_REFRESH_OLD_RCV
))
13032 json_object_string_add(
13035 "advertisedAndReceivedOld");
13037 json_object_string_add(
13040 "advertisedAndReceivedNew");
13045 PEER_CAP_REFRESH_ADV
))
13046 json_object_string_add(
13053 PEER_CAP_REFRESH_NEW_RCV
)
13056 PEER_CAP_REFRESH_OLD_RCV
))
13057 json_object_string_add(
13063 /* Multiprotocol Extensions */
13064 json_object
*json_multi
= NULL
;
13065 json_multi
= json_object_new_object();
13067 FOREACH_AFI_SAFI (afi
, safi
) {
13068 if (p
->afc_adv
[afi
][safi
]
13069 || p
->afc_recv
[afi
][safi
]) {
13070 json_object
*json_exten
= NULL
;
13072 json_object_new_object();
13074 if (p
->afc_adv
[afi
][safi
]
13075 && p
->afc_recv
[afi
][safi
])
13076 json_object_boolean_true_add(
13078 "advertisedAndReceived");
13079 else if (p
->afc_adv
[afi
][safi
])
13080 json_object_boolean_true_add(
13083 else if (p
->afc_recv
[afi
][safi
])
13084 json_object_boolean_true_add(
13088 json_object_object_add(
13090 get_afi_safi_str(afi
,
13096 json_object_object_add(
13097 json_cap
, "multiprotocolExtensions",
13100 /* Hostname capabilities */
13101 json_object
*json_hname
= NULL
;
13103 json_hname
= json_object_new_object();
13105 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13106 json_object_string_add(
13107 json_hname
, "advHostName",
13108 bgp
->peer_self
->hostname
13112 json_object_string_add(
13113 json_hname
, "advDomainName",
13114 bgp
->peer_self
->domainname
13121 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13122 json_object_string_add(
13123 json_hname
, "rcvHostName",
13124 p
->hostname
? p
->hostname
13126 json_object_string_add(
13127 json_hname
, "rcvDomainName",
13128 p
->domainname
? p
->domainname
13132 json_object_object_add(json_cap
, "hostName",
13135 /* Gracefull Restart */
13136 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
13137 || CHECK_FLAG(p
->cap
,
13138 PEER_CAP_RESTART_ADV
)) {
13139 if (CHECK_FLAG(p
->cap
,
13140 PEER_CAP_RESTART_ADV
)
13141 && CHECK_FLAG(p
->cap
,
13142 PEER_CAP_RESTART_RCV
))
13143 json_object_string_add(
13146 "advertisedAndReceived");
13147 else if (CHECK_FLAG(
13149 PEER_CAP_RESTART_ADV
))
13150 json_object_string_add(
13152 "gracefulRestartCapability",
13154 else if (CHECK_FLAG(
13156 PEER_CAP_RESTART_RCV
))
13157 json_object_string_add(
13159 "gracefulRestartCapability",
13162 if (CHECK_FLAG(p
->cap
,
13163 PEER_CAP_RESTART_RCV
)) {
13164 int restart_af_count
= 0;
13165 json_object
*json_restart
=
13168 json_object_new_object();
13170 json_object_int_add(
13172 "gracefulRestartRemoteTimerMsecs",
13173 p
->v_gr_restart
* 1000);
13175 FOREACH_AFI_SAFI (afi
, safi
) {
13180 PEER_CAP_RESTART_AF_RCV
)) {
13185 json_object_new_object();
13191 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13192 json_object_boolean_true_add(
13195 restart_af_count
++;
13196 json_object_object_add(
13205 if (!restart_af_count
) {
13206 json_object_string_add(
13208 "addressFamiliesByPeer",
13213 json_object_object_add(
13215 "addressFamiliesByPeer",
13219 json_object_object_add(json_neigh
,
13220 "neighborCapabilities",
13223 vty_out(vty
, " Neighbor capabilities:\n");
13226 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
13227 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13228 vty_out(vty
, " 4 Byte AS:");
13229 if (CHECK_FLAG(p
->cap
,
13231 vty_out(vty
, " advertised");
13232 if (CHECK_FLAG(p
->cap
,
13234 vty_out(vty
, " %sreceived",
13240 vty_out(vty
, "\n");
13244 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
13245 || CHECK_FLAG(p
->cap
,
13246 PEER_CAP_ADDPATH_ADV
)) {
13247 vty_out(vty
, " AddPath:\n");
13249 FOREACH_AFI_SAFI (afi
, safi
) {
13253 PEER_CAP_ADDPATH_AF_TX_ADV
)
13257 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13269 PEER_CAP_ADDPATH_AF_TX_ADV
))
13281 PEER_CAP_ADDPATH_AF_TX_RCV
))
13288 PEER_CAP_ADDPATH_AF_TX_ADV
)
13292 vty_out(vty
, "\n");
13298 PEER_CAP_ADDPATH_AF_RX_ADV
)
13302 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13314 PEER_CAP_ADDPATH_AF_RX_ADV
))
13326 PEER_CAP_ADDPATH_AF_RX_RCV
))
13333 PEER_CAP_ADDPATH_AF_RX_ADV
)
13337 vty_out(vty
, "\n");
13343 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
13344 || CHECK_FLAG(p
->cap
,
13345 PEER_CAP_DYNAMIC_ADV
)) {
13346 vty_out(vty
, " Dynamic:");
13347 if (CHECK_FLAG(p
->cap
,
13348 PEER_CAP_DYNAMIC_ADV
))
13349 vty_out(vty
, " advertised");
13350 if (CHECK_FLAG(p
->cap
,
13351 PEER_CAP_DYNAMIC_RCV
))
13352 vty_out(vty
, " %sreceived",
13355 PEER_CAP_DYNAMIC_ADV
)
13358 vty_out(vty
, "\n");
13361 /* Extended nexthop */
13362 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
13363 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13364 vty_out(vty
, " Extended nexthop:");
13365 if (CHECK_FLAG(p
->cap
,
13366 PEER_CAP_ENHE_ADV
))
13367 vty_out(vty
, " advertised");
13368 if (CHECK_FLAG(p
->cap
,
13369 PEER_CAP_ENHE_RCV
))
13370 vty_out(vty
, " %sreceived",
13376 vty_out(vty
, "\n");
13378 if (CHECK_FLAG(p
->cap
,
13379 PEER_CAP_ENHE_RCV
)) {
13381 " Address families by peer:\n ");
13382 for (safi
= SAFI_UNICAST
;
13383 safi
< SAFI_MAX
; safi
++)
13388 PEER_CAP_ENHE_AF_RCV
))
13398 /* Route Refresh */
13399 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
13400 || CHECK_FLAG(p
->cap
,
13401 PEER_CAP_REFRESH_NEW_RCV
)
13402 || CHECK_FLAG(p
->cap
,
13403 PEER_CAP_REFRESH_OLD_RCV
)) {
13404 vty_out(vty
, " Route refresh:");
13405 if (CHECK_FLAG(p
->cap
,
13406 PEER_CAP_REFRESH_ADV
))
13407 vty_out(vty
, " advertised");
13408 if (CHECK_FLAG(p
->cap
,
13409 PEER_CAP_REFRESH_NEW_RCV
)
13412 PEER_CAP_REFRESH_OLD_RCV
))
13413 vty_out(vty
, " %sreceived(%s)",
13416 PEER_CAP_REFRESH_ADV
)
13421 PEER_CAP_REFRESH_OLD_RCV
)
13424 PEER_CAP_REFRESH_NEW_RCV
))
13428 PEER_CAP_REFRESH_OLD_RCV
)
13432 vty_out(vty
, "\n");
13435 /* Multiprotocol Extensions */
13436 FOREACH_AFI_SAFI (afi
, safi
)
13437 if (p
->afc_adv
[afi
][safi
]
13438 || p
->afc_recv
[afi
][safi
]) {
13440 " Address Family %s:",
13445 if (p
->afc_adv
[afi
][safi
])
13448 if (p
->afc_recv
[afi
][safi
])
13455 vty_out(vty
, "\n");
13458 /* Hostname capability */
13459 vty_out(vty
, " Hostname Capability:");
13461 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13463 " advertised (name: %s,domain name: %s)",
13464 bgp
->peer_self
->hostname
13468 bgp
->peer_self
->domainname
13473 vty_out(vty
, " not advertised");
13476 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13478 " received (name: %s,domain name: %s)",
13479 p
->hostname
? p
->hostname
13481 p
->domainname
? p
->domainname
13484 vty_out(vty
, " not received");
13487 vty_out(vty
, "\n");
13489 /* Graceful Restart */
13490 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
13491 || CHECK_FLAG(p
->cap
,
13492 PEER_CAP_RESTART_ADV
)) {
13494 " Graceful Restart Capability:");
13495 if (CHECK_FLAG(p
->cap
,
13496 PEER_CAP_RESTART_ADV
))
13497 vty_out(vty
, " advertised");
13498 if (CHECK_FLAG(p
->cap
,
13499 PEER_CAP_RESTART_RCV
))
13500 vty_out(vty
, " %sreceived",
13503 PEER_CAP_RESTART_ADV
)
13506 vty_out(vty
, "\n");
13508 if (CHECK_FLAG(p
->cap
,
13509 PEER_CAP_RESTART_RCV
)) {
13510 int restart_af_count
= 0;
13513 " Remote Restart timer is %d seconds\n",
13516 " Address families by peer:\n ");
13518 FOREACH_AFI_SAFI (afi
, safi
)
13523 PEER_CAP_RESTART_AF_RCV
)) {
13537 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13539 : "not preserved");
13540 restart_af_count
++;
13542 if (!restart_af_count
)
13543 vty_out(vty
, "none");
13544 vty_out(vty
, "\n");
13546 } /* Gracefull Restart */
13551 /* graceful restart information */
13552 json_object
*json_grace
= NULL
;
13553 json_object
*json_grace_send
= NULL
;
13554 json_object
*json_grace_recv
= NULL
;
13555 int eor_send_af_count
= 0;
13556 int eor_receive_af_count
= 0;
13559 json_grace
= json_object_new_object();
13560 json_grace_send
= json_object_new_object();
13561 json_grace_recv
= json_object_new_object();
13563 if ((p
->status
== Established
)
13564 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13565 FOREACH_AFI_SAFI (afi
, safi
) {
13566 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13567 PEER_STATUS_EOR_SEND
)) {
13568 json_object_boolean_true_add(
13570 get_afi_safi_str(afi
,
13573 eor_send_af_count
++;
13576 FOREACH_AFI_SAFI (afi
, safi
) {
13578 p
->af_sflags
[afi
][safi
],
13579 PEER_STATUS_EOR_RECEIVED
)) {
13580 json_object_boolean_true_add(
13582 get_afi_safi_str(afi
,
13585 eor_receive_af_count
++;
13589 json_object_object_add(json_grace
, "endOfRibSend",
13591 json_object_object_add(json_grace
, "endOfRibRecv",
13595 if (p
->t_gr_restart
)
13596 json_object_int_add(json_grace
,
13597 "gracefulRestartTimerMsecs",
13598 thread_timer_remain_second(
13603 json_object_int_add(
13605 "gracefulStalepathTimerMsecs",
13606 thread_timer_remain_second(
13609 /* more gr info in new format */
13610 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
,
13612 json_object_object_add(
13613 json_neigh
, "gracefulRestartInfo", json_grace
);
13615 vty_out(vty
, " Graceful restart information:\n");
13616 if ((p
->status
== Established
)
13617 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13619 vty_out(vty
, " End-of-RIB send: ");
13620 FOREACH_AFI_SAFI (afi
, safi
) {
13621 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13622 PEER_STATUS_EOR_SEND
)) {
13623 vty_out(vty
, "%s%s",
13624 eor_send_af_count
? ", "
13629 eor_send_af_count
++;
13632 vty_out(vty
, "\n");
13633 vty_out(vty
, " End-of-RIB received: ");
13634 FOREACH_AFI_SAFI (afi
, safi
) {
13636 p
->af_sflags
[afi
][safi
],
13637 PEER_STATUS_EOR_RECEIVED
)) {
13638 vty_out(vty
, "%s%s",
13639 eor_receive_af_count
13642 get_afi_safi_str(afi
,
13645 eor_receive_af_count
++;
13648 vty_out(vty
, "\n");
13651 if (p
->t_gr_restart
)
13653 " The remaining time of restart timer is %ld\n",
13654 thread_timer_remain_second(
13659 " The remaining time of stalepath timer is %ld\n",
13660 thread_timer_remain_second(
13663 /* more gr info in new format */
13664 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
13668 json_object
*json_stat
= NULL
;
13669 json_stat
= json_object_new_object();
13670 /* Packet counts. */
13672 atomic_size_t outq_count
, inq_count
;
13673 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13674 memory_order_relaxed
);
13675 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13676 memory_order_relaxed
);
13678 json_object_int_add(json_stat
, "depthInq",
13679 (unsigned long)inq_count
);
13680 json_object_int_add(json_stat
, "depthOutq",
13681 (unsigned long)outq_count
);
13682 json_object_int_add(json_stat
, "opensSent",
13683 atomic_load_explicit(&p
->open_out
,
13684 memory_order_relaxed
));
13685 json_object_int_add(json_stat
, "opensRecv",
13686 atomic_load_explicit(&p
->open_in
,
13687 memory_order_relaxed
));
13688 json_object_int_add(json_stat
, "notificationsSent",
13689 atomic_load_explicit(&p
->notify_out
,
13690 memory_order_relaxed
));
13691 json_object_int_add(json_stat
, "notificationsRecv",
13692 atomic_load_explicit(&p
->notify_in
,
13693 memory_order_relaxed
));
13694 json_object_int_add(json_stat
, "updatesSent",
13695 atomic_load_explicit(&p
->update_out
,
13696 memory_order_relaxed
));
13697 json_object_int_add(json_stat
, "updatesRecv",
13698 atomic_load_explicit(&p
->update_in
,
13699 memory_order_relaxed
));
13700 json_object_int_add(json_stat
, "keepalivesSent",
13701 atomic_load_explicit(&p
->keepalive_out
,
13702 memory_order_relaxed
));
13703 json_object_int_add(json_stat
, "keepalivesRecv",
13704 atomic_load_explicit(&p
->keepalive_in
,
13705 memory_order_relaxed
));
13706 json_object_int_add(json_stat
, "routeRefreshSent",
13707 atomic_load_explicit(&p
->refresh_out
,
13708 memory_order_relaxed
));
13709 json_object_int_add(json_stat
, "routeRefreshRecv",
13710 atomic_load_explicit(&p
->refresh_in
,
13711 memory_order_relaxed
));
13712 json_object_int_add(json_stat
, "capabilitySent",
13713 atomic_load_explicit(&p
->dynamic_cap_out
,
13714 memory_order_relaxed
));
13715 json_object_int_add(json_stat
, "capabilityRecv",
13716 atomic_load_explicit(&p
->dynamic_cap_in
,
13717 memory_order_relaxed
));
13718 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
13719 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
13720 json_object_object_add(json_neigh
, "messageStats", json_stat
);
13722 atomic_size_t outq_count
, inq_count
;
13723 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13724 memory_order_relaxed
);
13725 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13726 memory_order_relaxed
);
13728 /* Packet counts. */
13729 vty_out(vty
, " Message statistics:\n");
13730 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
13731 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
13732 vty_out(vty
, " Sent Rcvd\n");
13733 vty_out(vty
, " Opens: %10d %10d\n",
13734 atomic_load_explicit(&p
->open_out
,
13735 memory_order_relaxed
),
13736 atomic_load_explicit(&p
->open_in
,
13737 memory_order_relaxed
));
13738 vty_out(vty
, " Notifications: %10d %10d\n",
13739 atomic_load_explicit(&p
->notify_out
,
13740 memory_order_relaxed
),
13741 atomic_load_explicit(&p
->notify_in
,
13742 memory_order_relaxed
));
13743 vty_out(vty
, " Updates: %10d %10d\n",
13744 atomic_load_explicit(&p
->update_out
,
13745 memory_order_relaxed
),
13746 atomic_load_explicit(&p
->update_in
,
13747 memory_order_relaxed
));
13748 vty_out(vty
, " Keepalives: %10d %10d\n",
13749 atomic_load_explicit(&p
->keepalive_out
,
13750 memory_order_relaxed
),
13751 atomic_load_explicit(&p
->keepalive_in
,
13752 memory_order_relaxed
));
13753 vty_out(vty
, " Route Refresh: %10d %10d\n",
13754 atomic_load_explicit(&p
->refresh_out
,
13755 memory_order_relaxed
),
13756 atomic_load_explicit(&p
->refresh_in
,
13757 memory_order_relaxed
));
13758 vty_out(vty
, " Capability: %10d %10d\n",
13759 atomic_load_explicit(&p
->dynamic_cap_out
,
13760 memory_order_relaxed
),
13761 atomic_load_explicit(&p
->dynamic_cap_in
,
13762 memory_order_relaxed
));
13763 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
13768 /* advertisement-interval */
13769 json_object_int_add(json_neigh
,
13770 "minBtwnAdvertisementRunsTimerMsecs",
13771 p
->v_routeadv
* 1000);
13773 /* Update-source. */
13774 if (p
->update_if
|| p
->update_source
) {
13776 json_object_string_add(json_neigh
,
13779 else if (p
->update_source
)
13780 json_object_string_add(
13781 json_neigh
, "updateSource",
13782 sockunion2str(p
->update_source
, buf1
,
13786 /* advertisement-interval */
13788 " Minimum time between advertisement runs is %d seconds\n",
13791 /* Update-source. */
13792 if (p
->update_if
|| p
->update_source
) {
13793 vty_out(vty
, " Update source is ");
13795 vty_out(vty
, "%s", p
->update_if
);
13796 else if (p
->update_source
)
13798 sockunion2str(p
->update_source
, buf1
,
13800 vty_out(vty
, "\n");
13803 vty_out(vty
, "\n");
13806 /* Address Family Information */
13807 json_object
*json_hold
= NULL
;
13810 json_hold
= json_object_new_object();
13812 FOREACH_AFI_SAFI (afi
, safi
)
13813 if (p
->afc
[afi
][safi
])
13814 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
13818 json_object_object_add(json_neigh
, "addressFamilyInfo",
13820 json_object_int_add(json_neigh
, "connectionsEstablished",
13822 json_object_int_add(json_neigh
, "connectionsDropped",
13825 vty_out(vty
, " Connections established %d; dropped %d\n",
13826 p
->established
, p
->dropped
);
13828 if (!p
->last_reset
) {
13830 json_object_string_add(json_neigh
, "lastReset",
13833 vty_out(vty
, " Last reset never\n");
13839 uptime
= bgp_clock();
13840 uptime
-= p
->resettime
;
13841 gmtime_r(&uptime
, &tm
);
13843 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
13845 + (tm
.tm_min
* 60000)
13846 + (tm
.tm_hour
* 3600000));
13847 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
13849 vty_out(vty
, " Last reset %s, ",
13850 peer_uptime(p
->resettime
, timebuf
,
13851 BGP_UPTIME_LEN
, 0, NULL
));
13853 bgp_show_peer_reset(vty
, p
, NULL
, false);
13854 if (p
->last_reset_cause_size
) {
13855 msg
= p
->last_reset_cause
;
13857 " Message received that caused BGP to send a NOTIFICATION:\n ");
13858 for (i
= 1; i
<= p
->last_reset_cause_size
;
13860 vty_out(vty
, "%02X", *msg
++);
13862 if (i
!= p
->last_reset_cause_size
) {
13864 vty_out(vty
, "\n ");
13865 } else if (i
% 4 == 0) {
13870 vty_out(vty
, "\n");
13875 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
13877 json_object_boolean_true_add(json_neigh
,
13878 "prefixesConfigExceedMax");
13881 " Peer had exceeded the max. no. of prefixes configured.\n");
13883 if (p
->t_pmax_restart
) {
13885 json_object_boolean_true_add(
13886 json_neigh
, "reducePrefixNumFrom");
13887 json_object_int_add(json_neigh
,
13888 "restartInTimerMsec",
13889 thread_timer_remain_second(
13894 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
13895 p
->host
, thread_timer_remain_second(
13896 p
->t_pmax_restart
));
13899 json_object_boolean_true_add(
13901 "reducePrefixNumAndClearIpBgp");
13904 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
13909 /* EBGP Multihop and GTSM */
13910 if (p
->sort
!= BGP_PEER_IBGP
) {
13912 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
13913 json_object_int_add(json_neigh
,
13914 "externalBgpNbrMaxHopsAway",
13916 else if (p
->ttl
> BGP_DEFAULT_TTL
)
13917 json_object_int_add(json_neigh
,
13918 "externalBgpNbrMaxHopsAway",
13921 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
13923 " External BGP neighbor may be up to %d hops away.\n",
13925 else if (p
->ttl
> BGP_DEFAULT_TTL
)
13927 " External BGP neighbor may be up to %d hops away.\n",
13931 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
) {
13933 json_object_int_add(json_neigh
,
13934 "internalBgpNbrMaxHopsAway",
13938 " Internal BGP neighbor may be up to %d hops away.\n",
13943 /* Local address. */
13946 json_object_string_add(json_neigh
, "hostLocal",
13947 sockunion2str(p
->su_local
, buf1
,
13949 json_object_int_add(json_neigh
, "portLocal",
13950 ntohs(p
->su_local
->sin
.sin_port
));
13952 vty_out(vty
, "Local host: %s, Local port: %d\n",
13953 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
13954 ntohs(p
->su_local
->sin
.sin_port
));
13957 /* Remote address. */
13958 if (p
->su_remote
) {
13960 json_object_string_add(json_neigh
, "hostForeign",
13961 sockunion2str(p
->su_remote
, buf1
,
13963 json_object_int_add(json_neigh
, "portForeign",
13964 ntohs(p
->su_remote
->sin
.sin_port
));
13966 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
13967 sockunion2str(p
->su_remote
, buf1
,
13969 ntohs(p
->su_remote
->sin
.sin_port
));
13972 /* Nexthop display. */
13975 json_object_string_add(json_neigh
, "nexthop",
13977 &p
->nexthop
.v4
, buf1
,
13979 json_object_string_add(json_neigh
, "nexthopGlobal",
13980 inet_ntop(AF_INET6
,
13981 &p
->nexthop
.v6_global
,
13982 buf1
, sizeof(buf1
)));
13983 json_object_string_add(json_neigh
, "nexthopLocal",
13984 inet_ntop(AF_INET6
,
13985 &p
->nexthop
.v6_local
,
13986 buf1
, sizeof(buf1
)));
13987 if (p
->shared_network
)
13988 json_object_string_add(json_neigh
,
13992 json_object_string_add(json_neigh
,
13994 "nonSharedNetwork");
13996 vty_out(vty
, "Nexthop: %s\n",
13997 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
13999 vty_out(vty
, "Nexthop global: %s\n",
14000 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
14002 vty_out(vty
, "Nexthop local: %s\n",
14003 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
14005 vty_out(vty
, "BGP connection: %s\n",
14006 p
->shared_network
? "shared network"
14007 : "non shared network");
14011 /* Timer information. */
14013 json_object_int_add(json_neigh
, "connectRetryTimer",
14015 if (p
->status
== Established
&& p
->rtt
)
14016 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14019 json_object_int_add(
14020 json_neigh
, "nextStartTimerDueInMsecs",
14021 thread_timer_remain_second(p
->t_start
) * 1000);
14023 json_object_int_add(
14024 json_neigh
, "nextConnectTimerDueInMsecs",
14025 thread_timer_remain_second(p
->t_connect
)
14027 if (p
->t_routeadv
) {
14028 json_object_int_add(json_neigh
, "mraiInterval",
14030 json_object_int_add(
14031 json_neigh
, "mraiTimerExpireInMsecs",
14032 thread_timer_remain_second(p
->t_routeadv
)
14036 json_object_int_add(json_neigh
, "authenticationEnabled",
14040 json_object_string_add(json_neigh
, "readThread", "on");
14042 json_object_string_add(json_neigh
, "readThread", "off");
14044 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14045 json_object_string_add(json_neigh
, "writeThread", "on");
14047 json_object_string_add(json_neigh
, "writeThread",
14050 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14052 if (p
->status
== Established
&& p
->rtt
)
14053 vty_out(vty
, "Estimated round trip time: %d ms\n",
14056 vty_out(vty
, "Next start timer due in %ld seconds\n",
14057 thread_timer_remain_second(p
->t_start
));
14059 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14060 thread_timer_remain_second(p
->t_connect
));
14063 "MRAI (interval %u) timer expires in %ld seconds\n",
14065 thread_timer_remain_second(p
->t_routeadv
));
14067 vty_out(vty
, "Peer Authentication Enabled\n");
14069 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14070 p
->t_read
? "on" : "off",
14071 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14076 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14077 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14078 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14081 vty_out(vty
, "\n");
14083 /* BFD information. */
14084 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
14087 if (p
->conf_if
) /* Configured interface name. */
14088 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14089 else /* Configured IP address. */
14090 json_object_object_add(json
, p
->host
, json_neigh
);
14094 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14095 enum show_type type
,
14096 union sockunion
*su
,
14097 const char *conf_if
, afi_t afi
,
14100 struct listnode
*node
, *nnode
;
14103 safi_t safi
= SAFI_UNICAST
;
14104 json_object
*json
= NULL
;
14105 json_object
*json_neighbor
= NULL
;
14108 json
= json_object_new_object();
14109 json_neighbor
= json_object_new_object();
14112 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14114 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14117 if ((peer
->afc
[afi
][safi
]) == 0)
14120 if (type
== show_all
) {
14121 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14125 json_object_object_add(json
, peer
->host
,
14127 json_neighbor
= NULL
;
14130 } else if (type
== show_peer
) {
14133 && !strcmp(peer
->conf_if
, conf_if
))
14135 && !strcmp(peer
->hostname
, conf_if
))) {
14137 bgp_show_peer_gr_status(vty
, peer
,
14142 if (sockunion_same(&peer
->su
, su
)) {
14144 bgp_show_peer_gr_status(vty
, peer
,
14149 if (use_json
&& find
)
14150 json_object_object_add(json
, peer
->host
,
14155 json_neighbor
= NULL
;
14160 if (type
== show_peer
&& !find
) {
14162 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14164 vty_out(vty
, "%% No such neighbor\n");
14167 vty_out(vty
, "%s\n",
14168 json_object_to_json_string_ext(
14169 json
, JSON_C_TO_STRING_PRETTY
));
14172 json_object_free(json_neighbor
);
14173 json_object_free(json
);
14175 vty_out(vty
, "\n");
14178 return CMD_SUCCESS
;
14181 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14182 enum show_type type
, union sockunion
*su
,
14183 const char *conf_if
, bool use_json
,
14186 struct listnode
*node
, *nnode
;
14189 bool nbr_output
= false;
14190 afi_t afi
= AFI_MAX
;
14191 safi_t safi
= SAFI_MAX
;
14193 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14195 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14199 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14200 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14205 bgp_show_peer(vty
, peer
, use_json
, json
);
14211 && !strcmp(peer
->conf_if
, conf_if
))
14213 && !strcmp(peer
->hostname
, conf_if
))) {
14215 bgp_show_peer(vty
, peer
, use_json
,
14219 if (sockunion_same(&peer
->su
, su
)) {
14221 bgp_show_peer(vty
, peer
, use_json
,
14226 case show_ipv4_peer
:
14227 case show_ipv6_peer
:
14228 FOREACH_SAFI (safi
) {
14229 if (peer
->afc
[afi
][safi
]) {
14232 && !strcmp(peer
->conf_if
, conf_if
))
14234 && !strcmp(peer
->hostname
, conf_if
))) {
14236 bgp_show_peer(vty
, peer
, use_json
,
14241 if (sockunion_same(&peer
->su
, su
)) {
14243 bgp_show_peer(vty
, peer
, use_json
,
14251 case show_ipv4_all
:
14252 case show_ipv6_all
:
14253 FOREACH_SAFI (safi
) {
14254 if (peer
->afc
[afi
][safi
]) {
14255 bgp_show_peer(vty
, peer
, use_json
, json
);
14264 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14265 type
== show_ipv6_peer
) && !find
) {
14267 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14269 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14272 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14273 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14274 vty_out(vty
, "%% No BGP neighbors found\n");
14277 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14278 json
, JSON_C_TO_STRING_PRETTY
));
14280 vty_out(vty
, "\n");
14283 return CMD_SUCCESS
;
14286 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14287 enum show_type type
,
14288 const char *ip_str
,
14289 afi_t afi
, bool use_json
)
14294 union sockunion su
;
14296 bgp
= bgp_get_default();
14302 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14306 ret
= str2sockunion(ip_str
, &su
);
14308 bgp_show_neighbor_graceful_restart(
14309 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14311 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14312 NULL
, afi
, use_json
);
14314 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14318 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14319 enum show_type type
,
14320 const char *ip_str
,
14323 struct listnode
*node
, *nnode
;
14325 union sockunion su
;
14326 json_object
*json
= NULL
;
14327 int ret
, is_first
= 1;
14328 bool nbr_output
= false;
14331 vty_out(vty
, "{\n");
14333 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14336 if (!(json
= json_object_new_object())) {
14338 EC_BGP_JSON_MEM_ERROR
,
14339 "Unable to allocate memory for JSON object");
14341 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14345 json_object_int_add(json
, "vrfId",
14346 (bgp
->vrf_id
== VRF_UNKNOWN
)
14348 : (int64_t)bgp
->vrf_id
);
14349 json_object_string_add(
14351 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14356 vty_out(vty
, ",\n");
14360 vty_out(vty
, "\"%s\":",
14361 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14365 vty_out(vty
, "\nInstance %s:\n",
14366 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14371 if (type
== show_peer
|| type
== show_ipv4_peer
||
14372 type
== show_ipv6_peer
) {
14373 ret
= str2sockunion(ip_str
, &su
);
14375 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14378 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14381 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14384 json_object_free(json
);
14389 vty_out(vty
, "}\n");
14390 else if (!nbr_output
)
14391 vty_out(vty
, "%% BGP instance not found\n");
14394 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14395 enum show_type type
, const char *ip_str
,
14400 union sockunion su
;
14401 json_object
*json
= NULL
;
14404 if (strmatch(name
, "all")) {
14405 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14407 return CMD_SUCCESS
;
14409 bgp
= bgp_lookup_by_name(name
);
14412 json
= json_object_new_object();
14413 vty_out(vty
, "%s\n",
14414 json_object_to_json_string_ext(
14416 JSON_C_TO_STRING_PRETTY
));
14417 json_object_free(json
);
14420 "%% BGP instance not found\n");
14422 return CMD_WARNING
;
14426 bgp
= bgp_get_default();
14430 json
= json_object_new_object();
14432 ret
= str2sockunion(ip_str
, &su
);
14434 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14437 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14440 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14443 json_object_free(json
);
14446 vty_out(vty
, "{}\n");
14448 vty_out(vty
, "%% BGP instance not found\n");
14451 return CMD_SUCCESS
;
14456 /* "show [ip] bgp neighbors graceful-restart" commands. */
14457 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
14458 show_ip_bgp_neighbors_graceful_restart_cmd
,
14459 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14465 "Neighbor to display information about\n"
14466 "Neighbor to display information about\n"
14467 "Neighbor on BGP configured interface\n"
14471 char *sh_arg
= NULL
;
14472 enum show_type sh_type
;
14474 afi_t afi
= AFI_MAX
;
14475 bool uj
= use_json(argc
, argv
);
14477 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14482 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14483 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14484 || argv_find(argv
, argc
, "WORD", &idx
)) {
14485 sh_type
= show_peer
;
14486 sh_arg
= argv
[idx
]->arg
;
14488 sh_type
= show_all
;
14490 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14491 return CMD_SUCCESS
;
14494 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14498 /* "show [ip] bgp neighbors" commands. */
14499 DEFUN (show_ip_bgp_neighbors
,
14500 show_ip_bgp_neighbors_cmd
,
14501 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14505 BGP_INSTANCE_HELP_STR
14508 "Detailed information on TCP and BGP neighbor connections\n"
14509 "Neighbor to display information about\n"
14510 "Neighbor to display information about\n"
14511 "Neighbor on BGP configured interface\n"
14515 char *sh_arg
= NULL
;
14516 enum show_type sh_type
;
14517 afi_t afi
= AFI_MAX
;
14519 bool uj
= use_json(argc
, argv
);
14523 /* [<vrf> VIEWVRFNAME] */
14524 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14525 vrf
= argv
[idx
+ 1]->arg
;
14526 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14528 } else if (argv_find(argv
, argc
, "view", &idx
))
14529 /* [<view> VIEWVRFNAME] */
14530 vrf
= argv
[idx
+ 1]->arg
;
14534 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14535 sh_type
= show_ipv4_all
;
14537 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14538 sh_type
= show_ipv6_all
;
14541 sh_type
= show_all
;
14544 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14545 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14546 || argv_find(argv
, argc
, "WORD", &idx
)) {
14547 sh_type
= show_peer
;
14548 sh_arg
= argv
[idx
]->arg
;
14551 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14552 sh_type
= show_ipv4_peer
;
14553 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14554 sh_type
= show_ipv6_peer
;
14557 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14560 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14561 paths' and `show ip mbgp paths'. Those functions results are the
14563 DEFUN (show_ip_bgp_paths
,
14564 show_ip_bgp_paths_cmd
,
14565 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14570 "Path information\n")
14572 vty_out(vty
, "Address Refcnt Path\n");
14573 aspath_print_all_vty(vty
);
14574 return CMD_SUCCESS
;
14579 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14582 struct community
*com
;
14584 com
= (struct community
*)bucket
->data
;
14585 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14586 community_str(com
, false));
14589 /* Show BGP's community internal data. */
14590 DEFUN (show_ip_bgp_community_info
,
14591 show_ip_bgp_community_info_cmd
,
14592 "show [ip] bgp community-info",
14596 "List all bgp community information\n")
14598 vty_out(vty
, "Address Refcnt Community\n");
14600 hash_iterate(community_hash(),
14601 (void (*)(struct hash_bucket
*,
14602 void *))community_show_all_iterator
,
14605 return CMD_SUCCESS
;
14608 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14611 struct lcommunity
*lcom
;
14613 lcom
= (struct lcommunity
*)bucket
->data
;
14614 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14615 lcommunity_str(lcom
, false));
14618 /* Show BGP's community internal data. */
14619 DEFUN (show_ip_bgp_lcommunity_info
,
14620 show_ip_bgp_lcommunity_info_cmd
,
14621 "show ip bgp large-community-info",
14625 "List all bgp large-community information\n")
14627 vty_out(vty
, "Address Refcnt Large-community\n");
14629 hash_iterate(lcommunity_hash(),
14630 (void (*)(struct hash_bucket
*,
14631 void *))lcommunity_show_all_iterator
,
14634 return CMD_SUCCESS
;
14636 /* Graceful Restart */
14638 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
14645 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
14647 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
14649 switch (bgp_global_gr_mode
) {
14651 case GLOBAL_HELPER
:
14652 vty_out(vty
, "Global BGP GR Mode : Helper\n");
14656 vty_out(vty
, "Global BGP GR Mode : Restart\n");
14659 case GLOBAL_DISABLE
:
14660 vty_out(vty
, "Global BGP GR Mode : Disable\n");
14663 case GLOBAL_INVALID
:
14665 "Global BGP GR Mode Invalid\n");
14668 vty_out(vty
, "\n");
14671 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
14672 enum show_type type
,
14673 const char *ip_str
,
14674 afi_t afi
, bool use_json
)
14676 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
14679 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
14681 bgp_show_neighbor_graceful_restart_vty(
14682 vty
, type
, ip_str
, afi
, use_json
);
14685 } else if (afi
!= AFI_MAX
) {
14686 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
14689 return CMD_ERR_INCOMPLETE
;
14692 return CMD_SUCCESS
;
14694 /* Graceful Restart */
14696 DEFUN (show_ip_bgp_attr_info
,
14697 show_ip_bgp_attr_info_cmd
,
14698 "show [ip] bgp attribute-info",
14702 "List all bgp attribute information\n")
14704 attr_show_all(vty
);
14705 return CMD_SUCCESS
;
14708 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
14709 afi_t afi
, safi_t safi
,
14710 bool use_json
, json_object
*json
)
14713 struct listnode
*node
;
14715 char buf1
[INET6_ADDRSTRLEN
];
14717 vpn_policy_direction_t dir
;
14720 json_object
*json_import_vrfs
= NULL
;
14721 json_object
*json_export_vrfs
= NULL
;
14723 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14726 vty_out(vty
, "%s\n",
14727 json_object_to_json_string_ext(
14729 JSON_C_TO_STRING_PRETTY
));
14730 json_object_free(json
);
14732 return CMD_WARNING
;
14735 /* Provide context for the block */
14736 json_object_string_add(json
, "vrf", name
? name
: "default");
14737 json_object_string_add(json
, "afiSafi",
14738 get_afi_safi_str(afi
, safi
, true));
14740 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14741 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
14742 json_object_string_add(json
, "importFromVrfs", "none");
14743 json_object_string_add(json
, "importRts", "none");
14745 json_import_vrfs
= json_object_new_array();
14747 for (ALL_LIST_ELEMENTS_RO(
14748 bgp
->vpn_policy
[afi
].import_vrf
,
14750 json_object_array_add(json_import_vrfs
,
14751 json_object_new_string(vname
));
14753 json_object_object_add(json
, "importFromVrfs",
14755 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14756 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14757 ecom_str
= ecommunity_ecom2str(
14758 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14759 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14760 json_object_string_add(json
, "importRts",
14762 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14764 json_object_string_add(json
, "importRts",
14768 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14769 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
14770 json_object_string_add(json
, "exportToVrfs", "none");
14771 json_object_string_add(json
, "routeDistinguisher",
14773 json_object_string_add(json
, "exportRts", "none");
14775 json_export_vrfs
= json_object_new_array();
14777 for (ALL_LIST_ELEMENTS_RO(
14778 bgp
->vpn_policy
[afi
].export_vrf
,
14780 json_object_array_add(json_export_vrfs
,
14781 json_object_new_string(vname
));
14782 json_object_object_add(json
, "exportToVrfs",
14784 json_object_string_add(json
, "routeDistinguisher",
14785 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
14786 buf1
, RD_ADDRSTRLEN
));
14788 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
14789 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14790 ecom_str
= ecommunity_ecom2str(
14791 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14792 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14793 json_object_string_add(json
, "exportRts",
14795 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14797 json_object_string_add(json
, "exportRts",
14802 vty_out(vty
, "%s\n",
14803 json_object_to_json_string_ext(json
,
14804 JSON_C_TO_STRING_PRETTY
));
14805 json_object_free(json
);
14808 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14811 vty_out(vty
, "%% No such BGP instance exist\n");
14812 return CMD_WARNING
;
14815 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14816 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
14818 "This VRF is not importing %s routes from any other VRF\n",
14819 get_afi_safi_str(afi
, safi
, false));
14822 "This VRF is importing %s routes from the following VRFs:\n",
14823 get_afi_safi_str(afi
, safi
, false));
14825 for (ALL_LIST_ELEMENTS_RO(
14826 bgp
->vpn_policy
[afi
].import_vrf
,
14828 vty_out(vty
, " %s\n", vname
);
14830 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14832 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14833 ecom_str
= ecommunity_ecom2str(
14834 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14835 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14836 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
14838 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14840 vty_out(vty
, "Import RT(s):\n");
14843 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14844 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
14846 "This VRF is not exporting %s routes to any other VRF\n",
14847 get_afi_safi_str(afi
, safi
, false));
14850 "This VRF is exporting %s routes to the following VRFs:\n",
14851 get_afi_safi_str(afi
, safi
, false));
14853 for (ALL_LIST_ELEMENTS_RO(
14854 bgp
->vpn_policy
[afi
].export_vrf
,
14856 vty_out(vty
, " %s\n", vname
);
14858 vty_out(vty
, "RD: %s\n",
14859 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
14860 buf1
, RD_ADDRSTRLEN
));
14862 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
14863 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14864 ecom_str
= ecommunity_ecom2str(
14865 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14866 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14867 vty_out(vty
, "Export RT: %s\n", ecom_str
);
14868 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14870 vty_out(vty
, "Import RT(s):\n");
14874 return CMD_SUCCESS
;
14877 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
14878 safi_t safi
, bool use_json
)
14880 struct listnode
*node
, *nnode
;
14882 char *vrf_name
= NULL
;
14883 json_object
*json
= NULL
;
14884 json_object
*json_vrf
= NULL
;
14885 json_object
*json_vrfs
= NULL
;
14888 json
= json_object_new_object();
14889 json_vrfs
= json_object_new_object();
14892 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14894 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
14895 vrf_name
= bgp
->name
;
14898 json_vrf
= json_object_new_object();
14900 vty_out(vty
, "\nInstance %s:\n",
14901 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14902 ? VRF_DEFAULT_NAME
: bgp
->name
);
14904 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
14906 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14907 json_object_object_add(json_vrfs
,
14908 VRF_DEFAULT_NAME
, json_vrf
);
14910 json_object_object_add(json_vrfs
, vrf_name
,
14916 json_object_object_add(json
, "vrfs", json_vrfs
);
14917 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
14918 JSON_C_TO_STRING_PRETTY
));
14919 json_object_free(json
);
14922 return CMD_SUCCESS
;
14925 /* "show [ip] bgp route-leak" command. */
14926 DEFUN (show_ip_bgp_route_leak
,
14927 show_ip_bgp_route_leak_cmd
,
14928 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
14932 BGP_INSTANCE_HELP_STR
14935 "Route leaking information\n"
14939 afi_t afi
= AFI_MAX
;
14940 safi_t safi
= SAFI_MAX
;
14942 bool uj
= use_json(argc
, argv
);
14944 json_object
*json
= NULL
;
14946 /* show [ip] bgp */
14947 if (argv_find(argv
, argc
, "ip", &idx
)) {
14949 safi
= SAFI_UNICAST
;
14951 /* [vrf VIEWVRFNAME] */
14952 if (argv_find(argv
, argc
, "view", &idx
)) {
14954 "%% This command is not applicable to BGP views\n");
14955 return CMD_WARNING
;
14958 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14959 vrf
= argv
[idx
+ 1]->arg
;
14960 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14963 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
14964 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
14965 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
14968 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
14970 "%% This command is applicable only for unicast ipv4|ipv6\n");
14971 return CMD_WARNING
;
14974 if (vrf
&& strmatch(vrf
, "all"))
14975 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
14978 json
= json_object_new_object();
14980 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
14983 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
14986 struct listnode
*node
, *nnode
;
14989 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14990 vty_out(vty
, "\nInstance %s:\n",
14991 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14994 update_group_show(bgp
, afi
, safi
, vty
, 0);
14998 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
14999 int safi
, uint64_t subgrp_id
)
15004 if (strmatch(name
, "all")) {
15005 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
15006 return CMD_SUCCESS
;
15008 bgp
= bgp_lookup_by_name(name
);
15011 bgp
= bgp_get_default();
15015 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
15016 return CMD_SUCCESS
;
15019 DEFUN (show_ip_bgp_updgrps
,
15020 show_ip_bgp_updgrps_cmd
,
15021 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
15025 BGP_INSTANCE_HELP_STR
15027 BGP_SAFI_WITH_LABEL_HELP_STR
15028 "Detailed info about dynamic update groups\n"
15029 "Specific subgroup to display detailed info for\n")
15032 afi_t afi
= AFI_IP6
;
15033 safi_t safi
= SAFI_UNICAST
;
15034 uint64_t subgrp_id
= 0;
15038 /* show [ip] bgp */
15039 if (argv_find(argv
, argc
, "ip", &idx
))
15041 /* [<vrf> VIEWVRFNAME] */
15042 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15043 vrf
= argv
[idx
+ 1]->arg
;
15044 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15046 } else if (argv_find(argv
, argc
, "view", &idx
))
15047 /* [<view> VIEWVRFNAME] */
15048 vrf
= argv
[idx
+ 1]->arg
;
15049 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15050 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15051 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15054 /* get subgroup id, if provided */
15056 if (argv
[idx
]->type
== VARIABLE_TKN
)
15057 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15059 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
15062 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15063 show_bgp_instance_all_ipv6_updgrps_cmd
,
15064 "show [ip] bgp <view|vrf> all update-groups",
15068 BGP_INSTANCE_ALL_HELP_STR
15069 "Detailed info about dynamic update groups\n")
15071 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15072 return CMD_SUCCESS
;
15075 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15076 show_bgp_l2vpn_evpn_updgrps_cmd
,
15077 "show [ip] bgp l2vpn evpn update-groups",
15081 "l2vpn address family\n"
15082 "evpn sub-address family\n"
15083 "Detailed info about dynamic update groups\n")
15086 uint64_t subgrp_id
= 0;
15088 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15089 return CMD_SUCCESS
;
15092 DEFUN (show_bgp_updgrps_stats
,
15093 show_bgp_updgrps_stats_cmd
,
15094 "show [ip] bgp update-groups statistics",
15098 "Detailed info about dynamic update groups\n"
15103 bgp
= bgp_get_default();
15105 update_group_show_stats(bgp
, vty
);
15107 return CMD_SUCCESS
;
15110 DEFUN (show_bgp_instance_updgrps_stats
,
15111 show_bgp_instance_updgrps_stats_cmd
,
15112 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15116 BGP_INSTANCE_HELP_STR
15117 "Detailed info about dynamic update groups\n"
15123 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15125 update_group_show_stats(bgp
, vty
);
15127 return CMD_SUCCESS
;
15130 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15131 afi_t afi
, safi_t safi
,
15132 const char *what
, uint64_t subgrp_id
)
15137 bgp
= bgp_lookup_by_name(name
);
15139 bgp
= bgp_get_default();
15142 if (!strcmp(what
, "advertise-queue"))
15143 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15145 else if (!strcmp(what
, "advertised-routes"))
15146 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15148 else if (!strcmp(what
, "packet-queue"))
15149 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15154 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15155 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15156 "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",
15157 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15159 "Detailed info about dynamic update groups\n"
15160 "Specific subgroup to display info for\n"
15161 "Advertisement queue\n"
15162 "Announced routes\n"
15165 uint64_t subgrp_id
= 0;
15169 subgrp_id
= strtoull(sgid
, NULL
, 10);
15174 afiz
= bgp_vty_afi_from_str(afi
);
15178 afiz
= bgp_vty_afi_from_str(afi
);
15179 if (afiz
!= AFI_IP
)
15181 "%% Cannot specify both 'ip' and 'ipv6'\n");
15182 return CMD_WARNING
;
15185 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15187 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15188 return CMD_SUCCESS
;
15191 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
15193 struct listnode
*node
, *nnode
;
15194 struct prefix
*range
;
15199 const char *peer_status
;
15200 const char *af_str
;
15205 conf
= group
->conf
;
15207 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15208 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15209 group
->name
, conf
->as
);
15210 } else if (conf
->as_type
== AS_INTERNAL
) {
15211 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15212 group
->name
, group
->bgp
->as
);
15214 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15217 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
15218 vty_out(vty
, " Peer-group type is internal\n");
15220 vty_out(vty
, " Peer-group type is external\n");
15222 /* Display AFs configured. */
15223 vty_out(vty
, " Configured address-families:");
15224 FOREACH_AFI_SAFI (afi
, safi
) {
15225 if (conf
->afc
[afi
][safi
]) {
15227 vty_out(vty
, " %s;", get_afi_safi_str(afi
, safi
, false));
15231 vty_out(vty
, " none\n");
15233 vty_out(vty
, "\n");
15235 /* Display listen ranges (for dynamic neighbors), if any */
15236 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15239 else if (afi
== AFI_IP6
)
15243 lr_count
= listcount(group
->listen_range
[afi
]);
15245 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
15249 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15251 vty_out(vty
, " %pFX\n", range
);
15255 /* Display group members and their status */
15256 if (listcount(group
->peer
)) {
15257 vty_out(vty
, " Peer-group members:\n");
15258 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15259 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15260 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15261 peer_status
= "Idle (Admin)";
15262 else if (CHECK_FLAG(peer
->sflags
,
15263 PEER_STATUS_PREFIX_OVERFLOW
))
15264 peer_status
= "Idle (PfxCt)";
15266 peer_status
= lookup_msg(bgp_status_msg
,
15267 peer
->status
, NULL
);
15269 dynamic
= peer_dynamic_neighbor(peer
);
15270 vty_out(vty
, " %s %s %s \n", peer
->host
,
15271 dynamic
? "(dynamic)" : "", peer_status
);
15275 return CMD_SUCCESS
;
15278 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15279 const char *group_name
)
15282 struct listnode
*node
, *nnode
;
15283 struct peer_group
*group
;
15284 bool found
= false;
15286 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15289 vty_out(vty
, "%% BGP instance not found\n");
15290 return CMD_WARNING
;
15293 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15295 if (strmatch(group
->name
, group_name
)) {
15296 bgp_show_one_peer_group(vty
, group
);
15301 bgp_show_one_peer_group(vty
, group
);
15305 if (group_name
&& !found
)
15306 vty_out(vty
, "%% No such peer-group\n");
15308 return CMD_SUCCESS
;
15311 DEFUN (show_ip_bgp_peer_groups
,
15312 show_ip_bgp_peer_groups_cmd
,
15313 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
15317 BGP_INSTANCE_HELP_STR
15318 "Detailed information on BGP peer groups\n"
15319 "Peer group name\n")
15324 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15326 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15328 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
15332 /* Redistribute VTY commands. */
15334 DEFUN_YANG (bgp_redistribute_ipv4
,
15335 bgp_redistribute_ipv4_cmd
,
15336 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15337 "Redistribute information from another routing protocol\n"
15338 FRR_IP_REDIST_HELP_STR_BGPD
)
15340 int idx_protocol
= 1;
15341 char base_xpath
[XPATH_MAXLEN
];
15343 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15344 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15345 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15346 argv
[idx_protocol
]->text
, "0");
15348 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15350 return nb_cli_apply_changes(vty
, base_xpath
);
15354 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15355 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15356 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15358 DEFUN_YANG (bgp_redistribute_ipv4_rmap
,
15359 bgp_redistribute_ipv4_rmap_cmd
,
15360 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15361 "Redistribute information from another routing protocol\n"
15362 FRR_IP_REDIST_HELP_STR_BGPD
15363 "Route map reference\n"
15364 "Pointer to route-map entries\n")
15366 int idx_protocol
= 1;
15368 char base_xpath
[XPATH_MAXLEN
];
15370 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15371 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15372 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15373 argv
[idx_protocol
]->text
, "0");
15375 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15376 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15377 argv
[idx_word
]->arg
);
15379 return nb_cli_apply_changes(vty
, base_xpath
);
15383 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15384 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15385 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15386 "Route map reference\n"
15387 "Pointer to route-map entries\n")
15389 DEFUN_YANG (bgp_redistribute_ipv4_metric
,
15390 bgp_redistribute_ipv4_metric_cmd
,
15391 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15392 "Redistribute information from another routing protocol\n"
15393 FRR_IP_REDIST_HELP_STR_BGPD
15394 "Metric for redistributed routes\n"
15395 "Default metric\n")
15397 int idx_protocol
= 1;
15398 int idx_number
= 3;
15399 char base_xpath
[XPATH_MAXLEN
];
15401 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15402 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15403 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15404 argv
[idx_protocol
]->text
, "0");
15406 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15407 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15408 argv
[idx_number
]->arg
);
15410 return nb_cli_apply_changes(vty
, base_xpath
);
15414 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15415 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15416 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15417 "Metric for redistributed routes\n"
15418 "Default metric\n")
15421 bgp_redistribute_ipv4_rmap_metric
,
15422 bgp_redistribute_ipv4_rmap_metric_cmd
,
15423 "redistribute " FRR_IP_REDIST_STR_BGPD
15424 " route-map WORD metric (0-4294967295)",
15425 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15426 "Route map reference\n"
15427 "Pointer to route-map entries\n"
15428 "Metric for redistributed routes\n"
15429 "Default metric\n")
15431 int idx_protocol
= 1;
15433 int idx_number
= 5;
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
);
15442 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15443 argv
[idx_word
]->arg
);
15444 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15445 argv
[idx_number
]->arg
);
15447 return nb_cli_apply_changes(vty
, base_xpath
);
15451 bgp_redistribute_ipv4_rmap_metric
,
15452 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15453 "redistribute " FRR_IP_REDIST_STR_BGPD
15454 " route-map WORD metric (0-4294967295)",
15455 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15456 "Route map reference\n"
15457 "Pointer to route-map entries\n"
15458 "Metric for redistributed routes\n"
15459 "Default metric\n")
15462 bgp_redistribute_ipv4_metric_rmap
,
15463 bgp_redistribute_ipv4_metric_rmap_cmd
,
15464 "redistribute " FRR_IP_REDIST_STR_BGPD
15465 " metric (0-4294967295) route-map WORD",
15466 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15467 "Metric for redistributed routes\n"
15469 "Route map reference\n"
15470 "Pointer to route-map entries\n")
15472 int idx_protocol
= 1;
15474 int idx_number
= 3;
15475 char base_xpath
[XPATH_MAXLEN
];
15477 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15478 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15479 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15480 argv
[idx_protocol
]->text
, "0");
15482 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15483 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15484 argv
[idx_number
]->arg
);
15485 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15486 argv
[idx_word
]->arg
);
15488 return nb_cli_apply_changes(vty
, base_xpath
);
15492 bgp_redistribute_ipv4_metric_rmap
,
15493 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15494 "redistribute " FRR_IP_REDIST_STR_BGPD
15495 " metric (0-4294967295) route-map WORD",
15496 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15497 "Metric for redistributed routes\n"
15499 "Route map reference\n"
15500 "Pointer to route-map entries\n")
15502 DEFUN_YANG (bgp_redistribute_ipv4_ospf
,
15503 bgp_redistribute_ipv4_ospf_cmd
,
15504 "redistribute <ospf|table> (1-65535)",
15505 "Redistribute information from another routing protocol\n"
15506 "Open Shortest Path First (OSPFv2)\n"
15507 "Non-main Kernel Routing Table\n"
15508 "Instance ID/Table ID\n")
15510 int idx_protocol
= 1;
15511 int idx_number
= 2;
15512 char base_xpath
[XPATH_MAXLEN
];
15514 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15515 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15516 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15517 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15519 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15521 return nb_cli_apply_changes(vty
, base_xpath
);
15524 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
15525 "redistribute <ospf|table> (1-65535)",
15526 "Redistribute information from another routing protocol\n"
15527 "Open Shortest Path First (OSPFv2)\n"
15528 "Non-main Kernel Routing Table\n"
15529 "Instance ID/Table ID\n")
15531 DEFUN_YANG (bgp_redistribute_ipv4_ospf_rmap
,
15532 bgp_redistribute_ipv4_ospf_rmap_cmd
,
15533 "redistribute <ospf|table> (1-65535) route-map WORD",
15534 "Redistribute information from another routing protocol\n"
15535 "Open Shortest Path First (OSPFv2)\n"
15536 "Non-main Kernel Routing Table\n"
15537 "Instance ID/Table ID\n"
15538 "Route map reference\n"
15539 "Pointer to route-map entries\n")
15541 int idx_protocol
= 1;
15542 int idx_number
= 2;
15544 char base_xpath
[XPATH_MAXLEN
];
15546 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15547 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15548 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15549 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15551 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15553 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15554 argv
[idx_word
]->arg
);
15556 return nb_cli_apply_changes(vty
, base_xpath
);
15559 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
15560 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
15561 "redistribute <ospf|table> (1-65535) route-map WORD",
15562 "Redistribute information from another routing protocol\n"
15563 "Open Shortest Path First (OSPFv2)\n"
15564 "Non-main Kernel Routing Table\n"
15565 "Instance ID/Table ID\n"
15566 "Route map reference\n"
15567 "Pointer to route-map entries\n")
15569 DEFUN_YANG(bgp_redistribute_ipv4_ospf_metric
,
15570 bgp_redistribute_ipv4_ospf_metric_cmd
,
15571 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15572 "Redistribute information from another routing protocol\n"
15573 "Open Shortest Path First (OSPFv2)\n"
15574 "Non-main Kernel Routing Table\n"
15575 "Instance ID/Table ID\n"
15576 "Metric for redistributed routes\n"
15577 "Default metric\n")
15579 int idx_protocol
= 1;
15580 int idx_number
= 2;
15581 int idx_number_2
= 4;
15582 char base_xpath
[XPATH_MAXLEN
];
15584 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15585 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15586 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15587 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15589 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15591 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15592 argv
[idx_number_2
]->arg
);
15594 return nb_cli_apply_changes(vty
, base_xpath
);
15597 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
15598 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
15599 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15600 "Redistribute information from another routing protocol\n"
15601 "Open Shortest Path First (OSPFv2)\n"
15602 "Non-main Kernel Routing Table\n"
15603 "Instance ID/Table ID\n"
15604 "Metric for redistributed routes\n"
15605 "Default metric\n")
15608 bgp_redistribute_ipv4_ospf_rmap_metric
,
15609 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
15610 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15611 "Redistribute information from another routing protocol\n"
15612 "Open Shortest Path First (OSPFv2)\n"
15613 "Non-main Kernel Routing Table\n"
15614 "Instance ID/Table ID\n"
15615 "Route map reference\n"
15616 "Pointer to route-map entries\n"
15617 "Metric for redistributed routes\n"
15618 "Default metric\n")
15620 int idx_protocol
= 1;
15621 int idx_number
= 2;
15623 int idx_number_2
= 6;
15624 char base_xpath
[XPATH_MAXLEN
];
15626 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15627 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15628 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15629 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15631 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15633 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15634 argv
[idx_word
]->arg
);
15635 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15636 argv
[idx_number_2
]->arg
);
15638 return nb_cli_apply_changes(vty
, base_xpath
);
15642 bgp_redistribute_ipv4_ospf_rmap_metric
,
15643 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
15644 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15645 "Redistribute information from another routing protocol\n"
15646 "Open Shortest Path First (OSPFv2)\n"
15647 "Non-main Kernel Routing Table\n"
15648 "Instance ID/Table ID\n"
15649 "Route map reference\n"
15650 "Pointer to route-map entries\n"
15651 "Metric for redistributed routes\n"
15652 "Default metric\n")
15655 bgp_redistribute_ipv4_ospf_metric_rmap
,
15656 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
15657 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15658 "Redistribute information from another routing protocol\n"
15659 "Open Shortest Path First (OSPFv2)\n"
15660 "Non-main Kernel Routing Table\n"
15661 "Instance ID/Table ID\n"
15662 "Metric for redistributed routes\n"
15664 "Route map reference\n"
15665 "Pointer to route-map entries\n")
15667 int idx_protocol
= 1;
15668 int idx_number
= 2;
15669 int idx_number_2
= 4;
15671 char base_xpath
[XPATH_MAXLEN
];
15673 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15674 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15675 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15676 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15678 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15680 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15681 argv
[idx_number_2
]->arg
);
15682 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15683 argv
[idx_word
]->arg
);
15685 return nb_cli_apply_changes(vty
, base_xpath
);
15689 bgp_redistribute_ipv4_ospf_metric_rmap
,
15690 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
15691 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15692 "Redistribute information from another routing protocol\n"
15693 "Open Shortest Path First (OSPFv2)\n"
15694 "Non-main Kernel Routing Table\n"
15695 "Instance ID/Table ID\n"
15696 "Metric for redistributed routes\n"
15698 "Route map reference\n"
15699 "Pointer to route-map entries\n")
15701 DEFUN_YANG (no_bgp_redistribute_ipv4_ospf
,
15702 no_bgp_redistribute_ipv4_ospf_cmd
,
15703 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
15705 "Redistribute information from another routing protocol\n"
15706 "Open Shortest Path First (OSPFv2)\n"
15707 "Non-main Kernel Routing Table\n"
15708 "Instance ID/Table ID\n"
15709 "Metric for redistributed routes\n"
15711 "Route map reference\n"
15712 "Pointer to route-map entries\n")
15714 int idx_protocol
= 2;
15715 int idx_number
= 3;
15716 char base_xpath
[XPATH_MAXLEN
];
15718 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15719 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15720 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15721 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15723 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
15725 return nb_cli_apply_changes(vty
, base_xpath
);
15729 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
15730 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
15732 "Redistribute information from another routing protocol\n"
15733 "Open Shortest Path First (OSPFv2)\n"
15734 "Non-main Kernel Routing Table\n"
15735 "Instance ID/Table ID\n"
15736 "Metric for redistributed routes\n"
15738 "Route map reference\n"
15739 "Pointer to route-map entries\n")
15741 DEFUN_YANG (no_bgp_redistribute_ipv4
,
15742 no_bgp_redistribute_ipv4_cmd
,
15743 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
15745 "Redistribute information from another routing protocol\n"
15746 FRR_IP_REDIST_HELP_STR_BGPD
15747 "Metric for redistributed routes\n"
15749 "Route map reference\n"
15750 "Pointer to route-map entries\n")
15752 int idx_protocol
= 2;
15753 char base_xpath
[XPATH_MAXLEN
];
15755 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15756 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15757 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15758 argv
[idx_protocol
]->text
, "0");
15760 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
15762 return nb_cli_apply_changes(vty
, base_xpath
);
15766 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
15767 "no redistribute " FRR_IP_REDIST_STR_BGPD
15768 " [{metric (0-4294967295)|route-map WORD}]",
15770 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15771 "Metric for redistributed routes\n"
15773 "Route map reference\n"
15774 "Pointer to route-map entries\n")
15776 DEFUN_YANG (bgp_redistribute_ipv6
,
15777 bgp_redistribute_ipv6_cmd
,
15778 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
15779 "Redistribute information from another routing protocol\n"
15780 FRR_IP6_REDIST_HELP_STR_BGPD
)
15782 int idx_protocol
= 1;
15783 char base_xpath
[XPATH_MAXLEN
];
15785 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15786 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15787 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15788 argv
[idx_protocol
]->text
, "0");
15790 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15792 return nb_cli_apply_changes(vty
, base_xpath
);
15795 DEFUN_YANG (bgp_redistribute_ipv6_rmap
,
15796 bgp_redistribute_ipv6_rmap_cmd
,
15797 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
15798 "Redistribute information from another routing protocol\n"
15799 FRR_IP6_REDIST_HELP_STR_BGPD
15800 "Route map reference\n"
15801 "Pointer to route-map entries\n")
15803 int idx_protocol
= 1;
15805 char base_xpath
[XPATH_MAXLEN
];
15807 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15808 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15809 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15810 argv
[idx_protocol
]->text
, "0");
15812 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15813 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15814 argv
[idx_word
]->arg
);
15816 return nb_cli_apply_changes(vty
, base_xpath
);
15819 DEFUN_YANG (bgp_redistribute_ipv6_metric
,
15820 bgp_redistribute_ipv6_metric_cmd
,
15821 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
15822 "Redistribute information from another routing protocol\n"
15823 FRR_IP6_REDIST_HELP_STR_BGPD
15824 "Metric for redistributed routes\n"
15825 "Default metric\n")
15827 int idx_protocol
= 1;
15828 int idx_number
= 3;
15829 char base_xpath
[XPATH_MAXLEN
];
15831 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15832 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15833 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15834 argv
[idx_protocol
]->text
, "0");
15836 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15837 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15838 argv
[idx_number
]->arg
);
15840 return nb_cli_apply_changes(vty
, base_xpath
);
15844 bgp_redistribute_ipv6_rmap_metric
,
15845 bgp_redistribute_ipv6_rmap_metric_cmd
,
15846 "redistribute " FRR_IP6_REDIST_STR_BGPD
15847 " route-map WORD metric (0-4294967295)",
15848 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
15849 "Route map reference\n"
15850 "Pointer to route-map entries\n"
15851 "Metric for redistributed routes\n"
15852 "Default metric\n")
15854 int idx_protocol
= 1;
15856 int idx_number
= 5;
15857 char base_xpath
[XPATH_MAXLEN
];
15859 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15860 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15861 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15862 argv
[idx_protocol
]->text
, "0");
15864 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15865 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15866 argv
[idx_word
]->arg
);
15867 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15868 argv
[idx_number
]->arg
);
15870 return nb_cli_apply_changes(vty
, base_xpath
);
15874 bgp_redistribute_ipv6_metric_rmap
,
15875 bgp_redistribute_ipv6_metric_rmap_cmd
,
15876 "redistribute " FRR_IP6_REDIST_STR_BGPD
15877 " metric (0-4294967295) route-map WORD",
15878 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
15879 "Metric for redistributed routes\n"
15881 "Route map reference\n"
15882 "Pointer to route-map entries\n")
15884 int idx_protocol
= 1;
15886 int idx_number
= 3;
15887 char base_xpath
[XPATH_MAXLEN
];
15889 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15890 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15891 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15892 argv
[idx_protocol
]->text
, "0");
15894 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15895 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15896 argv
[idx_number
]->arg
);
15897 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15898 argv
[idx_word
]->arg
);
15900 return nb_cli_apply_changes(vty
, base_xpath
);
15904 no_bgp_redistribute_ipv6
,
15905 no_bgp_redistribute_ipv6_cmd
,
15906 "no redistribute " FRR_IP6_REDIST_STR_BGPD
15907 " [{metric (0-4294967295)|route-map WORD}]",
15909 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
15910 "Metric for redistributed routes\n"
15912 "Route map reference\n"
15913 "Pointer to route-map entries\n")
15915 int idx_protocol
= 2;
15916 char base_xpath
[XPATH_MAXLEN
];
15918 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15919 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15920 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15921 argv
[idx_protocol
]->text
, "0");
15923 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
15925 return nb_cli_apply_changes(vty
, base_xpath
);
15928 void cli_show_bgp_global_afi_safi_ip_unicast_redistribution_list(
15929 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
15931 uint32_t instance
= 0;
15933 vty_out(vty
, " redistribute %s",
15934 yang_dnode_get_string(dnode
, "./route-type"));
15935 if ((instance
= yang_dnode_get_uint16(dnode
, "./route-instance")))
15936 vty_out(vty
, " %d", instance
);
15937 if (yang_dnode_exists(dnode
, "./metric"))
15938 vty_out(vty
, " metric %u",
15939 yang_dnode_get_uint32(dnode
, "./metric"));
15940 if (yang_dnode_exists(dnode
, "./rmap-policy-import"))
15941 vty_out(vty
, " route-map %s",
15942 yang_dnode_get_string(dnode
, "./rmap-policy-import"));
15943 vty_out(vty
, "\n");
15946 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
15947 afi_t afi
, safi_t safi
)
15951 /* Unicast redistribution only. */
15952 if (safi
!= SAFI_UNICAST
)
15955 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
15956 /* Redistribute BGP does not make sense. */
15957 if (i
!= ZEBRA_ROUTE_BGP
) {
15958 struct list
*red_list
;
15959 struct listnode
*node
;
15960 struct bgp_redist
*red
;
15962 red_list
= bgp
->redist
[afi
][i
];
15966 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
15967 /* "redistribute" configuration. */
15968 vty_out(vty
, " redistribute %s",
15969 zebra_route_string(i
));
15971 vty_out(vty
, " %d", red
->instance
);
15972 if (red
->redist_metric_flag
)
15973 vty_out(vty
, " metric %u",
15974 red
->redist_metric
);
15975 if (red
->rmap
.name
)
15976 vty_out(vty
, " route-map %s",
15978 vty_out(vty
, "\n");
15984 /* peer-group helpers for config-write */
15986 static bool peergroup_flag_check(struct peer
*peer
, uint32_t flag
)
15988 if (!peer_group_active(peer
)) {
15989 if (CHECK_FLAG(peer
->flags_invert
, flag
))
15990 return !CHECK_FLAG(peer
->flags
, flag
);
15992 return !!CHECK_FLAG(peer
->flags
, flag
);
15995 return !!CHECK_FLAG(peer
->flags_override
, flag
);
15998 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16001 if (!peer_group_active(peer
)) {
16002 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16003 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16005 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16008 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16011 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16012 uint8_t type
, int direct
)
16014 struct bgp_filter
*filter
;
16016 if (peer_group_active(peer
))
16017 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16020 filter
= &peer
->filter
[afi
][safi
];
16022 case PEER_FT_DISTRIBUTE_LIST
:
16023 return !!(filter
->dlist
[direct
].name
);
16024 case PEER_FT_FILTER_LIST
:
16025 return !!(filter
->aslist
[direct
].name
);
16026 case PEER_FT_PREFIX_LIST
:
16027 return !!(filter
->plist
[direct
].name
);
16028 case PEER_FT_ROUTE_MAP
:
16029 return !!(filter
->map
[direct
].name
);
16030 case PEER_FT_UNSUPPRESS_MAP
:
16031 return !!(filter
->usmap
.name
);
16032 case PEER_FT_ADVERTISE_MAP
:
16033 return !!(filter
->advmap
.aname
16034 && ((filter
->advmap
.condition
== direct
)
16035 && filter
->advmap
.cname
));
16041 /* Return true if the addpath type is set for peer and different from
16044 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16047 enum bgp_addpath_strat type
, g_type
;
16049 type
= peer
->addpath_type
[afi
][safi
];
16051 if (type
!= BGP_ADDPATH_NONE
) {
16052 if (peer_group_active(peer
)) {
16053 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16055 if (type
!= g_type
)
16067 /* This is part of the address-family block (unicast only) */
16068 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16073 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16074 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16075 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16076 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16077 bgp
->vpn_policy
[afi
]
16078 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16080 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16081 bgp
->vpn_policy
[afi
]
16082 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16084 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16085 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16086 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16087 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16090 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16091 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16093 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16096 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16097 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16098 bgp
->vpn_policy
[afi
].tovpn_label
);
16101 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16102 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
16103 char buf
[RD_ADDRSTRLEN
];
16104 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
16105 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
16108 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16109 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16111 char buf
[PREFIX_STRLEN
];
16112 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16113 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16116 vty_out(vty
, "%*snexthop vpn export %s\n",
16120 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16121 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16123 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16124 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16126 char *b
= ecommunity_ecom2str(
16127 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16128 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16129 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16130 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16132 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16133 char *b
= ecommunity_ecom2str(
16134 bgp
->vpn_policy
[afi
]
16135 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16136 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16137 ECOMMUNITY_ROUTE_TARGET
);
16138 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16139 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16141 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16142 char *b
= ecommunity_ecom2str(
16143 bgp
->vpn_policy
[afi
]
16144 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16145 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16146 ECOMMUNITY_ROUTE_TARGET
);
16147 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16148 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16152 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16153 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16154 bgp
->vpn_policy
[afi
]
16155 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16157 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16158 char *b
= ecommunity_ecom2str(
16159 bgp
->vpn_policy
[afi
]
16160 .import_redirect_rtlist
,
16161 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16162 ECOMMUNITY_ROUTE_TARGET
);
16164 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16165 != ECOMMUNITY_SIZE
)
16166 vty_out(vty
, "%*srt6 redirect import %s\n",
16169 vty_out(vty
, "%*srt redirect import %s\n",
16171 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16175 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16176 afi_t afi
, safi_t safi
)
16178 struct bgp_filter
*filter
;
16182 filter
= &peer
->filter
[afi
][safi
];
16184 /* distribute-list. */
16185 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16187 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16188 filter
->dlist
[FILTER_IN
].name
);
16190 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16192 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16193 filter
->dlist
[FILTER_OUT
].name
);
16196 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16198 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16199 filter
->plist
[FILTER_IN
].name
);
16201 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16203 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16204 filter
->plist
[FILTER_OUT
].name
);
16207 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16208 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16209 filter
->map
[RMAP_IN
].name
);
16211 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16213 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16214 filter
->map
[RMAP_OUT
].name
);
16216 /* unsuppress-map */
16217 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16218 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16219 filter
->usmap
.name
);
16221 /* advertise-map : always applied in OUT direction*/
16222 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16223 CONDITION_NON_EXIST
))
16225 " neighbor %s advertise-map %s non-exist-map %s\n",
16226 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16228 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16230 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16231 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16234 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16236 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16237 filter
->aslist
[FILTER_IN
].name
);
16239 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16241 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16242 filter
->aslist
[FILTER_OUT
].name
);
16245 /* BGP peer configuration display function. */
16246 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16249 struct peer
*g_peer
= NULL
;
16250 char buf
[SU_ADDRSTRLEN
];
16252 int if_pg_printed
= false;
16253 int if_ras_printed
= false;
16255 /* Skip dynamic neighbors. */
16256 if (peer_dynamic_neighbor(peer
))
16260 addr
= peer
->conf_if
;
16264 /************************************
16265 ****** Global to the neighbor ******
16266 ************************************/
16267 if (peer
->conf_if
) {
16268 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16269 vty_out(vty
, " neighbor %s interface v6only", addr
);
16271 vty_out(vty
, " neighbor %s interface", addr
);
16273 if (peer_group_active(peer
)) {
16274 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16275 if_pg_printed
= true;
16276 } else if (peer
->as_type
== AS_SPECIFIED
) {
16277 vty_out(vty
, " remote-as %u", peer
->as
);
16278 if_ras_printed
= true;
16279 } else if (peer
->as_type
== AS_INTERNAL
) {
16280 vty_out(vty
, " remote-as internal");
16281 if_ras_printed
= true;
16282 } else if (peer
->as_type
== AS_EXTERNAL
) {
16283 vty_out(vty
, " remote-as external");
16284 if_ras_printed
= true;
16287 vty_out(vty
, "\n");
16290 /* remote-as and peer-group */
16291 /* peer is a member of a peer-group */
16292 if (peer_group_active(peer
)) {
16293 g_peer
= peer
->group
->conf
;
16295 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16296 if (peer
->as_type
== AS_SPECIFIED
) {
16297 vty_out(vty
, " neighbor %s remote-as %u\n",
16299 } else if (peer
->as_type
== AS_INTERNAL
) {
16301 " neighbor %s remote-as internal\n",
16303 } else if (peer
->as_type
== AS_EXTERNAL
) {
16305 " neighbor %s remote-as external\n",
16310 /* For swpX peers we displayed the peer-group
16311 * via 'neighbor swpX interface peer-group PGNAME' */
16312 if (!if_pg_printed
)
16313 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16314 peer
->group
->name
);
16317 /* peer is NOT a member of a peer-group */
16319 /* peer is a peer-group, declare the peer-group */
16320 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16321 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16324 if (!if_ras_printed
) {
16325 if (peer
->as_type
== AS_SPECIFIED
) {
16326 vty_out(vty
, " neighbor %s remote-as %u\n",
16328 } else if (peer
->as_type
== AS_INTERNAL
) {
16330 " neighbor %s remote-as internal\n",
16332 } else if (peer
->as_type
== AS_EXTERNAL
) {
16334 " neighbor %s remote-as external\n",
16341 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16342 vty_out(vty
, " neighbor %s local-as %u", addr
,
16343 peer
->change_local_as
);
16344 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16345 vty_out(vty
, " no-prepend");
16346 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16347 vty_out(vty
, " replace-as");
16348 vty_out(vty
, "\n");
16353 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16357 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16358 if (peer
->tx_shutdown_message
)
16359 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16360 peer
->tx_shutdown_message
);
16362 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16365 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16366 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16367 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16370 if (peer
->bfd_info
) {
16371 if (!peer_group_active(peer
) || !g_peer
->bfd_info
) {
16372 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16377 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16378 vty_out(vty
, " neighbor %s password %s\n", addr
,
16381 /* neighbor solo */
16382 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16383 if (!peer_group_active(peer
)) {
16384 vty_out(vty
, " neighbor %s solo\n", addr
);
16389 if (peer
->port
!= BGP_PORT_DEFAULT
) {
16390 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
16393 /* Local interface name */
16394 if (peer
->ifname
) {
16395 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
16399 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
16400 vty_out(vty
, " neighbor %s passive\n", addr
);
16402 /* ebgp-multihop */
16403 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
16404 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
16405 && peer
->ttl
== MAXTTL
)) {
16406 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
16407 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
16412 /* ttl-security hops */
16413 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
16414 if (!peer_group_active(peer
)
16415 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
16416 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
16417 addr
, peer
->gtsm_hops
);
16421 /* disable-connected-check */
16422 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
16423 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
16425 /* enforce-first-as */
16426 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
16427 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
16429 /* update-source */
16430 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
16431 if (peer
->update_source
)
16432 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16433 sockunion2str(peer
->update_source
, buf
,
16435 else if (peer
->update_if
)
16436 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16440 /* advertisement-interval */
16441 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
16442 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
16446 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
16447 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
16448 peer
->keepalive
, peer
->holdtime
);
16450 /* timers connect */
16451 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
16452 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16454 /* need special-case handling for changed default values due to
16455 * config profile / version (because there is no "timers bgp connect"
16456 * command, we need to save this per-peer :/)
16458 else if (!peer_group_active(peer
) && !peer
->connect
&&
16459 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
16460 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16461 peer
->bgp
->default_connect_retry
);
16463 /* timers delayopen */
16464 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
16465 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16467 /* Save config even though flag is not set if default values have been
16470 else if (!peer_group_active(peer
) && !peer
->delayopen
16471 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
16472 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16473 peer
->bgp
->default_delayopen
);
16475 /* capability dynamic */
16476 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
16477 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
16479 /* capability extended-nexthop */
16480 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
16481 if (!peer
->conf_if
) {
16482 if (CHECK_FLAG(peer
->flags_invert
,
16483 PEER_FLAG_CAPABILITY_ENHE
))
16485 " no neighbor %s capability extended-nexthop\n",
16489 " neighbor %s capability extended-nexthop\n",
16494 /* dont-capability-negotiation */
16495 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
16496 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
16498 /* override-capability */
16499 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
16500 vty_out(vty
, " neighbor %s override-capability\n", addr
);
16502 /* strict-capability-match */
16503 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
16504 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
16506 /* Sender side AS path loop detection. */
16507 if (peer
->as_path_loop_detection
)
16508 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
16511 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16512 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
16514 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16515 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
16517 " neighbor %s graceful-restart-helper\n", addr
);
16518 } else if (CHECK_FLAG(
16519 peer
->peer_gr_new_status_flag
,
16520 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
16522 " neighbor %s graceful-restart\n", addr
);
16524 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16525 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
16527 peer
->peer_gr_new_status_flag
,
16528 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
16529 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
16535 /* BGP peer configuration display function. */
16536 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
16537 struct peer
*peer
, afi_t afi
, safi_t safi
)
16539 struct peer
*g_peer
= NULL
;
16541 bool flag_scomm
, flag_secomm
, flag_slcomm
;
16543 /* Skip dynamic neighbors. */
16544 if (peer_dynamic_neighbor(peer
))
16548 addr
= peer
->conf_if
;
16552 /************************************
16553 ****** Per AF to the neighbor ******
16554 ************************************/
16555 if (peer_group_active(peer
)) {
16556 g_peer
= peer
->group
->conf
;
16558 /* If the peer-group is active but peer is not, print a 'no
16560 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
16561 vty_out(vty
, " no neighbor %s activate\n", addr
);
16564 /* If the peer-group is not active but peer is, print an
16566 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
16567 vty_out(vty
, " neighbor %s activate\n", addr
);
16570 if (peer
->afc
[afi
][safi
]) {
16571 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
16572 if (CHECK_FLAG(bgp
->flags
,
16573 BGP_FLAG_NO_DEFAULT_IPV4
)) {
16574 vty_out(vty
, " neighbor %s activate\n",
16578 vty_out(vty
, " neighbor %s activate\n", addr
);
16580 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
16581 if (!CHECK_FLAG(bgp
->flags
,
16582 BGP_FLAG_NO_DEFAULT_IPV4
)) {
16584 " no neighbor %s activate\n",
16591 /* addpath TX knobs */
16592 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
16593 switch (peer
->addpath_type
[afi
][safi
]) {
16594 case BGP_ADDPATH_ALL
:
16595 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
16598 case BGP_ADDPATH_BEST_PER_AS
:
16600 " neighbor %s addpath-tx-bestpath-per-AS\n",
16603 case BGP_ADDPATH_MAX
:
16604 case BGP_ADDPATH_NONE
:
16609 /* ORF capability. */
16610 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
16611 || peergroup_af_flag_check(peer
, afi
, safi
,
16612 PEER_FLAG_ORF_PREFIX_RM
)) {
16613 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
16615 if (peergroup_af_flag_check(peer
, afi
, safi
,
16616 PEER_FLAG_ORF_PREFIX_SM
)
16617 && peergroup_af_flag_check(peer
, afi
, safi
,
16618 PEER_FLAG_ORF_PREFIX_RM
))
16619 vty_out(vty
, " both");
16620 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16621 PEER_FLAG_ORF_PREFIX_SM
))
16622 vty_out(vty
, " send");
16624 vty_out(vty
, " receive");
16625 vty_out(vty
, "\n");
16628 /* Route reflector client. */
16629 if (peergroup_af_flag_check(peer
, afi
, safi
,
16630 PEER_FLAG_REFLECTOR_CLIENT
)) {
16631 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
16634 /* next-hop-self force */
16635 if (peergroup_af_flag_check(peer
, afi
, safi
,
16636 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
16637 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
16640 /* next-hop-self */
16641 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
16642 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
16645 /* remove-private-AS */
16646 if (peergroup_af_flag_check(peer
, afi
, safi
,
16647 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
16648 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
16652 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16653 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
16654 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
16658 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16659 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
16660 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
16663 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16664 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
16665 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
16669 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
16670 vty_out(vty
, " neighbor %s as-override\n", addr
);
16673 /* send-community print. */
16674 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16675 PEER_FLAG_SEND_COMMUNITY
);
16676 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16677 PEER_FLAG_SEND_EXT_COMMUNITY
);
16678 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16679 PEER_FLAG_SEND_LARGE_COMMUNITY
);
16681 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
16682 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
16685 vty_out(vty
, " no neighbor %s send-community\n", addr
);
16688 " no neighbor %s send-community extended\n",
16692 vty_out(vty
, " no neighbor %s send-community large\n",
16696 /* Default information */
16697 if (peergroup_af_flag_check(peer
, afi
, safi
,
16698 PEER_FLAG_DEFAULT_ORIGINATE
)) {
16699 vty_out(vty
, " neighbor %s default-originate", addr
);
16701 if (peer
->default_rmap
[afi
][safi
].name
)
16702 vty_out(vty
, " route-map %s",
16703 peer
->default_rmap
[afi
][safi
].name
);
16705 vty_out(vty
, "\n");
16708 /* Soft reconfiguration inbound. */
16709 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
16710 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
16714 /* maximum-prefix. */
16715 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
16716 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
16717 peer
->pmax
[afi
][safi
]);
16719 if (peer
->pmax_threshold
[afi
][safi
]
16720 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
16721 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
16722 if (peer_af_flag_check(peer
, afi
, safi
,
16723 PEER_FLAG_MAX_PREFIX_WARNING
))
16724 vty_out(vty
, " warning-only");
16725 if (peer
->pmax_restart
[afi
][safi
])
16726 vty_out(vty
, " restart %u",
16727 peer
->pmax_restart
[afi
][safi
]);
16728 if (peer_af_flag_check(peer
, afi
, safi
,
16729 PEER_FLAG_MAX_PREFIX_FORCE
))
16730 vty_out(vty
, " force");
16732 vty_out(vty
, "\n");
16735 /* maximum-prefix-out */
16736 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
16737 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
16738 addr
, peer
->pmax_out
[afi
][safi
]);
16740 /* Route server client. */
16741 if (peergroup_af_flag_check(peer
, afi
, safi
,
16742 PEER_FLAG_RSERVER_CLIENT
)) {
16743 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
16746 /* Nexthop-local unchanged. */
16747 if (peergroup_af_flag_check(peer
, afi
, safi
,
16748 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
16749 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
16752 /* allowas-in <1-10> */
16753 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
16754 if (peer_af_flag_check(peer
, afi
, safi
,
16755 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
16756 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
16757 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
16758 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
16760 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
16761 peer
->allowas_in
[afi
][safi
]);
16766 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
16767 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
16768 peer
->weight
[afi
][safi
]);
16771 bgp_config_write_filter(vty
, peer
, afi
, safi
);
16773 /* atribute-unchanged. */
16774 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
16775 || (safi
!= SAFI_EVPN
16776 && peer_af_flag_check(peer
, afi
, safi
,
16777 PEER_FLAG_NEXTHOP_UNCHANGED
))
16778 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
16780 if (!peer_group_active(peer
)
16781 || peergroup_af_flag_check(peer
, afi
, safi
,
16782 PEER_FLAG_AS_PATH_UNCHANGED
)
16783 || peergroup_af_flag_check(peer
, afi
, safi
,
16784 PEER_FLAG_NEXTHOP_UNCHANGED
)
16785 || peergroup_af_flag_check(peer
, afi
, safi
,
16786 PEER_FLAG_MED_UNCHANGED
)) {
16789 " neighbor %s attribute-unchanged%s%s%s\n",
16791 peer_af_flag_check(peer
, afi
, safi
,
16792 PEER_FLAG_AS_PATH_UNCHANGED
)
16795 peer_af_flag_check(peer
, afi
, safi
,
16796 PEER_FLAG_NEXTHOP_UNCHANGED
)
16799 peer_af_flag_check(peer
, afi
, safi
,
16800 PEER_FLAG_MED_UNCHANGED
)
16807 /* Address family based peer configuration display. */
16808 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
16812 struct peer_group
*group
;
16813 struct listnode
*node
, *nnode
;
16816 vty_frame(vty
, " !\n address-family ");
16817 if (afi
== AFI_IP
) {
16818 if (safi
== SAFI_UNICAST
)
16819 vty_frame(vty
, "ipv4 unicast");
16820 else if (safi
== SAFI_LABELED_UNICAST
)
16821 vty_frame(vty
, "ipv4 labeled-unicast");
16822 else if (safi
== SAFI_MULTICAST
)
16823 vty_frame(vty
, "ipv4 multicast");
16824 else if (safi
== SAFI_MPLS_VPN
)
16825 vty_frame(vty
, "ipv4 vpn");
16826 else if (safi
== SAFI_ENCAP
)
16827 vty_frame(vty
, "ipv4 encap");
16828 else if (safi
== SAFI_FLOWSPEC
)
16829 vty_frame(vty
, "ipv4 flowspec");
16830 } else if (afi
== AFI_IP6
) {
16831 if (safi
== SAFI_UNICAST
)
16832 vty_frame(vty
, "ipv6 unicast");
16833 else if (safi
== SAFI_LABELED_UNICAST
)
16834 vty_frame(vty
, "ipv6 labeled-unicast");
16835 else if (safi
== SAFI_MULTICAST
)
16836 vty_frame(vty
, "ipv6 multicast");
16837 else if (safi
== SAFI_MPLS_VPN
)
16838 vty_frame(vty
, "ipv6 vpn");
16839 else if (safi
== SAFI_ENCAP
)
16840 vty_frame(vty
, "ipv6 encap");
16841 else if (safi
== SAFI_FLOWSPEC
)
16842 vty_frame(vty
, "ipv6 flowspec");
16843 } else if (afi
== AFI_L2VPN
) {
16844 if (safi
== SAFI_EVPN
)
16845 vty_frame(vty
, "l2vpn evpn");
16847 vty_frame(vty
, "\n");
16849 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
16851 bgp_config_write_network(vty
, bgp
, afi
, safi
);
16853 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
16855 /* BGP flag dampening. */
16856 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
16857 bgp_config_write_damp(vty
, afi
, safi
);
16859 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
16860 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
16862 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
16863 /* Skip dynamic neighbors. */
16864 if (peer_dynamic_neighbor(peer
))
16867 /* Do not display doppelganger peers */
16868 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
16869 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
16872 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
16873 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
16875 if (safi
== SAFI_EVPN
)
16876 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
16878 if (safi
== SAFI_FLOWSPEC
)
16879 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
16881 if (safi
== SAFI_UNICAST
) {
16882 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
16883 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
16884 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
16886 vty_out(vty
, " export vpn\n");
16888 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
16889 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
16891 vty_out(vty
, " import vpn\n");
16893 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
16894 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
16897 for (ALL_LIST_ELEMENTS_RO(
16898 bgp
->vpn_policy
[afi
].import_vrf
, node
,
16900 vty_out(vty
, " import vrf %s\n", name
);
16904 vty_endframe(vty
, " exit-address-family\n");
16907 int bgp_config_write(struct vty
*vty
)
16910 struct peer_group
*group
;
16912 struct listnode
*node
, *nnode
;
16913 struct listnode
*mnode
, *mnnode
;
16915 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
16916 vty_out(vty
, "bgp route-map delay-timer %u\n",
16917 bm
->rmap_update_timer
);
16919 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
16920 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
16921 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
16922 vty_out(vty
, " %d", bm
->v_establish_wait
);
16923 vty_out(vty
, "\n");
16926 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
16927 vty_out(vty
, "bgp graceful-shutdown\n");
16929 /* No-RIB (Zebra) option flag configuration */
16930 if (bgp_option_check(BGP_OPT_NO_FIB
))
16931 vty_out(vty
, "bgp no-rib\n");
16933 /* BGP configuration. */
16934 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
16936 /* skip all auto created vrf as they dont have user config */
16937 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
16940 /* Router bgp ASN */
16941 vty_out(vty
, "router bgp %u", bgp
->as
);
16944 vty_out(vty
, " %s %s",
16945 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
16946 ? "view" : "vrf", bgp
->name
);
16947 vty_out(vty
, "\n");
16949 /* BGP fast-external-failover. */
16950 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
16951 vty_out(vty
, " no bgp fast-external-failover\n");
16953 /* BGP router ID. */
16954 if (bgp
->router_id_static
.s_addr
!= 0)
16955 vty_out(vty
, " bgp router-id %pI4\n",
16956 &bgp
->router_id_static
);
16958 /* Suppress fib pending */
16959 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
16960 vty_out(vty
, " bgp suppress-fib-pending\n");
16962 /* BGP log-neighbor-changes. */
16963 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
16964 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
16965 vty_out(vty
, " %sbgp log-neighbor-changes\n",
16966 CHECK_FLAG(bgp
->flags
,
16967 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
16971 /* BGP configuration. */
16972 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
16973 vty_out(vty
, " bgp always-compare-med\n");
16975 /* RFC8212 default eBGP policy. */
16976 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
16977 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
16978 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
16979 CHECK_FLAG(bgp
->flags
,
16980 BGP_FLAG_EBGP_REQUIRES_POLICY
)
16984 /* draft-ietf-idr-deprecate-as-set-confed-set */
16985 if (bgp
->reject_as_sets
)
16986 vty_out(vty
, " bgp reject-as-sets\n");
16988 /* BGP default ipv4-unicast. */
16989 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
))
16990 vty_out(vty
, " no bgp default ipv4-unicast\n");
16992 /* BGP default local-preference. */
16993 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
16994 vty_out(vty
, " bgp default local-preference %u\n",
16995 bgp
->default_local_pref
);
16997 /* BGP default show-hostname */
16998 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
16999 != SAVE_BGP_SHOW_HOSTNAME
)
17000 vty_out(vty
, " %sbgp default show-hostname\n",
17001 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17005 /* BGP default show-nexthop-hostname */
17006 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17007 != SAVE_BGP_SHOW_HOSTNAME
)
17008 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17009 CHECK_FLAG(bgp
->flags
,
17010 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17014 /* BGP default subgroup-pkt-queue-max. */
17015 if (bgp
->default_subgroup_pkt_queue_max
17016 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17017 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17018 bgp
->default_subgroup_pkt_queue_max
);
17020 /* BGP client-to-client reflection. */
17021 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17022 vty_out(vty
, " no bgp client-to-client reflection\n");
17024 /* BGP cluster ID. */
17025 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17026 vty_out(vty
, " bgp cluster-id %pI4\n",
17029 /* Disable ebgp connected nexthop check */
17030 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17032 " bgp disable-ebgp-connected-route-check\n");
17034 /* Confederation identifier*/
17035 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17036 vty_out(vty
, " bgp confederation identifier %u\n",
17039 /* Confederation peer */
17040 if (bgp
->confed_peers_cnt
> 0) {
17043 vty_out(vty
, " bgp confederation peers");
17045 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17046 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17048 vty_out(vty
, "\n");
17051 /* BGP deterministic-med. */
17052 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17053 != SAVE_BGP_DETERMINISTIC_MED
)
17054 vty_out(vty
, " %sbgp deterministic-med\n",
17055 CHECK_FLAG(bgp
->flags
,
17056 BGP_FLAG_DETERMINISTIC_MED
)
17060 /* BGP update-delay. */
17061 bgp_config_write_update_delay(vty
, bgp
);
17063 if (bgp
->v_maxmed_onstartup
17064 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17065 vty_out(vty
, " bgp max-med on-startup %u",
17066 bgp
->v_maxmed_onstartup
);
17067 if (bgp
->maxmed_onstartup_value
17068 != BGP_MAXMED_VALUE_DEFAULT
)
17069 vty_out(vty
, " %u",
17070 bgp
->maxmed_onstartup_value
);
17071 vty_out(vty
, "\n");
17073 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17074 vty_out(vty
, " bgp max-med administrative");
17075 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17076 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17077 vty_out(vty
, "\n");
17081 bgp_config_write_wpkt_quanta(vty
, bgp
);
17083 bgp_config_write_rpkt_quanta(vty
, bgp
);
17085 /* coalesce time */
17086 bgp_config_write_coalesce_time(vty
, bgp
);
17088 /* BGP per-instance graceful-shutdown */
17089 /* BGP-wide settings and per-instance settings are mutually
17092 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17093 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17094 vty_out(vty
, " bgp graceful-shutdown\n");
17096 /* BGP graceful-restart. */
17097 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17099 " bgp graceful-restart stalepath-time %u\n",
17100 bgp
->stalepath_time
);
17102 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17103 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17104 bgp
->restart_time
);
17106 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17108 " bgp graceful-restart select-defer-time %u\n",
17109 bgp
->select_defer_time
);
17111 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17112 vty_out(vty
, " bgp graceful-restart\n");
17114 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17115 vty_out(vty
, " bgp graceful-restart-disable\n");
17117 /* BGP graceful-restart Preserve State F bit. */
17118 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17120 " bgp graceful-restart preserve-fw-state\n");
17122 /* Stale timer for RIB */
17123 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17125 " bgp graceful-restart rib-stale-time %u\n",
17126 bgp
->rib_stale_time
);
17128 /* BGP bestpath method. */
17129 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17130 vty_out(vty
, " bgp bestpath as-path ignore\n");
17131 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17132 vty_out(vty
, " bgp bestpath as-path confed\n");
17134 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17135 if (CHECK_FLAG(bgp
->flags
,
17136 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17138 " bgp bestpath as-path multipath-relax as-set\n");
17141 " bgp bestpath as-path multipath-relax\n");
17145 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17147 " bgp route-reflector allow-outbound-policy\n");
17149 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17150 vty_out(vty
, " bgp bestpath compare-routerid\n");
17151 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17152 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17153 vty_out(vty
, " bgp bestpath med");
17154 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17155 vty_out(vty
, " confed");
17156 if (CHECK_FLAG(bgp
->flags
,
17157 BGP_FLAG_MED_MISSING_AS_WORST
))
17158 vty_out(vty
, " missing-as-worst");
17159 vty_out(vty
, "\n");
17162 /* Link bandwidth handling. */
17163 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17164 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17165 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17166 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17167 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17168 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17170 /* BGP network import check. */
17171 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17172 != SAVE_BGP_IMPORT_CHECK
)
17173 vty_out(vty
, " %sbgp network import-check\n",
17174 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17178 /* BGP timers configuration. */
17179 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17180 && bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17181 vty_out(vty
, " timers bgp %u %u\n",
17182 bgp
->default_keepalive
, bgp
->default_holdtime
);
17185 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17186 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17189 /* Normal neighbor configuration. */
17190 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17191 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17192 bgp_config_write_peer_global(vty
, bgp
, peer
);
17195 /* listen range and limit for dynamic BGP neighbors */
17196 bgp_config_write_listen(vty
, bgp
);
17199 * BGP default autoshutdown neighbors
17201 * This must be placed after any peer and peer-group
17202 * configuration, to avoid setting all peers to shutdown after
17203 * a daemon restart, which is undesired behavior. (see #2286)
17205 if (bgp
->autoshutdown
)
17206 vty_out(vty
, " bgp default shutdown\n");
17208 /* BGP instance administrative shutdown */
17209 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17210 vty_out(vty
, " bgp shutdown\n");
17212 /* IPv4 unicast configuration. */
17213 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17215 /* IPv4 multicast configuration. */
17216 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17218 /* IPv4 labeled-unicast configuration. */
17219 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17221 /* IPv4 VPN configuration. */
17222 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17224 /* ENCAPv4 configuration. */
17225 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17227 /* FLOWSPEC v4 configuration. */
17228 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17230 /* IPv6 unicast configuration. */
17231 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17233 /* IPv6 multicast configuration. */
17234 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17236 /* IPv6 labeled-unicast configuration. */
17237 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17238 SAFI_LABELED_UNICAST
);
17240 /* IPv6 VPN configuration. */
17241 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17243 /* ENCAPv6 configuration. */
17244 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17246 /* FLOWSPEC v6 configuration. */
17247 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17249 /* EVPN configuration. */
17250 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17252 hook_call(bgp_inst_config_write
, bgp
, vty
);
17254 #ifdef ENABLE_BGP_VNC
17255 bgp_rfapi_cfg_write(vty
, bgp
);
17258 vty_out(vty
, "!\n");
17264 /* BGP node structure. */
17265 static struct cmd_node bgp_node
= {
17268 .parent_node
= CONFIG_NODE
,
17269 .prompt
= "%s(config-router)# ",
17270 .config_write
= bgp_config_write
,
17273 static struct cmd_node bgp_ipv4_unicast_node
= {
17274 .name
= "bgp ipv4 unicast",
17275 .node
= BGP_IPV4_NODE
,
17276 .parent_node
= BGP_NODE
,
17277 .prompt
= "%s(config-router-af)# ",
17280 static struct cmd_node bgp_ipv4_multicast_node
= {
17281 .name
= "bgp ipv4 multicast",
17282 .node
= BGP_IPV4M_NODE
,
17283 .parent_node
= BGP_NODE
,
17284 .prompt
= "%s(config-router-af)# ",
17287 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
17288 .name
= "bgp ipv4 labeled unicast",
17289 .node
= BGP_IPV4L_NODE
,
17290 .parent_node
= BGP_NODE
,
17291 .prompt
= "%s(config-router-af)# ",
17294 static struct cmd_node bgp_ipv6_unicast_node
= {
17295 .name
= "bgp ipv6",
17296 .node
= BGP_IPV6_NODE
,
17297 .parent_node
= BGP_NODE
,
17298 .prompt
= "%s(config-router-af)# ",
17301 static struct cmd_node bgp_ipv6_multicast_node
= {
17302 .name
= "bgp ipv6 multicast",
17303 .node
= BGP_IPV6M_NODE
,
17304 .parent_node
= BGP_NODE
,
17305 .prompt
= "%s(config-router-af)# ",
17308 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
17309 .name
= "bgp ipv6 labeled unicast",
17310 .node
= BGP_IPV6L_NODE
,
17311 .parent_node
= BGP_NODE
,
17312 .prompt
= "%s(config-router-af)# ",
17315 static struct cmd_node bgp_vpnv4_node
= {
17316 .name
= "bgp vpnv4",
17317 .node
= BGP_VPNV4_NODE
,
17318 .parent_node
= BGP_NODE
,
17319 .prompt
= "%s(config-router-af)# ",
17322 static struct cmd_node bgp_vpnv6_node
= {
17323 .name
= "bgp vpnv6",
17324 .node
= BGP_VPNV6_NODE
,
17325 .parent_node
= BGP_NODE
,
17326 .prompt
= "%s(config-router-af-vpnv6)# ",
17329 static struct cmd_node bgp_evpn_node
= {
17330 .name
= "bgp evpn",
17331 .node
= BGP_EVPN_NODE
,
17332 .parent_node
= BGP_NODE
,
17333 .prompt
= "%s(config-router-evpn)# ",
17336 static struct cmd_node bgp_evpn_vni_node
= {
17337 .name
= "bgp evpn vni",
17338 .node
= BGP_EVPN_VNI_NODE
,
17339 .parent_node
= BGP_EVPN_NODE
,
17340 .prompt
= "%s(config-router-af-vni)# ",
17343 static struct cmd_node bgp_flowspecv4_node
= {
17344 .name
= "bgp ipv4 flowspec",
17345 .node
= BGP_FLOWSPECV4_NODE
,
17346 .parent_node
= BGP_NODE
,
17347 .prompt
= "%s(config-router-af)# ",
17350 static struct cmd_node bgp_flowspecv6_node
= {
17351 .name
= "bgp ipv6 flowspec",
17352 .node
= BGP_FLOWSPECV6_NODE
,
17353 .parent_node
= BGP_NODE
,
17354 .prompt
= "%s(config-router-af-vpnv6)# ",
17357 static void community_list_vty(void);
17359 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
17363 struct listnode
*lnbgp
, *lnpeer
;
17365 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17366 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
17367 /* only provide suggestions on the appropriate input
17369 * they'll otherwise show up multiple times */
17370 enum cmd_token_type match_type
;
17371 char *name
= peer
->host
;
17373 if (peer
->conf_if
) {
17374 match_type
= VARIABLE_TKN
;
17375 name
= peer
->conf_if
;
17376 } else if (strchr(peer
->host
, ':'))
17377 match_type
= IPV6_TKN
;
17379 match_type
= IPV4_TKN
;
17381 if (token
->type
!= match_type
)
17384 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
17389 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
17390 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
17391 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
17392 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
17393 {.completions
= NULL
}};
17395 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
17398 struct peer_group
*group
;
17399 struct listnode
*lnbgp
, *lnpeer
;
17401 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17402 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
17403 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
17408 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
17409 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
17410 {.completions
= NULL
} };
17412 void bgp_vty_init(void)
17414 cmd_variable_handler_register(bgp_var_neighbor
);
17415 cmd_variable_handler_register(bgp_var_peergroup
);
17417 /* Install bgp top node. */
17418 install_node(&bgp_node
);
17419 install_node(&bgp_ipv4_unicast_node
);
17420 install_node(&bgp_ipv4_multicast_node
);
17421 install_node(&bgp_ipv4_labeled_unicast_node
);
17422 install_node(&bgp_ipv6_unicast_node
);
17423 install_node(&bgp_ipv6_multicast_node
);
17424 install_node(&bgp_ipv6_labeled_unicast_node
);
17425 install_node(&bgp_vpnv4_node
);
17426 install_node(&bgp_vpnv6_node
);
17427 install_node(&bgp_evpn_node
);
17428 install_node(&bgp_evpn_vni_node
);
17429 install_node(&bgp_flowspecv4_node
);
17430 install_node(&bgp_flowspecv6_node
);
17432 /* Install default VTY commands to new nodes. */
17433 install_default(BGP_NODE
);
17434 install_default(BGP_IPV4_NODE
);
17435 install_default(BGP_IPV4M_NODE
);
17436 install_default(BGP_IPV4L_NODE
);
17437 install_default(BGP_IPV6_NODE
);
17438 install_default(BGP_IPV6M_NODE
);
17439 install_default(BGP_IPV6L_NODE
);
17440 install_default(BGP_VPNV4_NODE
);
17441 install_default(BGP_VPNV6_NODE
);
17442 install_default(BGP_FLOWSPECV4_NODE
);
17443 install_default(BGP_FLOWSPECV6_NODE
);
17444 install_default(BGP_EVPN_NODE
);
17445 install_default(BGP_EVPN_VNI_NODE
);
17447 /* "bgp local-mac" hidden commands. */
17448 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
17449 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
17451 /* bgp route-map delay-timer commands. */
17452 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17453 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17455 /* global bgp update-delay command */
17456 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
17457 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
17459 /* global bgp graceful-shutdown command */
17460 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
17461 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
17463 /* Dummy commands (Currently not supported) */
17464 install_element(BGP_NODE
, &no_synchronization_cmd
);
17465 install_element(BGP_NODE
, &no_auto_summary_cmd
);
17467 /* "router bgp" commands. */
17468 install_element(CONFIG_NODE
, &router_bgp_cmd
);
17470 /* "no router bgp" commands. */
17471 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
17473 /* "bgp router-id" commands. */
17474 install_element(BGP_NODE
, &bgp_router_id_cmd
);
17475 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
17477 /* "bgp suppress-fib-pending" command */
17478 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
17480 /* "bgp cluster-id" commands. */
17481 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
17482 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
17484 /* "bgp no-rib" commands. */
17485 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
17486 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
17488 /* "bgp confederation" commands. */
17489 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
17490 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
17492 /* "bgp confederation peers" commands. */
17493 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
17494 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
17496 /* bgp max-med command */
17497 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
17498 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
17499 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
17500 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
17501 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
17503 /* bgp disable-ebgp-connected-nh-check */
17504 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
17505 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
17507 /* bgp update-delay command */
17508 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
17509 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
17511 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
17512 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
17514 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
17515 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
17517 /* "maximum-paths" commands. */
17518 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
17519 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
17520 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
17521 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
17522 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
17523 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
17524 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
17525 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
17526 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
17527 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
17528 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17529 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17530 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
17531 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17532 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17534 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
17535 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
17536 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17537 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17538 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17539 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
17540 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
17541 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17542 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17543 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17545 /* "timers bgp" commands. */
17546 install_element(BGP_NODE
, &bgp_timers_cmd
);
17547 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
17549 /* route-map delay-timer commands - per instance for backwards compat.
17551 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17552 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17554 /* "bgp client-to-client reflection" commands */
17555 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
17556 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
17558 /* "bgp always-compare-med" commands */
17559 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
17560 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
17562 /* bgp ebgp-requires-policy */
17563 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
17564 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
17566 /* bgp reject-as-sets */
17567 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
17568 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
17570 /* "bgp deterministic-med" commands */
17571 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
17572 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
17574 /* "bgp graceful-restart" command */
17575 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
17576 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
17578 /* "bgp graceful-restart-disable" command */
17579 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
17580 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
17582 /* "neighbor a:b:c:d graceful-restart" command */
17583 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
17584 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
17586 /* "neighbor a:b:c:d graceful-restart-disable" command */
17587 install_element(BGP_NODE
,
17588 &bgp_neighbor_graceful_restart_disable_set_cmd
);
17589 install_element(BGP_NODE
,
17590 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
17592 /* "neighbor a:b:c:d graceful-restart-helper" command */
17593 install_element(BGP_NODE
,
17594 &bgp_neighbor_graceful_restart_helper_set_cmd
);
17595 install_element(BGP_NODE
,
17596 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
17598 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
17599 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
17600 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
17601 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
17602 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
17603 install_element(BGP_NODE
,
17604 &no_bgp_graceful_restart_select_defer_time_cmd
);
17605 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
17606 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
17608 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
17609 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
17610 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
17611 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
17613 /* "bgp graceful-shutdown" commands */
17614 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
17615 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
17617 /* "bgp fast-external-failover" commands */
17618 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
17619 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
17621 /* "bgp bestpath compare-routerid" commands */
17622 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
17623 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
17625 /* "bgp bestpath as-path ignore" commands */
17626 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
17627 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
17629 /* "bgp bestpath as-path confed" commands */
17630 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
17631 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
17633 /* "bgp bestpath as-path multipath-relax" commands */
17634 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
17635 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
17637 /* "bgp log-neighbor-changes" commands */
17638 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
17639 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
17641 /* "bgp bestpath med" commands */
17642 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
17643 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
17645 /* "bgp bestpath bandwidth" commands */
17646 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
17647 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
17649 /* "no bgp default ipv4-unicast" commands. */
17650 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
17651 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
17653 /* "bgp network import-check" commands. */
17654 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
17655 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
17656 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
17658 /* "bgp default local-preference" commands. */
17659 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
17660 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
17662 /* bgp default show-hostname */
17663 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
17664 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
17666 /* bgp default show-nexthop-hostname */
17667 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
17668 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
17670 /* "bgp default subgroup-pkt-queue-max" commands. */
17671 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
17672 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
17674 /* bgp ibgp-allow-policy-mods command */
17675 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
17676 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
17678 /* "bgp listen limit" commands. */
17679 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
17680 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
17682 /* "bgp listen range" commands. */
17683 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
17684 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
17686 /* "bgp default shutdown" command */
17687 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
17689 /* "bgp shutdown" commands */
17690 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
17691 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
17692 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
17693 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
17695 /* "neighbor remote-as" commands. */
17696 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
17697 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
17698 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
17699 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
17700 install_element(BGP_NODE
,
17701 &neighbor_interface_v6only_config_remote_as_cmd
);
17702 install_element(BGP_NODE
, &no_neighbor_cmd
);
17703 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
17705 /* "neighbor peer-group" commands. */
17706 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
17707 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
17708 install_element(BGP_NODE
,
17709 &no_neighbor_interface_peer_group_remote_as_cmd
);
17711 /* "neighbor local-as" commands. */
17712 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
17713 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
17714 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
17715 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
17717 /* "neighbor solo" commands. */
17718 install_element(BGP_NODE
, &neighbor_solo_cmd
);
17719 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
17721 /* "neighbor password" commands. */
17722 install_element(BGP_NODE
, &neighbor_password_cmd
);
17723 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
17725 /* "neighbor activate" commands. */
17726 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
17727 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
17728 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
17729 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
17730 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
17731 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
17732 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
17733 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
17734 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
17735 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
17736 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
17737 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
17739 /* "no neighbor activate" commands. */
17740 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
17741 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
17742 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
17743 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
17744 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
17745 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
17746 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
17747 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
17748 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
17749 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
17750 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
17751 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
17753 /* "neighbor peer-group" set commands. */
17754 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
17755 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17756 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17757 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17758 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17759 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17760 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17761 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17762 install_element(BGP_FLOWSPECV4_NODE
,
17763 &neighbor_set_peer_group_hidden_cmd
);
17764 install_element(BGP_FLOWSPECV6_NODE
,
17765 &neighbor_set_peer_group_hidden_cmd
);
17767 /* "no neighbor peer-group unset" commands. */
17768 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
17769 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17770 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17771 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17772 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17773 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17774 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17775 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17776 install_element(BGP_FLOWSPECV4_NODE
,
17777 &no_neighbor_set_peer_group_hidden_cmd
);
17778 install_element(BGP_FLOWSPECV6_NODE
,
17779 &no_neighbor_set_peer_group_hidden_cmd
);
17781 /* "neighbor softreconfiguration inbound" commands.*/
17782 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
17783 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
17784 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
17785 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17786 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
17787 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17788 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
17789 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17790 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
17791 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17792 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
17793 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17794 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
17795 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17796 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
17797 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17798 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
17799 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17800 install_element(BGP_FLOWSPECV4_NODE
,
17801 &neighbor_soft_reconfiguration_cmd
);
17802 install_element(BGP_FLOWSPECV4_NODE
,
17803 &no_neighbor_soft_reconfiguration_cmd
);
17804 install_element(BGP_FLOWSPECV6_NODE
,
17805 &neighbor_soft_reconfiguration_cmd
);
17806 install_element(BGP_FLOWSPECV6_NODE
,
17807 &no_neighbor_soft_reconfiguration_cmd
);
17808 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
17809 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17811 /* "neighbor attribute-unchanged" commands. */
17812 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
17813 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
17814 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
17815 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
17816 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
17817 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
17818 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
17819 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
17820 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
17821 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
17822 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
17823 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
17824 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
17825 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
17826 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
17827 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
17828 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
17829 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
17831 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
17832 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
17834 /* "nexthop-local unchanged" commands */
17835 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
17836 install_element(BGP_IPV6_NODE
,
17837 &no_neighbor_nexthop_local_unchanged_cmd
);
17839 /* "neighbor next-hop-self" commands. */
17840 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
17841 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
17842 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
17843 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
17844 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
17845 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
17846 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
17847 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
17848 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
17849 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
17850 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
17851 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
17852 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
17853 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
17854 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
17855 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
17856 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
17857 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
17858 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
17859 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
17861 /* "neighbor next-hop-self force" commands. */
17862 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
17863 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
17864 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17865 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
17866 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
17867 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17868 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17869 install_element(BGP_IPV4_NODE
,
17870 &no_neighbor_nexthop_self_all_hidden_cmd
);
17871 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
17872 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17873 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17874 install_element(BGP_IPV4M_NODE
,
17875 &no_neighbor_nexthop_self_all_hidden_cmd
);
17876 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
17877 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17878 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17879 install_element(BGP_IPV4L_NODE
,
17880 &no_neighbor_nexthop_self_all_hidden_cmd
);
17881 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
17882 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17883 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17884 install_element(BGP_IPV6_NODE
,
17885 &no_neighbor_nexthop_self_all_hidden_cmd
);
17886 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
17887 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17888 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17889 install_element(BGP_IPV6M_NODE
,
17890 &no_neighbor_nexthop_self_all_hidden_cmd
);
17891 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
17892 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17893 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17894 install_element(BGP_IPV6L_NODE
,
17895 &no_neighbor_nexthop_self_all_hidden_cmd
);
17896 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
17897 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17898 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17899 install_element(BGP_VPNV4_NODE
,
17900 &no_neighbor_nexthop_self_all_hidden_cmd
);
17901 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
17902 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17903 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17904 install_element(BGP_VPNV6_NODE
,
17905 &no_neighbor_nexthop_self_all_hidden_cmd
);
17906 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
17907 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17909 /* "neighbor as-override" commands. */
17910 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
17911 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
17912 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
17913 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
17914 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
17915 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
17916 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
17917 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
17918 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
17919 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
17920 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
17921 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
17922 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
17923 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
17924 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
17925 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
17926 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
17927 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
17929 /* "neighbor remove-private-AS" commands. */
17930 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
17931 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
17932 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
17933 install_element(BGP_NODE
,
17934 &no_neighbor_remove_private_as_all_hidden_cmd
);
17935 install_element(BGP_NODE
,
17936 &neighbor_remove_private_as_replace_as_hidden_cmd
);
17937 install_element(BGP_NODE
,
17938 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
17939 install_element(BGP_NODE
,
17940 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
17943 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
17944 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
17945 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
17946 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
17947 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
17948 install_element(BGP_IPV4_NODE
,
17949 &neighbor_remove_private_as_replace_as_cmd
);
17950 install_element(BGP_IPV4_NODE
,
17951 &no_neighbor_remove_private_as_replace_as_cmd
);
17952 install_element(BGP_IPV4_NODE
,
17953 &neighbor_remove_private_as_all_replace_as_cmd
);
17954 install_element(BGP_IPV4_NODE
,
17955 &no_neighbor_remove_private_as_all_replace_as_cmd
);
17956 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
17957 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
17958 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
17959 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
17960 install_element(BGP_IPV4M_NODE
,
17961 &neighbor_remove_private_as_replace_as_cmd
);
17962 install_element(BGP_IPV4M_NODE
,
17963 &no_neighbor_remove_private_as_replace_as_cmd
);
17964 install_element(BGP_IPV4M_NODE
,
17965 &neighbor_remove_private_as_all_replace_as_cmd
);
17966 install_element(BGP_IPV4M_NODE
,
17967 &no_neighbor_remove_private_as_all_replace_as_cmd
);
17968 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
17969 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
17970 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
17971 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
17972 install_element(BGP_IPV4L_NODE
,
17973 &neighbor_remove_private_as_replace_as_cmd
);
17974 install_element(BGP_IPV4L_NODE
,
17975 &no_neighbor_remove_private_as_replace_as_cmd
);
17976 install_element(BGP_IPV4L_NODE
,
17977 &neighbor_remove_private_as_all_replace_as_cmd
);
17978 install_element(BGP_IPV4L_NODE
,
17979 &no_neighbor_remove_private_as_all_replace_as_cmd
);
17980 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
17981 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
17982 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
17983 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
17984 install_element(BGP_IPV6_NODE
,
17985 &neighbor_remove_private_as_replace_as_cmd
);
17986 install_element(BGP_IPV6_NODE
,
17987 &no_neighbor_remove_private_as_replace_as_cmd
);
17988 install_element(BGP_IPV6_NODE
,
17989 &neighbor_remove_private_as_all_replace_as_cmd
);
17990 install_element(BGP_IPV6_NODE
,
17991 &no_neighbor_remove_private_as_all_replace_as_cmd
);
17992 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
17993 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
17994 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
17995 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
17996 install_element(BGP_IPV6M_NODE
,
17997 &neighbor_remove_private_as_replace_as_cmd
);
17998 install_element(BGP_IPV6M_NODE
,
17999 &no_neighbor_remove_private_as_replace_as_cmd
);
18000 install_element(BGP_IPV6M_NODE
,
18001 &neighbor_remove_private_as_all_replace_as_cmd
);
18002 install_element(BGP_IPV6M_NODE
,
18003 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18004 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
18005 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
18006 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
18007 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18008 install_element(BGP_IPV6L_NODE
,
18009 &neighbor_remove_private_as_replace_as_cmd
);
18010 install_element(BGP_IPV6L_NODE
,
18011 &no_neighbor_remove_private_as_replace_as_cmd
);
18012 install_element(BGP_IPV6L_NODE
,
18013 &neighbor_remove_private_as_all_replace_as_cmd
);
18014 install_element(BGP_IPV6L_NODE
,
18015 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18016 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
18017 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18018 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18019 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18020 install_element(BGP_VPNV4_NODE
,
18021 &neighbor_remove_private_as_replace_as_cmd
);
18022 install_element(BGP_VPNV4_NODE
,
18023 &no_neighbor_remove_private_as_replace_as_cmd
);
18024 install_element(BGP_VPNV4_NODE
,
18025 &neighbor_remove_private_as_all_replace_as_cmd
);
18026 install_element(BGP_VPNV4_NODE
,
18027 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18028 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
18029 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18030 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18031 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18032 install_element(BGP_VPNV6_NODE
,
18033 &neighbor_remove_private_as_replace_as_cmd
);
18034 install_element(BGP_VPNV6_NODE
,
18035 &no_neighbor_remove_private_as_replace_as_cmd
);
18036 install_element(BGP_VPNV6_NODE
,
18037 &neighbor_remove_private_as_all_replace_as_cmd
);
18038 install_element(BGP_VPNV6_NODE
,
18039 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18041 /* "neighbor send-community" commands.*/
18042 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
18043 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
18044 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
18045 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
18046 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
18047 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
18048 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
18049 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
18050 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
18051 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
18052 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
18053 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
18054 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
18055 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
18056 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
18057 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
18058 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
18059 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
18060 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
18061 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
18062 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
18063 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
18064 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
18065 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
18066 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
18067 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
18068 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
18069 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
18070 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
18071 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
18072 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
18073 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
18074 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
18075 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
18076 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
18077 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
18079 /* "neighbor route-reflector" commands.*/
18080 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
18081 install_element(BGP_NODE
,
18082 &no_neighbor_route_reflector_client_hidden_cmd
);
18083 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
18084 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
18085 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
18086 install_element(BGP_IPV4M_NODE
,
18087 &no_neighbor_route_reflector_client_cmd
);
18088 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
18089 install_element(BGP_IPV4L_NODE
,
18090 &no_neighbor_route_reflector_client_cmd
);
18091 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
18092 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
18093 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
18094 install_element(BGP_IPV6M_NODE
,
18095 &no_neighbor_route_reflector_client_cmd
);
18096 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
18097 install_element(BGP_IPV6L_NODE
,
18098 &no_neighbor_route_reflector_client_cmd
);
18099 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
18100 install_element(BGP_VPNV4_NODE
,
18101 &no_neighbor_route_reflector_client_cmd
);
18102 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
18103 install_element(BGP_VPNV6_NODE
,
18104 &no_neighbor_route_reflector_client_cmd
);
18105 install_element(BGP_FLOWSPECV4_NODE
,
18106 &neighbor_route_reflector_client_cmd
);
18107 install_element(BGP_FLOWSPECV4_NODE
,
18108 &no_neighbor_route_reflector_client_cmd
);
18109 install_element(BGP_FLOWSPECV6_NODE
,
18110 &neighbor_route_reflector_client_cmd
);
18111 install_element(BGP_FLOWSPECV6_NODE
,
18112 &no_neighbor_route_reflector_client_cmd
);
18113 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
18114 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
18116 /* "neighbor route-server" commands.*/
18117 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
18118 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
18119 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
18120 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
18121 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
18122 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
18123 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
18124 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
18125 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
18126 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
18127 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
18128 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
18129 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
18130 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
18131 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
18132 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
18133 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
18134 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
18135 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
18136 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
18137 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
18138 install_element(BGP_FLOWSPECV4_NODE
,
18139 &no_neighbor_route_server_client_cmd
);
18140 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
18141 install_element(BGP_FLOWSPECV6_NODE
,
18142 &no_neighbor_route_server_client_cmd
);
18144 /* "neighbor addpath-tx-all-paths" commands.*/
18145 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
18146 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
18147 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18148 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18149 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18150 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18151 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18152 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18153 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18154 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18155 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18156 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18157 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18158 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18159 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18160 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18161 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18162 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18164 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
18165 install_element(BGP_NODE
,
18166 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18167 install_element(BGP_NODE
,
18168 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18169 install_element(BGP_IPV4_NODE
,
18170 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18171 install_element(BGP_IPV4_NODE
,
18172 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18173 install_element(BGP_IPV4M_NODE
,
18174 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18175 install_element(BGP_IPV4M_NODE
,
18176 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18177 install_element(BGP_IPV4L_NODE
,
18178 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18179 install_element(BGP_IPV4L_NODE
,
18180 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18181 install_element(BGP_IPV6_NODE
,
18182 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18183 install_element(BGP_IPV6_NODE
,
18184 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18185 install_element(BGP_IPV6M_NODE
,
18186 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18187 install_element(BGP_IPV6M_NODE
,
18188 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18189 install_element(BGP_IPV6L_NODE
,
18190 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18191 install_element(BGP_IPV6L_NODE
,
18192 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18193 install_element(BGP_VPNV4_NODE
,
18194 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18195 install_element(BGP_VPNV4_NODE
,
18196 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18197 install_element(BGP_VPNV6_NODE
,
18198 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18199 install_element(BGP_VPNV6_NODE
,
18200 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18202 /* "neighbor sender-as-path-loop-detection" commands. */
18203 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
18204 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
18206 /* "neighbor passive" commands. */
18207 install_element(BGP_NODE
, &neighbor_passive_cmd
);
18208 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
18211 /* "neighbor shutdown" commands. */
18212 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
18213 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
18214 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
18215 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
18216 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
18217 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
18219 /* "neighbor capability extended-nexthop" commands.*/
18220 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
18221 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
18223 /* "neighbor capability orf prefix-list" commands.*/
18224 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
18225 install_element(BGP_NODE
,
18226 &no_neighbor_capability_orf_prefix_hidden_cmd
);
18227 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
18228 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18229 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18230 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18231 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18232 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18233 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
18234 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18235 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18236 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18237 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18238 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18240 /* "neighbor capability dynamic" commands.*/
18241 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
18242 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
18244 /* "neighbor dont-capability-negotiate" commands. */
18245 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
18246 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
18248 /* "neighbor ebgp-multihop" commands. */
18249 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
18250 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
18251 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
18253 /* "neighbor disable-connected-check" commands. */
18254 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
18255 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
18257 /* "neighbor enforce-first-as" commands. */
18258 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
18259 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
18261 /* "neighbor description" commands. */
18262 install_element(BGP_NODE
, &neighbor_description_cmd
);
18263 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
18264 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
18266 /* "neighbor update-source" commands. "*/
18267 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
18268 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
18270 /* "neighbor default-originate" commands. */
18271 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
18272 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
18273 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
18274 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
18275 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
18276 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
18277 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
18278 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
18279 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
18280 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
18281 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
18282 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
18283 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
18284 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
18285 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
18286 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
18287 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
18288 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
18289 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
18290 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
18291 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
18293 /* "neighbor port" commands. */
18294 install_element(BGP_NODE
, &neighbor_port_cmd
);
18295 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
18297 /* "neighbor weight" commands. */
18298 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
18299 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
18301 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
18302 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
18303 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
18304 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
18305 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
18306 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
18307 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
18308 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
18309 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
18310 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
18311 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
18312 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
18313 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
18314 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
18315 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
18316 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
18318 /* "neighbor override-capability" commands. */
18319 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
18320 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
18322 /* "neighbor strict-capability-match" commands. */
18323 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
18324 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
18326 /* "neighbor timers" commands. */
18327 install_element(BGP_NODE
, &neighbor_timers_cmd
);
18328 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
18330 /* "neighbor timers connect" commands. */
18331 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
18332 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
18334 /* "neighbor timers delayopen" commands. */
18335 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
18336 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
18338 /* "neighbor advertisement-interval" commands. */
18339 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
18340 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
18342 /* "neighbor interface" commands. */
18343 install_element(BGP_NODE
, &neighbor_interface_cmd
);
18344 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
18346 /* "neighbor distribute" commands. */
18347 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
18348 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
18349 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
18350 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
18351 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
18352 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
18353 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
18354 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
18355 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
18356 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
18357 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
18358 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
18359 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
18360 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
18361 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
18362 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
18363 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
18364 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
18366 /* "neighbor prefix-list" commands. */
18367 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
18368 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
18369 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
18370 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
18371 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
18372 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
18373 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
18374 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
18375 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
18376 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
18377 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
18378 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
18379 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
18380 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
18381 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
18382 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
18383 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
18384 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
18385 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
18386 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
18387 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
18388 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
18390 /* "neighbor filter-list" commands. */
18391 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
18392 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
18393 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
18394 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
18395 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
18396 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
18397 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
18398 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
18399 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
18400 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
18401 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
18402 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
18403 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
18404 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
18405 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
18406 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
18407 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
18408 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
18409 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
18410 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
18411 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
18412 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
18414 /* "neighbor route-map" commands. */
18415 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
18416 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
18417 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
18418 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
18419 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
18420 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
18421 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
18422 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
18423 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
18424 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
18425 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
18426 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
18427 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
18428 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
18429 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
18430 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
18431 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
18432 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
18433 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
18434 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
18435 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
18436 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
18437 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
18438 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
18440 /* "neighbor unsuppress-map" commands. */
18441 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
18442 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
18443 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
18444 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18445 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
18446 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18447 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
18448 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18449 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
18450 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18451 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
18452 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18453 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
18454 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18455 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
18456 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18457 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
18458 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18460 /* "neighbor advertise-map" commands. */
18461 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
18462 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
18463 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
18464 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
18465 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
18466 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
18467 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
18468 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
18469 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
18471 /* neighbor maximum-prefix-out commands. */
18472 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
18473 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18474 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18475 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18476 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18477 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18478 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18479 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18480 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18481 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18482 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18483 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18484 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18485 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18486 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18487 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18488 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18489 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18491 /* "neighbor maximum-prefix" commands. */
18492 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
18493 install_element(BGP_NODE
,
18494 &neighbor_maximum_prefix_threshold_hidden_cmd
);
18495 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
18496 install_element(BGP_NODE
,
18497 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
18498 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
18499 install_element(BGP_NODE
,
18500 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
18501 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
18502 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
18503 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18504 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18505 install_element(BGP_IPV4_NODE
,
18506 &neighbor_maximum_prefix_threshold_warning_cmd
);
18507 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18508 install_element(BGP_IPV4_NODE
,
18509 &neighbor_maximum_prefix_threshold_restart_cmd
);
18510 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18511 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
18512 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18513 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18514 install_element(BGP_IPV4M_NODE
,
18515 &neighbor_maximum_prefix_threshold_warning_cmd
);
18516 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18517 install_element(BGP_IPV4M_NODE
,
18518 &neighbor_maximum_prefix_threshold_restart_cmd
);
18519 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18520 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
18521 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18522 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18523 install_element(BGP_IPV4L_NODE
,
18524 &neighbor_maximum_prefix_threshold_warning_cmd
);
18525 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18526 install_element(BGP_IPV4L_NODE
,
18527 &neighbor_maximum_prefix_threshold_restart_cmd
);
18528 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18529 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
18530 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18531 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18532 install_element(BGP_IPV6_NODE
,
18533 &neighbor_maximum_prefix_threshold_warning_cmd
);
18534 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18535 install_element(BGP_IPV6_NODE
,
18536 &neighbor_maximum_prefix_threshold_restart_cmd
);
18537 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18538 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
18539 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18540 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18541 install_element(BGP_IPV6M_NODE
,
18542 &neighbor_maximum_prefix_threshold_warning_cmd
);
18543 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18544 install_element(BGP_IPV6M_NODE
,
18545 &neighbor_maximum_prefix_threshold_restart_cmd
);
18546 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18547 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
18548 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18549 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18550 install_element(BGP_IPV6L_NODE
,
18551 &neighbor_maximum_prefix_threshold_warning_cmd
);
18552 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18553 install_element(BGP_IPV6L_NODE
,
18554 &neighbor_maximum_prefix_threshold_restart_cmd
);
18555 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18556 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
18557 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18558 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18559 install_element(BGP_VPNV4_NODE
,
18560 &neighbor_maximum_prefix_threshold_warning_cmd
);
18561 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18562 install_element(BGP_VPNV4_NODE
,
18563 &neighbor_maximum_prefix_threshold_restart_cmd
);
18564 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18565 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
18566 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18567 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18568 install_element(BGP_VPNV6_NODE
,
18569 &neighbor_maximum_prefix_threshold_warning_cmd
);
18570 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18571 install_element(BGP_VPNV6_NODE
,
18572 &neighbor_maximum_prefix_threshold_restart_cmd
);
18573 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18575 /* "neighbor allowas-in" */
18576 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
18577 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
18578 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
18579 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
18580 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
18581 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
18582 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
18583 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
18584 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
18585 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
18586 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
18587 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
18588 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
18589 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
18590 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
18591 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
18592 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
18593 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
18594 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
18595 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
18597 /* address-family commands. */
18598 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
18599 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
18600 #ifdef KEEP_OLD_VPN_COMMANDS
18601 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
18602 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
18603 #endif /* KEEP_OLD_VPN_COMMANDS */
18605 install_element(BGP_NODE
, &address_family_evpn_cmd
);
18607 /* "exit-address-family" command. */
18608 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
18609 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
18610 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
18611 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
18612 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
18613 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
18614 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
18615 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
18616 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
18617 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
18618 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
18620 /* "clear ip bgp commands" */
18621 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
18623 /* clear ip bgp prefix */
18624 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
18625 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
18626 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
18628 /* "show [ip] bgp summary" commands. */
18629 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
18630 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
18631 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
18632 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
18633 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
18634 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
18635 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
18637 /* "show [ip] bgp neighbors" commands. */
18638 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
18640 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
18642 /* "show [ip] bgp peer-group" commands. */
18643 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
18645 /* "show [ip] bgp paths" commands. */
18646 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
18648 /* "show [ip] bgp community" commands. */
18649 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
18651 /* "show ip bgp large-community" commands. */
18652 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
18653 /* "show [ip] bgp attribute-info" commands. */
18654 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
18655 /* "show [ip] bgp route-leak" command */
18656 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
18658 /* "redistribute" commands. */
18659 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
18660 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
18661 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
18662 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
18663 install_element(BGP_NODE
,
18664 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
18665 install_element(BGP_NODE
,
18666 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
18667 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
18668 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
18669 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
18670 install_element(BGP_NODE
,
18671 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
18672 install_element(BGP_NODE
,
18673 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
18674 install_element(BGP_NODE
,
18675 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
18676 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
18677 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
18678 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
18679 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
18680 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
18681 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
18682 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
18683 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
18684 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
18685 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
18686 install_element(BGP_IPV4_NODE
,
18687 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
18688 install_element(BGP_IPV4_NODE
,
18689 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
18690 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
18691 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
18692 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
18693 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
18694 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
18695 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
18697 /* import|export vpn [route-map WORD] */
18698 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
18699 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
18701 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
18702 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
18704 /* ttl_security commands */
18705 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
18706 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
18708 /* "show [ip] bgp memory" commands. */
18709 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
18711 /* "show bgp martian next-hop" */
18712 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
18714 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
18716 /* "show [ip] bgp views" commands. */
18717 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
18719 /* "show [ip] bgp vrfs" commands. */
18720 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
18722 /* Community-list. */
18723 community_list_vty();
18725 /* vpn-policy commands */
18726 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
18727 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
18728 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
18729 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
18730 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
18731 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
18732 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
18733 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
18734 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
18735 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
18736 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
18737 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
18739 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
18740 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
18742 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
18743 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
18744 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
18745 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
18746 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
18747 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
18748 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
18749 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
18750 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
18751 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
18754 #include "memory.h"
18755 #include "bgp_regex.h"
18756 #include "bgp_clist.h"
18757 #include "bgp_ecommunity.h"
18759 /* VTY functions. */
18761 /* Direction value to string conversion. */
18762 static const char *community_direct_str(int direct
)
18765 case COMMUNITY_DENY
:
18767 case COMMUNITY_PERMIT
:
18774 /* Display error string. */
18775 static void community_list_perror(struct vty
*vty
, int ret
)
18778 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
18779 vty_out(vty
, "%% Can't find community-list\n");
18781 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
18782 vty_out(vty
, "%% Malformed community-list value\n");
18784 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
18786 "%% Community name conflict, previously defined as standard community\n");
18788 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
18790 "%% Community name conflict, previously defined as expanded community\n");
18795 /* "community-list" keyword help string. */
18796 #define COMMUNITY_LIST_STR "Add a community list entry\n"
18798 /*community-list standard */
18799 DEFUN (community_list_standard
,
18800 bgp_community_list_standard_cmd
,
18801 "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
18804 "Community list number (standard)\n"
18805 "Add an standard community-list entry\n"
18806 "Community list name\n"
18807 "Sequence number of an entry\n"
18808 "Sequence number\n"
18809 "Specify community to reject\n"
18810 "Specify community to accept\n"
18813 char *cl_name_or_number
= NULL
;
18816 int style
= COMMUNITY_LIST_STANDARD
;
18819 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
18821 seq
= argv
[idx
]->arg
;
18824 argv_find(argv
, argc
, "(1-99)", &idx
);
18825 argv_find(argv
, argc
, "WORD", &idx
);
18826 cl_name_or_number
= argv
[idx
]->arg
;
18827 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
18829 argv_find(argv
, argc
, "AA:NN", &idx
);
18830 char *str
= argv_concat(argv
, argc
, idx
);
18832 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
18835 XFREE(MTYPE_TMP
, str
);
18838 /* Display error string. */
18839 community_list_perror(vty
, ret
);
18840 return CMD_WARNING_CONFIG_FAILED
;
18843 return CMD_SUCCESS
;
18846 DEFUN (no_community_list_standard_all
,
18847 no_bgp_community_list_standard_all_cmd
,
18848 "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
18852 "Community list number (standard)\n"
18853 "Add an standard community-list entry\n"
18854 "Community list name\n"
18855 "Sequence number of an entry\n"
18856 "Sequence number\n"
18857 "Specify community to reject\n"
18858 "Specify community to accept\n"
18861 char *cl_name_or_number
= NULL
;
18864 int style
= COMMUNITY_LIST_STANDARD
;
18868 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
18870 seq
= argv
[idx
]->arg
;
18873 argv_find(argv
, argc
, "permit", &idx
);
18874 argv_find(argv
, argc
, "deny", &idx
);
18877 direct
= argv_find(argv
, argc
, "permit", &idx
)
18882 argv_find(argv
, argc
, "AA:NN", &idx
);
18883 str
= argv_concat(argv
, argc
, idx
);
18887 argv_find(argv
, argc
, "(1-99)", &idx
);
18888 argv_find(argv
, argc
, "WORD", &idx
);
18889 cl_name_or_number
= argv
[idx
]->arg
;
18891 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
18894 XFREE(MTYPE_TMP
, str
);
18897 community_list_perror(vty
, ret
);
18898 return CMD_WARNING_CONFIG_FAILED
;
18901 return CMD_SUCCESS
;
18904 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
18905 "no bgp community-list <(1-99)|standard WORD>",
18906 NO_STR BGP_STR COMMUNITY_LIST_STR
18907 "Community list number (standard)\n"
18908 "Add an standard community-list entry\n"
18909 "Community list name\n")
18911 /*community-list expanded */
18912 DEFUN (community_list_expanded_all
,
18913 bgp_community_list_expanded_all_cmd
,
18914 "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
18917 "Community list number (expanded)\n"
18918 "Add an expanded community-list entry\n"
18919 "Community list name\n"
18920 "Sequence number of an entry\n"
18921 "Sequence number\n"
18922 "Specify community to reject\n"
18923 "Specify community to accept\n"
18926 char *cl_name_or_number
= NULL
;
18929 int style
= COMMUNITY_LIST_EXPANDED
;
18932 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
18934 seq
= argv
[idx
]->arg
;
18938 argv_find(argv
, argc
, "(100-500)", &idx
);
18939 argv_find(argv
, argc
, "WORD", &idx
);
18940 cl_name_or_number
= argv
[idx
]->arg
;
18941 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
18943 argv_find(argv
, argc
, "AA:NN", &idx
);
18944 char *str
= argv_concat(argv
, argc
, idx
);
18946 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
18949 XFREE(MTYPE_TMP
, str
);
18952 /* Display error string. */
18953 community_list_perror(vty
, ret
);
18954 return CMD_WARNING_CONFIG_FAILED
;
18957 return CMD_SUCCESS
;
18960 DEFUN (no_community_list_expanded_all
,
18961 no_bgp_community_list_expanded_all_cmd
,
18962 "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
18966 "Community list number (expanded)\n"
18967 "Add an expanded community-list entry\n"
18968 "Community list name\n"
18969 "Sequence number of an entry\n"
18970 "Sequence number\n"
18971 "Specify community to reject\n"
18972 "Specify community to accept\n"
18975 char *cl_name_or_number
= NULL
;
18979 int style
= COMMUNITY_LIST_EXPANDED
;
18982 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
18984 seq
= argv
[idx
]->arg
;
18987 argv_find(argv
, argc
, "permit", &idx
);
18988 argv_find(argv
, argc
, "deny", &idx
);
18991 direct
= argv_find(argv
, argc
, "permit", &idx
)
18996 argv_find(argv
, argc
, "AA:NN", &idx
);
18997 str
= argv_concat(argv
, argc
, idx
);
19001 argv_find(argv
, argc
, "(100-500)", &idx
);
19002 argv_find(argv
, argc
, "WORD", &idx
);
19003 cl_name_or_number
= argv
[idx
]->arg
;
19005 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19008 XFREE(MTYPE_TMP
, str
);
19011 community_list_perror(vty
, ret
);
19012 return CMD_WARNING_CONFIG_FAILED
;
19015 return CMD_SUCCESS
;
19018 ALIAS(no_community_list_expanded_all
,
19019 no_bgp_community_list_expanded_all_list_cmd
,
19020 "no bgp community-list <(100-500)|expanded WORD>",
19021 NO_STR BGP_STR COMMUNITY_LIST_STR
19022 "Community list number (expanded)\n"
19023 "Add an expanded community-list entry\n"
19024 "Community list name\n")
19026 /* Return configuration string of community-list entry. */
19027 static const char *community_list_config_str(struct community_entry
*entry
)
19034 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
19035 str
= community_str(entry
->u
.com
, false);
19036 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
19037 str
= lcommunity_str(entry
->u
.lcom
, false);
19039 str
= entry
->config
;
19044 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
19046 struct community_entry
*entry
;
19048 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19049 if (entry
== list
->head
) {
19050 if (all_digit(list
->name
))
19051 vty_out(vty
, "Community %s list %s\n",
19052 entry
->style
== COMMUNITY_LIST_STANDARD
19054 : "(expanded) access",
19057 vty_out(vty
, "Named Community %s list %s\n",
19058 entry
->style
== COMMUNITY_LIST_STANDARD
19064 vty_out(vty
, " %s\n",
19065 community_direct_str(entry
->direct
));
19067 vty_out(vty
, " %s %s\n",
19068 community_direct_str(entry
->direct
),
19069 community_list_config_str(entry
));
19073 DEFUN (show_community_list
,
19074 show_bgp_community_list_cmd
,
19075 "show bgp community-list",
19078 "List community-list\n")
19080 struct community_list
*list
;
19081 struct community_list_master
*cm
;
19083 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19085 return CMD_SUCCESS
;
19087 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19088 community_list_show(vty
, list
);
19090 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19091 community_list_show(vty
, list
);
19093 return CMD_SUCCESS
;
19096 DEFUN (show_community_list_arg
,
19097 show_bgp_community_list_arg_cmd
,
19098 "show bgp community-list <(1-500)|WORD> detail",
19101 "List community-list\n"
19102 "Community-list number\n"
19103 "Community-list name\n"
19104 "Detailed information on community-list\n")
19106 int idx_comm_list
= 3;
19107 struct community_list
*list
;
19109 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
19110 COMMUNITY_LIST_MASTER
);
19112 vty_out(vty
, "%% Can't find community-list\n");
19113 return CMD_WARNING
;
19116 community_list_show(vty
, list
);
19118 return CMD_SUCCESS
;
19122 * Large Community code.
19124 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
19125 struct cmd_token
**argv
, int style
,
19126 int reject_all_digit_name
)
19135 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19136 seq
= argv
[idx
]->arg
;
19139 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19142 /* All digit name check. */
19144 argv_find(argv
, argc
, "WORD", &idx
);
19145 argv_find(argv
, argc
, "(1-99)", &idx
);
19146 argv_find(argv
, argc
, "(100-500)", &idx
);
19147 cl_name
= argv
[idx
]->arg
;
19148 if (reject_all_digit_name
&& all_digit(cl_name
)) {
19149 vty_out(vty
, "%% Community name cannot have all digits\n");
19150 return CMD_WARNING_CONFIG_FAILED
;
19154 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
19155 argv_find(argv
, argc
, "LINE", &idx
);
19156 /* Concat community string argument. */
19158 str
= argv_concat(argv
, argc
, idx
);
19162 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
19164 /* Free temporary community list string allocated by
19166 XFREE(MTYPE_TMP
, str
);
19169 community_list_perror(vty
, ret
);
19170 return CMD_WARNING_CONFIG_FAILED
;
19172 return CMD_SUCCESS
;
19175 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
19176 struct cmd_token
**argv
, int style
)
19184 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19185 seq
= argv
[idx
]->arg
;
19188 argv_find(argv
, argc
, "permit", &idx
);
19189 argv_find(argv
, argc
, "deny", &idx
);
19192 /* Check the list direct. */
19193 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
19194 direct
= COMMUNITY_PERMIT
;
19196 direct
= COMMUNITY_DENY
;
19199 argv_find(argv
, argc
, "LINE", &idx
);
19200 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
19201 /* Concat community string argument. */
19202 str
= argv_concat(argv
, argc
, idx
);
19206 argv_find(argv
, argc
, "(1-99)", &idx
);
19207 argv_find(argv
, argc
, "(100-500)", &idx
);
19208 argv_find(argv
, argc
, "WORD", &idx
);
19210 /* Unset community list. */
19211 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
19214 /* Free temporary community list string allocated by
19216 XFREE(MTYPE_TMP
, str
);
19219 community_list_perror(vty
, ret
);
19220 return CMD_WARNING_CONFIG_FAILED
;
19223 return CMD_SUCCESS
;
19226 /* "large-community-list" keyword help string. */
19227 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
19228 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
19230 DEFUN (lcommunity_list_standard
,
19231 bgp_lcommunity_list_standard_cmd
,
19232 "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...",
19234 LCOMMUNITY_LIST_STR
19235 "Large Community list number (standard)\n"
19236 "Sequence number of an entry\n"
19237 "Sequence number\n"
19238 "Specify large community to reject\n"
19239 "Specify large community to accept\n"
19240 LCOMMUNITY_VAL_STR
)
19242 return lcommunity_list_set_vty(vty
, argc
, argv
,
19243 LARGE_COMMUNITY_LIST_STANDARD
, 0);
19246 DEFUN (lcommunity_list_expanded
,
19247 bgp_lcommunity_list_expanded_cmd
,
19248 "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...",
19250 LCOMMUNITY_LIST_STR
19251 "Large Community list number (expanded)\n"
19252 "Sequence number of an entry\n"
19253 "Sequence number\n"
19254 "Specify large community to reject\n"
19255 "Specify large community to accept\n"
19256 "An ordered list as a regular-expression\n")
19258 return lcommunity_list_set_vty(vty
, argc
, argv
,
19259 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
19262 DEFUN (lcommunity_list_name_standard
,
19263 bgp_lcommunity_list_name_standard_cmd
,
19264 "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...",
19266 LCOMMUNITY_LIST_STR
19267 "Specify standard large-community-list\n"
19268 "Large Community list name\n"
19269 "Sequence number of an entry\n"
19270 "Sequence number\n"
19271 "Specify large community to reject\n"
19272 "Specify large community to accept\n"
19273 LCOMMUNITY_VAL_STR
)
19275 return lcommunity_list_set_vty(vty
, argc
, argv
,
19276 LARGE_COMMUNITY_LIST_STANDARD
, 1);
19279 DEFUN (lcommunity_list_name_expanded
,
19280 bgp_lcommunity_list_name_expanded_cmd
,
19281 "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...",
19283 LCOMMUNITY_LIST_STR
19284 "Specify expanded large-community-list\n"
19285 "Large Community list name\n"
19286 "Sequence number of an entry\n"
19287 "Sequence number\n"
19288 "Specify large community to reject\n"
19289 "Specify large community to accept\n"
19290 "An ordered list as a regular-expression\n")
19292 return lcommunity_list_set_vty(vty
, argc
, argv
,
19293 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
19296 DEFUN (no_lcommunity_list_all
,
19297 no_bgp_lcommunity_list_all_cmd
,
19298 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
19301 LCOMMUNITY_LIST_STR
19302 "Large Community list number (standard)\n"
19303 "Large Community list number (expanded)\n"
19304 "Large Community list name\n")
19306 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19307 LARGE_COMMUNITY_LIST_STANDARD
);
19310 DEFUN (no_lcommunity_list_name_standard_all
,
19311 no_bgp_lcommunity_list_name_standard_all_cmd
,
19312 "no bgp large-community-list standard WORD",
19315 LCOMMUNITY_LIST_STR
19316 "Specify standard large-community-list\n"
19317 "Large Community list name\n")
19319 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19320 LARGE_COMMUNITY_LIST_STANDARD
);
19323 DEFUN (no_lcommunity_list_name_expanded_all
,
19324 no_bgp_lcommunity_list_name_expanded_all_cmd
,
19325 "no bgp large-community-list expanded WORD",
19328 LCOMMUNITY_LIST_STR
19329 "Specify expanded large-community-list\n"
19330 "Large Community list name\n")
19332 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19333 LARGE_COMMUNITY_LIST_EXPANDED
);
19336 DEFUN (no_lcommunity_list_standard
,
19337 no_bgp_lcommunity_list_standard_cmd
,
19338 "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...",
19341 LCOMMUNITY_LIST_STR
19342 "Large Community list number (standard)\n"
19343 "Sequence number of an entry\n"
19344 "Sequence number\n"
19345 "Specify large community to reject\n"
19346 "Specify large community to accept\n"
19347 LCOMMUNITY_VAL_STR
)
19349 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19350 LARGE_COMMUNITY_LIST_STANDARD
);
19353 DEFUN (no_lcommunity_list_expanded
,
19354 no_bgp_lcommunity_list_expanded_cmd
,
19355 "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...",
19358 LCOMMUNITY_LIST_STR
19359 "Large Community list number (expanded)\n"
19360 "Sequence number of an entry\n"
19361 "Sequence number\n"
19362 "Specify large community to reject\n"
19363 "Specify large community to accept\n"
19364 "An ordered list as a regular-expression\n")
19366 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19367 LARGE_COMMUNITY_LIST_EXPANDED
);
19370 DEFUN (no_lcommunity_list_name_standard
,
19371 no_bgp_lcommunity_list_name_standard_cmd
,
19372 "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...",
19375 LCOMMUNITY_LIST_STR
19376 "Specify standard large-community-list\n"
19377 "Large Community list name\n"
19378 "Sequence number of an entry\n"
19379 "Sequence number\n"
19380 "Specify large community to reject\n"
19381 "Specify large community to accept\n"
19382 LCOMMUNITY_VAL_STR
)
19384 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19385 LARGE_COMMUNITY_LIST_STANDARD
);
19388 DEFUN (no_lcommunity_list_name_expanded
,
19389 no_bgp_lcommunity_list_name_expanded_cmd
,
19390 "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...",
19393 LCOMMUNITY_LIST_STR
19394 "Specify expanded large-community-list\n"
19395 "Large community list name\n"
19396 "Sequence number of an entry\n"
19397 "Sequence number\n"
19398 "Specify large community to reject\n"
19399 "Specify large community to accept\n"
19400 "An ordered list as a regular-expression\n")
19402 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19403 LARGE_COMMUNITY_LIST_EXPANDED
);
19406 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
19408 struct community_entry
*entry
;
19410 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19411 if (entry
== list
->head
) {
19412 if (all_digit(list
->name
))
19413 vty_out(vty
, "Large community %s list %s\n",
19415 LARGE_COMMUNITY_LIST_STANDARD
19417 : "(expanded) access",
19421 "Named large community %s list %s\n",
19423 LARGE_COMMUNITY_LIST_STANDARD
19429 vty_out(vty
, " %s\n",
19430 community_direct_str(entry
->direct
));
19432 vty_out(vty
, " %s %s\n",
19433 community_direct_str(entry
->direct
),
19434 community_list_config_str(entry
));
19438 DEFUN (show_lcommunity_list
,
19439 show_bgp_lcommunity_list_cmd
,
19440 "show bgp large-community-list",
19443 "List large-community list\n")
19445 struct community_list
*list
;
19446 struct community_list_master
*cm
;
19448 cm
= community_list_master_lookup(bgp_clist
,
19449 LARGE_COMMUNITY_LIST_MASTER
);
19451 return CMD_SUCCESS
;
19453 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19454 lcommunity_list_show(vty
, list
);
19456 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19457 lcommunity_list_show(vty
, list
);
19459 return CMD_SUCCESS
;
19462 DEFUN (show_lcommunity_list_arg
,
19463 show_bgp_lcommunity_list_arg_cmd
,
19464 "show bgp large-community-list <(1-500)|WORD> detail",
19467 "List large-community list\n"
19468 "Large-community-list number\n"
19469 "Large-community-list name\n"
19470 "Detailed information on large-community-list\n")
19472 struct community_list
*list
;
19474 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
19475 LARGE_COMMUNITY_LIST_MASTER
);
19477 vty_out(vty
, "%% Can't find large-community-list\n");
19478 return CMD_WARNING
;
19481 lcommunity_list_show(vty
, list
);
19483 return CMD_SUCCESS
;
19486 /* "extcommunity-list" keyword help string. */
19487 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
19488 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
19490 DEFUN (extcommunity_list_standard
,
19491 bgp_extcommunity_list_standard_cmd
,
19492 "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19494 EXTCOMMUNITY_LIST_STR
19495 "Extended Community list number (standard)\n"
19496 "Specify standard extcommunity-list\n"
19497 "Community list name\n"
19498 "Sequence number of an entry\n"
19499 "Sequence number\n"
19500 "Specify community to reject\n"
19501 "Specify community to accept\n"
19502 EXTCOMMUNITY_VAL_STR
)
19504 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19506 char *cl_number_or_name
= NULL
;
19511 argv_find(argv
, argc
, "(1-99)", &idx
);
19512 argv_find(argv
, argc
, "WORD", &idx
);
19513 cl_number_or_name
= argv
[idx
]->arg
;
19515 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19516 seq
= argv
[idx
]->arg
;
19518 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19520 argv_find(argv
, argc
, "AA:NN", &idx
);
19521 char *str
= argv_concat(argv
, argc
, idx
);
19523 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19526 XFREE(MTYPE_TMP
, str
);
19529 community_list_perror(vty
, ret
);
19530 return CMD_WARNING_CONFIG_FAILED
;
19533 return CMD_SUCCESS
;
19536 DEFUN (extcommunity_list_name_expanded
,
19537 bgp_extcommunity_list_name_expanded_cmd
,
19538 "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...",
19540 EXTCOMMUNITY_LIST_STR
19541 "Extended Community list number (expanded)\n"
19542 "Specify expanded extcommunity-list\n"
19543 "Extended Community list name\n"
19544 "Sequence number of an entry\n"
19545 "Sequence number\n"
19546 "Specify community to reject\n"
19547 "Specify community to accept\n"
19548 "An ordered list as a regular-expression\n")
19550 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
19552 char *cl_number_or_name
= NULL
;
19556 argv_find(argv
, argc
, "(100-500)", &idx
);
19557 argv_find(argv
, argc
, "WORD", &idx
);
19558 cl_number_or_name
= argv
[idx
]->arg
;
19560 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19561 seq
= argv
[idx
]->arg
;
19563 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19565 argv_find(argv
, argc
, "LINE", &idx
);
19566 char *str
= argv_concat(argv
, argc
, idx
);
19568 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19571 XFREE(MTYPE_TMP
, str
);
19574 community_list_perror(vty
, ret
);
19575 return CMD_WARNING_CONFIG_FAILED
;
19578 return CMD_SUCCESS
;
19581 DEFUN (no_extcommunity_list_standard_all
,
19582 no_bgp_extcommunity_list_standard_all_cmd
,
19583 "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19586 EXTCOMMUNITY_LIST_STR
19587 "Extended Community list number (standard)\n"
19588 "Specify standard extcommunity-list\n"
19589 "Community list name\n"
19590 "Sequence number of an entry\n"
19591 "Sequence number\n"
19592 "Specify community to reject\n"
19593 "Specify community to accept\n"
19594 EXTCOMMUNITY_VAL_STR
)
19596 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19598 char *cl_number_or_name
= NULL
;
19603 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19604 seq
= argv
[idx
]->arg
;
19607 argv_find(argv
, argc
, "permit", &idx
);
19608 argv_find(argv
, argc
, "deny", &idx
);
19610 direct
= argv_find(argv
, argc
, "permit", &idx
)
19615 argv_find(argv
, argc
, "AA:NN", &idx
);
19616 str
= argv_concat(argv
, argc
, idx
);
19620 argv_find(argv
, argc
, "(1-99)", &idx
);
19621 argv_find(argv
, argc
, "WORD", &idx
);
19622 cl_number_or_name
= argv
[idx
]->arg
;
19624 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
19625 seq
, direct
, style
);
19627 XFREE(MTYPE_TMP
, str
);
19630 community_list_perror(vty
, ret
);
19631 return CMD_WARNING_CONFIG_FAILED
;
19634 return CMD_SUCCESS
;
19637 ALIAS(no_extcommunity_list_standard_all
,
19638 no_bgp_extcommunity_list_standard_all_list_cmd
,
19639 "no bgp extcommunity-list <(1-99)|standard WORD>",
19640 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
19641 "Extended Community list number (standard)\n"
19642 "Specify standard extcommunity-list\n"
19643 "Community list name\n")
19645 DEFUN (no_extcommunity_list_expanded_all
,
19646 no_bgp_extcommunity_list_expanded_all_cmd
,
19647 "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...",
19650 EXTCOMMUNITY_LIST_STR
19651 "Extended Community list number (expanded)\n"
19652 "Specify expanded extcommunity-list\n"
19653 "Extended Community list name\n"
19654 "Sequence number of an entry\n"
19655 "Sequence number\n"
19656 "Specify community to reject\n"
19657 "Specify community to accept\n"
19658 "An ordered list as a regular-expression\n")
19660 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
19662 char *cl_number_or_name
= NULL
;
19667 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19668 seq
= argv
[idx
]->arg
;
19671 argv_find(argv
, argc
, "permit", &idx
);
19672 argv_find(argv
, argc
, "deny", &idx
);
19675 direct
= argv_find(argv
, argc
, "permit", &idx
)
19680 argv_find(argv
, argc
, "LINE", &idx
);
19681 str
= argv_concat(argv
, argc
, idx
);
19685 argv_find(argv
, argc
, "(100-500)", &idx
);
19686 argv_find(argv
, argc
, "WORD", &idx
);
19687 cl_number_or_name
= argv
[idx
]->arg
;
19689 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
19690 seq
, direct
, style
);
19692 XFREE(MTYPE_TMP
, str
);
19695 community_list_perror(vty
, ret
);
19696 return CMD_WARNING_CONFIG_FAILED
;
19699 return CMD_SUCCESS
;
19702 ALIAS(no_extcommunity_list_expanded_all
,
19703 no_bgp_extcommunity_list_expanded_all_list_cmd
,
19704 "no bgp extcommunity-list <(100-500)|expanded WORD>",
19705 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
19706 "Extended Community list number (expanded)\n"
19707 "Specify expanded extcommunity-list\n"
19708 "Extended Community list name\n")
19710 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
19712 struct community_entry
*entry
;
19714 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19715 if (entry
== list
->head
) {
19716 if (all_digit(list
->name
))
19717 vty_out(vty
, "Extended community %s list %s\n",
19718 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
19720 : "(expanded) access",
19724 "Named extended community %s list %s\n",
19725 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
19731 vty_out(vty
, " %s\n",
19732 community_direct_str(entry
->direct
));
19734 vty_out(vty
, " %s %s\n",
19735 community_direct_str(entry
->direct
),
19736 community_list_config_str(entry
));
19740 DEFUN (show_extcommunity_list
,
19741 show_bgp_extcommunity_list_cmd
,
19742 "show bgp extcommunity-list",
19745 "List extended-community list\n")
19747 struct community_list
*list
;
19748 struct community_list_master
*cm
;
19750 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
19752 return CMD_SUCCESS
;
19754 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19755 extcommunity_list_show(vty
, list
);
19757 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19758 extcommunity_list_show(vty
, list
);
19760 return CMD_SUCCESS
;
19763 DEFUN (show_extcommunity_list_arg
,
19764 show_bgp_extcommunity_list_arg_cmd
,
19765 "show bgp extcommunity-list <(1-500)|WORD> detail",
19768 "List extended-community list\n"
19769 "Extcommunity-list number\n"
19770 "Extcommunity-list name\n"
19771 "Detailed information on extcommunity-list\n")
19773 int idx_comm_list
= 3;
19774 struct community_list
*list
;
19776 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
19777 EXTCOMMUNITY_LIST_MASTER
);
19779 vty_out(vty
, "%% Can't find extcommunity-list\n");
19780 return CMD_WARNING
;
19783 extcommunity_list_show(vty
, list
);
19785 return CMD_SUCCESS
;
19788 /* Display community-list and extcommunity-list configuration. */
19789 static int community_list_config_write(struct vty
*vty
)
19791 struct community_list
*list
;
19792 struct community_entry
*entry
;
19793 struct community_list_master
*cm
;
19796 /* Community-list. */
19797 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19799 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19800 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19802 "bgp community-list %s seq %" PRId64
" %s %s\n",
19803 list
->name
, entry
->seq
,
19804 community_direct_str(entry
->direct
),
19805 community_list_config_str(entry
));
19808 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19809 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19811 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
19812 entry
->style
== COMMUNITY_LIST_STANDARD
19815 list
->name
, entry
->seq
,
19816 community_direct_str(entry
->direct
),
19817 community_list_config_str(entry
));
19821 /* Extcommunity-list. */
19822 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
19824 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19825 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19827 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
19828 list
->name
, entry
->seq
,
19829 community_direct_str(entry
->direct
),
19830 community_list_config_str(entry
));
19833 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19834 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19836 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
19837 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
19840 list
->name
, entry
->seq
,
19841 community_direct_str(entry
->direct
),
19842 community_list_config_str(entry
));
19847 /* lcommunity-list. */
19848 cm
= community_list_master_lookup(bgp_clist
,
19849 LARGE_COMMUNITY_LIST_MASTER
);
19851 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19852 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19854 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
19855 list
->name
, entry
->seq
,
19856 community_direct_str(entry
->direct
),
19857 community_list_config_str(entry
));
19860 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19861 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19863 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
19865 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
19868 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
19869 community_list_config_str(entry
));
19876 static int community_list_config_write(struct vty
*vty
);
19877 static struct cmd_node community_list_node
= {
19878 .name
= "community list",
19879 .node
= COMMUNITY_LIST_NODE
,
19881 .config_write
= community_list_config_write
,
19884 static void community_list_vty(void)
19886 install_node(&community_list_node
);
19888 /* Community-list. */
19889 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
19890 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
19891 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
19892 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
19893 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
19894 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
19895 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
19896 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
19898 /* Extcommunity-list. */
19899 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
19900 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
19901 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
19902 install_element(CONFIG_NODE
,
19903 &no_bgp_extcommunity_list_standard_all_list_cmd
);
19904 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
19905 install_element(CONFIG_NODE
,
19906 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
19907 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
19908 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
19910 /* Large Community List */
19911 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
19912 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
19913 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
19914 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
19915 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
19916 install_element(CONFIG_NODE
,
19917 &no_bgp_lcommunity_list_name_standard_all_cmd
);
19918 install_element(CONFIG_NODE
,
19919 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
19920 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
19921 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
19922 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
19923 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
19924 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
19925 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);