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
);
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 DEFUN_YANG (neighbor_advertise_interval
,
7377 neighbor_advertise_interval_cmd
,
7378 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7379 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7380 "Minimum interval between sending BGP routing updates\n"
7381 "time in seconds\n")
7385 char base_xpath
[XPATH_MAXLEN
];
7387 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7388 sizeof(base_xpath
), NULL
)
7390 return CMD_WARNING_CONFIG_FAILED
;
7392 nb_cli_enqueue_change(vty
, "./timers/advertise-interval", NB_OP_MODIFY
,
7393 argv
[idx_number
]->arg
);
7395 return nb_cli_apply_changes(vty
, base_xpath
);
7398 DEFUN_YANG (no_neighbor_advertise_interval
,
7399 no_neighbor_advertise_interval_cmd
,
7400 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7401 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7402 "Minimum interval between sending BGP routing updates\n"
7403 "time in seconds\n")
7406 char base_xpath
[XPATH_MAXLEN
];
7408 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7409 sizeof(base_xpath
), NULL
)
7411 return CMD_WARNING_CONFIG_FAILED
;
7413 nb_cli_enqueue_change(vty
, "./timers/advertise-interval", NB_OP_DESTROY
,
7416 return nb_cli_apply_changes(vty
, base_xpath
);
7420 /* Time to wait before processing route-map updates */
7421 DEFUN (bgp_set_route_map_delay_timer
,
7422 bgp_set_route_map_delay_timer_cmd
,
7423 "bgp route-map delay-timer (0-600)",
7425 "BGP route-map delay timer\n"
7426 "Time in secs to wait before processing route-map changes\n"
7427 "0 disables the timer, no route updates happen when route-maps change\n")
7430 uint32_t rmap_delay_timer
;
7432 if (argv
[idx_number
]->arg
) {
7433 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7434 bm
->rmap_update_timer
= rmap_delay_timer
;
7436 /* if the dynamic update handling is being disabled, and a timer
7438 * running, stop the timer and act as if the timer has already
7441 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7442 BGP_TIMER_OFF(bm
->t_rmap_update
);
7443 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7448 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7449 return CMD_WARNING_CONFIG_FAILED
;
7453 DEFUN (no_bgp_set_route_map_delay_timer
,
7454 no_bgp_set_route_map_delay_timer_cmd
,
7455 "no bgp route-map delay-timer [(0-600)]",
7458 "Default BGP route-map delay timer\n"
7459 "Reset to default time to wait for processing route-map changes\n"
7460 "0 disables the timer, no route updates happen when route-maps change\n")
7463 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7468 DEFUN_YANG (neighbor_interface
,
7469 neighbor_interface_cmd
,
7470 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7471 NEIGHBOR_STR NEIGHBOR_ADDR_STR
7477 char base_xpath
[XPATH_MAXLEN
];
7479 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7480 argv
[idx_ip
]->arg
, "");
7482 nb_cli_enqueue_change(vty
, "./local-interface", NB_OP_MODIFY
,
7483 argv
[idx_word
]->arg
);
7485 return nb_cli_apply_changes(vty
, base_xpath
);
7488 DEFUN_YANG (no_neighbor_interface
,
7489 no_neighbor_interface_cmd
,
7490 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
7491 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7496 char base_xpath
[XPATH_MAXLEN
];
7498 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7499 argv
[idx_peer
]->arg
, "");
7501 nb_cli_enqueue_change(vty
, "./local-interface", NB_OP_DESTROY
, NULL
);
7503 return nb_cli_apply_changes(vty
, base_xpath
);
7506 DEFUN (neighbor_distribute_list
,
7507 neighbor_distribute_list_cmd
,
7508 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7511 "Filter updates to/from this neighbor\n"
7512 "IP access-list number\n"
7513 "IP access-list number (expanded range)\n"
7514 "IP Access-list name\n"
7515 "Filter incoming updates\n"
7516 "Filter outgoing updates\n")
7523 const char *pstr
= argv
[idx_peer
]->arg
;
7524 const char *acl
= argv
[idx_acl
]->arg
;
7525 const char *inout
= argv
[argc
- 1]->text
;
7527 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7529 return CMD_WARNING_CONFIG_FAILED
;
7531 /* Check filter direction. */
7532 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7533 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7536 return bgp_vty_return(vty
, ret
);
7540 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7541 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7542 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7543 "Filter updates to/from this neighbor\n"
7544 "IP access-list number\n"
7545 "IP access-list number (expanded range)\n"
7546 "IP Access-list name\n"
7547 "Filter incoming updates\n"
7548 "Filter outgoing updates\n")
7550 DEFUN (no_neighbor_distribute_list
,
7551 no_neighbor_distribute_list_cmd
,
7552 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7556 "Filter updates to/from this neighbor\n"
7557 "IP access-list number\n"
7558 "IP access-list number (expanded range)\n"
7559 "IP Access-list name\n"
7560 "Filter incoming updates\n"
7561 "Filter outgoing updates\n")
7567 const char *pstr
= argv
[idx_peer
]->arg
;
7568 const char *inout
= argv
[argc
- 1]->text
;
7570 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7572 return CMD_WARNING_CONFIG_FAILED
;
7574 /* Check filter direction. */
7575 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7576 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7579 return bgp_vty_return(vty
, ret
);
7583 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7584 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7585 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7586 "Filter updates to/from this neighbor\n"
7587 "IP access-list number\n"
7588 "IP access-list number (expanded range)\n"
7589 "IP Access-list name\n"
7590 "Filter incoming updates\n"
7591 "Filter outgoing updates\n")
7593 /* Set prefix list to the peer. */
7594 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7595 afi_t afi
, safi_t safi
,
7596 const char *name_str
,
7597 const char *direct_str
)
7600 int direct
= FILTER_IN
;
7603 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7605 return CMD_WARNING_CONFIG_FAILED
;
7607 /* Check filter direction. */
7608 if (strncmp(direct_str
, "i", 1) == 0)
7610 else if (strncmp(direct_str
, "o", 1) == 0)
7611 direct
= FILTER_OUT
;
7613 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7615 return bgp_vty_return(vty
, ret
);
7618 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7619 afi_t afi
, safi_t safi
,
7620 const char *direct_str
)
7624 int direct
= FILTER_IN
;
7626 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7628 return CMD_WARNING_CONFIG_FAILED
;
7630 /* Check filter direction. */
7631 if (strncmp(direct_str
, "i", 1) == 0)
7633 else if (strncmp(direct_str
, "o", 1) == 0)
7634 direct
= FILTER_OUT
;
7636 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7638 return bgp_vty_return(vty
, ret
);
7641 DEFUN (neighbor_prefix_list
,
7642 neighbor_prefix_list_cmd
,
7643 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7646 "Filter updates to/from this neighbor\n"
7647 "Name of a prefix list\n"
7648 "Filter incoming updates\n"
7649 "Filter outgoing updates\n")
7654 return peer_prefix_list_set_vty(
7655 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7656 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7659 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7660 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7661 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7662 "Filter updates to/from this neighbor\n"
7663 "Name of a prefix list\n"
7664 "Filter incoming updates\n"
7665 "Filter outgoing updates\n")
7667 DEFUN (no_neighbor_prefix_list
,
7668 no_neighbor_prefix_list_cmd
,
7669 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7673 "Filter updates to/from this neighbor\n"
7674 "Name of a prefix list\n"
7675 "Filter incoming updates\n"
7676 "Filter outgoing updates\n")
7680 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7681 bgp_node_afi(vty
), bgp_node_safi(vty
),
7682 argv
[idx_in_out
]->arg
);
7685 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7686 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7687 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7688 "Filter updates to/from this neighbor\n"
7689 "Name of a prefix list\n"
7690 "Filter incoming updates\n"
7691 "Filter outgoing updates\n")
7693 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7694 safi_t safi
, const char *name_str
,
7695 const char *direct_str
)
7699 int direct
= FILTER_IN
;
7701 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7703 return CMD_WARNING_CONFIG_FAILED
;
7705 /* Check filter direction. */
7706 if (strncmp(direct_str
, "i", 1) == 0)
7708 else if (strncmp(direct_str
, "o", 1) == 0)
7709 direct
= FILTER_OUT
;
7711 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7713 return bgp_vty_return(vty
, ret
);
7716 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7717 safi_t safi
, const char *direct_str
)
7721 int direct
= FILTER_IN
;
7723 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7725 return CMD_WARNING_CONFIG_FAILED
;
7727 /* Check filter direction. */
7728 if (strncmp(direct_str
, "i", 1) == 0)
7730 else if (strncmp(direct_str
, "o", 1) == 0)
7731 direct
= FILTER_OUT
;
7733 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7735 return bgp_vty_return(vty
, ret
);
7738 DEFUN (neighbor_filter_list
,
7739 neighbor_filter_list_cmd
,
7740 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7743 "Establish BGP filters\n"
7744 "AS path access-list name\n"
7745 "Filter incoming routes\n"
7746 "Filter outgoing routes\n")
7751 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7752 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7753 argv
[idx_in_out
]->arg
);
7756 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7757 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7758 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7759 "Establish BGP filters\n"
7760 "AS path access-list name\n"
7761 "Filter incoming routes\n"
7762 "Filter outgoing routes\n")
7764 DEFUN (no_neighbor_filter_list
,
7765 no_neighbor_filter_list_cmd
,
7766 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7770 "Establish BGP filters\n"
7771 "AS path access-list name\n"
7772 "Filter incoming routes\n"
7773 "Filter outgoing routes\n")
7777 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7778 bgp_node_afi(vty
), bgp_node_safi(vty
),
7779 argv
[idx_in_out
]->arg
);
7782 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7783 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7784 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7785 "Establish BGP filters\n"
7786 "AS path access-list name\n"
7787 "Filter incoming routes\n"
7788 "Filter outgoing routes\n")
7790 /* Set advertise-map to the peer. */
7791 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7792 afi_t afi
, safi_t safi
,
7793 const char *advertise_str
,
7794 const char *condition_str
, bool condition
,
7797 int ret
= CMD_WARNING_CONFIG_FAILED
;
7799 struct route_map
*advertise_map
;
7800 struct route_map
*condition_map
;
7802 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7806 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7807 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7810 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7811 advertise_map
, condition_str
,
7812 condition_map
, condition
);
7814 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7815 advertise_map
, condition_str
,
7816 condition_map
, condition
);
7818 return bgp_vty_return(vty
, ret
);
7821 DEFPY (neighbor_advertise_map
,
7822 neighbor_advertise_map_cmd
,
7823 "[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",
7827 "Route-map to conditionally advertise routes\n"
7828 "Name of advertise map\n"
7829 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7830 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7831 "Name of the exist or non exist map\n")
7833 bool condition
= CONDITION_EXIST
;
7835 if (!strcmp(exist
, "non-exist-map"))
7836 condition
= CONDITION_NON_EXIST
;
7838 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7839 bgp_node_safi(vty
), advertise_str
,
7840 condition_str
, condition
, !no
);
7843 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7844 "[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",
7845 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7846 "Route-map to conditionally advertise routes\n"
7847 "Name of advertise map\n"
7848 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7849 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7850 "Name of the exist or non exist map\n")
7852 /* Set route-map to the peer. */
7853 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7854 afi_t afi
, safi_t safi
, const char *name_str
,
7855 const char *direct_str
)
7859 int direct
= RMAP_IN
;
7860 struct route_map
*route_map
;
7862 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7864 return CMD_WARNING_CONFIG_FAILED
;
7866 /* Check filter direction. */
7867 if (strncmp(direct_str
, "in", 2) == 0)
7869 else if (strncmp(direct_str
, "o", 1) == 0)
7872 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7873 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7875 return bgp_vty_return(vty
, ret
);
7878 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7879 afi_t afi
, safi_t safi
,
7880 const char *direct_str
)
7884 int direct
= RMAP_IN
;
7886 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7888 return CMD_WARNING_CONFIG_FAILED
;
7890 /* Check filter direction. */
7891 if (strncmp(direct_str
, "in", 2) == 0)
7893 else if (strncmp(direct_str
, "o", 1) == 0)
7896 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7898 return bgp_vty_return(vty
, ret
);
7901 DEFUN (neighbor_route_map
,
7902 neighbor_route_map_cmd
,
7903 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7906 "Apply route map to neighbor\n"
7907 "Name of route map\n"
7908 "Apply map to incoming routes\n"
7909 "Apply map to outbound routes\n")
7914 return peer_route_map_set_vty(
7915 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7916 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7919 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7920 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7921 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7922 "Apply route map to neighbor\n"
7923 "Name of route map\n"
7924 "Apply map to incoming routes\n"
7925 "Apply map to outbound routes\n")
7927 DEFUN (no_neighbor_route_map
,
7928 no_neighbor_route_map_cmd
,
7929 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7933 "Apply route map to neighbor\n"
7934 "Name of route map\n"
7935 "Apply map to incoming routes\n"
7936 "Apply map to outbound routes\n")
7940 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7941 bgp_node_afi(vty
), bgp_node_safi(vty
),
7942 argv
[idx_in_out
]->arg
);
7945 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7946 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7947 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7948 "Apply route map to neighbor\n"
7949 "Name of route map\n"
7950 "Apply map to incoming routes\n"
7951 "Apply map to outbound routes\n")
7953 /* Set unsuppress-map to the peer. */
7954 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
7955 afi_t afi
, safi_t safi
,
7956 const char *name_str
)
7960 struct route_map
*route_map
;
7962 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7964 return CMD_WARNING_CONFIG_FAILED
;
7966 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7967 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
7969 return bgp_vty_return(vty
, ret
);
7972 /* Unset route-map from the peer. */
7973 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7974 afi_t afi
, safi_t safi
)
7979 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7981 return CMD_WARNING_CONFIG_FAILED
;
7983 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
7985 return bgp_vty_return(vty
, ret
);
7988 DEFUN (neighbor_unsuppress_map
,
7989 neighbor_unsuppress_map_cmd
,
7990 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7993 "Route-map to selectively unsuppress suppressed routes\n"
7994 "Name of route map\n")
7998 return peer_unsuppress_map_set_vty(
7999 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8000 argv
[idx_word
]->arg
);
8003 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
8004 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8005 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8006 "Route-map to selectively unsuppress suppressed routes\n"
8007 "Name of route map\n")
8009 DEFUN (no_neighbor_unsuppress_map
,
8010 no_neighbor_unsuppress_map_cmd
,
8011 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8015 "Route-map to selectively unsuppress suppressed routes\n"
8016 "Name of route map\n")
8019 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
8021 bgp_node_safi(vty
));
8024 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
8025 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8026 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8027 "Route-map to selectively unsuppress suppressed routes\n"
8028 "Name of route map\n")
8030 /* Maximum number of prefix to be sent to the neighbor. */
8031 DEFUN_YANG(neighbor_maximum_prefix_out
,
8032 neighbor_maximum_prefix_out_cmd
,
8033 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
8034 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8035 "Maximum number of prefixes to be sent to this peer\n"
8036 "Maximum no. of prefix limit\n")
8038 char base_xpath
[XPATH_MAXLEN
];
8039 char af_xpath
[XPATH_MAXLEN
];
8040 char attr_xpath
[XPATH_MAXLEN
];
8043 afi_t afi
= bgp_node_afi(vty
);
8044 safi_t safi
= bgp_node_safi(vty
);
8046 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8047 yang_afi_safi_value2identity(afi
, safi
));
8048 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8049 sizeof(base_xpath
), af_xpath
)
8051 return CMD_WARNING_CONFIG_FAILED
;
8053 snprintf(attr_xpath
, sizeof(attr_xpath
),
8054 "/%s/prefix-limit/direction-list[direction='out']",
8055 bgp_afi_safi_get_container_str(afi
, safi
));
8056 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8058 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8060 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8061 argv
[idx_number
]->arg
);
8063 return nb_cli_apply_changes(vty
, base_xpath
);
8066 DEFUN_YANG(no_neighbor_maximum_prefix_out
,
8067 no_neighbor_maximum_prefix_out_cmd
,
8068 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out",
8069 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8070 "Maximum number of prefixes to be sent to this peer\n")
8072 char base_xpath
[XPATH_MAXLEN
];
8073 char af_xpath
[XPATH_MAXLEN
];
8074 char attr_xpath
[XPATH_MAXLEN
];
8076 afi_t afi
= bgp_node_afi(vty
);
8077 safi_t safi
= bgp_node_safi(vty
);
8079 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8080 yang_afi_safi_value2identity(afi
, safi
));
8081 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8082 sizeof(base_xpath
), af_xpath
)
8084 return CMD_WARNING_CONFIG_FAILED
;
8086 snprintf(attr_xpath
, sizeof(attr_xpath
),
8087 "/%s/prefix-limit/direction-list[direction='out']",
8088 bgp_afi_safi_get_container_str(afi
, safi
));
8089 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8091 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
8093 return nb_cli_apply_changes(vty
, base_xpath
);
8096 /* Maximum number of prefix configuration. Prefix count is different
8097 for each peer configuration. So this configuration can be set for
8098 each peer configuration. */
8099 DEFUN_YANG(neighbor_maximum_prefix
,
8100 neighbor_maximum_prefix_cmd
,
8101 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8102 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8103 "Maximum number of prefix accept from this peer\n"
8104 "maximum no. of prefix limit\n"
8105 "Force checking all received routes not only accepted\n")
8110 char base_xpath
[XPATH_MAXLEN
];
8111 char af_xpath
[XPATH_MAXLEN
];
8112 char attr_xpath
[XPATH_MAXLEN
];
8113 afi_t afi
= bgp_node_afi(vty
);
8114 safi_t safi
= bgp_node_safi(vty
);
8116 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8117 yang_afi_safi_value2identity(afi
, safi
));
8118 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8119 sizeof(base_xpath
), af_xpath
)
8121 return CMD_WARNING_CONFIG_FAILED
;
8123 snprintf(attr_xpath
, sizeof(attr_xpath
),
8124 "/%s/prefix-limit/direction-list[direction='in']",
8125 bgp_afi_safi_get_container_str(afi
, safi
));
8126 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8128 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8130 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8131 argv
[idx_number
]->arg
);
8132 if (argv_find(argv
, argc
, "force", &idx_force
))
8133 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8136 return nb_cli_apply_changes(vty
, base_xpath
);
8139 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8140 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8141 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8142 "Maximum number of prefix accept from this peer\n"
8143 "maximum no. of prefix limit\n"
8144 "Force checking all received routes not only accepted\n")
8146 DEFUN_YANG(neighbor_maximum_prefix_threshold
,
8147 neighbor_maximum_prefix_threshold_cmd
,
8148 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8149 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8150 "Maximum number of prefix accept from this peer\n"
8151 "maximum no. of prefix limit\n"
8152 "Threshold value (%) at which to generate a warning msg\n"
8153 "Force checking all received routes not only accepted\n")
8157 int idx_number_2
= 4;
8159 char base_xpath
[XPATH_MAXLEN
];
8160 char af_xpath
[XPATH_MAXLEN
];
8161 char attr_xpath
[XPATH_MAXLEN
];
8162 afi_t afi
= bgp_node_afi(vty
);
8163 safi_t safi
= bgp_node_safi(vty
);
8165 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8166 yang_afi_safi_value2identity(afi
, safi
));
8167 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8168 sizeof(base_xpath
), af_xpath
)
8170 return CMD_WARNING_CONFIG_FAILED
;
8172 snprintf(attr_xpath
, sizeof(attr_xpath
),
8173 "/%s/prefix-limit/direction-list[direction='in']",
8174 bgp_afi_safi_get_container_str(afi
, safi
));
8175 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8177 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8179 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8180 argv
[idx_number
]->arg
);
8182 nb_cli_enqueue_change(vty
, "./options/shutdown-threshold-pct",
8183 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8185 if (argv_find(argv
, argc
, "force", &idx_force
))
8186 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8189 return nb_cli_apply_changes(vty
, base_xpath
);
8193 neighbor_maximum_prefix_threshold
,
8194 neighbor_maximum_prefix_threshold_hidden_cmd
,
8195 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8196 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8197 "Maximum number of prefix accept from this peer\n"
8198 "maximum no. of prefix limit\n"
8199 "Threshold value (%) at which to generate a warning msg\n"
8200 "Force checking all received routes not only accepted\n")
8202 DEFUN_YANG(neighbor_maximum_prefix_warning
,
8203 neighbor_maximum_prefix_warning_cmd
,
8204 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8205 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8206 "Maximum number of prefix accept from this peer\n"
8207 "maximum no. of prefix limit\n"
8208 "Only give warning message when limit is exceeded\n"
8209 "Force checking all received routes not only accepted\n")
8214 char base_xpath
[XPATH_MAXLEN
];
8215 char af_xpath
[XPATH_MAXLEN
];
8216 char attr_xpath
[XPATH_MAXLEN
];
8217 afi_t afi
= bgp_node_afi(vty
);
8218 safi_t safi
= bgp_node_safi(vty
);
8220 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8221 yang_afi_safi_value2identity(afi
, safi
));
8222 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8223 sizeof(base_xpath
), af_xpath
)
8225 return CMD_WARNING_CONFIG_FAILED
;
8227 snprintf(attr_xpath
, sizeof(attr_xpath
),
8228 "/%s/prefix-limit/direction-list[direction='in']",
8229 bgp_afi_safi_get_container_str(afi
, safi
));
8230 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8232 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8234 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8235 argv
[idx_number
]->arg
);
8237 nb_cli_enqueue_change(vty
, "./options/warning-only", NB_OP_MODIFY
,
8239 if (argv_find(argv
, argc
, "force", &idx_force
))
8240 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8243 return nb_cli_apply_changes(vty
, base_xpath
);
8247 neighbor_maximum_prefix_warning
,
8248 neighbor_maximum_prefix_warning_hidden_cmd
,
8249 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8250 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8251 "Maximum number of prefix accept from this peer\n"
8252 "maximum no. of prefix limit\n"
8253 "Only give warning message when limit is exceeded\n"
8254 "Force checking all received routes not only accepted\n")
8256 DEFUN_YANG(neighbor_maximum_prefix_threshold_warning
,
8257 neighbor_maximum_prefix_threshold_warning_cmd
,
8258 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8259 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8260 "Maximum number of prefix accept from this peer\n"
8261 "maximum no. of prefix limit\n"
8262 "Threshold value (%) at which to generate a warning msg\n"
8263 "Only give warning message when limit is exceeded\n"
8264 "Force checking all received routes not only accepted\n")
8268 int idx_number_2
= 4;
8270 char base_xpath
[XPATH_MAXLEN
];
8271 char af_xpath
[XPATH_MAXLEN
];
8272 char attr_xpath
[XPATH_MAXLEN
];
8273 afi_t afi
= bgp_node_afi(vty
);
8274 safi_t safi
= bgp_node_safi(vty
);
8276 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8277 yang_afi_safi_value2identity(afi
, safi
));
8278 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8279 sizeof(base_xpath
), af_xpath
)
8281 return CMD_WARNING_CONFIG_FAILED
;
8283 snprintf(attr_xpath
, sizeof(attr_xpath
),
8284 "/%s/prefix-limit/direction-list[direction='in']",
8285 bgp_afi_safi_get_container_str(afi
, safi
));
8286 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8288 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8290 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8291 argv
[idx_number
]->arg
);
8292 nb_cli_enqueue_change(vty
, "./options/tw-shutdown-threshold-pct",
8293 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8294 nb_cli_enqueue_change(vty
, "./options/tw-warning-only", NB_OP_MODIFY
,
8296 if (argv_find(argv
, argc
, "force", &idx_force
))
8297 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8300 return nb_cli_apply_changes(vty
, base_xpath
);
8304 neighbor_maximum_prefix_threshold_warning
,
8305 neighbor_maximum_prefix_threshold_warning_hidden_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")
8314 DEFUN_YANG(neighbor_maximum_prefix_restart
,
8315 neighbor_maximum_prefix_restart_cmd
,
8316 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8317 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8318 "Maximum number of prefix accept from this peer\n"
8319 "maximum no. of prefix limit\n"
8320 "Restart bgp connection after limit is exceeded\n"
8321 "Restart interval in minutes\n"
8322 "Force checking all received routes not only accepted\n")
8326 int idx_number_2
= 5;
8328 char base_xpath
[XPATH_MAXLEN
];
8329 char af_xpath
[XPATH_MAXLEN
];
8330 char attr_xpath
[XPATH_MAXLEN
];
8331 afi_t afi
= bgp_node_afi(vty
);
8332 safi_t safi
= bgp_node_safi(vty
);
8334 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8335 yang_afi_safi_value2identity(afi
, safi
));
8336 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8337 sizeof(base_xpath
), af_xpath
)
8339 return CMD_WARNING_CONFIG_FAILED
;
8341 snprintf(attr_xpath
, sizeof(attr_xpath
),
8342 "/%s/prefix-limit/direction-list[direction='in']",
8343 bgp_afi_safi_get_container_str(afi
, safi
));
8344 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8346 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8348 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8349 argv
[idx_number
]->arg
);
8350 nb_cli_enqueue_change(vty
, "./options/restart-timer", NB_OP_MODIFY
,
8351 argv
[idx_number_2
]->arg
);
8352 if (argv_find(argv
, argc
, "force", &idx_force
))
8353 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8356 return nb_cli_apply_changes(vty
, base_xpath
);
8360 neighbor_maximum_prefix_restart
,
8361 neighbor_maximum_prefix_restart_hidden_cmd
,
8362 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8363 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8364 "Maximum number of prefix accept from this peer\n"
8365 "maximum no. of prefix limit\n"
8366 "Restart bgp connection after limit is exceeded\n"
8367 "Restart interval in minutes\n"
8368 "Force checking all received routes not only accepted\n")
8370 DEFUN_YANG(neighbor_maximum_prefix_threshold_restart
,
8371 neighbor_maximum_prefix_threshold_restart_cmd
,
8372 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8373 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8374 "Maximum number of prefixes to accept from this peer\n"
8375 "maximum no. of prefix limit\n"
8376 "Threshold value (%) at which to generate a warning msg\n"
8377 "Restart bgp connection after limit is exceeded\n"
8378 "Restart interval in minutes\n"
8379 "Force checking all received routes not only accepted\n")
8383 int idx_number_2
= 4;
8384 int idx_number_3
= 6;
8386 char base_xpath
[XPATH_MAXLEN
];
8387 char af_xpath
[XPATH_MAXLEN
];
8388 char attr_xpath
[XPATH_MAXLEN
];
8389 afi_t afi
= bgp_node_afi(vty
);
8390 safi_t safi
= bgp_node_safi(vty
);
8392 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8393 yang_afi_safi_value2identity(afi
, safi
));
8394 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8395 sizeof(base_xpath
), af_xpath
)
8397 return CMD_WARNING_CONFIG_FAILED
;
8399 snprintf(attr_xpath
, sizeof(attr_xpath
),
8400 "/%s/prefix-limit/direction-list[direction='in']",
8401 bgp_afi_safi_get_container_str(afi
, safi
));
8402 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8404 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8406 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8407 argv
[idx_number
]->arg
);
8408 nb_cli_enqueue_change(vty
, "./options/tr-shutdown-threshold-pct",
8409 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8410 nb_cli_enqueue_change(vty
, "./options/tr-restart-timer", NB_OP_MODIFY
,
8411 argv
[idx_number_3
]->arg
);
8412 if (argv_find(argv
, argc
, "force", &idx_force
))
8413 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8416 return nb_cli_apply_changes(vty
, base_xpath
);
8420 neighbor_maximum_prefix_threshold_restart
,
8421 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8422 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8423 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8424 "Maximum number of prefixes to accept from this peer\n"
8425 "maximum no. of prefix limit\n"
8426 "Threshold value (%) at which to generate a warning msg\n"
8427 "Restart bgp connection after limit is exceeded\n"
8428 "Restart interval in minutes\n"
8429 "Force checking all received routes not only accepted\n")
8431 DEFUN_YANG(no_neighbor_maximum_prefix
,
8432 no_neighbor_maximum_prefix_cmd
,
8433 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8434 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8435 "Maximum number of prefixes to accept from this peer\n"
8436 "maximum no. of prefix limit\n"
8437 "Threshold value (%) at which to generate a warning msg\n"
8438 "Restart bgp connection after limit is exceeded\n"
8439 "Restart interval in minutes\n"
8440 "Only give warning message when limit is exceeded\n"
8441 "Force checking all received routes not only accepted\n")
8444 char base_xpath
[XPATH_MAXLEN
];
8445 char af_xpath
[XPATH_MAXLEN
];
8446 char attr_xpath
[XPATH_MAXLEN
];
8447 afi_t afi
= bgp_node_afi(vty
);
8448 safi_t safi
= bgp_node_safi(vty
);
8450 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8451 yang_afi_safi_value2identity(afi
, safi
));
8452 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8453 sizeof(base_xpath
), af_xpath
)
8455 return CMD_WARNING_CONFIG_FAILED
;
8457 snprintf(attr_xpath
, sizeof(attr_xpath
),
8458 "/%s/prefix-limit/direction-list[direction='in']",
8459 bgp_afi_safi_get_container_str(afi
, safi
));
8460 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8462 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
8464 return nb_cli_apply_changes(vty
, base_xpath
);
8468 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8469 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8470 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8471 "Maximum number of prefixes to accept from this peer\n"
8472 "maximum no. of prefix limit\n"
8473 "Threshold value (%) at which to generate a warning msg\n"
8474 "Restart bgp connection after limit is exceeded\n"
8475 "Restart interval in minutes\n"
8476 "Only give warning message when limit is exceeded\n"
8477 "Force checking all received routes not only accepted\n")
8480 /* "neighbor allowas-in" */
8481 DEFUN (neighbor_allowas_in
,
8482 neighbor_allowas_in_cmd
,
8483 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8486 "Accept as-path with my AS present in it\n"
8487 "Number of occurrences of AS number\n"
8488 "Only accept my AS in the as-path if the route was originated in my AS\n")
8491 int idx_number_origin
= 3;
8497 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8499 return CMD_WARNING_CONFIG_FAILED
;
8501 if (argc
<= idx_number_origin
)
8504 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8507 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8510 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8513 return bgp_vty_return(vty
, ret
);
8517 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8518 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8519 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8520 "Accept as-path with my AS present in it\n"
8521 "Number of occurrences of AS number\n"
8522 "Only accept my AS in the as-path if the route was originated in my AS\n")
8524 DEFUN (no_neighbor_allowas_in
,
8525 no_neighbor_allowas_in_cmd
,
8526 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8530 "allow local ASN appears in aspath attribute\n"
8531 "Number of occurrences of AS number\n"
8532 "Only accept my AS in the as-path if the route was originated in my AS\n")
8538 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8540 return CMD_WARNING_CONFIG_FAILED
;
8542 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8543 bgp_node_safi(vty
));
8545 return bgp_vty_return(vty
, ret
);
8549 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8550 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8551 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8552 "allow local ASN appears in aspath attribute\n"
8553 "Number of occurrences of AS number\n"
8554 "Only accept my AS in the as-path if the route was originated in my AS\n")
8556 DEFUN_YANG (neighbor_ttl_security
,
8557 neighbor_ttl_security_cmd
,
8558 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8561 "BGP ttl-security parameters\n"
8562 "Specify the maximum number of hops to the BGP peer\n"
8563 "Number of hops to BGP peer\n")
8567 char base_xpath
[XPATH_MAXLEN
];
8569 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8570 sizeof(base_xpath
), NULL
)
8572 return CMD_WARNING_CONFIG_FAILED
;
8574 nb_cli_enqueue_change(vty
, "./ttl-security", NB_OP_MODIFY
,
8575 argv
[idx_number
]->arg
);
8577 return nb_cli_apply_changes(vty
, base_xpath
);
8580 DEFUN_YANG(no_neighbor_ttl_security
,
8581 no_neighbor_ttl_security_cmd
,
8582 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8583 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8584 "BGP ttl-security parameters\n"
8585 "Specify the maximum number of hops to the BGP peer\n"
8586 "Number of hops to BGP peer\n")
8589 char base_xpath
[XPATH_MAXLEN
];
8591 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8592 sizeof(base_xpath
), NULL
)
8594 return CMD_WARNING_CONFIG_FAILED
;
8596 nb_cli_enqueue_change(vty
, "./ttl-security", NB_OP_DESTROY
, NULL
);
8598 return nb_cli_apply_changes(vty
, base_xpath
);
8601 DEFUN (neighbor_addpath_tx_all_paths
,
8602 neighbor_addpath_tx_all_paths_cmd
,
8603 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8606 "Use addpath to advertise all paths to a neighbor\n")
8611 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8613 return CMD_WARNING_CONFIG_FAILED
;
8615 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8620 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8621 neighbor_addpath_tx_all_paths_hidden_cmd
,
8622 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8623 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8624 "Use addpath to advertise all paths to a neighbor\n")
8626 DEFUN (no_neighbor_addpath_tx_all_paths
,
8627 no_neighbor_addpath_tx_all_paths_cmd
,
8628 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8632 "Use addpath to advertise all paths to a neighbor\n")
8637 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8639 return CMD_WARNING_CONFIG_FAILED
;
8641 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8642 != BGP_ADDPATH_ALL
) {
8644 "%% Peer not currently configured to transmit all paths.");
8645 return CMD_WARNING_CONFIG_FAILED
;
8648 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8654 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8655 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8656 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8657 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8658 "Use addpath to advertise all paths to a neighbor\n")
8660 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8661 neighbor_addpath_tx_bestpath_per_as_cmd
,
8662 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8665 "Use addpath to advertise the bestpath per each neighboring AS\n")
8670 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8672 return CMD_WARNING_CONFIG_FAILED
;
8674 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8675 BGP_ADDPATH_BEST_PER_AS
);
8680 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8681 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8682 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8683 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8684 "Use addpath to advertise the bestpath per each neighboring AS\n")
8686 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8687 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8688 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8692 "Use addpath to advertise the bestpath per each neighboring AS\n")
8697 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8699 return CMD_WARNING_CONFIG_FAILED
;
8701 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8702 != BGP_ADDPATH_BEST_PER_AS
) {
8704 "%% Peer not currently configured to transmit all best path per as.");
8705 return CMD_WARNING_CONFIG_FAILED
;
8708 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8714 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8715 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8716 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8717 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8718 "Use addpath to advertise the bestpath per each neighboring AS\n")
8721 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8722 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8725 "Detect AS loops before sending to neighbor\n")
8729 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8731 return CMD_WARNING_CONFIG_FAILED
;
8733 peer
->as_path_loop_detection
= true;
8739 no_neighbor_aspath_loop_detection
,
8740 no_neighbor_aspath_loop_detection_cmd
,
8741 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8745 "Detect AS loops before sending to neighbor\n")
8749 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8751 return CMD_WARNING_CONFIG_FAILED
;
8753 peer
->as_path_loop_detection
= false;
8758 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8759 struct ecommunity
**list
, bool is_rt6
)
8761 struct ecommunity
*ecom
= NULL
;
8762 struct ecommunity
*ecomadd
;
8764 for (; argc
; --argc
, ++argv
) {
8766 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8767 ECOMMUNITY_ROUTE_TARGET
,
8770 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8771 ECOMMUNITY_ROUTE_TARGET
,
8774 vty_out(vty
, "Malformed community-list value\n");
8776 ecommunity_free(&ecom
);
8777 return CMD_WARNING_CONFIG_FAILED
;
8781 ecommunity_merge(ecom
, ecomadd
);
8782 ecommunity_free(&ecomadd
);
8789 ecommunity_free(&*list
);
8796 bool vpn_policy_check_import(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
8797 bool v2vimport
, char *errmsg
, size_t errmsg_len
)
8800 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8801 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8802 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8803 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8805 errmsg
, errmsg_len
, "%s",
8806 "%% error: Please unconfigure import vrf commands before using vpn commands");
8810 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8811 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8812 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8813 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8815 errmsg
, errmsg_len
, "%s",
8816 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands");
8824 * v2vimport is true if we are handling a `import vrf ...` command
8826 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8830 switch (vty
->node
) {
8839 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8844 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8845 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8846 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8847 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8849 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8853 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8854 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8855 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8856 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8858 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8867 af_rd_vpn_export_cmd
,
8868 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8870 "Specify route distinguisher\n"
8871 "Between current address-family and vpn\n"
8872 "For routes leaked from current address-family to vpn\n"
8873 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8875 char base_xpath
[XPATH_MAXLEN
];
8880 afi
= bgp_node_afi(vty
);
8881 safi
= bgp_node_safi(vty
);
8884 base_xpath
, sizeof(base_xpath
),
8885 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
8886 yang_afi_safi_value2identity(afi
, safi
),
8887 bgp_afi_safi_get_container_str(afi
, safi
));
8889 if (argv_find(argv
, argc
, "no", &idx
))
8890 nb_cli_enqueue_change(vty
, "./rd", NB_OP_DESTROY
, NULL
);
8892 nb_cli_enqueue_change(vty
, "./rd", NB_OP_MODIFY
, rd_str
);
8894 return nb_cli_apply_changes(vty
, base_xpath
);
8897 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rd(
8898 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
8902 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
8903 yang_dnode_get_string(dnode
, NULL
));
8906 ALIAS (af_rd_vpn_export
,
8907 af_no_rd_vpn_export_cmd
,
8910 "Specify route distinguisher\n"
8911 "Between current address-family and vpn\n"
8912 "For routes leaked from current address-family to vpn\n")
8914 DEFPY (af_label_vpn_export
,
8915 af_label_vpn_export_cmd
,
8916 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
8918 "label value for VRF\n"
8919 "Between current address-family and vpn\n"
8920 "For routes leaked from current address-family to vpn\n"
8921 "Label Value <0-1048575>\n"
8922 "Automatically assign a label\n")
8924 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8925 mpls_label_t label
= MPLS_LABEL_NONE
;
8930 if (argv_find(argv
, argc
, "no", &idx
))
8933 /* If "no ...", squash trailing parameter */
8939 label
= label_val
; /* parser should force unsigned */
8942 afi
= vpn_policy_getafi(vty
, bgp
, false);
8944 return CMD_WARNING_CONFIG_FAILED
;
8947 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8948 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
8953 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8955 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8956 bgp_get_default(), bgp
);
8958 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8959 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
8961 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
8964 * label has previously been automatically
8965 * assigned by labelpool: release it
8967 * NB if tovpn_label == MPLS_LABEL_NONE it
8968 * means the automatic assignment is in flight
8969 * and therefore the labelpool callback must
8970 * detect that the auto label is not needed.
8973 bgp_lp_release(LP_TYPE_VRF
,
8974 &bgp
->vpn_policy
[afi
],
8975 bgp
->vpn_policy
[afi
].tovpn_label
);
8977 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8978 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8981 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
8983 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8984 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8985 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
8986 vpn_leak_label_callback
);
8989 /* post-change: re-export vpn routes */
8990 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8991 bgp_get_default(), bgp
);
8996 ALIAS (af_label_vpn_export
,
8997 af_no_label_vpn_export_cmd
,
8998 "no label vpn export",
9000 "label value for VRF\n"
9001 "Between current address-family and vpn\n"
9002 "For routes leaked from current address-family to vpn\n")
9004 DEFPY_YANG (af_nexthop_vpn_export
,
9005 af_nexthop_vpn_export_cmd
,
9006 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
9008 "Specify next hop to use for VRF advertised prefixes\n"
9009 "Between current address-family and vpn\n"
9010 "For routes leaked from current address-family to vpn\n"
9014 char base_xpath
[XPATH_MAXLEN
];
9022 vty_out(vty
, "%% Nexthop required\n");
9023 return CMD_WARNING_CONFIG_FAILED
;
9025 if (!sockunion2hostprefix(nexthop_su
, &p
))
9026 return CMD_WARNING_CONFIG_FAILED
;
9029 afi
= bgp_node_afi(vty
);
9030 safi
= bgp_node_safi(vty
);
9033 base_xpath
, sizeof(base_xpath
),
9034 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9035 yang_afi_safi_value2identity(afi
, safi
),
9036 bgp_afi_safi_get_container_str(afi
, safi
));
9038 if (argv_find(argv
, argc
, "no", &idx
))
9039 nb_cli_enqueue_change(vty
, "./nexthop", NB_OP_DESTROY
, NULL
);
9041 nb_cli_enqueue_change(vty
, "./nexthop", NB_OP_MODIFY
,
9044 return nb_cli_apply_changes(vty
, base_xpath
);
9047 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_nexthop(
9048 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9052 vty_out(vty
, "%*snexthop vpn export %s\n", indent
, "",
9053 yang_dnode_get_string(dnode
, NULL
));
9056 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9058 if (!strcmp(dstr
, "import")) {
9059 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9060 } else if (!strcmp(dstr
, "export")) {
9061 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9062 } else if (!strcmp(dstr
, "both")) {
9063 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9064 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9066 vty_out(vty
, "%% direction parse error\n");
9067 return CMD_WARNING_CONFIG_FAILED
;
9072 DEFPY (af_rt_vpn_imexport
,
9073 af_rt_vpn_imexport_cmd
,
9074 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9076 "Specify route target list\n"
9077 "Specify route target list\n"
9078 "Between current address-family and vpn\n"
9079 "For routes leaked from vpn to current address-family: match any\n"
9080 "For routes leaked from current address-family to vpn: set\n"
9081 "both import: match any and export: set\n"
9082 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9084 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9086 struct ecommunity
*ecom
= NULL
;
9087 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9088 vpn_policy_direction_t dir
;
9093 if (argv_find(argv
, argc
, "no", &idx
))
9096 afi
= vpn_policy_getafi(vty
, bgp
, false);
9098 return CMD_WARNING_CONFIG_FAILED
;
9100 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9101 if (ret
!= CMD_SUCCESS
)
9105 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9106 vty_out(vty
, "%% Missing RTLIST\n");
9107 return CMD_WARNING_CONFIG_FAILED
;
9109 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9110 if (ret
!= CMD_SUCCESS
) {
9115 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9119 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9122 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9124 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9125 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9126 ecommunity_dup(ecom
);
9128 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9130 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9131 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9134 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9138 ecommunity_free(&ecom
);
9143 ALIAS (af_rt_vpn_imexport
,
9144 af_no_rt_vpn_imexport_cmd
,
9145 "no <rt|route-target> vpn <import|export|both>$direction_str",
9147 "Specify route target list\n"
9148 "Specify route target list\n"
9149 "Between current address-family and vpn\n"
9150 "For routes leaked from vpn to current address-family\n"
9151 "For routes leaked from current address-family to vpn\n"
9152 "both import and export\n")
9154 DEFPY_YANG (af_route_map_vpn_imexport
,
9155 af_route_map_vpn_imexport_cmd
,
9156 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9157 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9159 "Specify route map\n"
9160 "Between current address-family and vpn\n"
9161 "For routes leaked from vpn to current address-family\n"
9162 "For routes leaked from current address-family to vpn\n"
9163 "name of route-map\n")
9165 char base_xpath
[XPATH_MAXLEN
];
9170 afi
= bgp_node_afi(vty
);
9171 safi
= bgp_node_safi(vty
);
9174 base_xpath
, sizeof(base_xpath
),
9175 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9176 yang_afi_safi_value2identity(afi
, safi
),
9177 bgp_afi_safi_get_container_str(afi
, safi
));
9179 if (argv_find(argv
, argc
, "no", &idx
)) {
9180 if (!strcmp(direction_str
, "import"))
9181 nb_cli_enqueue_change(vty
, "./rmap-import",
9182 NB_OP_DESTROY
, NULL
);
9183 else if (!strcmp(direction_str
, "export"))
9184 nb_cli_enqueue_change(vty
, "./rmap-export",
9185 NB_OP_DESTROY
, NULL
);
9187 if (!strcmp(direction_str
, "import"))
9188 nb_cli_enqueue_change(vty
, "./rmap-import",
9189 NB_OP_MODIFY
, rmap_str
);
9190 if (!strcmp(direction_str
, "export"))
9191 nb_cli_enqueue_change(vty
, "./rmap-export",
9192 NB_OP_MODIFY
, rmap_str
);
9194 return nb_cli_apply_changes(vty
, base_xpath
);
9197 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_import(
9198 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9202 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
9203 yang_dnode_get_string(dnode
, NULL
));
9206 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_export(
9207 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9211 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
9212 yang_dnode_get_string(dnode
, NULL
));
9215 ALIAS (af_route_map_vpn_imexport
,
9216 af_no_route_map_vpn_imexport_cmd
,
9217 "no route-map vpn <import|export>$direction_str",
9219 "Specify route map\n"
9220 "Between current address-family and vpn\n"
9221 "For routes leaked from vpn to current address-family\n"
9222 "For routes leaked from current address-family to vpn\n")
9224 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9225 "import vrf route-map RMAP$rmap_str",
9226 "Import routes from another VRF\n"
9227 "Vrf routes being filtered\n"
9228 "Specify route map\n"
9229 "name of route-map\n")
9231 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9232 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9234 struct bgp
*bgp_default
;
9236 afi
= vpn_policy_getafi(vty
, bgp
, true);
9238 return CMD_WARNING_CONFIG_FAILED
;
9240 bgp_default
= bgp_get_default();
9245 /* Auto-create assuming the same AS */
9246 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9247 BGP_INSTANCE_TYPE_DEFAULT
);
9251 "VRF default is not configured as a bgp instance\n");
9256 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9258 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9259 XFREE(MTYPE_ROUTE_MAP_NAME
,
9260 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9261 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9262 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9263 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9264 route_map_lookup_warn_noexist(vty
, rmap_str
);
9265 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9268 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9269 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9271 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9276 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9277 "no import vrf route-map [RMAP$rmap_str]",
9279 "Import routes from another VRF\n"
9280 "Vrf routes being filtered\n"
9281 "Specify route map\n"
9282 "name of route-map\n")
9284 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9285 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9288 afi
= vpn_policy_getafi(vty
, bgp
, true);
9290 return CMD_WARNING_CONFIG_FAILED
;
9292 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9294 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9295 XFREE(MTYPE_ROUTE_MAP_NAME
,
9296 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9297 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9298 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9300 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9301 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9302 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9304 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9309 DEFPY_YANG(bgp_imexport_vrf
,
9310 bgp_imexport_vrf_cmd
,
9311 "[no] import vrf VIEWVRFNAME$import_name",
9313 "Import routes from another VRF\n"
9314 "VRF to import from\n"
9315 "The name of the VRF\n")
9317 char base_xpath
[XPATH_MAXLEN
];
9322 if (import_name
== NULL
) {
9323 vty_out(vty
, "%% Missing import name\n");
9327 if (strcmp(import_name
, "route-map") == 0) {
9328 vty_out(vty
, "%% Must include route-map name\n");
9332 afi
= bgp_node_afi(vty
);
9333 safi
= bgp_node_safi(vty
);
9336 base_xpath
, sizeof(base_xpath
),
9337 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vrf-list[vrf='%s']",
9338 yang_afi_safi_value2identity(afi
, safi
),
9339 bgp_afi_safi_get_container_str(afi
, safi
), import_name
);
9341 if (argv_find(argv
, argc
, "no", &idx
))
9342 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
9344 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
9346 return nb_cli_apply_changes(vty
, base_xpath
);
9349 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vrfs(
9350 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9352 vty_out(vty
, " import vrf %s\n",
9353 yang_dnode_get_string(dnode
, "./vrf"));
9356 /* This command is valid only in a bgp vrf instance or the default instance */
9357 DEFPY_YANG (bgp_imexport_vpn
,
9358 bgp_imexport_vpn_cmd
,
9359 "[no] <import|export>$direction_str vpn",
9361 "Import routes to this address-family\n"
9362 "Export routes from this address-family\n"
9363 "to/from default instance VPN RIB\n")
9365 char base_xpath
[XPATH_MAXLEN
];
9370 afi
= bgp_node_afi(vty
);
9371 safi
= bgp_node_safi(vty
);
9373 if (!strcmp(direction_str
, "import")) {
9375 base_xpath
, sizeof(base_xpath
),
9376 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vpn",
9377 yang_afi_safi_value2identity(afi
, safi
),
9378 bgp_afi_safi_get_container_str(afi
, safi
));
9379 } else if (!strcmp(direction_str
, "export")) {
9381 base_xpath
, sizeof(base_xpath
),
9382 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/export-vpn",
9383 yang_afi_safi_value2identity(afi
, safi
),
9384 bgp_afi_safi_get_container_str(afi
, safi
));
9386 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9387 return CMD_WARNING_CONFIG_FAILED
;
9390 if (argv_find(argv
, argc
, "no", &idx
))
9391 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
9393 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, "true");
9395 return nb_cli_apply_changes(vty
, base_xpath
);
9398 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vpn(
9399 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9401 if (yang_dnode_get_bool(dnode
, NULL
))
9402 vty_out(vty
, " import vpn\n");
9405 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_export_vpn(
9406 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9408 if (yang_dnode_get_bool(dnode
, NULL
))
9409 vty_out(vty
, " export vpn\n");
9412 DEFPY (af_routetarget_import
,
9413 af_routetarget_import_cmd
,
9414 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9416 "Specify route target list\n"
9417 "Specify route target list\n"
9418 "Specify route target list\n"
9419 "Specify route target list\n"
9420 "Flow-spec redirect type route target\n"
9421 "Import routes to this address-family\n"
9422 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9424 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9426 struct ecommunity
*ecom
= NULL
;
9428 int idx
= 0, idx_unused
= 0;
9432 if (argv_find(argv
, argc
, "no", &idx
))
9435 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9436 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9439 afi
= vpn_policy_getafi(vty
, bgp
, false);
9441 return CMD_WARNING_CONFIG_FAILED
;
9443 if (rt6
&& afi
!= AFI_IP6
)
9444 return CMD_WARNING_CONFIG_FAILED
;
9447 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9448 vty_out(vty
, "%% Missing RTLIST\n");
9449 return CMD_WARNING_CONFIG_FAILED
;
9451 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9452 if (ret
!= CMD_SUCCESS
)
9457 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9458 ecommunity_free(&bgp
->vpn_policy
[afi
]
9459 .import_redirect_rtlist
);
9460 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9461 ecommunity_dup(ecom
);
9463 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9464 ecommunity_free(&bgp
->vpn_policy
[afi
]
9465 .import_redirect_rtlist
);
9466 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9470 ecommunity_free(&ecom
);
9475 void cli_show_bgp_global_afi_safi_header(struct vty
*vty
,
9476 struct lyd_node
*dnode
,
9479 const char *af_name
;
9483 af_name
= yang_dnode_get_string(dnode
, "./afi-safi-name");
9484 yang_afi_safi_identity2value(af_name
, &afi
, &safi
);
9486 vty_out(vty
, " !\n address-family ");
9487 if (afi
== AFI_IP
) {
9488 if (safi
== SAFI_UNICAST
)
9489 vty_out(vty
, "ipv4 unicast");
9490 else if (safi
== SAFI_LABELED_UNICAST
)
9491 vty_out(vty
, "ipv4 labeled-unicast");
9492 else if (safi
== SAFI_MULTICAST
)
9493 vty_out(vty
, "ipv4 multicast");
9494 else if (safi
== SAFI_MPLS_VPN
)
9495 vty_out(vty
, "ipv4 vpn");
9496 else if (safi
== SAFI_ENCAP
)
9497 vty_out(vty
, "ipv4 encap");
9498 else if (safi
== SAFI_FLOWSPEC
)
9499 vty_out(vty
, "ipv4 flowspec");
9500 } else if (afi
== AFI_IP6
) {
9501 if (safi
== SAFI_UNICAST
)
9502 vty_out(vty
, "ipv6 unicast");
9503 else if (safi
== SAFI_LABELED_UNICAST
)
9504 vty_out(vty
, "ipv6 labeled-unicast");
9505 else if (safi
== SAFI_MULTICAST
)
9506 vty_out(vty
, "ipv6 multicast");
9507 else if (safi
== SAFI_MPLS_VPN
)
9508 vty_out(vty
, "ipv6 vpn");
9509 else if (safi
== SAFI_ENCAP
)
9510 vty_out(vty
, "ipv6 encap");
9511 else if (safi
== SAFI_FLOWSPEC
)
9512 vty_out(vty
, "ipv6 flowspec");
9513 } else if (afi
== AFI_L2VPN
) {
9514 if (safi
== SAFI_EVPN
)
9515 vty_out(vty
, "l2vpn evpn");
9520 DEFUN_NOSH (address_family_ipv4_safi
,
9521 address_family_ipv4_safi_cmd
,
9522 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9523 "Enter Address Family command mode\n"
9525 BGP_SAFI_WITH_LABEL_HELP_STR
)
9528 safi_t safi
= SAFI_UNICAST
;
9529 const struct lyd_node
*vrf_dnode
, *bgp_glb_dnode
;
9530 const char *vrf_name
= NULL
;
9533 safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9535 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
9537 vrf_dnode
= yang_dnode_get_parent(bgp_glb_dnode
,
9538 "control-plane-protocol");
9539 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
9541 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
)
9542 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9543 && safi
!= SAFI_EVPN
) {
9545 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9546 return CMD_WARNING_CONFIG_FAILED
;
9549 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9554 DEFUN_NOSH (address_family_ipv6_safi
,
9555 address_family_ipv6_safi_cmd
,
9556 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9557 "Enter Address Family command mode\n"
9559 BGP_SAFI_WITH_LABEL_HELP_STR
)
9561 safi_t safi
= SAFI_UNICAST
;
9562 const struct lyd_node
*vrf_dnode
, *bgp_glb_dnode
;
9563 const char *vrf_name
= NULL
;
9566 safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9567 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
9569 vrf_dnode
= yang_dnode_get_parent(bgp_glb_dnode
,
9570 "control-plane-protocol");
9571 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
9573 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
)
9574 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9575 && safi
!= SAFI_EVPN
) {
9577 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9578 return CMD_WARNING_CONFIG_FAILED
;
9581 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9586 #ifdef KEEP_OLD_VPN_COMMANDS
9587 DEFUN_NOSH (address_family_vpnv4
,
9588 address_family_vpnv4_cmd
,
9589 "address-family vpnv4 [unicast]",
9590 "Enter Address Family command mode\n"
9592 "Address Family modifier\n")
9594 vty
->node
= BGP_VPNV4_NODE
;
9598 DEFUN_NOSH (address_family_vpnv6
,
9599 address_family_vpnv6_cmd
,
9600 "address-family vpnv6 [unicast]",
9601 "Enter Address Family command mode\n"
9603 "Address Family modifier\n")
9605 vty
->node
= BGP_VPNV6_NODE
;
9608 #endif /* KEEP_OLD_VPN_COMMANDS */
9610 DEFUN_NOSH (address_family_evpn
,
9611 address_family_evpn_cmd
,
9612 "address-family l2vpn evpn",
9613 "Enter Address Family command mode\n"
9615 "Address Family modifier\n")
9617 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9618 vty
->node
= BGP_EVPN_NODE
;
9622 DEFUN_NOSH (exit_address_family
,
9623 exit_address_family_cmd
,
9624 "exit-address-family",
9625 "Exit from Address Family configuration mode\n")
9627 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9628 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9629 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9630 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9631 || vty
->node
== BGP_EVPN_NODE
9632 || vty
->node
== BGP_FLOWSPECV4_NODE
9633 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9634 vty
->node
= BGP_NODE
;
9638 void cli_show_bgp_global_afi_safi_header_end(struct vty
*vty
,
9639 struct lyd_node
*dnode
9640 __attribute__((__unused__
)))
9642 vty_out(vty
, " exit-address-family\n");
9645 /* Recalculate bestpath and re-advertise a prefix */
9646 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9647 const char *ip_str
, afi_t afi
, safi_t safi
,
9648 struct prefix_rd
*prd
)
9651 struct prefix match
;
9652 struct bgp_dest
*dest
;
9653 struct bgp_dest
*rm
;
9655 struct bgp_table
*table
;
9656 struct bgp_table
*rib
;
9658 /* BGP structure lookup. */
9660 bgp
= bgp_lookup_by_name(view_name
);
9662 vty_out(vty
, "%% Can't find BGP instance %s\n",
9667 bgp
= bgp_get_default();
9669 vty_out(vty
, "%% No BGP process is configured\n");
9674 /* Check IP address argument. */
9675 ret
= str2prefix(ip_str
, &match
);
9677 vty_out(vty
, "%% address is malformed\n");
9681 match
.family
= afi2family(afi
);
9682 rib
= bgp
->rib
[afi
][safi
];
9684 if (safi
== SAFI_MPLS_VPN
) {
9685 for (dest
= bgp_table_top(rib
); dest
;
9686 dest
= bgp_route_next(dest
)) {
9687 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9689 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9692 table
= bgp_dest_get_bgp_table_info(dest
);
9696 if ((rm
= bgp_node_match(table
, &match
)) != NULL
) {
9697 const struct prefix
*rm_p
=
9698 bgp_dest_get_prefix(rm
);
9700 if (rm_p
->prefixlen
== match
.prefixlen
) {
9702 BGP_NODE_USER_CLEAR
);
9703 bgp_process(bgp
, rm
, afi
, safi
);
9705 bgp_dest_unlock_node(rm
);
9709 if ((dest
= bgp_node_match(rib
, &match
)) != NULL
) {
9710 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9712 if (dest_p
->prefixlen
== match
.prefixlen
) {
9713 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9714 bgp_process(bgp
, dest
, afi
, safi
);
9716 bgp_dest_unlock_node(dest
);
9723 /* one clear bgp command to rule them all */
9724 DEFUN (clear_ip_bgp_all
,
9725 clear_ip_bgp_all_cmd
,
9726 "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>]",
9730 BGP_INSTANCE_HELP_STR
9733 BGP_SAFI_WITH_LABEL_HELP_STR
9734 "Address Family modifier\n"
9736 "BGP IPv4 neighbor to clear\n"
9737 "BGP IPv6 neighbor to clear\n"
9738 "BGP neighbor on interface to clear\n"
9739 "Clear peers with the AS number\n"
9740 "Clear all external peers\n"
9741 "Clear all members of peer-group\n"
9742 "BGP peer-group name\n"
9747 "Push out prefix-list ORF and do inbound soft reconfig\n"
9752 afi_t afi
= AFI_UNSPEC
;
9753 safi_t safi
= SAFI_UNSPEC
;
9754 enum clear_sort clr_sort
= clear_peer
;
9755 enum bgp_clear_type clr_type
;
9756 char *clr_arg
= NULL
;
9759 char errmsg
[BUFSIZ
] = {'\0'};
9762 /* clear [ip] bgp */
9763 if (argv_find(argv
, argc
, "ip", &idx
))
9766 /* [<vrf> VIEWVRFNAME] */
9767 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9768 vrf
= argv
[idx
+ 1]->arg
;
9770 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9772 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9773 /* [<view> VIEWVRFNAME] */
9774 vrf
= argv
[idx
+ 1]->arg
;
9777 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9778 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
9779 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
9781 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
9782 if (argv_find(argv
, argc
, "*", &idx
)) {
9783 clr_sort
= clear_all
;
9784 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
9785 clr_sort
= clear_peer
;
9786 clr_arg
= argv
[idx
]->arg
;
9787 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
9788 clr_sort
= clear_peer
;
9789 clr_arg
= argv
[idx
]->arg
;
9790 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
9791 clr_sort
= clear_group
;
9793 clr_arg
= argv
[idx
]->arg
;
9794 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
9795 clr_sort
= clear_peer
;
9796 clr_arg
= argv
[idx
]->arg
;
9797 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
9798 clr_sort
= clear_peer
;
9799 clr_arg
= argv
[idx
]->arg
;
9800 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
9801 clr_sort
= clear_as
;
9802 clr_arg
= argv
[idx
]->arg
;
9803 } else if (argv_find(argv
, argc
, "external", &idx
)) {
9804 clr_sort
= clear_external
;
9807 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
9808 if (argv_find(argv
, argc
, "soft", &idx
)) {
9809 if (argv_find(argv
, argc
, "in", &idx
)
9810 || argv_find(argv
, argc
, "out", &idx
))
9811 clr_type
= strmatch(argv
[idx
]->text
, "in")
9813 : BGP_CLEAR_SOFT_OUT
;
9815 clr_type
= BGP_CLEAR_SOFT_BOTH
;
9816 } else if (argv_find(argv
, argc
, "in", &idx
)) {
9817 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
9818 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
9819 : BGP_CLEAR_SOFT_IN
;
9820 } else if (argv_find(argv
, argc
, "out", &idx
)) {
9821 clr_type
= BGP_CLEAR_SOFT_OUT
;
9823 clr_type
= BGP_CLEAR_SOFT_NONE
;
9825 ret
= bgp_clear_vty(vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
, errmsg
,
9828 vty_out(vty
, "Error description: %s\n", errmsg
);
9833 DEFUN (clear_ip_bgp_prefix
,
9834 clear_ip_bgp_prefix_cmd
,
9835 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
9839 BGP_INSTANCE_HELP_STR
9840 "Clear bestpath and re-advertise\n"
9844 char *prefix
= NULL
;
9848 /* [<view|vrf> VIEWVRFNAME] */
9849 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9850 vrf
= argv
[idx
+ 1]->arg
;
9852 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9854 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9855 /* [<view> VIEWVRFNAME] */
9856 vrf
= argv
[idx
+ 1]->arg
;
9860 prefix
= argv
[argc
- 1]->arg
;
9862 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
9865 DEFUN (clear_bgp_ipv6_safi_prefix
,
9866 clear_bgp_ipv6_safi_prefix_cmd
,
9867 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9873 "Clear bestpath and re-advertise\n"
9877 int idx_ipv6_prefix
= 0;
9878 safi_t safi
= SAFI_UNICAST
;
9879 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9880 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9882 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9883 return bgp_clear_prefix(
9884 vty
, NULL
, prefix
, AFI_IP6
,
9888 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
9889 clear_bgp_instance_ipv6_safi_prefix_cmd
,
9890 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9894 BGP_INSTANCE_HELP_STR
9897 "Clear bestpath and re-advertise\n"
9901 int idx_vrfview
= 0;
9902 int idx_ipv6_prefix
= 0;
9903 safi_t safi
= SAFI_UNICAST
;
9904 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9905 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9906 char *vrfview
= NULL
;
9908 /* [<view|vrf> VIEWVRFNAME] */
9909 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
9910 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9911 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
9913 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
9914 /* [<view> VIEWVRFNAME] */
9915 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9917 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9919 return bgp_clear_prefix(
9920 vty
, vrfview
, prefix
,
9921 AFI_IP6
, safi
, NULL
);
9924 DEFUN (show_bgp_views
,
9926 "show [ip] bgp views",
9930 "Show the defined BGP views\n")
9932 struct list
*inst
= bm
->bgp
;
9933 struct listnode
*node
;
9936 vty_out(vty
, "Defined BGP views:\n");
9937 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
9939 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
9941 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
9948 DEFUN (show_bgp_vrfs
,
9950 "show [ip] bgp vrfs [json]",
9957 char buf
[ETHER_ADDR_STRLEN
];
9958 struct list
*inst
= bm
->bgp
;
9959 struct listnode
*node
;
9961 bool uj
= use_json(argc
, argv
);
9962 json_object
*json
= NULL
;
9963 json_object
*json_vrfs
= NULL
;
9967 json
= json_object_new_object();
9968 json_vrfs
= json_object_new_object();
9971 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
9972 const char *name
, *type
;
9974 struct listnode
*node2
, *nnode2
;
9975 int peers_cfg
, peers_estb
;
9976 json_object
*json_vrf
= NULL
;
9979 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
9983 if (!uj
&& count
== 1) {
9985 "%4s %-5s %-16s %9s %10s %-37s\n",
9986 "Type", "Id", "routerId", "#PeersCfg",
9987 "#PeersEstb", "Name");
9988 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
9989 "L3-VNI", "RouterMAC", "Interface");
9992 peers_cfg
= peers_estb
= 0;
9994 json_vrf
= json_object_new_object();
9997 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
9998 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10001 if (peer
->status
== Established
)
10005 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10006 name
= VRF_DEFAULT_NAME
;
10015 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10017 : (int64_t)bgp
->vrf_id
;
10018 char buf
[BUFSIZ
] = {0};
10020 json_object_string_add(json_vrf
, "type", type
);
10021 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
10022 json_object_string_add(json_vrf
, "routerId",
10024 &bgp
->router_id
, buf
,
10026 json_object_int_add(json_vrf
, "numConfiguredPeers",
10028 json_object_int_add(json_vrf
, "numEstablishedPeers",
10031 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
10032 json_object_string_add(
10034 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
10035 json_object_string_add(json_vrf
, "interface",
10036 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10038 json_object_object_add(json_vrfs
, name
, json_vrf
);
10040 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10042 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10043 : (int)bgp
->vrf_id
,
10044 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10045 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
10047 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
10048 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10054 json_object_object_add(json
, "vrfs", json_vrfs
);
10056 json_object_int_add(json
, "totalVrfs", count
);
10058 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10059 json
, JSON_C_TO_STRING_PRETTY
));
10060 json_object_free(json
);
10064 "\nTotal number of VRFs (including default): %d\n",
10068 return CMD_SUCCESS
;
10071 DEFUN (show_bgp_mac_hash
,
10072 show_bgp_mac_hash_cmd
,
10073 "show bgp mac hash",
10077 "Mac Address database\n")
10079 bgp_mac_dump_table(vty
);
10081 return CMD_SUCCESS
;
10084 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10086 struct vty
*vty
= (struct vty
*)args
;
10087 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10089 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10092 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10094 vty_out(vty
, "self nexthop database:\n");
10095 bgp_nexthop_show_address_hash(vty
, bgp
);
10097 vty_out(vty
, "Tunnel-ip database:\n");
10098 hash_iterate(bgp
->tip_hash
,
10099 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10103 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10104 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10105 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10106 "martian next-hops\n"
10107 "martian next-hop database\n")
10109 struct bgp
*bgp
= NULL
;
10113 /* [<vrf> VIEWVRFNAME] */
10114 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10115 name
= argv
[idx
+ 1]->arg
;
10116 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10118 } else if (argv_find(argv
, argc
, "view", &idx
))
10119 /* [<view> VIEWVRFNAME] */
10120 name
= argv
[idx
+ 1]->arg
;
10122 bgp
= bgp_lookup_by_name(name
);
10124 bgp
= bgp_get_default();
10127 vty_out(vty
, "%% No BGP process is configured\n");
10128 return CMD_WARNING
;
10130 bgp_show_martian_nexthops(vty
, bgp
);
10132 return CMD_SUCCESS
;
10135 DEFUN (show_bgp_memory
,
10136 show_bgp_memory_cmd
,
10137 "show [ip] bgp memory",
10141 "Global BGP memory statistics\n")
10143 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10144 unsigned long count
;
10146 /* RIB related usage stats */
10147 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10148 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10149 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10150 count
* sizeof(struct bgp_dest
)));
10152 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10153 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10154 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10155 count
* sizeof(struct bgp_path_info
)));
10156 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10157 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10160 memstrbuf
, sizeof(memstrbuf
),
10161 count
* sizeof(struct bgp_path_info_extra
)));
10163 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10164 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10165 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10166 count
* sizeof(struct bgp_static
)));
10168 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10169 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10170 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10171 count
* sizeof(struct bpacket
)));
10174 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10175 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10176 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10177 count
* sizeof(struct bgp_adj_in
)));
10178 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10179 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10180 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10181 count
* sizeof(struct bgp_adj_out
)));
10183 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10184 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10186 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10187 count
* sizeof(struct bgp_nexthop_cache
)));
10189 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10190 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10192 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10193 count
* sizeof(struct bgp_damp_info
)));
10196 count
= attr_count();
10197 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10198 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10199 count
* sizeof(struct attr
)));
10201 if ((count
= attr_unknown_count()))
10202 vty_out(vty
, "%ld unknown attributes\n", count
);
10204 /* AS_PATH attributes */
10205 count
= aspath_count();
10206 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10207 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10208 count
* sizeof(struct aspath
)));
10210 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10211 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10212 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10213 count
* sizeof(struct assegment
)));
10215 /* Other attributes */
10216 if ((count
= community_count()))
10217 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10218 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10219 count
* sizeof(struct community
)));
10220 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10221 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10222 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10223 count
* sizeof(struct ecommunity
)));
10224 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10226 "%ld BGP large-community entries, using %s of memory\n",
10227 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10228 count
* sizeof(struct lcommunity
)));
10230 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10231 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10232 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10233 count
* sizeof(struct cluster_list
)));
10235 /* Peer related usage */
10236 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10237 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10238 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10239 count
* sizeof(struct peer
)));
10241 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10242 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10243 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10244 count
* sizeof(struct peer_group
)));
10247 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10248 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10249 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10250 count
* sizeof(regex_t
)));
10251 return CMD_SUCCESS
;
10254 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10256 json_object
*bestpath
= json_object_new_object();
10258 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10259 json_object_string_add(bestpath
, "asPath", "ignore");
10261 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10262 json_object_string_add(bestpath
, "asPath", "confed");
10264 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10265 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10266 json_object_string_add(bestpath
, "multiPathRelax",
10269 json_object_string_add(bestpath
, "multiPathRelax",
10272 json_object_string_add(bestpath
, "multiPathRelax", "false");
10274 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10275 json_object_string_add(bestpath
, "compareRouterId", "true");
10276 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10277 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10278 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10279 json_object_string_add(bestpath
, "med", "confed");
10280 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10281 json_object_string_add(bestpath
, "med",
10282 "missing-as-worst");
10284 json_object_string_add(bestpath
, "med", "true");
10287 json_object_object_add(json
, "bestPath", bestpath
);
10290 /* Print the error code/subcode for why the peer is down */
10291 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10292 json_object
*json_peer
, bool use_json
)
10294 const char *code_str
;
10295 const char *subcode_str
;
10298 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10299 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10300 char errorcodesubcode_hexstr
[5];
10301 char errorcodesubcode_str
[256];
10303 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10304 subcode_str
= bgp_notify_subcode_str(
10306 peer
->notify
.subcode
);
10308 snprintf(errorcodesubcode_hexstr
,
10309 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10310 peer
->notify
.code
, peer
->notify
.subcode
);
10311 json_object_string_add(json_peer
,
10312 "lastErrorCodeSubcode",
10313 errorcodesubcode_hexstr
);
10314 snprintf(errorcodesubcode_str
, 255, "%s%s",
10315 code_str
, subcode_str
);
10316 json_object_string_add(json_peer
,
10317 "lastNotificationReason",
10318 errorcodesubcode_str
);
10319 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10320 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10321 && (peer
->notify
.subcode
10322 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10323 || peer
->notify
.subcode
10324 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10325 && peer
->notify
.length
) {
10327 const char *msg_str
;
10329 msg_str
= bgp_notify_admin_message(
10330 msgbuf
, sizeof(msgbuf
),
10331 (uint8_t *)peer
->notify
.data
,
10332 peer
->notify
.length
);
10334 json_object_string_add(
10336 "lastShutdownDescription",
10341 json_object_string_add(json_peer
, "lastResetDueTo",
10342 peer_down_str
[(int)peer
->last_reset
]);
10343 json_object_int_add(json_peer
, "lastResetCode",
10346 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10347 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10348 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10350 bgp_notify_subcode_str(peer
->notify
.code
,
10351 peer
->notify
.subcode
);
10352 vty_out(vty
, " Notification %s (%s%s)\n",
10353 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10356 code_str
, subcode_str
);
10358 vty_out(vty
, " %s\n",
10359 peer_down_str
[(int)peer
->last_reset
]);
10364 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10367 return ((peer
->status
!= Established
) ||
10368 !peer
->afc_recv
[afi
][safi
]);
10371 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10372 struct peer
*peer
, json_object
*json_peer
,
10373 int max_neighbor_width
, bool use_json
)
10375 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10379 if (peer_dynamic_neighbor(peer
))
10380 json_object_boolean_true_add(json_peer
,
10382 if (peer
->hostname
)
10383 json_object_string_add(json_peer
, "hostname",
10386 if (peer
->domainname
)
10387 json_object_string_add(json_peer
, "domainname",
10389 json_object_int_add(json_peer
, "connectionsEstablished",
10390 peer
->established
);
10391 json_object_int_add(json_peer
, "connectionsDropped",
10393 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10394 use_json
, json_peer
);
10395 if (peer
->status
== Established
)
10396 json_object_string_add(json_peer
, "lastResetDueTo",
10397 "AFI/SAFI Not Negotiated");
10399 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10402 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10404 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10405 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10406 peer
->hostname
, peer
->host
);
10408 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10410 /* pad the neighbor column with spaces */
10411 if (len
< max_neighbor_width
)
10412 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10414 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10416 peer_uptime(peer
->uptime
, timebuf
,
10417 BGP_UPTIME_LEN
, 0, NULL
));
10418 if (peer
->status
== Established
)
10419 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10421 bgp_show_peer_reset(vty
, peer
, NULL
,
10427 /* Show BGP peer's summary information. */
10428 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10429 bool show_failed
, bool show_established
,
10433 struct listnode
*node
, *nnode
;
10434 unsigned int count
= 0, dn_count
= 0;
10435 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10436 char neighbor_buf
[VTY_BUFSIZ
];
10437 int neighbor_col_default_width
= 16;
10438 int len
, failed_count
= 0;
10439 int max_neighbor_width
= 0;
10441 json_object
*json
= NULL
;
10442 json_object
*json_peer
= NULL
;
10443 json_object
*json_peers
= NULL
;
10444 struct peer_af
*paf
;
10445 struct bgp_filter
*filter
;
10447 /* labeled-unicast routes are installed in the unicast table so in order
10449 * display the correct PfxRcd value we must look at SAFI_UNICAST
10452 if (safi
== SAFI_LABELED_UNICAST
)
10453 pfx_rcd_safi
= SAFI_UNICAST
;
10455 pfx_rcd_safi
= safi
;
10458 json
= json_object_new_object();
10459 json_peers
= json_object_new_object();
10460 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10461 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10464 if (peer
->afc
[afi
][safi
]) {
10465 /* See if we have at least a single failed peer */
10466 if (bgp_has_peer_failed(peer
, afi
, safi
))
10470 if (peer_dynamic_neighbor(peer
))
10475 /* Loop over all neighbors that will be displayed to determine
10477 * characters are needed for the Neighbor column
10479 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10480 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10483 if (peer
->afc
[afi
][safi
]) {
10484 memset(dn_flag
, '\0', sizeof(dn_flag
));
10485 if (peer_dynamic_neighbor(peer
))
10489 && CHECK_FLAG(bgp
->flags
,
10490 BGP_FLAG_SHOW_HOSTNAME
))
10491 snprintf(neighbor_buf
,
10492 sizeof(neighbor_buf
),
10493 "%s%s(%s) ", dn_flag
,
10494 peer
->hostname
, peer
->host
);
10496 snprintf(neighbor_buf
,
10497 sizeof(neighbor_buf
), "%s%s ",
10498 dn_flag
, peer
->host
);
10500 len
= strlen(neighbor_buf
);
10502 if (len
> max_neighbor_width
)
10503 max_neighbor_width
= len
;
10505 /* See if we have at least a single failed peer */
10506 if (bgp_has_peer_failed(peer
, afi
, safi
))
10512 /* Originally we displayed the Neighbor column as 16
10513 * characters wide so make that the default
10515 if (max_neighbor_width
< neighbor_col_default_width
)
10516 max_neighbor_width
= neighbor_col_default_width
;
10519 if (show_failed
&& !failed_count
) {
10521 json_object_int_add(json
, "failedPeersCount", 0);
10522 json_object_int_add(json
, "dynamicPeers", dn_count
);
10523 json_object_int_add(json
, "totalPeers", count
);
10525 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10526 json
, JSON_C_TO_STRING_PRETTY
));
10527 json_object_free(json
);
10529 vty_out(vty
, "%% No failed BGP neighbors found\n");
10530 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
10532 return CMD_SUCCESS
;
10535 count
= 0; /* Reset the value as its used again */
10536 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10537 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10540 if (!peer
->afc
[afi
][safi
])
10544 unsigned long ents
;
10545 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10548 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10550 : (int64_t)bgp
->vrf_id
;
10552 /* Usage summary and header */
10554 char buf
[BUFSIZ
] = {0};
10556 json_object_string_add(
10558 inet_ntop(AF_INET
, &bgp
->router_id
, buf
,
10560 json_object_int_add(json
, "as", bgp
->as
);
10561 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10562 json_object_string_add(
10565 == BGP_INSTANCE_TYPE_DEFAULT
)
10570 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10571 &bgp
->router_id
, bgp
->as
,
10572 bgp
->vrf_id
== VRF_UNKNOWN
10574 : (int)bgp
->vrf_id
);
10575 vty_out(vty
, "\n");
10578 if (bgp_update_delay_configured(bgp
)) {
10580 json_object_int_add(
10581 json
, "updateDelayLimit",
10582 bgp
->v_update_delay
);
10584 if (bgp
->v_update_delay
10585 != bgp
->v_establish_wait
)
10586 json_object_int_add(
10588 "updateDelayEstablishWait",
10589 bgp
->v_establish_wait
);
10591 if (bgp_update_delay_active(bgp
)) {
10592 json_object_string_add(
10594 "updateDelayFirstNeighbor",
10595 bgp
->update_delay_begin_time
);
10596 json_object_boolean_true_add(
10598 "updateDelayInProgress");
10600 if (bgp
->update_delay_over
) {
10601 json_object_string_add(
10603 "updateDelayFirstNeighbor",
10604 bgp
->update_delay_begin_time
);
10605 json_object_string_add(
10607 "updateDelayBestpathResumed",
10608 bgp
->update_delay_end_time
);
10609 json_object_string_add(
10611 "updateDelayZebraUpdateResume",
10612 bgp
->update_delay_zebra_resume_time
);
10613 json_object_string_add(
10615 "updateDelayPeerUpdateResume",
10616 bgp
->update_delay_peers_resume_time
);
10621 "Read-only mode update-delay limit: %d seconds\n",
10622 bgp
->v_update_delay
);
10623 if (bgp
->v_update_delay
10624 != bgp
->v_establish_wait
)
10626 " Establish wait: %d seconds\n",
10627 bgp
->v_establish_wait
);
10629 if (bgp_update_delay_active(bgp
)) {
10631 " First neighbor established: %s\n",
10632 bgp
->update_delay_begin_time
);
10634 " Delay in progress\n");
10636 if (bgp
->update_delay_over
) {
10638 " First neighbor established: %s\n",
10639 bgp
->update_delay_begin_time
);
10641 " Best-paths resumed: %s\n",
10642 bgp
->update_delay_end_time
);
10644 " zebra update resumed: %s\n",
10645 bgp
->update_delay_zebra_resume_time
);
10647 " peers update resumed: %s\n",
10648 bgp
->update_delay_peers_resume_time
);
10655 if (bgp_maxmed_onstartup_configured(bgp
)
10656 && bgp
->maxmed_active
)
10657 json_object_boolean_true_add(
10658 json
, "maxMedOnStartup");
10659 if (bgp
->v_maxmed_admin
)
10660 json_object_boolean_true_add(
10661 json
, "maxMedAdministrative");
10663 json_object_int_add(
10664 json
, "tableVersion",
10665 bgp_table_version(bgp
->rib
[afi
][safi
]));
10667 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10668 json_object_int_add(json
, "ribCount", ents
);
10669 json_object_int_add(
10671 ents
* sizeof(struct bgp_dest
));
10673 ents
= bgp
->af_peer_count
[afi
][safi
];
10674 json_object_int_add(json
, "peerCount", ents
);
10675 json_object_int_add(json
, "peerMemory",
10676 ents
* sizeof(struct peer
));
10678 if ((ents
= listcount(bgp
->group
))) {
10679 json_object_int_add(
10680 json
, "peerGroupCount", ents
);
10681 json_object_int_add(
10682 json
, "peerGroupMemory",
10683 ents
* sizeof(struct
10687 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10688 BGP_CONFIG_DAMPENING
))
10689 json_object_boolean_true_add(
10690 json
, "dampeningEnabled");
10692 if (bgp_maxmed_onstartup_configured(bgp
)
10693 && bgp
->maxmed_active
)
10695 "Max-med on-startup active\n");
10696 if (bgp
->v_maxmed_admin
)
10698 "Max-med administrative active\n");
10700 vty_out(vty
, "BGP table version %" PRIu64
"\n",
10701 bgp_table_version(bgp
->rib
[afi
][safi
]));
10703 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10705 "RIB entries %ld, using %s of memory\n",
10708 memstrbuf
, sizeof(memstrbuf
),
10713 /* Peer related usage */
10714 ents
= bgp
->af_peer_count
[afi
][safi
];
10715 vty_out(vty
, "Peers %ld, using %s of memory\n",
10718 memstrbuf
, sizeof(memstrbuf
),
10719 ents
* sizeof(struct peer
)));
10721 if ((ents
= listcount(bgp
->group
)))
10723 "Peer groups %ld, using %s of memory\n",
10728 ents
* sizeof(struct
10731 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10732 BGP_CONFIG_DAMPENING
))
10733 vty_out(vty
, "Dampening enabled.\n");
10734 vty_out(vty
, "\n");
10736 /* Subtract 8 here because 'Neighbor' is
10738 vty_out(vty
, "Neighbor");
10739 vty_out(vty
, "%*s", max_neighbor_width
- 8,
10742 vty_out(vty
, "EstdCnt DropCnt ResetTime Reason\n");
10745 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt\n");
10749 paf
= peer_af_find(peer
, afi
, safi
);
10750 filter
= &peer
->filter
[afi
][safi
];
10753 /* Works for both failed & successful cases */
10754 if (peer_dynamic_neighbor(peer
))
10761 bgp_has_peer_failed(peer
, afi
, safi
)) {
10762 json_peer
= json_object_new_object();
10763 bgp_show_failed_summary(vty
, bgp
, peer
,
10764 json_peer
, 0, use_json
);
10765 } else if (!show_failed
) {
10766 if (show_established
10767 && bgp_has_peer_failed(peer
, afi
, safi
))
10770 json_peer
= json_object_new_object();
10771 if (peer_dynamic_neighbor(peer
)) {
10772 json_object_boolean_true_add(json_peer
,
10776 if (peer
->hostname
)
10777 json_object_string_add(json_peer
, "hostname",
10780 if (peer
->domainname
)
10781 json_object_string_add(json_peer
, "domainname",
10784 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
10785 json_object_int_add(json_peer
, "version", 4);
10786 json_object_int_add(json_peer
, "msgRcvd",
10787 PEER_TOTAL_RX(peer
));
10788 json_object_int_add(json_peer
, "msgSent",
10789 PEER_TOTAL_TX(peer
));
10791 atomic_size_t outq_count
, inq_count
;
10792 outq_count
= atomic_load_explicit(
10793 &peer
->obuf
->count
,
10794 memory_order_relaxed
);
10795 inq_count
= atomic_load_explicit(
10796 &peer
->ibuf
->count
,
10797 memory_order_relaxed
);
10799 json_object_int_add(json_peer
, "tableVersion",
10800 peer
->version
[afi
][safi
]);
10801 json_object_int_add(json_peer
, "outq",
10803 json_object_int_add(json_peer
, "inq",
10805 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10806 use_json
, json_peer
);
10808 json_object_int_add(json_peer
, "pfxRcd",
10809 peer
->pcount
[afi
][pfx_rcd_safi
]);
10811 if (paf
&& PAF_SUBGRP(paf
))
10812 json_object_int_add(
10813 json_peer
, "pfxSnt",
10814 (PAF_SUBGRP(paf
))->scount
);
10816 json_object_int_add(json_peer
, "pfxSnt",
10819 /* BGP FSM state */
10820 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10821 || CHECK_FLAG(peer
->bgp
->flags
,
10822 BGP_FLAG_SHUTDOWN
))
10823 json_object_string_add(json_peer
,
10826 else if (peer
->afc_recv
[afi
][safi
])
10827 json_object_string_add(
10828 json_peer
, "state",
10829 lookup_msg(bgp_status_msg
,
10830 peer
->status
, NULL
));
10831 else if (CHECK_FLAG(
10833 PEER_STATUS_PREFIX_OVERFLOW
))
10834 json_object_string_add(json_peer
,
10838 json_object_string_add(
10839 json_peer
, "state",
10840 lookup_msg(bgp_status_msg
,
10841 peer
->status
, NULL
));
10843 /* BGP peer state */
10844 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10845 || CHECK_FLAG(peer
->bgp
->flags
,
10846 BGP_FLAG_SHUTDOWN
))
10847 json_object_string_add(json_peer
,
10850 else if (CHECK_FLAG(
10852 PEER_STATUS_PREFIX_OVERFLOW
))
10853 json_object_string_add(json_peer
,
10856 else if (CHECK_FLAG(peer
->flags
,
10857 PEER_FLAG_PASSIVE
))
10858 json_object_string_add(json_peer
,
10861 else if (CHECK_FLAG(peer
->sflags
,
10862 PEER_STATUS_NSF_WAIT
))
10863 json_object_string_add(json_peer
,
10866 else if (CHECK_FLAG(
10868 BGP_FLAG_EBGP_REQUIRES_POLICY
)
10869 && (!bgp_inbound_policy_exists(peer
,
10871 || !bgp_outbound_policy_exists(
10873 json_object_string_add(json_peer
,
10877 json_object_string_add(
10878 json_peer
, "peerState", "OK");
10880 json_object_int_add(json_peer
, "connectionsEstablished",
10881 peer
->established
);
10882 json_object_int_add(json_peer
, "connectionsDropped",
10885 /* Avoid creating empty peer dicts in JSON */
10886 if (json_peer
== NULL
)
10890 json_object_string_add(json_peer
, "idType",
10892 else if (peer
->su
.sa
.sa_family
== AF_INET
)
10893 json_object_string_add(json_peer
, "idType",
10895 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
10896 json_object_string_add(json_peer
, "idType",
10898 json_object_object_add(json_peers
, peer
->host
,
10902 bgp_has_peer_failed(peer
, afi
, safi
)) {
10903 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
10904 max_neighbor_width
,
10906 } else if (!show_failed
) {
10907 if (show_established
10908 && bgp_has_peer_failed(peer
, afi
, safi
))
10911 memset(dn_flag
, '\0', sizeof(dn_flag
));
10912 if (peer_dynamic_neighbor(peer
)) {
10917 && CHECK_FLAG(bgp
->flags
,
10918 BGP_FLAG_SHOW_HOSTNAME
))
10919 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10923 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10925 /* pad the neighbor column with spaces */
10926 if (len
< max_neighbor_width
)
10927 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10930 atomic_size_t outq_count
, inq_count
;
10931 outq_count
= atomic_load_explicit(
10932 &peer
->obuf
->count
,
10933 memory_order_relaxed
);
10934 inq_count
= atomic_load_explicit(
10935 &peer
->ibuf
->count
,
10936 memory_order_relaxed
);
10939 "4 %10u %9u %9u %8" PRIu64
" %4zu %4zu %8s",
10940 peer
->as
, PEER_TOTAL_RX(peer
),
10941 PEER_TOTAL_TX(peer
),
10942 peer
->version
[afi
][safi
], inq_count
,
10944 peer_uptime(peer
->uptime
, timebuf
,
10945 BGP_UPTIME_LEN
, 0, NULL
));
10947 if (peer
->status
== Established
) {
10948 if (peer
->afc_recv
[afi
][safi
]) {
10951 BGP_FLAG_EBGP_REQUIRES_POLICY
)
10952 && !bgp_inbound_policy_exists(
10954 vty_out(vty
, " %12s",
10963 vty_out(vty
, " NoNeg");
10966 if (paf
&& PAF_SUBGRP(paf
)) {
10969 BGP_FLAG_EBGP_REQUIRES_POLICY
)
10970 && !bgp_outbound_policy_exists(
10972 vty_out(vty
, " %8s",
10982 if (CHECK_FLAG(peer
->flags
,
10983 PEER_FLAG_SHUTDOWN
)
10984 || CHECK_FLAG(peer
->bgp
->flags
,
10985 BGP_FLAG_SHUTDOWN
))
10986 vty_out(vty
, " Idle (Admin)");
10987 else if (CHECK_FLAG(
10989 PEER_STATUS_PREFIX_OVERFLOW
))
10990 vty_out(vty
, " Idle (PfxCt)");
10992 vty_out(vty
, " %12s",
10993 lookup_msg(bgp_status_msg
,
10994 peer
->status
, NULL
));
10996 vty_out(vty
, " %8u", 0);
10998 vty_out(vty
, "\n");
11005 json_object_object_add(json
, "peers", json_peers
);
11006 json_object_int_add(json
, "failedPeers", failed_count
);
11007 json_object_int_add(json
, "totalPeers", count
);
11008 json_object_int_add(json
, "dynamicPeers", dn_count
);
11011 bgp_show_bestpath_json(bgp
, json
);
11013 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11014 json
, JSON_C_TO_STRING_PRETTY
));
11015 json_object_free(json
);
11018 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
11020 vty_out(vty
, "No %s neighbor is configured\n",
11021 get_afi_safi_str(afi
, safi
, false));
11025 vty_out(vty
, "* - dynamic neighbor\n");
11026 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11027 dn_count
, bgp
->dynamic_neighbors_limit
);
11031 return CMD_SUCCESS
;
11034 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11035 int safi
, bool show_failed
,
11036 bool show_established
, bool use_json
)
11039 int afi_wildcard
= (afi
== AFI_MAX
);
11040 int safi_wildcard
= (safi
== SAFI_MAX
);
11041 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11042 bool nbr_output
= false;
11044 if (use_json
&& is_wildcard
)
11045 vty_out(vty
, "{\n");
11047 afi
= 1; /* AFI_IP */
11048 while (afi
< AFI_MAX
) {
11050 safi
= 1; /* SAFI_UNICAST */
11051 while (safi
< SAFI_MAX
) {
11052 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11057 * So limit output to those afi/safi
11059 * actualy have something interesting in
11064 vty_out(vty
, ",\n");
11068 vty_out(vty
, "\"%s\":",
11069 get_afi_safi_str(afi
,
11073 vty_out(vty
, "\n%s Summary:\n",
11074 get_afi_safi_str(afi
,
11079 bgp_show_summary(vty
, bgp
, afi
, safi
,
11080 show_failed
, show_established
,
11084 if (!safi_wildcard
)
11092 if (use_json
&& is_wildcard
)
11093 vty_out(vty
, "}\n");
11094 else if (!nbr_output
) {
11096 vty_out(vty
, "{}\n");
11098 vty_out(vty
, "%% No BGP neighbors found\n");
11102 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11103 safi_t safi
, bool show_failed
,
11104 bool show_established
,
11107 struct listnode
*node
, *nnode
;
11110 bool nbr_output
= false;
11113 vty_out(vty
, "{\n");
11115 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11119 vty_out(vty
, ",\n");
11123 vty_out(vty
, "\"%s\":",
11124 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11128 vty_out(vty
, "\nInstance %s:\n",
11129 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11133 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
11134 show_established
, use_json
);
11138 vty_out(vty
, "}\n");
11139 else if (!nbr_output
)
11140 vty_out(vty
, "%% BGP instance not found\n");
11143 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11144 safi_t safi
, bool show_failed
, bool show_established
,
11150 if (strmatch(name
, "all")) {
11151 bgp_show_all_instances_summary_vty(
11152 vty
, afi
, safi
, show_failed
, show_established
,
11154 return CMD_SUCCESS
;
11156 bgp
= bgp_lookup_by_name(name
);
11160 vty_out(vty
, "{}\n");
11163 "%% BGP instance not found\n");
11164 return CMD_WARNING
;
11167 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
,
11168 show_failed
, show_established
,
11170 return CMD_SUCCESS
;
11174 bgp
= bgp_get_default();
11177 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
11178 show_established
, use_json
);
11181 vty_out(vty
, "{}\n");
11183 vty_out(vty
, "%% BGP instance not found\n");
11184 return CMD_WARNING
;
11187 return CMD_SUCCESS
;
11190 /* `show [ip] bgp summary' commands. */
11191 DEFPY (show_ip_bgp_summary
,
11192 show_ip_bgp_summary_cmd
,
11193 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] [all$all] summary [established|failed] [json$uj]",
11197 BGP_INSTANCE_HELP_STR
11199 BGP_SAFI_WITH_LABEL_HELP_STR
11200 "Display the entries for all address families\n"
11201 "Summary of BGP neighbor status\n"
11202 "Show only sessions in Established state\n"
11203 "Show only sessions not in Established state\n"
11207 afi_t afi
= AFI_MAX
;
11208 safi_t safi
= SAFI_MAX
;
11209 bool show_failed
= false;
11210 bool show_established
= false;
11214 /* show [ip] bgp */
11215 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11217 /* [<vrf> VIEWVRFNAME] */
11218 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11219 vrf
= argv
[idx
+ 1]->arg
;
11220 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11222 } else if (argv_find(argv
, argc
, "view", &idx
))
11223 /* [<view> VIEWVRFNAME] */
11224 vrf
= argv
[idx
+ 1]->arg
;
11225 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11226 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11227 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11230 if (argv_find(argv
, argc
, "failed", &idx
))
11231 show_failed
= true;
11232 if (argv_find(argv
, argc
, "established", &idx
))
11233 show_established
= true;
11235 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, show_failed
,
11236 show_established
, uj
);
11239 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11242 return get_afi_safi_json_str(afi
, safi
);
11244 return get_afi_safi_vty_str(afi
, safi
);
11248 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11249 afi_t afi
, safi_t safi
,
11250 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11251 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11252 bool use_json
, json_object
*json_pref
)
11255 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11256 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11258 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11259 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11260 json_object_string_add(json_pref
, "sendMode",
11261 "advertisedAndReceived");
11262 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11263 json_object_string_add(json_pref
, "sendMode",
11265 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11266 json_object_string_add(json_pref
, "sendMode",
11269 vty_out(vty
, " Send-mode: ");
11270 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11271 vty_out(vty
, "advertised");
11272 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11273 vty_out(vty
, "%sreceived",
11274 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11278 vty_out(vty
, "\n");
11283 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11284 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11286 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11287 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11288 json_object_string_add(json_pref
, "recvMode",
11289 "advertisedAndReceived");
11290 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11291 json_object_string_add(json_pref
, "recvMode",
11293 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11294 json_object_string_add(json_pref
, "recvMode",
11297 vty_out(vty
, " Receive-mode: ");
11298 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11299 vty_out(vty
, "advertised");
11300 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11301 vty_out(vty
, "%sreceived",
11302 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11306 vty_out(vty
, "\n");
11311 static void bgp_show_neighnor_graceful_restart_rbit(struct vty
*vty
,
11316 bool rbit_status
= false;
11319 vty_out(vty
, "\n R bit: ");
11321 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11322 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11323 && (p
->status
== Established
)) {
11325 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_BIT_RCV
))
11326 rbit_status
= true;
11328 rbit_status
= false;
11333 json_object_boolean_true_add(json
, "rBit");
11335 vty_out(vty
, "True\n");
11338 json_object_boolean_false_add(json
, "rBit");
11340 vty_out(vty
, "False\n");
11344 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11349 const char *mode
= "NotApplicable";
11352 vty_out(vty
, "\n Remote GR Mode: ");
11354 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11355 && (peer
->status
== Established
)) {
11357 if ((peer
->nsf_af_count
== 0)
11358 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11362 } else if (peer
->nsf_af_count
== 0
11363 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11367 } else if (peer
->nsf_af_count
!= 0
11368 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11375 json_object_string_add(json
, "remoteGrMode", mode
);
11377 vty_out(vty
, mode
, "\n");
11380 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11385 const char *mode
= "Invalid";
11388 vty_out(vty
, " Local GR Mode: ");
11390 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11392 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11394 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11396 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11397 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11399 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11401 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11408 json_object_string_add(json
, "localGrMode", mode
);
11410 vty_out(vty
, mode
, "\n");
11414 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11415 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11419 json_object
*json_afi_safi
= NULL
;
11420 json_object
*json_timer
= NULL
;
11421 json_object
*json_endofrib_status
= NULL
;
11422 bool eor_flag
= false;
11424 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11425 for (safi
= SAFI_UNICAST
; safi
<= SAFI_MPLS_VPN
; safi
++) {
11426 if (!peer
->afc
[afi
][safi
])
11429 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11430 || !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11434 json_afi_safi
= json_object_new_object();
11435 json_endofrib_status
= json_object_new_object();
11436 json_timer
= json_object_new_object();
11439 if (peer
->eor_stime
[afi
][safi
]
11440 >= peer
->pkt_stime
[afi
][safi
])
11446 vty_out(vty
, " %s:\n",
11447 get_afi_safi_str(afi
, safi
, false));
11449 vty_out(vty
, " F bit: ");
11452 if (peer
->nsf
[afi
][safi
]
11453 && CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11454 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11457 json_object_boolean_true_add(
11458 json_afi_safi
, "fBit");
11460 vty_out(vty
, "True\n");
11463 json_object_boolean_false_add(
11464 json_afi_safi
, "fBit");
11466 vty_out(vty
, "False\n");
11470 vty_out(vty
, " End-of-RIB sent: ");
11472 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11473 PEER_STATUS_EOR_SEND
)) {
11475 json_object_boolean_true_add(
11476 json_endofrib_status
,
11479 PRINT_EOR_JSON(eor_flag
);
11481 vty_out(vty
, "Yes\n");
11483 " End-of-RIB sent after update: ");
11485 PRINT_EOR(eor_flag
);
11489 json_object_boolean_false_add(
11490 json_endofrib_status
,
11492 json_object_boolean_false_add(
11493 json_endofrib_status
,
11494 "endOfRibSentAfterUpdate");
11496 vty_out(vty
, "No\n");
11498 " End-of-RIB sent after update: ");
11499 vty_out(vty
, "No\n");
11504 vty_out(vty
, " End-of-RIB received: ");
11506 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11507 PEER_STATUS_EOR_RECEIVED
)) {
11509 json_object_boolean_true_add(
11510 json_endofrib_status
,
11513 vty_out(vty
, "Yes\n");
11516 json_object_boolean_false_add(
11517 json_endofrib_status
,
11520 vty_out(vty
, "No\n");
11524 json_object_int_add(json_timer
,
11526 peer
->bgp
->stalepath_time
);
11528 if (peer
->t_gr_stale
!= NULL
) {
11529 json_object_int_add(
11531 "stalePathTimerRemaining",
11532 thread_timer_remain_second(
11533 peer
->t_gr_stale
));
11536 /* Display Configured Selection
11537 * Deferral only when when
11538 * Gr mode is enabled.
11540 if (CHECK_FLAG(peer
->flags
,
11541 PEER_FLAG_GRACEFUL_RESTART
)) {
11542 json_object_int_add(
11544 "selectionDeferralTimer",
11545 peer
->bgp
->stalepath_time
);
11548 if (peer
->bgp
->gr_info
[afi
][safi
]
11552 json_object_int_add(
11554 "selectionDeferralTimerRemaining",
11555 thread_timer_remain_second(
11559 .t_select_deferral
));
11562 vty_out(vty
, " Timers:\n");
11564 " Configured Stale Path Time(sec): %u\n",
11565 peer
->bgp
->stalepath_time
);
11567 if (peer
->t_gr_stale
!= NULL
)
11569 " Stale Path Remaining(sec): %ld\n",
11570 thread_timer_remain_second(
11571 peer
->t_gr_stale
));
11572 /* Display Configured Selection
11573 * Deferral only when when
11574 * Gr mode is enabled.
11576 if (CHECK_FLAG(peer
->flags
,
11577 PEER_FLAG_GRACEFUL_RESTART
))
11579 " Configured Selection Deferral Time(sec): %u\n",
11580 peer
->bgp
->select_defer_time
);
11582 if (peer
->bgp
->gr_info
[afi
][safi
]
11586 " Selection Deferral Time Remaining(sec): %ld\n",
11587 thread_timer_remain_second(
11591 .t_select_deferral
));
11594 json_object_object_add(json_afi_safi
,
11596 json_endofrib_status
);
11597 json_object_object_add(json_afi_safi
, "timers",
11599 json_object_object_add(
11600 json
, get_afi_safi_str(afi
, safi
, true),
11607 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
11613 json_object
*json_timer
= NULL
;
11615 json_timer
= json_object_new_object();
11617 json_object_int_add(json_timer
, "configuredRestartTimer",
11618 p
->bgp
->restart_time
);
11620 json_object_int_add(json_timer
, "receivedRestartTimer",
11623 if (p
->t_gr_restart
!= NULL
)
11624 json_object_int_add(
11625 json_timer
, "restartTimerRemaining",
11626 thread_timer_remain_second(p
->t_gr_restart
));
11628 json_object_object_add(json
, "timers", json_timer
);
11631 vty_out(vty
, " Timers:\n");
11632 vty_out(vty
, " Configured Restart Time(sec): %u\n",
11633 p
->bgp
->restart_time
);
11635 vty_out(vty
, " Received Restart Time(sec): %u\n",
11637 if (p
->t_gr_restart
!= NULL
)
11638 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11639 thread_timer_remain_second(p
->t_gr_restart
));
11640 if (p
->t_gr_restart
!= NULL
) {
11641 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11642 thread_timer_remain_second(p
->t_gr_restart
));
11647 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
11648 bool use_json
, json_object
*json
)
11650 char buf
[SU_ADDRSTRLEN
] = {0};
11651 char dn_flag
[2] = {0};
11652 /* '*' + v6 address of neighbor */
11653 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
11655 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11660 json_object_string_add(
11661 json
, "neighborAddr",
11662 BGP_PEER_SU_UNSPEC(p
)
11664 : sockunion2str(&p
->su
, buf
,
11667 vty_out(vty
, "BGP neighbor on %s: %s\n", p
->conf_if
,
11668 BGP_PEER_SU_UNSPEC(p
)
11670 : sockunion2str(&p
->su
, buf
,
11673 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
11677 json_object_string_add(json
, "neighborAddr",
11680 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
11683 /* more gr info in new format */
11684 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
11687 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
11688 safi_t safi
, bool use_json
,
11689 json_object
*json_neigh
)
11691 struct bgp_filter
*filter
;
11692 struct peer_af
*paf
;
11693 char orf_pfx_name
[BUFSIZ
];
11695 json_object
*json_af
= NULL
;
11696 json_object
*json_prefA
= NULL
;
11697 json_object
*json_prefB
= NULL
;
11698 json_object
*json_addr
= NULL
;
11699 json_object
*json_advmap
= NULL
;
11702 json_addr
= json_object_new_object();
11703 json_af
= json_object_new_object();
11704 filter
= &p
->filter
[afi
][safi
];
11706 if (peer_group_active(p
))
11707 json_object_string_add(json_addr
, "peerGroupMember",
11710 paf
= peer_af_find(p
, afi
, safi
);
11711 if (paf
&& PAF_SUBGRP(paf
)) {
11712 json_object_int_add(json_addr
, "updateGroupId",
11713 PAF_UPDGRP(paf
)->id
);
11714 json_object_int_add(json_addr
, "subGroupId",
11715 PAF_SUBGRP(paf
)->id
);
11716 json_object_int_add(json_addr
, "packetQueueLength",
11717 bpacket_queue_virtual_length(paf
));
11720 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11721 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11722 PEER_CAP_ORF_PREFIX_SM_RCV
)
11723 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11724 PEER_CAP_ORF_PREFIX_RM_ADV
)
11725 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11726 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11727 json_object_int_add(json_af
, "orfType",
11729 json_prefA
= json_object_new_object();
11730 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
11731 PEER_CAP_ORF_PREFIX_SM_ADV
,
11732 PEER_CAP_ORF_PREFIX_RM_ADV
,
11733 PEER_CAP_ORF_PREFIX_SM_RCV
,
11734 PEER_CAP_ORF_PREFIX_RM_RCV
,
11735 use_json
, json_prefA
);
11736 json_object_object_add(json_af
, "orfPrefixList",
11740 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11741 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11742 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11743 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11744 PEER_CAP_ORF_PREFIX_RM_ADV
)
11745 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11746 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
11747 json_object_int_add(json_af
, "orfOldType",
11748 ORF_TYPE_PREFIX_OLD
);
11749 json_prefB
= json_object_new_object();
11750 bgp_show_peer_afi_orf_cap(
11751 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
11752 PEER_CAP_ORF_PREFIX_RM_ADV
,
11753 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
11754 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
11756 json_object_object_add(json_af
, "orfOldPrefixList",
11760 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11761 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11762 PEER_CAP_ORF_PREFIX_SM_RCV
)
11763 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11764 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11765 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11766 PEER_CAP_ORF_PREFIX_RM_ADV
)
11767 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11768 PEER_CAP_ORF_PREFIX_RM_RCV
)
11769 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11770 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
11771 json_object_object_add(json_addr
, "afDependentCap",
11774 json_object_free(json_af
);
11776 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
11777 p
->host
, afi
, safi
);
11778 orf_pfx_count
= prefix_bgp_show_prefix_list(
11779 NULL
, afi
, orf_pfx_name
, use_json
);
11781 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11782 PEER_STATUS_ORF_PREFIX_SEND
)
11783 || orf_pfx_count
) {
11784 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11785 PEER_STATUS_ORF_PREFIX_SEND
))
11786 json_object_boolean_true_add(json_neigh
,
11789 json_object_int_add(json_addr
, "orfRecvCounter",
11792 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11793 PEER_STATUS_ORF_WAIT_REFRESH
))
11794 json_object_string_add(
11795 json_addr
, "orfFirstUpdate",
11796 "deferredUntilORFOrRouteRefreshRecvd");
11798 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11799 PEER_FLAG_REFLECTOR_CLIENT
))
11800 json_object_boolean_true_add(json_addr
,
11801 "routeReflectorClient");
11802 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11803 PEER_FLAG_RSERVER_CLIENT
))
11804 json_object_boolean_true_add(json_addr
,
11805 "routeServerClient");
11806 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
11807 json_object_boolean_true_add(json_addr
,
11808 "inboundSoftConfigPermit");
11810 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11811 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
11812 json_object_boolean_true_add(
11814 "privateAsNumsAllReplacedInUpdatesToNbr");
11815 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11816 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
11817 json_object_boolean_true_add(
11819 "privateAsNumsReplacedInUpdatesToNbr");
11820 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11821 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
11822 json_object_boolean_true_add(
11824 "privateAsNumsAllRemovedInUpdatesToNbr");
11825 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11826 PEER_FLAG_REMOVE_PRIVATE_AS
))
11827 json_object_boolean_true_add(
11829 "privateAsNumsRemovedInUpdatesToNbr");
11831 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
11832 json_object_boolean_true_add(
11834 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
11837 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
11838 json_object_string_add(json_addr
,
11839 "overrideASNsInOutboundUpdates",
11840 "ifAspathEqualRemoteAs");
11842 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
11843 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11844 PEER_FLAG_FORCE_NEXTHOP_SELF
))
11845 json_object_boolean_true_add(json_addr
,
11846 "routerAlwaysNextHop");
11847 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11848 PEER_FLAG_AS_PATH_UNCHANGED
))
11849 json_object_boolean_true_add(
11850 json_addr
, "unchangedAsPathPropogatedToNbr");
11851 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11852 PEER_FLAG_NEXTHOP_UNCHANGED
))
11853 json_object_boolean_true_add(
11854 json_addr
, "unchangedNextHopPropogatedToNbr");
11855 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
11856 json_object_boolean_true_add(
11857 json_addr
, "unchangedMedPropogatedToNbr");
11858 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
11859 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11860 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
11861 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11862 PEER_FLAG_SEND_COMMUNITY
)
11863 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
11864 PEER_FLAG_SEND_EXT_COMMUNITY
))
11865 json_object_string_add(json_addr
,
11866 "commAttriSentToNbr",
11867 "extendedAndStandard");
11868 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11869 PEER_FLAG_SEND_EXT_COMMUNITY
))
11870 json_object_string_add(json_addr
,
11871 "commAttriSentToNbr",
11874 json_object_string_add(json_addr
,
11875 "commAttriSentToNbr",
11878 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11879 PEER_FLAG_DEFAULT_ORIGINATE
)) {
11880 if (p
->default_rmap
[afi
][safi
].name
)
11881 json_object_string_add(
11882 json_addr
, "defaultRouteMap",
11883 p
->default_rmap
[afi
][safi
].name
);
11885 if (paf
&& PAF_SUBGRP(paf
)
11886 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
11887 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
11888 json_object_boolean_true_add(json_addr
,
11891 json_object_boolean_true_add(json_addr
,
11895 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
11896 if (is_evpn_enabled())
11897 json_object_boolean_true_add(
11898 json_addr
, "advertiseAllVnis");
11901 if (filter
->plist
[FILTER_IN
].name
11902 || filter
->dlist
[FILTER_IN
].name
11903 || filter
->aslist
[FILTER_IN
].name
11904 || filter
->map
[RMAP_IN
].name
)
11905 json_object_boolean_true_add(json_addr
,
11906 "inboundPathPolicyConfig");
11907 if (filter
->plist
[FILTER_OUT
].name
11908 || filter
->dlist
[FILTER_OUT
].name
11909 || filter
->aslist
[FILTER_OUT
].name
11910 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
11911 json_object_boolean_true_add(
11912 json_addr
, "outboundPathPolicyConfig");
11915 if (filter
->plist
[FILTER_IN
].name
)
11916 json_object_string_add(json_addr
,
11917 "incomingUpdatePrefixFilterList",
11918 filter
->plist
[FILTER_IN
].name
);
11919 if (filter
->plist
[FILTER_OUT
].name
)
11920 json_object_string_add(json_addr
,
11921 "outgoingUpdatePrefixFilterList",
11922 filter
->plist
[FILTER_OUT
].name
);
11924 /* distribute-list */
11925 if (filter
->dlist
[FILTER_IN
].name
)
11926 json_object_string_add(
11927 json_addr
, "incomingUpdateNetworkFilterList",
11928 filter
->dlist
[FILTER_IN
].name
);
11929 if (filter
->dlist
[FILTER_OUT
].name
)
11930 json_object_string_add(
11931 json_addr
, "outgoingUpdateNetworkFilterList",
11932 filter
->dlist
[FILTER_OUT
].name
);
11935 if (filter
->aslist
[FILTER_IN
].name
)
11936 json_object_string_add(json_addr
,
11937 "incomingUpdateAsPathFilterList",
11938 filter
->aslist
[FILTER_IN
].name
);
11939 if (filter
->aslist
[FILTER_OUT
].name
)
11940 json_object_string_add(json_addr
,
11941 "outgoingUpdateAsPathFilterList",
11942 filter
->aslist
[FILTER_OUT
].name
);
11945 if (filter
->map
[RMAP_IN
].name
)
11946 json_object_string_add(
11947 json_addr
, "routeMapForIncomingAdvertisements",
11948 filter
->map
[RMAP_IN
].name
);
11949 if (filter
->map
[RMAP_OUT
].name
)
11950 json_object_string_add(
11951 json_addr
, "routeMapForOutgoingAdvertisements",
11952 filter
->map
[RMAP_OUT
].name
);
11954 /* ebgp-requires-policy (inbound) */
11955 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
11956 && !bgp_inbound_policy_exists(p
, filter
))
11957 json_object_string_add(
11958 json_addr
, "inboundEbgpRequiresPolicy",
11959 "Inbound updates discarded due to missing policy");
11961 /* ebgp-requires-policy (outbound) */
11962 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
11963 && (!bgp_outbound_policy_exists(p
, filter
)))
11964 json_object_string_add(
11965 json_addr
, "outboundEbgpRequiresPolicy",
11966 "Outbound updates discarded due to missing policy");
11968 /* unsuppress-map */
11969 if (filter
->usmap
.name
)
11970 json_object_string_add(json_addr
,
11971 "selectiveUnsuppressRouteMap",
11972 filter
->usmap
.name
);
11974 /* advertise-map */
11975 if (filter
->advmap
.aname
) {
11976 json_advmap
= json_object_new_object();
11977 json_object_string_add(json_advmap
, "condition",
11978 filter
->advmap
.condition
11981 json_object_string_add(json_advmap
, "conditionMap",
11982 filter
->advmap
.cname
);
11983 json_object_string_add(json_advmap
, "advertiseMap",
11984 filter
->advmap
.aname
);
11985 json_object_string_add(json_advmap
, "advertiseStatus",
11986 filter
->advmap
.update_type
11990 json_object_object_add(json_addr
, "advertiseMap",
11994 /* Receive prefix count */
11995 json_object_int_add(json_addr
, "acceptedPrefixCounter",
11996 p
->pcount
[afi
][safi
]);
11997 if (paf
&& PAF_SUBGRP(paf
))
11998 json_object_int_add(json_addr
, "sentPrefixCounter",
11999 (PAF_SUBGRP(paf
))->scount
);
12001 /* Maximum prefix */
12002 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12003 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12004 p
->pmax_out
[afi
][safi
]);
12006 /* Maximum prefix */
12007 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12008 json_object_int_add(json_addr
, "prefixAllowedMax",
12009 p
->pmax
[afi
][safi
]);
12010 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12011 PEER_FLAG_MAX_PREFIX_WARNING
))
12012 json_object_boolean_true_add(
12013 json_addr
, "prefixAllowedMaxWarning");
12014 json_object_int_add(json_addr
,
12015 "prefixAllowedWarningThresh",
12016 p
->pmax_threshold
[afi
][safi
]);
12017 if (p
->pmax_restart
[afi
][safi
])
12018 json_object_int_add(
12020 "prefixAllowedRestartIntervalMsecs",
12021 p
->pmax_restart
[afi
][safi
] * 60000);
12023 json_object_object_add(json_neigh
,
12024 get_afi_safi_str(afi
, safi
, true),
12028 filter
= &p
->filter
[afi
][safi
];
12030 vty_out(vty
, " For address family: %s\n",
12031 get_afi_safi_str(afi
, safi
, false));
12033 if (peer_group_active(p
))
12034 vty_out(vty
, " %s peer-group member\n",
12037 paf
= peer_af_find(p
, afi
, safi
);
12038 if (paf
&& PAF_SUBGRP(paf
)) {
12039 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12040 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12041 vty_out(vty
, " Packet Queue length %d\n",
12042 bpacket_queue_virtual_length(paf
));
12044 vty_out(vty
, " Not part of any update group\n");
12046 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12047 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12048 PEER_CAP_ORF_PREFIX_SM_RCV
)
12049 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12050 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12051 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12052 PEER_CAP_ORF_PREFIX_RM_ADV
)
12053 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12054 PEER_CAP_ORF_PREFIX_RM_RCV
)
12055 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12056 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12057 vty_out(vty
, " AF-dependant capabilities:\n");
12059 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12060 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12061 PEER_CAP_ORF_PREFIX_SM_RCV
)
12062 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12063 PEER_CAP_ORF_PREFIX_RM_ADV
)
12064 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12065 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12067 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12069 bgp_show_peer_afi_orf_cap(
12070 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12071 PEER_CAP_ORF_PREFIX_RM_ADV
,
12072 PEER_CAP_ORF_PREFIX_SM_RCV
,
12073 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12075 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12076 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12077 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12078 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12079 PEER_CAP_ORF_PREFIX_RM_ADV
)
12080 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12081 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12083 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12084 ORF_TYPE_PREFIX_OLD
);
12085 bgp_show_peer_afi_orf_cap(
12086 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12087 PEER_CAP_ORF_PREFIX_RM_ADV
,
12088 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12089 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12092 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12093 p
->host
, afi
, safi
);
12094 orf_pfx_count
= prefix_bgp_show_prefix_list(
12095 NULL
, afi
, orf_pfx_name
, use_json
);
12097 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12098 PEER_STATUS_ORF_PREFIX_SEND
)
12099 || orf_pfx_count
) {
12100 vty_out(vty
, " Outbound Route Filter (ORF):");
12101 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12102 PEER_STATUS_ORF_PREFIX_SEND
))
12103 vty_out(vty
, " sent;");
12105 vty_out(vty
, " received (%d entries)",
12107 vty_out(vty
, "\n");
12109 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12110 PEER_STATUS_ORF_WAIT_REFRESH
))
12112 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12114 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12115 PEER_FLAG_REFLECTOR_CLIENT
))
12116 vty_out(vty
, " Route-Reflector Client\n");
12117 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12118 PEER_FLAG_RSERVER_CLIENT
))
12119 vty_out(vty
, " Route-Server Client\n");
12120 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12122 " Inbound soft reconfiguration allowed\n");
12124 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12125 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12127 " Private AS numbers (all) replaced in updates to this neighbor\n");
12128 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12129 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12131 " Private AS numbers replaced in updates to this neighbor\n");
12132 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12133 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12135 " Private AS numbers (all) removed in updates to this neighbor\n");
12136 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12137 PEER_FLAG_REMOVE_PRIVATE_AS
))
12139 " Private AS numbers removed in updates to this neighbor\n");
12141 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12142 vty_out(vty
, " %s\n",
12143 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12144 ->human_description
);
12146 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12148 " Override ASNs in outbound updates if aspath equals remote-as\n");
12150 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12151 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12152 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12153 vty_out(vty
, " NEXT_HOP is always this router\n");
12154 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12155 PEER_FLAG_AS_PATH_UNCHANGED
))
12157 " AS_PATH is propagated unchanged to this neighbor\n");
12158 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12159 PEER_FLAG_NEXTHOP_UNCHANGED
))
12161 " NEXT_HOP is propagated unchanged to this neighbor\n");
12162 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12164 " MED is propagated unchanged to this neighbor\n");
12165 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12166 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12167 PEER_FLAG_SEND_EXT_COMMUNITY
)
12168 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12169 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12171 " Community attribute sent to this neighbor");
12172 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12173 PEER_FLAG_SEND_COMMUNITY
)
12174 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12175 PEER_FLAG_SEND_EXT_COMMUNITY
)
12176 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12177 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12178 vty_out(vty
, "(all)\n");
12179 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12180 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12181 vty_out(vty
, "(large)\n");
12182 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12183 PEER_FLAG_SEND_EXT_COMMUNITY
))
12184 vty_out(vty
, "(extended)\n");
12186 vty_out(vty
, "(standard)\n");
12188 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12189 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12190 vty_out(vty
, " Default information originate,");
12192 if (p
->default_rmap
[afi
][safi
].name
)
12193 vty_out(vty
, " default route-map %s%s,",
12194 p
->default_rmap
[afi
][safi
].map
? "*"
12196 p
->default_rmap
[afi
][safi
].name
);
12197 if (paf
&& PAF_SUBGRP(paf
)
12198 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12199 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12200 vty_out(vty
, " default sent\n");
12202 vty_out(vty
, " default not sent\n");
12205 /* advertise-vni-all */
12206 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12207 if (is_evpn_enabled())
12208 vty_out(vty
, " advertise-all-vni\n");
12211 if (filter
->plist
[FILTER_IN
].name
12212 || filter
->dlist
[FILTER_IN
].name
12213 || filter
->aslist
[FILTER_IN
].name
12214 || filter
->map
[RMAP_IN
].name
)
12215 vty_out(vty
, " Inbound path policy configured\n");
12216 if (filter
->plist
[FILTER_OUT
].name
12217 || filter
->dlist
[FILTER_OUT
].name
12218 || filter
->aslist
[FILTER_OUT
].name
12219 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12220 vty_out(vty
, " Outbound path policy configured\n");
12223 if (filter
->plist
[FILTER_IN
].name
)
12225 " Incoming update prefix filter list is %s%s\n",
12226 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12227 filter
->plist
[FILTER_IN
].name
);
12228 if (filter
->plist
[FILTER_OUT
].name
)
12230 " Outgoing update prefix filter list is %s%s\n",
12231 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12232 filter
->plist
[FILTER_OUT
].name
);
12234 /* distribute-list */
12235 if (filter
->dlist
[FILTER_IN
].name
)
12237 " Incoming update network filter list is %s%s\n",
12238 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12239 filter
->dlist
[FILTER_IN
].name
);
12240 if (filter
->dlist
[FILTER_OUT
].name
)
12242 " Outgoing update network filter list is %s%s\n",
12243 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12244 filter
->dlist
[FILTER_OUT
].name
);
12247 if (filter
->aslist
[FILTER_IN
].name
)
12249 " Incoming update AS path filter list is %s%s\n",
12250 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12251 filter
->aslist
[FILTER_IN
].name
);
12252 if (filter
->aslist
[FILTER_OUT
].name
)
12254 " Outgoing update AS path filter list is %s%s\n",
12255 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12256 filter
->aslist
[FILTER_OUT
].name
);
12259 if (filter
->map
[RMAP_IN
].name
)
12261 " Route map for incoming advertisements is %s%s\n",
12262 filter
->map
[RMAP_IN
].map
? "*" : "",
12263 filter
->map
[RMAP_IN
].name
);
12264 if (filter
->map
[RMAP_OUT
].name
)
12266 " Route map for outgoing advertisements is %s%s\n",
12267 filter
->map
[RMAP_OUT
].map
? "*" : "",
12268 filter
->map
[RMAP_OUT
].name
);
12270 /* ebgp-requires-policy (inbound) */
12271 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12272 && !bgp_inbound_policy_exists(p
, filter
))
12274 " Inbound updates discarded due to missing policy\n");
12276 /* ebgp-requires-policy (outbound) */
12277 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12278 && !bgp_outbound_policy_exists(p
, filter
))
12280 " Outbound updates discarded due to missing policy\n");
12282 /* unsuppress-map */
12283 if (filter
->usmap
.name
)
12285 " Route map for selective unsuppress is %s%s\n",
12286 filter
->usmap
.map
? "*" : "",
12287 filter
->usmap
.name
);
12289 /* advertise-map */
12290 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12292 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12293 filter
->advmap
.condition
? "EXIST"
12295 filter
->advmap
.cmap
? "*" : "",
12296 filter
->advmap
.cname
,
12297 filter
->advmap
.amap
? "*" : "",
12298 filter
->advmap
.aname
,
12299 filter
->advmap
.update_type
== ADVERTISE
12303 /* Receive prefix count */
12304 vty_out(vty
, " %u accepted prefixes\n",
12305 p
->pcount
[afi
][safi
]);
12307 /* maximum-prefix-out */
12308 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12309 PEER_FLAG_MAX_PREFIX_OUT
))
12311 " Maximum allowed prefixes sent %u\n",
12312 p
->pmax_out
[afi
][safi
]);
12314 /* Maximum prefix */
12315 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12317 " Maximum prefixes allowed %u%s\n",
12318 p
->pmax
[afi
][safi
],
12319 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12320 PEER_FLAG_MAX_PREFIX_WARNING
)
12321 ? " (warning-only)"
12323 vty_out(vty
, " Threshold for warning message %d%%",
12324 p
->pmax_threshold
[afi
][safi
]);
12325 if (p
->pmax_restart
[afi
][safi
])
12326 vty_out(vty
, ", restart interval %d min",
12327 p
->pmax_restart
[afi
][safi
]);
12328 vty_out(vty
, "\n");
12331 vty_out(vty
, "\n");
12335 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12339 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
12340 char timebuf
[BGP_UPTIME_LEN
];
12346 json_object
*json_neigh
= NULL
;
12352 json_neigh
= json_object_new_object();
12354 memset(dn_flag
, '\0', sizeof(dn_flag
));
12355 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12359 if (p
->conf_if
) /* Configured interface name. */
12360 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
12361 BGP_PEER_SU_UNSPEC(p
)
12363 : sockunion2str(&p
->su
, buf
,
12365 else /* Configured IP address. */
12366 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12371 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12372 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12374 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12375 json_object_string_add(
12376 json_neigh
, "bgpNeighborAddr",
12377 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
12379 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12381 if (p
->change_local_as
)
12382 json_object_int_add(json_neigh
, "localAs",
12383 p
->change_local_as
);
12385 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12387 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12388 json_object_boolean_true_add(json_neigh
,
12389 "localAsNoPrepend");
12391 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12392 json_object_boolean_true_add(json_neigh
,
12393 "localAsReplaceAs");
12395 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12396 || (p
->as_type
== AS_INTERNAL
))
12397 vty_out(vty
, "remote AS %u, ", p
->as
);
12399 vty_out(vty
, "remote AS Unspecified, ");
12400 vty_out(vty
, "local AS %u%s%s, ",
12401 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12402 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12405 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12409 /* peer type internal or confed-internal */
12410 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12412 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12413 json_object_boolean_true_add(
12414 json_neigh
, "nbrConfedInternalLink");
12416 json_object_boolean_true_add(json_neigh
,
12417 "nbrInternalLink");
12419 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12420 vty_out(vty
, "confed-internal link\n");
12422 vty_out(vty
, "internal link\n");
12424 /* peer type external or confed-external */
12425 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12427 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12428 json_object_boolean_true_add(
12429 json_neigh
, "nbrConfedExternalLink");
12431 json_object_boolean_true_add(json_neigh
,
12432 "nbrExternalLink");
12434 if (bgp_confederation_peers_check(bgp
, p
->as
))
12435 vty_out(vty
, "confed-external link\n");
12437 vty_out(vty
, "external link\n");
12441 json_object_boolean_true_add(json_neigh
,
12442 "nbrUnspecifiedLink");
12444 vty_out(vty
, "unspecified link\n");
12450 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12452 vty_out(vty
, " Description: %s\n", p
->desc
);
12458 json_object_string_add(json_neigh
, "hostname",
12462 json_object_string_add(json_neigh
, "domainname",
12465 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12466 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12469 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12476 json_object_string_add(json_neigh
, "peerGroup",
12480 struct prefix prefix
, *range
= NULL
;
12482 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12483 range
= peer_group_lookup_dynamic_neighbor_range(
12484 p
->group
, &prefix
);
12487 prefix2str(range
, buf1
, sizeof(buf1
));
12488 json_object_string_add(
12490 "peerSubnetRangeGroup", buf1
);
12495 " Member of peer-group %s for session parameters\n",
12499 struct prefix prefix
, *range
= NULL
;
12501 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12502 range
= peer_group_lookup_dynamic_neighbor_range(
12503 p
->group
, &prefix
);
12507 " Belongs to the subnet range group: %pFX\n",
12515 /* Administrative shutdown. */
12516 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12517 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12518 json_object_boolean_true_add(json_neigh
,
12522 json_object_int_add(json_neigh
, "bgpVersion", 4);
12523 json_object_string_add(
12524 json_neigh
, "remoteRouterId",
12525 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12526 json_object_string_add(
12527 json_neigh
, "localRouterId",
12528 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12531 /* Confederation */
12532 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12533 && bgp_confederation_peers_check(bgp
, p
->as
))
12534 json_object_boolean_true_add(json_neigh
,
12538 json_object_string_add(
12539 json_neigh
, "bgpState",
12540 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12542 if (p
->status
== Established
) {
12545 uptime
= bgp_clock();
12546 uptime
-= p
->uptime
;
12547 epoch_tbuf
= time(NULL
) - uptime
;
12549 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
12551 json_object_string_add(json_neigh
, "bgpTimerUpString",
12552 peer_uptime(p
->uptime
, timebuf
,
12555 json_object_int_add(json_neigh
,
12556 "bgpTimerUpEstablishedEpoch",
12560 else if (p
->status
== Active
) {
12561 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12562 json_object_string_add(json_neigh
, "bgpStateIs",
12564 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12565 json_object_string_add(json_neigh
, "bgpStateIs",
12573 uptime
= bgp_clock();
12574 uptime
-= p
->readtime
;
12575 gmtime_r(&uptime
, &tm
);
12577 json_object_int_add(json_neigh
, "bgpTimerLastRead",
12578 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12579 + (tm
.tm_hour
* 3600000));
12581 uptime
= bgp_clock();
12582 uptime
-= p
->last_write
;
12583 gmtime_r(&uptime
, &tm
);
12585 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
12586 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12587 + (tm
.tm_hour
* 3600000));
12589 uptime
= bgp_clock();
12590 uptime
-= p
->update_time
;
12591 gmtime_r(&uptime
, &tm
);
12593 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
12594 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12595 + (tm
.tm_hour
* 3600000));
12597 /* Configured timer values. */
12598 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
12599 p
->v_holdtime
* 1000);
12600 json_object_int_add(json_neigh
,
12601 "bgpTimerKeepAliveIntervalMsecs",
12602 p
->v_keepalive
* 1000);
12603 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12604 json_object_int_add(json_neigh
,
12605 "bgpTimerConfiguredHoldTimeMsecs",
12606 p
->holdtime
* 1000);
12607 json_object_int_add(
12609 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12610 p
->keepalive
* 1000);
12611 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12612 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12613 json_object_int_add(json_neigh
,
12614 "bgpTimerConfiguredHoldTimeMsecs",
12615 bgp
->default_holdtime
);
12616 json_object_int_add(
12618 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12619 bgp
->default_keepalive
);
12622 /* Administrative shutdown. */
12623 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12624 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12625 vty_out(vty
, " Administratively shut down\n");
12628 vty_out(vty
, " BGP version 4");
12629 vty_out(vty
, ", remote router ID %s",
12630 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12631 vty_out(vty
, ", local router ID %s\n",
12632 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12635 /* Confederation */
12636 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12637 && bgp_confederation_peers_check(bgp
, p
->as
))
12639 " Neighbor under common administration\n");
12642 vty_out(vty
, " BGP state = %s",
12643 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12645 if (p
->status
== Established
)
12646 vty_out(vty
, ", up for %8s",
12647 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
12650 else if (p
->status
== Active
) {
12651 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12652 vty_out(vty
, " (passive)");
12653 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12654 vty_out(vty
, " (NSF passive)");
12656 vty_out(vty
, "\n");
12659 vty_out(vty
, " Last read %s",
12660 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
12662 vty_out(vty
, ", Last write %s\n",
12663 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
12666 /* Configured timer values. */
12668 " Hold time is %d, keepalive interval is %d seconds\n",
12669 p
->v_holdtime
, p
->v_keepalive
);
12670 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12671 vty_out(vty
, " Configured hold time is %d",
12673 vty_out(vty
, ", keepalive interval is %d seconds\n",
12675 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12676 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12677 vty_out(vty
, " Configured hold time is %d",
12678 bgp
->default_holdtime
);
12679 vty_out(vty
, ", keepalive interval is %d seconds\n",
12680 bgp
->default_keepalive
);
12684 if (p
->status
== Established
) {
12685 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
12686 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
12687 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
12688 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
12689 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
12690 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
12691 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
12692 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
12693 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
12694 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
12695 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
12696 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
12697 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
12698 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
12699 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
12700 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
12701 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
12702 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
12703 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
12704 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
12706 json_object
*json_cap
= NULL
;
12708 json_cap
= json_object_new_object();
12711 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
12712 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
12713 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
12714 && CHECK_FLAG(p
->cap
,
12716 json_object_string_add(
12717 json_cap
, "4byteAs",
12718 "advertisedAndReceived");
12719 else if (CHECK_FLAG(p
->cap
,
12721 json_object_string_add(
12722 json_cap
, "4byteAs",
12724 else if (CHECK_FLAG(p
->cap
,
12726 json_object_string_add(
12727 json_cap
, "4byteAs",
12732 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
12733 || CHECK_FLAG(p
->cap
,
12734 PEER_CAP_ADDPATH_ADV
)) {
12735 json_object
*json_add
= NULL
;
12736 const char *print_store
;
12738 json_add
= json_object_new_object();
12740 FOREACH_AFI_SAFI (afi
, safi
) {
12741 json_object
*json_sub
= NULL
;
12743 json_object_new_object();
12744 print_store
= get_afi_safi_str(
12750 PEER_CAP_ADDPATH_AF_TX_ADV
)
12754 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
12759 PEER_CAP_ADDPATH_AF_TX_ADV
)
12764 PEER_CAP_ADDPATH_AF_TX_RCV
))
12765 json_object_boolean_true_add(
12767 "txAdvertisedAndReceived");
12773 PEER_CAP_ADDPATH_AF_TX_ADV
))
12774 json_object_boolean_true_add(
12782 PEER_CAP_ADDPATH_AF_TX_RCV
))
12783 json_object_boolean_true_add(
12791 PEER_CAP_ADDPATH_AF_RX_ADV
)
12795 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
12800 PEER_CAP_ADDPATH_AF_RX_ADV
)
12805 PEER_CAP_ADDPATH_AF_RX_RCV
))
12806 json_object_boolean_true_add(
12808 "rxAdvertisedAndReceived");
12814 PEER_CAP_ADDPATH_AF_RX_ADV
))
12815 json_object_boolean_true_add(
12823 PEER_CAP_ADDPATH_AF_RX_RCV
))
12824 json_object_boolean_true_add(
12832 PEER_CAP_ADDPATH_AF_TX_ADV
)
12836 PEER_CAP_ADDPATH_AF_TX_RCV
)
12840 PEER_CAP_ADDPATH_AF_RX_ADV
)
12844 PEER_CAP_ADDPATH_AF_RX_RCV
))
12845 json_object_object_add(
12854 json_object_object_add(
12855 json_cap
, "addPath", json_add
);
12859 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
12860 || CHECK_FLAG(p
->cap
,
12861 PEER_CAP_DYNAMIC_ADV
)) {
12862 if (CHECK_FLAG(p
->cap
,
12863 PEER_CAP_DYNAMIC_ADV
)
12864 && CHECK_FLAG(p
->cap
,
12865 PEER_CAP_DYNAMIC_RCV
))
12866 json_object_string_add(
12867 json_cap
, "dynamic",
12868 "advertisedAndReceived");
12869 else if (CHECK_FLAG(
12871 PEER_CAP_DYNAMIC_ADV
))
12872 json_object_string_add(
12873 json_cap
, "dynamic",
12875 else if (CHECK_FLAG(
12877 PEER_CAP_DYNAMIC_RCV
))
12878 json_object_string_add(
12879 json_cap
, "dynamic",
12883 /* Extended nexthop */
12884 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
12885 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
12886 json_object
*json_nxt
= NULL
;
12887 const char *print_store
;
12890 if (CHECK_FLAG(p
->cap
,
12892 && CHECK_FLAG(p
->cap
,
12893 PEER_CAP_ENHE_RCV
))
12894 json_object_string_add(
12897 "advertisedAndReceived");
12898 else if (CHECK_FLAG(p
->cap
,
12899 PEER_CAP_ENHE_ADV
))
12900 json_object_string_add(
12904 else if (CHECK_FLAG(p
->cap
,
12905 PEER_CAP_ENHE_RCV
))
12906 json_object_string_add(
12911 if (CHECK_FLAG(p
->cap
,
12912 PEER_CAP_ENHE_RCV
)) {
12914 json_object_new_object();
12916 for (safi
= SAFI_UNICAST
;
12917 safi
< SAFI_MAX
; safi
++) {
12922 PEER_CAP_ENHE_AF_RCV
)) {
12923 print_store
= get_afi_safi_str(
12926 json_object_string_add(
12929 "recieved"); /* misspelled for compatibility */
12932 json_object_object_add(
12934 "extendedNexthopFamililesByPeer",
12939 /* Route Refresh */
12940 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
12941 || CHECK_FLAG(p
->cap
,
12942 PEER_CAP_REFRESH_NEW_RCV
)
12943 || CHECK_FLAG(p
->cap
,
12944 PEER_CAP_REFRESH_OLD_RCV
)) {
12945 if (CHECK_FLAG(p
->cap
,
12946 PEER_CAP_REFRESH_ADV
)
12949 PEER_CAP_REFRESH_NEW_RCV
)
12952 PEER_CAP_REFRESH_OLD_RCV
))) {
12955 PEER_CAP_REFRESH_OLD_RCV
)
12958 PEER_CAP_REFRESH_NEW_RCV
))
12959 json_object_string_add(
12962 "advertisedAndReceivedOldNew");
12966 PEER_CAP_REFRESH_OLD_RCV
))
12967 json_object_string_add(
12970 "advertisedAndReceivedOld");
12972 json_object_string_add(
12975 "advertisedAndReceivedNew");
12980 PEER_CAP_REFRESH_ADV
))
12981 json_object_string_add(
12988 PEER_CAP_REFRESH_NEW_RCV
)
12991 PEER_CAP_REFRESH_OLD_RCV
))
12992 json_object_string_add(
12998 /* Multiprotocol Extensions */
12999 json_object
*json_multi
= NULL
;
13000 json_multi
= json_object_new_object();
13002 FOREACH_AFI_SAFI (afi
, safi
) {
13003 if (p
->afc_adv
[afi
][safi
]
13004 || p
->afc_recv
[afi
][safi
]) {
13005 json_object
*json_exten
= NULL
;
13007 json_object_new_object();
13009 if (p
->afc_adv
[afi
][safi
]
13010 && p
->afc_recv
[afi
][safi
])
13011 json_object_boolean_true_add(
13013 "advertisedAndReceived");
13014 else if (p
->afc_adv
[afi
][safi
])
13015 json_object_boolean_true_add(
13018 else if (p
->afc_recv
[afi
][safi
])
13019 json_object_boolean_true_add(
13023 json_object_object_add(
13025 get_afi_safi_str(afi
,
13031 json_object_object_add(
13032 json_cap
, "multiprotocolExtensions",
13035 /* Hostname capabilities */
13036 json_object
*json_hname
= NULL
;
13038 json_hname
= json_object_new_object();
13040 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13041 json_object_string_add(
13042 json_hname
, "advHostName",
13043 bgp
->peer_self
->hostname
13047 json_object_string_add(
13048 json_hname
, "advDomainName",
13049 bgp
->peer_self
->domainname
13056 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13057 json_object_string_add(
13058 json_hname
, "rcvHostName",
13059 p
->hostname
? p
->hostname
13061 json_object_string_add(
13062 json_hname
, "rcvDomainName",
13063 p
->domainname
? p
->domainname
13067 json_object_object_add(json_cap
, "hostName",
13070 /* Gracefull Restart */
13071 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
13072 || CHECK_FLAG(p
->cap
,
13073 PEER_CAP_RESTART_ADV
)) {
13074 if (CHECK_FLAG(p
->cap
,
13075 PEER_CAP_RESTART_ADV
)
13076 && CHECK_FLAG(p
->cap
,
13077 PEER_CAP_RESTART_RCV
))
13078 json_object_string_add(
13081 "advertisedAndReceived");
13082 else if (CHECK_FLAG(
13084 PEER_CAP_RESTART_ADV
))
13085 json_object_string_add(
13087 "gracefulRestartCapability",
13089 else if (CHECK_FLAG(
13091 PEER_CAP_RESTART_RCV
))
13092 json_object_string_add(
13094 "gracefulRestartCapability",
13097 if (CHECK_FLAG(p
->cap
,
13098 PEER_CAP_RESTART_RCV
)) {
13099 int restart_af_count
= 0;
13100 json_object
*json_restart
=
13103 json_object_new_object();
13105 json_object_int_add(
13107 "gracefulRestartRemoteTimerMsecs",
13108 p
->v_gr_restart
* 1000);
13110 FOREACH_AFI_SAFI (afi
, safi
) {
13115 PEER_CAP_RESTART_AF_RCV
)) {
13120 json_object_new_object();
13126 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13127 json_object_boolean_true_add(
13130 restart_af_count
++;
13131 json_object_object_add(
13140 if (!restart_af_count
) {
13141 json_object_string_add(
13143 "addressFamiliesByPeer",
13148 json_object_object_add(
13150 "addressFamiliesByPeer",
13154 json_object_object_add(json_neigh
,
13155 "neighborCapabilities",
13158 vty_out(vty
, " Neighbor capabilities:\n");
13161 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
13162 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13163 vty_out(vty
, " 4 Byte AS:");
13164 if (CHECK_FLAG(p
->cap
,
13166 vty_out(vty
, " advertised");
13167 if (CHECK_FLAG(p
->cap
,
13169 vty_out(vty
, " %sreceived",
13175 vty_out(vty
, "\n");
13179 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
13180 || CHECK_FLAG(p
->cap
,
13181 PEER_CAP_ADDPATH_ADV
)) {
13182 vty_out(vty
, " AddPath:\n");
13184 FOREACH_AFI_SAFI (afi
, safi
) {
13188 PEER_CAP_ADDPATH_AF_TX_ADV
)
13192 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13204 PEER_CAP_ADDPATH_AF_TX_ADV
))
13216 PEER_CAP_ADDPATH_AF_TX_RCV
))
13223 PEER_CAP_ADDPATH_AF_TX_ADV
)
13227 vty_out(vty
, "\n");
13233 PEER_CAP_ADDPATH_AF_RX_ADV
)
13237 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13249 PEER_CAP_ADDPATH_AF_RX_ADV
))
13261 PEER_CAP_ADDPATH_AF_RX_RCV
))
13268 PEER_CAP_ADDPATH_AF_RX_ADV
)
13272 vty_out(vty
, "\n");
13278 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
13279 || CHECK_FLAG(p
->cap
,
13280 PEER_CAP_DYNAMIC_ADV
)) {
13281 vty_out(vty
, " Dynamic:");
13282 if (CHECK_FLAG(p
->cap
,
13283 PEER_CAP_DYNAMIC_ADV
))
13284 vty_out(vty
, " advertised");
13285 if (CHECK_FLAG(p
->cap
,
13286 PEER_CAP_DYNAMIC_RCV
))
13287 vty_out(vty
, " %sreceived",
13290 PEER_CAP_DYNAMIC_ADV
)
13293 vty_out(vty
, "\n");
13296 /* Extended nexthop */
13297 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
13298 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13299 vty_out(vty
, " Extended nexthop:");
13300 if (CHECK_FLAG(p
->cap
,
13301 PEER_CAP_ENHE_ADV
))
13302 vty_out(vty
, " advertised");
13303 if (CHECK_FLAG(p
->cap
,
13304 PEER_CAP_ENHE_RCV
))
13305 vty_out(vty
, " %sreceived",
13311 vty_out(vty
, "\n");
13313 if (CHECK_FLAG(p
->cap
,
13314 PEER_CAP_ENHE_RCV
)) {
13316 " Address families by peer:\n ");
13317 for (safi
= SAFI_UNICAST
;
13318 safi
< SAFI_MAX
; safi
++)
13323 PEER_CAP_ENHE_AF_RCV
))
13333 /* Route Refresh */
13334 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
13335 || CHECK_FLAG(p
->cap
,
13336 PEER_CAP_REFRESH_NEW_RCV
)
13337 || CHECK_FLAG(p
->cap
,
13338 PEER_CAP_REFRESH_OLD_RCV
)) {
13339 vty_out(vty
, " Route refresh:");
13340 if (CHECK_FLAG(p
->cap
,
13341 PEER_CAP_REFRESH_ADV
))
13342 vty_out(vty
, " advertised");
13343 if (CHECK_FLAG(p
->cap
,
13344 PEER_CAP_REFRESH_NEW_RCV
)
13347 PEER_CAP_REFRESH_OLD_RCV
))
13348 vty_out(vty
, " %sreceived(%s)",
13351 PEER_CAP_REFRESH_ADV
)
13356 PEER_CAP_REFRESH_OLD_RCV
)
13359 PEER_CAP_REFRESH_NEW_RCV
))
13363 PEER_CAP_REFRESH_OLD_RCV
)
13367 vty_out(vty
, "\n");
13370 /* Multiprotocol Extensions */
13371 FOREACH_AFI_SAFI (afi
, safi
)
13372 if (p
->afc_adv
[afi
][safi
]
13373 || p
->afc_recv
[afi
][safi
]) {
13375 " Address Family %s:",
13380 if (p
->afc_adv
[afi
][safi
])
13383 if (p
->afc_recv
[afi
][safi
])
13390 vty_out(vty
, "\n");
13393 /* Hostname capability */
13394 vty_out(vty
, " Hostname Capability:");
13396 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13398 " advertised (name: %s,domain name: %s)",
13399 bgp
->peer_self
->hostname
13403 bgp
->peer_self
->domainname
13408 vty_out(vty
, " not advertised");
13411 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13413 " received (name: %s,domain name: %s)",
13414 p
->hostname
? p
->hostname
13416 p
->domainname
? p
->domainname
13419 vty_out(vty
, " not received");
13422 vty_out(vty
, "\n");
13424 /* Graceful Restart */
13425 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
13426 || CHECK_FLAG(p
->cap
,
13427 PEER_CAP_RESTART_ADV
)) {
13429 " Graceful Restart Capability:");
13430 if (CHECK_FLAG(p
->cap
,
13431 PEER_CAP_RESTART_ADV
))
13432 vty_out(vty
, " advertised");
13433 if (CHECK_FLAG(p
->cap
,
13434 PEER_CAP_RESTART_RCV
))
13435 vty_out(vty
, " %sreceived",
13438 PEER_CAP_RESTART_ADV
)
13441 vty_out(vty
, "\n");
13443 if (CHECK_FLAG(p
->cap
,
13444 PEER_CAP_RESTART_RCV
)) {
13445 int restart_af_count
= 0;
13448 " Remote Restart timer is %d seconds\n",
13451 " Address families by peer:\n ");
13453 FOREACH_AFI_SAFI (afi
, safi
)
13458 PEER_CAP_RESTART_AF_RCV
)) {
13472 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13474 : "not preserved");
13475 restart_af_count
++;
13477 if (!restart_af_count
)
13478 vty_out(vty
, "none");
13479 vty_out(vty
, "\n");
13481 } /* Gracefull Restart */
13486 /* graceful restart information */
13487 json_object
*json_grace
= NULL
;
13488 json_object
*json_grace_send
= NULL
;
13489 json_object
*json_grace_recv
= NULL
;
13490 int eor_send_af_count
= 0;
13491 int eor_receive_af_count
= 0;
13494 json_grace
= json_object_new_object();
13495 json_grace_send
= json_object_new_object();
13496 json_grace_recv
= json_object_new_object();
13498 if ((p
->status
== Established
)
13499 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13500 FOREACH_AFI_SAFI (afi
, safi
) {
13501 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13502 PEER_STATUS_EOR_SEND
)) {
13503 json_object_boolean_true_add(
13505 get_afi_safi_str(afi
,
13508 eor_send_af_count
++;
13511 FOREACH_AFI_SAFI (afi
, safi
) {
13513 p
->af_sflags
[afi
][safi
],
13514 PEER_STATUS_EOR_RECEIVED
)) {
13515 json_object_boolean_true_add(
13517 get_afi_safi_str(afi
,
13520 eor_receive_af_count
++;
13524 json_object_object_add(json_grace
, "endOfRibSend",
13526 json_object_object_add(json_grace
, "endOfRibRecv",
13530 if (p
->t_gr_restart
)
13531 json_object_int_add(json_grace
,
13532 "gracefulRestartTimerMsecs",
13533 thread_timer_remain_second(
13538 json_object_int_add(
13540 "gracefulStalepathTimerMsecs",
13541 thread_timer_remain_second(
13544 /* more gr info in new format */
13545 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
,
13547 json_object_object_add(
13548 json_neigh
, "gracefulRestartInfo", json_grace
);
13550 vty_out(vty
, " Graceful restart information:\n");
13551 if ((p
->status
== Established
)
13552 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13554 vty_out(vty
, " End-of-RIB send: ");
13555 FOREACH_AFI_SAFI (afi
, safi
) {
13556 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13557 PEER_STATUS_EOR_SEND
)) {
13558 vty_out(vty
, "%s%s",
13559 eor_send_af_count
? ", "
13564 eor_send_af_count
++;
13567 vty_out(vty
, "\n");
13568 vty_out(vty
, " End-of-RIB received: ");
13569 FOREACH_AFI_SAFI (afi
, safi
) {
13571 p
->af_sflags
[afi
][safi
],
13572 PEER_STATUS_EOR_RECEIVED
)) {
13573 vty_out(vty
, "%s%s",
13574 eor_receive_af_count
13577 get_afi_safi_str(afi
,
13580 eor_receive_af_count
++;
13583 vty_out(vty
, "\n");
13586 if (p
->t_gr_restart
)
13588 " The remaining time of restart timer is %ld\n",
13589 thread_timer_remain_second(
13594 " The remaining time of stalepath timer is %ld\n",
13595 thread_timer_remain_second(
13598 /* more gr info in new format */
13599 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
13603 json_object
*json_stat
= NULL
;
13604 json_stat
= json_object_new_object();
13605 /* Packet counts. */
13607 atomic_size_t outq_count
, inq_count
;
13608 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13609 memory_order_relaxed
);
13610 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13611 memory_order_relaxed
);
13613 json_object_int_add(json_stat
, "depthInq",
13614 (unsigned long)inq_count
);
13615 json_object_int_add(json_stat
, "depthOutq",
13616 (unsigned long)outq_count
);
13617 json_object_int_add(json_stat
, "opensSent",
13618 atomic_load_explicit(&p
->open_out
,
13619 memory_order_relaxed
));
13620 json_object_int_add(json_stat
, "opensRecv",
13621 atomic_load_explicit(&p
->open_in
,
13622 memory_order_relaxed
));
13623 json_object_int_add(json_stat
, "notificationsSent",
13624 atomic_load_explicit(&p
->notify_out
,
13625 memory_order_relaxed
));
13626 json_object_int_add(json_stat
, "notificationsRecv",
13627 atomic_load_explicit(&p
->notify_in
,
13628 memory_order_relaxed
));
13629 json_object_int_add(json_stat
, "updatesSent",
13630 atomic_load_explicit(&p
->update_out
,
13631 memory_order_relaxed
));
13632 json_object_int_add(json_stat
, "updatesRecv",
13633 atomic_load_explicit(&p
->update_in
,
13634 memory_order_relaxed
));
13635 json_object_int_add(json_stat
, "keepalivesSent",
13636 atomic_load_explicit(&p
->keepalive_out
,
13637 memory_order_relaxed
));
13638 json_object_int_add(json_stat
, "keepalivesRecv",
13639 atomic_load_explicit(&p
->keepalive_in
,
13640 memory_order_relaxed
));
13641 json_object_int_add(json_stat
, "routeRefreshSent",
13642 atomic_load_explicit(&p
->refresh_out
,
13643 memory_order_relaxed
));
13644 json_object_int_add(json_stat
, "routeRefreshRecv",
13645 atomic_load_explicit(&p
->refresh_in
,
13646 memory_order_relaxed
));
13647 json_object_int_add(json_stat
, "capabilitySent",
13648 atomic_load_explicit(&p
->dynamic_cap_out
,
13649 memory_order_relaxed
));
13650 json_object_int_add(json_stat
, "capabilityRecv",
13651 atomic_load_explicit(&p
->dynamic_cap_in
,
13652 memory_order_relaxed
));
13653 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
13654 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
13655 json_object_object_add(json_neigh
, "messageStats", json_stat
);
13657 atomic_size_t outq_count
, inq_count
;
13658 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13659 memory_order_relaxed
);
13660 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13661 memory_order_relaxed
);
13663 /* Packet counts. */
13664 vty_out(vty
, " Message statistics:\n");
13665 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
13666 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
13667 vty_out(vty
, " Sent Rcvd\n");
13668 vty_out(vty
, " Opens: %10d %10d\n",
13669 atomic_load_explicit(&p
->open_out
,
13670 memory_order_relaxed
),
13671 atomic_load_explicit(&p
->open_in
,
13672 memory_order_relaxed
));
13673 vty_out(vty
, " Notifications: %10d %10d\n",
13674 atomic_load_explicit(&p
->notify_out
,
13675 memory_order_relaxed
),
13676 atomic_load_explicit(&p
->notify_in
,
13677 memory_order_relaxed
));
13678 vty_out(vty
, " Updates: %10d %10d\n",
13679 atomic_load_explicit(&p
->update_out
,
13680 memory_order_relaxed
),
13681 atomic_load_explicit(&p
->update_in
,
13682 memory_order_relaxed
));
13683 vty_out(vty
, " Keepalives: %10d %10d\n",
13684 atomic_load_explicit(&p
->keepalive_out
,
13685 memory_order_relaxed
),
13686 atomic_load_explicit(&p
->keepalive_in
,
13687 memory_order_relaxed
));
13688 vty_out(vty
, " Route Refresh: %10d %10d\n",
13689 atomic_load_explicit(&p
->refresh_out
,
13690 memory_order_relaxed
),
13691 atomic_load_explicit(&p
->refresh_in
,
13692 memory_order_relaxed
));
13693 vty_out(vty
, " Capability: %10d %10d\n",
13694 atomic_load_explicit(&p
->dynamic_cap_out
,
13695 memory_order_relaxed
),
13696 atomic_load_explicit(&p
->dynamic_cap_in
,
13697 memory_order_relaxed
));
13698 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
13703 /* advertisement-interval */
13704 json_object_int_add(json_neigh
,
13705 "minBtwnAdvertisementRunsTimerMsecs",
13706 p
->v_routeadv
* 1000);
13708 /* Update-source. */
13709 if (p
->update_if
|| p
->update_source
) {
13711 json_object_string_add(json_neigh
,
13714 else if (p
->update_source
)
13715 json_object_string_add(
13716 json_neigh
, "updateSource",
13717 sockunion2str(p
->update_source
, buf1
,
13721 /* advertisement-interval */
13723 " Minimum time between advertisement runs is %d seconds\n",
13726 /* Update-source. */
13727 if (p
->update_if
|| p
->update_source
) {
13728 vty_out(vty
, " Update source is ");
13730 vty_out(vty
, "%s", p
->update_if
);
13731 else if (p
->update_source
)
13733 sockunion2str(p
->update_source
, buf1
,
13735 vty_out(vty
, "\n");
13738 vty_out(vty
, "\n");
13741 /* Address Family Information */
13742 json_object
*json_hold
= NULL
;
13745 json_hold
= json_object_new_object();
13747 FOREACH_AFI_SAFI (afi
, safi
)
13748 if (p
->afc
[afi
][safi
])
13749 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
13753 json_object_object_add(json_neigh
, "addressFamilyInfo",
13755 json_object_int_add(json_neigh
, "connectionsEstablished",
13757 json_object_int_add(json_neigh
, "connectionsDropped",
13760 vty_out(vty
, " Connections established %d; dropped %d\n",
13761 p
->established
, p
->dropped
);
13763 if (!p
->last_reset
) {
13765 json_object_string_add(json_neigh
, "lastReset",
13768 vty_out(vty
, " Last reset never\n");
13774 uptime
= bgp_clock();
13775 uptime
-= p
->resettime
;
13776 gmtime_r(&uptime
, &tm
);
13778 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
13780 + (tm
.tm_min
* 60000)
13781 + (tm
.tm_hour
* 3600000));
13782 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
13784 vty_out(vty
, " Last reset %s, ",
13785 peer_uptime(p
->resettime
, timebuf
,
13786 BGP_UPTIME_LEN
, 0, NULL
));
13788 bgp_show_peer_reset(vty
, p
, NULL
, false);
13789 if (p
->last_reset_cause_size
) {
13790 msg
= p
->last_reset_cause
;
13792 " Message received that caused BGP to send a NOTIFICATION:\n ");
13793 for (i
= 1; i
<= p
->last_reset_cause_size
;
13795 vty_out(vty
, "%02X", *msg
++);
13797 if (i
!= p
->last_reset_cause_size
) {
13799 vty_out(vty
, "\n ");
13800 } else if (i
% 4 == 0) {
13805 vty_out(vty
, "\n");
13810 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
13812 json_object_boolean_true_add(json_neigh
,
13813 "prefixesConfigExceedMax");
13816 " Peer had exceeded the max. no. of prefixes configured.\n");
13818 if (p
->t_pmax_restart
) {
13820 json_object_boolean_true_add(
13821 json_neigh
, "reducePrefixNumFrom");
13822 json_object_int_add(json_neigh
,
13823 "restartInTimerMsec",
13824 thread_timer_remain_second(
13829 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
13830 p
->host
, thread_timer_remain_second(
13831 p
->t_pmax_restart
));
13834 json_object_boolean_true_add(
13836 "reducePrefixNumAndClearIpBgp");
13839 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
13844 /* EBGP Multihop and GTSM */
13845 if (p
->sort
!= BGP_PEER_IBGP
) {
13847 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
13848 json_object_int_add(json_neigh
,
13849 "externalBgpNbrMaxHopsAway",
13851 else if (p
->ttl
> BGP_DEFAULT_TTL
)
13852 json_object_int_add(json_neigh
,
13853 "externalBgpNbrMaxHopsAway",
13856 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
13858 " External BGP neighbor may be up to %d hops away.\n",
13860 else if (p
->ttl
> BGP_DEFAULT_TTL
)
13862 " External BGP neighbor may be up to %d hops away.\n",
13866 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
) {
13868 json_object_int_add(json_neigh
,
13869 "internalBgpNbrMaxHopsAway",
13873 " Internal BGP neighbor may be up to %d hops away.\n",
13878 /* Local address. */
13881 json_object_string_add(json_neigh
, "hostLocal",
13882 sockunion2str(p
->su_local
, buf1
,
13884 json_object_int_add(json_neigh
, "portLocal",
13885 ntohs(p
->su_local
->sin
.sin_port
));
13887 vty_out(vty
, "Local host: %s, Local port: %d\n",
13888 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
13889 ntohs(p
->su_local
->sin
.sin_port
));
13892 /* Remote address. */
13893 if (p
->su_remote
) {
13895 json_object_string_add(json_neigh
, "hostForeign",
13896 sockunion2str(p
->su_remote
, buf1
,
13898 json_object_int_add(json_neigh
, "portForeign",
13899 ntohs(p
->su_remote
->sin
.sin_port
));
13901 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
13902 sockunion2str(p
->su_remote
, buf1
,
13904 ntohs(p
->su_remote
->sin
.sin_port
));
13907 /* Nexthop display. */
13910 json_object_string_add(json_neigh
, "nexthop",
13912 &p
->nexthop
.v4
, buf1
,
13914 json_object_string_add(json_neigh
, "nexthopGlobal",
13915 inet_ntop(AF_INET6
,
13916 &p
->nexthop
.v6_global
,
13917 buf1
, sizeof(buf1
)));
13918 json_object_string_add(json_neigh
, "nexthopLocal",
13919 inet_ntop(AF_INET6
,
13920 &p
->nexthop
.v6_local
,
13921 buf1
, sizeof(buf1
)));
13922 if (p
->shared_network
)
13923 json_object_string_add(json_neigh
,
13927 json_object_string_add(json_neigh
,
13929 "nonSharedNetwork");
13931 vty_out(vty
, "Nexthop: %s\n",
13932 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
13934 vty_out(vty
, "Nexthop global: %s\n",
13935 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
13937 vty_out(vty
, "Nexthop local: %s\n",
13938 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
13940 vty_out(vty
, "BGP connection: %s\n",
13941 p
->shared_network
? "shared network"
13942 : "non shared network");
13946 /* Timer information. */
13948 json_object_int_add(json_neigh
, "connectRetryTimer",
13950 if (p
->status
== Established
&& p
->rtt
)
13951 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
13954 json_object_int_add(
13955 json_neigh
, "nextStartTimerDueInMsecs",
13956 thread_timer_remain_second(p
->t_start
) * 1000);
13958 json_object_int_add(
13959 json_neigh
, "nextConnectTimerDueInMsecs",
13960 thread_timer_remain_second(p
->t_connect
)
13962 if (p
->t_routeadv
) {
13963 json_object_int_add(json_neigh
, "mraiInterval",
13965 json_object_int_add(
13966 json_neigh
, "mraiTimerExpireInMsecs",
13967 thread_timer_remain_second(p
->t_routeadv
)
13971 json_object_int_add(json_neigh
, "authenticationEnabled",
13975 json_object_string_add(json_neigh
, "readThread", "on");
13977 json_object_string_add(json_neigh
, "readThread", "off");
13979 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
13980 json_object_string_add(json_neigh
, "writeThread", "on");
13982 json_object_string_add(json_neigh
, "writeThread",
13985 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
13987 if (p
->status
== Established
&& p
->rtt
)
13988 vty_out(vty
, "Estimated round trip time: %d ms\n",
13991 vty_out(vty
, "Next start timer due in %ld seconds\n",
13992 thread_timer_remain_second(p
->t_start
));
13994 vty_out(vty
, "Next connect timer due in %ld seconds\n",
13995 thread_timer_remain_second(p
->t_connect
));
13998 "MRAI (interval %u) timer expires in %ld seconds\n",
14000 thread_timer_remain_second(p
->t_routeadv
));
14002 vty_out(vty
, "Peer Authentication Enabled\n");
14004 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14005 p
->t_read
? "on" : "off",
14006 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14011 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14012 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14013 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14016 vty_out(vty
, "\n");
14018 /* BFD information. */
14019 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
14022 if (p
->conf_if
) /* Configured interface name. */
14023 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14024 else /* Configured IP address. */
14025 json_object_object_add(json
, p
->host
, json_neigh
);
14029 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14030 enum show_type type
,
14031 union sockunion
*su
,
14032 const char *conf_if
, afi_t afi
,
14035 struct listnode
*node
, *nnode
;
14038 safi_t safi
= SAFI_UNICAST
;
14039 json_object
*json
= NULL
;
14040 json_object
*json_neighbor
= NULL
;
14043 json
= json_object_new_object();
14044 json_neighbor
= json_object_new_object();
14047 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14049 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14052 if ((peer
->afc
[afi
][safi
]) == 0)
14055 if (type
== show_all
) {
14056 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14060 json_object_object_add(json
, peer
->host
,
14062 json_neighbor
= NULL
;
14065 } else if (type
== show_peer
) {
14068 && !strcmp(peer
->conf_if
, conf_if
))
14070 && !strcmp(peer
->hostname
, conf_if
))) {
14072 bgp_show_peer_gr_status(vty
, peer
,
14077 if (sockunion_same(&peer
->su
, su
)) {
14079 bgp_show_peer_gr_status(vty
, peer
,
14084 if (use_json
&& find
)
14085 json_object_object_add(json
, peer
->host
,
14090 json_neighbor
= NULL
;
14095 if (type
== show_peer
&& !find
) {
14097 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14099 vty_out(vty
, "%% No such neighbor\n");
14102 vty_out(vty
, "%s\n",
14103 json_object_to_json_string_ext(
14104 json
, JSON_C_TO_STRING_PRETTY
));
14107 json_object_free(json_neighbor
);
14108 json_object_free(json
);
14110 vty_out(vty
, "\n");
14113 return CMD_SUCCESS
;
14116 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14117 enum show_type type
, union sockunion
*su
,
14118 const char *conf_if
, bool use_json
,
14121 struct listnode
*node
, *nnode
;
14124 bool nbr_output
= false;
14125 afi_t afi
= AFI_MAX
;
14126 safi_t safi
= SAFI_MAX
;
14128 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14130 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14134 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14135 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14140 bgp_show_peer(vty
, peer
, use_json
, json
);
14146 && !strcmp(peer
->conf_if
, conf_if
))
14148 && !strcmp(peer
->hostname
, conf_if
))) {
14150 bgp_show_peer(vty
, peer
, use_json
,
14154 if (sockunion_same(&peer
->su
, su
)) {
14156 bgp_show_peer(vty
, peer
, use_json
,
14161 case show_ipv4_peer
:
14162 case show_ipv6_peer
:
14163 FOREACH_SAFI (safi
) {
14164 if (peer
->afc
[afi
][safi
]) {
14167 && !strcmp(peer
->conf_if
, conf_if
))
14169 && !strcmp(peer
->hostname
, conf_if
))) {
14171 bgp_show_peer(vty
, peer
, use_json
,
14176 if (sockunion_same(&peer
->su
, su
)) {
14178 bgp_show_peer(vty
, peer
, use_json
,
14186 case show_ipv4_all
:
14187 case show_ipv6_all
:
14188 FOREACH_SAFI (safi
) {
14189 if (peer
->afc
[afi
][safi
]) {
14190 bgp_show_peer(vty
, peer
, use_json
, json
);
14199 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14200 type
== show_ipv6_peer
) && !find
) {
14202 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14204 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14207 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14208 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14209 vty_out(vty
, "%% No BGP neighbors found\n");
14212 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14213 json
, JSON_C_TO_STRING_PRETTY
));
14215 vty_out(vty
, "\n");
14218 return CMD_SUCCESS
;
14221 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14222 enum show_type type
,
14223 const char *ip_str
,
14224 afi_t afi
, bool use_json
)
14229 union sockunion su
;
14231 bgp
= bgp_get_default();
14237 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14241 ret
= str2sockunion(ip_str
, &su
);
14243 bgp_show_neighbor_graceful_restart(
14244 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14246 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14247 NULL
, afi
, use_json
);
14249 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14253 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14254 enum show_type type
,
14255 const char *ip_str
,
14258 struct listnode
*node
, *nnode
;
14260 union sockunion su
;
14261 json_object
*json
= NULL
;
14262 int ret
, is_first
= 1;
14263 bool nbr_output
= false;
14266 vty_out(vty
, "{\n");
14268 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14271 if (!(json
= json_object_new_object())) {
14273 EC_BGP_JSON_MEM_ERROR
,
14274 "Unable to allocate memory for JSON object");
14276 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14280 json_object_int_add(json
, "vrfId",
14281 (bgp
->vrf_id
== VRF_UNKNOWN
)
14283 : (int64_t)bgp
->vrf_id
);
14284 json_object_string_add(
14286 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14291 vty_out(vty
, ",\n");
14295 vty_out(vty
, "\"%s\":",
14296 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14300 vty_out(vty
, "\nInstance %s:\n",
14301 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14306 if (type
== show_peer
|| type
== show_ipv4_peer
||
14307 type
== show_ipv6_peer
) {
14308 ret
= str2sockunion(ip_str
, &su
);
14310 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14313 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14316 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14319 json_object_free(json
);
14324 vty_out(vty
, "}\n");
14325 else if (!nbr_output
)
14326 vty_out(vty
, "%% BGP instance not found\n");
14329 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14330 enum show_type type
, const char *ip_str
,
14335 union sockunion su
;
14336 json_object
*json
= NULL
;
14339 if (strmatch(name
, "all")) {
14340 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14342 return CMD_SUCCESS
;
14344 bgp
= bgp_lookup_by_name(name
);
14347 json
= json_object_new_object();
14348 vty_out(vty
, "%s\n",
14349 json_object_to_json_string_ext(
14351 JSON_C_TO_STRING_PRETTY
));
14352 json_object_free(json
);
14355 "%% BGP instance not found\n");
14357 return CMD_WARNING
;
14361 bgp
= bgp_get_default();
14365 json
= json_object_new_object();
14367 ret
= str2sockunion(ip_str
, &su
);
14369 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14372 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14375 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14378 json_object_free(json
);
14381 vty_out(vty
, "{}\n");
14383 vty_out(vty
, "%% BGP instance not found\n");
14386 return CMD_SUCCESS
;
14391 /* "show [ip] bgp neighbors graceful-restart" commands. */
14392 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
14393 show_ip_bgp_neighbors_graceful_restart_cmd
,
14394 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14400 "Neighbor to display information about\n"
14401 "Neighbor to display information about\n"
14402 "Neighbor on BGP configured interface\n"
14406 char *sh_arg
= NULL
;
14407 enum show_type sh_type
;
14409 afi_t afi
= AFI_MAX
;
14410 bool uj
= use_json(argc
, argv
);
14412 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14417 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14418 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14419 || argv_find(argv
, argc
, "WORD", &idx
)) {
14420 sh_type
= show_peer
;
14421 sh_arg
= argv
[idx
]->arg
;
14423 sh_type
= show_all
;
14425 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14426 return CMD_SUCCESS
;
14429 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14433 /* "show [ip] bgp neighbors" commands. */
14434 DEFUN (show_ip_bgp_neighbors
,
14435 show_ip_bgp_neighbors_cmd
,
14436 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14440 BGP_INSTANCE_HELP_STR
14443 "Detailed information on TCP and BGP neighbor connections\n"
14444 "Neighbor to display information about\n"
14445 "Neighbor to display information about\n"
14446 "Neighbor on BGP configured interface\n"
14450 char *sh_arg
= NULL
;
14451 enum show_type sh_type
;
14452 afi_t afi
= AFI_MAX
;
14454 bool uj
= use_json(argc
, argv
);
14458 /* [<vrf> VIEWVRFNAME] */
14459 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14460 vrf
= argv
[idx
+ 1]->arg
;
14461 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14463 } else if (argv_find(argv
, argc
, "view", &idx
))
14464 /* [<view> VIEWVRFNAME] */
14465 vrf
= argv
[idx
+ 1]->arg
;
14469 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14470 sh_type
= show_ipv4_all
;
14472 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14473 sh_type
= show_ipv6_all
;
14476 sh_type
= show_all
;
14479 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14480 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14481 || argv_find(argv
, argc
, "WORD", &idx
)) {
14482 sh_type
= show_peer
;
14483 sh_arg
= argv
[idx
]->arg
;
14486 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14487 sh_type
= show_ipv4_peer
;
14488 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14489 sh_type
= show_ipv6_peer
;
14492 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14495 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14496 paths' and `show ip mbgp paths'. Those functions results are the
14498 DEFUN (show_ip_bgp_paths
,
14499 show_ip_bgp_paths_cmd
,
14500 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14505 "Path information\n")
14507 vty_out(vty
, "Address Refcnt Path\n");
14508 aspath_print_all_vty(vty
);
14509 return CMD_SUCCESS
;
14514 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14517 struct community
*com
;
14519 com
= (struct community
*)bucket
->data
;
14520 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14521 community_str(com
, false));
14524 /* Show BGP's community internal data. */
14525 DEFUN (show_ip_bgp_community_info
,
14526 show_ip_bgp_community_info_cmd
,
14527 "show [ip] bgp community-info",
14531 "List all bgp community information\n")
14533 vty_out(vty
, "Address Refcnt Community\n");
14535 hash_iterate(community_hash(),
14536 (void (*)(struct hash_bucket
*,
14537 void *))community_show_all_iterator
,
14540 return CMD_SUCCESS
;
14543 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14546 struct lcommunity
*lcom
;
14548 lcom
= (struct lcommunity
*)bucket
->data
;
14549 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14550 lcommunity_str(lcom
, false));
14553 /* Show BGP's community internal data. */
14554 DEFUN (show_ip_bgp_lcommunity_info
,
14555 show_ip_bgp_lcommunity_info_cmd
,
14556 "show ip bgp large-community-info",
14560 "List all bgp large-community information\n")
14562 vty_out(vty
, "Address Refcnt Large-community\n");
14564 hash_iterate(lcommunity_hash(),
14565 (void (*)(struct hash_bucket
*,
14566 void *))lcommunity_show_all_iterator
,
14569 return CMD_SUCCESS
;
14571 /* Graceful Restart */
14573 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
14580 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
14582 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
14584 switch (bgp_global_gr_mode
) {
14586 case GLOBAL_HELPER
:
14587 vty_out(vty
, "Global BGP GR Mode : Helper\n");
14591 vty_out(vty
, "Global BGP GR Mode : Restart\n");
14594 case GLOBAL_DISABLE
:
14595 vty_out(vty
, "Global BGP GR Mode : Disable\n");
14598 case GLOBAL_INVALID
:
14600 "Global BGP GR Mode Invalid\n");
14603 vty_out(vty
, "\n");
14606 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
14607 enum show_type type
,
14608 const char *ip_str
,
14609 afi_t afi
, bool use_json
)
14611 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
14614 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
14616 bgp_show_neighbor_graceful_restart_vty(
14617 vty
, type
, ip_str
, afi
, use_json
);
14620 } else if (afi
!= AFI_MAX
) {
14621 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
14624 return CMD_ERR_INCOMPLETE
;
14627 return CMD_SUCCESS
;
14629 /* Graceful Restart */
14631 DEFUN (show_ip_bgp_attr_info
,
14632 show_ip_bgp_attr_info_cmd
,
14633 "show [ip] bgp attribute-info",
14637 "List all bgp attribute information\n")
14639 attr_show_all(vty
);
14640 return CMD_SUCCESS
;
14643 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
14644 afi_t afi
, safi_t safi
,
14645 bool use_json
, json_object
*json
)
14648 struct listnode
*node
;
14650 char buf1
[INET6_ADDRSTRLEN
];
14652 vpn_policy_direction_t dir
;
14655 json_object
*json_import_vrfs
= NULL
;
14656 json_object
*json_export_vrfs
= NULL
;
14658 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14661 vty_out(vty
, "%s\n",
14662 json_object_to_json_string_ext(
14664 JSON_C_TO_STRING_PRETTY
));
14665 json_object_free(json
);
14667 return CMD_WARNING
;
14670 /* Provide context for the block */
14671 json_object_string_add(json
, "vrf", name
? name
: "default");
14672 json_object_string_add(json
, "afiSafi",
14673 get_afi_safi_str(afi
, safi
, true));
14675 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14676 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
14677 json_object_string_add(json
, "importFromVrfs", "none");
14678 json_object_string_add(json
, "importRts", "none");
14680 json_import_vrfs
= json_object_new_array();
14682 for (ALL_LIST_ELEMENTS_RO(
14683 bgp
->vpn_policy
[afi
].import_vrf
,
14685 json_object_array_add(json_import_vrfs
,
14686 json_object_new_string(vname
));
14688 json_object_object_add(json
, "importFromVrfs",
14690 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14691 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14692 ecom_str
= ecommunity_ecom2str(
14693 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14694 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14695 json_object_string_add(json
, "importRts",
14697 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14699 json_object_string_add(json
, "importRts",
14703 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14704 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
14705 json_object_string_add(json
, "exportToVrfs", "none");
14706 json_object_string_add(json
, "routeDistinguisher",
14708 json_object_string_add(json
, "exportRts", "none");
14710 json_export_vrfs
= json_object_new_array();
14712 for (ALL_LIST_ELEMENTS_RO(
14713 bgp
->vpn_policy
[afi
].export_vrf
,
14715 json_object_array_add(json_export_vrfs
,
14716 json_object_new_string(vname
));
14717 json_object_object_add(json
, "exportToVrfs",
14719 json_object_string_add(json
, "routeDistinguisher",
14720 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
14721 buf1
, RD_ADDRSTRLEN
));
14723 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
14724 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14725 ecom_str
= ecommunity_ecom2str(
14726 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14727 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14728 json_object_string_add(json
, "exportRts",
14730 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14732 json_object_string_add(json
, "exportRts",
14737 vty_out(vty
, "%s\n",
14738 json_object_to_json_string_ext(json
,
14739 JSON_C_TO_STRING_PRETTY
));
14740 json_object_free(json
);
14743 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14746 vty_out(vty
, "%% No such BGP instance exist\n");
14747 return CMD_WARNING
;
14750 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14751 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
14753 "This VRF is not importing %s routes from any other VRF\n",
14754 get_afi_safi_str(afi
, safi
, false));
14757 "This VRF is importing %s routes from the following VRFs:\n",
14758 get_afi_safi_str(afi
, safi
, false));
14760 for (ALL_LIST_ELEMENTS_RO(
14761 bgp
->vpn_policy
[afi
].import_vrf
,
14763 vty_out(vty
, " %s\n", vname
);
14765 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14767 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14768 ecom_str
= ecommunity_ecom2str(
14769 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14770 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14771 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
14773 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14775 vty_out(vty
, "Import RT(s):\n");
14778 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14779 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
14781 "This VRF is not exporting %s routes to any other VRF\n",
14782 get_afi_safi_str(afi
, safi
, false));
14785 "This VRF is exporting %s routes to the following VRFs:\n",
14786 get_afi_safi_str(afi
, safi
, false));
14788 for (ALL_LIST_ELEMENTS_RO(
14789 bgp
->vpn_policy
[afi
].export_vrf
,
14791 vty_out(vty
, " %s\n", vname
);
14793 vty_out(vty
, "RD: %s\n",
14794 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
14795 buf1
, RD_ADDRSTRLEN
));
14797 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
14798 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14799 ecom_str
= ecommunity_ecom2str(
14800 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14801 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14802 vty_out(vty
, "Export RT: %s\n", ecom_str
);
14803 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14805 vty_out(vty
, "Import RT(s):\n");
14809 return CMD_SUCCESS
;
14812 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
14813 safi_t safi
, bool use_json
)
14815 struct listnode
*node
, *nnode
;
14817 char *vrf_name
= NULL
;
14818 json_object
*json
= NULL
;
14819 json_object
*json_vrf
= NULL
;
14820 json_object
*json_vrfs
= NULL
;
14823 json
= json_object_new_object();
14824 json_vrfs
= json_object_new_object();
14827 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14829 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
14830 vrf_name
= bgp
->name
;
14833 json_vrf
= json_object_new_object();
14835 vty_out(vty
, "\nInstance %s:\n",
14836 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14837 ? VRF_DEFAULT_NAME
: bgp
->name
);
14839 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
14841 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14842 json_object_object_add(json_vrfs
,
14843 VRF_DEFAULT_NAME
, json_vrf
);
14845 json_object_object_add(json_vrfs
, vrf_name
,
14851 json_object_object_add(json
, "vrfs", json_vrfs
);
14852 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
14853 JSON_C_TO_STRING_PRETTY
));
14854 json_object_free(json
);
14857 return CMD_SUCCESS
;
14860 /* "show [ip] bgp route-leak" command. */
14861 DEFUN (show_ip_bgp_route_leak
,
14862 show_ip_bgp_route_leak_cmd
,
14863 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
14867 BGP_INSTANCE_HELP_STR
14870 "Route leaking information\n"
14874 afi_t afi
= AFI_MAX
;
14875 safi_t safi
= SAFI_MAX
;
14877 bool uj
= use_json(argc
, argv
);
14879 json_object
*json
= NULL
;
14881 /* show [ip] bgp */
14882 if (argv_find(argv
, argc
, "ip", &idx
)) {
14884 safi
= SAFI_UNICAST
;
14886 /* [vrf VIEWVRFNAME] */
14887 if (argv_find(argv
, argc
, "view", &idx
)) {
14889 "%% This command is not applicable to BGP views\n");
14890 return CMD_WARNING
;
14893 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14894 vrf
= argv
[idx
+ 1]->arg
;
14895 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14898 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
14899 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
14900 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
14903 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
14905 "%% This command is applicable only for unicast ipv4|ipv6\n");
14906 return CMD_WARNING
;
14909 if (vrf
&& strmatch(vrf
, "all"))
14910 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
14913 json
= json_object_new_object();
14915 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
14918 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
14921 struct listnode
*node
, *nnode
;
14924 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14925 vty_out(vty
, "\nInstance %s:\n",
14926 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14929 update_group_show(bgp
, afi
, safi
, vty
, 0);
14933 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
14934 int safi
, uint64_t subgrp_id
)
14939 if (strmatch(name
, "all")) {
14940 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
14941 return CMD_SUCCESS
;
14943 bgp
= bgp_lookup_by_name(name
);
14946 bgp
= bgp_get_default();
14950 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
14951 return CMD_SUCCESS
;
14954 DEFUN (show_ip_bgp_updgrps
,
14955 show_ip_bgp_updgrps_cmd
,
14956 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
14960 BGP_INSTANCE_HELP_STR
14962 BGP_SAFI_WITH_LABEL_HELP_STR
14963 "Detailed info about dynamic update groups\n"
14964 "Specific subgroup to display detailed info for\n")
14967 afi_t afi
= AFI_IP6
;
14968 safi_t safi
= SAFI_UNICAST
;
14969 uint64_t subgrp_id
= 0;
14973 /* show [ip] bgp */
14974 if (argv_find(argv
, argc
, "ip", &idx
))
14976 /* [<vrf> VIEWVRFNAME] */
14977 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14978 vrf
= argv
[idx
+ 1]->arg
;
14979 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14981 } else if (argv_find(argv
, argc
, "view", &idx
))
14982 /* [<view> VIEWVRFNAME] */
14983 vrf
= argv
[idx
+ 1]->arg
;
14984 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
14985 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
14986 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
14989 /* get subgroup id, if provided */
14991 if (argv
[idx
]->type
== VARIABLE_TKN
)
14992 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
14994 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
14997 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
14998 show_bgp_instance_all_ipv6_updgrps_cmd
,
14999 "show [ip] bgp <view|vrf> all update-groups",
15003 BGP_INSTANCE_ALL_HELP_STR
15004 "Detailed info about dynamic update groups\n")
15006 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15007 return CMD_SUCCESS
;
15010 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15011 show_bgp_l2vpn_evpn_updgrps_cmd
,
15012 "show [ip] bgp l2vpn evpn update-groups",
15016 "l2vpn address family\n"
15017 "evpn sub-address family\n"
15018 "Detailed info about dynamic update groups\n")
15021 uint64_t subgrp_id
= 0;
15023 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15024 return CMD_SUCCESS
;
15027 DEFUN (show_bgp_updgrps_stats
,
15028 show_bgp_updgrps_stats_cmd
,
15029 "show [ip] bgp update-groups statistics",
15033 "Detailed info about dynamic update groups\n"
15038 bgp
= bgp_get_default();
15040 update_group_show_stats(bgp
, vty
);
15042 return CMD_SUCCESS
;
15045 DEFUN (show_bgp_instance_updgrps_stats
,
15046 show_bgp_instance_updgrps_stats_cmd
,
15047 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15051 BGP_INSTANCE_HELP_STR
15052 "Detailed info about dynamic update groups\n"
15058 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15060 update_group_show_stats(bgp
, vty
);
15062 return CMD_SUCCESS
;
15065 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15066 afi_t afi
, safi_t safi
,
15067 const char *what
, uint64_t subgrp_id
)
15072 bgp
= bgp_lookup_by_name(name
);
15074 bgp
= bgp_get_default();
15077 if (!strcmp(what
, "advertise-queue"))
15078 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15080 else if (!strcmp(what
, "advertised-routes"))
15081 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15083 else if (!strcmp(what
, "packet-queue"))
15084 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15089 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15090 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15091 "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",
15092 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15094 "Detailed info about dynamic update groups\n"
15095 "Specific subgroup to display info for\n"
15096 "Advertisement queue\n"
15097 "Announced routes\n"
15100 uint64_t subgrp_id
= 0;
15104 subgrp_id
= strtoull(sgid
, NULL
, 10);
15109 afiz
= bgp_vty_afi_from_str(afi
);
15113 afiz
= bgp_vty_afi_from_str(afi
);
15114 if (afiz
!= AFI_IP
)
15116 "%% Cannot specify both 'ip' and 'ipv6'\n");
15117 return CMD_WARNING
;
15120 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15122 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15123 return CMD_SUCCESS
;
15126 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
15128 struct listnode
*node
, *nnode
;
15129 struct prefix
*range
;
15134 const char *peer_status
;
15135 const char *af_str
;
15140 conf
= group
->conf
;
15142 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15143 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15144 group
->name
, conf
->as
);
15145 } else if (conf
->as_type
== AS_INTERNAL
) {
15146 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15147 group
->name
, group
->bgp
->as
);
15149 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15152 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
15153 vty_out(vty
, " Peer-group type is internal\n");
15155 vty_out(vty
, " Peer-group type is external\n");
15157 /* Display AFs configured. */
15158 vty_out(vty
, " Configured address-families:");
15159 FOREACH_AFI_SAFI (afi
, safi
) {
15160 if (conf
->afc
[afi
][safi
]) {
15162 vty_out(vty
, " %s;", get_afi_safi_str(afi
, safi
, false));
15166 vty_out(vty
, " none\n");
15168 vty_out(vty
, "\n");
15170 /* Display listen ranges (for dynamic neighbors), if any */
15171 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15174 else if (afi
== AFI_IP6
)
15178 lr_count
= listcount(group
->listen_range
[afi
]);
15180 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
15184 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15186 vty_out(vty
, " %pFX\n", range
);
15190 /* Display group members and their status */
15191 if (listcount(group
->peer
)) {
15192 vty_out(vty
, " Peer-group members:\n");
15193 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15194 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15195 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15196 peer_status
= "Idle (Admin)";
15197 else if (CHECK_FLAG(peer
->sflags
,
15198 PEER_STATUS_PREFIX_OVERFLOW
))
15199 peer_status
= "Idle (PfxCt)";
15201 peer_status
= lookup_msg(bgp_status_msg
,
15202 peer
->status
, NULL
);
15204 dynamic
= peer_dynamic_neighbor(peer
);
15205 vty_out(vty
, " %s %s %s \n", peer
->host
,
15206 dynamic
? "(dynamic)" : "", peer_status
);
15210 return CMD_SUCCESS
;
15213 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15214 const char *group_name
)
15217 struct listnode
*node
, *nnode
;
15218 struct peer_group
*group
;
15219 bool found
= false;
15221 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15224 vty_out(vty
, "%% BGP instance not found\n");
15225 return CMD_WARNING
;
15228 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15230 if (strmatch(group
->name
, group_name
)) {
15231 bgp_show_one_peer_group(vty
, group
);
15236 bgp_show_one_peer_group(vty
, group
);
15240 if (group_name
&& !found
)
15241 vty_out(vty
, "%% No such peer-group\n");
15243 return CMD_SUCCESS
;
15246 DEFUN (show_ip_bgp_peer_groups
,
15247 show_ip_bgp_peer_groups_cmd
,
15248 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
15252 BGP_INSTANCE_HELP_STR
15253 "Detailed information on BGP peer groups\n"
15254 "Peer group name\n")
15259 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15261 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15263 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
15267 /* Redistribute VTY commands. */
15269 DEFUN_YANG (bgp_redistribute_ipv4
,
15270 bgp_redistribute_ipv4_cmd
,
15271 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15272 "Redistribute information from another routing protocol\n"
15273 FRR_IP_REDIST_HELP_STR_BGPD
)
15275 int idx_protocol
= 1;
15276 char base_xpath
[XPATH_MAXLEN
];
15278 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15279 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15280 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15281 argv
[idx_protocol
]->text
, "0");
15283 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15285 return nb_cli_apply_changes(vty
, base_xpath
);
15289 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15290 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15291 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15293 DEFUN_YANG (bgp_redistribute_ipv4_rmap
,
15294 bgp_redistribute_ipv4_rmap_cmd
,
15295 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15296 "Redistribute information from another routing protocol\n"
15297 FRR_IP_REDIST_HELP_STR_BGPD
15298 "Route map reference\n"
15299 "Pointer to route-map entries\n")
15301 int idx_protocol
= 1;
15303 char base_xpath
[XPATH_MAXLEN
];
15305 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15306 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15307 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15308 argv
[idx_protocol
]->text
, "0");
15310 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15311 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15312 argv
[idx_word
]->arg
);
15314 return nb_cli_apply_changes(vty
, base_xpath
);
15318 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15319 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15320 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15321 "Route map reference\n"
15322 "Pointer to route-map entries\n")
15324 DEFUN_YANG (bgp_redistribute_ipv4_metric
,
15325 bgp_redistribute_ipv4_metric_cmd
,
15326 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15327 "Redistribute information from another routing protocol\n"
15328 FRR_IP_REDIST_HELP_STR_BGPD
15329 "Metric for redistributed routes\n"
15330 "Default metric\n")
15332 int idx_protocol
= 1;
15333 int idx_number
= 3;
15334 char base_xpath
[XPATH_MAXLEN
];
15336 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15337 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15338 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15339 argv
[idx_protocol
]->text
, "0");
15341 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15342 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15343 argv
[idx_number
]->arg
);
15345 return nb_cli_apply_changes(vty
, base_xpath
);
15349 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15350 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15351 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15352 "Metric for redistributed routes\n"
15353 "Default metric\n")
15356 bgp_redistribute_ipv4_rmap_metric
,
15357 bgp_redistribute_ipv4_rmap_metric_cmd
,
15358 "redistribute " FRR_IP_REDIST_STR_BGPD
15359 " route-map WORD metric (0-4294967295)",
15360 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15361 "Route map reference\n"
15362 "Pointer to route-map entries\n"
15363 "Metric for redistributed routes\n"
15364 "Default metric\n")
15366 int idx_protocol
= 1;
15368 int idx_number
= 5;
15369 char base_xpath
[XPATH_MAXLEN
];
15371 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15372 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15373 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15374 argv
[idx_protocol
]->text
, "0");
15376 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15377 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15378 argv
[idx_word
]->arg
);
15379 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15380 argv
[idx_number
]->arg
);
15382 return nb_cli_apply_changes(vty
, base_xpath
);
15386 bgp_redistribute_ipv4_rmap_metric
,
15387 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15388 "redistribute " FRR_IP_REDIST_STR_BGPD
15389 " route-map WORD metric (0-4294967295)",
15390 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15391 "Route map reference\n"
15392 "Pointer to route-map entries\n"
15393 "Metric for redistributed routes\n"
15394 "Default metric\n")
15397 bgp_redistribute_ipv4_metric_rmap
,
15398 bgp_redistribute_ipv4_metric_rmap_cmd
,
15399 "redistribute " FRR_IP_REDIST_STR_BGPD
15400 " metric (0-4294967295) route-map WORD",
15401 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15402 "Metric for redistributed routes\n"
15404 "Route map reference\n"
15405 "Pointer to route-map entries\n")
15407 int idx_protocol
= 1;
15409 int idx_number
= 3;
15410 char base_xpath
[XPATH_MAXLEN
];
15412 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15413 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15414 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15415 argv
[idx_protocol
]->text
, "0");
15417 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15418 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15419 argv
[idx_number
]->arg
);
15420 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15421 argv
[idx_word
]->arg
);
15423 return nb_cli_apply_changes(vty
, base_xpath
);
15427 bgp_redistribute_ipv4_metric_rmap
,
15428 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15429 "redistribute " FRR_IP_REDIST_STR_BGPD
15430 " metric (0-4294967295) route-map WORD",
15431 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15432 "Metric for redistributed routes\n"
15434 "Route map reference\n"
15435 "Pointer to route-map entries\n")
15437 DEFUN_YANG (bgp_redistribute_ipv4_ospf
,
15438 bgp_redistribute_ipv4_ospf_cmd
,
15439 "redistribute <ospf|table> (1-65535)",
15440 "Redistribute information from another routing protocol\n"
15441 "Open Shortest Path First (OSPFv2)\n"
15442 "Non-main Kernel Routing Table\n"
15443 "Instance ID/Table ID\n")
15445 int idx_protocol
= 1;
15446 int idx_number
= 2;
15447 char base_xpath
[XPATH_MAXLEN
];
15449 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15450 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15451 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15452 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15454 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15456 return nb_cli_apply_changes(vty
, base_xpath
);
15459 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
15460 "redistribute <ospf|table> (1-65535)",
15461 "Redistribute information from another routing protocol\n"
15462 "Open Shortest Path First (OSPFv2)\n"
15463 "Non-main Kernel Routing Table\n"
15464 "Instance ID/Table ID\n")
15466 DEFUN_YANG (bgp_redistribute_ipv4_ospf_rmap
,
15467 bgp_redistribute_ipv4_ospf_rmap_cmd
,
15468 "redistribute <ospf|table> (1-65535) route-map WORD",
15469 "Redistribute information from another routing protocol\n"
15470 "Open Shortest Path First (OSPFv2)\n"
15471 "Non-main Kernel Routing Table\n"
15472 "Instance ID/Table ID\n"
15473 "Route map reference\n"
15474 "Pointer to route-map entries\n")
15476 int idx_protocol
= 1;
15477 int idx_number
= 2;
15479 char base_xpath
[XPATH_MAXLEN
];
15481 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15482 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15483 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15484 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15486 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15488 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15489 argv
[idx_word
]->arg
);
15491 return nb_cli_apply_changes(vty
, base_xpath
);
15494 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
15495 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
15496 "redistribute <ospf|table> (1-65535) route-map WORD",
15497 "Redistribute information from another routing protocol\n"
15498 "Open Shortest Path First (OSPFv2)\n"
15499 "Non-main Kernel Routing Table\n"
15500 "Instance ID/Table ID\n"
15501 "Route map reference\n"
15502 "Pointer to route-map entries\n")
15504 DEFUN_YANG(bgp_redistribute_ipv4_ospf_metric
,
15505 bgp_redistribute_ipv4_ospf_metric_cmd
,
15506 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15507 "Redistribute information from another routing protocol\n"
15508 "Open Shortest Path First (OSPFv2)\n"
15509 "Non-main Kernel Routing Table\n"
15510 "Instance ID/Table ID\n"
15511 "Metric for redistributed routes\n"
15512 "Default metric\n")
15514 int idx_protocol
= 1;
15515 int idx_number
= 2;
15516 int idx_number_2
= 4;
15517 char base_xpath
[XPATH_MAXLEN
];
15519 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15520 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15521 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15522 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15524 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15526 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15527 argv
[idx_number_2
]->arg
);
15529 return nb_cli_apply_changes(vty
, base_xpath
);
15532 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
15533 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
15534 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15535 "Redistribute information from another routing protocol\n"
15536 "Open Shortest Path First (OSPFv2)\n"
15537 "Non-main Kernel Routing Table\n"
15538 "Instance ID/Table ID\n"
15539 "Metric for redistributed routes\n"
15540 "Default metric\n")
15543 bgp_redistribute_ipv4_ospf_rmap_metric
,
15544 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
15545 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15546 "Redistribute information from another routing protocol\n"
15547 "Open Shortest Path First (OSPFv2)\n"
15548 "Non-main Kernel Routing Table\n"
15549 "Instance ID/Table ID\n"
15550 "Route map reference\n"
15551 "Pointer to route-map entries\n"
15552 "Metric for redistributed routes\n"
15553 "Default metric\n")
15555 int idx_protocol
= 1;
15556 int idx_number
= 2;
15558 int idx_number_2
= 6;
15559 char base_xpath
[XPATH_MAXLEN
];
15561 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15562 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15563 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15564 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15566 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15568 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15569 argv
[idx_word
]->arg
);
15570 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15571 argv
[idx_number_2
]->arg
);
15573 return nb_cli_apply_changes(vty
, base_xpath
);
15577 bgp_redistribute_ipv4_ospf_rmap_metric
,
15578 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
15579 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15580 "Redistribute information from another routing protocol\n"
15581 "Open Shortest Path First (OSPFv2)\n"
15582 "Non-main Kernel Routing Table\n"
15583 "Instance ID/Table ID\n"
15584 "Route map reference\n"
15585 "Pointer to route-map entries\n"
15586 "Metric for redistributed routes\n"
15587 "Default metric\n")
15590 bgp_redistribute_ipv4_ospf_metric_rmap
,
15591 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
15592 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15593 "Redistribute information from another routing protocol\n"
15594 "Open Shortest Path First (OSPFv2)\n"
15595 "Non-main Kernel Routing Table\n"
15596 "Instance ID/Table ID\n"
15597 "Metric for redistributed routes\n"
15599 "Route map reference\n"
15600 "Pointer to route-map entries\n")
15602 int idx_protocol
= 1;
15603 int idx_number
= 2;
15604 int idx_number_2
= 4;
15606 char base_xpath
[XPATH_MAXLEN
];
15608 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15609 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15610 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15611 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15613 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15615 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15616 argv
[idx_number_2
]->arg
);
15617 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15618 argv
[idx_word
]->arg
);
15620 return nb_cli_apply_changes(vty
, base_xpath
);
15624 bgp_redistribute_ipv4_ospf_metric_rmap
,
15625 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
15626 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15627 "Redistribute information from another routing protocol\n"
15628 "Open Shortest Path First (OSPFv2)\n"
15629 "Non-main Kernel Routing Table\n"
15630 "Instance ID/Table ID\n"
15631 "Metric for redistributed routes\n"
15633 "Route map reference\n"
15634 "Pointer to route-map entries\n")
15636 DEFUN_YANG (no_bgp_redistribute_ipv4_ospf
,
15637 no_bgp_redistribute_ipv4_ospf_cmd
,
15638 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
15640 "Redistribute information from another routing protocol\n"
15641 "Open Shortest Path First (OSPFv2)\n"
15642 "Non-main Kernel Routing Table\n"
15643 "Instance ID/Table ID\n"
15644 "Metric for redistributed routes\n"
15646 "Route map reference\n"
15647 "Pointer to route-map entries\n")
15649 int idx_protocol
= 2;
15650 int idx_number
= 3;
15651 char base_xpath
[XPATH_MAXLEN
];
15653 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15654 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15655 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15656 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15658 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
15660 return nb_cli_apply_changes(vty
, base_xpath
);
15664 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
15665 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
15667 "Redistribute information from another routing protocol\n"
15668 "Open Shortest Path First (OSPFv2)\n"
15669 "Non-main Kernel Routing Table\n"
15670 "Instance ID/Table ID\n"
15671 "Metric for redistributed routes\n"
15673 "Route map reference\n"
15674 "Pointer to route-map entries\n")
15676 DEFUN_YANG (no_bgp_redistribute_ipv4
,
15677 no_bgp_redistribute_ipv4_cmd
,
15678 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
15680 "Redistribute information from another routing protocol\n"
15681 FRR_IP_REDIST_HELP_STR_BGPD
15682 "Metric for redistributed routes\n"
15684 "Route map reference\n"
15685 "Pointer to route-map entries\n")
15687 int idx_protocol
= 2;
15688 char base_xpath
[XPATH_MAXLEN
];
15690 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15691 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15692 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15693 argv
[idx_protocol
]->text
, "0");
15695 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
15697 return nb_cli_apply_changes(vty
, base_xpath
);
15701 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
15702 "no redistribute " FRR_IP_REDIST_STR_BGPD
15703 " [{metric (0-4294967295)|route-map WORD}]",
15705 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15706 "Metric for redistributed routes\n"
15708 "Route map reference\n"
15709 "Pointer to route-map entries\n")
15711 DEFUN_YANG (bgp_redistribute_ipv6
,
15712 bgp_redistribute_ipv6_cmd
,
15713 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
15714 "Redistribute information from another routing protocol\n"
15715 FRR_IP6_REDIST_HELP_STR_BGPD
)
15717 int idx_protocol
= 1;
15718 char base_xpath
[XPATH_MAXLEN
];
15720 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15721 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15722 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15723 argv
[idx_protocol
]->text
, "0");
15725 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15727 return nb_cli_apply_changes(vty
, base_xpath
);
15730 DEFUN_YANG (bgp_redistribute_ipv6_rmap
,
15731 bgp_redistribute_ipv6_rmap_cmd
,
15732 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
15733 "Redistribute information from another routing protocol\n"
15734 FRR_IP6_REDIST_HELP_STR_BGPD
15735 "Route map reference\n"
15736 "Pointer to route-map entries\n")
15738 int idx_protocol
= 1;
15740 char base_xpath
[XPATH_MAXLEN
];
15742 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15743 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15744 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15745 argv
[idx_protocol
]->text
, "0");
15747 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15748 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15749 argv
[idx_word
]->arg
);
15751 return nb_cli_apply_changes(vty
, base_xpath
);
15754 DEFUN_YANG (bgp_redistribute_ipv6_metric
,
15755 bgp_redistribute_ipv6_metric_cmd
,
15756 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
15757 "Redistribute information from another routing protocol\n"
15758 FRR_IP6_REDIST_HELP_STR_BGPD
15759 "Metric for redistributed routes\n"
15760 "Default metric\n")
15762 int idx_protocol
= 1;
15763 int idx_number
= 3;
15764 char base_xpath
[XPATH_MAXLEN
];
15766 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15767 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15768 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15769 argv
[idx_protocol
]->text
, "0");
15771 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15772 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15773 argv
[idx_number
]->arg
);
15775 return nb_cli_apply_changes(vty
, base_xpath
);
15779 bgp_redistribute_ipv6_rmap_metric
,
15780 bgp_redistribute_ipv6_rmap_metric_cmd
,
15781 "redistribute " FRR_IP6_REDIST_STR_BGPD
15782 " route-map WORD metric (0-4294967295)",
15783 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
15784 "Route map reference\n"
15785 "Pointer to route-map entries\n"
15786 "Metric for redistributed routes\n"
15787 "Default metric\n")
15789 int idx_protocol
= 1;
15791 int idx_number
= 5;
15792 char base_xpath
[XPATH_MAXLEN
];
15794 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15795 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15796 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15797 argv
[idx_protocol
]->text
, "0");
15799 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15800 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15801 argv
[idx_word
]->arg
);
15802 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15803 argv
[idx_number
]->arg
);
15805 return nb_cli_apply_changes(vty
, base_xpath
);
15809 bgp_redistribute_ipv6_metric_rmap
,
15810 bgp_redistribute_ipv6_metric_rmap_cmd
,
15811 "redistribute " FRR_IP6_REDIST_STR_BGPD
15812 " metric (0-4294967295) route-map WORD",
15813 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
15814 "Metric for redistributed routes\n"
15816 "Route map reference\n"
15817 "Pointer to route-map entries\n")
15819 int idx_protocol
= 1;
15821 int idx_number
= 3;
15822 char base_xpath
[XPATH_MAXLEN
];
15824 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15825 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15826 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15827 argv
[idx_protocol
]->text
, "0");
15829 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15830 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15831 argv
[idx_number
]->arg
);
15832 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15833 argv
[idx_word
]->arg
);
15835 return nb_cli_apply_changes(vty
, base_xpath
);
15839 no_bgp_redistribute_ipv6
,
15840 no_bgp_redistribute_ipv6_cmd
,
15841 "no redistribute " FRR_IP6_REDIST_STR_BGPD
15842 " [{metric (0-4294967295)|route-map WORD}]",
15844 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
15845 "Metric for redistributed routes\n"
15847 "Route map reference\n"
15848 "Pointer to route-map entries\n")
15850 int idx_protocol
= 2;
15851 char base_xpath
[XPATH_MAXLEN
];
15853 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15854 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15855 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15856 argv
[idx_protocol
]->text
, "0");
15858 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
15860 return nb_cli_apply_changes(vty
, base_xpath
);
15863 void cli_show_bgp_global_afi_safi_ip_unicast_redistribution_list(
15864 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
15866 uint32_t instance
= 0;
15868 vty_out(vty
, " redistribute %s",
15869 yang_dnode_get_string(dnode
, "./route-type"));
15870 if ((instance
= yang_dnode_get_uint16(dnode
, "./route-instance")))
15871 vty_out(vty
, " %d", instance
);
15872 if (yang_dnode_exists(dnode
, "./metric"))
15873 vty_out(vty
, " metric %u",
15874 yang_dnode_get_uint32(dnode
, "./metric"));
15875 if (yang_dnode_exists(dnode
, "./rmap-policy-import"))
15876 vty_out(vty
, " route-map %s",
15877 yang_dnode_get_string(dnode
, "./rmap-policy-import"));
15878 vty_out(vty
, "\n");
15881 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
15882 afi_t afi
, safi_t safi
)
15886 /* Unicast redistribution only. */
15887 if (safi
!= SAFI_UNICAST
)
15890 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
15891 /* Redistribute BGP does not make sense. */
15892 if (i
!= ZEBRA_ROUTE_BGP
) {
15893 struct list
*red_list
;
15894 struct listnode
*node
;
15895 struct bgp_redist
*red
;
15897 red_list
= bgp
->redist
[afi
][i
];
15901 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
15902 /* "redistribute" configuration. */
15903 vty_out(vty
, " redistribute %s",
15904 zebra_route_string(i
));
15906 vty_out(vty
, " %d", red
->instance
);
15907 if (red
->redist_metric_flag
)
15908 vty_out(vty
, " metric %u",
15909 red
->redist_metric
);
15910 if (red
->rmap
.name
)
15911 vty_out(vty
, " route-map %s",
15913 vty_out(vty
, "\n");
15919 /* peer-group helpers for config-write */
15921 static bool peergroup_flag_check(struct peer
*peer
, uint32_t flag
)
15923 if (!peer_group_active(peer
)) {
15924 if (CHECK_FLAG(peer
->flags_invert
, flag
))
15925 return !CHECK_FLAG(peer
->flags
, flag
);
15927 return !!CHECK_FLAG(peer
->flags
, flag
);
15930 return !!CHECK_FLAG(peer
->flags_override
, flag
);
15933 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
15936 if (!peer_group_active(peer
)) {
15937 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
15938 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
15940 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
15943 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
15946 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
15947 uint8_t type
, int direct
)
15949 struct bgp_filter
*filter
;
15951 if (peer_group_active(peer
))
15952 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
15955 filter
= &peer
->filter
[afi
][safi
];
15957 case PEER_FT_DISTRIBUTE_LIST
:
15958 return !!(filter
->dlist
[direct
].name
);
15959 case PEER_FT_FILTER_LIST
:
15960 return !!(filter
->aslist
[direct
].name
);
15961 case PEER_FT_PREFIX_LIST
:
15962 return !!(filter
->plist
[direct
].name
);
15963 case PEER_FT_ROUTE_MAP
:
15964 return !!(filter
->map
[direct
].name
);
15965 case PEER_FT_UNSUPPRESS_MAP
:
15966 return !!(filter
->usmap
.name
);
15967 case PEER_FT_ADVERTISE_MAP
:
15968 return !!(filter
->advmap
.aname
15969 && ((filter
->advmap
.condition
== direct
)
15970 && filter
->advmap
.cname
));
15976 /* Return true if the addpath type is set for peer and different from
15979 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
15982 enum bgp_addpath_strat type
, g_type
;
15984 type
= peer
->addpath_type
[afi
][safi
];
15986 if (type
!= BGP_ADDPATH_NONE
) {
15987 if (peer_group_active(peer
)) {
15988 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
15990 if (type
!= g_type
)
16002 /* This is part of the address-family block (unicast only) */
16003 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16008 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16009 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16010 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16011 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16012 bgp
->vpn_policy
[afi
]
16013 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16015 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16016 bgp
->vpn_policy
[afi
]
16017 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16019 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16020 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16021 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16022 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16025 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16026 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16028 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16031 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16032 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16033 bgp
->vpn_policy
[afi
].tovpn_label
);
16036 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16037 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
16038 char buf
[RD_ADDRSTRLEN
];
16039 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
16040 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
16043 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16044 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16046 char buf
[PREFIX_STRLEN
];
16047 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16048 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16051 vty_out(vty
, "%*snexthop vpn export %s\n",
16055 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16056 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16058 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16059 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16061 char *b
= ecommunity_ecom2str(
16062 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16063 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16064 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16065 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16067 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16068 char *b
= ecommunity_ecom2str(
16069 bgp
->vpn_policy
[afi
]
16070 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16071 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16072 ECOMMUNITY_ROUTE_TARGET
);
16073 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16074 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16076 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16077 char *b
= ecommunity_ecom2str(
16078 bgp
->vpn_policy
[afi
]
16079 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16080 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16081 ECOMMUNITY_ROUTE_TARGET
);
16082 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16083 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16087 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16088 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16089 bgp
->vpn_policy
[afi
]
16090 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16092 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16093 char *b
= ecommunity_ecom2str(
16094 bgp
->vpn_policy
[afi
]
16095 .import_redirect_rtlist
,
16096 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16097 ECOMMUNITY_ROUTE_TARGET
);
16099 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16100 != ECOMMUNITY_SIZE
)
16101 vty_out(vty
, "%*srt6 redirect import %s\n",
16104 vty_out(vty
, "%*srt redirect import %s\n",
16106 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16110 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16111 afi_t afi
, safi_t safi
)
16113 struct bgp_filter
*filter
;
16117 filter
= &peer
->filter
[afi
][safi
];
16119 /* distribute-list. */
16120 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16122 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16123 filter
->dlist
[FILTER_IN
].name
);
16125 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16127 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16128 filter
->dlist
[FILTER_OUT
].name
);
16131 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16133 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16134 filter
->plist
[FILTER_IN
].name
);
16136 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16138 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16139 filter
->plist
[FILTER_OUT
].name
);
16142 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16143 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16144 filter
->map
[RMAP_IN
].name
);
16146 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16148 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16149 filter
->map
[RMAP_OUT
].name
);
16151 /* unsuppress-map */
16152 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16153 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16154 filter
->usmap
.name
);
16156 /* advertise-map : always applied in OUT direction*/
16157 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16158 CONDITION_NON_EXIST
))
16160 " neighbor %s advertise-map %s non-exist-map %s\n",
16161 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16163 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16165 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16166 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16169 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16171 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16172 filter
->aslist
[FILTER_IN
].name
);
16174 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16176 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16177 filter
->aslist
[FILTER_OUT
].name
);
16180 /* BGP peer configuration display function. */
16181 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16184 struct peer
*g_peer
= NULL
;
16185 char buf
[SU_ADDRSTRLEN
];
16187 int if_pg_printed
= false;
16188 int if_ras_printed
= false;
16190 /* Skip dynamic neighbors. */
16191 if (peer_dynamic_neighbor(peer
))
16195 addr
= peer
->conf_if
;
16199 /************************************
16200 ****** Global to the neighbor ******
16201 ************************************/
16202 if (peer
->conf_if
) {
16203 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16204 vty_out(vty
, " neighbor %s interface v6only", addr
);
16206 vty_out(vty
, " neighbor %s interface", addr
);
16208 if (peer_group_active(peer
)) {
16209 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16210 if_pg_printed
= true;
16211 } else if (peer
->as_type
== AS_SPECIFIED
) {
16212 vty_out(vty
, " remote-as %u", peer
->as
);
16213 if_ras_printed
= true;
16214 } else if (peer
->as_type
== AS_INTERNAL
) {
16215 vty_out(vty
, " remote-as internal");
16216 if_ras_printed
= true;
16217 } else if (peer
->as_type
== AS_EXTERNAL
) {
16218 vty_out(vty
, " remote-as external");
16219 if_ras_printed
= true;
16222 vty_out(vty
, "\n");
16225 /* remote-as and peer-group */
16226 /* peer is a member of a peer-group */
16227 if (peer_group_active(peer
)) {
16228 g_peer
= peer
->group
->conf
;
16230 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16231 if (peer
->as_type
== AS_SPECIFIED
) {
16232 vty_out(vty
, " neighbor %s remote-as %u\n",
16234 } else if (peer
->as_type
== AS_INTERNAL
) {
16236 " neighbor %s remote-as internal\n",
16238 } else if (peer
->as_type
== AS_EXTERNAL
) {
16240 " neighbor %s remote-as external\n",
16245 /* For swpX peers we displayed the peer-group
16246 * via 'neighbor swpX interface peer-group PGNAME' */
16247 if (!if_pg_printed
)
16248 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16249 peer
->group
->name
);
16252 /* peer is NOT a member of a peer-group */
16254 /* peer is a peer-group, declare the peer-group */
16255 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16256 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16259 if (!if_ras_printed
) {
16260 if (peer
->as_type
== AS_SPECIFIED
) {
16261 vty_out(vty
, " neighbor %s remote-as %u\n",
16263 } else if (peer
->as_type
== AS_INTERNAL
) {
16265 " neighbor %s remote-as internal\n",
16267 } else if (peer
->as_type
== AS_EXTERNAL
) {
16269 " neighbor %s remote-as external\n",
16276 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16277 vty_out(vty
, " neighbor %s local-as %u", addr
,
16278 peer
->change_local_as
);
16279 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16280 vty_out(vty
, " no-prepend");
16281 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16282 vty_out(vty
, " replace-as");
16283 vty_out(vty
, "\n");
16288 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16292 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16293 if (peer
->tx_shutdown_message
)
16294 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16295 peer
->tx_shutdown_message
);
16297 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16300 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16301 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16302 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16305 if (peer
->bfd_info
) {
16306 if (!peer_group_active(peer
) || !g_peer
->bfd_info
) {
16307 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16312 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16313 vty_out(vty
, " neighbor %s password %s\n", addr
,
16316 /* neighbor solo */
16317 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16318 if (!peer_group_active(peer
)) {
16319 vty_out(vty
, " neighbor %s solo\n", addr
);
16324 if (peer
->port
!= BGP_PORT_DEFAULT
) {
16325 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
16328 /* Local interface name */
16329 if (peer
->ifname
) {
16330 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
16334 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
16335 vty_out(vty
, " neighbor %s passive\n", addr
);
16337 /* ebgp-multihop */
16338 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
16339 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
16340 && peer
->ttl
== MAXTTL
)) {
16341 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
16342 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
16347 /* ttl-security hops */
16348 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
16349 if (!peer_group_active(peer
)
16350 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
16351 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
16352 addr
, peer
->gtsm_hops
);
16356 /* disable-connected-check */
16357 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
16358 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
16360 /* enforce-first-as */
16361 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
16362 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
16364 /* update-source */
16365 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
16366 if (peer
->update_source
)
16367 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16368 sockunion2str(peer
->update_source
, buf
,
16370 else if (peer
->update_if
)
16371 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16375 /* advertisement-interval */
16376 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
16377 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
16381 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
16382 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
16383 peer
->keepalive
, peer
->holdtime
);
16385 /* timers connect */
16386 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
16387 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16389 /* need special-case handling for changed default values due to
16390 * config profile / version (because there is no "timers bgp connect"
16391 * command, we need to save this per-peer :/)
16393 else if (!peer_group_active(peer
) && !peer
->connect
&&
16394 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
16395 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16396 peer
->bgp
->default_connect_retry
);
16398 /* capability dynamic */
16399 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
16400 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
16402 /* capability extended-nexthop */
16403 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
16404 if (!peer
->conf_if
) {
16405 if (CHECK_FLAG(peer
->flags_invert
,
16406 PEER_FLAG_CAPABILITY_ENHE
))
16408 " no neighbor %s capability extended-nexthop\n",
16412 " neighbor %s capability extended-nexthop\n",
16417 /* dont-capability-negotiation */
16418 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
16419 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
16421 /* override-capability */
16422 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
16423 vty_out(vty
, " neighbor %s override-capability\n", addr
);
16425 /* strict-capability-match */
16426 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
16427 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
16429 /* Sender side AS path loop detection. */
16430 if (peer
->as_path_loop_detection
)
16431 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
16434 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16435 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
16437 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16438 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
16440 " neighbor %s graceful-restart-helper\n", addr
);
16441 } else if (CHECK_FLAG(
16442 peer
->peer_gr_new_status_flag
,
16443 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
16445 " neighbor %s graceful-restart\n", addr
);
16447 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16448 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
16450 peer
->peer_gr_new_status_flag
,
16451 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
16452 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
16458 /* BGP peer configuration display function. */
16459 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
16460 struct peer
*peer
, afi_t afi
, safi_t safi
)
16462 struct peer
*g_peer
= NULL
;
16464 bool flag_scomm
, flag_secomm
, flag_slcomm
;
16466 /* Skip dynamic neighbors. */
16467 if (peer_dynamic_neighbor(peer
))
16471 addr
= peer
->conf_if
;
16475 /************************************
16476 ****** Per AF to the neighbor ******
16477 ************************************/
16478 if (peer_group_active(peer
)) {
16479 g_peer
= peer
->group
->conf
;
16481 /* If the peer-group is active but peer is not, print a 'no
16483 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
16484 vty_out(vty
, " no neighbor %s activate\n", addr
);
16487 /* If the peer-group is not active but peer is, print an
16489 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
16490 vty_out(vty
, " neighbor %s activate\n", addr
);
16493 if (peer
->afc
[afi
][safi
]) {
16494 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
16495 if (CHECK_FLAG(bgp
->flags
,
16496 BGP_FLAG_NO_DEFAULT_IPV4
)) {
16497 vty_out(vty
, " neighbor %s activate\n",
16501 vty_out(vty
, " neighbor %s activate\n", addr
);
16503 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
16504 if (!CHECK_FLAG(bgp
->flags
,
16505 BGP_FLAG_NO_DEFAULT_IPV4
)) {
16507 " no neighbor %s activate\n",
16514 /* addpath TX knobs */
16515 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
16516 switch (peer
->addpath_type
[afi
][safi
]) {
16517 case BGP_ADDPATH_ALL
:
16518 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
16521 case BGP_ADDPATH_BEST_PER_AS
:
16523 " neighbor %s addpath-tx-bestpath-per-AS\n",
16526 case BGP_ADDPATH_MAX
:
16527 case BGP_ADDPATH_NONE
:
16532 /* ORF capability. */
16533 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
16534 || peergroup_af_flag_check(peer
, afi
, safi
,
16535 PEER_FLAG_ORF_PREFIX_RM
)) {
16536 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
16538 if (peergroup_af_flag_check(peer
, afi
, safi
,
16539 PEER_FLAG_ORF_PREFIX_SM
)
16540 && peergroup_af_flag_check(peer
, afi
, safi
,
16541 PEER_FLAG_ORF_PREFIX_RM
))
16542 vty_out(vty
, " both");
16543 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16544 PEER_FLAG_ORF_PREFIX_SM
))
16545 vty_out(vty
, " send");
16547 vty_out(vty
, " receive");
16548 vty_out(vty
, "\n");
16551 /* Route reflector client. */
16552 if (peergroup_af_flag_check(peer
, afi
, safi
,
16553 PEER_FLAG_REFLECTOR_CLIENT
)) {
16554 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
16557 /* next-hop-self force */
16558 if (peergroup_af_flag_check(peer
, afi
, safi
,
16559 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
16560 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
16563 /* next-hop-self */
16564 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
16565 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
16568 /* remove-private-AS */
16569 if (peergroup_af_flag_check(peer
, afi
, safi
,
16570 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
16571 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
16575 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16576 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
16577 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
16581 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16582 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
16583 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
16586 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16587 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
16588 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
16592 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
16593 vty_out(vty
, " neighbor %s as-override\n", addr
);
16596 /* send-community print. */
16597 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16598 PEER_FLAG_SEND_COMMUNITY
);
16599 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16600 PEER_FLAG_SEND_EXT_COMMUNITY
);
16601 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16602 PEER_FLAG_SEND_LARGE_COMMUNITY
);
16604 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
16605 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
16608 vty_out(vty
, " no neighbor %s send-community\n", addr
);
16611 " no neighbor %s send-community extended\n",
16615 vty_out(vty
, " no neighbor %s send-community large\n",
16619 /* Default information */
16620 if (peergroup_af_flag_check(peer
, afi
, safi
,
16621 PEER_FLAG_DEFAULT_ORIGINATE
)) {
16622 vty_out(vty
, " neighbor %s default-originate", addr
);
16624 if (peer
->default_rmap
[afi
][safi
].name
)
16625 vty_out(vty
, " route-map %s",
16626 peer
->default_rmap
[afi
][safi
].name
);
16628 vty_out(vty
, "\n");
16631 /* Soft reconfiguration inbound. */
16632 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
16633 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
16637 /* maximum-prefix. */
16638 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
16639 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
16640 peer
->pmax
[afi
][safi
]);
16642 if (peer
->pmax_threshold
[afi
][safi
]
16643 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
16644 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
16645 if (peer_af_flag_check(peer
, afi
, safi
,
16646 PEER_FLAG_MAX_PREFIX_WARNING
))
16647 vty_out(vty
, " warning-only");
16648 if (peer
->pmax_restart
[afi
][safi
])
16649 vty_out(vty
, " restart %u",
16650 peer
->pmax_restart
[afi
][safi
]);
16651 if (peer_af_flag_check(peer
, afi
, safi
,
16652 PEER_FLAG_MAX_PREFIX_FORCE
))
16653 vty_out(vty
, " force");
16655 vty_out(vty
, "\n");
16658 /* maximum-prefix-out */
16659 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
16660 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
16661 addr
, peer
->pmax_out
[afi
][safi
]);
16663 /* Route server client. */
16664 if (peergroup_af_flag_check(peer
, afi
, safi
,
16665 PEER_FLAG_RSERVER_CLIENT
)) {
16666 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
16669 /* Nexthop-local unchanged. */
16670 if (peergroup_af_flag_check(peer
, afi
, safi
,
16671 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
16672 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
16675 /* allowas-in <1-10> */
16676 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
16677 if (peer_af_flag_check(peer
, afi
, safi
,
16678 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
16679 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
16680 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
16681 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
16683 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
16684 peer
->allowas_in
[afi
][safi
]);
16689 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
16690 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
16691 peer
->weight
[afi
][safi
]);
16694 bgp_config_write_filter(vty
, peer
, afi
, safi
);
16696 /* atribute-unchanged. */
16697 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
16698 || (safi
!= SAFI_EVPN
16699 && peer_af_flag_check(peer
, afi
, safi
,
16700 PEER_FLAG_NEXTHOP_UNCHANGED
))
16701 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
16703 if (!peer_group_active(peer
)
16704 || peergroup_af_flag_check(peer
, afi
, safi
,
16705 PEER_FLAG_AS_PATH_UNCHANGED
)
16706 || peergroup_af_flag_check(peer
, afi
, safi
,
16707 PEER_FLAG_NEXTHOP_UNCHANGED
)
16708 || peergroup_af_flag_check(peer
, afi
, safi
,
16709 PEER_FLAG_MED_UNCHANGED
)) {
16712 " neighbor %s attribute-unchanged%s%s%s\n",
16714 peer_af_flag_check(peer
, afi
, safi
,
16715 PEER_FLAG_AS_PATH_UNCHANGED
)
16718 peer_af_flag_check(peer
, afi
, safi
,
16719 PEER_FLAG_NEXTHOP_UNCHANGED
)
16722 peer_af_flag_check(peer
, afi
, safi
,
16723 PEER_FLAG_MED_UNCHANGED
)
16730 /* Address family based peer configuration display. */
16731 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
16735 struct peer_group
*group
;
16736 struct listnode
*node
, *nnode
;
16739 vty_frame(vty
, " !\n address-family ");
16740 if (afi
== AFI_IP
) {
16741 if (safi
== SAFI_UNICAST
)
16742 vty_frame(vty
, "ipv4 unicast");
16743 else if (safi
== SAFI_LABELED_UNICAST
)
16744 vty_frame(vty
, "ipv4 labeled-unicast");
16745 else if (safi
== SAFI_MULTICAST
)
16746 vty_frame(vty
, "ipv4 multicast");
16747 else if (safi
== SAFI_MPLS_VPN
)
16748 vty_frame(vty
, "ipv4 vpn");
16749 else if (safi
== SAFI_ENCAP
)
16750 vty_frame(vty
, "ipv4 encap");
16751 else if (safi
== SAFI_FLOWSPEC
)
16752 vty_frame(vty
, "ipv4 flowspec");
16753 } else if (afi
== AFI_IP6
) {
16754 if (safi
== SAFI_UNICAST
)
16755 vty_frame(vty
, "ipv6 unicast");
16756 else if (safi
== SAFI_LABELED_UNICAST
)
16757 vty_frame(vty
, "ipv6 labeled-unicast");
16758 else if (safi
== SAFI_MULTICAST
)
16759 vty_frame(vty
, "ipv6 multicast");
16760 else if (safi
== SAFI_MPLS_VPN
)
16761 vty_frame(vty
, "ipv6 vpn");
16762 else if (safi
== SAFI_ENCAP
)
16763 vty_frame(vty
, "ipv6 encap");
16764 else if (safi
== SAFI_FLOWSPEC
)
16765 vty_frame(vty
, "ipv6 flowspec");
16766 } else if (afi
== AFI_L2VPN
) {
16767 if (safi
== SAFI_EVPN
)
16768 vty_frame(vty
, "l2vpn evpn");
16770 vty_frame(vty
, "\n");
16772 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
16774 bgp_config_write_network(vty
, bgp
, afi
, safi
);
16776 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
16778 /* BGP flag dampening. */
16779 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
16780 bgp_config_write_damp(vty
, afi
, safi
);
16782 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
16783 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
16785 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
16786 /* Skip dynamic neighbors. */
16787 if (peer_dynamic_neighbor(peer
))
16790 /* Do not display doppelganger peers */
16791 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
16792 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
16795 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
16796 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
16798 if (safi
== SAFI_EVPN
)
16799 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
16801 if (safi
== SAFI_FLOWSPEC
)
16802 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
16804 if (safi
== SAFI_UNICAST
) {
16805 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
16806 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
16807 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
16809 vty_out(vty
, " export vpn\n");
16811 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
16812 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
16814 vty_out(vty
, " import vpn\n");
16816 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
16817 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
16820 for (ALL_LIST_ELEMENTS_RO(
16821 bgp
->vpn_policy
[afi
].import_vrf
, node
,
16823 vty_out(vty
, " import vrf %s\n", name
);
16827 vty_endframe(vty
, " exit-address-family\n");
16830 int bgp_config_write(struct vty
*vty
)
16833 struct peer_group
*group
;
16835 struct listnode
*node
, *nnode
;
16836 struct listnode
*mnode
, *mnnode
;
16838 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
16839 vty_out(vty
, "bgp route-map delay-timer %u\n",
16840 bm
->rmap_update_timer
);
16842 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
16843 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
16844 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
16845 vty_out(vty
, " %d", bm
->v_establish_wait
);
16846 vty_out(vty
, "\n");
16849 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
16850 vty_out(vty
, "bgp graceful-shutdown\n");
16852 /* No-RIB (Zebra) option flag configuration */
16853 if (bgp_option_check(BGP_OPT_NO_FIB
))
16854 vty_out(vty
, "bgp no-rib\n");
16856 /* BGP configuration. */
16857 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
16859 /* skip all auto created vrf as they dont have user config */
16860 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
16863 /* Router bgp ASN */
16864 vty_out(vty
, "router bgp %u", bgp
->as
);
16867 vty_out(vty
, " %s %s",
16868 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
16869 ? "view" : "vrf", bgp
->name
);
16870 vty_out(vty
, "\n");
16872 /* BGP fast-external-failover. */
16873 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
16874 vty_out(vty
, " no bgp fast-external-failover\n");
16876 /* BGP router ID. */
16877 if (bgp
->router_id_static
.s_addr
!= 0)
16878 vty_out(vty
, " bgp router-id %pI4\n",
16879 &bgp
->router_id_static
);
16881 /* Suppress fib pending */
16882 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
16883 vty_out(vty
, " bgp suppress-fib-pending\n");
16885 /* BGP log-neighbor-changes. */
16886 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
16887 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
16888 vty_out(vty
, " %sbgp log-neighbor-changes\n",
16889 CHECK_FLAG(bgp
->flags
,
16890 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
16894 /* BGP configuration. */
16895 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
16896 vty_out(vty
, " bgp always-compare-med\n");
16898 /* RFC8212 default eBGP policy. */
16899 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
16900 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
16901 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
16902 CHECK_FLAG(bgp
->flags
,
16903 BGP_FLAG_EBGP_REQUIRES_POLICY
)
16907 /* draft-ietf-idr-deprecate-as-set-confed-set */
16908 if (bgp
->reject_as_sets
)
16909 vty_out(vty
, " bgp reject-as-sets\n");
16911 /* BGP default ipv4-unicast. */
16912 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
))
16913 vty_out(vty
, " no bgp default ipv4-unicast\n");
16915 /* BGP default local-preference. */
16916 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
16917 vty_out(vty
, " bgp default local-preference %u\n",
16918 bgp
->default_local_pref
);
16920 /* BGP default show-hostname */
16921 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
16922 != SAVE_BGP_SHOW_HOSTNAME
)
16923 vty_out(vty
, " %sbgp default show-hostname\n",
16924 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
16928 /* BGP default show-nexthop-hostname */
16929 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
16930 != SAVE_BGP_SHOW_HOSTNAME
)
16931 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
16932 CHECK_FLAG(bgp
->flags
,
16933 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
16937 /* BGP default subgroup-pkt-queue-max. */
16938 if (bgp
->default_subgroup_pkt_queue_max
16939 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
16940 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
16941 bgp
->default_subgroup_pkt_queue_max
);
16943 /* BGP client-to-client reflection. */
16944 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
16945 vty_out(vty
, " no bgp client-to-client reflection\n");
16947 /* BGP cluster ID. */
16948 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
16949 vty_out(vty
, " bgp cluster-id %pI4\n",
16952 /* Disable ebgp connected nexthop check */
16953 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
16955 " bgp disable-ebgp-connected-route-check\n");
16957 /* Confederation identifier*/
16958 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
16959 vty_out(vty
, " bgp confederation identifier %u\n",
16962 /* Confederation peer */
16963 if (bgp
->confed_peers_cnt
> 0) {
16966 vty_out(vty
, " bgp confederation peers");
16968 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
16969 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
16971 vty_out(vty
, "\n");
16974 /* BGP deterministic-med. */
16975 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
16976 != SAVE_BGP_DETERMINISTIC_MED
)
16977 vty_out(vty
, " %sbgp deterministic-med\n",
16978 CHECK_FLAG(bgp
->flags
,
16979 BGP_FLAG_DETERMINISTIC_MED
)
16983 /* BGP update-delay. */
16984 bgp_config_write_update_delay(vty
, bgp
);
16986 if (bgp
->v_maxmed_onstartup
16987 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
16988 vty_out(vty
, " bgp max-med on-startup %u",
16989 bgp
->v_maxmed_onstartup
);
16990 if (bgp
->maxmed_onstartup_value
16991 != BGP_MAXMED_VALUE_DEFAULT
)
16992 vty_out(vty
, " %u",
16993 bgp
->maxmed_onstartup_value
);
16994 vty_out(vty
, "\n");
16996 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
16997 vty_out(vty
, " bgp max-med administrative");
16998 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
16999 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17000 vty_out(vty
, "\n");
17004 bgp_config_write_wpkt_quanta(vty
, bgp
);
17006 bgp_config_write_rpkt_quanta(vty
, bgp
);
17008 /* coalesce time */
17009 bgp_config_write_coalesce_time(vty
, bgp
);
17011 /* BGP per-instance graceful-shutdown */
17012 /* BGP-wide settings and per-instance settings are mutually
17015 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17016 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17017 vty_out(vty
, " bgp graceful-shutdown\n");
17019 /* BGP graceful-restart. */
17020 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17022 " bgp graceful-restart stalepath-time %u\n",
17023 bgp
->stalepath_time
);
17025 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17026 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17027 bgp
->restart_time
);
17029 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17031 " bgp graceful-restart select-defer-time %u\n",
17032 bgp
->select_defer_time
);
17034 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17035 vty_out(vty
, " bgp graceful-restart\n");
17037 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17038 vty_out(vty
, " bgp graceful-restart-disable\n");
17040 /* BGP graceful-restart Preserve State F bit. */
17041 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17043 " bgp graceful-restart preserve-fw-state\n");
17045 /* Stale timer for RIB */
17046 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17048 " bgp graceful-restart rib-stale-time %u\n",
17049 bgp
->rib_stale_time
);
17051 /* BGP bestpath method. */
17052 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17053 vty_out(vty
, " bgp bestpath as-path ignore\n");
17054 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17055 vty_out(vty
, " bgp bestpath as-path confed\n");
17057 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17058 if (CHECK_FLAG(bgp
->flags
,
17059 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17061 " bgp bestpath as-path multipath-relax as-set\n");
17064 " bgp bestpath as-path multipath-relax\n");
17068 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17070 " bgp route-reflector allow-outbound-policy\n");
17072 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17073 vty_out(vty
, " bgp bestpath compare-routerid\n");
17074 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17075 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17076 vty_out(vty
, " bgp bestpath med");
17077 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17078 vty_out(vty
, " confed");
17079 if (CHECK_FLAG(bgp
->flags
,
17080 BGP_FLAG_MED_MISSING_AS_WORST
))
17081 vty_out(vty
, " missing-as-worst");
17082 vty_out(vty
, "\n");
17085 /* Link bandwidth handling. */
17086 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17087 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17088 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17089 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17090 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17091 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17093 /* BGP network import check. */
17094 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17095 != SAVE_BGP_IMPORT_CHECK
)
17096 vty_out(vty
, " %sbgp network import-check\n",
17097 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17101 /* BGP timers configuration. */
17102 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17103 && bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17104 vty_out(vty
, " timers bgp %u %u\n",
17105 bgp
->default_keepalive
, bgp
->default_holdtime
);
17108 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17109 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17112 /* Normal neighbor configuration. */
17113 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17114 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17115 bgp_config_write_peer_global(vty
, bgp
, peer
);
17118 /* listen range and limit for dynamic BGP neighbors */
17119 bgp_config_write_listen(vty
, bgp
);
17122 * BGP default autoshutdown neighbors
17124 * This must be placed after any peer and peer-group
17125 * configuration, to avoid setting all peers to shutdown after
17126 * a daemon restart, which is undesired behavior. (see #2286)
17128 if (bgp
->autoshutdown
)
17129 vty_out(vty
, " bgp default shutdown\n");
17131 /* BGP instance administrative shutdown */
17132 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17133 vty_out(vty
, " bgp shutdown\n");
17135 /* IPv4 unicast configuration. */
17136 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17138 /* IPv4 multicast configuration. */
17139 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17141 /* IPv4 labeled-unicast configuration. */
17142 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17144 /* IPv4 VPN configuration. */
17145 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17147 /* ENCAPv4 configuration. */
17148 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17150 /* FLOWSPEC v4 configuration. */
17151 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17153 /* IPv6 unicast configuration. */
17154 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17156 /* IPv6 multicast configuration. */
17157 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17159 /* IPv6 labeled-unicast configuration. */
17160 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17161 SAFI_LABELED_UNICAST
);
17163 /* IPv6 VPN configuration. */
17164 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17166 /* ENCAPv6 configuration. */
17167 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17169 /* FLOWSPEC v6 configuration. */
17170 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17172 /* EVPN configuration. */
17173 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17175 hook_call(bgp_inst_config_write
, bgp
, vty
);
17177 #ifdef ENABLE_BGP_VNC
17178 bgp_rfapi_cfg_write(vty
, bgp
);
17181 vty_out(vty
, "!\n");
17187 /* BGP node structure. */
17188 static struct cmd_node bgp_node
= {
17191 .parent_node
= CONFIG_NODE
,
17192 .prompt
= "%s(config-router)# ",
17193 .config_write
= bgp_config_write
,
17196 static struct cmd_node bgp_ipv4_unicast_node
= {
17197 .name
= "bgp ipv4 unicast",
17198 .node
= BGP_IPV4_NODE
,
17199 .parent_node
= BGP_NODE
,
17200 .prompt
= "%s(config-router-af)# ",
17203 static struct cmd_node bgp_ipv4_multicast_node
= {
17204 .name
= "bgp ipv4 multicast",
17205 .node
= BGP_IPV4M_NODE
,
17206 .parent_node
= BGP_NODE
,
17207 .prompt
= "%s(config-router-af)# ",
17210 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
17211 .name
= "bgp ipv4 labeled unicast",
17212 .node
= BGP_IPV4L_NODE
,
17213 .parent_node
= BGP_NODE
,
17214 .prompt
= "%s(config-router-af)# ",
17217 static struct cmd_node bgp_ipv6_unicast_node
= {
17218 .name
= "bgp ipv6",
17219 .node
= BGP_IPV6_NODE
,
17220 .parent_node
= BGP_NODE
,
17221 .prompt
= "%s(config-router-af)# ",
17224 static struct cmd_node bgp_ipv6_multicast_node
= {
17225 .name
= "bgp ipv6 multicast",
17226 .node
= BGP_IPV6M_NODE
,
17227 .parent_node
= BGP_NODE
,
17228 .prompt
= "%s(config-router-af)# ",
17231 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
17232 .name
= "bgp ipv6 labeled unicast",
17233 .node
= BGP_IPV6L_NODE
,
17234 .parent_node
= BGP_NODE
,
17235 .prompt
= "%s(config-router-af)# ",
17238 static struct cmd_node bgp_vpnv4_node
= {
17239 .name
= "bgp vpnv4",
17240 .node
= BGP_VPNV4_NODE
,
17241 .parent_node
= BGP_NODE
,
17242 .prompt
= "%s(config-router-af)# ",
17245 static struct cmd_node bgp_vpnv6_node
= {
17246 .name
= "bgp vpnv6",
17247 .node
= BGP_VPNV6_NODE
,
17248 .parent_node
= BGP_NODE
,
17249 .prompt
= "%s(config-router-af-vpnv6)# ",
17252 static struct cmd_node bgp_evpn_node
= {
17253 .name
= "bgp evpn",
17254 .node
= BGP_EVPN_NODE
,
17255 .parent_node
= BGP_NODE
,
17256 .prompt
= "%s(config-router-evpn)# ",
17259 static struct cmd_node bgp_evpn_vni_node
= {
17260 .name
= "bgp evpn vni",
17261 .node
= BGP_EVPN_VNI_NODE
,
17262 .parent_node
= BGP_EVPN_NODE
,
17263 .prompt
= "%s(config-router-af-vni)# ",
17266 static struct cmd_node bgp_flowspecv4_node
= {
17267 .name
= "bgp ipv4 flowspec",
17268 .node
= BGP_FLOWSPECV4_NODE
,
17269 .parent_node
= BGP_NODE
,
17270 .prompt
= "%s(config-router-af)# ",
17273 static struct cmd_node bgp_flowspecv6_node
= {
17274 .name
= "bgp ipv6 flowspec",
17275 .node
= BGP_FLOWSPECV6_NODE
,
17276 .parent_node
= BGP_NODE
,
17277 .prompt
= "%s(config-router-af-vpnv6)# ",
17280 static void community_list_vty(void);
17282 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
17286 struct listnode
*lnbgp
, *lnpeer
;
17288 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17289 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
17290 /* only provide suggestions on the appropriate input
17292 * they'll otherwise show up multiple times */
17293 enum cmd_token_type match_type
;
17294 char *name
= peer
->host
;
17296 if (peer
->conf_if
) {
17297 match_type
= VARIABLE_TKN
;
17298 name
= peer
->conf_if
;
17299 } else if (strchr(peer
->host
, ':'))
17300 match_type
= IPV6_TKN
;
17302 match_type
= IPV4_TKN
;
17304 if (token
->type
!= match_type
)
17307 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
17312 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
17313 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
17314 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
17315 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
17316 {.completions
= NULL
}};
17318 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
17321 struct peer_group
*group
;
17322 struct listnode
*lnbgp
, *lnpeer
;
17324 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17325 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
17326 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
17331 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
17332 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
17333 {.completions
= NULL
} };
17335 void bgp_vty_init(void)
17337 cmd_variable_handler_register(bgp_var_neighbor
);
17338 cmd_variable_handler_register(bgp_var_peergroup
);
17340 /* Install bgp top node. */
17341 install_node(&bgp_node
);
17342 install_node(&bgp_ipv4_unicast_node
);
17343 install_node(&bgp_ipv4_multicast_node
);
17344 install_node(&bgp_ipv4_labeled_unicast_node
);
17345 install_node(&bgp_ipv6_unicast_node
);
17346 install_node(&bgp_ipv6_multicast_node
);
17347 install_node(&bgp_ipv6_labeled_unicast_node
);
17348 install_node(&bgp_vpnv4_node
);
17349 install_node(&bgp_vpnv6_node
);
17350 install_node(&bgp_evpn_node
);
17351 install_node(&bgp_evpn_vni_node
);
17352 install_node(&bgp_flowspecv4_node
);
17353 install_node(&bgp_flowspecv6_node
);
17355 /* Install default VTY commands to new nodes. */
17356 install_default(BGP_NODE
);
17357 install_default(BGP_IPV4_NODE
);
17358 install_default(BGP_IPV4M_NODE
);
17359 install_default(BGP_IPV4L_NODE
);
17360 install_default(BGP_IPV6_NODE
);
17361 install_default(BGP_IPV6M_NODE
);
17362 install_default(BGP_IPV6L_NODE
);
17363 install_default(BGP_VPNV4_NODE
);
17364 install_default(BGP_VPNV6_NODE
);
17365 install_default(BGP_FLOWSPECV4_NODE
);
17366 install_default(BGP_FLOWSPECV6_NODE
);
17367 install_default(BGP_EVPN_NODE
);
17368 install_default(BGP_EVPN_VNI_NODE
);
17370 /* "bgp local-mac" hidden commands. */
17371 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
17372 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
17374 /* bgp route-map delay-timer commands. */
17375 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17376 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17378 /* global bgp update-delay command */
17379 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
17380 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
17382 /* global bgp graceful-shutdown command */
17383 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
17384 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
17386 /* Dummy commands (Currently not supported) */
17387 install_element(BGP_NODE
, &no_synchronization_cmd
);
17388 install_element(BGP_NODE
, &no_auto_summary_cmd
);
17390 /* "router bgp" commands. */
17391 install_element(CONFIG_NODE
, &router_bgp_cmd
);
17393 /* "no router bgp" commands. */
17394 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
17396 /* "bgp router-id" commands. */
17397 install_element(BGP_NODE
, &bgp_router_id_cmd
);
17398 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
17400 /* "bgp suppress-fib-pending" command */
17401 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
17403 /* "bgp cluster-id" commands. */
17404 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
17405 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
17407 /* "bgp no-rib" commands. */
17408 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
17409 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
17411 /* "bgp confederation" commands. */
17412 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
17413 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
17415 /* "bgp confederation peers" commands. */
17416 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
17417 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
17419 /* bgp max-med command */
17420 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
17421 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
17422 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
17423 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
17424 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
17426 /* bgp disable-ebgp-connected-nh-check */
17427 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
17428 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
17430 /* bgp update-delay command */
17431 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
17432 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
17434 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
17435 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
17437 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
17438 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
17440 /* "maximum-paths" commands. */
17441 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
17442 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
17443 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
17444 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
17445 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
17446 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
17447 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
17448 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
17449 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
17450 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
17451 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17452 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17453 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
17454 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17455 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17457 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
17458 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
17459 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17460 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17461 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17462 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
17463 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
17464 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17465 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17466 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17468 /* "timers bgp" commands. */
17469 install_element(BGP_NODE
, &bgp_timers_cmd
);
17470 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
17472 /* route-map delay-timer commands - per instance for backwards compat.
17474 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17475 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17477 /* "bgp client-to-client reflection" commands */
17478 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
17479 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
17481 /* "bgp always-compare-med" commands */
17482 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
17483 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
17485 /* bgp ebgp-requires-policy */
17486 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
17487 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
17489 /* bgp reject-as-sets */
17490 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
17491 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
17493 /* "bgp deterministic-med" commands */
17494 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
17495 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
17497 /* "bgp graceful-restart" command */
17498 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
17499 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
17501 /* "bgp graceful-restart-disable" command */
17502 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
17503 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
17505 /* "neighbor a:b:c:d graceful-restart" command */
17506 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
17507 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
17509 /* "neighbor a:b:c:d graceful-restart-disable" command */
17510 install_element(BGP_NODE
,
17511 &bgp_neighbor_graceful_restart_disable_set_cmd
);
17512 install_element(BGP_NODE
,
17513 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
17515 /* "neighbor a:b:c:d graceful-restart-helper" command */
17516 install_element(BGP_NODE
,
17517 &bgp_neighbor_graceful_restart_helper_set_cmd
);
17518 install_element(BGP_NODE
,
17519 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
17521 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
17522 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
17523 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
17524 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
17525 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
17526 install_element(BGP_NODE
,
17527 &no_bgp_graceful_restart_select_defer_time_cmd
);
17528 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
17529 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
17531 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
17532 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
17533 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
17534 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
17536 /* "bgp graceful-shutdown" commands */
17537 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
17538 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
17540 /* "bgp fast-external-failover" commands */
17541 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
17542 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
17544 /* "bgp bestpath compare-routerid" commands */
17545 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
17546 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
17548 /* "bgp bestpath as-path ignore" commands */
17549 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
17550 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
17552 /* "bgp bestpath as-path confed" commands */
17553 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
17554 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
17556 /* "bgp bestpath as-path multipath-relax" commands */
17557 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
17558 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
17560 /* "bgp log-neighbor-changes" commands */
17561 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
17562 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
17564 /* "bgp bestpath med" commands */
17565 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
17566 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
17568 /* "bgp bestpath bandwidth" commands */
17569 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
17570 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
17572 /* "no bgp default ipv4-unicast" commands. */
17573 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
17574 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
17576 /* "bgp network import-check" commands. */
17577 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
17578 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
17579 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
17581 /* "bgp default local-preference" commands. */
17582 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
17583 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
17585 /* bgp default show-hostname */
17586 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
17587 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
17589 /* bgp default show-nexthop-hostname */
17590 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
17591 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
17593 /* "bgp default subgroup-pkt-queue-max" commands. */
17594 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
17595 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
17597 /* bgp ibgp-allow-policy-mods command */
17598 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
17599 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
17601 /* "bgp listen limit" commands. */
17602 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
17603 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
17605 /* "bgp listen range" commands. */
17606 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
17607 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
17609 /* "bgp default shutdown" command */
17610 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
17612 /* "bgp shutdown" commands */
17613 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
17614 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
17615 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
17616 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
17618 /* "neighbor remote-as" commands. */
17619 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
17620 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
17621 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
17622 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
17623 install_element(BGP_NODE
,
17624 &neighbor_interface_v6only_config_remote_as_cmd
);
17625 install_element(BGP_NODE
, &no_neighbor_cmd
);
17626 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
17628 /* "neighbor peer-group" commands. */
17629 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
17630 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
17631 install_element(BGP_NODE
,
17632 &no_neighbor_interface_peer_group_remote_as_cmd
);
17634 /* "neighbor local-as" commands. */
17635 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
17636 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
17637 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
17638 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
17640 /* "neighbor solo" commands. */
17641 install_element(BGP_NODE
, &neighbor_solo_cmd
);
17642 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
17644 /* "neighbor password" commands. */
17645 install_element(BGP_NODE
, &neighbor_password_cmd
);
17646 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
17648 /* "neighbor activate" commands. */
17649 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
17650 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
17651 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
17652 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
17653 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
17654 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
17655 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
17656 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
17657 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
17658 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
17659 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
17660 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
17662 /* "no neighbor activate" commands. */
17663 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
17664 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
17665 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
17666 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
17667 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
17668 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
17669 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
17670 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
17671 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
17672 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
17673 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
17674 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
17676 /* "neighbor peer-group" set commands. */
17677 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
17678 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17679 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17680 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17681 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17682 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17683 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17684 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17685 install_element(BGP_FLOWSPECV4_NODE
,
17686 &neighbor_set_peer_group_hidden_cmd
);
17687 install_element(BGP_FLOWSPECV6_NODE
,
17688 &neighbor_set_peer_group_hidden_cmd
);
17690 /* "no neighbor peer-group unset" commands. */
17691 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
17692 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17693 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17694 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17695 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17696 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17697 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17698 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17699 install_element(BGP_FLOWSPECV4_NODE
,
17700 &no_neighbor_set_peer_group_hidden_cmd
);
17701 install_element(BGP_FLOWSPECV6_NODE
,
17702 &no_neighbor_set_peer_group_hidden_cmd
);
17704 /* "neighbor softreconfiguration inbound" commands.*/
17705 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
17706 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
17707 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
17708 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17709 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
17710 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17711 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
17712 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17713 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
17714 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17715 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
17716 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17717 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
17718 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17719 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
17720 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17721 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
17722 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17723 install_element(BGP_FLOWSPECV4_NODE
,
17724 &neighbor_soft_reconfiguration_cmd
);
17725 install_element(BGP_FLOWSPECV4_NODE
,
17726 &no_neighbor_soft_reconfiguration_cmd
);
17727 install_element(BGP_FLOWSPECV6_NODE
,
17728 &neighbor_soft_reconfiguration_cmd
);
17729 install_element(BGP_FLOWSPECV6_NODE
,
17730 &no_neighbor_soft_reconfiguration_cmd
);
17731 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
17732 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17734 /* "neighbor attribute-unchanged" commands. */
17735 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
17736 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
17737 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
17738 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
17739 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
17740 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
17741 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
17742 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
17743 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
17744 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
17745 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
17746 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
17747 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
17748 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
17749 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
17750 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
17751 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
17752 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
17754 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
17755 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
17757 /* "nexthop-local unchanged" commands */
17758 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
17759 install_element(BGP_IPV6_NODE
,
17760 &no_neighbor_nexthop_local_unchanged_cmd
);
17762 /* "neighbor next-hop-self" commands. */
17763 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
17764 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
17765 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
17766 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
17767 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
17768 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
17769 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
17770 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
17771 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
17772 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
17773 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
17774 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
17775 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
17776 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
17777 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
17778 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
17779 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
17780 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
17781 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
17782 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
17784 /* "neighbor next-hop-self force" commands. */
17785 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
17786 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
17787 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17788 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
17789 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
17790 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17791 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17792 install_element(BGP_IPV4_NODE
,
17793 &no_neighbor_nexthop_self_all_hidden_cmd
);
17794 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
17795 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17796 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17797 install_element(BGP_IPV4M_NODE
,
17798 &no_neighbor_nexthop_self_all_hidden_cmd
);
17799 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
17800 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17801 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17802 install_element(BGP_IPV4L_NODE
,
17803 &no_neighbor_nexthop_self_all_hidden_cmd
);
17804 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
17805 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17806 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17807 install_element(BGP_IPV6_NODE
,
17808 &no_neighbor_nexthop_self_all_hidden_cmd
);
17809 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
17810 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17811 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17812 install_element(BGP_IPV6M_NODE
,
17813 &no_neighbor_nexthop_self_all_hidden_cmd
);
17814 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
17815 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17816 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17817 install_element(BGP_IPV6L_NODE
,
17818 &no_neighbor_nexthop_self_all_hidden_cmd
);
17819 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
17820 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17821 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17822 install_element(BGP_VPNV4_NODE
,
17823 &no_neighbor_nexthop_self_all_hidden_cmd
);
17824 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
17825 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17826 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17827 install_element(BGP_VPNV6_NODE
,
17828 &no_neighbor_nexthop_self_all_hidden_cmd
);
17829 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
17830 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17832 /* "neighbor as-override" commands. */
17833 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
17834 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
17835 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
17836 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
17837 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
17838 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
17839 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
17840 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
17841 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
17842 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
17843 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
17844 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
17845 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
17846 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
17847 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
17848 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
17849 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
17850 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
17852 /* "neighbor remove-private-AS" commands. */
17853 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
17854 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
17855 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
17856 install_element(BGP_NODE
,
17857 &no_neighbor_remove_private_as_all_hidden_cmd
);
17858 install_element(BGP_NODE
,
17859 &neighbor_remove_private_as_replace_as_hidden_cmd
);
17860 install_element(BGP_NODE
,
17861 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
17862 install_element(BGP_NODE
,
17863 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
17866 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
17867 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
17868 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
17869 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
17870 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
17871 install_element(BGP_IPV4_NODE
,
17872 &neighbor_remove_private_as_replace_as_cmd
);
17873 install_element(BGP_IPV4_NODE
,
17874 &no_neighbor_remove_private_as_replace_as_cmd
);
17875 install_element(BGP_IPV4_NODE
,
17876 &neighbor_remove_private_as_all_replace_as_cmd
);
17877 install_element(BGP_IPV4_NODE
,
17878 &no_neighbor_remove_private_as_all_replace_as_cmd
);
17879 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
17880 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
17881 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
17882 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
17883 install_element(BGP_IPV4M_NODE
,
17884 &neighbor_remove_private_as_replace_as_cmd
);
17885 install_element(BGP_IPV4M_NODE
,
17886 &no_neighbor_remove_private_as_replace_as_cmd
);
17887 install_element(BGP_IPV4M_NODE
,
17888 &neighbor_remove_private_as_all_replace_as_cmd
);
17889 install_element(BGP_IPV4M_NODE
,
17890 &no_neighbor_remove_private_as_all_replace_as_cmd
);
17891 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
17892 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
17893 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
17894 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
17895 install_element(BGP_IPV4L_NODE
,
17896 &neighbor_remove_private_as_replace_as_cmd
);
17897 install_element(BGP_IPV4L_NODE
,
17898 &no_neighbor_remove_private_as_replace_as_cmd
);
17899 install_element(BGP_IPV4L_NODE
,
17900 &neighbor_remove_private_as_all_replace_as_cmd
);
17901 install_element(BGP_IPV4L_NODE
,
17902 &no_neighbor_remove_private_as_all_replace_as_cmd
);
17903 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
17904 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
17905 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
17906 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
17907 install_element(BGP_IPV6_NODE
,
17908 &neighbor_remove_private_as_replace_as_cmd
);
17909 install_element(BGP_IPV6_NODE
,
17910 &no_neighbor_remove_private_as_replace_as_cmd
);
17911 install_element(BGP_IPV6_NODE
,
17912 &neighbor_remove_private_as_all_replace_as_cmd
);
17913 install_element(BGP_IPV6_NODE
,
17914 &no_neighbor_remove_private_as_all_replace_as_cmd
);
17915 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
17916 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
17917 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
17918 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
17919 install_element(BGP_IPV6M_NODE
,
17920 &neighbor_remove_private_as_replace_as_cmd
);
17921 install_element(BGP_IPV6M_NODE
,
17922 &no_neighbor_remove_private_as_replace_as_cmd
);
17923 install_element(BGP_IPV6M_NODE
,
17924 &neighbor_remove_private_as_all_replace_as_cmd
);
17925 install_element(BGP_IPV6M_NODE
,
17926 &no_neighbor_remove_private_as_all_replace_as_cmd
);
17927 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
17928 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
17929 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
17930 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
17931 install_element(BGP_IPV6L_NODE
,
17932 &neighbor_remove_private_as_replace_as_cmd
);
17933 install_element(BGP_IPV6L_NODE
,
17934 &no_neighbor_remove_private_as_replace_as_cmd
);
17935 install_element(BGP_IPV6L_NODE
,
17936 &neighbor_remove_private_as_all_replace_as_cmd
);
17937 install_element(BGP_IPV6L_NODE
,
17938 &no_neighbor_remove_private_as_all_replace_as_cmd
);
17939 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
17940 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
17941 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
17942 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
17943 install_element(BGP_VPNV4_NODE
,
17944 &neighbor_remove_private_as_replace_as_cmd
);
17945 install_element(BGP_VPNV4_NODE
,
17946 &no_neighbor_remove_private_as_replace_as_cmd
);
17947 install_element(BGP_VPNV4_NODE
,
17948 &neighbor_remove_private_as_all_replace_as_cmd
);
17949 install_element(BGP_VPNV4_NODE
,
17950 &no_neighbor_remove_private_as_all_replace_as_cmd
);
17951 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
17952 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
17953 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
17954 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
17955 install_element(BGP_VPNV6_NODE
,
17956 &neighbor_remove_private_as_replace_as_cmd
);
17957 install_element(BGP_VPNV6_NODE
,
17958 &no_neighbor_remove_private_as_replace_as_cmd
);
17959 install_element(BGP_VPNV6_NODE
,
17960 &neighbor_remove_private_as_all_replace_as_cmd
);
17961 install_element(BGP_VPNV6_NODE
,
17962 &no_neighbor_remove_private_as_all_replace_as_cmd
);
17964 /* "neighbor send-community" commands.*/
17965 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
17966 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
17967 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
17968 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
17969 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
17970 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
17971 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
17972 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
17973 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
17974 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
17975 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
17976 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
17977 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
17978 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
17979 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
17980 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
17981 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
17982 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
17983 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
17984 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
17985 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
17986 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
17987 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
17988 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
17989 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
17990 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
17991 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
17992 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
17993 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
17994 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
17995 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
17996 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
17997 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
17998 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
17999 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
18000 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
18002 /* "neighbor route-reflector" commands.*/
18003 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
18004 install_element(BGP_NODE
,
18005 &no_neighbor_route_reflector_client_hidden_cmd
);
18006 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
18007 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
18008 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
18009 install_element(BGP_IPV4M_NODE
,
18010 &no_neighbor_route_reflector_client_cmd
);
18011 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
18012 install_element(BGP_IPV4L_NODE
,
18013 &no_neighbor_route_reflector_client_cmd
);
18014 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
18015 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
18016 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
18017 install_element(BGP_IPV6M_NODE
,
18018 &no_neighbor_route_reflector_client_cmd
);
18019 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
18020 install_element(BGP_IPV6L_NODE
,
18021 &no_neighbor_route_reflector_client_cmd
);
18022 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
18023 install_element(BGP_VPNV4_NODE
,
18024 &no_neighbor_route_reflector_client_cmd
);
18025 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
18026 install_element(BGP_VPNV6_NODE
,
18027 &no_neighbor_route_reflector_client_cmd
);
18028 install_element(BGP_FLOWSPECV4_NODE
,
18029 &neighbor_route_reflector_client_cmd
);
18030 install_element(BGP_FLOWSPECV4_NODE
,
18031 &no_neighbor_route_reflector_client_cmd
);
18032 install_element(BGP_FLOWSPECV6_NODE
,
18033 &neighbor_route_reflector_client_cmd
);
18034 install_element(BGP_FLOWSPECV6_NODE
,
18035 &no_neighbor_route_reflector_client_cmd
);
18036 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
18037 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
18039 /* "neighbor route-server" commands.*/
18040 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
18041 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
18042 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
18043 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
18044 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
18045 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
18046 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
18047 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
18048 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
18049 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
18050 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
18051 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
18052 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
18053 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
18054 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
18055 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
18056 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
18057 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
18058 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
18059 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
18060 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
18061 install_element(BGP_FLOWSPECV4_NODE
,
18062 &no_neighbor_route_server_client_cmd
);
18063 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
18064 install_element(BGP_FLOWSPECV6_NODE
,
18065 &no_neighbor_route_server_client_cmd
);
18067 /* "neighbor addpath-tx-all-paths" commands.*/
18068 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
18069 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
18070 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18071 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18072 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18073 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18074 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18075 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18076 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18077 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18078 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18079 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18080 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18081 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18082 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18083 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18084 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18085 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18087 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
18088 install_element(BGP_NODE
,
18089 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18090 install_element(BGP_NODE
,
18091 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18092 install_element(BGP_IPV4_NODE
,
18093 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18094 install_element(BGP_IPV4_NODE
,
18095 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18096 install_element(BGP_IPV4M_NODE
,
18097 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18098 install_element(BGP_IPV4M_NODE
,
18099 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18100 install_element(BGP_IPV4L_NODE
,
18101 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18102 install_element(BGP_IPV4L_NODE
,
18103 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18104 install_element(BGP_IPV6_NODE
,
18105 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18106 install_element(BGP_IPV6_NODE
,
18107 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18108 install_element(BGP_IPV6M_NODE
,
18109 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18110 install_element(BGP_IPV6M_NODE
,
18111 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18112 install_element(BGP_IPV6L_NODE
,
18113 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18114 install_element(BGP_IPV6L_NODE
,
18115 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18116 install_element(BGP_VPNV4_NODE
,
18117 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18118 install_element(BGP_VPNV4_NODE
,
18119 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18120 install_element(BGP_VPNV6_NODE
,
18121 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18122 install_element(BGP_VPNV6_NODE
,
18123 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18125 /* "neighbor sender-as-path-loop-detection" commands. */
18126 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
18127 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
18129 /* "neighbor passive" commands. */
18130 install_element(BGP_NODE
, &neighbor_passive_cmd
);
18131 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
18134 /* "neighbor shutdown" commands. */
18135 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
18136 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
18137 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
18138 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
18139 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
18140 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
18142 /* "neighbor capability extended-nexthop" commands.*/
18143 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
18144 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
18146 /* "neighbor capability orf prefix-list" commands.*/
18147 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
18148 install_element(BGP_NODE
,
18149 &no_neighbor_capability_orf_prefix_hidden_cmd
);
18150 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
18151 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18152 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18153 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18154 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18155 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18156 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
18157 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18158 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18159 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18160 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18161 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18163 /* "neighbor capability dynamic" commands.*/
18164 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
18165 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
18167 /* "neighbor dont-capability-negotiate" commands. */
18168 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
18169 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
18171 /* "neighbor ebgp-multihop" commands. */
18172 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
18173 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
18174 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
18176 /* "neighbor disable-connected-check" commands. */
18177 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
18178 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
18180 /* "neighbor enforce-first-as" commands. */
18181 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
18182 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
18184 /* "neighbor description" commands. */
18185 install_element(BGP_NODE
, &neighbor_description_cmd
);
18186 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
18187 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
18189 /* "neighbor update-source" commands. "*/
18190 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
18191 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
18193 /* "neighbor default-originate" commands. */
18194 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
18195 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
18196 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
18197 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
18198 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
18199 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
18200 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
18201 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
18202 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
18203 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
18204 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
18205 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
18206 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
18207 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
18208 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
18209 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
18210 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
18211 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
18212 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
18213 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
18214 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
18216 /* "neighbor port" commands. */
18217 install_element(BGP_NODE
, &neighbor_port_cmd
);
18218 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
18220 /* "neighbor weight" commands. */
18221 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
18222 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
18224 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
18225 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
18226 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
18227 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
18228 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
18229 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
18230 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
18231 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
18232 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
18233 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
18234 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
18235 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
18236 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
18237 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
18238 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
18239 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
18241 /* "neighbor override-capability" commands. */
18242 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
18243 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
18245 /* "neighbor strict-capability-match" commands. */
18246 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
18247 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
18249 /* "neighbor timers" commands. */
18250 install_element(BGP_NODE
, &neighbor_timers_cmd
);
18251 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
18253 /* "neighbor timers connect" commands. */
18254 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
18255 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
18257 /* "neighbor advertisement-interval" commands. */
18258 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
18259 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
18261 /* "neighbor interface" commands. */
18262 install_element(BGP_NODE
, &neighbor_interface_cmd
);
18263 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
18265 /* "neighbor distribute" commands. */
18266 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
18267 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
18268 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
18269 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
18270 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
18271 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
18272 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
18273 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
18274 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
18275 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
18276 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
18277 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
18278 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
18279 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
18280 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
18281 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
18282 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
18283 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
18285 /* "neighbor prefix-list" commands. */
18286 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
18287 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
18288 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
18289 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
18290 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
18291 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
18292 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
18293 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
18294 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
18295 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
18296 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
18297 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
18298 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
18299 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
18300 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
18301 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
18302 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
18303 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
18304 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
18305 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
18306 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
18307 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
18309 /* "neighbor filter-list" commands. */
18310 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
18311 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
18312 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
18313 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
18314 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
18315 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
18316 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
18317 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
18318 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
18319 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
18320 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
18321 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
18322 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
18323 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
18324 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
18325 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
18326 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
18327 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
18328 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
18329 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
18330 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
18331 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
18333 /* "neighbor route-map" commands. */
18334 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
18335 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
18336 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
18337 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
18338 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
18339 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
18340 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
18341 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
18342 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
18343 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
18344 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
18345 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
18346 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
18347 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
18348 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
18349 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
18350 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
18351 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
18352 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
18353 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
18354 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
18355 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
18356 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
18357 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
18359 /* "neighbor unsuppress-map" commands. */
18360 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
18361 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
18362 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
18363 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18364 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
18365 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18366 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
18367 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18368 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
18369 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18370 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
18371 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18372 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
18373 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18374 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
18375 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18376 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
18377 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18379 /* "neighbor advertise-map" commands. */
18380 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
18381 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
18382 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
18383 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
18384 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
18385 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
18386 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
18387 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
18388 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
18390 /* neighbor maximum-prefix-out commands. */
18391 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
18392 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18393 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18394 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18395 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18396 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18397 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18398 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18399 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18400 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18401 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18402 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18403 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18404 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18405 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18406 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18407 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18408 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18410 /* "neighbor maximum-prefix" commands. */
18411 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
18412 install_element(BGP_NODE
,
18413 &neighbor_maximum_prefix_threshold_hidden_cmd
);
18414 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
18415 install_element(BGP_NODE
,
18416 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
18417 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
18418 install_element(BGP_NODE
,
18419 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
18420 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
18421 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
18422 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18423 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18424 install_element(BGP_IPV4_NODE
,
18425 &neighbor_maximum_prefix_threshold_warning_cmd
);
18426 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18427 install_element(BGP_IPV4_NODE
,
18428 &neighbor_maximum_prefix_threshold_restart_cmd
);
18429 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18430 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
18431 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18432 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18433 install_element(BGP_IPV4M_NODE
,
18434 &neighbor_maximum_prefix_threshold_warning_cmd
);
18435 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18436 install_element(BGP_IPV4M_NODE
,
18437 &neighbor_maximum_prefix_threshold_restart_cmd
);
18438 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18439 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
18440 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18441 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18442 install_element(BGP_IPV4L_NODE
,
18443 &neighbor_maximum_prefix_threshold_warning_cmd
);
18444 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18445 install_element(BGP_IPV4L_NODE
,
18446 &neighbor_maximum_prefix_threshold_restart_cmd
);
18447 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18448 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
18449 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18450 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18451 install_element(BGP_IPV6_NODE
,
18452 &neighbor_maximum_prefix_threshold_warning_cmd
);
18453 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18454 install_element(BGP_IPV6_NODE
,
18455 &neighbor_maximum_prefix_threshold_restart_cmd
);
18456 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18457 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
18458 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18459 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18460 install_element(BGP_IPV6M_NODE
,
18461 &neighbor_maximum_prefix_threshold_warning_cmd
);
18462 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18463 install_element(BGP_IPV6M_NODE
,
18464 &neighbor_maximum_prefix_threshold_restart_cmd
);
18465 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18466 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
18467 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18468 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18469 install_element(BGP_IPV6L_NODE
,
18470 &neighbor_maximum_prefix_threshold_warning_cmd
);
18471 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18472 install_element(BGP_IPV6L_NODE
,
18473 &neighbor_maximum_prefix_threshold_restart_cmd
);
18474 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18475 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
18476 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18477 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18478 install_element(BGP_VPNV4_NODE
,
18479 &neighbor_maximum_prefix_threshold_warning_cmd
);
18480 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18481 install_element(BGP_VPNV4_NODE
,
18482 &neighbor_maximum_prefix_threshold_restart_cmd
);
18483 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18484 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
18485 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18486 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18487 install_element(BGP_VPNV6_NODE
,
18488 &neighbor_maximum_prefix_threshold_warning_cmd
);
18489 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18490 install_element(BGP_VPNV6_NODE
,
18491 &neighbor_maximum_prefix_threshold_restart_cmd
);
18492 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18494 /* "neighbor allowas-in" */
18495 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
18496 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
18497 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
18498 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
18499 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
18500 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
18501 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
18502 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
18503 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
18504 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
18505 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
18506 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
18507 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
18508 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
18509 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
18510 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
18511 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
18512 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
18513 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
18514 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
18516 /* address-family commands. */
18517 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
18518 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
18519 #ifdef KEEP_OLD_VPN_COMMANDS
18520 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
18521 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
18522 #endif /* KEEP_OLD_VPN_COMMANDS */
18524 install_element(BGP_NODE
, &address_family_evpn_cmd
);
18526 /* "exit-address-family" command. */
18527 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
18528 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
18529 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
18530 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
18531 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
18532 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
18533 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
18534 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
18535 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
18536 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
18537 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
18539 /* "clear ip bgp commands" */
18540 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
18542 /* clear ip bgp prefix */
18543 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
18544 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
18545 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
18547 /* "show [ip] bgp summary" commands. */
18548 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
18549 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
18550 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
18551 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
18552 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
18553 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
18554 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
18556 /* "show [ip] bgp neighbors" commands. */
18557 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
18559 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
18561 /* "show [ip] bgp peer-group" commands. */
18562 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
18564 /* "show [ip] bgp paths" commands. */
18565 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
18567 /* "show [ip] bgp community" commands. */
18568 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
18570 /* "show ip bgp large-community" commands. */
18571 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
18572 /* "show [ip] bgp attribute-info" commands. */
18573 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
18574 /* "show [ip] bgp route-leak" command */
18575 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
18577 /* "redistribute" commands. */
18578 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
18579 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
18580 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
18581 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
18582 install_element(BGP_NODE
,
18583 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
18584 install_element(BGP_NODE
,
18585 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
18586 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
18587 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
18588 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
18589 install_element(BGP_NODE
,
18590 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
18591 install_element(BGP_NODE
,
18592 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
18593 install_element(BGP_NODE
,
18594 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
18595 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
18596 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
18597 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
18598 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
18599 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
18600 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
18601 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
18602 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
18603 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
18604 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
18605 install_element(BGP_IPV4_NODE
,
18606 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
18607 install_element(BGP_IPV4_NODE
,
18608 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
18609 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
18610 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
18611 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
18612 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
18613 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
18614 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
18616 /* import|export vpn [route-map WORD] */
18617 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
18618 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
18620 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
18621 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
18623 /* ttl_security commands */
18624 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
18625 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
18627 /* "show [ip] bgp memory" commands. */
18628 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
18630 /* "show bgp martian next-hop" */
18631 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
18633 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
18635 /* "show [ip] bgp views" commands. */
18636 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
18638 /* "show [ip] bgp vrfs" commands. */
18639 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
18641 /* Community-list. */
18642 community_list_vty();
18644 /* vpn-policy commands */
18645 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
18646 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
18647 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
18648 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
18649 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
18650 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
18651 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
18652 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
18653 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
18654 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
18655 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
18656 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
18658 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
18659 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
18661 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
18662 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
18663 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
18664 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
18665 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
18666 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
18667 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
18668 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
18669 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
18670 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
18673 #include "memory.h"
18674 #include "bgp_regex.h"
18675 #include "bgp_clist.h"
18676 #include "bgp_ecommunity.h"
18678 /* VTY functions. */
18680 /* Direction value to string conversion. */
18681 static const char *community_direct_str(int direct
)
18684 case COMMUNITY_DENY
:
18686 case COMMUNITY_PERMIT
:
18693 /* Display error string. */
18694 static void community_list_perror(struct vty
*vty
, int ret
)
18697 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
18698 vty_out(vty
, "%% Can't find community-list\n");
18700 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
18701 vty_out(vty
, "%% Malformed community-list value\n");
18703 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
18705 "%% Community name conflict, previously defined as standard community\n");
18707 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
18709 "%% Community name conflict, previously defined as expanded community\n");
18714 /* "community-list" keyword help string. */
18715 #define COMMUNITY_LIST_STR "Add a community list entry\n"
18717 /*community-list standard */
18718 DEFUN (community_list_standard
,
18719 bgp_community_list_standard_cmd
,
18720 "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
18723 "Community list number (standard)\n"
18724 "Add an standard community-list entry\n"
18725 "Community list name\n"
18726 "Sequence number of an entry\n"
18727 "Sequence number\n"
18728 "Specify community to reject\n"
18729 "Specify community to accept\n"
18732 char *cl_name_or_number
= NULL
;
18735 int style
= COMMUNITY_LIST_STANDARD
;
18738 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
18740 seq
= argv
[idx
]->arg
;
18743 argv_find(argv
, argc
, "(1-99)", &idx
);
18744 argv_find(argv
, argc
, "WORD", &idx
);
18745 cl_name_or_number
= argv
[idx
]->arg
;
18746 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
18748 argv_find(argv
, argc
, "AA:NN", &idx
);
18749 char *str
= argv_concat(argv
, argc
, idx
);
18751 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
18754 XFREE(MTYPE_TMP
, str
);
18757 /* Display error string. */
18758 community_list_perror(vty
, ret
);
18759 return CMD_WARNING_CONFIG_FAILED
;
18762 return CMD_SUCCESS
;
18765 DEFUN (no_community_list_standard_all
,
18766 no_bgp_community_list_standard_all_cmd
,
18767 "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
18771 "Community list number (standard)\n"
18772 "Add an standard community-list entry\n"
18773 "Community list name\n"
18774 "Sequence number of an entry\n"
18775 "Sequence number\n"
18776 "Specify community to reject\n"
18777 "Specify community to accept\n"
18780 char *cl_name_or_number
= NULL
;
18783 int style
= COMMUNITY_LIST_STANDARD
;
18787 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
18789 seq
= argv
[idx
]->arg
;
18792 argv_find(argv
, argc
, "permit", &idx
);
18793 argv_find(argv
, argc
, "deny", &idx
);
18796 direct
= argv_find(argv
, argc
, "permit", &idx
)
18801 argv_find(argv
, argc
, "AA:NN", &idx
);
18802 str
= argv_concat(argv
, argc
, idx
);
18806 argv_find(argv
, argc
, "(1-99)", &idx
);
18807 argv_find(argv
, argc
, "WORD", &idx
);
18808 cl_name_or_number
= argv
[idx
]->arg
;
18810 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
18813 XFREE(MTYPE_TMP
, str
);
18816 community_list_perror(vty
, ret
);
18817 return CMD_WARNING_CONFIG_FAILED
;
18820 return CMD_SUCCESS
;
18823 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
18824 "no bgp community-list <(1-99)|standard WORD>",
18825 NO_STR BGP_STR COMMUNITY_LIST_STR
18826 "Community list number (standard)\n"
18827 "Add an standard community-list entry\n"
18828 "Community list name\n")
18830 /*community-list expanded */
18831 DEFUN (community_list_expanded_all
,
18832 bgp_community_list_expanded_all_cmd
,
18833 "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
18836 "Community list number (expanded)\n"
18837 "Add an expanded community-list entry\n"
18838 "Community list name\n"
18839 "Sequence number of an entry\n"
18840 "Sequence number\n"
18841 "Specify community to reject\n"
18842 "Specify community to accept\n"
18845 char *cl_name_or_number
= NULL
;
18848 int style
= COMMUNITY_LIST_EXPANDED
;
18851 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
18853 seq
= argv
[idx
]->arg
;
18857 argv_find(argv
, argc
, "(100-500)", &idx
);
18858 argv_find(argv
, argc
, "WORD", &idx
);
18859 cl_name_or_number
= argv
[idx
]->arg
;
18860 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
18862 argv_find(argv
, argc
, "AA:NN", &idx
);
18863 char *str
= argv_concat(argv
, argc
, idx
);
18865 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
18868 XFREE(MTYPE_TMP
, str
);
18871 /* Display error string. */
18872 community_list_perror(vty
, ret
);
18873 return CMD_WARNING_CONFIG_FAILED
;
18876 return CMD_SUCCESS
;
18879 DEFUN (no_community_list_expanded_all
,
18880 no_bgp_community_list_expanded_all_cmd
,
18881 "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
18885 "Community list number (expanded)\n"
18886 "Add an expanded community-list entry\n"
18887 "Community list name\n"
18888 "Sequence number of an entry\n"
18889 "Sequence number\n"
18890 "Specify community to reject\n"
18891 "Specify community to accept\n"
18894 char *cl_name_or_number
= NULL
;
18898 int style
= COMMUNITY_LIST_EXPANDED
;
18901 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
18903 seq
= argv
[idx
]->arg
;
18906 argv_find(argv
, argc
, "permit", &idx
);
18907 argv_find(argv
, argc
, "deny", &idx
);
18910 direct
= argv_find(argv
, argc
, "permit", &idx
)
18915 argv_find(argv
, argc
, "AA:NN", &idx
);
18916 str
= argv_concat(argv
, argc
, idx
);
18920 argv_find(argv
, argc
, "(100-500)", &idx
);
18921 argv_find(argv
, argc
, "WORD", &idx
);
18922 cl_name_or_number
= argv
[idx
]->arg
;
18924 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
18927 XFREE(MTYPE_TMP
, str
);
18930 community_list_perror(vty
, ret
);
18931 return CMD_WARNING_CONFIG_FAILED
;
18934 return CMD_SUCCESS
;
18937 ALIAS(no_community_list_expanded_all
,
18938 no_bgp_community_list_expanded_all_list_cmd
,
18939 "no bgp community-list <(100-500)|expanded WORD>",
18940 NO_STR BGP_STR COMMUNITY_LIST_STR
18941 "Community list number (expanded)\n"
18942 "Add an expanded community-list entry\n"
18943 "Community list name\n")
18945 /* Return configuration string of community-list entry. */
18946 static const char *community_list_config_str(struct community_entry
*entry
)
18953 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
18954 str
= community_str(entry
->u
.com
, false);
18955 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
18956 str
= lcommunity_str(entry
->u
.lcom
, false);
18958 str
= entry
->config
;
18963 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
18965 struct community_entry
*entry
;
18967 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
18968 if (entry
== list
->head
) {
18969 if (all_digit(list
->name
))
18970 vty_out(vty
, "Community %s list %s\n",
18971 entry
->style
== COMMUNITY_LIST_STANDARD
18973 : "(expanded) access",
18976 vty_out(vty
, "Named Community %s list %s\n",
18977 entry
->style
== COMMUNITY_LIST_STANDARD
18983 vty_out(vty
, " %s\n",
18984 community_direct_str(entry
->direct
));
18986 vty_out(vty
, " %s %s\n",
18987 community_direct_str(entry
->direct
),
18988 community_list_config_str(entry
));
18992 DEFUN (show_community_list
,
18993 show_bgp_community_list_cmd
,
18994 "show bgp community-list",
18997 "List community-list\n")
18999 struct community_list
*list
;
19000 struct community_list_master
*cm
;
19002 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19004 return CMD_SUCCESS
;
19006 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19007 community_list_show(vty
, list
);
19009 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19010 community_list_show(vty
, list
);
19012 return CMD_SUCCESS
;
19015 DEFUN (show_community_list_arg
,
19016 show_bgp_community_list_arg_cmd
,
19017 "show bgp community-list <(1-500)|WORD> detail",
19020 "List community-list\n"
19021 "Community-list number\n"
19022 "Community-list name\n"
19023 "Detailed information on community-list\n")
19025 int idx_comm_list
= 3;
19026 struct community_list
*list
;
19028 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
19029 COMMUNITY_LIST_MASTER
);
19031 vty_out(vty
, "%% Can't find community-list\n");
19032 return CMD_WARNING
;
19035 community_list_show(vty
, list
);
19037 return CMD_SUCCESS
;
19041 * Large Community code.
19043 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
19044 struct cmd_token
**argv
, int style
,
19045 int reject_all_digit_name
)
19054 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19055 seq
= argv
[idx
]->arg
;
19058 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19061 /* All digit name check. */
19063 argv_find(argv
, argc
, "WORD", &idx
);
19064 argv_find(argv
, argc
, "(1-99)", &idx
);
19065 argv_find(argv
, argc
, "(100-500)", &idx
);
19066 cl_name
= argv
[idx
]->arg
;
19067 if (reject_all_digit_name
&& all_digit(cl_name
)) {
19068 vty_out(vty
, "%% Community name cannot have all digits\n");
19069 return CMD_WARNING_CONFIG_FAILED
;
19073 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
19074 argv_find(argv
, argc
, "LINE", &idx
);
19075 /* Concat community string argument. */
19077 str
= argv_concat(argv
, argc
, idx
);
19081 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
19083 /* Free temporary community list string allocated by
19085 XFREE(MTYPE_TMP
, str
);
19088 community_list_perror(vty
, ret
);
19089 return CMD_WARNING_CONFIG_FAILED
;
19091 return CMD_SUCCESS
;
19094 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
19095 struct cmd_token
**argv
, int style
)
19103 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19104 seq
= argv
[idx
]->arg
;
19107 argv_find(argv
, argc
, "permit", &idx
);
19108 argv_find(argv
, argc
, "deny", &idx
);
19111 /* Check the list direct. */
19112 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
19113 direct
= COMMUNITY_PERMIT
;
19115 direct
= COMMUNITY_DENY
;
19118 argv_find(argv
, argc
, "LINE", &idx
);
19119 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
19120 /* Concat community string argument. */
19121 str
= argv_concat(argv
, argc
, idx
);
19125 argv_find(argv
, argc
, "(1-99)", &idx
);
19126 argv_find(argv
, argc
, "(100-500)", &idx
);
19127 argv_find(argv
, argc
, "WORD", &idx
);
19129 /* Unset community list. */
19130 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
19133 /* Free temporary community list string allocated by
19135 XFREE(MTYPE_TMP
, str
);
19138 community_list_perror(vty
, ret
);
19139 return CMD_WARNING_CONFIG_FAILED
;
19142 return CMD_SUCCESS
;
19145 /* "large-community-list" keyword help string. */
19146 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
19147 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
19149 DEFUN (lcommunity_list_standard
,
19150 bgp_lcommunity_list_standard_cmd
,
19151 "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...",
19153 LCOMMUNITY_LIST_STR
19154 "Large Community list number (standard)\n"
19155 "Sequence number of an entry\n"
19156 "Sequence number\n"
19157 "Specify large community to reject\n"
19158 "Specify large community to accept\n"
19159 LCOMMUNITY_VAL_STR
)
19161 return lcommunity_list_set_vty(vty
, argc
, argv
,
19162 LARGE_COMMUNITY_LIST_STANDARD
, 0);
19165 DEFUN (lcommunity_list_expanded
,
19166 bgp_lcommunity_list_expanded_cmd
,
19167 "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...",
19169 LCOMMUNITY_LIST_STR
19170 "Large Community list number (expanded)\n"
19171 "Sequence number of an entry\n"
19172 "Sequence number\n"
19173 "Specify large community to reject\n"
19174 "Specify large community to accept\n"
19175 "An ordered list as a regular-expression\n")
19177 return lcommunity_list_set_vty(vty
, argc
, argv
,
19178 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
19181 DEFUN (lcommunity_list_name_standard
,
19182 bgp_lcommunity_list_name_standard_cmd
,
19183 "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...",
19185 LCOMMUNITY_LIST_STR
19186 "Specify standard large-community-list\n"
19187 "Large Community list name\n"
19188 "Sequence number of an entry\n"
19189 "Sequence number\n"
19190 "Specify large community to reject\n"
19191 "Specify large community to accept\n"
19192 LCOMMUNITY_VAL_STR
)
19194 return lcommunity_list_set_vty(vty
, argc
, argv
,
19195 LARGE_COMMUNITY_LIST_STANDARD
, 1);
19198 DEFUN (lcommunity_list_name_expanded
,
19199 bgp_lcommunity_list_name_expanded_cmd
,
19200 "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...",
19202 LCOMMUNITY_LIST_STR
19203 "Specify expanded large-community-list\n"
19204 "Large Community list name\n"
19205 "Sequence number of an entry\n"
19206 "Sequence number\n"
19207 "Specify large community to reject\n"
19208 "Specify large community to accept\n"
19209 "An ordered list as a regular-expression\n")
19211 return lcommunity_list_set_vty(vty
, argc
, argv
,
19212 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
19215 DEFUN (no_lcommunity_list_all
,
19216 no_bgp_lcommunity_list_all_cmd
,
19217 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
19220 LCOMMUNITY_LIST_STR
19221 "Large Community list number (standard)\n"
19222 "Large Community list number (expanded)\n"
19223 "Large Community list name\n")
19225 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19226 LARGE_COMMUNITY_LIST_STANDARD
);
19229 DEFUN (no_lcommunity_list_name_standard_all
,
19230 no_bgp_lcommunity_list_name_standard_all_cmd
,
19231 "no bgp large-community-list standard WORD",
19234 LCOMMUNITY_LIST_STR
19235 "Specify standard large-community-list\n"
19236 "Large Community list name\n")
19238 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19239 LARGE_COMMUNITY_LIST_STANDARD
);
19242 DEFUN (no_lcommunity_list_name_expanded_all
,
19243 no_bgp_lcommunity_list_name_expanded_all_cmd
,
19244 "no bgp large-community-list expanded WORD",
19247 LCOMMUNITY_LIST_STR
19248 "Specify expanded large-community-list\n"
19249 "Large Community list name\n")
19251 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19252 LARGE_COMMUNITY_LIST_EXPANDED
);
19255 DEFUN (no_lcommunity_list_standard
,
19256 no_bgp_lcommunity_list_standard_cmd
,
19257 "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...",
19260 LCOMMUNITY_LIST_STR
19261 "Large Community list number (standard)\n"
19262 "Sequence number of an entry\n"
19263 "Sequence number\n"
19264 "Specify large community to reject\n"
19265 "Specify large community to accept\n"
19266 LCOMMUNITY_VAL_STR
)
19268 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19269 LARGE_COMMUNITY_LIST_STANDARD
);
19272 DEFUN (no_lcommunity_list_expanded
,
19273 no_bgp_lcommunity_list_expanded_cmd
,
19274 "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...",
19277 LCOMMUNITY_LIST_STR
19278 "Large Community list number (expanded)\n"
19279 "Sequence number of an entry\n"
19280 "Sequence number\n"
19281 "Specify large community to reject\n"
19282 "Specify large community to accept\n"
19283 "An ordered list as a regular-expression\n")
19285 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19286 LARGE_COMMUNITY_LIST_EXPANDED
);
19289 DEFUN (no_lcommunity_list_name_standard
,
19290 no_bgp_lcommunity_list_name_standard_cmd
,
19291 "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...",
19294 LCOMMUNITY_LIST_STR
19295 "Specify standard large-community-list\n"
19296 "Large Community list name\n"
19297 "Sequence number of an entry\n"
19298 "Sequence number\n"
19299 "Specify large community to reject\n"
19300 "Specify large community to accept\n"
19301 LCOMMUNITY_VAL_STR
)
19303 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19304 LARGE_COMMUNITY_LIST_STANDARD
);
19307 DEFUN (no_lcommunity_list_name_expanded
,
19308 no_bgp_lcommunity_list_name_expanded_cmd
,
19309 "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...",
19312 LCOMMUNITY_LIST_STR
19313 "Specify expanded large-community-list\n"
19314 "Large community list name\n"
19315 "Sequence number of an entry\n"
19316 "Sequence number\n"
19317 "Specify large community to reject\n"
19318 "Specify large community to accept\n"
19319 "An ordered list as a regular-expression\n")
19321 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19322 LARGE_COMMUNITY_LIST_EXPANDED
);
19325 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
19327 struct community_entry
*entry
;
19329 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19330 if (entry
== list
->head
) {
19331 if (all_digit(list
->name
))
19332 vty_out(vty
, "Large community %s list %s\n",
19334 LARGE_COMMUNITY_LIST_STANDARD
19336 : "(expanded) access",
19340 "Named large community %s list %s\n",
19342 LARGE_COMMUNITY_LIST_STANDARD
19348 vty_out(vty
, " %s\n",
19349 community_direct_str(entry
->direct
));
19351 vty_out(vty
, " %s %s\n",
19352 community_direct_str(entry
->direct
),
19353 community_list_config_str(entry
));
19357 DEFUN (show_lcommunity_list
,
19358 show_bgp_lcommunity_list_cmd
,
19359 "show bgp large-community-list",
19362 "List large-community list\n")
19364 struct community_list
*list
;
19365 struct community_list_master
*cm
;
19367 cm
= community_list_master_lookup(bgp_clist
,
19368 LARGE_COMMUNITY_LIST_MASTER
);
19370 return CMD_SUCCESS
;
19372 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19373 lcommunity_list_show(vty
, list
);
19375 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19376 lcommunity_list_show(vty
, list
);
19378 return CMD_SUCCESS
;
19381 DEFUN (show_lcommunity_list_arg
,
19382 show_bgp_lcommunity_list_arg_cmd
,
19383 "show bgp large-community-list <(1-500)|WORD> detail",
19386 "List large-community list\n"
19387 "Large-community-list number\n"
19388 "Large-community-list name\n"
19389 "Detailed information on large-community-list\n")
19391 struct community_list
*list
;
19393 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
19394 LARGE_COMMUNITY_LIST_MASTER
);
19396 vty_out(vty
, "%% Can't find large-community-list\n");
19397 return CMD_WARNING
;
19400 lcommunity_list_show(vty
, list
);
19402 return CMD_SUCCESS
;
19405 /* "extcommunity-list" keyword help string. */
19406 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
19407 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
19409 DEFUN (extcommunity_list_standard
,
19410 bgp_extcommunity_list_standard_cmd
,
19411 "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19413 EXTCOMMUNITY_LIST_STR
19414 "Extended Community list number (standard)\n"
19415 "Specify standard extcommunity-list\n"
19416 "Community list name\n"
19417 "Sequence number of an entry\n"
19418 "Sequence number\n"
19419 "Specify community to reject\n"
19420 "Specify community to accept\n"
19421 EXTCOMMUNITY_VAL_STR
)
19423 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19425 char *cl_number_or_name
= NULL
;
19430 argv_find(argv
, argc
, "(1-99)", &idx
);
19431 argv_find(argv
, argc
, "WORD", &idx
);
19432 cl_number_or_name
= argv
[idx
]->arg
;
19434 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19435 seq
= argv
[idx
]->arg
;
19437 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19439 argv_find(argv
, argc
, "AA:NN", &idx
);
19440 char *str
= argv_concat(argv
, argc
, idx
);
19442 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19445 XFREE(MTYPE_TMP
, str
);
19448 community_list_perror(vty
, ret
);
19449 return CMD_WARNING_CONFIG_FAILED
;
19452 return CMD_SUCCESS
;
19455 DEFUN (extcommunity_list_name_expanded
,
19456 bgp_extcommunity_list_name_expanded_cmd
,
19457 "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...",
19459 EXTCOMMUNITY_LIST_STR
19460 "Extended Community list number (expanded)\n"
19461 "Specify expanded extcommunity-list\n"
19462 "Extended Community list name\n"
19463 "Sequence number of an entry\n"
19464 "Sequence number\n"
19465 "Specify community to reject\n"
19466 "Specify community to accept\n"
19467 "An ordered list as a regular-expression\n")
19469 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
19471 char *cl_number_or_name
= NULL
;
19475 argv_find(argv
, argc
, "(100-500)", &idx
);
19476 argv_find(argv
, argc
, "WORD", &idx
);
19477 cl_number_or_name
= argv
[idx
]->arg
;
19479 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19480 seq
= argv
[idx
]->arg
;
19482 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19484 argv_find(argv
, argc
, "LINE", &idx
);
19485 char *str
= argv_concat(argv
, argc
, idx
);
19487 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19490 XFREE(MTYPE_TMP
, str
);
19493 community_list_perror(vty
, ret
);
19494 return CMD_WARNING_CONFIG_FAILED
;
19497 return CMD_SUCCESS
;
19500 DEFUN (no_extcommunity_list_standard_all
,
19501 no_bgp_extcommunity_list_standard_all_cmd
,
19502 "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19505 EXTCOMMUNITY_LIST_STR
19506 "Extended Community list number (standard)\n"
19507 "Specify standard extcommunity-list\n"
19508 "Community list name\n"
19509 "Sequence number of an entry\n"
19510 "Sequence number\n"
19511 "Specify community to reject\n"
19512 "Specify community to accept\n"
19513 EXTCOMMUNITY_VAL_STR
)
19515 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19517 char *cl_number_or_name
= NULL
;
19522 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19523 seq
= argv
[idx
]->arg
;
19526 argv_find(argv
, argc
, "permit", &idx
);
19527 argv_find(argv
, argc
, "deny", &idx
);
19529 direct
= argv_find(argv
, argc
, "permit", &idx
)
19534 argv_find(argv
, argc
, "AA:NN", &idx
);
19535 str
= argv_concat(argv
, argc
, idx
);
19539 argv_find(argv
, argc
, "(1-99)", &idx
);
19540 argv_find(argv
, argc
, "WORD", &idx
);
19541 cl_number_or_name
= argv
[idx
]->arg
;
19543 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
19544 seq
, direct
, style
);
19546 XFREE(MTYPE_TMP
, str
);
19549 community_list_perror(vty
, ret
);
19550 return CMD_WARNING_CONFIG_FAILED
;
19553 return CMD_SUCCESS
;
19556 ALIAS(no_extcommunity_list_standard_all
,
19557 no_bgp_extcommunity_list_standard_all_list_cmd
,
19558 "no bgp extcommunity-list <(1-99)|standard WORD>",
19559 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
19560 "Extended Community list number (standard)\n"
19561 "Specify standard extcommunity-list\n"
19562 "Community list name\n")
19564 DEFUN (no_extcommunity_list_expanded_all
,
19565 no_bgp_extcommunity_list_expanded_all_cmd
,
19566 "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...",
19569 EXTCOMMUNITY_LIST_STR
19570 "Extended Community list number (expanded)\n"
19571 "Specify expanded extcommunity-list\n"
19572 "Extended Community list name\n"
19573 "Sequence number of an entry\n"
19574 "Sequence number\n"
19575 "Specify community to reject\n"
19576 "Specify community to accept\n"
19577 "An ordered list as a regular-expression\n")
19579 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
19581 char *cl_number_or_name
= NULL
;
19586 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19587 seq
= argv
[idx
]->arg
;
19590 argv_find(argv
, argc
, "permit", &idx
);
19591 argv_find(argv
, argc
, "deny", &idx
);
19594 direct
= argv_find(argv
, argc
, "permit", &idx
)
19599 argv_find(argv
, argc
, "LINE", &idx
);
19600 str
= argv_concat(argv
, argc
, idx
);
19604 argv_find(argv
, argc
, "(100-500)", &idx
);
19605 argv_find(argv
, argc
, "WORD", &idx
);
19606 cl_number_or_name
= argv
[idx
]->arg
;
19608 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
19609 seq
, direct
, style
);
19611 XFREE(MTYPE_TMP
, str
);
19614 community_list_perror(vty
, ret
);
19615 return CMD_WARNING_CONFIG_FAILED
;
19618 return CMD_SUCCESS
;
19621 ALIAS(no_extcommunity_list_expanded_all
,
19622 no_bgp_extcommunity_list_expanded_all_list_cmd
,
19623 "no bgp extcommunity-list <(100-500)|expanded WORD>",
19624 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
19625 "Extended Community list number (expanded)\n"
19626 "Specify expanded extcommunity-list\n"
19627 "Extended Community list name\n")
19629 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
19631 struct community_entry
*entry
;
19633 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19634 if (entry
== list
->head
) {
19635 if (all_digit(list
->name
))
19636 vty_out(vty
, "Extended community %s list %s\n",
19637 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
19639 : "(expanded) access",
19643 "Named extended community %s list %s\n",
19644 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
19650 vty_out(vty
, " %s\n",
19651 community_direct_str(entry
->direct
));
19653 vty_out(vty
, " %s %s\n",
19654 community_direct_str(entry
->direct
),
19655 community_list_config_str(entry
));
19659 DEFUN (show_extcommunity_list
,
19660 show_bgp_extcommunity_list_cmd
,
19661 "show bgp extcommunity-list",
19664 "List extended-community list\n")
19666 struct community_list
*list
;
19667 struct community_list_master
*cm
;
19669 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
19671 return CMD_SUCCESS
;
19673 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19674 extcommunity_list_show(vty
, list
);
19676 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19677 extcommunity_list_show(vty
, list
);
19679 return CMD_SUCCESS
;
19682 DEFUN (show_extcommunity_list_arg
,
19683 show_bgp_extcommunity_list_arg_cmd
,
19684 "show bgp extcommunity-list <(1-500)|WORD> detail",
19687 "List extended-community list\n"
19688 "Extcommunity-list number\n"
19689 "Extcommunity-list name\n"
19690 "Detailed information on extcommunity-list\n")
19692 int idx_comm_list
= 3;
19693 struct community_list
*list
;
19695 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
19696 EXTCOMMUNITY_LIST_MASTER
);
19698 vty_out(vty
, "%% Can't find extcommunity-list\n");
19699 return CMD_WARNING
;
19702 extcommunity_list_show(vty
, list
);
19704 return CMD_SUCCESS
;
19707 /* Display community-list and extcommunity-list configuration. */
19708 static int community_list_config_write(struct vty
*vty
)
19710 struct community_list
*list
;
19711 struct community_entry
*entry
;
19712 struct community_list_master
*cm
;
19715 /* Community-list. */
19716 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19718 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19719 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19721 "bgp community-list %s seq %" PRId64
" %s %s\n",
19722 list
->name
, entry
->seq
,
19723 community_direct_str(entry
->direct
),
19724 community_list_config_str(entry
));
19727 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19728 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19730 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
19731 entry
->style
== COMMUNITY_LIST_STANDARD
19734 list
->name
, entry
->seq
,
19735 community_direct_str(entry
->direct
),
19736 community_list_config_str(entry
));
19740 /* Extcommunity-list. */
19741 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
19743 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19744 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19746 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
19747 list
->name
, entry
->seq
,
19748 community_direct_str(entry
->direct
),
19749 community_list_config_str(entry
));
19752 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19753 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19755 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
19756 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
19759 list
->name
, entry
->seq
,
19760 community_direct_str(entry
->direct
),
19761 community_list_config_str(entry
));
19766 /* lcommunity-list. */
19767 cm
= community_list_master_lookup(bgp_clist
,
19768 LARGE_COMMUNITY_LIST_MASTER
);
19770 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19771 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19773 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
19774 list
->name
, entry
->seq
,
19775 community_direct_str(entry
->direct
),
19776 community_list_config_str(entry
));
19779 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19780 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19782 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
19784 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
19787 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
19788 community_list_config_str(entry
));
19795 static int community_list_config_write(struct vty
*vty
);
19796 static struct cmd_node community_list_node
= {
19797 .name
= "community list",
19798 .node
= COMMUNITY_LIST_NODE
,
19800 .config_write
= community_list_config_write
,
19803 static void community_list_vty(void)
19805 install_node(&community_list_node
);
19807 /* Community-list. */
19808 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
19809 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
19810 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
19811 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
19812 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
19813 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
19814 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
19815 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
19817 /* Extcommunity-list. */
19818 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
19819 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
19820 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
19821 install_element(CONFIG_NODE
,
19822 &no_bgp_extcommunity_list_standard_all_list_cmd
);
19823 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
19824 install_element(CONFIG_NODE
,
19825 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
19826 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
19827 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
19829 /* Large Community List */
19830 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
19831 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
19832 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
19833 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
19834 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
19835 install_element(CONFIG_NODE
,
19836 &no_bgp_lcommunity_list_name_standard_all_cmd
);
19837 install_element(CONFIG_NODE
,
19838 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
19839 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
19840 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
19841 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
19842 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
19843 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
19844 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);