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
)
213 if (safi
== SAFI_UNICAST
)
214 return "IPv4 Unicast";
215 if (safi
== SAFI_MULTICAST
)
216 return "IPv4 Multicast";
217 if (safi
== SAFI_LABELED_UNICAST
)
218 return "IPv4 Labeled Unicast";
219 if (safi
== SAFI_MPLS_VPN
)
221 if (safi
== SAFI_ENCAP
)
223 if (safi
== SAFI_FLOWSPEC
)
224 return "IPv4 Flowspec";
225 } else if (afi
== AFI_IP6
) {
226 if (safi
== SAFI_UNICAST
)
227 return "IPv6 Unicast";
228 if (safi
== SAFI_MULTICAST
)
229 return "IPv6 Multicast";
230 if (safi
== SAFI_LABELED_UNICAST
)
231 return "IPv6 Labeled Unicast";
232 if (safi
== SAFI_MPLS_VPN
)
234 if (safi
== SAFI_ENCAP
)
236 if (safi
== SAFI_FLOWSPEC
)
237 return "IPv6 Flowspec";
238 } else if (afi
== AFI_L2VPN
) {
239 if (safi
== SAFI_EVPN
)
247 * Please note that we have intentionally camelCased
248 * the return strings here. So if you want
249 * to use this function, please ensure you
250 * are doing this within json output
252 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
255 if (safi
== SAFI_UNICAST
)
256 return "ipv4Unicast";
257 if (safi
== SAFI_MULTICAST
)
258 return "ipv4Multicast";
259 if (safi
== SAFI_LABELED_UNICAST
)
260 return "ipv4LabeledUnicast";
261 if (safi
== SAFI_MPLS_VPN
)
263 if (safi
== SAFI_ENCAP
)
265 if (safi
== SAFI_FLOWSPEC
)
266 return "ipv4Flowspec";
267 } else if (afi
== AFI_IP6
) {
268 if (safi
== SAFI_UNICAST
)
269 return "ipv6Unicast";
270 if (safi
== SAFI_MULTICAST
)
271 return "ipv6Multicast";
272 if (safi
== SAFI_LABELED_UNICAST
)
273 return "ipv6LabeledUnicast";
274 if (safi
== SAFI_MPLS_VPN
)
276 if (safi
== SAFI_ENCAP
)
278 if (safi
== SAFI_FLOWSPEC
)
279 return "ipv6Flowspec";
280 } else if (afi
== AFI_L2VPN
) {
281 if (safi
== SAFI_EVPN
)
288 /* return string maps to afi-safi specific container names
289 * defined in bgp yang file.
291 const char *bgp_afi_safi_get_container_str(afi_t afi
, safi_t safi
)
294 if (safi
== SAFI_UNICAST
)
295 return "ipv4-unicast";
296 if (safi
== SAFI_MULTICAST
)
297 return "ipv4-multicast";
298 if (safi
== SAFI_LABELED_UNICAST
)
299 return "ipv4-labeled-unicast";
300 if (safi
== SAFI_MPLS_VPN
)
301 return "l3vpn-ipv4-unicast";
302 if (safi
== SAFI_FLOWSPEC
)
303 return "ipv4-flowspec";
304 } else if (afi
== AFI_IP6
) {
305 if (safi
== SAFI_UNICAST
)
306 return "ipv6-unicast";
307 if (safi
== SAFI_MULTICAST
)
308 return "ipv6-multicast";
309 if (safi
== SAFI_LABELED_UNICAST
)
310 return "ipv6-labeled-unicast";
311 if (safi
== SAFI_MPLS_VPN
)
312 return "l3vpn-ipv6-unicast";
313 if (safi
== SAFI_FLOWSPEC
)
314 return "ipv6-flowspec";
315 } else if (afi
== AFI_L2VPN
) {
316 if (safi
== SAFI_EVPN
)
323 /* Utility function to get address family from current node. */
324 afi_t
bgp_node_afi(struct vty
*vty
)
332 case BGP_FLOWSPECV6_NODE
:
345 /* Utility function to get subsequent address family from current
347 safi_t
bgp_node_safi(struct vty
*vty
)
353 safi
= SAFI_MPLS_VPN
;
357 safi
= SAFI_MULTICAST
;
364 safi
= SAFI_LABELED_UNICAST
;
366 case BGP_FLOWSPECV4_NODE
:
367 case BGP_FLOWSPECV6_NODE
:
368 safi
= SAFI_FLOWSPEC
;
378 * Converts an AFI in string form to afi_t
380 * @param afi string, one of
384 * @return the corresponding afi_t
386 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
388 afi_t afi
= AFI_MAX
; /* unknown */
389 if (strmatch(afi_str
, "ipv4"))
391 else if (strmatch(afi_str
, "ipv6"))
393 else if (strmatch(afi_str
, "l2vpn"))
398 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
402 if (argv_find(argv
, argc
, "ipv4", index
)) {
406 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
410 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
418 /* supports <unicast|multicast|vpn|labeled-unicast> */
419 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
421 safi_t safi
= SAFI_MAX
; /* unknown */
422 if (strmatch(safi_str
, "multicast"))
423 safi
= SAFI_MULTICAST
;
424 else if (strmatch(safi_str
, "unicast"))
426 else if (strmatch(safi_str
, "vpn"))
427 safi
= SAFI_MPLS_VPN
;
428 else if (strmatch(safi_str
, "evpn"))
430 else if (strmatch(safi_str
, "labeled-unicast"))
431 safi
= SAFI_LABELED_UNICAST
;
432 else if (strmatch(safi_str
, "flowspec"))
433 safi
= SAFI_FLOWSPEC
;
437 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
441 if (argv_find(argv
, argc
, "unicast", index
)) {
444 *safi
= SAFI_UNICAST
;
445 } else if (argv_find(argv
, argc
, "multicast", index
)) {
448 *safi
= SAFI_MULTICAST
;
449 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
452 *safi
= SAFI_LABELED_UNICAST
;
453 } else if (argv_find(argv
, argc
, "vpn", index
)) {
456 *safi
= SAFI_MPLS_VPN
;
457 } else if (argv_find(argv
, argc
, "evpn", index
)) {
461 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
464 *safi
= SAFI_FLOWSPEC
;
469 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
470 enum bgp_instance_type inst_type
)
472 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
474 if (ret
== BGP_CREATED
) {
475 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
476 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
478 if (DFLT_BGP_IMPORT_CHECK
)
479 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
480 if (DFLT_BGP_SHOW_HOSTNAME
)
481 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
482 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
483 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
484 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
485 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
486 if (DFLT_BGP_DETERMINISTIC_MED
)
487 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
488 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
489 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
497 * bgp_vty_find_and_parse_afi_safi_bgp
499 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
500 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
501 * to appropriate values for the calling function. This is to allow the
502 * calling function to make decisions appropriate for the show command
503 * that is being parsed.
505 * The show commands are generally of the form:
506 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
507 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
509 * Since we use argv_find if the show command in particular doesn't have:
511 * [<view|vrf> VIEWVRFNAME]
512 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
513 * The command parsing should still be ok.
515 * vty -> The vty for the command so we can output some useful data in
516 * the event of a parse error in the vrf.
517 * argv -> The command tokens
518 * argc -> How many command tokens we have
519 * idx -> The current place in the command, generally should be 0 for this
521 * afi -> The parsed afi if it was included in the show command, returned here
522 * safi -> The parsed safi if it was included in the show command, returned here
523 * bgp -> Pointer to the bgp data structure we need to fill in.
524 * use_json -> json is configured or not
526 * The function returns the correct location in the parse tree for the
529 * Returns 0 for failure to parse correctly, else the idx position of where
530 * it found the last token.
532 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
533 struct cmd_token
**argv
, int argc
,
534 int *idx
, afi_t
*afi
, safi_t
*safi
,
535 struct bgp
**bgp
, bool use_json
)
537 char *vrf_name
= NULL
;
543 if (argv_find(argv
, argc
, "ip", idx
))
546 if (argv_find(argv
, argc
, "view", idx
))
547 vrf_name
= argv
[*idx
+ 1]->arg
;
548 else if (argv_find(argv
, argc
, "vrf", idx
)) {
549 vrf_name
= argv
[*idx
+ 1]->arg
;
550 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
554 if (strmatch(vrf_name
, "all"))
557 *bgp
= bgp_lookup_by_name(vrf_name
);
560 json_object
*json
= NULL
;
561 json
= json_object_new_object();
562 json_object_string_add(
564 "View/Vrf is unknown");
566 json_object_to_json_string_ext(json
,
567 JSON_C_TO_STRING_PRETTY
));
568 json_object_free(json
);
571 vty_out(vty
, "View/Vrf %s is unknown\n",
578 *bgp
= bgp_get_default();
581 json_object
*json
= NULL
;
582 json
= json_object_new_object();
583 json_object_string_add(
585 "Default BGP instance not found");
587 json_object_to_json_string_ext(json
,
588 JSON_C_TO_STRING_PRETTY
));
589 json_object_free(json
);
593 "Default BGP instance not found\n");
599 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
600 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
606 bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
608 struct interface
*ifp
= NULL
;
610 if (su
->sa
.sa_family
== AF_INET
)
611 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
612 else if (su
->sa
.sa_family
== AF_INET6
)
613 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
614 su
->sin6
.sin6_scope_id
,
623 /* Utility function for looking up peer or peer group. */
624 /* This is used only for configuration, so disallow if attempted on
625 * a dynamic neighbor.
627 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
629 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
632 struct peer
*peer
= NULL
;
633 struct peer_group
*group
= NULL
;
639 ret
= str2sockunion(peer_str
, &su
);
641 /* IP address, locate peer. */
642 peer
= peer_lookup(bgp
, &su
);
644 /* Not IP, could match either peer configured on interface or a
646 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
648 group
= peer_group_lookup(bgp
, peer_str
);
652 if (peer_dynamic_neighbor(peer
)) {
654 "%% Operation not allowed on a dynamic neighbor\n");
664 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
669 int bgp_nb_errmsg_return(char *errmsg
, size_t errmsg_len
, int ret
)
671 const char *str
= NULL
;
674 case BGP_ERR_INVALID_VALUE
:
675 str
= "Invalid value";
677 case BGP_ERR_INVALID_FLAG
:
678 str
= "Invalid flag";
680 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
681 str
= "Peer-group has been shutdown. Activate the peer-group first";
683 case BGP_ERR_PEER_FLAG_CONFLICT
:
684 str
= "Can't set override-capability and strict-capability-match at the same time";
686 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
687 str
= "Specify remote-as or peer-group remote AS first";
689 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
690 str
= "Cannot change the peer-group. Deconfigure first";
692 case BGP_ERR_PEER_GROUP_MISMATCH
:
693 str
= "Peer is not a member of this peer-group";
695 case BGP_ERR_PEER_FILTER_CONFLICT
:
696 str
= "Prefix/distribute list can not co-exist";
698 case BGP_ERR_NOT_INTERNAL_PEER
:
699 str
= "Invalid command. Not an internal neighbor";
701 case BGP_ERR_REMOVE_PRIVATE_AS
:
702 str
= "remove-private-AS cannot be configured for IBGP peers";
704 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
705 str
= "Local-AS allowed only for EBGP peers";
707 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
708 str
= "Cannot have local-as same as BGP AS number";
710 case BGP_ERR_TCPSIG_FAILED
:
711 str
= "Error while applying TCP-Sig to session(s)";
713 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
714 str
= "ebgp-multihop and ttl-security cannot be configured together";
716 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
717 str
= "ttl-security only allowed for EBGP peers";
719 case BGP_ERR_AS_OVERRIDE
:
720 str
= "as-override cannot be configured for IBGP peers";
722 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
723 str
= "Invalid limit for number of dynamic neighbors";
725 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
726 str
= "Dynamic neighbor listen range already exists";
728 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
729 str
= "Operation not allowed on a dynamic neighbor";
731 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
732 str
= "Operation not allowed on a directly connected neighbor";
734 case BGP_ERR_PEER_SAFI_CONFLICT
:
737 case BGP_ERR_GR_INVALID_CMD
:
738 str
= "The Graceful Restart command used is not valid at this moment.";
740 case BGP_ERR_GR_OPERATION_FAILED
:
741 str
= "The Graceful Restart Operation failed due to an err.";
743 case BGP_GR_NO_OPERATION
:
746 case BGP_ERR_PEER_GROUP_MEMBER
:
747 str
= "Peer-group member cannot override remote-as of peer-group";
749 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
750 str
= "Peer-group members must be all internal or all external";
754 snprintf(errmsg
, errmsg_len
, "%s", str
);
761 int bgp_vty_return(struct vty
*vty
, int ret
)
763 const char *str
= NULL
;
766 case BGP_ERR_INVALID_VALUE
:
767 str
= "Invalid value";
769 case BGP_ERR_INVALID_FLAG
:
770 str
= "Invalid flag";
772 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
773 str
= "Peer-group has been shutdown. Activate the peer-group first";
775 case BGP_ERR_PEER_FLAG_CONFLICT
:
776 str
= "Can't set override-capability and strict-capability-match at the same time";
778 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
779 str
= "Specify remote-as or peer-group remote AS first";
781 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
782 str
= "Cannot change the peer-group. Deconfigure first";
784 case BGP_ERR_PEER_GROUP_MISMATCH
:
785 str
= "Peer is not a member of this peer-group";
787 case BGP_ERR_PEER_FILTER_CONFLICT
:
788 str
= "Prefix/distribute list can not co-exist";
790 case BGP_ERR_NOT_INTERNAL_PEER
:
791 str
= "Invalid command. Not an internal neighbor";
793 case BGP_ERR_REMOVE_PRIVATE_AS
:
794 str
= "remove-private-AS cannot be configured for IBGP peers";
796 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
797 str
= "Local-AS allowed only for EBGP peers";
799 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
800 str
= "Cannot have local-as same as BGP AS number";
802 case BGP_ERR_TCPSIG_FAILED
:
803 str
= "Error while applying TCP-Sig to session(s)";
805 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
806 str
= "ebgp-multihop and ttl-security cannot be configured together";
808 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
809 str
= "ttl-security only allowed for EBGP peers";
811 case BGP_ERR_AS_OVERRIDE
:
812 str
= "as-override cannot be configured for IBGP peers";
814 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
815 str
= "Invalid limit for number of dynamic neighbors";
817 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
818 str
= "Dynamic neighbor listen range already exists";
820 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
821 str
= "Operation not allowed on a dynamic neighbor";
823 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
824 str
= "Operation not allowed on a directly connected neighbor";
826 case BGP_ERR_PEER_SAFI_CONFLICT
:
829 case BGP_ERR_GR_INVALID_CMD
:
830 str
= "The Graceful Restart command used is not valid at this moment.";
832 case BGP_ERR_GR_OPERATION_FAILED
:
833 str
= "The Graceful Restart Operation failed due to an err.";
835 case BGP_GR_NO_OPERATION
:
840 vty_out(vty
, "%% %s\n", str
);
841 return CMD_WARNING_CONFIG_FAILED
;
846 /* BGP clear sort. */
855 static void bgp_clear_vty_error(struct peer
*peer
, afi_t afi
, safi_t safi
,
856 int error
, char *errmsg
, size_t errmsg_len
)
859 case BGP_ERR_AF_UNCONFIGURED
:
860 snprintf(errmsg
, errmsg_len
,
861 "%%BGP: Enable %s address family for the neighbor %s",
862 get_afi_safi_str(afi
, safi
, false), peer
->host
);
864 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
867 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig",
875 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
876 struct listnode
**nnode
, enum bgp_clear_type stype
)
880 /* if afi/.safi not specified, spin thru all of them */
881 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
885 FOREACH_AFI_SAFI (tmp_afi
, tmp_safi
) {
886 if (!peer
->afc
[tmp_afi
][tmp_safi
])
889 if (stype
== BGP_CLEAR_SOFT_NONE
)
890 ret
= peer_clear(peer
, nnode
);
892 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
895 /* if afi specified and safi not, spin thru safis on this afi */
896 } else if (safi
== SAFI_UNSPEC
) {
899 for (tmp_safi
= SAFI_UNICAST
;
900 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
901 if (!peer
->afc
[afi
][tmp_safi
])
904 if (stype
== BGP_CLEAR_SOFT_NONE
)
905 ret
= peer_clear(peer
, nnode
);
907 ret
= peer_clear_soft(peer
, afi
,
910 /* both afi/safi specified, let the caller know if not defined */
912 if (!peer
->afc
[afi
][safi
])
915 if (stype
== BGP_CLEAR_SOFT_NONE
)
916 ret
= peer_clear(peer
, nnode
);
918 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
924 /* `clear ip bgp' functions. */
925 static int bgp_clear(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
926 enum clear_sort sort
, enum bgp_clear_type stype
,
927 const char *arg
, char *errmsg
, size_t errmsg_len
)
933 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
935 /* Clear all neighbors. */
937 * Pass along pointer to next node to peer_clear() when walking all
938 * nodes on the BGP instance as that may get freed if it is a
941 if (sort
== clear_all
) {
942 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
944 bgp_peer_gr_flags_update(peer
);
946 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
947 gr_router_detected
= true;
949 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
953 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
957 if (gr_router_detected
958 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
959 bgp_zebra_send_capabilities(bgp
, false);
960 } else if (!gr_router_detected
961 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
962 bgp_zebra_send_capabilities(bgp
, true);
965 /* This is to apply read-only mode on this clear. */
966 if (stype
== BGP_CLEAR_SOFT_NONE
)
967 bgp
->update_delay_over
= 0;
972 /* Clear specified neighbor. */
973 if (sort
== clear_peer
) {
976 /* Make sockunion for lookup. */
977 ret
= str2sockunion(arg
, &su
);
979 peer
= peer_lookup_by_conf_if(bgp
, arg
);
981 peer
= peer_lookup_by_hostname(bgp
, arg
);
985 "Malformed address or name: %s",
991 peer
= peer_lookup(bgp
, &su
);
993 snprintf(errmsg
, errmsg_len
,
994 "%%BGP: Unknown neighbor - \"%s\"",
1000 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1001 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1003 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1005 /* if afi/safi not defined for this peer, let caller know */
1007 ret
= BGP_ERR_AF_UNCONFIGURED
;
1010 bgp_clear_vty_error(peer
, afi
, safi
, ret
, errmsg
,
1016 /* Clear all neighbors belonging to a specific peer-group. */
1017 if (sort
== clear_group
) {
1018 struct peer_group
*group
;
1020 group
= peer_group_lookup(bgp
, arg
);
1022 snprintf(errmsg
, errmsg_len
,
1023 "%%BGP: No such peer-group %s", arg
);
1027 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1028 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1031 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1032 errmsg
, errmsg_len
);
1040 "%%BGP: No %s peer belonging to peer-group %s is configured",
1041 get_afi_safi_str(afi
, safi
, false), arg
);
1046 /* Clear all external (eBGP) neighbors. */
1047 if (sort
== clear_external
) {
1048 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1049 if (peer
->sort
== BGP_PEER_IBGP
)
1052 bgp_peer_gr_flags_update(peer
);
1054 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1055 gr_router_detected
= true;
1057 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1060 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1061 errmsg
, errmsg_len
);
1066 if (gr_router_detected
1067 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1068 bgp_zebra_send_capabilities(bgp
, false);
1069 } else if (!gr_router_detected
1070 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1071 bgp_zebra_send_capabilities(bgp
, true);
1075 snprintf(errmsg
, errmsg_len
,
1076 "%%BGP: No external %s peer is configured",
1077 get_afi_safi_str(afi
, safi
, false));
1082 /* Clear all neighbors belonging to a specific AS. */
1083 if (sort
== clear_as
) {
1084 as_t as
= strtoul(arg
, NULL
, 10);
1086 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1090 bgp_peer_gr_flags_update(peer
);
1092 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1093 gr_router_detected
= true;
1095 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1098 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1099 errmsg
, errmsg_len
);
1104 if (gr_router_detected
1105 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1106 bgp_zebra_send_capabilities(bgp
, false);
1107 } else if (!gr_router_detected
1108 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1109 bgp_zebra_send_capabilities(bgp
, true);
1113 snprintf(errmsg
, errmsg_len
,
1114 "%%BGP: No %s peer is configured with AS %s",
1115 get_afi_safi_str(afi
, safi
, false), arg
);
1123 static int bgp_clear_vty(const char *name
, afi_t afi
, safi_t safi
,
1124 enum clear_sort sort
, enum bgp_clear_type stype
,
1125 const char *arg
, char *errmsg
, size_t errmsg_len
)
1129 /* BGP structure lookup. */
1131 bgp
= bgp_lookup_by_name(name
);
1133 snprintf(errmsg
, errmsg_len
,
1134 "Can't find BGP instance %s", name
);
1138 bgp
= bgp_get_default();
1140 snprintf(errmsg
, errmsg_len
,
1141 "No BGP process is configured");
1146 return bgp_clear(bgp
, afi
, safi
, sort
, stype
, arg
, errmsg
, errmsg_len
);
1149 /* clear soft inbound */
1150 int bgp_clear_star_soft_in(const char *name
, char *errmsg
, size_t errmsg_len
)
1156 FOREACH_AFI_SAFI (afi
, safi
) {
1157 ret
= bgp_clear_vty(name
, afi
, safi
, clear_all
,
1158 BGP_CLEAR_SOFT_IN
, NULL
, errmsg
,
1160 if (ret
!= CMD_SUCCESS
)
1167 /* clear soft outbound */
1168 int bgp_clear_star_soft_out(const char *name
, char *errmsg
, size_t errmsg_len
)
1174 FOREACH_AFI_SAFI (afi
, safi
) {
1175 ret
= bgp_clear_vty(name
, afi
, safi
, clear_all
,
1176 BGP_CLEAR_SOFT_OUT
, NULL
, errmsg
,
1178 if (ret
!= CMD_SUCCESS
)
1186 #ifndef VTYSH_EXTRACT_PL
1187 #include "bgpd/bgp_vty_clippy.c"
1190 DEFUN_HIDDEN (bgp_local_mac
,
1192 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1194 "Local MAC config\n"
1195 "VxLAN Network Identifier\n"
1199 "mac-mobility sequence\n"
1209 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1210 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1211 vty_out(vty
, "%% Malformed MAC address\n");
1214 memset(&ip
, 0, sizeof(ip
));
1215 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1217 bgp
= bgp_get_default();
1219 vty_out(vty
, "Default BGP instance is not there\n");
1223 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1226 vty_out(vty
, "Internal error\n");
1233 DEFUN_HIDDEN (no_bgp_local_mac
,
1234 no_bgp_local_mac_cmd
,
1235 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1238 "Local MAC config\n"
1239 "VxLAN Network Identifier\n"
1250 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1251 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1252 vty_out(vty
, "%% Malformed MAC address\n");
1255 memset(&ip
, 0, sizeof(ip
));
1257 bgp
= bgp_get_default();
1259 vty_out(vty
, "Default BGP instance is not there\n");
1263 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1265 vty_out(vty
, "Internal error\n");
1272 DEFUN (no_synchronization
,
1273 no_synchronization_cmd
,
1274 "no synchronization",
1276 "Perform IGP synchronization\n")
1281 DEFUN (no_auto_summary
,
1282 no_auto_summary_cmd
,
1285 "Enable automatic network number summarization\n")
1290 /* "router bgp" commands. */
1291 DEFUN_YANG_NOSH(router_bgp
,
1293 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1294 ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR
)
1297 int idx_view_vrf
= 3;
1299 int ret
= CMD_SUCCESS
;
1302 const char *name
= NULL
;
1303 char as_str
[12] = {'\0'};
1304 enum bgp_instance_type inst_type
;
1305 char base_xpath
[XPATH_MAXLEN
];
1307 // "router bgp" without an ASN
1309 // Pending: Make VRF option available for ASN less config
1310 bgp
= bgp_get_default();
1313 vty_out(vty
, "%% No BGP process is configured\n");
1314 return CMD_WARNING_CONFIG_FAILED
;
1317 if (listcount(bm
->bgp
) > 1) {
1318 vty_out(vty
, "%% Please specify ASN and VRF\n");
1319 return CMD_WARNING_CONFIG_FAILED
;
1322 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1323 "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME
);
1325 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
1326 snprintf(as_str
, 12, "%d", bgp
->as
);
1327 nb_cli_enqueue_change(vty
, "./global/local-as", NB_OP_MODIFY
,
1329 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
) {
1330 nb_cli_enqueue_change(vty
,
1331 "./global/instance-type-view",
1332 NB_OP_MODIFY
, "true");
1335 nb_cli_pending_commit_check(vty
);
1336 ret
= nb_cli_apply_changes(vty
, base_xpath
);
1337 if (ret
== CMD_SUCCESS
) {
1338 VTY_PUSH_XPATH(BGP_NODE
, base_xpath
);
1341 * For backward compatibility with old commands we still
1342 * need to use the qobj infrastructure.
1344 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1352 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1353 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1355 name
= argv
[idx_vrf
]->arg
;
1357 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1358 if (strmatch(name
, VRF_DEFAULT_NAME
))
1361 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1362 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view")) {
1363 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1366 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1367 "frr-bgp:bgp", "bgp", name
? name
: VRF_DEFAULT_NAME
);
1369 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
1370 nb_cli_enqueue_change(vty
, "./global/local-as", NB_OP_MODIFY
,
1371 argv
[idx_asn
]->arg
);
1372 if (inst_type
== BGP_INSTANCE_TYPE_VIEW
) {
1373 nb_cli_enqueue_change(vty
,
1374 "./global/instance-type-view",
1375 NB_OP_MODIFY
, "true");
1378 nb_cli_pending_commit_check(vty
);
1379 ret
= nb_cli_apply_changes(vty
, base_xpath
);
1380 if (ret
== CMD_SUCCESS
) {
1381 VTY_PUSH_XPATH(BGP_NODE
, base_xpath
);
1384 * For backward compatibility with old commands we still
1385 * need to use the qobj infrastructure.
1387 bgp
= bgp_lookup(as
, name
);
1389 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1396 /* "no router bgp" commands. */
1397 DEFUN_YANG(no_router_bgp
,
1399 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1400 NO_STR ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR
)
1406 const char *name
= NULL
;
1407 char base_xpath
[XPATH_MAXLEN
];
1408 const struct lyd_node
*bgp_glb_dnode
;
1410 // "no router bgp" without an ASN
1412 // Pending: Make VRF option available for ASN less config
1413 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1414 "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME
);
1416 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
1418 if (!bgp_glb_dnode
) {
1419 vty_out(vty
, "%% No BGP process is configured\n");
1420 return CMD_WARNING_CONFIG_FAILED
;
1423 if (listcount(bm
->bgp
) > 1) {
1424 vty_out(vty
, "%% Please specify ASN and VRF\n");
1425 return CMD_WARNING_CONFIG_FAILED
;
1428 /* tcli mode bgp would not be set until apply stage. */
1429 bgp
= nb_running_get_entry(bgp_glb_dnode
, NULL
, false);
1434 vty_out(vty
, "%% Please unconfigure l3vni %u",
1436 return CMD_WARNING_CONFIG_FAILED
;
1439 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1442 name
= argv
[idx_vrf
]->arg
;
1444 /* Lookup bgp structure. */
1445 bgp
= bgp_lookup(as
, name
);
1447 vty_out(vty
, "%% Can't find BGP instance\n");
1448 return CMD_WARNING_CONFIG_FAILED
;
1452 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1454 return CMD_WARNING_CONFIG_FAILED
;
1457 /* Cannot delete default instance if vrf instances exist */
1458 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1459 struct listnode
*node
;
1460 struct bgp
*tmp_bgp
;
1462 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1463 if (tmp_bgp
->inst_type
1464 == BGP_INSTANCE_TYPE_VRF
) {
1466 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1467 return CMD_WARNING_CONFIG_FAILED
;
1472 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1473 "frr-bgp:bgp", "bgp",
1474 bgp
->name
? bgp
->name
: VRF_DEFAULT_NAME
);
1476 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
1478 return nb_cli_apply_changes(vty
, base_xpath
);
1481 void cli_show_router_bgp(struct vty
*vty
, struct lyd_node
*dnode
,
1484 const struct lyd_node
*vrf_dnode
;
1485 const char *vrf_name
;
1488 vrf_dnode
= yang_dnode_get_parent(dnode
, "control-plane-protocol");
1489 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
1490 as
= yang_dnode_get_uint32(dnode
, "./global/local-as");
1492 vty_out(vty
, "!\n");
1493 vty_out(vty
, "router bgp %u", as
);
1494 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
))
1495 vty_out(vty
, " vrf %s", vrf_name
);
1499 /* BGP router-id. */
1501 DEFPY_YANG(bgp_router_id
, bgp_router_id_cmd
, "bgp router-id A.B.C.D",
1503 "Override configured router identifier\n"
1504 "Manually configured router identifier\n")
1506 nb_cli_enqueue_change(vty
, "./global/router-id", NB_OP_MODIFY
,
1509 return nb_cli_apply_changes(vty
, NULL
);
1512 DEFPY_YANG(no_bgp_router_id
, no_bgp_router_id_cmd
, "no bgp router-id [A.B.C.D]",
1514 "Override configured router identifier\n"
1515 "Manually configured router identifier\n")
1517 nb_cli_enqueue_change(vty
, "./global/router-id", NB_OP_DESTROY
,
1518 router_id_str
? router_id_str
: NULL
);
1520 return nb_cli_apply_changes(vty
, NULL
);
1523 void cli_show_router_bgp_router_id(struct vty
*vty
, struct lyd_node
*dnode
,
1526 vty_out(vty
, " bgp router-id %s\n", yang_dnode_get_string(dnode
, NULL
));
1529 DEFPY (bgp_global_suppress_fib_pending
,
1530 bgp_global_suppress_fib_pending_cmd
,
1531 "[no] bgp suppress-fib-pending",
1534 "Advertise only routes that are programmed in kernel to peers globally\n")
1536 bm_wait_for_fib_set(!no
);
1541 DEFPY (bgp_suppress_fib_pending
,
1542 bgp_suppress_fib_pending_cmd
,
1543 "[no] bgp suppress-fib-pending",
1546 "Advertise only routes that are programmed in kernel to peers\n")
1548 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1550 bgp_suppress_fib_pending_set(bgp
, !no
);
1555 /* BGP Cluster ID. */
1556 DEFUN_YANG(bgp_cluster_id
,
1558 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1560 "Configure Route-Reflector Cluster-id\n"
1561 "Route-Reflector Cluster-id in IP address format\n"
1562 "Route-Reflector Cluster-id as 32 bit quantity\n")
1566 nb_cli_enqueue_change(
1567 vty
, "./global/route-reflector/route-reflector-cluster-id",
1568 NB_OP_MODIFY
, argv
[idx_ipv4
]->arg
);
1570 return nb_cli_apply_changes(vty
, NULL
);
1573 DEFUN_YANG(no_bgp_cluster_id
,
1574 no_bgp_cluster_id_cmd
,
1575 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1577 "Configure Route-Reflector Cluster-id\n"
1578 "Route-Reflector Cluster-id in IP address format\n"
1579 "Route-Reflector Cluster-id as 32 bit quantity\n")
1581 nb_cli_enqueue_change(
1582 vty
, "./global/route-reflector/route-reflector-cluster-id",
1583 NB_OP_DESTROY
, NULL
);
1585 return nb_cli_apply_changes(vty
, NULL
);
1592 "Disable BGP route installation to RIB (Zebra)\n")
1594 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1596 "%% No-RIB option is already set, nothing to do here.\n");
1600 bgp_option_norib_set_runtime();
1605 DEFPY (no_bgp_norib
,
1610 "Disable BGP route installation to RIB (Zebra)\n")
1612 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1614 "%% No-RIB option is not set, nothing to do here.\n");
1618 bgp_option_norib_unset_runtime();
1623 DEFPY (no_bgp_send_extra_data
,
1624 no_bgp_send_extra_data_cmd
,
1625 "[no] bgp send-extra-data zebra",
1628 "Extra data to Zebra for display/use\n"
1632 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1634 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1639 DEFUN_YANG(bgp_confederation_identifier
,
1640 bgp_confederation_identifier_cmd
,
1641 "bgp confederation identifier (1-4294967295)",
1642 "BGP specific commands\n"
1643 "AS confederation parameters\n"
1645 "Set routing domain confederation AS\n")
1649 nb_cli_enqueue_change(vty
, "./global/confederation/identifier",
1650 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
1652 return nb_cli_apply_changes(vty
, NULL
);
1655 DEFUN_YANG(no_bgp_confederation_identifier
,
1656 no_bgp_confederation_identifier_cmd
,
1657 "no bgp confederation identifier [(1-4294967295)]",
1659 "BGP specific commands\n"
1660 "AS confederation parameters\n"
1662 "Set routing domain confederation AS\n")
1664 nb_cli_enqueue_change(vty
, "./global/confederation/identifier",
1665 NB_OP_DESTROY
, NULL
);
1667 return nb_cli_apply_changes(vty
, NULL
);
1670 void cli_show_router_bgp_confederation_identifier(struct vty
*vty
,
1671 struct lyd_node
*dnode
,
1674 vty_out(vty
, " bgp confederation identifier %u\n",
1675 yang_dnode_get_uint32(dnode
, NULL
));
1678 DEFUN_YANG(bgp_confederation_peers
,
1679 bgp_confederation_peers_cmd
,
1680 "bgp confederation peers (1-4294967295)...",
1681 "BGP specific commands\n"
1682 "AS confederation parameters\n"
1683 "Peer ASs in BGP confederation\n" AS_STR
)
1688 for (i
= idx_asn
; i
< argc
; i
++)
1689 nb_cli_enqueue_change(vty
, "./global/confederation/member-as",
1690 NB_OP_CREATE
, argv
[i
]->arg
);
1692 return nb_cli_apply_changes(vty
, NULL
);
1695 DEFUN_YANG(no_bgp_confederation_peers
,
1696 no_bgp_confederation_peers_cmd
,
1697 "no bgp confederation peers (1-4294967295)...",
1699 "BGP specific commands\n"
1700 "AS confederation parameters\n"
1701 "Peer ASs in BGP confederation\n" AS_STR
)
1706 for (i
= idx_asn
; i
< argc
; i
++)
1707 nb_cli_enqueue_change(vty
, "./global/confederation/member-as",
1708 NB_OP_DESTROY
, argv
[i
]->arg
);
1710 return nb_cli_apply_changes(vty
, NULL
);
1713 void cli_show_router_bgp_confederation_member_as(struct vty
*vty
,
1714 struct lyd_node
*dnode
,
1717 vty_out(vty
, " bgp confederation peers %u \n",
1718 yang_dnode_get_uint32(dnode
, NULL
));
1722 * Central routine for maximum-paths configuration.
1723 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1724 * @set: 1 for setting values, 0 for removing the max-paths config.
1726 int bgp_maxpaths_config_vty(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1727 int peer_type
, uint16_t maxpaths
, uint16_t options
,
1728 int set
, char *errmsg
, size_t errmsg_len
)
1733 if (maxpaths
> multipath_num
) {
1736 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1737 maxpaths
, multipath_num
);
1738 return CMD_WARNING_CONFIG_FAILED
;
1740 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1743 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1748 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1749 (set
== 1) ? "" : "un",
1750 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1751 maxpaths
, afi
, safi
);
1752 return CMD_WARNING_CONFIG_FAILED
;
1755 bgp_recalculate_all_bestpaths(bgp
);
1760 void cli_show_router_bgp_med_config(struct vty
*vty
, struct lyd_node
*dnode
,
1763 if (yang_dnode_get_bool(dnode
, "./enable-med-admin")) {
1764 uint32_t med_admin_val
;
1766 vty_out(vty
, " bgp max-med administrative");
1767 if ((med_admin_val
=
1768 yang_dnode_get_uint32(dnode
, "./max-med-admin"))
1769 != BGP_MAXMED_VALUE_DEFAULT
)
1770 vty_out(vty
, " %u", med_admin_val
);
1774 if (yang_dnode_exists(dnode
, "./max-med-onstart-up-time")) {
1775 uint32_t onstartup_val
;
1777 vty_out(vty
, " bgp max-med on-startup %u",
1778 yang_dnode_get_uint32(dnode
,
1779 "./max-med-onstart-up-time"));
1780 onstartup_val
= yang_dnode_get_uint32(
1781 dnode
, "./max-med-onstart-up-value");
1782 if (onstartup_val
!= BGP_MAXMED_VALUE_DEFAULT
)
1783 vty_out(vty
, " %u", onstartup_val
);
1789 DEFUN_YANG(bgp_maxmed_admin
,
1790 bgp_maxmed_admin_cmd
,
1791 "bgp max-med administrative ",
1793 "Advertise routes with max-med\n"
1794 "Administratively applied, for an indefinite period\n")
1796 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1797 NB_OP_MODIFY
, "true");
1799 return nb_cli_apply_changes(vty
, NULL
);
1802 DEFUN_YANG(bgp_maxmed_admin_medv
,
1803 bgp_maxmed_admin_medv_cmd
,
1804 "bgp max-med administrative (0-4294967295)",
1806 "Advertise routes with max-med\n"
1807 "Administratively applied, for an indefinite period\n"
1808 "Max MED value to be used\n")
1812 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1813 NB_OP_MODIFY
, "true");
1815 nb_cli_enqueue_change(vty
, "./global/med-config/max-med-admin",
1816 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
1818 return nb_cli_apply_changes(vty
, NULL
);
1821 DEFUN_YANG(no_bgp_maxmed_admin
,
1822 no_bgp_maxmed_admin_cmd
,
1823 "no bgp max-med administrative [(0-4294967295)]",
1825 "Advertise routes with max-med\n"
1826 "Administratively applied, for an indefinite period\n"
1827 "Max MED value to be used\n")
1829 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1830 NB_OP_MODIFY
, "false");
1832 nb_cli_enqueue_change(vty
, "./global/med-config/max-med-admin",
1833 NB_OP_MODIFY
, NULL
);
1835 return nb_cli_apply_changes(vty
, NULL
);
1838 DEFUN_YANG (bgp_maxmed_onstartup
,
1839 bgp_maxmed_onstartup_cmd
,
1840 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1842 "Advertise routes with max-med\n"
1843 "Effective on a startup\n"
1844 "Time (seconds) period for max-med\n"
1845 "Max MED value to be used\n")
1849 argv_find(argv
, argc
, "(5-86400)", &idx
);
1850 nb_cli_enqueue_change(vty
,
1851 "./global/med-config/max-med-onstart-up-time",
1852 NB_OP_MODIFY
, argv
[idx
]->arg
);
1854 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1855 nb_cli_enqueue_change(
1856 vty
, "./global/med-config/max-med-onstart-up-value",
1857 NB_OP_MODIFY
, argv
[idx
]->arg
);
1859 nb_cli_enqueue_change(
1860 vty
, "./global/med-config/max-med-onstart-up-value",
1861 NB_OP_MODIFY
, NULL
);
1863 return nb_cli_apply_changes(vty
, NULL
);
1866 DEFUN_YANG (no_bgp_maxmed_onstartup
,
1867 no_bgp_maxmed_onstartup_cmd
,
1868 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1870 "Advertise routes with max-med\n"
1871 "Effective on a startup\n"
1872 "Time (seconds) period for max-med\n"
1873 "Max MED value to be used\n")
1875 nb_cli_enqueue_change(vty
,
1876 "./global/med-config/max-med-onstart-up-time",
1877 NB_OP_DESTROY
, NULL
);
1879 nb_cli_enqueue_change(vty
,
1880 "./global/med-config/max-med-onstart-up-value",
1881 NB_OP_MODIFY
, NULL
);
1883 return nb_cli_apply_changes(vty
, NULL
);
1886 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
1887 uint16_t update_delay
,
1888 uint16_t establish_wait
)
1890 struct listnode
*node
, *nnode
;
1892 bool vrf_cfg
= false;
1895 * See if update-delay is set per-vrf and warn user to delete it
1896 * Note that we only need to check this if this is the first time
1897 * setting the global config.
1899 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
1900 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1901 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1903 "%% update-delay configuration found in vrf %s\n",
1904 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
1914 "%%Failed: global update-delay config not permitted\n");
1918 if (!establish_wait
) { /* update-delay <delay> */
1919 bm
->v_update_delay
= update_delay
;
1920 bm
->v_establish_wait
= bm
->v_update_delay
;
1922 /* update-delay <delay> <establish-wait> */
1923 if (update_delay
< establish_wait
) {
1925 "%%Failed: update-delay less than the establish-wait!\n");
1926 return CMD_WARNING_CONFIG_FAILED
;
1929 bm
->v_update_delay
= update_delay
;
1930 bm
->v_establish_wait
= establish_wait
;
1933 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1934 bgp
->v_update_delay
= bm
->v_update_delay
;
1935 bgp
->v_establish_wait
= bm
->v_establish_wait
;
1941 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
1943 struct listnode
*node
, *nnode
;
1946 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1947 bm
->v_establish_wait
= bm
->v_update_delay
;
1949 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1950 bgp
->v_update_delay
= bm
->v_update_delay
;
1951 bgp
->v_establish_wait
= bm
->v_establish_wait
;
1957 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
1958 uint16_t establish_wait
)
1960 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1962 /* if configured globally, per-instance config is not allowed */
1963 if (bm
->v_update_delay
) {
1965 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
1966 return CMD_WARNING_CONFIG_FAILED
;
1970 if (!establish_wait
) /* update-delay <delay> */
1972 bgp
->v_update_delay
= update_delay
;
1973 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1977 /* update-delay <delay> <establish-wait> */
1978 if (update_delay
< establish_wait
) {
1980 "%%Failed: update-delay less than the establish-wait!\n");
1981 return CMD_WARNING_CONFIG_FAILED
;
1984 bgp
->v_update_delay
= update_delay
;
1985 bgp
->v_establish_wait
= establish_wait
;
1990 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1992 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1994 /* If configured globally, cannot remove from one bgp instance */
1995 if (bm
->v_update_delay
) {
1997 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
1998 return CMD_WARNING_CONFIG_FAILED
;
2000 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2001 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2006 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2008 /* If configured globally, no need to display per-instance value */
2009 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2010 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2011 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2012 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2017 /* Global update-delay configuration */
2018 DEFPY (bgp_global_update_delay
,
2019 bgp_global_update_delay_cmd
,
2020 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2022 "Force initial delay for best-path and updates for all bgp instances\n"
2023 "Max delay in seconds\n"
2024 "Establish wait in seconds\n")
2026 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2029 /* Global update-delay deconfiguration */
2030 DEFPY (no_bgp_global_update_delay
,
2031 no_bgp_global_update_delay_cmd
,
2032 "no bgp update-delay [(0-3600) [(1-3600)]]",
2035 "Force initial delay for best-path and updates\n"
2036 "Max delay in seconds\n"
2037 "Establish wait in seconds\n")
2039 return bgp_global_update_delay_deconfig_vty(vty
);
2042 /* Update-delay configuration */
2044 DEFPY (bgp_update_delay
,
2045 bgp_update_delay_cmd
,
2046 "update-delay (0-3600)$delay [(1-3600)$wait]",
2047 "Force initial delay for best-path and updates\n"
2048 "Max delay in seconds\n"
2049 "Establish wait in seconds\n")
2051 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2054 /* Update-delay deconfiguration */
2055 DEFPY (no_bgp_update_delay
,
2056 no_bgp_update_delay_cmd
,
2057 "no update-delay [(0-3600) [(1-3600)]]",
2059 "Force initial delay for best-path and updates\n"
2060 "Max delay in seconds\n"
2061 "Establish wait in seconds\n")
2063 return bgp_update_delay_deconfig_vty(vty
);
2067 int bgp_wpkt_quanta_config_vty(struct bgp
*bgp
, uint32_t quanta
, bool set
)
2069 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2070 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2075 int bgp_rpkt_quanta_config_vty(struct bgp
*bgp
, uint32_t quanta
, bool set
)
2077 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2078 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2083 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2086 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2087 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2088 vty_out(vty
, " write-quanta %d\n", quanta
);
2091 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2094 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2095 if (quanta
!= BGP_READ_PACKET_MAX
)
2096 vty_out(vty
, " read-quanta %d\n", quanta
);
2099 /* Packet quanta configuration
2101 * XXX: The value set here controls the size of a stack buffer in the IO
2102 * thread. When changing these limits be careful to prevent stack overflow.
2104 * Furthermore, the maximums used here should correspond to
2105 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2107 DEFPY_YANG (bgp_wpkt_quanta
,
2108 bgp_wpkt_quanta_cmd
,
2109 "[no] write-quanta (1-64)$quanta",
2111 "How many packets to write to peer socket per run\n"
2112 "Number of packets\n")
2115 nb_cli_enqueue_change(
2117 "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta",
2118 NB_OP_MODIFY
, quanta_str
);
2120 nb_cli_enqueue_change(
2122 "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta",
2123 NB_OP_MODIFY
, NULL
);
2125 return nb_cli_apply_changes(vty
, NULL
);
2128 DEFPY_YANG (bgp_rpkt_quanta
,
2129 bgp_rpkt_quanta_cmd
,
2130 "[no] read-quanta (1-10)$quanta",
2132 "How many packets to read from peer socket per I/O cycle\n"
2133 "Number of packets\n")
2136 nb_cli_enqueue_change(
2138 "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta",
2139 NB_OP_MODIFY
, quanta_str
);
2141 nb_cli_enqueue_change(
2143 "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta",
2144 NB_OP_MODIFY
, NULL
);
2146 return nb_cli_apply_changes(vty
, NULL
);
2149 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2151 if (!bgp
->heuristic_coalesce
)
2152 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2155 void cli_show_router_global_update_group_config_coalesce_time(
2156 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2158 vty_out(vty
, " coalesce-time %u\n", yang_dnode_get_uint32(dnode
, NULL
));
2162 DEFUN_YANG (bgp_coalesce_time
,
2163 bgp_coalesce_time_cmd
,
2164 "coalesce-time (0-4294967295)",
2165 "Subgroup coalesce timer\n"
2166 "Subgroup coalesce timer value (in ms)\n")
2170 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
2171 nb_cli_enqueue_change(
2172 vty
, "./global/global-update-group-config/coalesce-time",
2173 NB_OP_MODIFY
, argv
[idx
]->arg
);
2175 return nb_cli_apply_changes(vty
, NULL
);
2178 DEFUN_YANG(no_bgp_coalesce_time
,
2179 no_bgp_coalesce_time_cmd
,
2180 "no coalesce-time (0-4294967295)",
2182 "Subgroup coalesce timer\n"
2183 "Subgroup coalesce timer value (in ms)\n")
2185 nb_cli_enqueue_change(
2186 vty
, "./global/global-update-group-config/coalesce-time",
2187 NB_OP_MODIFY
, NULL
);
2189 return nb_cli_apply_changes(vty
, NULL
);
2192 /* Maximum-paths configuration */
2193 DEFUN_YANG (bgp_maxpaths
,
2195 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2196 "Forward packets over multiple paths\n"
2197 "Number of paths\n")
2200 char base_xpath
[XPATH_MAXLEN
];
2204 afi
= bgp_node_afi(vty
);
2205 safi
= bgp_node_safi(vty
);
2208 base_xpath
, sizeof(base_xpath
),
2209 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ebgp/maximum-paths",
2210 yang_afi_safi_value2identity(afi
, safi
),
2211 bgp_afi_safi_get_container_str(afi
, safi
));
2213 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2214 argv
[idx_number
]->arg
);
2216 return nb_cli_apply_changes(vty
, NULL
);
2219 void cli_show_bgp_global_afi_safi_unicast_use_multiple_paths_ebgp_maximum_paths(
2220 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2222 vty_out(vty
, " maximum-paths %d\n",
2223 yang_dnode_get_uint16(dnode
, NULL
));
2226 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2227 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2228 "Forward packets over multiple paths\n"
2229 "Number of paths\n")
2231 DEFUN_YANG (bgp_maxpaths_ibgp
,
2232 bgp_maxpaths_ibgp_cmd
,
2233 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2234 "Forward packets over multiple paths\n"
2236 "Number of paths\n")
2239 char base_xpath
[XPATH_MAXLEN
];
2243 afi
= bgp_node_afi(vty
);
2244 safi
= bgp_node_safi(vty
);
2247 base_xpath
, sizeof(base_xpath
),
2248 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2249 yang_afi_safi_value2identity(afi
, safi
),
2250 bgp_afi_safi_get_container_str(afi
, safi
));
2252 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2253 argv
[idx_number
]->arg
);
2255 return nb_cli_apply_changes(vty
, NULL
);
2258 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2259 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2260 "Forward packets over multiple paths\n"
2262 "Number of paths\n")
2264 DEFUN_YANG (bgp_maxpaths_ibgp_cluster
,
2265 bgp_maxpaths_ibgp_cluster_cmd
,
2266 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2267 "Forward packets over multiple paths\n"
2270 "Match the cluster length\n")
2273 char base_xpath
[XPATH_MAXLEN
];
2277 afi
= bgp_node_afi(vty
);
2278 safi
= bgp_node_safi(vty
);
2281 base_xpath
, sizeof(base_xpath
),
2282 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2283 yang_afi_safi_value2identity(afi
, safi
),
2284 bgp_afi_safi_get_container_str(afi
, safi
));
2286 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2287 argv
[idx_number
]->arg
);
2290 base_xpath
, sizeof(base_xpath
),
2291 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/cluster-length-list",
2292 yang_afi_safi_value2identity(afi
, safi
),
2293 bgp_afi_safi_get_container_str(afi
, safi
));
2295 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, "true");
2297 return nb_cli_apply_changes(vty
, NULL
);
2300 void cli_show_bgp_global_afi_safi_ip_unicast_use_multiple_paths_ibgp_maximum_paths(
2301 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2303 vty_out(vty
, " maximum-paths ibgp %d",
2304 yang_dnode_get_uint16(dnode
, "./maximum-paths"));
2305 if (yang_dnode_get_bool(dnode
, "./cluster-length-list"))
2306 vty_out(vty
, " equal-cluster-length");
2310 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2311 "maximum-paths ibgp " CMD_RANGE_STR(
2312 1, MULTIPATH_NUM
) " equal-cluster-length",
2313 "Forward packets over multiple paths\n"
2316 "Match the cluster length\n")
2318 DEFUN_YANG (no_bgp_maxpaths
,
2319 no_bgp_maxpaths_cmd
,
2320 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2322 "Forward packets over multiple paths\n"
2323 "Number of paths\n")
2325 char base_xpath
[XPATH_MAXLEN
];
2329 afi
= bgp_node_afi(vty
);
2330 safi
= bgp_node_safi(vty
);
2333 base_xpath
, sizeof(base_xpath
),
2334 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ebgp/maximum-paths",
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
, NULL
);
2340 return nb_cli_apply_changes(vty
, NULL
);
2343 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2344 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2345 "Forward packets over multiple paths\n"
2346 "Number of paths\n")
2348 DEFUN_YANG (no_bgp_maxpaths_ibgp
,
2349 no_bgp_maxpaths_ibgp_cmd
,
2350 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2352 "Forward packets over multiple paths\n"
2355 "Match the cluster length\n")
2357 char base_xpath
[XPATH_MAXLEN
];
2361 afi
= bgp_node_afi(vty
);
2362 safi
= bgp_node_safi(vty
);
2365 base_xpath
, sizeof(base_xpath
),
2366 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2367 yang_afi_safi_value2identity(afi
, safi
),
2368 bgp_afi_safi_get_container_str(afi
, safi
));
2370 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, NULL
);
2373 base_xpath
, sizeof(base_xpath
),
2374 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/cluster-length-list",
2375 yang_afi_safi_value2identity(afi
, safi
),
2376 bgp_afi_safi_get_container_str(afi
, safi
));
2378 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, "false");
2380 return nb_cli_apply_changes(vty
, NULL
);
2383 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2384 "no maximum-paths ibgp [" CMD_RANGE_STR(
2385 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2387 "Forward packets over multiple paths\n"
2390 "Match the cluster length\n")
2392 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2393 afi_t afi
, safi_t safi
)
2395 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2396 vty_out(vty
, " maximum-paths %d\n",
2397 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2400 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2401 vty_out(vty
, " maximum-paths ibgp %d",
2402 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2403 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
2404 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
2405 vty_out(vty
, " equal-cluster-length");
2412 DEFUN_YANG (bgp_timers
,
2414 "timers bgp (0-65535) (0-65535)",
2415 "Adjust routing timers\n"
2417 "Keepalive interval\n"
2421 int idx_number_2
= 3;
2423 nb_cli_enqueue_change(vty
, "./global/global-config-timers/keepalive",
2424 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
2425 nb_cli_enqueue_change(vty
, "./global/global-config-timers/hold-time",
2426 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
2428 return nb_cli_apply_changes(vty
, NULL
);
2431 DEFUN_YANG (no_bgp_timers
,
2433 "no timers bgp [(0-65535) (0-65535)]",
2435 "Adjust routing timers\n"
2437 "Keepalive interval\n"
2440 nb_cli_enqueue_change(vty
, "./global/global-config-timers/keepalive",
2441 NB_OP_DESTROY
, NULL
);
2442 nb_cli_enqueue_change(vty
, "./global/global-config-timers/hold-time",
2443 NB_OP_DESTROY
, NULL
);
2445 return nb_cli_apply_changes(vty
, NULL
);
2448 void cli_show_router_bgp_route_reflector(struct vty
*vty
,
2449 struct lyd_node
*dnode
,
2452 if (yang_dnode_get_bool(dnode
, "./no-client-reflect"))
2453 vty_out(vty
, " no bgp client-to-client reflection\n");
2455 if (yang_dnode_get_bool(dnode
, "./allow-outbound-policy"))
2456 vty_out(vty
, " bgp route-reflector allow-outbound-policy\n");
2458 if (yang_dnode_exists(dnode
, "./route-reflector-cluster-id"))
2459 vty_out(vty
, " bgp cluster-id %s\n",
2460 yang_dnode_get_string(dnode
,
2461 "./route-reflector-cluster-id"));
2464 DEFUN_YANG(bgp_client_to_client_reflection
,
2465 bgp_client_to_client_reflection_cmd
,
2466 "bgp client-to-client reflection",
2467 "BGP specific commands\n"
2468 "Configure client to client route reflection\n"
2469 "reflection of routes allowed\n")
2471 nb_cli_enqueue_change(vty
, "./global/route-reflector/no-client-reflect",
2472 NB_OP_MODIFY
, "false");
2474 return nb_cli_apply_changes(vty
, NULL
);
2477 DEFUN_YANG(no_bgp_client_to_client_reflection
,
2478 no_bgp_client_to_client_reflection_cmd
,
2479 "no bgp client-to-client reflection",
2481 "BGP specific commands\n"
2482 "Configure client to client route reflection\n"
2483 "reflection of routes allowed\n")
2485 nb_cli_enqueue_change(vty
, "./global/route-reflector/no-client-reflect",
2486 NB_OP_MODIFY
, "true");
2488 return nb_cli_apply_changes(vty
, NULL
);
2491 void cli_show_router_bgp_route_selection(struct vty
*vty
,
2492 struct lyd_node
*dnode
,
2496 if (yang_dnode_get_bool(dnode
, "./always-compare-med"))
2497 vty_out(vty
, " bgp always-compare-med\n");
2499 if (yang_dnode_get_bool(dnode
, "./ignore-as-path-length"))
2500 vty_out(vty
, " bgp bestpath as-path ignore\n");
2502 if (yang_dnode_get_bool(dnode
, "./aspath-confed"))
2503 vty_out(vty
, " bgp bestpath as-path confed\n");
2505 if (yang_dnode_get_bool(dnode
, "./external-compare-router-id"))
2506 vty_out(vty
, " bgp bestpath compare-routerid\n");
2508 if (yang_dnode_get_bool(dnode
, "./allow-multiple-as")) {
2509 if (yang_dnode_get_bool(dnode
, "./multi-path-as-set"))
2511 " bgp bestpath as-path multipath-relax as-set\n");
2513 vty_out(vty
, " bgp bestpath as-path multipath-relax\n");
2516 if (yang_dnode_get_bool(dnode
, "./deterministic-med"))
2517 vty_out(vty
, " bgp deterministic-med\n");
2519 if (yang_dnode_get_bool(dnode
, "./confed-med")
2520 || yang_dnode_get_bool(dnode
, "./missing-as-worst-med")) {
2521 vty_out(vty
, " bgp bestpath med");
2522 if (yang_dnode_get_bool(dnode
, "./confed-med"))
2523 vty_out(vty
, " confed");
2524 if (yang_dnode_get_bool(dnode
, "./missing-as-worst-med"))
2525 vty_out(vty
, " missing-as-worst");
2530 /* "bgp always-compare-med" configuration. */
2531 DEFUN_YANG(bgp_always_compare_med
,
2532 bgp_always_compare_med_cmd
,
2533 "bgp always-compare-med",
2534 "BGP specific commands\n"
2535 "Allow comparing MED from different neighbors\n")
2537 nb_cli_enqueue_change(
2538 vty
, "./global/route-selection-options/always-compare-med",
2539 NB_OP_MODIFY
, "true");
2541 return nb_cli_apply_changes(vty
, NULL
);
2544 DEFUN_YANG(no_bgp_always_compare_med
,
2545 no_bgp_always_compare_med_cmd
,
2546 "no bgp always-compare-med",
2548 "BGP specific commands\n"
2549 "Allow comparing MED from different neighbors\n")
2551 nb_cli_enqueue_change(
2552 vty
, "./global/route-selection-options/always-compare-med",
2553 NB_OP_MODIFY
, "false");
2555 return nb_cli_apply_changes(vty
, NULL
);
2558 DEFUN_YANG(bgp_ebgp_requires_policy
,
2559 bgp_ebgp_requires_policy_cmd
,
2560 "bgp ebgp-requires-policy",
2561 "BGP specific commands\n"
2562 "Require in and out policy for eBGP peers (RFC8212)\n")
2564 nb_cli_enqueue_change(vty
, "./global/ebgp-requires-policy",
2565 NB_OP_MODIFY
, "true");
2566 return nb_cli_apply_changes(vty
, NULL
);
2569 DEFUN_YANG(no_bgp_ebgp_requires_policy
,
2570 no_bgp_ebgp_requires_policy_cmd
,
2571 "no bgp ebgp-requires-policy",
2573 "BGP specific commands\n"
2574 "Require in and out policy for eBGP peers (RFC8212)\n")
2576 nb_cli_enqueue_change(vty
, "./global/ebgp-requires-policy",
2577 NB_OP_MODIFY
, "false");
2578 return nb_cli_apply_changes(vty
, NULL
);
2581 void cli_show_router_bgp_ebgp_requires_policy(struct vty
*vty
,
2582 struct lyd_node
*dnode
,
2585 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_EBGP_REQUIRES_POLICY
)
2586 vty_out(vty
, " bgp ebgp-requires-policy\n");
2589 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2590 "bgp reject-as-sets",
2591 "BGP specific commands\n"
2592 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2594 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2595 struct listnode
*node
, *nnode
;
2598 bgp
->reject_as_sets
= true;
2600 /* Reset existing BGP sessions to reject routes
2601 * with aspath containing AS_SET or AS_CONFED_SET.
2603 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2604 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2605 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2606 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2607 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2614 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2615 "no bgp reject-as-sets",
2617 "BGP specific commands\n"
2618 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2620 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2621 struct listnode
*node
, *nnode
;
2624 bgp
->reject_as_sets
= false;
2626 /* Reset existing BGP sessions to reject routes
2627 * with aspath containing AS_SET or AS_CONFED_SET.
2629 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2630 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2631 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2632 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2633 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2640 /* "bgp deterministic-med" configuration. */
2641 DEFUN_YANG (bgp_deterministic_med
,
2642 bgp_deterministic_med_cmd
,
2643 "bgp deterministic-med",
2644 "BGP specific commands\n"
2645 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2647 nb_cli_enqueue_change(
2648 vty
, "./global/route-selection-options/deterministic-med",
2649 NB_OP_MODIFY
, "true");
2651 return nb_cli_apply_changes(vty
, NULL
);
2654 DEFUN_YANG (no_bgp_deterministic_med
,
2655 no_bgp_deterministic_med_cmd
,
2656 "no bgp deterministic-med",
2658 "BGP specific commands\n"
2659 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2661 nb_cli_enqueue_change(
2662 vty
, "./global/route-selection-options/deterministic-med",
2663 NB_OP_MODIFY
, "false");
2665 return nb_cli_apply_changes(vty
, NULL
);
2668 /* "bgp graceful-restart mode" configuration. */
2669 DEFUN (bgp_graceful_restart
,
2670 bgp_graceful_restart_cmd
,
2671 "bgp graceful-restart",
2672 "BGP specific commands\n"
2676 int ret
= BGP_GR_FAILURE
;
2678 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2679 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2681 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2683 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2685 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2688 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2689 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2691 "Graceful restart configuration changed, reset all peers to take effect\n");
2692 return bgp_vty_return(vty
, ret
);
2695 DEFUN (no_bgp_graceful_restart
,
2696 no_bgp_graceful_restart_cmd
,
2697 "no bgp graceful-restart",
2699 "BGP specific commands\n"
2703 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2705 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2706 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2708 int ret
= BGP_GR_FAILURE
;
2710 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2712 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2715 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2716 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2718 "Graceful restart configuration changed, reset all peers to take effect\n");
2720 return bgp_vty_return(vty
, ret
);
2723 DEFUN (bgp_graceful_restart_stalepath_time
,
2724 bgp_graceful_restart_stalepath_time_cmd
,
2725 "bgp graceful-restart stalepath-time (1-4095)",
2726 "BGP specific commands\n"
2727 "Graceful restart capability parameters\n"
2728 "Set the max time to hold onto restarting peer's stale paths\n"
2729 "Delay value (seconds)\n")
2731 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2735 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2736 bgp
->stalepath_time
= stalepath
;
2740 DEFUN (bgp_graceful_restart_restart_time
,
2741 bgp_graceful_restart_restart_time_cmd
,
2742 "bgp graceful-restart restart-time (1-4095)",
2743 "BGP specific commands\n"
2744 "Graceful restart capability parameters\n"
2745 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2746 "Delay value (seconds)\n")
2748 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2752 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2753 bgp
->restart_time
= restart
;
2757 DEFUN (bgp_graceful_restart_select_defer_time
,
2758 bgp_graceful_restart_select_defer_time_cmd
,
2759 "bgp graceful-restart select-defer-time (0-3600)",
2760 "BGP specific commands\n"
2761 "Graceful restart capability parameters\n"
2762 "Set the time to defer the BGP route selection after restart\n"
2763 "Delay value (seconds, 0 - disable)\n")
2765 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2767 uint32_t defer_time
;
2769 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2770 bgp
->select_defer_time
= defer_time
;
2771 if (defer_time
== 0)
2772 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2774 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2779 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2780 no_bgp_graceful_restart_stalepath_time_cmd
,
2781 "no bgp graceful-restart stalepath-time [(1-4095)]",
2783 "BGP specific commands\n"
2784 "Graceful restart capability parameters\n"
2785 "Set the max time to hold onto restarting peer's stale paths\n"
2786 "Delay value (seconds)\n")
2788 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2790 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2794 DEFUN (no_bgp_graceful_restart_restart_time
,
2795 no_bgp_graceful_restart_restart_time_cmd
,
2796 "no bgp graceful-restart restart-time [(1-4095)]",
2798 "BGP specific commands\n"
2799 "Graceful restart capability parameters\n"
2800 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2801 "Delay value (seconds)\n")
2803 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2805 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2809 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2810 no_bgp_graceful_restart_select_defer_time_cmd
,
2811 "no bgp graceful-restart select-defer-time [(0-3600)]",
2813 "BGP specific commands\n"
2814 "Graceful restart capability parameters\n"
2815 "Set the time to defer the BGP route selection after restart\n"
2816 "Delay value (seconds)\n")
2818 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2820 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2821 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2826 DEFUN (bgp_graceful_restart_preserve_fw
,
2827 bgp_graceful_restart_preserve_fw_cmd
,
2828 "bgp graceful-restart preserve-fw-state",
2829 "BGP specific commands\n"
2830 "Graceful restart capability parameters\n"
2831 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2833 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2834 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2838 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2839 no_bgp_graceful_restart_preserve_fw_cmd
,
2840 "no bgp graceful-restart preserve-fw-state",
2842 "BGP specific commands\n"
2843 "Graceful restart capability parameters\n"
2844 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2846 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2847 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2851 DEFUN (bgp_graceful_restart_disable
,
2852 bgp_graceful_restart_disable_cmd
,
2853 "bgp graceful-restart-disable",
2854 "BGP specific commands\n"
2857 int ret
= BGP_GR_FAILURE
;
2859 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2861 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
2863 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2865 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
2867 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
2870 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2872 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
2874 "Graceful restart configuration changed, reset all peers to take effect\n");
2876 return bgp_vty_return(vty
, ret
);
2879 DEFUN (no_bgp_graceful_restart_disable
,
2880 no_bgp_graceful_restart_disable_cmd
,
2881 "no bgp graceful-restart-disable",
2883 "BGP specific commands\n"
2887 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2889 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2891 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
2893 int ret
= BGP_GR_FAILURE
;
2895 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
2897 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2900 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2902 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
2904 "Graceful restart configuration changed, reset all peers to take effect\n");
2906 return bgp_vty_return(vty
, ret
);
2909 DEFUN (bgp_neighbor_graceful_restart_set
,
2910 bgp_neighbor_graceful_restart_set_cmd
,
2911 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
2919 int ret
= BGP_GR_FAILURE
;
2921 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2923 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2925 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
2927 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2929 return CMD_WARNING_CONFIG_FAILED
;
2931 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
2933 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2934 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2936 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2938 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
2940 "Graceful restart configuration changed, reset this peer to take effect\n");
2942 return bgp_vty_return(vty
, ret
);
2945 DEFUN (no_bgp_neighbor_graceful_restart
,
2946 no_bgp_neighbor_graceful_restart_set_cmd
,
2947 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
2955 int ret
= BGP_GR_FAILURE
;
2958 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2960 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2962 return CMD_WARNING_CONFIG_FAILED
;
2964 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2966 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
2968 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
2970 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2971 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2973 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2975 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
2977 "Graceful restart configuration changed, reset this peer to take effect\n");
2979 return bgp_vty_return(vty
, ret
);
2982 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
2983 bgp_neighbor_graceful_restart_helper_set_cmd
,
2984 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
2987 GR_NEIGHBOR_HELPER_CMD
2992 int ret
= BGP_GR_FAILURE
;
2994 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2996 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2998 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3000 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3003 return CMD_WARNING_CONFIG_FAILED
;
3006 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3008 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3009 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3011 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3013 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3015 "Graceful restart configuration changed, reset this peer to take effect\n");
3017 return bgp_vty_return(vty
, ret
);
3020 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3021 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3022 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3026 NO_GR_NEIGHBOR_HELPER_CMD
3030 int ret
= BGP_GR_FAILURE
;
3033 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3035 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3037 return CMD_WARNING_CONFIG_FAILED
;
3039 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3041 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3043 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3045 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3046 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3048 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3050 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3052 "Graceful restart configuration changed, reset this peer to take effect\n");
3054 return bgp_vty_return(vty
, ret
);
3057 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3058 bgp_neighbor_graceful_restart_disable_set_cmd
,
3059 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3062 GR_NEIGHBOR_DISABLE_CMD
3067 int ret
= BGP_GR_FAILURE
;
3069 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3071 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3073 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3075 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3077 return CMD_WARNING_CONFIG_FAILED
;
3079 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3081 if (peer
->bgp
->t_startup
)
3082 bgp_peer_gr_flags_update(peer
);
3084 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3085 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3087 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3089 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3091 "Graceful restart configuration changed, reset this peer to take effect\n");
3093 return bgp_vty_return(vty
, ret
);
3096 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3097 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3098 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3102 NO_GR_NEIGHBOR_DISABLE_CMD
3106 int ret
= BGP_GR_FAILURE
;
3109 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3111 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3113 return CMD_WARNING_CONFIG_FAILED
;
3115 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3117 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3119 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3121 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3122 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3124 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3126 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3128 "Graceful restart configuration changed, reset this peer to take effect\n");
3130 return bgp_vty_return(vty
, ret
);
3133 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3134 bgp_graceful_restart_disable_eor_cmd
,
3135 "bgp graceful-restart disable-eor",
3136 "BGP specific commands\n"
3137 "Graceful restart configuration parameters\n"
3138 "Disable EOR Check\n")
3140 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3141 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3146 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3147 no_bgp_graceful_restart_disable_eor_cmd
,
3148 "no bgp graceful-restart disable-eor",
3150 "BGP specific commands\n"
3151 "Graceful restart configuration parameters\n"
3152 "Disable EOR Check\n")
3154 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3155 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3160 DEFUN (bgp_graceful_restart_rib_stale_time
,
3161 bgp_graceful_restart_rib_stale_time_cmd
,
3162 "bgp graceful-restart rib-stale-time (1-3600)",
3163 "BGP specific commands\n"
3164 "Graceful restart configuration parameters\n"
3165 "Specify the stale route removal timer in rib\n"
3166 "Delay value (seconds)\n")
3168 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3170 uint32_t stale_time
;
3172 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3173 bgp
->rib_stale_time
= stale_time
;
3174 /* Send the stale timer update message to RIB */
3175 if (bgp_zebra_stale_timer_update(bgp
))
3181 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3182 no_bgp_graceful_restart_rib_stale_time_cmd
,
3183 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3185 "BGP specific commands\n"
3186 "Graceful restart configuration parameters\n"
3187 "Specify the stale route removal timer in rib\n"
3188 "Delay value (seconds)\n")
3190 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3192 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3193 /* Send the stale timer update message to RIB */
3194 if (bgp_zebra_stale_timer_update(bgp
))
3200 static inline int bgp_initiate_graceful_shut_unshut(struct bgp
*bgp
,
3204 bgp_static_redo_import_check(bgp
);
3205 bgp_redistribute_redo(bgp
);
3206 if (bgp_clear_star_soft_out(bgp
->name
, errmsg
, errmsg_len
) < 0)
3208 if (bgp_clear_star_soft_in(bgp
->name
, errmsg
, errmsg_len
) < 0)
3214 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3216 struct listnode
*node
, *nnode
;
3218 bool vrf_cfg
= false;
3219 char errmsg
[BUFSIZ
] = {'\0'};
3221 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3224 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3225 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3226 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3228 "%% graceful-shutdown configuration found in vrf %s\n",
3229 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3230 VRF_DEFAULT_NAME
: bgp
->name
);
3237 "%%Failed: global graceful-shutdown not permitted\n");
3241 /* Set flag globally */
3242 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3244 /* Initiate processing for all BGP instances. */
3245 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3246 if (bgp_initiate_graceful_shut_unshut(bgp
, errmsg
,
3250 vty_out(vty
, "%s\n", errmsg
);
3256 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3258 struct listnode
*node
, *nnode
;
3260 char errmsg
[BUFSIZ
] = {'\0'};
3262 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3265 /* Unset flag globally */
3266 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3268 /* Initiate processing for all BGP instances. */
3269 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3270 if (bgp_initiate_graceful_shut_unshut(bgp
, errmsg
,
3274 vty_out(vty
, "%s\n", errmsg
);
3280 /* "bgp graceful-shutdown" configuration */
3281 DEFUN (bgp_graceful_shutdown
,
3282 bgp_graceful_shutdown_cmd
,
3283 "bgp graceful-shutdown",
3285 "Graceful shutdown parameters\n")
3287 if (vty
->node
== CONFIG_NODE
)
3288 return bgp_global_graceful_shutdown_config_vty(vty
);
3290 nb_cli_enqueue_change(vty
, "./global/graceful-shutdown/enable",
3291 NB_OP_MODIFY
, "true");
3293 return nb_cli_apply_changes(vty
, NULL
);
3296 DEFUN_YANG (no_bgp_graceful_shutdown
,
3297 no_bgp_graceful_shutdown_cmd
,
3298 "no bgp graceful-shutdown",
3301 "Graceful shutdown parameters\n")
3303 if (vty
->node
== CONFIG_NODE
)
3304 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3306 nb_cli_enqueue_change(vty
, "./global/graceful-shutdown/enable",
3307 NB_OP_MODIFY
, "false");
3309 return nb_cli_apply_changes(vty
, NULL
);
3312 void cli_show_router_bgp_graceful_shutdown(struct vty
*vty
,
3313 struct lyd_node
*dnode
,
3316 if (yang_dnode_get_bool(dnode
, NULL
))
3317 vty_out(vty
, " bgp graceful-shutdown\n");
3320 /* "bgp fast-external-failover" configuration. */
3321 DEFUN_YANG (bgp_fast_external_failover
,
3322 bgp_fast_external_failover_cmd
,
3323 "bgp fast-external-failover",
3325 "Immediately reset session if a link to a directly connected external peer goes down\n")
3327 nb_cli_enqueue_change(vty
, "./global/fast-external-failover",
3328 NB_OP_MODIFY
, "false");
3330 return nb_cli_apply_changes(vty
, NULL
);
3333 DEFUN_YANG (no_bgp_fast_external_failover
,
3334 no_bgp_fast_external_failover_cmd
,
3335 "no bgp fast-external-failover",
3338 "Immediately reset session if a link to a directly connected external peer goes down\n")
3340 nb_cli_enqueue_change(vty
, "./global/fast-external-failover",
3341 NB_OP_MODIFY
, "true");
3343 return nb_cli_apply_changes(vty
, NULL
);
3346 void cli_show_router_bgp_fast_external_failover(struct vty
*vty
,
3347 struct lyd_node
*dnode
,
3350 if (!yang_dnode_get_bool(dnode
, NULL
))
3351 vty_out(vty
, " no bgp fast-external-failover\n");
3354 /* "bgp bestpath compare-routerid" configuration. */
3355 DEFUN_YANG(bgp_bestpath_compare_router_id
,
3356 bgp_bestpath_compare_router_id_cmd
,
3357 "bgp bestpath compare-routerid",
3358 "BGP specific commands\n"
3359 "Change the default bestpath selection\n"
3360 "Compare router-id for identical EBGP paths\n")
3362 nb_cli_enqueue_change(
3364 "./global/route-selection-options/external-compare-router-id",
3365 NB_OP_MODIFY
, "true");
3367 return nb_cli_apply_changes(vty
, NULL
);
3370 DEFUN_YANG(no_bgp_bestpath_compare_router_id
,
3371 no_bgp_bestpath_compare_router_id_cmd
,
3372 "no bgp bestpath compare-routerid",
3374 "BGP specific commands\n"
3375 "Change the default bestpath selection\n"
3376 "Compare router-id for identical EBGP paths\n")
3378 nb_cli_enqueue_change(
3380 "./global/route-selection-options/external-compare-router-id",
3381 NB_OP_MODIFY
, "false");
3383 return nb_cli_apply_changes(vty
, NULL
);
3386 /* "bgp bestpath as-path ignore" configuration. */
3387 DEFUN_YANG(bgp_bestpath_aspath_ignore
,
3388 bgp_bestpath_aspath_ignore_cmd
,
3389 "bgp bestpath as-path ignore",
3390 "BGP specific commands\n"
3391 "Change the default bestpath selection\n"
3392 "AS-path attribute\n"
3393 "Ignore as-path length in selecting a route\n")
3395 nb_cli_enqueue_change(
3396 vty
, "./global/route-selection-options/ignore-as-path-length",
3397 NB_OP_MODIFY
, "true");
3399 return nb_cli_apply_changes(vty
, NULL
);
3402 DEFUN_YANG(no_bgp_bestpath_aspath_ignore
,
3403 no_bgp_bestpath_aspath_ignore_cmd
,
3404 "no bgp bestpath as-path ignore",
3406 "BGP specific commands\n"
3407 "Change the default bestpath selection\n"
3408 "AS-path attribute\n"
3409 "Ignore as-path length in selecting a route\n")
3411 nb_cli_enqueue_change(
3412 vty
, "./global/route-selection-options/ignore-as-path-length",
3413 NB_OP_MODIFY
, "false");
3415 return nb_cli_apply_changes(vty
, NULL
);
3418 /* "bgp bestpath as-path confed" configuration. */
3419 DEFUN_YANG (bgp_bestpath_aspath_confed
,
3420 bgp_bestpath_aspath_confed_cmd
,
3421 "bgp bestpath as-path confed",
3422 "BGP specific commands\n"
3423 "Change the default bestpath selection\n"
3424 "AS-path attribute\n"
3425 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3427 nb_cli_enqueue_change(vty
,
3428 "./global/route-selection-options/aspath-confed",
3429 NB_OP_MODIFY
, "true");
3431 return nb_cli_apply_changes(vty
, NULL
);
3434 DEFUN_YANG (no_bgp_bestpath_aspath_confed
,
3435 no_bgp_bestpath_aspath_confed_cmd
,
3436 "no bgp bestpath as-path confed",
3438 "BGP specific commands\n"
3439 "Change the default bestpath selection\n"
3440 "AS-path attribute\n"
3441 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3443 nb_cli_enqueue_change(vty
,
3444 "./global/route-selection-options/aspath-confed",
3445 NB_OP_MODIFY
, "false");
3447 return nb_cli_apply_changes(vty
, NULL
);
3450 /* "bgp bestpath as-path multipath-relax" configuration. */
3451 DEFUN_YANG (bgp_bestpath_aspath_multipath_relax
,
3452 bgp_bestpath_aspath_multipath_relax_cmd
,
3453 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3454 "BGP specific commands\n"
3455 "Change the default bestpath selection\n"
3456 "AS-path attribute\n"
3457 "Allow load sharing across routes that have different AS paths (but same length)\n"
3458 "Generate an AS_SET\n"
3459 "Do not generate an AS_SET\n")
3463 nb_cli_enqueue_change(
3464 vty
, "./global/route-selection-options/allow-multiple-as",
3465 NB_OP_MODIFY
, "true");
3466 if (argv_find(argv
, argc
, "as-set", &idx
))
3467 nb_cli_enqueue_change(
3469 "./global/route-selection-options/multi-path-as-set",
3470 NB_OP_MODIFY
, "true");
3472 nb_cli_enqueue_change(
3474 "./global/route-selection-options/multi-path-as-set",
3475 NB_OP_MODIFY
, "false");
3477 return nb_cli_apply_changes(vty
, NULL
);
3480 DEFUN_YANG (no_bgp_bestpath_aspath_multipath_relax
,
3481 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3482 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3484 "BGP specific commands\n"
3485 "Change the default bestpath selection\n"
3486 "AS-path attribute\n"
3487 "Allow load sharing across routes that have different AS paths (but same length)\n"
3488 "Generate an AS_SET\n"
3489 "Do not generate an AS_SET\n")
3491 nb_cli_enqueue_change(
3492 vty
, "./global/route-selection-options/allow-multiple-as",
3493 NB_OP_MODIFY
, "false");
3494 nb_cli_enqueue_change(
3495 vty
, "./global/route-selection-options/multi-path-as-set",
3496 NB_OP_MODIFY
, "false");
3498 return nb_cli_apply_changes(vty
, NULL
);
3501 /* "bgp log-neighbor-changes" configuration. */
3502 DEFUN_YANG(bgp_log_neighbor_changes
,
3503 bgp_log_neighbor_changes_cmd
,
3504 "bgp log-neighbor-changes",
3505 "BGP specific commands\n"
3506 "Log neighbor up/down and reset reason\n")
3508 nb_cli_enqueue_change(
3509 vty
, "./global/global-neighbor-config/log-neighbor-changes",
3510 NB_OP_MODIFY
, "true");
3512 return nb_cli_apply_changes(vty
, NULL
);
3515 DEFUN_YANG(no_bgp_log_neighbor_changes
,
3516 no_bgp_log_neighbor_changes_cmd
,
3517 "no bgp log-neighbor-changes",
3519 "BGP specific commands\n"
3520 "Log neighbor up/down and reset reason\n")
3522 nb_cli_enqueue_change(
3523 vty
, "./global/global-neighbor-config/log-neighbor-changes",
3524 NB_OP_MODIFY
, "false");
3526 return nb_cli_apply_changes(vty
, NULL
);
3529 /* "bgp bestpath med" configuration. */
3530 DEFUN_YANG (bgp_bestpath_med
,
3531 bgp_bestpath_med_cmd
,
3532 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3533 "BGP specific commands\n"
3534 "Change the default bestpath selection\n"
3536 "Compare MED among confederation paths\n"
3537 "Treat missing MED as the least preferred one\n"
3538 "Treat missing MED as the least preferred one\n"
3539 "Compare MED among confederation paths\n")
3542 bool confed
= false;
3543 bool worst_med
= false;
3546 if (argv_find(argv
, argc
, "confed", &idx
))
3549 nb_cli_enqueue_change(vty
,
3550 "./global/route-selection-options/confed-med",
3551 NB_OP_MODIFY
, confed
? "true" : "false");
3554 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3557 nb_cli_enqueue_change(
3558 vty
, "./global/route-selection-options/missing-as-worst-med",
3559 NB_OP_MODIFY
, worst_med
? "true" : "false");
3561 return nb_cli_apply_changes(vty
, NULL
);
3564 DEFUN_YANG (no_bgp_bestpath_med
,
3565 no_bgp_bestpath_med_cmd
,
3566 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3568 "BGP specific commands\n"
3569 "Change the default bestpath selection\n"
3571 "Compare MED among confederation paths\n"
3572 "Treat missing MED as the least preferred one\n"
3573 "Treat missing MED as the least preferred one\n"
3574 "Compare MED among confederation paths\n")
3578 if (argv_find(argv
, argc
, "confed", &idx
))
3579 nb_cli_enqueue_change(
3580 vty
, "./global/route-selection-options/confed-med",
3581 NB_OP_MODIFY
, "false");
3584 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3585 nb_cli_enqueue_change(
3587 "./global/route-selection-options/missing-as-worst-med",
3588 NB_OP_MODIFY
, "false");
3590 return nb_cli_apply_changes(vty
, NULL
);
3593 /* "bgp bestpath bandwidth" configuration. */
3594 DEFPY (bgp_bestpath_bw
,
3595 bgp_bestpath_bw_cmd
,
3596 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3597 "BGP specific commands\n"
3598 "Change the default bestpath selection\n"
3599 "Link Bandwidth attribute\n"
3600 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3601 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3602 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3604 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3609 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3610 return CMD_ERR_INCOMPLETE
;
3612 if (!strcmp(bw_cfg
, "ignore"))
3613 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3614 else if (!strcmp(bw_cfg
, "skip-missing"))
3615 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3616 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3617 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3619 return CMD_ERR_NO_MATCH
;
3621 /* This config is used in route install, so redo that. */
3622 FOREACH_AFI_SAFI (afi
, safi
) {
3623 if (!bgp_fibupd_safi(safi
))
3625 bgp_zebra_announce_table(bgp
, afi
, safi
);
3631 DEFPY (no_bgp_bestpath_bw
,
3632 no_bgp_bestpath_bw_cmd
,
3633 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3635 "BGP specific commands\n"
3636 "Change the default bestpath selection\n"
3637 "Link Bandwidth attribute\n"
3638 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3639 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3640 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3642 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3646 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3648 /* This config is used in route install, so redo that. */
3649 FOREACH_AFI_SAFI (afi
, safi
) {
3650 if (!bgp_fibupd_safi(safi
))
3652 bgp_zebra_announce_table(bgp
, afi
, safi
);
3657 /* "no bgp default ipv4-unicast". */
3658 DEFUN (no_bgp_default_ipv4_unicast
,
3659 no_bgp_default_ipv4_unicast_cmd
,
3660 "no bgp default ipv4-unicast",
3662 "BGP specific commands\n"
3663 "Configure BGP defaults\n"
3664 "Activate ipv4-unicast for a peer by default\n")
3666 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3667 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
);
3671 DEFUN (bgp_default_ipv4_unicast
,
3672 bgp_default_ipv4_unicast_cmd
,
3673 "bgp default ipv4-unicast",
3674 "BGP specific commands\n"
3675 "Configure BGP defaults\n"
3676 "Activate ipv4-unicast for a peer by default\n")
3678 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3679 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
);
3683 /* Display hostname in certain command outputs */
3684 DEFUN_YANG (bgp_default_show_hostname
,
3685 bgp_default_show_hostname_cmd
,
3686 "bgp default show-hostname",
3687 "BGP specific commands\n"
3688 "Configure BGP defaults\n"
3689 "Show hostname in certain command outputs\n")
3691 nb_cli_enqueue_change(vty
, "./global/show-hostname", NB_OP_MODIFY
,
3694 return nb_cli_apply_changes(vty
, NULL
);
3697 DEFUN_YANG(no_bgp_default_show_hostname
,
3698 no_bgp_default_show_hostname_cmd
,
3699 "no bgp default show-hostname",
3701 "BGP specific commands\n"
3702 "Configure BGP defaults\n"
3703 "Show hostname in certain command outputs\n")
3705 nb_cli_enqueue_change(vty
, "./global/show-hostname", NB_OP_MODIFY
,
3708 return nb_cli_apply_changes(vty
, NULL
);
3711 void cli_show_router_bgp_show_hostname(struct vty
*vty
, struct lyd_node
*dnode
,
3714 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SHOW_HOSTNAME
)
3715 vty_out(vty
, " bgp default show-hostname\n");
3718 /* Display hostname in certain command outputs */
3719 DEFUN_YANG(bgp_default_show_nexthop_hostname
,
3720 bgp_default_show_nexthop_hostname_cmd
,
3721 "bgp default show-nexthop-hostname",
3722 "BGP specific commands\n"
3723 "Configure BGP defaults\n"
3724 "Show hostname for nexthop in certain command outputs\n")
3726 nb_cli_enqueue_change(vty
, "./global/show-nexthop-hostname",
3727 NB_OP_MODIFY
, "true");
3729 return nb_cli_apply_changes(vty
, NULL
);
3732 DEFUN (no_bgp_default_show_nexthop_hostname
,
3733 no_bgp_default_show_nexthop_hostname_cmd
,
3734 "no bgp default show-nexthop-hostname",
3736 "BGP specific commands\n"
3737 "Configure BGP defaults\n"
3738 "Show hostname for nexthop in certain command outputs\n")
3740 nb_cli_enqueue_change(vty
, "./global/show-nexthop-hostname",
3741 NB_OP_MODIFY
, "false");
3743 return nb_cli_apply_changes(vty
, NULL
);
3746 void cli_show_router_bgp_show_nexthop_hostname(struct vty
*vty
,
3747 struct lyd_node
*dnode
,
3750 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SHOW_HOSTNAME
)
3751 vty_out(vty
, " bgp default show-nexthop-hostname\n");
3754 /* "bgp network import-check" configuration. */
3755 DEFUN_YANG(bgp_network_import_check
,
3756 bgp_network_import_check_cmd
,
3757 "bgp network import-check",
3758 "BGP specific commands\n"
3759 "BGP network command\n"
3760 "Check BGP network route exists in IGP\n")
3762 nb_cli_enqueue_change(vty
, "./global/import-check", NB_OP_MODIFY
,
3765 return nb_cli_apply_changes(vty
, NULL
);
3768 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
3769 "bgp network import-check exact",
3770 "BGP specific commands\n"
3771 "BGP network command\n"
3772 "Check BGP network route exists in IGP\n"
3773 "Match route precisely\n")
3775 DEFUN_YANG(no_bgp_network_import_check
,
3776 no_bgp_network_import_check_cmd
,
3777 "no bgp network import-check",
3779 "BGP specific commands\n"
3780 "BGP network command\n"
3781 "Check BGP network route exists in IGP\n")
3783 nb_cli_enqueue_change(vty
, "./global/import-check", NB_OP_MODIFY
,
3786 return nb_cli_apply_changes(vty
, NULL
);
3789 void cli_show_router_bgp_import_check(struct vty
*vty
, struct lyd_node
*dnode
,
3792 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_IMPORT_CHECK
)
3793 vty_out(vty
, " bgp network import-check\n");
3796 DEFUN_YANG(bgp_default_local_preference
,
3797 bgp_default_local_preference_cmd
,
3798 "bgp default local-preference (0-4294967295)",
3799 "BGP specific commands\n"
3800 "Configure BGP defaults\n"
3801 "local preference (higher=more preferred)\n"
3802 "Configure default local preference value\n")
3806 nb_cli_enqueue_change(vty
, "./global/local-pref", NB_OP_MODIFY
,
3807 argv
[idx_number
]->arg
);
3809 return nb_cli_apply_changes(vty
, NULL
);
3812 DEFUN_YANG(no_bgp_default_local_preference
,
3813 no_bgp_default_local_preference_cmd
,
3814 "no bgp default local-preference [(0-4294967295)]",
3816 "BGP specific commands\n"
3817 "Configure BGP defaults\n"
3818 "local preference (higher=more preferred)\n"
3819 "Configure default local preference value\n")
3821 nb_cli_enqueue_change(vty
, "./global/local-pref", NB_OP_MODIFY
, NULL
);
3823 return nb_cli_apply_changes(vty
, NULL
);
3826 void cli_show_router_bgp_local_pref(struct vty
*vty
, struct lyd_node
*dnode
,
3829 vty_out(vty
, " bgp default local-preference %u\n",
3830 yang_dnode_get_uint32(dnode
, NULL
));
3834 DEFUN_YANG(bgp_default_subgroup_pkt_queue_max
,
3835 bgp_default_subgroup_pkt_queue_max_cmd
,
3836 "bgp default subgroup-pkt-queue-max (20-100)",
3837 "BGP specific commands\n"
3838 "Configure BGP defaults\n"
3839 "subgroup-pkt-queue-max\n"
3840 "Configure subgroup packet queue max\n")
3844 nb_cli_enqueue_change(
3846 "./global/global-update-group-config/subgroup-pkt-queue-size",
3847 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
3849 return nb_cli_apply_changes(vty
, NULL
);
3852 DEFUN_YANG(no_bgp_default_subgroup_pkt_queue_max
,
3853 no_bgp_default_subgroup_pkt_queue_max_cmd
,
3854 "no bgp default subgroup-pkt-queue-max [(20-100)]",
3856 "BGP specific commands\n"
3857 "Configure BGP defaults\n"
3858 "subgroup-pkt-queue-max\n"
3859 "Configure subgroup packet queue max\n")
3861 nb_cli_enqueue_change(
3863 "./global/global-update-group-config/subgroup-pkt-queue-size",
3864 NB_OP_MODIFY
, NULL
);
3866 return nb_cli_apply_changes(vty
, NULL
);
3869 void cli_show_router_global_update_group_config_subgroup_pkt_queue_size(
3870 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
3872 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
3873 yang_dnode_get_uint32(dnode
, NULL
));
3876 DEFUN_YANG(bgp_rr_allow_outbound_policy
,
3877 bgp_rr_allow_outbound_policy_cmd
,
3878 "bgp route-reflector allow-outbound-policy",
3879 "BGP specific commands\n"
3880 "Allow modifications made by out route-map\n"
3881 "on ibgp neighbors\n")
3883 nb_cli_enqueue_change(vty
,
3884 "./global/route-reflector/allow-outbound-policy",
3885 NB_OP_MODIFY
, "true");
3887 return nb_cli_apply_changes(vty
, NULL
);
3890 DEFUN_YANG(no_bgp_rr_allow_outbound_policy
,
3891 no_bgp_rr_allow_outbound_policy_cmd
,
3892 "no bgp route-reflector allow-outbound-policy",
3894 "BGP specific commands\n"
3895 "Allow modifications made by out route-map\n"
3896 "on ibgp neighbors\n")
3898 nb_cli_enqueue_change(vty
,
3899 "./global/route-reflector/allow-outbound-policy",
3900 NB_OP_MODIFY
, "false");
3902 return nb_cli_apply_changes(vty
, NULL
);
3906 void cli_show_router_global_neighbor_config(struct vty
*vty
,
3907 struct lyd_node
*dnode
,
3910 uint32_t write_quanta
, read_quanta
;
3912 if (yang_dnode_get_bool(dnode
, "./log-neighbor-changes"))
3913 vty_out(vty
, " bgp log-neighbor-changes\n");
3915 if (yang_dnode_exists(dnode
, "./dynamic-neighbors-limit")) {
3916 uint32_t listen_limit
= yang_dnode_get_uint32(
3917 dnode
, "./dynamic-neighbors-limit");
3918 vty_out(vty
, " bgp listen limit %u\n", listen_limit
);
3921 write_quanta
= yang_dnode_get_uint32(
3922 dnode
, "./packet-quanta-config/wpkt-quanta");
3923 if (write_quanta
!= BGP_WRITE_PACKET_MAX
)
3924 vty_out(vty
, " write-quanta %d\n", write_quanta
);
3926 read_quanta
= yang_dnode_get_uint32(
3927 dnode
, "./packet-quanta-config/rpkt-quanta");
3929 if (read_quanta
!= BGP_READ_PACKET_MAX
)
3930 vty_out(vty
, " read-quanta %d\n", read_quanta
);
3933 DEFUN_YANG(bgp_listen_limit
,
3934 bgp_listen_limit_cmd
,
3935 "bgp listen limit (1-5000)",
3936 "BGP specific commands\n"
3937 "BGP Dynamic Neighbors listen commands\n"
3938 "Maximum number of BGP Dynamic Neighbors that can be created\n"
3939 "Configure Dynamic Neighbors listen limit value\n")
3943 nb_cli_enqueue_change(
3944 vty
, "./global/global-neighbor-config/dynamic-neighbors-limit",
3945 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
3947 return nb_cli_apply_changes(vty
, NULL
);
3950 DEFUN_YANG(no_bgp_listen_limit
,
3951 no_bgp_listen_limit_cmd
,
3952 "no bgp listen limit [(1-5000)]",
3954 "BGP specific commands\n"
3955 "BGP Dynamic Neighbors listen commands\n"
3956 "Maximum number of BGP Dynamic Neighbors that can be created\n"
3957 "Configure Dynamic Neighbors listen limit value\n")
3959 nb_cli_enqueue_change(
3960 vty
, "./global/global-neighbor-config/dynamic-neighbors-limit",
3961 NB_OP_DESTROY
, NULL
);
3963 return nb_cli_apply_changes(vty
, NULL
);
3968 * Check if this listen range is already configured. Check for exact
3969 * match or overlap based on input.
3971 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
3972 struct prefix
*range
, int exact
)
3974 struct listnode
*node
, *nnode
;
3975 struct listnode
*node1
, *nnode1
;
3976 struct peer_group
*group
;
3981 afi
= family2afi(range
->family
);
3982 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
3983 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
3986 match
= prefix_same(range
, lr
);
3988 match
= (prefix_match(range
, lr
)
3989 || prefix_match(lr
, range
));
3998 DEFUN (bgp_listen_range
,
3999 bgp_listen_range_cmd
,
4000 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4001 "BGP specific commands\n"
4002 "Configure BGP dynamic neighbors listen range\n"
4003 "Configure BGP dynamic neighbors listen range\n"
4005 "Member of the peer-group\n"
4006 "Peer-group name\n")
4008 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4009 struct prefix range
;
4010 struct peer_group
*group
, *existing_group
;
4015 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4016 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4017 char *prefix
= argv
[idx
]->arg
;
4018 argv_find(argv
, argc
, "PGNAME", &idx
);
4019 char *peergroup
= argv
[idx
]->arg
;
4021 /* Convert IP prefix string to struct prefix. */
4022 ret
= str2prefix(prefix
, &range
);
4024 vty_out(vty
, "%% Malformed listen range\n");
4025 return CMD_WARNING_CONFIG_FAILED
;
4028 afi
= family2afi(range
.family
);
4030 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4032 "%% Malformed listen range (link-local address)\n");
4033 return CMD_WARNING_CONFIG_FAILED
;
4038 /* Check if same listen range is already configured. */
4039 existing_group
= listen_range_exists(bgp
, &range
, 1);
4040 if (existing_group
) {
4041 if (strcmp(existing_group
->name
, peergroup
) == 0)
4045 "%% Same listen range is attached to peer-group %s\n",
4046 existing_group
->name
);
4047 return CMD_WARNING_CONFIG_FAILED
;
4051 /* Check if an overlapping listen range exists. */
4052 if (listen_range_exists(bgp
, &range
, 0)) {
4054 "%% Listen range overlaps with existing listen range\n");
4055 return CMD_WARNING_CONFIG_FAILED
;
4058 group
= peer_group_lookup(bgp
, peergroup
);
4060 vty_out(vty
, "%% Configure the peer-group first\n");
4061 return CMD_WARNING_CONFIG_FAILED
;
4064 ret
= peer_group_listen_range_add(group
, &range
);
4065 return bgp_vty_return(vty
, ret
);
4068 DEFUN (no_bgp_listen_range
,
4069 no_bgp_listen_range_cmd
,
4070 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4072 "BGP specific commands\n"
4073 "Unconfigure BGP dynamic neighbors listen range\n"
4074 "Unconfigure BGP dynamic neighbors listen range\n"
4076 "Member of the peer-group\n"
4077 "Peer-group name\n")
4079 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4080 struct prefix range
;
4081 struct peer_group
*group
;
4086 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4087 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4088 char *prefix
= argv
[idx
]->arg
;
4089 argv_find(argv
, argc
, "PGNAME", &idx
);
4090 char *peergroup
= argv
[idx
]->arg
;
4092 /* Convert IP prefix string to struct prefix. */
4093 ret
= str2prefix(prefix
, &range
);
4095 vty_out(vty
, "%% Malformed listen range\n");
4096 return CMD_WARNING_CONFIG_FAILED
;
4099 afi
= family2afi(range
.family
);
4101 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4103 "%% Malformed listen range (link-local address)\n");
4104 return CMD_WARNING_CONFIG_FAILED
;
4109 group
= peer_group_lookup(bgp
, peergroup
);
4111 vty_out(vty
, "%% Peer-group does not exist\n");
4112 return CMD_WARNING_CONFIG_FAILED
;
4115 ret
= peer_group_listen_range_del(group
, &range
);
4116 return bgp_vty_return(vty
, ret
);
4119 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4121 struct peer_group
*group
;
4122 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4123 struct prefix
*range
;
4126 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4127 vty_out(vty
, " bgp listen limit %d\n",
4128 bgp
->dynamic_neighbors_limit
);
4130 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4131 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4132 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4135 " bgp listen range %pFX peer-group %s\n",
4136 range
, group
->name
);
4143 DEFUN_YANG(bgp_disable_connected_route_check
,
4144 bgp_disable_connected_route_check_cmd
,
4145 "bgp disable-ebgp-connected-route-check",
4146 "BGP specific commands\n"
4147 "Disable checking if nexthop is connected on ebgp sessions\n")
4149 nb_cli_enqueue_change(vty
,
4150 "./global/ebgp-multihop-connected-route-check",
4151 NB_OP_MODIFY
, "true");
4153 return nb_cli_apply_changes(vty
, NULL
);
4156 DEFUN_YANG(no_bgp_disable_connected_route_check
,
4157 no_bgp_disable_connected_route_check_cmd
,
4158 "no bgp disable-ebgp-connected-route-check",
4160 "BGP specific commands\n"
4161 "Disable checking if nexthop is connected on ebgp sessions\n")
4163 nb_cli_enqueue_change(vty
,
4164 "./global/ebgp-multihop-connected-route-check",
4165 NB_OP_MODIFY
, "false");
4167 return nb_cli_apply_changes(vty
, NULL
);
4170 void cli_show_router_global_ebgp_multihop_connected_route_check(
4171 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
4173 if (yang_dnode_get_bool(dnode
, NULL
))
4174 vty_out(vty
, " bgp disable-ebgp-connected-route-check\n");
4177 DEFUN_YANG(bgp_default_shutdown
,
4178 bgp_default_shutdown_cmd
,
4179 "[no] bgp default shutdown",
4181 "Configure BGP defaults\n"
4182 "Apply administrative shutdown to newly configured peers\n")
4184 nb_cli_enqueue_change(vty
, "./global/default-shutdown", NB_OP_MODIFY
,
4185 strmatch(argv
[0]->text
, "no") ? "false" : "true");
4187 return nb_cli_apply_changes(vty
, NULL
);
4190 void cli_show_router_bgp_default_shutdown(struct vty
*vty
,
4191 struct lyd_node
*dnode
,
4194 if (yang_dnode_get_bool(dnode
, NULL
))
4195 vty_out(vty
, " bgp default shutdown\n");
4198 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4200 "Administrative shutdown of the BGP instance\n"
4201 "Add a shutdown message (RFC 8203)\n"
4202 "Shutdown message\n")
4204 char *msgstr
= NULL
;
4206 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4209 msgstr
= argv_concat(argv
, argc
, 3);
4211 bgp_shutdown_enable(bgp
, msgstr
);
4212 XFREE(MTYPE_TMP
, msgstr
);
4217 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4218 BGP_STR
"Administrative shutdown of the BGP instance\n")
4220 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4222 bgp_shutdown_enable(bgp
, NULL
);
4227 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4228 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4230 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4232 bgp_shutdown_disable(bgp
);
4237 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4238 "no bgp shutdown message MSG...", NO_STR BGP_STR
4239 "Administrative shutdown of the BGP instance\n"
4240 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4242 DEFUN_YANG(neighbor_remote_as
,
4243 neighbor_remote_as_cmd
,
4244 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4245 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4246 "Specify a BGP neighbor\n" AS_STR
4247 "Internal BGP peer\n"
4248 "External BGP peer\n")
4251 int idx_remote_as
= 3;
4252 char base_xpath
[XPATH_MAXLEN
];
4253 char unnbr_xpath
[XPATH_MAXLEN
];
4254 char prgrp_xpath
[XPATH_MAXLEN
];
4256 const char *as_type_str
= "as-specified";
4258 if (str2sockunion(argv
[idx_peer
]->arg
, &su
) < 0) {
4259 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
4260 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, argv
[idx_peer
]->arg
, "");
4262 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
4263 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
, "");
4265 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4266 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4267 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4268 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
,
4269 "%s%s", VTY_CURR_XPATH
,
4271 snprintf(base_xpath
, sizeof(base_xpath
),
4272 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
,
4276 "%% Create the peer-group or interface first\n");
4277 return CMD_WARNING_CONFIG_FAILED
;
4280 snprintf(base_xpath
, sizeof(base_xpath
),
4281 FRR_BGP_NEIGHBOR_NUM_XPATH
, argv
[idx_peer
]->arg
, "");
4284 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4285 as_type_str
= "internal";
4286 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4287 as_type_str
= "external";
4289 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4290 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4292 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4293 NB_OP_MODIFY
, as_type_str
);
4295 return nb_cli_apply_changes(vty
, base_xpath
);
4298 int peer_conf_interface_create(struct bgp
*bgp
, const char *conf_if
, afi_t afi
,
4299 safi_t safi
, bool v6only
,
4300 const char *peer_group_name
, int as_type
,
4301 as_t as
, char *errmsg
, size_t errmsg_len
)
4304 struct peer_group
*group
;
4307 group
= peer_group_lookup(bgp
, conf_if
);
4310 snprintf(errmsg
, errmsg_len
,
4311 "Name conflict with peer-group \n");
4315 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4317 if (as_type
!= AS_UNSPECIFIED
)
4318 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
4321 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
)
4322 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
4323 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
4324 as_type
, 0, 0, NULL
);
4326 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
4327 as_type
, afi
, safi
, NULL
);
4330 snprintf(errmsg
, errmsg_len
,
4331 "BGP failed to create peer\n");
4336 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4338 /* Request zebra to initiate IPv6 RAs on this interface. We do
4340 * any unnumbered peer in order to not worry about run-time
4342 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4344 * gets deleted later etc.)
4347 bgp_zebra_initiate_radv(bgp
, peer
);
4350 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4351 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4353 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4355 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4357 /* v6only flag changed. Reset bgp seesion */
4358 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4359 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4360 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4361 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4363 bgp_session_reset(peer
);
4366 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4367 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4368 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4369 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4372 if (peer_group_name
) {
4373 group
= peer_group_lookup(bgp
, peer_group_name
);
4375 snprintf(errmsg
, errmsg_len
,
4376 "Configure the peer-group first\n");
4380 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4383 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
4386 DEFUN_YANG(neighbor_interface_config
,
4387 neighbor_interface_config_cmd
,
4388 "neighbor WORD interface [peer-group PGNAME]",
4390 "Interface name or neighbor tag\n"
4391 "Enable BGP on interface\n"
4392 "Member of the peer-group\n"
4393 "Peer-group name\n")
4396 int idx_peer_group_word
= 4;
4397 char base_xpath
[XPATH_MAXLEN
];
4399 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4400 argv
[idx_word
]->arg
, "");
4402 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4403 if (argc
> idx_peer_group_word
)
4404 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_MODIFY
,
4405 argv
[idx_peer_group_word
]->arg
);
4407 return nb_cli_apply_changes(vty
, base_xpath
);
4410 DEFUN_YANG(neighbor_interface_config_v6only
,
4411 neighbor_interface_config_v6only_cmd
,
4412 "neighbor WORD interface v6only [peer-group PGNAME]",
4414 "Interface name or neighbor tag\n"
4415 "Enable BGP on interface\n"
4416 "Enable BGP with v6 link-local only\n"
4417 "Member of the peer-group\n"
4418 "Peer-group name\n")
4421 int idx_peer_group_word
= 5;
4422 char base_xpath
[XPATH_MAXLEN
];
4424 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4425 argv
[idx_word
]->arg
, "");
4427 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4428 if (argc
> idx_peer_group_word
)
4429 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_MODIFY
,
4430 argv
[idx_peer_group_word
]->arg
);
4432 nb_cli_enqueue_change(vty
, "./v6only", NB_OP_MODIFY
, "true");
4434 return nb_cli_apply_changes(vty
, base_xpath
);
4439 neighbor_interface_config_remote_as
,
4440 neighbor_interface_config_remote_as_cmd
,
4441 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4443 "Interface name or neighbor tag\n"
4444 "Enable BGP on interface\n"
4445 "Specify a BGP neighbor\n" AS_STR
4446 "Internal BGP peer\n"
4447 "External BGP peer\n")
4450 int idx_remote_as
= 4;
4451 char base_xpath
[XPATH_MAXLEN
];
4452 const char *as_type_str
= "as-specified";
4454 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4455 argv
[idx_word
]->arg
, "");
4457 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4459 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4460 as_type_str
= "internal";
4461 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4462 as_type_str
= "external";
4464 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4465 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4467 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4468 NB_OP_MODIFY
, as_type_str
);
4470 return nb_cli_apply_changes(vty
, base_xpath
);
4474 neighbor_interface_v6only_config_remote_as
,
4475 neighbor_interface_v6only_config_remote_as_cmd
,
4476 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4478 "Interface name or neighbor tag\n"
4479 "Enable BGP with v6 link-local only\n"
4480 "Enable BGP on interface\n"
4481 "Specify a BGP neighbor\n" AS_STR
4482 "Internal BGP peer\n"
4483 "External BGP peer\n")
4486 int idx_remote_as
= 5;
4487 char base_xpath
[XPATH_MAXLEN
];
4488 const char *as_type_str
= "as-specified";
4490 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4491 argv
[idx_word
]->arg
, "");
4493 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4495 nb_cli_enqueue_change(vty
, "./v6only", NB_OP_MODIFY
, "true");
4497 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4498 as_type_str
= "internal";
4499 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4500 as_type_str
= "external";
4502 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4503 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4505 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4506 NB_OP_MODIFY
, as_type_str
);
4508 return nb_cli_apply_changes(vty
, base_xpath
);
4511 DEFUN_YANG(neighbor_peer_group
, neighbor_peer_group_cmd
,
4512 "neighbor WORD peer-group",
4514 "Interface name or neighbor tag\n"
4515 "Configure peer-group\n")
4517 char base_xpath
[XPATH_MAXLEN
];
4520 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4521 argv
[idx_word
]->arg
, "");
4523 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4525 return nb_cli_apply_changes(vty
, base_xpath
);
4528 DEFUN_YANG(no_neighbor
,
4530 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4533 "Specify a BGP neighbor\n" AS_STR
4534 "Internal BGP peer\n"
4535 "External BGP peer\n")
4538 char base_xpath
[XPATH_MAXLEN
];
4539 char num_xpath
[XPATH_MAXLEN
];
4540 char unnbr_xpath
[XPATH_MAXLEN
];
4541 char prgrp_xpath
[XPATH_MAXLEN
];
4544 if (str2sockunion(argv
[idx_peer
]->arg
, &su
) == 0) {
4545 snprintf(num_xpath
, sizeof(num_xpath
),
4546 FRR_BGP_NEIGHBOR_NUM_XPATH
, argv
[idx_peer
]->arg
, "");
4547 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4548 VTY_CURR_XPATH
, num_xpath
+ 1)) {
4549 strlcpy(base_xpath
, num_xpath
, sizeof(base_xpath
));
4552 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
4553 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, argv
[idx_peer
]->arg
, "");
4555 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
4556 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
, "");
4558 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4559 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4560 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4561 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
,
4562 "%s%s", VTY_CURR_XPATH
,
4564 strlcpy(base_xpath
, prgrp_xpath
, sizeof(base_xpath
));
4567 "%% Create the peer-group or interface first\n");
4568 return CMD_WARNING_CONFIG_FAILED
;
4572 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_DESTROY
, NULL
);
4574 return nb_cli_apply_changes(vty
, NULL
);
4577 DEFUN_YANG(no_neighbor_interface_config
,
4578 no_neighbor_interface_config_cmd
,
4579 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4582 "Configure BGP on interface\n"
4583 "Enable BGP with v6 link-local only\n"
4584 "Member of the peer-group\n"
4586 "Specify a BGP neighbor\n" AS_STR
4587 "Internal BGP peer\n"
4588 "External BGP peer\n")
4591 char base_xpath
[XPATH_MAXLEN
];
4593 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4594 argv
[idx_word
]->arg
, "");
4596 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
4598 return nb_cli_apply_changes(vty
, base_xpath
);
4601 DEFUN_YANG(no_neighbor_peer_group
,
4602 no_neighbor_peer_group_cmd
,
4603 "no neighbor WORD peer-group",
4606 "Configure peer-group\n")
4608 char base_xpath
[XPATH_MAXLEN
];
4611 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4612 argv
[idx_word
]->arg
, "");
4614 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
4616 return nb_cli_apply_changes(vty
, base_xpath
);
4619 DEFUN_YANG(no_neighbor_interface_peer_group_remote_as
,
4620 no_neighbor_interface_peer_group_remote_as_cmd
,
4621 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4623 "Interface name or neighbor tag\n"
4624 "Specify a BGP neighbor\n" AS_STR
4625 "Internal BGP peer\n"
4626 "External BGP peer\n")
4629 char base_xpath
[XPATH_MAXLEN
];
4630 char unnbr_xpath
[XPATH_MAXLEN
];
4631 char prgrp_xpath
[XPATH_MAXLEN
];
4633 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4634 argv
[idx_peer
]->arg
, "");
4636 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4637 argv
[idx_peer
]->arg
, "");
4639 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4640 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4641 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4642 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4643 VTY_CURR_XPATH
, prgrp_xpath
+ 1)) {
4644 strlcpy(base_xpath
, prgrp_xpath
, sizeof(base_xpath
));
4646 vty_out(vty
, "%% Create the peer-group or interface first\n");
4647 return CMD_WARNING_CONFIG_FAILED
;
4650 strlcat(base_xpath
, "/neighbor-remote-as/remote-as-type",
4651 sizeof(base_xpath
));
4653 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_DESTROY
, NULL
);
4655 return nb_cli_apply_changes(vty
, NULL
);
4658 DEFUN_YANG(neighbor_local_as
,
4659 neighbor_local_as_cmd
,
4660 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4661 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4662 "Specify a local-as number\n"
4663 "AS number used as local AS\n")
4667 char base_xpath
[XPATH_MAXLEN
];
4669 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4670 sizeof(base_xpath
), NULL
)
4672 return CMD_WARNING_CONFIG_FAILED
;
4674 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4675 argv
[idx_number
]->arg
);
4677 return nb_cli_apply_changes(vty
, base_xpath
);
4681 neighbor_local_as_no_prepend
, neighbor_local_as_no_prepend_cmd
,
4682 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4683 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4684 "Specify a local-as number\n"
4685 "AS number used as local AS\n"
4686 "Do not prepend local-as to updates from ebgp peers\n")
4690 char base_xpath
[XPATH_MAXLEN
];
4692 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4693 sizeof(base_xpath
), NULL
)
4695 return CMD_WARNING_CONFIG_FAILED
;
4697 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4698 argv
[idx_number
]->arg
);
4699 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4702 return nb_cli_apply_changes(vty
, base_xpath
);
4706 neighbor_local_as_no_prepend_replace_as
,
4707 neighbor_local_as_no_prepend_replace_as_cmd
,
4708 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4709 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4710 "Specify a local-as number\n"
4711 "AS number used as local AS\n"
4712 "Do not prepend local-as to updates from ebgp peers\n"
4713 "Do not prepend local-as to updates from ibgp peers\n")
4717 char base_xpath
[XPATH_MAXLEN
];
4719 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4720 sizeof(base_xpath
), NULL
)
4722 return CMD_WARNING_CONFIG_FAILED
;
4724 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4725 argv
[idx_number
]->arg
);
4726 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4728 nb_cli_enqueue_change(vty
, "./local-as/no-replace-as", NB_OP_MODIFY
,
4731 return nb_cli_apply_changes(vty
, base_xpath
);
4734 DEFUN_YANG(no_neighbor_local_as
,
4735 no_neighbor_local_as_cmd
,
4736 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4737 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4738 "Specify a local-as number\n"
4739 "AS number used as local AS\n"
4740 "Do not prepend local-as to updates from ebgp peers\n"
4741 "Do not prepend local-as to updates from ibgp peers\n")
4744 char base_xpath
[XPATH_MAXLEN
];
4746 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4747 sizeof(base_xpath
), NULL
)
4749 return CMD_WARNING_CONFIG_FAILED
;
4751 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_DESTROY
, NULL
);
4752 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4754 nb_cli_enqueue_change(vty
, "./local-as/no-replace-as", NB_OP_MODIFY
,
4757 return nb_cli_apply_changes(vty
, base_xpath
);
4761 DEFUN (neighbor_solo
,
4763 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4766 "Solo peer - part of its own update group\n")
4772 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4774 return CMD_WARNING_CONFIG_FAILED
;
4776 ret
= update_group_adjust_soloness(peer
, 1);
4777 return bgp_vty_return(vty
, ret
);
4780 DEFUN (no_neighbor_solo
,
4781 no_neighbor_solo_cmd
,
4782 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4786 "Solo peer - part of its own update group\n")
4792 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4794 return CMD_WARNING_CONFIG_FAILED
;
4796 ret
= update_group_adjust_soloness(peer
, 0);
4797 return bgp_vty_return(vty
, ret
);
4800 DEFUN_YANG(neighbor_password
,
4801 neighbor_password_cmd
,
4802 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
4803 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4809 char base_xpath
[XPATH_MAXLEN
];
4811 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4812 sizeof(base_xpath
), NULL
)
4814 return CMD_WARNING_CONFIG_FAILED
;
4816 nb_cli_enqueue_change(vty
, "./password", NB_OP_MODIFY
,
4817 argv
[idx_line
]->arg
);
4819 return nb_cli_apply_changes(vty
, base_xpath
);
4822 DEFUN_YANG(no_neighbor_password
,
4823 no_neighbor_password_cmd
,
4824 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
4825 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4830 char base_xpath
[XPATH_MAXLEN
];
4832 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4833 sizeof(base_xpath
), NULL
)
4835 return CMD_WARNING_CONFIG_FAILED
;
4837 nb_cli_enqueue_change(vty
, "./password", NB_OP_DESTROY
, NULL
);
4839 return nb_cli_apply_changes(vty
, base_xpath
);
4842 DEFUN_YANG(neighbor_activate
,
4843 neighbor_activate_cmd
,
4844 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4845 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4846 "Enable the Address Family for this Neighbor\n")
4849 char base_xpath
[XPATH_MAXLEN
];
4850 char af_xpath
[XPATH_MAXLEN
];
4851 afi_t afi
= bgp_node_afi(vty
);
4852 safi_t safi
= bgp_node_safi(vty
);
4854 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
4855 yang_afi_safi_value2identity(afi
, safi
));
4856 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4857 sizeof(base_xpath
), af_xpath
)
4859 return CMD_WARNING_CONFIG_FAILED
;
4861 nb_cli_enqueue_change(vty
, "./enabled", NB_OP_MODIFY
, "true");
4863 return nb_cli_apply_changes(vty
, base_xpath
);
4866 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
4867 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4868 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4869 "Enable the Address Family for this Neighbor\n")
4871 DEFUN_YANG(no_neighbor_activate
,
4872 no_neighbor_activate_cmd
,
4873 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4876 "Enable the Address Family for this Neighbor\n")
4879 char base_xpath
[XPATH_MAXLEN
];
4880 char af_xpath
[XPATH_MAXLEN
];
4881 afi_t afi
= bgp_node_afi(vty
);
4882 safi_t safi
= bgp_node_safi(vty
);
4884 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
4885 yang_afi_safi_value2identity(afi
, safi
));
4887 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4888 sizeof(base_xpath
), af_xpath
)
4890 return CMD_WARNING_CONFIG_FAILED
;
4892 nb_cli_enqueue_change(vty
, "./enabled", NB_OP_MODIFY
, "false");
4894 return nb_cli_apply_changes(vty
, base_xpath
);
4897 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
4898 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4899 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4900 "Enable the Address Family for this Neighbor\n")
4902 DEFUN_YANG (neighbor_set_peer_group
,
4903 neighbor_set_peer_group_cmd
,
4904 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4907 "Member of the peer-group\n"
4908 "Peer-group name\n")
4912 char base_xpath
[XPATH_MAXLEN
];
4914 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4915 sizeof(base_xpath
), NULL
)
4917 return CMD_WARNING_CONFIG_FAILED
;
4919 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_MODIFY
,
4920 argv
[idx_word
]->arg
);
4922 return nb_cli_apply_changes(vty
, base_xpath
);
4925 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
4926 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4927 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4928 "Member of the peer-group\n"
4929 "Peer-group name\n")
4931 DEFUN_YANG (no_neighbor_set_peer_group
,
4932 no_neighbor_set_peer_group_cmd
,
4933 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4937 "Member of the peer-group\n"
4938 "Peer-group name\n")
4941 char base_xpath
[XPATH_MAXLEN
];
4943 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4944 sizeof(base_xpath
), NULL
)
4946 return CMD_WARNING_CONFIG_FAILED
;
4948 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_DESTROY
, NULL
);
4950 return nb_cli_apply_changes(vty
, base_xpath
);
4953 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
4954 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4955 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4956 "Member of the peer-group\n"
4957 "Peer-group name\n")
4959 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
4960 uint32_t flag
, int set
)
4965 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4967 return CMD_WARNING_CONFIG_FAILED
;
4970 * If 'neighbor <interface>', then this is for directly connected peers,
4971 * we should not accept disable-connected-check.
4973 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
4975 "%s is directly connected peer, cannot accept disable-connected-check\n",
4977 return CMD_WARNING_CONFIG_FAILED
;
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_vty_return(vty
, ret
);
4991 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
4993 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
4996 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
4999 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
5002 int peer_flag_modify_nb(struct bgp
*bgp
, const char *ip_str
, struct peer
*peer
,
5003 uint32_t flag
, bool set
, char *errmsg
,
5009 * If 'neighbor <interface>', then this is for directly connected peers,
5010 * we should not accept disable-connected-check.
5012 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5015 "%s is directly connected peer, cannot accept disable-connected-check\n",
5020 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5021 peer_tx_shutdown_message_unset(peer
);
5024 ret
= peer_flag_set(peer
, flag
);
5026 ret
= peer_flag_unset(peer
, flag
);
5028 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
5031 /* neighbor passive. */
5032 DEFUN_YANG(neighbor_passive
,
5033 neighbor_passive_cmd
,
5034 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5037 "Don't send open messages to this neighbor\n")
5040 char base_xpath
[XPATH_MAXLEN
];
5042 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5043 sizeof(base_xpath
), NULL
)
5045 return CMD_WARNING_CONFIG_FAILED
;
5047 nb_cli_enqueue_change(vty
, "./passive-mode", NB_OP_MODIFY
, "true");
5049 return nb_cli_apply_changes(vty
, base_xpath
);
5052 DEFUN_YANG(no_neighbor_passive
,
5053 no_neighbor_passive_cmd
,
5054 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5057 "Don't send open messages to this neighbor\n")
5060 char base_xpath
[XPATH_MAXLEN
];
5062 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5063 sizeof(base_xpath
), NULL
)
5065 return CMD_WARNING_CONFIG_FAILED
;
5067 nb_cli_enqueue_change(vty
, "./passive-mode", NB_OP_MODIFY
, "false");
5069 return nb_cli_apply_changes(vty
, base_xpath
);
5072 /* neighbor shutdown. */
5073 DEFUN_YANG(neighbor_shutdown_msg
,
5074 neighbor_shutdown_msg_cmd
,
5075 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5076 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5077 "Administratively shut down this neighbor\n"
5078 "Add a shutdown message (RFC 8203)\n"
5079 "Shutdown message\n")
5082 char base_xpath
[XPATH_MAXLEN
];
5084 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5085 sizeof(base_xpath
), NULL
)
5087 return CMD_WARNING_CONFIG_FAILED
;
5092 message
= argv_concat(argv
, argc
, 4);
5093 nb_cli_enqueue_change(vty
, "./admin-shutdown/message",
5094 NB_OP_MODIFY
, message
);
5097 nb_cli_enqueue_change(vty
, "./admin-shutdown/enable", NB_OP_MODIFY
,
5100 return nb_cli_apply_changes(vty
, base_xpath
);
5103 ALIAS_YANG(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5104 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5105 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5106 "Administratively shut down this neighbor\n")
5108 DEFUN_YANG(no_neighbor_shutdown_msg
,
5109 no_neighbor_shutdown_msg_cmd
,
5110 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5113 "Administratively shut down this neighbor\n"
5114 "Remove a shutdown message (RFC 8203)\n"
5115 "Shutdown message\n")
5118 char base_xpath
[XPATH_MAXLEN
];
5120 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5121 sizeof(base_xpath
), NULL
)
5123 return CMD_WARNING_CONFIG_FAILED
;
5125 nb_cli_enqueue_change(vty
, "./admin-shutdown/enable", NB_OP_MODIFY
,
5128 return nb_cli_apply_changes(vty
, base_xpath
);
5131 ALIAS_YANG(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5132 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5133 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5134 "Administratively shut down this neighbor\n")
5136 DEFUN(neighbor_shutdown_rtt
,
5137 neighbor_shutdown_rtt_cmd
,
5138 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5141 "Administratively shut down this neighbor\n"
5142 "Shutdown if round-trip-time is higher than expected\n"
5143 "Round-trip-time in milliseconds\n"
5144 "Specify the number of keepalives before shutdown\n"
5145 "The number of keepalives with higher RTT to shutdown\n")
5152 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5155 return CMD_WARNING_CONFIG_FAILED
;
5157 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5159 if (argv_find(argv
, argc
, "count", &idx_count
))
5160 peer
->rtt_keepalive_conf
=
5161 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5163 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5164 PEER_FLAG_RTT_SHUTDOWN
);
5167 DEFUN(no_neighbor_shutdown_rtt
,
5168 no_neighbor_shutdown_rtt_cmd
,
5169 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5173 "Administratively shut down this neighbor\n"
5174 "Shutdown if round-trip-time is higher than expected\n"
5175 "Round-trip-time in milliseconds\n"
5176 "Specify the number of keepalives before shutdown\n"
5177 "The number of keepalives with higher RTT to shutdown\n")
5182 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5185 return CMD_WARNING_CONFIG_FAILED
;
5187 peer
->rtt_expected
= 0;
5188 peer
->rtt_keepalive_conf
= 1;
5190 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5191 PEER_FLAG_RTT_SHUTDOWN
);
5194 /* neighbor capability dynamic. */
5195 DEFUN_YANG (neighbor_capability_dynamic
,
5196 neighbor_capability_dynamic_cmd
,
5197 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5200 "Advertise capability to the peer\n"
5201 "Advertise dynamic capability to this neighbor\n")
5204 char base_xpath
[XPATH_MAXLEN
];
5206 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5207 sizeof(base_xpath
), NULL
)
5209 return CMD_WARNING_CONFIG_FAILED
;
5211 nb_cli_enqueue_change(vty
, "./capability-options/dynamic-capability",
5212 NB_OP_MODIFY
, "true");
5214 return nb_cli_apply_changes(vty
, base_xpath
);
5217 DEFUN_YANG (no_neighbor_capability_dynamic
,
5218 no_neighbor_capability_dynamic_cmd
,
5219 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5223 "Advertise capability to the peer\n"
5224 "Advertise dynamic capability to this neighbor\n")
5227 char base_xpath
[XPATH_MAXLEN
];
5229 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5230 sizeof(base_xpath
), NULL
)
5232 return CMD_WARNING_CONFIG_FAILED
;
5234 nb_cli_enqueue_change(vty
, "./capability-options/dynamic-capability",
5235 NB_OP_MODIFY
, "false");
5237 return nb_cli_apply_changes(vty
, base_xpath
);
5240 /* neighbor dont-capability-negotiate */
5241 DEFUN (neighbor_dont_capability_negotiate
,
5242 neighbor_dont_capability_negotiate_cmd
,
5243 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5246 "Do not perform capability negotiation\n")
5249 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5250 PEER_FLAG_DONT_CAPABILITY
);
5253 DEFUN (no_neighbor_dont_capability_negotiate
,
5254 no_neighbor_dont_capability_negotiate_cmd
,
5255 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5259 "Do not perform capability negotiation\n")
5262 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5263 PEER_FLAG_DONT_CAPABILITY
);
5266 /* neighbor capability extended next hop encoding */
5267 DEFUN_YANG (neighbor_capability_enhe
,
5268 neighbor_capability_enhe_cmd
,
5269 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5272 "Advertise capability to the peer\n"
5273 "Advertise extended next-hop capability to the peer\n")
5276 char base_xpath
[XPATH_MAXLEN
];
5278 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5279 sizeof(base_xpath
), NULL
)
5281 return CMD_WARNING_CONFIG_FAILED
;
5283 nb_cli_enqueue_change(
5284 vty
, "./capability-options/extended-nexthop-capability",
5285 NB_OP_MODIFY
, "true");
5287 return nb_cli_apply_changes(vty
, base_xpath
);
5290 DEFUN_YANG (no_neighbor_capability_enhe
,
5291 no_neighbor_capability_enhe_cmd
,
5292 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5296 "Advertise capability to the peer\n"
5297 "Advertise extended next-hop capability to the peer\n")
5300 char base_xpath
[XPATH_MAXLEN
];
5302 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5303 sizeof(base_xpath
), NULL
)
5305 return CMD_WARNING_CONFIG_FAILED
;
5307 nb_cli_enqueue_change(
5308 vty
, "./capability-options/extended-nexthop-capability",
5309 NB_OP_MODIFY
, "false");
5311 return nb_cli_apply_changes(vty
, base_xpath
);
5314 int peer_af_flag_modify_nb(struct peer
*peer
, afi_t afi
, safi_t safi
,
5315 uint32_t flag
, int set
, char *errmsg
,
5321 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5323 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5325 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
5328 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5329 afi_t afi
, safi_t safi
, uint32_t flag
,
5335 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5337 return CMD_WARNING_CONFIG_FAILED
;
5340 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5342 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5344 return bgp_vty_return(vty
, ret
);
5347 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5348 afi_t afi
, safi_t safi
, uint32_t flag
)
5350 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5353 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5354 afi_t afi
, safi_t safi
, uint32_t flag
)
5356 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5359 /* neighbor capability orf prefix-list. */
5360 DEFUN (neighbor_capability_orf_prefix
,
5361 neighbor_capability_orf_prefix_cmd
,
5362 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5365 "Advertise capability to the peer\n"
5366 "Advertise ORF capability to the peer\n"
5367 "Advertise prefixlist ORF capability to this neighbor\n"
5368 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5369 "Capability to RECEIVE the ORF from this neighbor\n"
5370 "Capability to SEND the ORF to this neighbor\n")
5372 int idx_send_recv
= 5;
5373 char *peer_str
= argv
[1]->arg
;
5375 afi_t afi
= bgp_node_afi(vty
);
5376 safi_t safi
= bgp_node_safi(vty
);
5378 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5380 return CMD_WARNING_CONFIG_FAILED
;
5382 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5383 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5384 PEER_FLAG_ORF_PREFIX_SM
);
5386 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5387 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5388 PEER_FLAG_ORF_PREFIX_RM
);
5390 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5391 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5392 PEER_FLAG_ORF_PREFIX_SM
)
5393 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5394 PEER_FLAG_ORF_PREFIX_RM
);
5396 return CMD_WARNING_CONFIG_FAILED
;
5400 neighbor_capability_orf_prefix
,
5401 neighbor_capability_orf_prefix_hidden_cmd
,
5402 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5403 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5404 "Advertise capability to the peer\n"
5405 "Advertise ORF capability to the peer\n"
5406 "Advertise prefixlist ORF capability to this neighbor\n"
5407 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5408 "Capability to RECEIVE the ORF from this neighbor\n"
5409 "Capability to SEND the ORF to this neighbor\n")
5411 DEFUN (no_neighbor_capability_orf_prefix
,
5412 no_neighbor_capability_orf_prefix_cmd
,
5413 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5417 "Advertise capability to the peer\n"
5418 "Advertise ORF capability to the peer\n"
5419 "Advertise prefixlist ORF capability to this neighbor\n"
5420 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5421 "Capability to RECEIVE the ORF from this neighbor\n"
5422 "Capability to SEND the ORF to this neighbor\n")
5424 int idx_send_recv
= 6;
5425 char *peer_str
= argv
[2]->arg
;
5427 afi_t afi
= bgp_node_afi(vty
);
5428 safi_t safi
= bgp_node_safi(vty
);
5430 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5432 return CMD_WARNING_CONFIG_FAILED
;
5434 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5435 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5436 PEER_FLAG_ORF_PREFIX_SM
);
5438 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5439 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5440 PEER_FLAG_ORF_PREFIX_RM
);
5442 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5443 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5444 PEER_FLAG_ORF_PREFIX_SM
)
5445 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5446 PEER_FLAG_ORF_PREFIX_RM
);
5448 return CMD_WARNING_CONFIG_FAILED
;
5452 no_neighbor_capability_orf_prefix
,
5453 no_neighbor_capability_orf_prefix_hidden_cmd
,
5454 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5455 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5456 "Advertise capability to the peer\n"
5457 "Advertise ORF capability to the peer\n"
5458 "Advertise prefixlist ORF capability to this neighbor\n"
5459 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5460 "Capability to RECEIVE the ORF from this neighbor\n"
5461 "Capability to SEND the ORF to this neighbor\n")
5463 /* neighbor next-hop-self. */
5464 DEFUN_YANG (neighbor_nexthop_self
,
5465 neighbor_nexthop_self_cmd
,
5466 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5469 "Disable the next hop calculation for this neighbor\n")
5472 char base_xpath
[XPATH_MAXLEN
];
5473 char af_xpath
[XPATH_MAXLEN
];
5474 char attr_xpath
[XPATH_MAXLEN
];
5475 afi_t afi
= bgp_node_afi(vty
);
5476 safi_t safi
= bgp_node_safi(vty
);
5479 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5480 yang_afi_safi_value2identity(afi
, safi
));
5482 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5483 sizeof(base_xpath
), af_xpath
)
5485 return CMD_WARNING_CONFIG_FAILED
;
5487 snprintf(attr_xpath
, sizeof(attr_xpath
),
5488 "./%s/nexthop-self/next-hop-self",
5489 bgp_afi_safi_get_container_str(afi
, safi
));
5491 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5493 return nb_cli_apply_changes(vty
, base_xpath
);
5496 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5497 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5498 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5499 "Disable the next hop calculation for this neighbor\n")
5501 /* neighbor next-hop-self. */
5502 DEFUN_YANG(neighbor_nexthop_self_force
,
5503 neighbor_nexthop_self_force_cmd
,
5504 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5507 "Disable the next hop calculation for this neighbor\n"
5508 "Set the next hop to self for reflected routes\n")
5511 char base_xpath
[XPATH_MAXLEN
];
5512 char af_xpath
[XPATH_MAXLEN
];
5513 char attr_xpath
[XPATH_MAXLEN
];
5514 afi_t afi
= bgp_node_afi(vty
);
5515 safi_t safi
= bgp_node_safi(vty
);
5518 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5519 yang_afi_safi_value2identity(afi
, safi
));
5521 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5522 sizeof(base_xpath
), af_xpath
)
5524 return CMD_WARNING_CONFIG_FAILED
;
5526 snprintf(attr_xpath
, sizeof(attr_xpath
),
5527 "./%s/nexthop-self/next-hop-self-force",
5528 bgp_afi_safi_get_container_str(afi
, safi
));
5530 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5532 return nb_cli_apply_changes(vty
, base_xpath
);
5535 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5536 neighbor_nexthop_self_force_hidden_cmd
,
5537 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5538 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5539 "Disable the next hop calculation for this neighbor\n"
5540 "Set the next hop to self for reflected routes\n")
5542 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5543 neighbor_nexthop_self_all_hidden_cmd
,
5544 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5545 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5546 "Disable the next hop calculation for this neighbor\n"
5547 "Set the next hop to self for reflected routes\n")
5549 DEFUN_YANG (no_neighbor_nexthop_self
,
5550 no_neighbor_nexthop_self_cmd
,
5551 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5555 "Disable the next hop calculation for this neighbor\n")
5558 char base_xpath
[XPATH_MAXLEN
];
5559 char af_xpath
[XPATH_MAXLEN
];
5560 char attr_xpath
[XPATH_MAXLEN
];
5561 afi_t afi
= bgp_node_afi(vty
);
5562 safi_t safi
= bgp_node_safi(vty
);
5564 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5565 yang_afi_safi_value2identity(afi
, safi
));
5567 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5568 sizeof(base_xpath
), af_xpath
)
5570 return CMD_WARNING_CONFIG_FAILED
;
5572 snprintf(attr_xpath
, sizeof(attr_xpath
),
5573 "./%s/nexthop-self/next-hop-self",
5574 bgp_afi_safi_get_container_str(afi
, safi
));
5576 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5578 return nb_cli_apply_changes(vty
, base_xpath
);
5581 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5582 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5583 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5584 "Disable the next hop calculation for this neighbor\n")
5586 DEFUN_YANG (no_neighbor_nexthop_self_force
,
5587 no_neighbor_nexthop_self_force_cmd
,
5588 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5592 "Disable the next hop calculation for this neighbor\n"
5593 "Set the next hop to self for reflected routes\n")
5596 char base_xpath
[XPATH_MAXLEN
];
5597 char af_xpath
[XPATH_MAXLEN
];
5598 char attr_xpath
[XPATH_MAXLEN
];
5599 afi_t afi
= bgp_node_afi(vty
);
5600 safi_t safi
= bgp_node_safi(vty
);
5603 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5604 yang_afi_safi_value2identity(afi
, safi
));
5606 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5607 sizeof(base_xpath
), af_xpath
)
5609 return CMD_WARNING_CONFIG_FAILED
;
5611 snprintf(attr_xpath
, sizeof(attr_xpath
),
5612 "./%s/nexthop-self/next-hop-self-force",
5613 bgp_afi_safi_get_container_str(afi
, safi
));
5615 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5617 return nb_cli_apply_changes(vty
, base_xpath
);
5620 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5621 no_neighbor_nexthop_self_force_hidden_cmd
,
5622 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5623 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5624 "Disable the next hop calculation for this neighbor\n"
5625 "Set the next hop to self for reflected routes\n")
5627 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5628 no_neighbor_nexthop_self_all_hidden_cmd
,
5629 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5630 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5631 "Disable the next hop calculation for this neighbor\n"
5632 "Set the next hop to self for reflected routes\n")
5634 /* neighbor as-override */
5635 DEFUN_YANG (neighbor_as_override
,
5636 neighbor_as_override_cmd
,
5637 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5640 "Override ASNs in outbound updates if aspath equals remote-as\n")
5643 char base_xpath
[XPATH_MAXLEN
];
5644 char af_xpath
[XPATH_MAXLEN
];
5645 char attr_xpath
[XPATH_MAXLEN
];
5646 afi_t afi
= bgp_node_afi(vty
);
5647 safi_t safi
= bgp_node_safi(vty
);
5649 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5650 yang_afi_safi_value2identity(afi
, safi
));
5652 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5653 sizeof(base_xpath
), af_xpath
)
5655 return CMD_WARNING_CONFIG_FAILED
;
5657 snprintf(attr_xpath
, sizeof(attr_xpath
),
5658 "./%s/as-path-options/replace-peer-as",
5659 bgp_afi_safi_get_container_str(afi
, safi
));
5661 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5663 return nb_cli_apply_changes(vty
, base_xpath
);
5666 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5667 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5668 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5669 "Override ASNs in outbound updates if aspath equals remote-as\n")
5671 DEFUN_YANG (no_neighbor_as_override
,
5672 no_neighbor_as_override_cmd
,
5673 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5677 "Override ASNs in outbound updates if aspath equals remote-as\n")
5680 char base_xpath
[XPATH_MAXLEN
];
5681 char af_xpath
[XPATH_MAXLEN
];
5682 char attr_xpath
[XPATH_MAXLEN
];
5683 afi_t afi
= bgp_node_afi(vty
);
5684 safi_t safi
= bgp_node_safi(vty
);
5686 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5687 yang_afi_safi_value2identity(afi
, safi
));
5689 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5690 sizeof(base_xpath
), af_xpath
)
5692 return CMD_WARNING_CONFIG_FAILED
;
5694 snprintf(attr_xpath
, sizeof(attr_xpath
),
5695 "./%s/as-path-options/replace-peer-as",
5696 bgp_afi_safi_get_container_str(afi
, safi
));
5698 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5700 return nb_cli_apply_changes(vty
, base_xpath
);
5703 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5704 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5705 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5706 "Override ASNs in outbound updates if aspath equals remote-as\n")
5708 /* neighbor remove-private-AS. */
5709 DEFUN_YANG (neighbor_remove_private_as
,
5710 neighbor_remove_private_as_cmd
,
5711 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5714 "Remove private ASNs in outbound updates\n")
5717 char base_xpath
[XPATH_MAXLEN
];
5718 char af_xpath
[XPATH_MAXLEN
];
5719 char attr_xpath
[XPATH_MAXLEN
];
5720 afi_t afi
= bgp_node_afi(vty
);
5721 safi_t safi
= bgp_node_safi(vty
);
5723 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5724 yang_afi_safi_value2identity(afi
, safi
));
5726 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5727 sizeof(base_xpath
), af_xpath
)
5729 return CMD_WARNING_CONFIG_FAILED
;
5731 snprintf(attr_xpath
, sizeof(attr_xpath
),
5732 "./%s/private-as/remove-private-as",
5733 bgp_afi_safi_get_container_str(afi
, safi
));
5735 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5737 return nb_cli_apply_changes(vty
, base_xpath
);
5740 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5741 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5742 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5743 "Remove private ASNs in outbound updates\n")
5745 DEFUN_YANG (neighbor_remove_private_as_all
,
5746 neighbor_remove_private_as_all_cmd
,
5747 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5750 "Remove private ASNs in outbound updates\n"
5751 "Apply to all AS numbers\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-all",
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_all
,
5779 neighbor_remove_private_as_all_hidden_cmd
,
5780 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5781 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5782 "Remove private ASNs in outbound updates\n"
5783 "Apply to all AS numbers")
5785 DEFUN_YANG (neighbor_remove_private_as_replace_as
,
5786 neighbor_remove_private_as_replace_as_cmd
,
5787 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5790 "Remove private ASNs in outbound updates\n"
5791 "Replace private ASNs with our ASN in outbound updates\n")
5794 char base_xpath
[XPATH_MAXLEN
];
5795 char af_xpath
[XPATH_MAXLEN
];
5796 char attr_xpath
[XPATH_MAXLEN
];
5797 afi_t afi
= bgp_node_afi(vty
);
5798 safi_t safi
= bgp_node_safi(vty
);
5801 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5802 yang_afi_safi_value2identity(afi
, safi
));
5804 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5805 sizeof(base_xpath
), af_xpath
)
5807 return CMD_WARNING_CONFIG_FAILED
;
5809 snprintf(attr_xpath
, sizeof(attr_xpath
),
5810 "./%s/private-as/remove-private-as-replace",
5811 bgp_afi_safi_get_container_str(afi
, safi
));
5813 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5815 return nb_cli_apply_changes(vty
, base_xpath
);
5818 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5819 neighbor_remove_private_as_replace_as_hidden_cmd
,
5820 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5821 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5822 "Remove private ASNs in outbound updates\n"
5823 "Replace private ASNs with our ASN in outbound updates\n")
5825 DEFUN_YANG (neighbor_remove_private_as_all_replace_as
,
5826 neighbor_remove_private_as_all_replace_as_cmd
,
5827 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5830 "Remove private ASNs in outbound updates\n"
5831 "Apply to all AS numbers\n"
5832 "Replace private ASNs with our ASN in outbound updates\n")
5835 char base_xpath
[XPATH_MAXLEN
];
5836 char af_xpath
[XPATH_MAXLEN
];
5837 char attr_xpath
[XPATH_MAXLEN
];
5838 afi_t afi
= bgp_node_afi(vty
);
5839 safi_t safi
= bgp_node_safi(vty
);
5842 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5843 yang_afi_safi_value2identity(afi
, safi
));
5845 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5846 sizeof(base_xpath
), af_xpath
)
5848 return CMD_WARNING_CONFIG_FAILED
;
5850 snprintf(attr_xpath
, sizeof(attr_xpath
),
5851 "./%s/private-as/remove-private-as-all-replace",
5852 bgp_afi_safi_get_container_str(afi
, safi
));
5854 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5856 return nb_cli_apply_changes(vty
, base_xpath
);
5860 neighbor_remove_private_as_all_replace_as
,
5861 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5862 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5863 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5864 "Remove private ASNs in outbound updates\n"
5865 "Apply to all AS numbers\n"
5866 "Replace private ASNs with our ASN in outbound updates\n")
5868 DEFUN_YANG (no_neighbor_remove_private_as
,
5869 no_neighbor_remove_private_as_cmd
,
5870 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5874 "Remove private ASNs in outbound updates\n")
5877 char base_xpath
[XPATH_MAXLEN
];
5878 char af_xpath
[XPATH_MAXLEN
];
5879 char attr_xpath
[XPATH_MAXLEN
];
5880 afi_t afi
= bgp_node_afi(vty
);
5881 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",
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
,
5901 no_neighbor_remove_private_as_hidden_cmd
,
5902 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5903 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5904 "Remove private ASNs in outbound updates\n")
5906 DEFUN_YANG (no_neighbor_remove_private_as_all
,
5907 no_neighbor_remove_private_as_all_cmd
,
5908 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5912 "Remove private ASNs in outbound updates\n"
5913 "Apply to all AS numbers\n")
5916 char base_xpath
[XPATH_MAXLEN
];
5917 char af_xpath
[XPATH_MAXLEN
];
5918 char attr_xpath
[XPATH_MAXLEN
];
5919 afi_t afi
= bgp_node_afi(vty
);
5920 safi_t safi
= bgp_node_safi(vty
);
5923 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5924 yang_afi_safi_value2identity(afi
, safi
));
5926 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5927 sizeof(base_xpath
), af_xpath
)
5929 return CMD_WARNING_CONFIG_FAILED
;
5931 snprintf(attr_xpath
, sizeof(attr_xpath
),
5932 "./%s/private-as/remove-private-as-all",
5933 bgp_afi_safi_get_container_str(afi
, safi
));
5935 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5937 return nb_cli_apply_changes(vty
, base_xpath
);
5940 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5941 no_neighbor_remove_private_as_all_hidden_cmd
,
5942 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5943 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5944 "Remove private ASNs in outbound updates\n"
5945 "Apply to all AS numbers\n")
5947 DEFUN_YANG (no_neighbor_remove_private_as_replace_as
,
5948 no_neighbor_remove_private_as_replace_as_cmd
,
5949 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5953 "Remove private ASNs in outbound updates\n"
5954 "Replace private ASNs with our ASN in outbound updates\n")
5957 char base_xpath
[XPATH_MAXLEN
];
5958 char af_xpath
[XPATH_MAXLEN
];
5959 char attr_xpath
[XPATH_MAXLEN
];
5960 afi_t afi
= bgp_node_afi(vty
);
5961 safi_t safi
= bgp_node_safi(vty
);
5964 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5965 yang_afi_safi_value2identity(afi
, safi
));
5967 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5968 sizeof(base_xpath
), af_xpath
)
5970 return CMD_WARNING_CONFIG_FAILED
;
5972 snprintf(attr_xpath
, sizeof(attr_xpath
),
5973 "./%s/private-as/remove-private-as-replace",
5974 bgp_afi_safi_get_container_str(afi
, safi
));
5976 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5978 return nb_cli_apply_changes(vty
, base_xpath
);
5981 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
5982 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
5983 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5984 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5985 "Remove private ASNs in outbound updates\n"
5986 "Replace private ASNs with our ASN in outbound updates\n")
5988 DEFUN_YANG (no_neighbor_remove_private_as_all_replace_as
,
5989 no_neighbor_remove_private_as_all_replace_as_cmd
,
5990 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5994 "Remove private ASNs in outbound updates\n"
5995 "Apply to all AS numbers\n"
5996 "Replace private ASNs with our ASN in outbound updates\n")
5999 char base_xpath
[XPATH_MAXLEN
];
6000 char af_xpath
[XPATH_MAXLEN
];
6001 char attr_xpath
[XPATH_MAXLEN
];
6002 afi_t afi
= bgp_node_afi(vty
);
6003 safi_t safi
= bgp_node_safi(vty
);
6006 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6007 yang_afi_safi_value2identity(afi
, safi
));
6009 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6010 sizeof(base_xpath
), af_xpath
)
6012 return CMD_WARNING_CONFIG_FAILED
;
6014 snprintf(attr_xpath
, sizeof(attr_xpath
),
6015 "./%s/private-as/remove-private-as-all-replace",
6016 bgp_afi_safi_get_container_str(afi
, safi
));
6018 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6020 return nb_cli_apply_changes(vty
, base_xpath
);
6024 no_neighbor_remove_private_as_all_replace_as
,
6025 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
6026 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6027 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6028 "Remove private ASNs in outbound updates\n"
6029 "Apply to all AS numbers\n"
6030 "Replace private ASNs with our ASN in outbound updates\n")
6033 /* neighbor send-community. */
6034 DEFUN_YANG (neighbor_send_community
,
6035 neighbor_send_community_cmd
,
6036 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6039 "Send Community attribute to this neighbor\n")
6043 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6045 PEER_FLAG_SEND_COMMUNITY
);
6048 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
6049 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6050 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6051 "Send Community attribute to this neighbor\n")
6053 DEFUN_YANG (no_neighbor_send_community
,
6054 no_neighbor_send_community_cmd
,
6055 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6059 "Send Community attribute to this neighbor\n")
6063 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6064 bgp_node_afi(vty
), bgp_node_safi(vty
),
6065 PEER_FLAG_SEND_COMMUNITY
);
6068 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
6069 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6070 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6071 "Send Community attribute to this neighbor\n")
6073 /* neighbor send-community extended. */
6074 DEFUN_YANG (neighbor_send_community_type
,
6075 neighbor_send_community_type_cmd
,
6076 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6079 "Send Community attribute to this neighbor\n"
6080 "Send Standard and Extended Community attributes\n"
6081 "Send Standard, Large and Extended Community attributes\n"
6082 "Send Extended Community attributes\n"
6083 "Send Standard Community attributes\n"
6084 "Send Large Community attributes\n")
6086 const char *type
= argv
[argc
- 1]->text
;
6087 char *peer_str
= argv
[1]->arg
;
6088 char base_xpath
[XPATH_MAXLEN
];
6089 char af_xpath
[XPATH_MAXLEN
];
6090 char std_xpath
[XPATH_MAXLEN
];
6091 char ext_xpath
[XPATH_MAXLEN
];
6092 char lrg_xpath
[XPATH_MAXLEN
];
6093 afi_t afi
= bgp_node_afi(vty
);
6094 safi_t safi
= bgp_node_safi(vty
);
6096 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6097 yang_afi_safi_value2identity(afi
, safi
));
6099 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6100 sizeof(base_xpath
), af_xpath
)
6102 return CMD_WARNING_CONFIG_FAILED
;
6104 if (strmatch(type
, "standard")) {
6105 snprintf(std_xpath
, sizeof(std_xpath
),
6106 "./%s/send-community/send-community",
6107 bgp_afi_safi_get_container_str(afi
, safi
));
6109 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6112 if (strmatch(type
, "extended")) {
6113 snprintf(ext_xpath
, sizeof(ext_xpath
),
6114 "./%s/send-community/send-ext-community",
6115 bgp_afi_safi_get_container_str(afi
, safi
));
6117 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6120 if (strmatch(type
, "large")) {
6121 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6122 "./%s/send-community/send-large-community",
6123 bgp_afi_safi_get_container_str(afi
, safi
));
6125 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "true");
6128 if (strmatch(type
, "both")) {
6129 snprintf(std_xpath
, sizeof(std_xpath
),
6130 "./%s/send-community/send-community",
6131 bgp_afi_safi_get_container_str(afi
, safi
));
6133 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6135 snprintf(ext_xpath
, sizeof(ext_xpath
),
6136 "./%s/send-community/send-ext-community",
6137 bgp_afi_safi_get_container_str(afi
, safi
));
6139 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6142 if (strmatch(type
, "all")) {
6143 snprintf(std_xpath
, sizeof(std_xpath
),
6144 "./%s/send-community/send-community",
6145 bgp_afi_safi_get_container_str(afi
, safi
));
6147 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6149 snprintf(ext_xpath
, sizeof(ext_xpath
),
6150 "./%s/send-community/send-ext-community",
6151 bgp_afi_safi_get_container_str(afi
, safi
));
6153 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6155 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6156 "./%s/send-community/send-large-community",
6157 bgp_afi_safi_get_container_str(afi
, safi
));
6159 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "true");
6162 return nb_cli_apply_changes(vty
, base_xpath
);
6166 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6167 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6168 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6169 "Send Community attribute to this neighbor\n"
6170 "Send Standard and Extended Community attributes\n"
6171 "Send Standard, Large and Extended Community attributes\n"
6172 "Send Extended Community attributes\n"
6173 "Send Standard Community attributes\n"
6174 "Send Large Community attributes\n")
6176 DEFUN_YANG (no_neighbor_send_community_type
,
6177 no_neighbor_send_community_type_cmd
,
6178 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6182 "Send Community attribute to this neighbor\n"
6183 "Send Standard and Extended Community attributes\n"
6184 "Send Standard, Large and Extended Community attributes\n"
6185 "Send Extended Community attributes\n"
6186 "Send Standard Community attributes\n"
6187 "Send Large Community attributes\n")
6189 const char *type
= argv
[argc
- 1]->text
;
6190 char *peer_str
= argv
[2]->arg
;
6191 char base_xpath
[XPATH_MAXLEN
];
6192 char af_xpath
[XPATH_MAXLEN
];
6193 char std_xpath
[XPATH_MAXLEN
];
6194 char ext_xpath
[XPATH_MAXLEN
];
6195 char lrg_xpath
[XPATH_MAXLEN
];
6196 afi_t afi
= bgp_node_afi(vty
);
6197 safi_t safi
= bgp_node_safi(vty
);
6199 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6200 yang_afi_safi_value2identity(afi
, safi
));
6202 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6203 sizeof(base_xpath
), af_xpath
)
6205 return CMD_WARNING_CONFIG_FAILED
;
6207 if (strmatch(type
, "standard")) {
6208 snprintf(std_xpath
, sizeof(std_xpath
),
6209 "./%s/send-community/send-community",
6210 bgp_afi_safi_get_container_str(afi
, safi
));
6212 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6215 if (strmatch(type
, "extended")) {
6216 snprintf(ext_xpath
, sizeof(ext_xpath
),
6217 "./%s/send-community/send-ext-community",
6218 bgp_afi_safi_get_container_str(afi
, safi
));
6220 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6223 if (strmatch(type
, "large")) {
6224 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6225 "./%s/send-community/send-large-community",
6226 bgp_afi_safi_get_container_str(afi
, safi
));
6228 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "false");
6231 if (strmatch(type
, "both")) {
6232 snprintf(std_xpath
, sizeof(std_xpath
),
6233 "./%s/send-community/send-community",
6234 bgp_afi_safi_get_container_str(afi
, safi
));
6236 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6238 snprintf(ext_xpath
, sizeof(ext_xpath
),
6239 "./%s/send-community/send-ext-community",
6240 bgp_afi_safi_get_container_str(afi
, safi
));
6242 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6245 if (strmatch(type
, "all")) {
6246 snprintf(std_xpath
, sizeof(std_xpath
),
6247 "./%s/send-community/send-community",
6248 bgp_afi_safi_get_container_str(afi
, safi
));
6250 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6252 snprintf(ext_xpath
, sizeof(ext_xpath
),
6253 "./%s/send-community/send-ext-community",
6254 bgp_afi_safi_get_container_str(afi
, safi
));
6256 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6258 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6259 "./%s/send-community/send-large-community",
6260 bgp_afi_safi_get_container_str(afi
, safi
));
6262 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "false");
6265 return nb_cli_apply_changes(vty
, base_xpath
);
6269 no_neighbor_send_community_type
,
6270 no_neighbor_send_community_type_hidden_cmd
,
6271 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6272 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6273 "Send Community attribute to this neighbor\n"
6274 "Send Standard and Extended Community attributes\n"
6275 "Send Standard, Large and Extended Community attributes\n"
6276 "Send Extended Community attributes\n"
6277 "Send Standard Community attributes\n"
6278 "Send Large Community attributes\n")
6280 /* neighbor soft-reconfig. */
6281 DEFUN_YANG (neighbor_soft_reconfiguration
,
6282 neighbor_soft_reconfiguration_cmd
,
6283 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6284 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6285 "Per neighbor soft reconfiguration\n"
6286 "Allow inbound soft reconfiguration for this neighbor\n")
6289 char base_xpath
[XPATH_MAXLEN
];
6290 char af_xpath
[XPATH_MAXLEN
];
6291 char soft_xpath
[XPATH_MAXLEN
];
6292 afi_t afi
= bgp_node_afi(vty
);
6293 safi_t safi
= bgp_node_safi(vty
);
6296 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6297 yang_afi_safi_value2identity(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 snprintf(soft_xpath
, sizeof(soft_xpath
), "./%s/soft-reconfiguration",
6305 bgp_afi_safi_get_container_str(afi
, safi
));
6307 nb_cli_enqueue_change(vty
, soft_xpath
, NB_OP_MODIFY
, "true");
6309 return nb_cli_apply_changes(vty
, base_xpath
);
6312 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6313 neighbor_soft_reconfiguration_hidden_cmd
,
6314 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6315 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6316 "Per neighbor soft reconfiguration\n"
6317 "Allow inbound soft reconfiguration for this neighbor\n")
6319 DEFUN_YANG (no_neighbor_soft_reconfiguration
,
6320 no_neighbor_soft_reconfiguration_cmd
,
6321 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6322 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6323 "Per neighbor soft reconfiguration\n"
6324 "Allow inbound soft reconfiguration for this neighbor\n")
6327 char base_xpath
[XPATH_MAXLEN
];
6328 char af_xpath
[XPATH_MAXLEN
];
6329 char soft_xpath
[XPATH_MAXLEN
];
6330 afi_t afi
= bgp_node_afi(vty
);
6331 safi_t safi
= bgp_node_safi(vty
);
6333 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6334 yang_afi_safi_value2identity(afi
, safi
));
6336 snprintf(soft_xpath
, sizeof(soft_xpath
), "./%s/soft-reconfiguration",
6337 bgp_afi_safi_get_container_str(afi
, safi
));
6339 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6340 sizeof(base_xpath
), af_xpath
)
6342 return CMD_WARNING_CONFIG_FAILED
;
6344 nb_cli_enqueue_change(vty
, soft_xpath
, NB_OP_MODIFY
, "false");
6346 return nb_cli_apply_changes(vty
, base_xpath
);
6349 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6350 no_neighbor_soft_reconfiguration_hidden_cmd
,
6351 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6352 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6353 "Per neighbor soft reconfiguration\n"
6354 "Allow inbound soft reconfiguration for this neighbor\n")
6356 DEFUN_YANG (neighbor_route_reflector_client
,
6357 neighbor_route_reflector_client_cmd
,
6358 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6361 "Configure a neighbor as Route Reflector client\n")
6364 char base_xpath
[XPATH_MAXLEN
];
6365 char af_xpath
[XPATH_MAXLEN
];
6366 char attr_xpath
[XPATH_MAXLEN
];
6367 afi_t afi
= bgp_node_afi(vty
);
6368 safi_t safi
= bgp_node_safi(vty
);
6370 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6371 yang_afi_safi_value2identity(afi
, safi
));
6373 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6374 sizeof(base_xpath
), af_xpath
)
6376 return CMD_WARNING_CONFIG_FAILED
;
6378 snprintf(attr_xpath
, sizeof(attr_xpath
),
6379 "./%s/route-reflector/route-reflector-client",
6380 bgp_afi_safi_get_container_str(afi
, safi
));
6382 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6384 return nb_cli_apply_changes(vty
, base_xpath
);
6387 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6388 neighbor_route_reflector_client_hidden_cmd
,
6389 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6390 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6391 "Configure a neighbor as Route Reflector client\n")
6393 DEFUN_YANG (no_neighbor_route_reflector_client
,
6394 no_neighbor_route_reflector_client_cmd
,
6395 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6399 "Configure a neighbor as Route Reflector client\n")
6402 char base_xpath
[XPATH_MAXLEN
];
6403 char af_xpath
[XPATH_MAXLEN
];
6404 char attr_xpath
[XPATH_MAXLEN
];
6405 afi_t afi
= bgp_node_afi(vty
);
6406 safi_t safi
= bgp_node_safi(vty
);
6408 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6409 yang_afi_safi_value2identity(afi
, safi
));
6411 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6412 sizeof(base_xpath
), af_xpath
)
6414 return CMD_WARNING_CONFIG_FAILED
;
6416 snprintf(attr_xpath
, sizeof(attr_xpath
),
6417 "./%s/route-reflector/route-reflector-client",
6418 bgp_afi_safi_get_container_str(afi
, safi
));
6420 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6422 return nb_cli_apply_changes(vty
, base_xpath
);
6425 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6426 no_neighbor_route_reflector_client_hidden_cmd
,
6427 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6428 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6429 "Configure a neighbor as Route Reflector client\n")
6431 /* neighbor route-server-client. */
6432 DEFUN_YANG (neighbor_route_server_client
,
6433 neighbor_route_server_client_cmd
,
6434 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6437 "Configure a neighbor as Route Server client\n")
6440 char base_xpath
[XPATH_MAXLEN
];
6441 char af_xpath
[XPATH_MAXLEN
];
6442 char attr_xpath
[XPATH_MAXLEN
];
6443 afi_t afi
= bgp_node_afi(vty
);
6444 safi_t safi
= bgp_node_safi(vty
);
6446 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6447 yang_afi_safi_value2identity(afi
, safi
));
6449 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6450 sizeof(base_xpath
), af_xpath
)
6452 return CMD_WARNING_CONFIG_FAILED
;
6454 snprintf(attr_xpath
, sizeof(attr_xpath
),
6455 "./%s/route-server/route-server-client",
6456 bgp_afi_safi_get_container_str(afi
, safi
));
6458 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6460 return nb_cli_apply_changes(vty
, base_xpath
);
6463 ALIAS_HIDDEN(neighbor_route_server_client
,
6464 neighbor_route_server_client_hidden_cmd
,
6465 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6466 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6467 "Configure a neighbor as Route Server client\n")
6469 DEFUN_YANG (no_neighbor_route_server_client
,
6470 no_neighbor_route_server_client_cmd
,
6471 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6475 "Configure a neighbor as Route Server client\n")
6478 char base_xpath
[XPATH_MAXLEN
];
6479 char af_xpath
[XPATH_MAXLEN
];
6480 char attr_xpath
[XPATH_MAXLEN
];
6481 afi_t afi
= bgp_node_afi(vty
);
6482 safi_t safi
= bgp_node_safi(vty
);
6484 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6485 yang_afi_safi_value2identity(afi
, safi
));
6487 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6488 sizeof(base_xpath
), af_xpath
)
6490 return CMD_WARNING_CONFIG_FAILED
;
6492 snprintf(attr_xpath
, sizeof(attr_xpath
),
6493 "./%s/route-server/route-server-client",
6494 bgp_afi_safi_get_container_str(afi
, safi
));
6496 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6498 return nb_cli_apply_changes(vty
, base_xpath
);
6501 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6502 no_neighbor_route_server_client_hidden_cmd
,
6503 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6504 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6505 "Configure a neighbor as Route Server client\n")
6507 DEFUN (neighbor_nexthop_local_unchanged
,
6508 neighbor_nexthop_local_unchanged_cmd
,
6509 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6512 "Configure treatment of outgoing link-local nexthop attribute\n"
6513 "Leave link-local nexthop unchanged for this peer\n")
6516 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6518 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6521 DEFUN (no_neighbor_nexthop_local_unchanged
,
6522 no_neighbor_nexthop_local_unchanged_cmd
,
6523 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6527 "Configure treatment of outgoing link-local-nexthop attribute\n"
6528 "Leave link-local nexthop unchanged for this peer\n")
6531 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6532 bgp_node_afi(vty
), bgp_node_safi(vty
),
6533 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6536 DEFUN_YANG (neighbor_attr_unchanged
,
6537 neighbor_attr_unchanged_cmd
,
6538 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6541 "BGP attribute is propagated unchanged to this neighbor\n"
6542 "As-path attribute\n"
6543 "Nexthop attribute\n"
6547 char *peer_str
= argv
[1]->arg
;
6548 bool aspath
= false;
6549 bool nexthop
= false;
6551 afi_t afi
= bgp_node_afi(vty
);
6552 safi_t safi
= bgp_node_safi(vty
);
6553 char base_xpath
[XPATH_MAXLEN
];
6554 char af_xpath
[XPATH_MAXLEN
];
6555 char as_xpath
[XPATH_MAXLEN
];
6556 char nxthop_xpath
[XPATH_MAXLEN
];
6557 char med_xpath
[XPATH_MAXLEN
];
6559 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6560 yang_afi_safi_value2identity(afi
, safi
));
6562 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6563 sizeof(base_xpath
), af_xpath
)
6565 return CMD_WARNING_CONFIG_FAILED
;
6567 if (argv_find(argv
, argc
, "as-path", &idx
))
6571 if (argv_find(argv
, argc
, "next-hop", &idx
))
6575 if (argv_find(argv
, argc
, "med", &idx
))
6578 snprintf(as_xpath
, sizeof(as_xpath
),
6579 "./%s/attr-unchanged/as-path-unchanged",
6580 bgp_afi_safi_get_container_str(afi
, safi
));
6581 snprintf(nxthop_xpath
, sizeof(nxthop_xpath
),
6582 "./%s/attr-unchanged/next-hop-unchanged",
6583 bgp_afi_safi_get_container_str(afi
, safi
));
6584 snprintf(med_xpath
, sizeof(med_xpath
),
6585 "./%s/attr-unchanged/med-unchanged",
6586 bgp_afi_safi_get_container_str(afi
, safi
));
6588 /* no flags means all of them! */
6589 if (!aspath
&& !nexthop
&& !med
) {
6590 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "true");
6591 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "true");
6592 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "true");
6595 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
,
6598 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
,
6602 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
,
6605 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
,
6609 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
,
6612 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
,
6616 return nb_cli_apply_changes(vty
, base_xpath
);
6620 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6621 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6622 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6623 "BGP attribute is propagated unchanged to this neighbor\n"
6624 "As-path attribute\n"
6625 "Nexthop attribute\n"
6628 DEFUN_YANG (no_neighbor_attr_unchanged
,
6629 no_neighbor_attr_unchanged_cmd
,
6630 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6634 "BGP attribute is propagated unchanged to this neighbor\n"
6635 "As-path attribute\n"
6636 "Nexthop attribute\n"
6640 char *peer_str
= argv
[2]->arg
;
6641 bool aspath
= false;
6642 bool nexthop
= false;
6644 afi_t afi
= bgp_node_afi(vty
);
6645 safi_t safi
= bgp_node_safi(vty
);
6646 char base_xpath
[XPATH_MAXLEN
];
6647 char af_xpath
[XPATH_MAXLEN
];
6648 char as_xpath
[XPATH_MAXLEN
];
6649 char nxthop_xpath
[XPATH_MAXLEN
];
6650 char med_xpath
[XPATH_MAXLEN
];
6652 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6653 yang_afi_safi_value2identity(afi
, safi
));
6655 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6656 sizeof(base_xpath
), af_xpath
)
6658 return CMD_WARNING_CONFIG_FAILED
;
6660 if (argv_find(argv
, argc
, "as-path", &idx
))
6664 if (argv_find(argv
, argc
, "next-hop", &idx
))
6668 if (argv_find(argv
, argc
, "med", &idx
))
6671 snprintf(as_xpath
, sizeof(as_xpath
),
6672 "./%s/attr-unchanged/as-path-unchanged",
6673 bgp_afi_safi_get_container_str(afi
, safi
));
6674 snprintf(nxthop_xpath
, sizeof(nxthop_xpath
),
6675 "./%s/attr-unchanged/next-hop-unchanged",
6676 bgp_afi_safi_get_container_str(afi
, safi
));
6677 snprintf(med_xpath
, sizeof(med_xpath
),
6678 "./%s/attr-unchanged/med-unchanged",
6679 bgp_afi_safi_get_container_str(afi
, safi
));
6681 /* no flags means all of them! */
6682 if (!aspath
&& !nexthop
&& !med
) {
6683 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "false");
6684 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "false");
6685 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "false");
6689 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "false");
6692 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "false");
6695 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "false");
6697 return nb_cli_apply_changes(vty
, base_xpath
);
6701 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6702 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6703 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6704 "BGP attribute is propagated unchanged to this neighbor\n"
6705 "As-path attribute\n"
6706 "Nexthop attribute\n"
6709 /* neighbor ebgp-multihop. */
6710 DEFUN_YANG (neighbor_ebgp_multihop
,
6711 neighbor_ebgp_multihop_cmd
,
6712 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6713 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6714 "Allow EBGP neighbors not on directly connected networks\n")
6717 char base_xpath
[XPATH_MAXLEN
];
6719 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6720 sizeof(base_xpath
), NULL
)
6722 return CMD_WARNING_CONFIG_FAILED
;
6724 nb_cli_enqueue_change(vty
, "./ebgp-multihop/enabled", NB_OP_MODIFY
,
6727 return nb_cli_apply_changes(vty
, base_xpath
);
6730 DEFUN_YANG (neighbor_ebgp_multihop_ttl
,
6731 neighbor_ebgp_multihop_ttl_cmd
,
6732 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6733 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6734 "Allow EBGP neighbors not on directly connected networks\n"
6735 "maximum hop count\n")
6739 char base_xpath
[XPATH_MAXLEN
];
6741 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6742 sizeof(base_xpath
), NULL
)
6744 return CMD_WARNING_CONFIG_FAILED
;
6746 nb_cli_enqueue_change(vty
, "./ebgp-multihop/multihop-ttl", NB_OP_MODIFY
,
6747 argv
[idx_number
]->arg
);
6749 return nb_cli_apply_changes(vty
, base_xpath
);
6752 DEFUN_YANG (no_neighbor_ebgp_multihop
,
6753 no_neighbor_ebgp_multihop_cmd
,
6754 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6755 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6756 "Allow EBGP neighbors not on directly connected networks\n"
6757 "maximum hop count\n")
6760 char base_xpath
[XPATH_MAXLEN
];
6762 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6763 sizeof(base_xpath
), NULL
)
6765 return CMD_WARNING_CONFIG_FAILED
;
6768 nb_cli_enqueue_change(vty
, "./ebgp-multihop/multihop-ttl",
6769 NB_OP_DESTROY
, NULL
);
6771 nb_cli_enqueue_change(vty
, "./ebgp-multihop/enabled",
6772 NB_OP_MODIFY
, "false");
6774 return nb_cli_apply_changes(vty
, base_xpath
);
6778 /* disable-connected-check */
6779 DEFUN_YANG (neighbor_disable_connected_check
,
6780 neighbor_disable_connected_check_cmd
,
6781 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6782 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6783 "one-hop away EBGP peer using loopback address\n"
6784 "Enforce EBGP neighbors perform multihop\n")
6787 char base_xpath
[XPATH_MAXLEN
];
6789 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6790 sizeof(base_xpath
), NULL
)
6792 return CMD_WARNING_CONFIG_FAILED
;
6794 nb_cli_enqueue_change(vty
, "./ebgp-multihop/disable-connected-check",
6795 NB_OP_MODIFY
, "true");
6797 return nb_cli_apply_changes(vty
, base_xpath
);
6800 DEFUN_YANG (no_neighbor_disable_connected_check
,
6801 no_neighbor_disable_connected_check_cmd
,
6802 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6803 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6804 "one-hop away EBGP peer using loopback address\n"
6805 "Enforce EBGP neighbors perform multihop\n")
6808 char base_xpath
[XPATH_MAXLEN
];
6810 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6811 sizeof(base_xpath
), NULL
)
6813 return CMD_WARNING_CONFIG_FAILED
;
6815 nb_cli_enqueue_change(vty
, "./ebgp-multihop/disable-connected-check",
6816 NB_OP_MODIFY
, "false");
6818 return nb_cli_apply_changes(vty
, base_xpath
);
6822 /* enforce-first-as */
6823 DEFUN_YANG (neighbor_enforce_first_as
,
6824 neighbor_enforce_first_as_cmd
,
6825 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6826 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6827 "Enforce the first AS for EBGP routes\n")
6830 char base_xpath
[XPATH_MAXLEN
];
6832 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6833 sizeof(base_xpath
), NULL
)
6835 return CMD_WARNING_CONFIG_FAILED
;
6837 nb_cli_enqueue_change(vty
, "./enforce-first-as", NB_OP_MODIFY
, "true");
6839 return nb_cli_apply_changes(vty
, base_xpath
);
6842 DEFUN_YANG (no_neighbor_enforce_first_as
,
6843 no_neighbor_enforce_first_as_cmd
,
6844 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6845 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6846 "Enforce the first AS for EBGP routes\n")
6849 char base_xpath
[XPATH_MAXLEN
];
6851 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6852 sizeof(base_xpath
), NULL
)
6854 return CMD_WARNING_CONFIG_FAILED
;
6856 nb_cli_enqueue_change(vty
, "./enforce-first-as", NB_OP_MODIFY
, "false");
6858 return nb_cli_apply_changes(vty
, base_xpath
);
6861 static int peer_and_group_lookup_nb(struct vty
*vty
, const char *peer_str
,
6862 char *base_xpath
, int xpath_len
,
6866 char num_xpath
[XPATH_MAXLEN
];
6867 char unnbr_xpath
[XPATH_MAXLEN
];
6868 char prgrp_xpath
[XPATH_MAXLEN
];
6870 if (str2sockunion(peer_str
, &su
) == 0) {
6871 snprintf(num_xpath
, sizeof(num_xpath
),
6872 "/neighbors/neighbor[remote-address='%s']", peer_str
);
6873 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
6874 VTY_CURR_XPATH
, num_xpath
)) {
6875 snprintf(base_xpath
, xpath_len
,
6876 FRR_BGP_NEIGHBOR_NUM_XPATH
, peer_str
,
6877 xpath
? xpath
: "");
6880 "%% Specify remote-as or peer-group commands first\n");
6885 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
6886 "/neighbors/unnumbered-neighbor[interface='%s']",
6889 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
6890 "/peer-groups/peer-group[peer-group-name='%s']",
6893 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
6894 VTY_CURR_XPATH
, unnbr_xpath
)) {
6895 snprintf(base_xpath
, xpath_len
,
6896 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, peer_str
,
6897 xpath
? xpath
: "");
6898 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
,
6899 "%s%s", VTY_CURR_XPATH
,
6901 snprintf(base_xpath
, xpath_len
,
6902 FRR_BGP_PEER_GROUP_XPATH
, peer_str
,
6903 xpath
? xpath
: "");
6906 "%% Create the peer-group or interface first\n");
6914 DEFUN_YANG (neighbor_description
,
6915 neighbor_description_cmd
,
6916 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6917 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6918 "Neighbor specific description\n"
6919 "Up to 80 characters describing this neighbor\n")
6924 char base_xpath
[XPATH_MAXLEN
];
6927 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6928 sizeof(base_xpath
), NULL
)
6930 return CMD_WARNING_CONFIG_FAILED
;
6932 str
= argv_concat(argv
, argc
, idx_line
);
6934 nb_cli_enqueue_change(vty
, "./description", NB_OP_MODIFY
, str
);
6936 ret
= nb_cli_apply_changes(vty
, base_xpath
);
6938 XFREE(MTYPE_TMP
, str
);
6943 DEFUN_YANG (no_neighbor_description
,
6944 no_neighbor_description_cmd
,
6945 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6946 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6947 "Neighbor specific description\n")
6950 char base_xpath
[XPATH_MAXLEN
];
6952 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6953 sizeof(base_xpath
), NULL
)
6955 return CMD_WARNING_CONFIG_FAILED
;
6957 nb_cli_enqueue_change(vty
, "./description", NB_OP_DESTROY
, NULL
);
6959 return nb_cli_apply_changes(vty
, base_xpath
);
6962 ALIAS_YANG(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6963 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6964 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6965 "Neighbor specific description\n"
6966 "Up to 80 characters describing this neighbor\n")
6968 #define BGP_UPDATE_SOURCE_HELP_STR \
6971 "Interface name (requires zebra to be running)\n"
6973 DEFUN_YANG (neighbor_update_source
,
6974 neighbor_update_source_cmd
,
6975 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6976 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6977 "Source of routing updates\n"
6978 BGP_UPDATE_SOURCE_HELP_STR
)
6983 char base_xpath
[XPATH_MAXLEN
];
6985 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6986 sizeof(base_xpath
), NULL
)
6988 return CMD_WARNING_CONFIG_FAILED
;
6990 if (str2sockunion(argv
[idx_peer_2
]->arg
, &su
) == 0)
6991 nb_cli_enqueue_change(vty
, "./update-source/ip", NB_OP_MODIFY
,
6992 argv
[idx_peer_2
]->arg
);
6994 nb_cli_enqueue_change(vty
, "./update-source/interface",
6995 NB_OP_MODIFY
, argv
[idx_peer_2
]->arg
);
6997 return nb_cli_apply_changes(vty
, base_xpath
);
7000 DEFUN_YANG (no_neighbor_update_source
,
7001 no_neighbor_update_source_cmd
,
7002 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
7005 "Source of routing updates\n"
7006 BGP_UPDATE_SOURCE_HELP_STR
)
7009 char base_xpath
[XPATH_MAXLEN
];
7011 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7012 sizeof(base_xpath
), NULL
)
7014 return CMD_WARNING_CONFIG_FAILED
;
7016 nb_cli_enqueue_change(vty
, "./update-source/ip", NB_OP_DESTROY
, NULL
);
7017 nb_cli_enqueue_change(vty
, "./update-source/interface", NB_OP_DESTROY
,
7020 return nb_cli_apply_changes(vty
, base_xpath
);
7023 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
7024 afi_t afi
, safi_t safi
,
7025 const char *rmap
, int set
)
7029 struct route_map
*route_map
= NULL
;
7031 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
7033 return CMD_WARNING_CONFIG_FAILED
;
7037 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
7038 ret
= peer_default_originate_set(peer
, afi
, safi
,
7041 ret
= peer_default_originate_unset(peer
, afi
, safi
);
7043 return bgp_vty_return(vty
, ret
);
7046 /* neighbor default-originate. */
7047 DEFUN (neighbor_default_originate
,
7048 neighbor_default_originate_cmd
,
7049 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
7052 "Originate default route to this neighbor\n")
7055 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
7057 bgp_node_safi(vty
), NULL
, 1);
7060 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
7061 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
7062 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7063 "Originate default route to this neighbor\n")
7065 DEFUN (neighbor_default_originate_rmap
,
7066 neighbor_default_originate_rmap_cmd
,
7067 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
7070 "Originate default route to this neighbor\n"
7071 "Route-map to specify criteria to originate default\n"
7076 return peer_default_originate_set_vty(
7077 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7078 argv
[idx_word
]->arg
, 1);
7082 neighbor_default_originate_rmap
,
7083 neighbor_default_originate_rmap_hidden_cmd
,
7084 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
7085 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7086 "Originate default route to this neighbor\n"
7087 "Route-map to specify criteria to originate default\n"
7090 DEFUN (no_neighbor_default_originate
,
7091 no_neighbor_default_originate_cmd
,
7092 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
7096 "Originate default route to this neighbor\n"
7097 "Route-map to specify criteria to originate default\n"
7101 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
7103 bgp_node_safi(vty
), NULL
, 0);
7107 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
7108 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
7109 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7110 "Originate default route to this neighbor\n"
7111 "Route-map to specify criteria to originate default\n"
7115 /* Set specified peer's BGP port. */
7116 DEFUN_YANG (neighbor_port
,
7118 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
7121 "Neighbor's BGP port\n"
7122 "TCP port number\n")
7126 char base_xpath
[XPATH_MAXLEN
];
7128 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7129 argv
[idx_ip
]->arg
, "");
7131 nb_cli_enqueue_change(vty
, "./local-port", NB_OP_MODIFY
,
7132 argv
[idx_number
]->arg
);
7134 return nb_cli_apply_changes(vty
, base_xpath
);
7137 DEFUN_YANG (no_neighbor_port
,
7138 no_neighbor_port_cmd
,
7139 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
7140 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR
7141 "Neighbor's BGP port\n"
7142 "TCP port number\n")
7145 char base_xpath
[XPATH_MAXLEN
];
7147 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7148 argv
[idx_ip
]->arg
, "");
7150 nb_cli_enqueue_change(vty
, "./local-port", NB_OP_DESTROY
, NULL
);
7152 return nb_cli_apply_changes(vty
, base_xpath
);
7155 DEFUN_YANG (neighbor_weight
,
7156 neighbor_weight_cmd
,
7157 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7158 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7159 "Set default weight for routes from this neighbor\n"
7164 char base_xpath
[XPATH_MAXLEN
];
7165 char af_xpath
[XPATH_MAXLEN
];
7166 char attr_xpath
[XPATH_MAXLEN
];
7167 afi_t afi
= bgp_node_afi(vty
);
7168 safi_t safi
= bgp_node_safi(vty
);
7170 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
7171 yang_afi_safi_value2identity(afi
, safi
));
7173 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7174 sizeof(base_xpath
), af_xpath
)
7176 return CMD_WARNING_CONFIG_FAILED
;
7178 snprintf(attr_xpath
, sizeof(attr_xpath
), "./%s/weight/weight-attribute",
7179 bgp_afi_safi_get_container_str(afi
, safi
));
7181 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
,
7182 argv
[idx_number
]->arg
);
7184 return nb_cli_apply_changes(vty
, base_xpath
);
7187 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
7188 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7189 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7190 "Set default weight for routes from this neighbor\n"
7193 DEFUN_YANG (no_neighbor_weight
,
7194 no_neighbor_weight_cmd
,
7195 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7196 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7197 "Set default weight for routes from this neighbor\n"
7201 char base_xpath
[XPATH_MAXLEN
];
7202 char af_xpath
[XPATH_MAXLEN
];
7203 char attr_xpath
[XPATH_MAXLEN
];
7204 afi_t afi
= bgp_node_afi(vty
);
7205 safi_t safi
= bgp_node_safi(vty
);
7207 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
7208 yang_afi_safi_value2identity(afi
, safi
));
7210 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7211 sizeof(base_xpath
), af_xpath
)
7213 return CMD_WARNING_CONFIG_FAILED
;
7215 snprintf(attr_xpath
, sizeof(attr_xpath
), "./%s/weight/weight-attribute",
7216 bgp_afi_safi_get_container_str(afi
, safi
));
7218 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_DESTROY
, NULL
);
7220 return nb_cli_apply_changes(vty
, base_xpath
);
7223 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
7224 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7225 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7226 "Set default weight for routes from this neighbor\n"
7230 /* Override capability negotiation. */
7231 DEFUN_YANG (neighbor_override_capability
,
7232 neighbor_override_capability_cmd
,
7233 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7236 "Override capability negotiation result\n")
7239 char base_xpath
[XPATH_MAXLEN
];
7241 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7242 sizeof(base_xpath
), NULL
)
7244 return CMD_WARNING_CONFIG_FAILED
;
7246 nb_cli_enqueue_change(
7247 vty
, "./capability-options/override-capability",
7248 NB_OP_MODIFY
, "true");
7250 return nb_cli_apply_changes(vty
, base_xpath
);
7253 DEFUN_YANG (no_neighbor_override_capability
,
7254 no_neighbor_override_capability_cmd
,
7255 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7259 "Override capability negotiation result\n")
7262 char base_xpath
[XPATH_MAXLEN
];
7264 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7265 sizeof(base_xpath
), NULL
)
7267 return CMD_WARNING_CONFIG_FAILED
;
7269 nb_cli_enqueue_change(
7270 vty
, "./capability-options/override-capability",
7271 NB_OP_MODIFY
, "false");
7273 return nb_cli_apply_changes(vty
, base_xpath
);
7276 DEFUN_YANG (neighbor_strict_capability
,
7277 neighbor_strict_capability_cmd
,
7278 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7281 "Strict capability negotiation match\n")
7284 char base_xpath
[XPATH_MAXLEN
];
7286 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7287 sizeof(base_xpath
), NULL
)
7289 return CMD_WARNING_CONFIG_FAILED
;
7291 nb_cli_enqueue_change(
7292 vty
, "./capability-options/strict-capability",
7293 NB_OP_MODIFY
, "true");
7295 return nb_cli_apply_changes(vty
, base_xpath
);
7298 DEFUN_YANG (no_neighbor_strict_capability
,
7299 no_neighbor_strict_capability_cmd
,
7300 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7304 "Strict capability negotiation match\n")
7307 char base_xpath
[XPATH_MAXLEN
];
7309 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7310 sizeof(base_xpath
), NULL
)
7312 return CMD_WARNING_CONFIG_FAILED
;
7314 nb_cli_enqueue_change(
7315 vty
, "./capability-options/strict-capability",
7316 NB_OP_MODIFY
, "false");
7318 return nb_cli_apply_changes(vty
, base_xpath
);
7321 DEFUN_YANG (neighbor_timers
,
7322 neighbor_timers_cmd
,
7323 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7324 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7325 "BGP per neighbor timers\n"
7326 "Keepalive interval\n"
7331 int idx_number_2
= 4;
7332 char base_xpath
[XPATH_MAXLEN
];
7334 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7335 sizeof(base_xpath
), NULL
)
7337 return CMD_WARNING_CONFIG_FAILED
;
7339 nb_cli_enqueue_change(vty
, "./timers/keepalive", NB_OP_MODIFY
,
7340 argv
[idx_number
]->arg
);
7342 nb_cli_enqueue_change(vty
, "./timers/hold-time", NB_OP_MODIFY
,
7343 argv
[idx_number_2
]->arg
);
7345 return nb_cli_apply_changes(vty
, base_xpath
);
7348 DEFUN_YANG (no_neighbor_timers
,
7349 no_neighbor_timers_cmd
,
7350 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7351 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7352 "BGP per neighbor timers\n"
7353 "Keepalive interval\n"
7357 char base_xpath
[XPATH_MAXLEN
];
7359 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7360 sizeof(base_xpath
), NULL
)
7362 return CMD_WARNING_CONFIG_FAILED
;
7364 nb_cli_enqueue_change(vty
, "./timers/hold-time", NB_OP_DESTROY
, NULL
);
7366 nb_cli_enqueue_change(vty
, "./timers/keepalive", NB_OP_DESTROY
, NULL
);
7368 return nb_cli_apply_changes(vty
, base_xpath
);
7371 DEFUN_YANG (neighbor_timers_connect
,
7372 neighbor_timers_connect_cmd
,
7373 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7374 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7375 "BGP per neighbor timers\n"
7376 "BGP connect timer\n"
7381 char base_xpath
[XPATH_MAXLEN
];
7383 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7384 sizeof(base_xpath
), NULL
)
7386 return CMD_WARNING_CONFIG_FAILED
;
7388 nb_cli_enqueue_change(vty
, "./timers/connect-time", NB_OP_MODIFY
,
7389 argv
[idx_number
]->arg
);
7391 return nb_cli_apply_changes(vty
, base_xpath
);
7394 DEFUN_YANG (no_neighbor_timers_connect
,
7395 no_neighbor_timers_connect_cmd
,
7396 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7397 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7398 "BGP per neighbor timers\n"
7399 "BGP connect timer\n"
7403 char base_xpath
[XPATH_MAXLEN
];
7405 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7406 sizeof(base_xpath
), NULL
)
7408 return CMD_WARNING_CONFIG_FAILED
;
7410 nb_cli_enqueue_change(vty
, "./timers/connect-time", NB_OP_DESTROY
,
7413 return nb_cli_apply_changes(vty
, base_xpath
);
7416 DEFPY (neighbor_timers_delayopen
,
7417 neighbor_timers_delayopen_cmd
,
7418 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7421 "BGP per neighbor timers\n"
7422 "RFC 4271 DelayOpenTimer\n"
7423 "DelayOpenTime timer interval\n")
7427 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7429 return CMD_WARNING_CONFIG_FAILED
;
7432 if (peer_timers_delayopen_unset(peer
))
7433 return CMD_WARNING_CONFIG_FAILED
;
7435 if (peer_timers_delayopen_set(peer
, interval
))
7436 return CMD_WARNING_CONFIG_FAILED
;
7442 DEFPY (no_neighbor_timers_delayopen
,
7443 no_neighbor_timers_delayopen_cmd
,
7444 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7448 "BGP per neighbor timers\n"
7449 "RFC 4271 DelayOpenTimer\n"
7450 "DelayOpenTime timer interval\n")
7454 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7456 return CMD_WARNING_CONFIG_FAILED
;
7458 if (peer_timers_delayopen_unset(peer
))
7459 return CMD_WARNING_CONFIG_FAILED
;
7464 DEFUN_YANG (neighbor_advertise_interval
,
7465 neighbor_advertise_interval_cmd
,
7466 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7467 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7468 "Minimum interval between sending BGP routing updates\n"
7469 "time in seconds\n")
7473 char base_xpath
[XPATH_MAXLEN
];
7475 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7476 sizeof(base_xpath
), NULL
)
7478 return CMD_WARNING_CONFIG_FAILED
;
7480 nb_cli_enqueue_change(vty
, "./timers/advertise-interval", NB_OP_MODIFY
,
7481 argv
[idx_number
]->arg
);
7483 return nb_cli_apply_changes(vty
, base_xpath
);
7486 DEFUN_YANG (no_neighbor_advertise_interval
,
7487 no_neighbor_advertise_interval_cmd
,
7488 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7489 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7490 "Minimum interval between sending BGP routing updates\n"
7491 "time in seconds\n")
7494 char base_xpath
[XPATH_MAXLEN
];
7496 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7497 sizeof(base_xpath
), NULL
)
7499 return CMD_WARNING_CONFIG_FAILED
;
7501 nb_cli_enqueue_change(vty
, "./timers/advertise-interval", NB_OP_DESTROY
,
7504 return nb_cli_apply_changes(vty
, base_xpath
);
7508 /* Time to wait before processing route-map updates */
7509 DEFUN (bgp_set_route_map_delay_timer
,
7510 bgp_set_route_map_delay_timer_cmd
,
7511 "bgp route-map delay-timer (0-600)",
7513 "BGP route-map delay timer\n"
7514 "Time in secs to wait before processing route-map changes\n"
7515 "0 disables the timer, no route updates happen when route-maps change\n")
7518 uint32_t rmap_delay_timer
;
7520 if (argv
[idx_number
]->arg
) {
7521 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7522 bm
->rmap_update_timer
= rmap_delay_timer
;
7524 /* if the dynamic update handling is being disabled, and a timer
7526 * running, stop the timer and act as if the timer has already
7529 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7530 BGP_TIMER_OFF(bm
->t_rmap_update
);
7531 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7536 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7537 return CMD_WARNING_CONFIG_FAILED
;
7541 DEFUN (no_bgp_set_route_map_delay_timer
,
7542 no_bgp_set_route_map_delay_timer_cmd
,
7543 "no bgp route-map delay-timer [(0-600)]",
7546 "Default BGP route-map delay timer\n"
7547 "Reset to default time to wait for processing route-map changes\n"
7548 "0 disables the timer, no route updates happen when route-maps change\n")
7551 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7556 DEFUN_YANG (neighbor_interface
,
7557 neighbor_interface_cmd
,
7558 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7559 NEIGHBOR_STR NEIGHBOR_ADDR_STR
7565 char base_xpath
[XPATH_MAXLEN
];
7567 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7568 argv
[idx_ip
]->arg
, "");
7570 nb_cli_enqueue_change(vty
, "./local-interface", NB_OP_MODIFY
,
7571 argv
[idx_word
]->arg
);
7573 return nb_cli_apply_changes(vty
, base_xpath
);
7576 DEFUN_YANG (no_neighbor_interface
,
7577 no_neighbor_interface_cmd
,
7578 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
7579 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7584 char base_xpath
[XPATH_MAXLEN
];
7586 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7587 argv
[idx_peer
]->arg
, "");
7589 nb_cli_enqueue_change(vty
, "./local-interface", NB_OP_DESTROY
, NULL
);
7591 return nb_cli_apply_changes(vty
, base_xpath
);
7594 DEFUN (neighbor_distribute_list
,
7595 neighbor_distribute_list_cmd
,
7596 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7599 "Filter updates to/from this neighbor\n"
7600 "IP access-list number\n"
7601 "IP access-list number (expanded range)\n"
7602 "IP Access-list name\n"
7603 "Filter incoming updates\n"
7604 "Filter outgoing updates\n")
7611 const char *pstr
= argv
[idx_peer
]->arg
;
7612 const char *acl
= argv
[idx_acl
]->arg
;
7613 const char *inout
= argv
[argc
- 1]->text
;
7615 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7617 return CMD_WARNING_CONFIG_FAILED
;
7619 /* Check filter direction. */
7620 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7621 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7624 return bgp_vty_return(vty
, ret
);
7628 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7629 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7630 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7631 "Filter updates to/from this neighbor\n"
7632 "IP access-list number\n"
7633 "IP access-list number (expanded range)\n"
7634 "IP Access-list name\n"
7635 "Filter incoming updates\n"
7636 "Filter outgoing updates\n")
7638 DEFUN (no_neighbor_distribute_list
,
7639 no_neighbor_distribute_list_cmd
,
7640 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7644 "Filter updates to/from this neighbor\n"
7645 "IP access-list number\n"
7646 "IP access-list number (expanded range)\n"
7647 "IP Access-list name\n"
7648 "Filter incoming updates\n"
7649 "Filter outgoing updates\n")
7655 const char *pstr
= argv
[idx_peer
]->arg
;
7656 const char *inout
= argv
[argc
- 1]->text
;
7658 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7660 return CMD_WARNING_CONFIG_FAILED
;
7662 /* Check filter direction. */
7663 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7664 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7667 return bgp_vty_return(vty
, ret
);
7671 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7672 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7673 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7674 "Filter updates to/from this neighbor\n"
7675 "IP access-list number\n"
7676 "IP access-list number (expanded range)\n"
7677 "IP Access-list name\n"
7678 "Filter incoming updates\n"
7679 "Filter outgoing updates\n")
7681 /* Set prefix list to the peer. */
7682 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
7683 afi_t afi
, safi_t safi
,
7684 const char *name_str
,
7685 const char *direct_str
)
7688 int direct
= FILTER_IN
;
7691 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7693 return CMD_WARNING_CONFIG_FAILED
;
7695 /* Check filter direction. */
7696 if (strncmp(direct_str
, "i", 1) == 0)
7698 else if (strncmp(direct_str
, "o", 1) == 0)
7699 direct
= FILTER_OUT
;
7701 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
7703 return bgp_vty_return(vty
, ret
);
7706 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
7707 afi_t afi
, safi_t safi
,
7708 const char *direct_str
)
7712 int direct
= FILTER_IN
;
7714 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7716 return CMD_WARNING_CONFIG_FAILED
;
7718 /* Check filter direction. */
7719 if (strncmp(direct_str
, "i", 1) == 0)
7721 else if (strncmp(direct_str
, "o", 1) == 0)
7722 direct
= FILTER_OUT
;
7724 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
7726 return bgp_vty_return(vty
, ret
);
7729 DEFUN (neighbor_prefix_list
,
7730 neighbor_prefix_list_cmd
,
7731 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7734 "Filter updates to/from this neighbor\n"
7735 "Name of a prefix list\n"
7736 "Filter incoming updates\n"
7737 "Filter outgoing updates\n")
7742 return peer_prefix_list_set_vty(
7743 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7744 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7747 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7748 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7749 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7750 "Filter updates to/from this neighbor\n"
7751 "Name of a prefix list\n"
7752 "Filter incoming updates\n"
7753 "Filter outgoing updates\n")
7755 DEFUN (no_neighbor_prefix_list
,
7756 no_neighbor_prefix_list_cmd
,
7757 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7761 "Filter updates to/from this neighbor\n"
7762 "Name of a prefix list\n"
7763 "Filter incoming updates\n"
7764 "Filter outgoing updates\n")
7768 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
7769 bgp_node_afi(vty
), bgp_node_safi(vty
),
7770 argv
[idx_in_out
]->arg
);
7773 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
7774 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7775 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7776 "Filter updates to/from this neighbor\n"
7777 "Name of a prefix list\n"
7778 "Filter incoming updates\n"
7779 "Filter outgoing updates\n")
7781 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7782 safi_t safi
, const char *name_str
,
7783 const char *direct_str
)
7787 int direct
= FILTER_IN
;
7789 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7791 return CMD_WARNING_CONFIG_FAILED
;
7793 /* Check filter direction. */
7794 if (strncmp(direct_str
, "i", 1) == 0)
7796 else if (strncmp(direct_str
, "o", 1) == 0)
7797 direct
= FILTER_OUT
;
7799 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7801 return bgp_vty_return(vty
, ret
);
7804 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7805 safi_t safi
, const char *direct_str
)
7809 int direct
= FILTER_IN
;
7811 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7813 return CMD_WARNING_CONFIG_FAILED
;
7815 /* Check filter direction. */
7816 if (strncmp(direct_str
, "i", 1) == 0)
7818 else if (strncmp(direct_str
, "o", 1) == 0)
7819 direct
= FILTER_OUT
;
7821 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7823 return bgp_vty_return(vty
, ret
);
7826 DEFUN (neighbor_filter_list
,
7827 neighbor_filter_list_cmd
,
7828 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7831 "Establish BGP filters\n"
7832 "AS path access-list name\n"
7833 "Filter incoming routes\n"
7834 "Filter outgoing routes\n")
7839 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7840 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7841 argv
[idx_in_out
]->arg
);
7844 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7845 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7846 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7847 "Establish BGP filters\n"
7848 "AS path access-list name\n"
7849 "Filter incoming routes\n"
7850 "Filter outgoing routes\n")
7852 DEFUN (no_neighbor_filter_list
,
7853 no_neighbor_filter_list_cmd
,
7854 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7858 "Establish BGP filters\n"
7859 "AS path access-list name\n"
7860 "Filter incoming routes\n"
7861 "Filter outgoing routes\n")
7865 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7866 bgp_node_afi(vty
), bgp_node_safi(vty
),
7867 argv
[idx_in_out
]->arg
);
7870 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7871 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7872 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7873 "Establish BGP filters\n"
7874 "AS path access-list name\n"
7875 "Filter incoming routes\n"
7876 "Filter outgoing routes\n")
7878 /* Set advertise-map to the peer. */
7879 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7880 afi_t afi
, safi_t safi
,
7881 const char *advertise_str
,
7882 const char *condition_str
, bool condition
,
7885 int ret
= CMD_WARNING_CONFIG_FAILED
;
7887 struct route_map
*advertise_map
;
7888 struct route_map
*condition_map
;
7890 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7894 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7895 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7898 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7899 advertise_map
, condition_str
,
7900 condition_map
, condition
);
7902 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7903 advertise_map
, condition_str
,
7904 condition_map
, condition
);
7906 return bgp_vty_return(vty
, ret
);
7909 DEFPY (neighbor_advertise_map
,
7910 neighbor_advertise_map_cmd
,
7911 "[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",
7915 "Route-map to conditionally advertise routes\n"
7916 "Name of advertise map\n"
7917 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7918 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7919 "Name of the exist or non exist map\n")
7921 bool condition
= CONDITION_EXIST
;
7923 if (!strcmp(exist
, "non-exist-map"))
7924 condition
= CONDITION_NON_EXIST
;
7926 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7927 bgp_node_safi(vty
), advertise_str
,
7928 condition_str
, condition
, !no
);
7931 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7932 "[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",
7933 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7934 "Route-map to conditionally advertise routes\n"
7935 "Name of advertise map\n"
7936 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7937 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7938 "Name of the exist or non exist map\n")
7940 /* Set route-map to the peer. */
7941 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7942 afi_t afi
, safi_t safi
, const char *name_str
,
7943 const char *direct_str
)
7947 int direct
= RMAP_IN
;
7948 struct route_map
*route_map
;
7950 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7952 return CMD_WARNING_CONFIG_FAILED
;
7954 /* Check filter direction. */
7955 if (strncmp(direct_str
, "in", 2) == 0)
7957 else if (strncmp(direct_str
, "o", 1) == 0)
7960 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7961 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7963 return bgp_vty_return(vty
, ret
);
7966 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7967 afi_t afi
, safi_t safi
,
7968 const char *direct_str
)
7972 int direct
= RMAP_IN
;
7974 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7976 return CMD_WARNING_CONFIG_FAILED
;
7978 /* Check filter direction. */
7979 if (strncmp(direct_str
, "in", 2) == 0)
7981 else if (strncmp(direct_str
, "o", 1) == 0)
7984 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7986 return bgp_vty_return(vty
, ret
);
7989 DEFUN (neighbor_route_map
,
7990 neighbor_route_map_cmd
,
7991 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7994 "Apply route map to neighbor\n"
7995 "Name of route map\n"
7996 "Apply map to incoming routes\n"
7997 "Apply map to outbound routes\n")
8002 return peer_route_map_set_vty(
8003 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8004 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
8007 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
8008 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
8009 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8010 "Apply route map to neighbor\n"
8011 "Name of route map\n"
8012 "Apply map to incoming routes\n"
8013 "Apply map to outbound routes\n")
8015 DEFUN (no_neighbor_route_map
,
8016 no_neighbor_route_map_cmd
,
8017 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
8021 "Apply route map to neighbor\n"
8022 "Name of route map\n"
8023 "Apply map to incoming routes\n"
8024 "Apply map to outbound routes\n")
8028 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
8029 bgp_node_afi(vty
), bgp_node_safi(vty
),
8030 argv
[idx_in_out
]->arg
);
8033 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
8034 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
8035 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8036 "Apply route map to neighbor\n"
8037 "Name of route map\n"
8038 "Apply map to incoming routes\n"
8039 "Apply map to outbound routes\n")
8041 /* Set unsuppress-map to the peer. */
8042 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
8043 afi_t afi
, safi_t safi
,
8044 const char *name_str
)
8048 struct route_map
*route_map
;
8050 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8052 return CMD_WARNING_CONFIG_FAILED
;
8054 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
8055 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
8057 return bgp_vty_return(vty
, ret
);
8060 /* Unset route-map from the peer. */
8061 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
8062 afi_t afi
, safi_t safi
)
8067 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8069 return CMD_WARNING_CONFIG_FAILED
;
8071 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
8073 return bgp_vty_return(vty
, ret
);
8076 DEFUN (neighbor_unsuppress_map
,
8077 neighbor_unsuppress_map_cmd
,
8078 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8081 "Route-map to selectively unsuppress suppressed routes\n"
8082 "Name of route map\n")
8086 return peer_unsuppress_map_set_vty(
8087 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8088 argv
[idx_word
]->arg
);
8091 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
8092 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8093 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8094 "Route-map to selectively unsuppress suppressed routes\n"
8095 "Name of route map\n")
8097 DEFUN (no_neighbor_unsuppress_map
,
8098 no_neighbor_unsuppress_map_cmd
,
8099 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8103 "Route-map to selectively unsuppress suppressed routes\n"
8104 "Name of route map\n")
8107 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
8109 bgp_node_safi(vty
));
8112 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
8113 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8114 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8115 "Route-map to selectively unsuppress suppressed routes\n"
8116 "Name of route map\n")
8118 /* Maximum number of prefix to be sent to the neighbor. */
8119 DEFUN_YANG(neighbor_maximum_prefix_out
,
8120 neighbor_maximum_prefix_out_cmd
,
8121 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
8122 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8123 "Maximum number of prefixes to be sent to this peer\n"
8124 "Maximum no. of prefix limit\n")
8126 char base_xpath
[XPATH_MAXLEN
];
8127 char af_xpath
[XPATH_MAXLEN
];
8128 char attr_xpath
[XPATH_MAXLEN
];
8131 afi_t afi
= bgp_node_afi(vty
);
8132 safi_t safi
= bgp_node_safi(vty
);
8134 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8135 yang_afi_safi_value2identity(afi
, safi
));
8136 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8137 sizeof(base_xpath
), af_xpath
)
8139 return CMD_WARNING_CONFIG_FAILED
;
8141 snprintf(attr_xpath
, sizeof(attr_xpath
),
8142 "/%s/prefix-limit/direction-list[direction='out']",
8143 bgp_afi_safi_get_container_str(afi
, safi
));
8144 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8146 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8148 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8149 argv
[idx_number
]->arg
);
8151 return nb_cli_apply_changes(vty
, base_xpath
);
8154 DEFUN_YANG(no_neighbor_maximum_prefix_out
,
8155 no_neighbor_maximum_prefix_out_cmd
,
8156 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out",
8157 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8158 "Maximum number of prefixes to be sent to this peer\n")
8160 char base_xpath
[XPATH_MAXLEN
];
8161 char af_xpath
[XPATH_MAXLEN
];
8162 char attr_xpath
[XPATH_MAXLEN
];
8164 afi_t afi
= bgp_node_afi(vty
);
8165 safi_t safi
= bgp_node_safi(vty
);
8167 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8168 yang_afi_safi_value2identity(afi
, safi
));
8169 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8170 sizeof(base_xpath
), af_xpath
)
8172 return CMD_WARNING_CONFIG_FAILED
;
8174 snprintf(attr_xpath
, sizeof(attr_xpath
),
8175 "/%s/prefix-limit/direction-list[direction='out']",
8176 bgp_afi_safi_get_container_str(afi
, safi
));
8177 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8179 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
8181 return nb_cli_apply_changes(vty
, base_xpath
);
8184 /* Maximum number of prefix configuration. Prefix count is different
8185 for each peer configuration. So this configuration can be set for
8186 each peer configuration. */
8187 DEFUN_YANG(neighbor_maximum_prefix
,
8188 neighbor_maximum_prefix_cmd
,
8189 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8190 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8191 "Maximum number of prefix accept from this peer\n"
8192 "maximum no. of prefix limit\n"
8193 "Force checking all received routes not only accepted\n")
8198 char base_xpath
[XPATH_MAXLEN
];
8199 char af_xpath
[XPATH_MAXLEN
];
8200 char attr_xpath
[XPATH_MAXLEN
];
8201 afi_t afi
= bgp_node_afi(vty
);
8202 safi_t safi
= bgp_node_safi(vty
);
8204 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8205 yang_afi_safi_value2identity(afi
, safi
));
8206 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8207 sizeof(base_xpath
), af_xpath
)
8209 return CMD_WARNING_CONFIG_FAILED
;
8211 snprintf(attr_xpath
, sizeof(attr_xpath
),
8212 "/%s/prefix-limit/direction-list[direction='in']",
8213 bgp_afi_safi_get_container_str(afi
, safi
));
8214 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8216 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8218 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8219 argv
[idx_number
]->arg
);
8220 if (argv_find(argv
, argc
, "force", &idx_force
))
8221 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8224 return nb_cli_apply_changes(vty
, base_xpath
);
8227 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8228 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8229 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8230 "Maximum number of prefix accept from this peer\n"
8231 "maximum no. of prefix limit\n"
8232 "Force checking all received routes not only accepted\n")
8234 DEFUN_YANG(neighbor_maximum_prefix_threshold
,
8235 neighbor_maximum_prefix_threshold_cmd
,
8236 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8237 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8238 "Maximum number of prefix accept from this peer\n"
8239 "maximum no. of prefix limit\n"
8240 "Threshold value (%) at which to generate a warning msg\n"
8241 "Force checking all received routes not only accepted\n")
8245 int idx_number_2
= 4;
8247 char base_xpath
[XPATH_MAXLEN
];
8248 char af_xpath
[XPATH_MAXLEN
];
8249 char attr_xpath
[XPATH_MAXLEN
];
8250 afi_t afi
= bgp_node_afi(vty
);
8251 safi_t safi
= bgp_node_safi(vty
);
8253 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8254 yang_afi_safi_value2identity(afi
, safi
));
8255 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8256 sizeof(base_xpath
), af_xpath
)
8258 return CMD_WARNING_CONFIG_FAILED
;
8260 snprintf(attr_xpath
, sizeof(attr_xpath
),
8261 "/%s/prefix-limit/direction-list[direction='in']",
8262 bgp_afi_safi_get_container_str(afi
, safi
));
8263 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8265 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8267 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8268 argv
[idx_number
]->arg
);
8270 nb_cli_enqueue_change(vty
, "./options/shutdown-threshold-pct",
8271 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8273 if (argv_find(argv
, argc
, "force", &idx_force
))
8274 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8277 return nb_cli_apply_changes(vty
, base_xpath
);
8281 neighbor_maximum_prefix_threshold
,
8282 neighbor_maximum_prefix_threshold_hidden_cmd
,
8283 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8284 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8285 "Maximum number of prefix accept from this peer\n"
8286 "maximum no. of prefix limit\n"
8287 "Threshold value (%) at which to generate a warning msg\n"
8288 "Force checking all received routes not only accepted\n")
8290 DEFUN_YANG(neighbor_maximum_prefix_warning
,
8291 neighbor_maximum_prefix_warning_cmd
,
8292 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8293 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8294 "Maximum number of prefix accept from this peer\n"
8295 "maximum no. of prefix limit\n"
8296 "Only give warning message when limit is exceeded\n"
8297 "Force checking all received routes not only accepted\n")
8302 char base_xpath
[XPATH_MAXLEN
];
8303 char af_xpath
[XPATH_MAXLEN
];
8304 char attr_xpath
[XPATH_MAXLEN
];
8305 afi_t afi
= bgp_node_afi(vty
);
8306 safi_t safi
= bgp_node_safi(vty
);
8308 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8309 yang_afi_safi_value2identity(afi
, safi
));
8310 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8311 sizeof(base_xpath
), af_xpath
)
8313 return CMD_WARNING_CONFIG_FAILED
;
8315 snprintf(attr_xpath
, sizeof(attr_xpath
),
8316 "/%s/prefix-limit/direction-list[direction='in']",
8317 bgp_afi_safi_get_container_str(afi
, safi
));
8318 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8320 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8322 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8323 argv
[idx_number
]->arg
);
8325 nb_cli_enqueue_change(vty
, "./options/warning-only", NB_OP_MODIFY
,
8327 if (argv_find(argv
, argc
, "force", &idx_force
))
8328 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8331 return nb_cli_apply_changes(vty
, base_xpath
);
8335 neighbor_maximum_prefix_warning
,
8336 neighbor_maximum_prefix_warning_hidden_cmd
,
8337 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8338 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8339 "Maximum number of prefix accept from this peer\n"
8340 "maximum no. of prefix limit\n"
8341 "Only give warning message when limit is exceeded\n"
8342 "Force checking all received routes not only accepted\n")
8344 DEFUN_YANG(neighbor_maximum_prefix_threshold_warning
,
8345 neighbor_maximum_prefix_threshold_warning_cmd
,
8346 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8347 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8348 "Maximum number of prefix accept from this peer\n"
8349 "maximum no. of prefix limit\n"
8350 "Threshold value (%) at which to generate a warning msg\n"
8351 "Only give warning message when limit is exceeded\n"
8352 "Force checking all received routes not only accepted\n")
8356 int idx_number_2
= 4;
8358 char base_xpath
[XPATH_MAXLEN
];
8359 char af_xpath
[XPATH_MAXLEN
];
8360 char attr_xpath
[XPATH_MAXLEN
];
8361 afi_t afi
= bgp_node_afi(vty
);
8362 safi_t safi
= bgp_node_safi(vty
);
8364 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8365 yang_afi_safi_value2identity(afi
, safi
));
8366 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8367 sizeof(base_xpath
), af_xpath
)
8369 return CMD_WARNING_CONFIG_FAILED
;
8371 snprintf(attr_xpath
, sizeof(attr_xpath
),
8372 "/%s/prefix-limit/direction-list[direction='in']",
8373 bgp_afi_safi_get_container_str(afi
, safi
));
8374 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8376 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8378 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8379 argv
[idx_number
]->arg
);
8380 nb_cli_enqueue_change(vty
, "./options/tw-shutdown-threshold-pct",
8381 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8382 nb_cli_enqueue_change(vty
, "./options/tw-warning-only", NB_OP_MODIFY
,
8384 if (argv_find(argv
, argc
, "force", &idx_force
))
8385 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8388 return nb_cli_apply_changes(vty
, base_xpath
);
8392 neighbor_maximum_prefix_threshold_warning
,
8393 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8394 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8395 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8396 "Maximum number of prefix accept from this peer\n"
8397 "maximum no. of prefix limit\n"
8398 "Threshold value (%) at which to generate a warning msg\n"
8399 "Only give warning message when limit is exceeded\n"
8400 "Force checking all received routes not only accepted\n")
8402 DEFUN_YANG(neighbor_maximum_prefix_restart
,
8403 neighbor_maximum_prefix_restart_cmd
,
8404 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8405 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8406 "Maximum number of prefix accept from this peer\n"
8407 "maximum no. of prefix limit\n"
8408 "Restart bgp connection after limit is exceeded\n"
8409 "Restart interval in minutes\n"
8410 "Force checking all received routes not only accepted\n")
8414 int idx_number_2
= 5;
8416 char base_xpath
[XPATH_MAXLEN
];
8417 char af_xpath
[XPATH_MAXLEN
];
8418 char attr_xpath
[XPATH_MAXLEN
];
8419 afi_t afi
= bgp_node_afi(vty
);
8420 safi_t safi
= bgp_node_safi(vty
);
8422 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8423 yang_afi_safi_value2identity(afi
, safi
));
8424 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8425 sizeof(base_xpath
), af_xpath
)
8427 return CMD_WARNING_CONFIG_FAILED
;
8429 snprintf(attr_xpath
, sizeof(attr_xpath
),
8430 "/%s/prefix-limit/direction-list[direction='in']",
8431 bgp_afi_safi_get_container_str(afi
, safi
));
8432 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8434 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8436 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8437 argv
[idx_number
]->arg
);
8438 nb_cli_enqueue_change(vty
, "./options/restart-timer", NB_OP_MODIFY
,
8439 argv
[idx_number_2
]->arg
);
8440 if (argv_find(argv
, argc
, "force", &idx_force
))
8441 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8444 return nb_cli_apply_changes(vty
, base_xpath
);
8448 neighbor_maximum_prefix_restart
,
8449 neighbor_maximum_prefix_restart_hidden_cmd
,
8450 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8451 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8452 "Maximum number of prefix accept from this peer\n"
8453 "maximum no. of prefix limit\n"
8454 "Restart bgp connection after limit is exceeded\n"
8455 "Restart interval in minutes\n"
8456 "Force checking all received routes not only accepted\n")
8458 DEFUN_YANG(neighbor_maximum_prefix_threshold_restart
,
8459 neighbor_maximum_prefix_threshold_restart_cmd
,
8460 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8461 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8462 "Maximum number of prefixes to accept from this peer\n"
8463 "maximum no. of prefix limit\n"
8464 "Threshold value (%) at which to generate a warning msg\n"
8465 "Restart bgp connection after limit is exceeded\n"
8466 "Restart interval in minutes\n"
8467 "Force checking all received routes not only accepted\n")
8471 int idx_number_2
= 4;
8472 int idx_number_3
= 6;
8474 char base_xpath
[XPATH_MAXLEN
];
8475 char af_xpath
[XPATH_MAXLEN
];
8476 char attr_xpath
[XPATH_MAXLEN
];
8477 afi_t afi
= bgp_node_afi(vty
);
8478 safi_t safi
= bgp_node_safi(vty
);
8480 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8481 yang_afi_safi_value2identity(afi
, safi
));
8482 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8483 sizeof(base_xpath
), af_xpath
)
8485 return CMD_WARNING_CONFIG_FAILED
;
8487 snprintf(attr_xpath
, sizeof(attr_xpath
),
8488 "/%s/prefix-limit/direction-list[direction='in']",
8489 bgp_afi_safi_get_container_str(afi
, safi
));
8490 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8492 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8494 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8495 argv
[idx_number
]->arg
);
8496 nb_cli_enqueue_change(vty
, "./options/tr-shutdown-threshold-pct",
8497 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8498 nb_cli_enqueue_change(vty
, "./options/tr-restart-timer", NB_OP_MODIFY
,
8499 argv
[idx_number_3
]->arg
);
8500 if (argv_find(argv
, argc
, "force", &idx_force
))
8501 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8504 return nb_cli_apply_changes(vty
, base_xpath
);
8508 neighbor_maximum_prefix_threshold_restart
,
8509 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8510 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8511 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8512 "Maximum number of prefixes to accept from this peer\n"
8513 "maximum no. of prefix limit\n"
8514 "Threshold value (%) at which to generate a warning msg\n"
8515 "Restart bgp connection after limit is exceeded\n"
8516 "Restart interval in minutes\n"
8517 "Force checking all received routes not only accepted\n")
8519 DEFUN_YANG(no_neighbor_maximum_prefix
,
8520 no_neighbor_maximum_prefix_cmd
,
8521 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8522 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8523 "Maximum number of prefixes to accept from this peer\n"
8524 "maximum no. of prefix limit\n"
8525 "Threshold value (%) at which to generate a warning msg\n"
8526 "Restart bgp connection after limit is exceeded\n"
8527 "Restart interval in minutes\n"
8528 "Only give warning message when limit is exceeded\n"
8529 "Force checking all received routes not only accepted\n")
8532 char base_xpath
[XPATH_MAXLEN
];
8533 char af_xpath
[XPATH_MAXLEN
];
8534 char attr_xpath
[XPATH_MAXLEN
];
8535 afi_t afi
= bgp_node_afi(vty
);
8536 safi_t safi
= bgp_node_safi(vty
);
8538 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8539 yang_afi_safi_value2identity(afi
, safi
));
8540 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8541 sizeof(base_xpath
), af_xpath
)
8543 return CMD_WARNING_CONFIG_FAILED
;
8545 snprintf(attr_xpath
, sizeof(attr_xpath
),
8546 "/%s/prefix-limit/direction-list[direction='in']",
8547 bgp_afi_safi_get_container_str(afi
, safi
));
8548 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8550 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
8552 return nb_cli_apply_changes(vty
, base_xpath
);
8556 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8557 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8558 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8559 "Maximum number of prefixes to accept from this peer\n"
8560 "maximum no. of prefix limit\n"
8561 "Threshold value (%) at which to generate a warning msg\n"
8562 "Restart bgp connection after limit is exceeded\n"
8563 "Restart interval in minutes\n"
8564 "Only give warning message when limit is exceeded\n"
8565 "Force checking all received routes not only accepted\n")
8568 /* "neighbor allowas-in" */
8569 DEFUN (neighbor_allowas_in
,
8570 neighbor_allowas_in_cmd
,
8571 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8574 "Accept as-path with my AS present in it\n"
8575 "Number of occurrences of AS number\n"
8576 "Only accept my AS in the as-path if the route was originated in my AS\n")
8579 int idx_number_origin
= 3;
8585 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8587 return CMD_WARNING_CONFIG_FAILED
;
8589 if (argc
<= idx_number_origin
)
8592 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8595 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8598 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8601 return bgp_vty_return(vty
, ret
);
8605 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8606 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8607 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8608 "Accept as-path with my AS present in it\n"
8609 "Number of occurrences of AS number\n"
8610 "Only accept my AS in the as-path if the route was originated in my AS\n")
8612 DEFUN (no_neighbor_allowas_in
,
8613 no_neighbor_allowas_in_cmd
,
8614 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8618 "allow local ASN appears in aspath attribute\n"
8619 "Number of occurrences of AS number\n"
8620 "Only accept my AS in the as-path if the route was originated in my AS\n")
8626 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8628 return CMD_WARNING_CONFIG_FAILED
;
8630 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8631 bgp_node_safi(vty
));
8633 return bgp_vty_return(vty
, ret
);
8637 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8638 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8639 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8640 "allow local ASN appears in aspath attribute\n"
8641 "Number of occurrences of AS number\n"
8642 "Only accept my AS in the as-path if the route was originated in my AS\n")
8644 DEFUN_YANG (neighbor_ttl_security
,
8645 neighbor_ttl_security_cmd
,
8646 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8649 "BGP ttl-security parameters\n"
8650 "Specify the maximum number of hops to the BGP peer\n"
8651 "Number of hops to BGP peer\n")
8655 char base_xpath
[XPATH_MAXLEN
];
8657 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8658 sizeof(base_xpath
), NULL
)
8660 return CMD_WARNING_CONFIG_FAILED
;
8662 nb_cli_enqueue_change(vty
, "./ttl-security", NB_OP_MODIFY
,
8663 argv
[idx_number
]->arg
);
8665 return nb_cli_apply_changes(vty
, base_xpath
);
8668 DEFUN_YANG(no_neighbor_ttl_security
,
8669 no_neighbor_ttl_security_cmd
,
8670 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8671 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8672 "BGP ttl-security parameters\n"
8673 "Specify the maximum number of hops to the BGP peer\n"
8674 "Number of hops to BGP peer\n")
8677 char base_xpath
[XPATH_MAXLEN
];
8679 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8680 sizeof(base_xpath
), NULL
)
8682 return CMD_WARNING_CONFIG_FAILED
;
8684 nb_cli_enqueue_change(vty
, "./ttl-security", NB_OP_DESTROY
, NULL
);
8686 return nb_cli_apply_changes(vty
, base_xpath
);
8689 DEFUN (neighbor_addpath_tx_all_paths
,
8690 neighbor_addpath_tx_all_paths_cmd
,
8691 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8694 "Use addpath to advertise all paths to a neighbor\n")
8699 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8701 return CMD_WARNING_CONFIG_FAILED
;
8703 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8708 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8709 neighbor_addpath_tx_all_paths_hidden_cmd
,
8710 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8711 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8712 "Use addpath to advertise all paths to a neighbor\n")
8714 DEFUN (no_neighbor_addpath_tx_all_paths
,
8715 no_neighbor_addpath_tx_all_paths_cmd
,
8716 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8720 "Use addpath to advertise all paths to a neighbor\n")
8725 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8727 return CMD_WARNING_CONFIG_FAILED
;
8729 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8730 != BGP_ADDPATH_ALL
) {
8732 "%% Peer not currently configured to transmit all paths.");
8733 return CMD_WARNING_CONFIG_FAILED
;
8736 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8742 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8743 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8744 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8745 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8746 "Use addpath to advertise all paths to a neighbor\n")
8748 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8749 neighbor_addpath_tx_bestpath_per_as_cmd
,
8750 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8753 "Use addpath to advertise the bestpath per each neighboring AS\n")
8758 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8760 return CMD_WARNING_CONFIG_FAILED
;
8762 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8763 BGP_ADDPATH_BEST_PER_AS
);
8768 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8769 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8770 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8771 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8772 "Use addpath to advertise the bestpath per each neighboring AS\n")
8774 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8775 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8776 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8780 "Use addpath to advertise the bestpath per each neighboring AS\n")
8785 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8787 return CMD_WARNING_CONFIG_FAILED
;
8789 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8790 != BGP_ADDPATH_BEST_PER_AS
) {
8792 "%% Peer not currently configured to transmit all best path per as.");
8793 return CMD_WARNING_CONFIG_FAILED
;
8796 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8802 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8803 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8804 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8805 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8806 "Use addpath to advertise the bestpath per each neighboring AS\n")
8809 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8810 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8813 "Detect AS loops before sending to neighbor\n")
8817 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8819 return CMD_WARNING_CONFIG_FAILED
;
8821 peer
->as_path_loop_detection
= true;
8827 no_neighbor_aspath_loop_detection
,
8828 no_neighbor_aspath_loop_detection_cmd
,
8829 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8833 "Detect AS loops before sending to neighbor\n")
8837 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8839 return CMD_WARNING_CONFIG_FAILED
;
8841 peer
->as_path_loop_detection
= false;
8846 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8847 struct ecommunity
**list
, bool is_rt6
)
8849 struct ecommunity
*ecom
= NULL
;
8850 struct ecommunity
*ecomadd
;
8852 for (; argc
; --argc
, ++argv
) {
8854 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8855 ECOMMUNITY_ROUTE_TARGET
,
8858 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8859 ECOMMUNITY_ROUTE_TARGET
,
8862 vty_out(vty
, "Malformed community-list value\n");
8864 ecommunity_free(&ecom
);
8865 return CMD_WARNING_CONFIG_FAILED
;
8869 ecommunity_merge(ecom
, ecomadd
);
8870 ecommunity_free(&ecomadd
);
8877 ecommunity_free(&*list
);
8884 bool vpn_policy_check_import(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
8885 bool v2vimport
, char *errmsg
, size_t errmsg_len
)
8888 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8889 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8890 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8891 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8893 errmsg
, errmsg_len
, "%s",
8894 "%% error: Please unconfigure import vrf commands before using vpn commands");
8898 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8899 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8900 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8901 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8903 errmsg
, errmsg_len
, "%s",
8904 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands");
8912 * v2vimport is true if we are handling a `import vrf ...` command
8914 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
8918 switch (vty
->node
) {
8927 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
8932 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8933 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8934 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8935 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8937 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
8941 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8942 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8943 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8944 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8946 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
8955 af_rd_vpn_export_cmd
,
8956 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
8958 "Specify route distinguisher\n"
8959 "Between current address-family and vpn\n"
8960 "For routes leaked from current address-family to vpn\n"
8961 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
8963 char base_xpath
[XPATH_MAXLEN
];
8968 afi
= bgp_node_afi(vty
);
8969 safi
= bgp_node_safi(vty
);
8972 base_xpath
, sizeof(base_xpath
),
8973 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
8974 yang_afi_safi_value2identity(afi
, safi
),
8975 bgp_afi_safi_get_container_str(afi
, safi
));
8977 if (argv_find(argv
, argc
, "no", &idx
))
8978 nb_cli_enqueue_change(vty
, "./rd", NB_OP_DESTROY
, NULL
);
8980 nb_cli_enqueue_change(vty
, "./rd", NB_OP_MODIFY
, rd_str
);
8982 return nb_cli_apply_changes(vty
, base_xpath
);
8985 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rd(
8986 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
8990 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
8991 yang_dnode_get_string(dnode
, NULL
));
8994 ALIAS (af_rd_vpn_export
,
8995 af_no_rd_vpn_export_cmd
,
8998 "Specify route distinguisher\n"
8999 "Between current address-family and vpn\n"
9000 "For routes leaked from current address-family to vpn\n")
9002 DEFPY (af_label_vpn_export
,
9003 af_label_vpn_export_cmd
,
9004 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
9006 "label value for VRF\n"
9007 "Between current address-family and vpn\n"
9008 "For routes leaked from current address-family to vpn\n"
9009 "Label Value <0-1048575>\n"
9010 "Automatically assign a label\n")
9012 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9013 mpls_label_t label
= MPLS_LABEL_NONE
;
9018 if (argv_find(argv
, argc
, "no", &idx
))
9021 /* If "no ...", squash trailing parameter */
9027 label
= label_val
; /* parser should force unsigned */
9030 afi
= vpn_policy_getafi(vty
, bgp
, false);
9032 return CMD_WARNING_CONFIG_FAILED
;
9035 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9036 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
9041 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9043 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9044 bgp_get_default(), bgp
);
9046 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9047 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
9049 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
9052 * label has previously been automatically
9053 * assigned by labelpool: release it
9055 * NB if tovpn_label == MPLS_LABEL_NONE it
9056 * means the automatic assignment is in flight
9057 * and therefore the labelpool callback must
9058 * detect that the auto label is not needed.
9061 bgp_lp_release(LP_TYPE_VRF
,
9062 &bgp
->vpn_policy
[afi
],
9063 bgp
->vpn_policy
[afi
].tovpn_label
);
9065 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9066 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9069 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
9071 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9072 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9073 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
9074 vpn_leak_label_callback
);
9077 /* post-change: re-export vpn routes */
9078 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9079 bgp_get_default(), bgp
);
9084 ALIAS (af_label_vpn_export
,
9085 af_no_label_vpn_export_cmd
,
9086 "no label vpn export",
9088 "label value for VRF\n"
9089 "Between current address-family and vpn\n"
9090 "For routes leaked from current address-family to vpn\n")
9092 DEFPY_YANG (af_nexthop_vpn_export
,
9093 af_nexthop_vpn_export_cmd
,
9094 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
9096 "Specify next hop to use for VRF advertised prefixes\n"
9097 "Between current address-family and vpn\n"
9098 "For routes leaked from current address-family to vpn\n"
9102 char base_xpath
[XPATH_MAXLEN
];
9110 vty_out(vty
, "%% Nexthop required\n");
9111 return CMD_WARNING_CONFIG_FAILED
;
9113 if (!sockunion2hostprefix(nexthop_su
, &p
))
9114 return CMD_WARNING_CONFIG_FAILED
;
9117 afi
= bgp_node_afi(vty
);
9118 safi
= bgp_node_safi(vty
);
9121 base_xpath
, sizeof(base_xpath
),
9122 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9123 yang_afi_safi_value2identity(afi
, safi
),
9124 bgp_afi_safi_get_container_str(afi
, safi
));
9126 if (argv_find(argv
, argc
, "no", &idx
))
9127 nb_cli_enqueue_change(vty
, "./nexthop", NB_OP_DESTROY
, NULL
);
9129 nb_cli_enqueue_change(vty
, "./nexthop", NB_OP_MODIFY
,
9132 return nb_cli_apply_changes(vty
, base_xpath
);
9135 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_nexthop(
9136 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9140 vty_out(vty
, "%*snexthop vpn export %s\n", indent
, "",
9141 yang_dnode_get_string(dnode
, NULL
));
9144 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9146 if (!strcmp(dstr
, "import")) {
9147 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9148 } else if (!strcmp(dstr
, "export")) {
9149 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9150 } else if (!strcmp(dstr
, "both")) {
9151 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9152 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9154 vty_out(vty
, "%% direction parse error\n");
9155 return CMD_WARNING_CONFIG_FAILED
;
9160 DEFPY (af_rt_vpn_imexport
,
9161 af_rt_vpn_imexport_cmd
,
9162 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9164 "Specify route target list\n"
9165 "Specify route target list\n"
9166 "Between current address-family and vpn\n"
9167 "For routes leaked from vpn to current address-family: match any\n"
9168 "For routes leaked from current address-family to vpn: set\n"
9169 "both import: match any and export: set\n"
9170 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9172 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9174 struct ecommunity
*ecom
= NULL
;
9175 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9176 vpn_policy_direction_t dir
;
9181 if (argv_find(argv
, argc
, "no", &idx
))
9184 afi
= vpn_policy_getafi(vty
, bgp
, false);
9186 return CMD_WARNING_CONFIG_FAILED
;
9188 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9189 if (ret
!= CMD_SUCCESS
)
9193 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9194 vty_out(vty
, "%% Missing RTLIST\n");
9195 return CMD_WARNING_CONFIG_FAILED
;
9197 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9198 if (ret
!= CMD_SUCCESS
) {
9203 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9207 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9210 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9212 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9213 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9214 ecommunity_dup(ecom
);
9216 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9218 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9219 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9222 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9226 ecommunity_free(&ecom
);
9231 ALIAS (af_rt_vpn_imexport
,
9232 af_no_rt_vpn_imexport_cmd
,
9233 "no <rt|route-target> vpn <import|export|both>$direction_str",
9235 "Specify route target list\n"
9236 "Specify route target list\n"
9237 "Between current address-family and vpn\n"
9238 "For routes leaked from vpn to current address-family\n"
9239 "For routes leaked from current address-family to vpn\n"
9240 "both import and export\n")
9242 DEFPY_YANG (af_route_map_vpn_imexport
,
9243 af_route_map_vpn_imexport_cmd
,
9244 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9245 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9247 "Specify route map\n"
9248 "Between current address-family and vpn\n"
9249 "For routes leaked from vpn to current address-family\n"
9250 "For routes leaked from current address-family to vpn\n"
9251 "name of route-map\n")
9253 char base_xpath
[XPATH_MAXLEN
];
9258 afi
= bgp_node_afi(vty
);
9259 safi
= bgp_node_safi(vty
);
9262 base_xpath
, sizeof(base_xpath
),
9263 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9264 yang_afi_safi_value2identity(afi
, safi
),
9265 bgp_afi_safi_get_container_str(afi
, safi
));
9267 if (argv_find(argv
, argc
, "no", &idx
)) {
9268 if (!strcmp(direction_str
, "import"))
9269 nb_cli_enqueue_change(vty
, "./rmap-import",
9270 NB_OP_DESTROY
, NULL
);
9271 else if (!strcmp(direction_str
, "export"))
9272 nb_cli_enqueue_change(vty
, "./rmap-export",
9273 NB_OP_DESTROY
, NULL
);
9275 if (!strcmp(direction_str
, "import"))
9276 nb_cli_enqueue_change(vty
, "./rmap-import",
9277 NB_OP_MODIFY
, rmap_str
);
9278 if (!strcmp(direction_str
, "export"))
9279 nb_cli_enqueue_change(vty
, "./rmap-export",
9280 NB_OP_MODIFY
, rmap_str
);
9282 return nb_cli_apply_changes(vty
, base_xpath
);
9285 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_import(
9286 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9290 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
9291 yang_dnode_get_string(dnode
, NULL
));
9294 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_export(
9295 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9299 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
9300 yang_dnode_get_string(dnode
, NULL
));
9303 ALIAS (af_route_map_vpn_imexport
,
9304 af_no_route_map_vpn_imexport_cmd
,
9305 "no route-map vpn <import|export>$direction_str",
9307 "Specify route map\n"
9308 "Between current address-family and vpn\n"
9309 "For routes leaked from vpn to current address-family\n"
9310 "For routes leaked from current address-family to vpn\n")
9312 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9313 "import vrf route-map RMAP$rmap_str",
9314 "Import routes from another VRF\n"
9315 "Vrf routes being filtered\n"
9316 "Specify route map\n"
9317 "name of route-map\n")
9319 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9320 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9322 struct bgp
*bgp_default
;
9324 afi
= vpn_policy_getafi(vty
, bgp
, true);
9326 return CMD_WARNING_CONFIG_FAILED
;
9328 bgp_default
= bgp_get_default();
9333 /* Auto-create assuming the same AS */
9334 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9335 BGP_INSTANCE_TYPE_DEFAULT
);
9339 "VRF default is not configured as a bgp instance\n");
9344 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9346 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9347 XFREE(MTYPE_ROUTE_MAP_NAME
,
9348 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9349 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9350 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9351 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9352 route_map_lookup_warn_noexist(vty
, rmap_str
);
9353 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9356 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9357 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9359 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9364 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9365 "no import vrf route-map [RMAP$rmap_str]",
9367 "Import routes from another VRF\n"
9368 "Vrf routes being filtered\n"
9369 "Specify route map\n"
9370 "name of route-map\n")
9372 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9373 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9376 afi
= vpn_policy_getafi(vty
, bgp
, true);
9378 return CMD_WARNING_CONFIG_FAILED
;
9380 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9382 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9383 XFREE(MTYPE_ROUTE_MAP_NAME
,
9384 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9385 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9386 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9388 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9389 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9390 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9392 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9397 DEFPY_YANG(bgp_imexport_vrf
,
9398 bgp_imexport_vrf_cmd
,
9399 "[no] import vrf VIEWVRFNAME$import_name",
9401 "Import routes from another VRF\n"
9402 "VRF to import from\n"
9403 "The name of the VRF\n")
9405 char base_xpath
[XPATH_MAXLEN
];
9410 if (import_name
== NULL
) {
9411 vty_out(vty
, "%% Missing import name\n");
9415 if (strcmp(import_name
, "route-map") == 0) {
9416 vty_out(vty
, "%% Must include route-map name\n");
9420 afi
= bgp_node_afi(vty
);
9421 safi
= bgp_node_safi(vty
);
9424 base_xpath
, sizeof(base_xpath
),
9425 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vrf-list[vrf='%s']",
9426 yang_afi_safi_value2identity(afi
, safi
),
9427 bgp_afi_safi_get_container_str(afi
, safi
), import_name
);
9429 if (argv_find(argv
, argc
, "no", &idx
))
9430 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
9432 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
9434 return nb_cli_apply_changes(vty
, base_xpath
);
9437 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vrfs(
9438 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9440 vty_out(vty
, " import vrf %s\n",
9441 yang_dnode_get_string(dnode
, "./vrf"));
9444 /* This command is valid only in a bgp vrf instance or the default instance */
9445 DEFPY_YANG (bgp_imexport_vpn
,
9446 bgp_imexport_vpn_cmd
,
9447 "[no] <import|export>$direction_str vpn",
9449 "Import routes to this address-family\n"
9450 "Export routes from this address-family\n"
9451 "to/from default instance VPN RIB\n")
9453 char base_xpath
[XPATH_MAXLEN
];
9458 afi
= bgp_node_afi(vty
);
9459 safi
= bgp_node_safi(vty
);
9461 if (!strcmp(direction_str
, "import")) {
9463 base_xpath
, sizeof(base_xpath
),
9464 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vpn",
9465 yang_afi_safi_value2identity(afi
, safi
),
9466 bgp_afi_safi_get_container_str(afi
, safi
));
9467 } else if (!strcmp(direction_str
, "export")) {
9469 base_xpath
, sizeof(base_xpath
),
9470 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/export-vpn",
9471 yang_afi_safi_value2identity(afi
, safi
),
9472 bgp_afi_safi_get_container_str(afi
, safi
));
9474 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9475 return CMD_WARNING_CONFIG_FAILED
;
9478 if (argv_find(argv
, argc
, "no", &idx
))
9479 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
9481 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, "true");
9483 return nb_cli_apply_changes(vty
, base_xpath
);
9486 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vpn(
9487 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9489 if (yang_dnode_get_bool(dnode
, NULL
))
9490 vty_out(vty
, " import vpn\n");
9493 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_export_vpn(
9494 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9496 if (yang_dnode_get_bool(dnode
, NULL
))
9497 vty_out(vty
, " export vpn\n");
9500 DEFPY (af_routetarget_import
,
9501 af_routetarget_import_cmd
,
9502 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9504 "Specify route target list\n"
9505 "Specify route target list\n"
9506 "Specify route target list\n"
9507 "Specify route target list\n"
9508 "Flow-spec redirect type route target\n"
9509 "Import routes to this address-family\n"
9510 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9512 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9514 struct ecommunity
*ecom
= NULL
;
9516 int idx
= 0, idx_unused
= 0;
9520 if (argv_find(argv
, argc
, "no", &idx
))
9523 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9524 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9527 afi
= vpn_policy_getafi(vty
, bgp
, false);
9529 return CMD_WARNING_CONFIG_FAILED
;
9531 if (rt6
&& afi
!= AFI_IP6
)
9532 return CMD_WARNING_CONFIG_FAILED
;
9535 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9536 vty_out(vty
, "%% Missing RTLIST\n");
9537 return CMD_WARNING_CONFIG_FAILED
;
9539 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9540 if (ret
!= CMD_SUCCESS
)
9545 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9546 ecommunity_free(&bgp
->vpn_policy
[afi
]
9547 .import_redirect_rtlist
);
9548 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9549 ecommunity_dup(ecom
);
9551 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9552 ecommunity_free(&bgp
->vpn_policy
[afi
]
9553 .import_redirect_rtlist
);
9554 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9558 ecommunity_free(&ecom
);
9563 void cli_show_bgp_global_afi_safi_header(struct vty
*vty
,
9564 struct lyd_node
*dnode
,
9567 const char *af_name
;
9571 af_name
= yang_dnode_get_string(dnode
, "./afi-safi-name");
9572 yang_afi_safi_identity2value(af_name
, &afi
, &safi
);
9574 vty_out(vty
, " !\n address-family ");
9575 if (afi
== AFI_IP
) {
9576 if (safi
== SAFI_UNICAST
)
9577 vty_out(vty
, "ipv4 unicast");
9578 else if (safi
== SAFI_LABELED_UNICAST
)
9579 vty_out(vty
, "ipv4 labeled-unicast");
9580 else if (safi
== SAFI_MULTICAST
)
9581 vty_out(vty
, "ipv4 multicast");
9582 else if (safi
== SAFI_MPLS_VPN
)
9583 vty_out(vty
, "ipv4 vpn");
9584 else if (safi
== SAFI_ENCAP
)
9585 vty_out(vty
, "ipv4 encap");
9586 else if (safi
== SAFI_FLOWSPEC
)
9587 vty_out(vty
, "ipv4 flowspec");
9588 } else if (afi
== AFI_IP6
) {
9589 if (safi
== SAFI_UNICAST
)
9590 vty_out(vty
, "ipv6 unicast");
9591 else if (safi
== SAFI_LABELED_UNICAST
)
9592 vty_out(vty
, "ipv6 labeled-unicast");
9593 else if (safi
== SAFI_MULTICAST
)
9594 vty_out(vty
, "ipv6 multicast");
9595 else if (safi
== SAFI_MPLS_VPN
)
9596 vty_out(vty
, "ipv6 vpn");
9597 else if (safi
== SAFI_ENCAP
)
9598 vty_out(vty
, "ipv6 encap");
9599 else if (safi
== SAFI_FLOWSPEC
)
9600 vty_out(vty
, "ipv6 flowspec");
9601 } else if (afi
== AFI_L2VPN
) {
9602 if (safi
== SAFI_EVPN
)
9603 vty_out(vty
, "l2vpn evpn");
9608 DEFUN_NOSH (address_family_ipv4_safi
,
9609 address_family_ipv4_safi_cmd
,
9610 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9611 "Enter Address Family command mode\n"
9613 BGP_SAFI_WITH_LABEL_HELP_STR
)
9616 safi_t safi
= SAFI_UNICAST
;
9617 const struct lyd_node
*vrf_dnode
, *bgp_glb_dnode
;
9618 const char *vrf_name
= NULL
;
9621 safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9623 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
9625 vrf_dnode
= yang_dnode_get_parent(bgp_glb_dnode
,
9626 "control-plane-protocol");
9627 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
9629 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
)
9630 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9631 && safi
!= SAFI_EVPN
) {
9633 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9634 return CMD_WARNING_CONFIG_FAILED
;
9637 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9642 DEFUN_NOSH (address_family_ipv6_safi
,
9643 address_family_ipv6_safi_cmd
,
9644 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9645 "Enter Address Family command mode\n"
9647 BGP_SAFI_WITH_LABEL_HELP_STR
)
9649 safi_t safi
= SAFI_UNICAST
;
9650 const struct lyd_node
*vrf_dnode
, *bgp_glb_dnode
;
9651 const char *vrf_name
= NULL
;
9654 safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9655 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
9657 vrf_dnode
= yang_dnode_get_parent(bgp_glb_dnode
,
9658 "control-plane-protocol");
9659 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
9661 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
)
9662 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9663 && safi
!= SAFI_EVPN
) {
9665 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9666 return CMD_WARNING_CONFIG_FAILED
;
9669 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9674 #ifdef KEEP_OLD_VPN_COMMANDS
9675 DEFUN_NOSH (address_family_vpnv4
,
9676 address_family_vpnv4_cmd
,
9677 "address-family vpnv4 [unicast]",
9678 "Enter Address Family command mode\n"
9680 "Address Family modifier\n")
9682 vty
->node
= BGP_VPNV4_NODE
;
9686 DEFUN_NOSH (address_family_vpnv6
,
9687 address_family_vpnv6_cmd
,
9688 "address-family vpnv6 [unicast]",
9689 "Enter Address Family command mode\n"
9691 "Address Family modifier\n")
9693 vty
->node
= BGP_VPNV6_NODE
;
9696 #endif /* KEEP_OLD_VPN_COMMANDS */
9698 DEFUN_NOSH (address_family_evpn
,
9699 address_family_evpn_cmd
,
9700 "address-family l2vpn evpn",
9701 "Enter Address Family command mode\n"
9703 "Address Family modifier\n")
9705 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9706 vty
->node
= BGP_EVPN_NODE
;
9710 DEFUN_NOSH (exit_address_family
,
9711 exit_address_family_cmd
,
9712 "exit-address-family",
9713 "Exit from Address Family configuration mode\n")
9715 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9716 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9717 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9718 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9719 || vty
->node
== BGP_EVPN_NODE
9720 || vty
->node
== BGP_FLOWSPECV4_NODE
9721 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9722 vty
->node
= BGP_NODE
;
9726 void cli_show_bgp_global_afi_safi_header_end(struct vty
*vty
,
9727 struct lyd_node
*dnode
9728 __attribute__((__unused__
)))
9730 vty_out(vty
, " exit-address-family\n");
9733 /* Recalculate bestpath and re-advertise a prefix */
9734 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9735 const char *ip_str
, afi_t afi
, safi_t safi
,
9736 struct prefix_rd
*prd
)
9739 struct prefix match
;
9740 struct bgp_dest
*dest
;
9741 struct bgp_dest
*rm
;
9743 struct bgp_table
*table
;
9744 struct bgp_table
*rib
;
9746 /* BGP structure lookup. */
9748 bgp
= bgp_lookup_by_name(view_name
);
9750 vty_out(vty
, "%% Can't find BGP instance %s\n",
9755 bgp
= bgp_get_default();
9757 vty_out(vty
, "%% No BGP process is configured\n");
9762 /* Check IP address argument. */
9763 ret
= str2prefix(ip_str
, &match
);
9765 vty_out(vty
, "%% address is malformed\n");
9769 match
.family
= afi2family(afi
);
9770 rib
= bgp
->rib
[afi
][safi
];
9772 if (safi
== SAFI_MPLS_VPN
) {
9773 for (dest
= bgp_table_top(rib
); dest
;
9774 dest
= bgp_route_next(dest
)) {
9775 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9777 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9780 table
= bgp_dest_get_bgp_table_info(dest
);
9784 if ((rm
= bgp_node_match(table
, &match
)) != NULL
) {
9785 const struct prefix
*rm_p
=
9786 bgp_dest_get_prefix(rm
);
9788 if (rm_p
->prefixlen
== match
.prefixlen
) {
9790 BGP_NODE_USER_CLEAR
);
9791 bgp_process(bgp
, rm
, afi
, safi
);
9793 bgp_dest_unlock_node(rm
);
9797 if ((dest
= bgp_node_match(rib
, &match
)) != NULL
) {
9798 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9800 if (dest_p
->prefixlen
== match
.prefixlen
) {
9801 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9802 bgp_process(bgp
, dest
, afi
, safi
);
9804 bgp_dest_unlock_node(dest
);
9811 /* one clear bgp command to rule them all */
9812 DEFUN (clear_ip_bgp_all
,
9813 clear_ip_bgp_all_cmd
,
9814 "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>]",
9818 BGP_INSTANCE_HELP_STR
9821 BGP_SAFI_WITH_LABEL_HELP_STR
9822 "Address Family modifier\n"
9824 "BGP IPv4 neighbor to clear\n"
9825 "BGP IPv6 neighbor to clear\n"
9826 "BGP neighbor on interface to clear\n"
9827 "Clear peers with the AS number\n"
9828 "Clear all external peers\n"
9829 "Clear all members of peer-group\n"
9830 "BGP peer-group name\n"
9835 "Push out prefix-list ORF and do inbound soft reconfig\n"
9840 afi_t afi
= AFI_UNSPEC
;
9841 safi_t safi
= SAFI_UNSPEC
;
9842 enum clear_sort clr_sort
= clear_peer
;
9843 enum bgp_clear_type clr_type
;
9844 char *clr_arg
= NULL
;
9847 char errmsg
[BUFSIZ
] = {'\0'};
9850 /* clear [ip] bgp */
9851 if (argv_find(argv
, argc
, "ip", &idx
))
9854 /* [<vrf> VIEWVRFNAME] */
9855 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9856 vrf
= argv
[idx
+ 1]->arg
;
9858 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9860 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9861 /* [<view> VIEWVRFNAME] */
9862 vrf
= argv
[idx
+ 1]->arg
;
9865 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9866 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
9867 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
9869 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
9870 if (argv_find(argv
, argc
, "*", &idx
)) {
9871 clr_sort
= clear_all
;
9872 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
9873 clr_sort
= clear_peer
;
9874 clr_arg
= argv
[idx
]->arg
;
9875 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
9876 clr_sort
= clear_peer
;
9877 clr_arg
= argv
[idx
]->arg
;
9878 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
9879 clr_sort
= clear_group
;
9881 clr_arg
= argv
[idx
]->arg
;
9882 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
9883 clr_sort
= clear_peer
;
9884 clr_arg
= argv
[idx
]->arg
;
9885 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
9886 clr_sort
= clear_peer
;
9887 clr_arg
= argv
[idx
]->arg
;
9888 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
9889 clr_sort
= clear_as
;
9890 clr_arg
= argv
[idx
]->arg
;
9891 } else if (argv_find(argv
, argc
, "external", &idx
)) {
9892 clr_sort
= clear_external
;
9895 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
9896 if (argv_find(argv
, argc
, "soft", &idx
)) {
9897 if (argv_find(argv
, argc
, "in", &idx
)
9898 || argv_find(argv
, argc
, "out", &idx
))
9899 clr_type
= strmatch(argv
[idx
]->text
, "in")
9901 : BGP_CLEAR_SOFT_OUT
;
9903 clr_type
= BGP_CLEAR_SOFT_BOTH
;
9904 } else if (argv_find(argv
, argc
, "in", &idx
)) {
9905 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
9906 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
9907 : BGP_CLEAR_SOFT_IN
;
9908 } else if (argv_find(argv
, argc
, "out", &idx
)) {
9909 clr_type
= BGP_CLEAR_SOFT_OUT
;
9911 clr_type
= BGP_CLEAR_SOFT_NONE
;
9913 ret
= bgp_clear_vty(vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
, errmsg
,
9916 vty_out(vty
, "Error description: %s\n", errmsg
);
9921 DEFUN (clear_ip_bgp_prefix
,
9922 clear_ip_bgp_prefix_cmd
,
9923 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
9927 BGP_INSTANCE_HELP_STR
9928 "Clear bestpath and re-advertise\n"
9932 char *prefix
= NULL
;
9936 /* [<view|vrf> VIEWVRFNAME] */
9937 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9938 vrf
= argv
[idx
+ 1]->arg
;
9940 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9942 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9943 /* [<view> VIEWVRFNAME] */
9944 vrf
= argv
[idx
+ 1]->arg
;
9948 prefix
= argv
[argc
- 1]->arg
;
9950 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
9953 DEFUN (clear_bgp_ipv6_safi_prefix
,
9954 clear_bgp_ipv6_safi_prefix_cmd
,
9955 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9961 "Clear bestpath and re-advertise\n"
9965 int idx_ipv6_prefix
= 0;
9966 safi_t safi
= SAFI_UNICAST
;
9967 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9968 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9970 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
9971 return bgp_clear_prefix(
9972 vty
, NULL
, prefix
, AFI_IP6
,
9976 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
9977 clear_bgp_instance_ipv6_safi_prefix_cmd
,
9978 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
9982 BGP_INSTANCE_HELP_STR
9985 "Clear bestpath and re-advertise\n"
9989 int idx_vrfview
= 0;
9990 int idx_ipv6_prefix
= 0;
9991 safi_t safi
= SAFI_UNICAST
;
9992 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
9993 argv
[idx_ipv6_prefix
]->arg
: NULL
;
9994 char *vrfview
= NULL
;
9996 /* [<view|vrf> VIEWVRFNAME] */
9997 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
9998 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
9999 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
10001 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
10002 /* [<view> VIEWVRFNAME] */
10003 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10005 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10007 return bgp_clear_prefix(
10008 vty
, vrfview
, prefix
,
10009 AFI_IP6
, safi
, NULL
);
10012 DEFUN (show_bgp_views
,
10013 show_bgp_views_cmd
,
10014 "show [ip] bgp views",
10018 "Show the defined BGP views\n")
10020 struct list
*inst
= bm
->bgp
;
10021 struct listnode
*node
;
10024 vty_out(vty
, "Defined BGP views:\n");
10025 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10027 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10029 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
10033 return CMD_SUCCESS
;
10036 DEFUN (show_bgp_vrfs
,
10038 "show [ip] bgp vrfs [json]",
10045 char buf
[ETHER_ADDR_STRLEN
];
10046 struct list
*inst
= bm
->bgp
;
10047 struct listnode
*node
;
10049 bool uj
= use_json(argc
, argv
);
10050 json_object
*json
= NULL
;
10051 json_object
*json_vrfs
= NULL
;
10055 json
= json_object_new_object();
10056 json_vrfs
= json_object_new_object();
10059 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10060 const char *name
, *type
;
10062 struct listnode
*node2
, *nnode2
;
10063 int peers_cfg
, peers_estb
;
10064 json_object
*json_vrf
= NULL
;
10067 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10071 if (!uj
&& count
== 1) {
10073 "%4s %-5s %-16s %9s %10s %-37s\n",
10074 "Type", "Id", "routerId", "#PeersCfg",
10075 "#PeersEstb", "Name");
10076 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10077 "L3-VNI", "RouterMAC", "Interface");
10080 peers_cfg
= peers_estb
= 0;
10082 json_vrf
= json_object_new_object();
10085 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
10086 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10089 if (peer
->status
== Established
)
10093 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10094 name
= VRF_DEFAULT_NAME
;
10103 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10105 : (int64_t)bgp
->vrf_id
;
10106 char buf
[BUFSIZ
] = {0};
10108 json_object_string_add(json_vrf
, "type", type
);
10109 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
10110 json_object_string_add(json_vrf
, "routerId",
10112 &bgp
->router_id
, buf
,
10114 json_object_int_add(json_vrf
, "numConfiguredPeers",
10116 json_object_int_add(json_vrf
, "numEstablishedPeers",
10119 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
10120 json_object_string_add(
10122 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
10123 json_object_string_add(json_vrf
, "interface",
10124 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10126 json_object_object_add(json_vrfs
, name
, json_vrf
);
10128 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10130 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10131 : (int)bgp
->vrf_id
,
10132 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10133 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
10135 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
10136 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10142 json_object_object_add(json
, "vrfs", json_vrfs
);
10144 json_object_int_add(json
, "totalVrfs", count
);
10146 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10147 json
, JSON_C_TO_STRING_PRETTY
));
10148 json_object_free(json
);
10152 "\nTotal number of VRFs (including default): %d\n",
10156 return CMD_SUCCESS
;
10159 DEFUN (show_bgp_mac_hash
,
10160 show_bgp_mac_hash_cmd
,
10161 "show bgp mac hash",
10165 "Mac Address database\n")
10167 bgp_mac_dump_table(vty
);
10169 return CMD_SUCCESS
;
10172 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10174 struct vty
*vty
= (struct vty
*)args
;
10175 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10177 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10180 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10182 vty_out(vty
, "self nexthop database:\n");
10183 bgp_nexthop_show_address_hash(vty
, bgp
);
10185 vty_out(vty
, "Tunnel-ip database:\n");
10186 hash_iterate(bgp
->tip_hash
,
10187 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10191 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10192 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10193 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10194 "martian next-hops\n"
10195 "martian next-hop database\n")
10197 struct bgp
*bgp
= NULL
;
10201 /* [<vrf> VIEWVRFNAME] */
10202 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10203 name
= argv
[idx
+ 1]->arg
;
10204 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10206 } else if (argv_find(argv
, argc
, "view", &idx
))
10207 /* [<view> VIEWVRFNAME] */
10208 name
= argv
[idx
+ 1]->arg
;
10210 bgp
= bgp_lookup_by_name(name
);
10212 bgp
= bgp_get_default();
10215 vty_out(vty
, "%% No BGP process is configured\n");
10216 return CMD_WARNING
;
10218 bgp_show_martian_nexthops(vty
, bgp
);
10220 return CMD_SUCCESS
;
10223 DEFUN (show_bgp_memory
,
10224 show_bgp_memory_cmd
,
10225 "show [ip] bgp memory",
10229 "Global BGP memory statistics\n")
10231 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10232 unsigned long count
;
10234 /* RIB related usage stats */
10235 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10236 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10237 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10238 count
* sizeof(struct bgp_dest
)));
10240 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10241 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10242 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10243 count
* sizeof(struct bgp_path_info
)));
10244 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10245 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10248 memstrbuf
, sizeof(memstrbuf
),
10249 count
* sizeof(struct bgp_path_info_extra
)));
10251 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10252 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10253 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10254 count
* sizeof(struct bgp_static
)));
10256 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10257 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10258 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10259 count
* sizeof(struct bpacket
)));
10262 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10263 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10264 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10265 count
* sizeof(struct bgp_adj_in
)));
10266 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10267 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10268 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10269 count
* sizeof(struct bgp_adj_out
)));
10271 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10272 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10274 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10275 count
* sizeof(struct bgp_nexthop_cache
)));
10277 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10278 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10280 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10281 count
* sizeof(struct bgp_damp_info
)));
10284 count
= attr_count();
10285 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10286 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10287 count
* sizeof(struct attr
)));
10289 if ((count
= attr_unknown_count()))
10290 vty_out(vty
, "%ld unknown attributes\n", count
);
10292 /* AS_PATH attributes */
10293 count
= aspath_count();
10294 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10295 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10296 count
* sizeof(struct aspath
)));
10298 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10299 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10300 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10301 count
* sizeof(struct assegment
)));
10303 /* Other attributes */
10304 if ((count
= community_count()))
10305 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10306 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10307 count
* sizeof(struct community
)));
10308 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10309 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10310 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10311 count
* sizeof(struct ecommunity
)));
10312 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10314 "%ld BGP large-community entries, using %s of memory\n",
10315 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10316 count
* sizeof(struct lcommunity
)));
10318 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10319 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10320 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10321 count
* sizeof(struct cluster_list
)));
10323 /* Peer related usage */
10324 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10325 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10326 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10327 count
* sizeof(struct peer
)));
10329 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10330 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10331 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10332 count
* sizeof(struct peer_group
)));
10335 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10336 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10337 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10338 count
* sizeof(regex_t
)));
10339 return CMD_SUCCESS
;
10342 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10344 json_object
*bestpath
= json_object_new_object();
10346 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10347 json_object_string_add(bestpath
, "asPath", "ignore");
10349 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10350 json_object_string_add(bestpath
, "asPath", "confed");
10352 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10353 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10354 json_object_string_add(bestpath
, "multiPathRelax",
10357 json_object_string_add(bestpath
, "multiPathRelax",
10360 json_object_string_add(bestpath
, "multiPathRelax", "false");
10362 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10363 json_object_string_add(bestpath
, "compareRouterId", "true");
10364 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10365 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10366 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10367 json_object_string_add(bestpath
, "med", "confed");
10368 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10369 json_object_string_add(bestpath
, "med",
10370 "missing-as-worst");
10372 json_object_string_add(bestpath
, "med", "true");
10375 json_object_object_add(json
, "bestPath", bestpath
);
10378 /* Print the error code/subcode for why the peer is down */
10379 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10380 json_object
*json_peer
, bool use_json
)
10382 const char *code_str
;
10383 const char *subcode_str
;
10386 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10387 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10388 char errorcodesubcode_hexstr
[5];
10389 char errorcodesubcode_str
[256];
10391 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10392 subcode_str
= bgp_notify_subcode_str(
10394 peer
->notify
.subcode
);
10396 snprintf(errorcodesubcode_hexstr
,
10397 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10398 peer
->notify
.code
, peer
->notify
.subcode
);
10399 json_object_string_add(json_peer
,
10400 "lastErrorCodeSubcode",
10401 errorcodesubcode_hexstr
);
10402 snprintf(errorcodesubcode_str
, 255, "%s%s",
10403 code_str
, subcode_str
);
10404 json_object_string_add(json_peer
,
10405 "lastNotificationReason",
10406 errorcodesubcode_str
);
10407 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10408 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10409 && (peer
->notify
.subcode
10410 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10411 || peer
->notify
.subcode
10412 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10413 && peer
->notify
.length
) {
10415 const char *msg_str
;
10417 msg_str
= bgp_notify_admin_message(
10418 msgbuf
, sizeof(msgbuf
),
10419 (uint8_t *)peer
->notify
.data
,
10420 peer
->notify
.length
);
10422 json_object_string_add(
10424 "lastShutdownDescription",
10429 json_object_string_add(json_peer
, "lastResetDueTo",
10430 peer_down_str
[(int)peer
->last_reset
]);
10431 json_object_int_add(json_peer
, "lastResetCode",
10434 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10435 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10436 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10438 bgp_notify_subcode_str(peer
->notify
.code
,
10439 peer
->notify
.subcode
);
10440 vty_out(vty
, " Notification %s (%s%s)\n",
10441 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10444 code_str
, subcode_str
);
10446 vty_out(vty
, " %s\n",
10447 peer_down_str
[(int)peer
->last_reset
]);
10452 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10455 return ((peer
->status
!= Established
) ||
10456 !peer
->afc_recv
[afi
][safi
]);
10459 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10460 struct peer
*peer
, json_object
*json_peer
,
10461 int max_neighbor_width
, bool use_json
)
10463 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10467 if (peer_dynamic_neighbor(peer
))
10468 json_object_boolean_true_add(json_peer
,
10470 if (peer
->hostname
)
10471 json_object_string_add(json_peer
, "hostname",
10474 if (peer
->domainname
)
10475 json_object_string_add(json_peer
, "domainname",
10477 json_object_int_add(json_peer
, "connectionsEstablished",
10478 peer
->established
);
10479 json_object_int_add(json_peer
, "connectionsDropped",
10481 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10482 use_json
, json_peer
);
10483 if (peer
->status
== Established
)
10484 json_object_string_add(json_peer
, "lastResetDueTo",
10485 "AFI/SAFI Not Negotiated");
10487 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10490 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10492 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10493 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10494 peer
->hostname
, peer
->host
);
10496 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10498 /* pad the neighbor column with spaces */
10499 if (len
< max_neighbor_width
)
10500 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10502 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10504 peer_uptime(peer
->uptime
, timebuf
,
10505 BGP_UPTIME_LEN
, 0, NULL
));
10506 if (peer
->status
== Established
)
10507 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10509 bgp_show_peer_reset(vty
, peer
, NULL
,
10515 /* Show BGP peer's summary information. */
10516 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10517 bool show_failed
, bool show_established
,
10521 struct listnode
*node
, *nnode
;
10522 unsigned int count
= 0, dn_count
= 0;
10523 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10524 char neighbor_buf
[VTY_BUFSIZ
];
10525 int neighbor_col_default_width
= 16;
10526 int len
, failed_count
= 0;
10527 int max_neighbor_width
= 0;
10529 json_object
*json
= NULL
;
10530 json_object
*json_peer
= NULL
;
10531 json_object
*json_peers
= NULL
;
10532 struct peer_af
*paf
;
10533 struct bgp_filter
*filter
;
10535 /* labeled-unicast routes are installed in the unicast table so in order
10537 * display the correct PfxRcd value we must look at SAFI_UNICAST
10540 if (safi
== SAFI_LABELED_UNICAST
)
10541 pfx_rcd_safi
= SAFI_UNICAST
;
10543 pfx_rcd_safi
= safi
;
10546 json
= json_object_new_object();
10547 json_peers
= json_object_new_object();
10548 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10549 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10552 if (peer
->afc
[afi
][safi
]) {
10553 /* See if we have at least a single failed peer */
10554 if (bgp_has_peer_failed(peer
, afi
, safi
))
10558 if (peer_dynamic_neighbor(peer
))
10563 /* Loop over all neighbors that will be displayed to determine
10565 * characters are needed for the Neighbor column
10567 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10568 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10571 if (peer
->afc
[afi
][safi
]) {
10572 memset(dn_flag
, '\0', sizeof(dn_flag
));
10573 if (peer_dynamic_neighbor(peer
))
10577 && CHECK_FLAG(bgp
->flags
,
10578 BGP_FLAG_SHOW_HOSTNAME
))
10579 snprintf(neighbor_buf
,
10580 sizeof(neighbor_buf
),
10581 "%s%s(%s) ", dn_flag
,
10582 peer
->hostname
, peer
->host
);
10584 snprintf(neighbor_buf
,
10585 sizeof(neighbor_buf
), "%s%s ",
10586 dn_flag
, peer
->host
);
10588 len
= strlen(neighbor_buf
);
10590 if (len
> max_neighbor_width
)
10591 max_neighbor_width
= len
;
10593 /* See if we have at least a single failed peer */
10594 if (bgp_has_peer_failed(peer
, afi
, safi
))
10600 /* Originally we displayed the Neighbor column as 16
10601 * characters wide so make that the default
10603 if (max_neighbor_width
< neighbor_col_default_width
)
10604 max_neighbor_width
= neighbor_col_default_width
;
10607 if (show_failed
&& !failed_count
) {
10609 json_object_int_add(json
, "failedPeersCount", 0);
10610 json_object_int_add(json
, "dynamicPeers", dn_count
);
10611 json_object_int_add(json
, "totalPeers", count
);
10613 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10614 json
, JSON_C_TO_STRING_PRETTY
));
10615 json_object_free(json
);
10617 vty_out(vty
, "%% No failed BGP neighbors found\n");
10618 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
10620 return CMD_SUCCESS
;
10623 count
= 0; /* Reset the value as its used again */
10624 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10625 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10628 if (!peer
->afc
[afi
][safi
])
10632 unsigned long ents
;
10633 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10636 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10638 : (int64_t)bgp
->vrf_id
;
10640 /* Usage summary and header */
10642 char buf
[BUFSIZ
] = {0};
10644 json_object_string_add(
10646 inet_ntop(AF_INET
, &bgp
->router_id
, buf
,
10648 json_object_int_add(json
, "as", bgp
->as
);
10649 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10650 json_object_string_add(
10653 == BGP_INSTANCE_TYPE_DEFAULT
)
10658 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10659 &bgp
->router_id
, bgp
->as
,
10660 bgp
->vrf_id
== VRF_UNKNOWN
10662 : (int)bgp
->vrf_id
);
10663 vty_out(vty
, "\n");
10666 if (bgp_update_delay_configured(bgp
)) {
10668 json_object_int_add(
10669 json
, "updateDelayLimit",
10670 bgp
->v_update_delay
);
10672 if (bgp
->v_update_delay
10673 != bgp
->v_establish_wait
)
10674 json_object_int_add(
10676 "updateDelayEstablishWait",
10677 bgp
->v_establish_wait
);
10679 if (bgp_update_delay_active(bgp
)) {
10680 json_object_string_add(
10682 "updateDelayFirstNeighbor",
10683 bgp
->update_delay_begin_time
);
10684 json_object_boolean_true_add(
10686 "updateDelayInProgress");
10688 if (bgp
->update_delay_over
) {
10689 json_object_string_add(
10691 "updateDelayFirstNeighbor",
10692 bgp
->update_delay_begin_time
);
10693 json_object_string_add(
10695 "updateDelayBestpathResumed",
10696 bgp
->update_delay_end_time
);
10697 json_object_string_add(
10699 "updateDelayZebraUpdateResume",
10700 bgp
->update_delay_zebra_resume_time
);
10701 json_object_string_add(
10703 "updateDelayPeerUpdateResume",
10704 bgp
->update_delay_peers_resume_time
);
10709 "Read-only mode update-delay limit: %d seconds\n",
10710 bgp
->v_update_delay
);
10711 if (bgp
->v_update_delay
10712 != bgp
->v_establish_wait
)
10714 " Establish wait: %d seconds\n",
10715 bgp
->v_establish_wait
);
10717 if (bgp_update_delay_active(bgp
)) {
10719 " First neighbor established: %s\n",
10720 bgp
->update_delay_begin_time
);
10722 " Delay in progress\n");
10724 if (bgp
->update_delay_over
) {
10726 " First neighbor established: %s\n",
10727 bgp
->update_delay_begin_time
);
10729 " Best-paths resumed: %s\n",
10730 bgp
->update_delay_end_time
);
10732 " zebra update resumed: %s\n",
10733 bgp
->update_delay_zebra_resume_time
);
10735 " peers update resumed: %s\n",
10736 bgp
->update_delay_peers_resume_time
);
10743 if (bgp_maxmed_onstartup_configured(bgp
)
10744 && bgp
->maxmed_active
)
10745 json_object_boolean_true_add(
10746 json
, "maxMedOnStartup");
10747 if (bgp
->v_maxmed_admin
)
10748 json_object_boolean_true_add(
10749 json
, "maxMedAdministrative");
10751 json_object_int_add(
10752 json
, "tableVersion",
10753 bgp_table_version(bgp
->rib
[afi
][safi
]));
10755 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10756 json_object_int_add(json
, "ribCount", ents
);
10757 json_object_int_add(
10759 ents
* sizeof(struct bgp_dest
));
10761 ents
= bgp
->af_peer_count
[afi
][safi
];
10762 json_object_int_add(json
, "peerCount", ents
);
10763 json_object_int_add(json
, "peerMemory",
10764 ents
* sizeof(struct peer
));
10766 if ((ents
= listcount(bgp
->group
))) {
10767 json_object_int_add(
10768 json
, "peerGroupCount", ents
);
10769 json_object_int_add(
10770 json
, "peerGroupMemory",
10771 ents
* sizeof(struct
10775 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10776 BGP_CONFIG_DAMPENING
))
10777 json_object_boolean_true_add(
10778 json
, "dampeningEnabled");
10780 if (bgp_maxmed_onstartup_configured(bgp
)
10781 && bgp
->maxmed_active
)
10783 "Max-med on-startup active\n");
10784 if (bgp
->v_maxmed_admin
)
10786 "Max-med administrative active\n");
10788 vty_out(vty
, "BGP table version %" PRIu64
"\n",
10789 bgp_table_version(bgp
->rib
[afi
][safi
]));
10791 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10793 "RIB entries %ld, using %s of memory\n",
10796 memstrbuf
, sizeof(memstrbuf
),
10801 /* Peer related usage */
10802 ents
= bgp
->af_peer_count
[afi
][safi
];
10803 vty_out(vty
, "Peers %ld, using %s of memory\n",
10806 memstrbuf
, sizeof(memstrbuf
),
10807 ents
* sizeof(struct peer
)));
10809 if ((ents
= listcount(bgp
->group
)))
10811 "Peer groups %ld, using %s of memory\n",
10816 ents
* sizeof(struct
10819 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10820 BGP_CONFIG_DAMPENING
))
10821 vty_out(vty
, "Dampening enabled.\n");
10822 vty_out(vty
, "\n");
10824 /* Subtract 8 here because 'Neighbor' is
10826 vty_out(vty
, "Neighbor");
10827 vty_out(vty
, "%*s", max_neighbor_width
- 8,
10830 vty_out(vty
, "EstdCnt DropCnt ResetTime Reason\n");
10833 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt Desc\n");
10837 paf
= peer_af_find(peer
, afi
, safi
);
10838 filter
= &peer
->filter
[afi
][safi
];
10841 /* Works for both failed & successful cases */
10842 if (peer_dynamic_neighbor(peer
))
10849 bgp_has_peer_failed(peer
, afi
, safi
)) {
10850 json_peer
= json_object_new_object();
10851 bgp_show_failed_summary(vty
, bgp
, peer
,
10852 json_peer
, 0, use_json
);
10853 } else if (!show_failed
) {
10854 if (show_established
10855 && bgp_has_peer_failed(peer
, afi
, safi
))
10858 json_peer
= json_object_new_object();
10859 if (peer_dynamic_neighbor(peer
)) {
10860 json_object_boolean_true_add(json_peer
,
10864 if (peer
->hostname
)
10865 json_object_string_add(json_peer
, "hostname",
10868 if (peer
->domainname
)
10869 json_object_string_add(json_peer
, "domainname",
10872 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
10873 json_object_int_add(json_peer
, "version", 4);
10874 json_object_int_add(json_peer
, "msgRcvd",
10875 PEER_TOTAL_RX(peer
));
10876 json_object_int_add(json_peer
, "msgSent",
10877 PEER_TOTAL_TX(peer
));
10879 atomic_size_t outq_count
, inq_count
;
10880 outq_count
= atomic_load_explicit(
10881 &peer
->obuf
->count
,
10882 memory_order_relaxed
);
10883 inq_count
= atomic_load_explicit(
10884 &peer
->ibuf
->count
,
10885 memory_order_relaxed
);
10887 json_object_int_add(json_peer
, "tableVersion",
10888 peer
->version
[afi
][safi
]);
10889 json_object_int_add(json_peer
, "outq",
10891 json_object_int_add(json_peer
, "inq",
10893 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10894 use_json
, json_peer
);
10896 json_object_int_add(json_peer
, "pfxRcd",
10897 peer
->pcount
[afi
][pfx_rcd_safi
]);
10899 if (paf
&& PAF_SUBGRP(paf
))
10900 json_object_int_add(
10901 json_peer
, "pfxSnt",
10902 (PAF_SUBGRP(paf
))->scount
);
10904 json_object_int_add(json_peer
, "pfxSnt",
10907 /* BGP FSM state */
10908 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10909 || CHECK_FLAG(peer
->bgp
->flags
,
10910 BGP_FLAG_SHUTDOWN
))
10911 json_object_string_add(json_peer
,
10914 else if (peer
->afc_recv
[afi
][safi
])
10915 json_object_string_add(
10916 json_peer
, "state",
10917 lookup_msg(bgp_status_msg
,
10918 peer
->status
, NULL
));
10919 else if (CHECK_FLAG(
10921 PEER_STATUS_PREFIX_OVERFLOW
))
10922 json_object_string_add(json_peer
,
10926 json_object_string_add(
10927 json_peer
, "state",
10928 lookup_msg(bgp_status_msg
,
10929 peer
->status
, NULL
));
10931 /* BGP peer state */
10932 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
10933 || CHECK_FLAG(peer
->bgp
->flags
,
10934 BGP_FLAG_SHUTDOWN
))
10935 json_object_string_add(json_peer
,
10938 else if (CHECK_FLAG(
10940 PEER_STATUS_PREFIX_OVERFLOW
))
10941 json_object_string_add(json_peer
,
10944 else if (CHECK_FLAG(peer
->flags
,
10945 PEER_FLAG_PASSIVE
))
10946 json_object_string_add(json_peer
,
10949 else if (CHECK_FLAG(peer
->sflags
,
10950 PEER_STATUS_NSF_WAIT
))
10951 json_object_string_add(json_peer
,
10954 else if (CHECK_FLAG(
10956 BGP_FLAG_EBGP_REQUIRES_POLICY
)
10957 && (!bgp_inbound_policy_exists(peer
,
10959 || !bgp_outbound_policy_exists(
10961 json_object_string_add(json_peer
,
10965 json_object_string_add(
10966 json_peer
, "peerState", "OK");
10968 json_object_int_add(json_peer
, "connectionsEstablished",
10969 peer
->established
);
10970 json_object_int_add(json_peer
, "connectionsDropped",
10973 json_object_string_add(
10974 json_peer
, "desc", peer
->desc
);
10976 /* Avoid creating empty peer dicts in JSON */
10977 if (json_peer
== NULL
)
10981 json_object_string_add(json_peer
, "idType",
10983 else if (peer
->su
.sa
.sa_family
== AF_INET
)
10984 json_object_string_add(json_peer
, "idType",
10986 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
10987 json_object_string_add(json_peer
, "idType",
10989 json_object_object_add(json_peers
, peer
->host
,
10993 bgp_has_peer_failed(peer
, afi
, safi
)) {
10994 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
10995 max_neighbor_width
,
10997 } else if (!show_failed
) {
10998 if (show_established
10999 && bgp_has_peer_failed(peer
, afi
, safi
))
11002 memset(dn_flag
, '\0', sizeof(dn_flag
));
11003 if (peer_dynamic_neighbor(peer
)) {
11008 && CHECK_FLAG(bgp
->flags
,
11009 BGP_FLAG_SHOW_HOSTNAME
))
11010 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11014 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11016 /* pad the neighbor column with spaces */
11017 if (len
< max_neighbor_width
)
11018 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11021 atomic_size_t outq_count
, inq_count
;
11022 outq_count
= atomic_load_explicit(
11023 &peer
->obuf
->count
,
11024 memory_order_relaxed
);
11025 inq_count
= atomic_load_explicit(
11026 &peer
->ibuf
->count
,
11027 memory_order_relaxed
);
11030 "4 %10u %9u %9u %8" PRIu64
" %4zu %4zu %8s",
11031 peer
->as
, PEER_TOTAL_RX(peer
),
11032 PEER_TOTAL_TX(peer
),
11033 peer
->version
[afi
][safi
], inq_count
,
11035 peer_uptime(peer
->uptime
, timebuf
,
11036 BGP_UPTIME_LEN
, 0, NULL
));
11038 if (peer
->status
== Established
) {
11039 if (peer
->afc_recv
[afi
][safi
]) {
11042 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11043 && !bgp_inbound_policy_exists(
11045 vty_out(vty
, " %12s",
11054 vty_out(vty
, " NoNeg");
11057 if (paf
&& PAF_SUBGRP(paf
)) {
11060 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11061 && !bgp_outbound_policy_exists(
11063 vty_out(vty
, " %8s",
11073 if (CHECK_FLAG(peer
->flags
,
11074 PEER_FLAG_SHUTDOWN
)
11075 || CHECK_FLAG(peer
->bgp
->flags
,
11076 BGP_FLAG_SHUTDOWN
))
11077 vty_out(vty
, " Idle (Admin)");
11078 else if (CHECK_FLAG(
11080 PEER_STATUS_PREFIX_OVERFLOW
))
11081 vty_out(vty
, " Idle (PfxCt)");
11083 vty_out(vty
, " %12s",
11084 lookup_msg(bgp_status_msg
,
11085 peer
->status
, NULL
));
11087 vty_out(vty
, " %8u", 0);
11090 vty_out(vty
, " %s", peer
->desc
);
11092 vty_out(vty
, " N/A");
11093 vty_out(vty
, "\n");
11100 json_object_object_add(json
, "peers", json_peers
);
11101 json_object_int_add(json
, "failedPeers", failed_count
);
11102 json_object_int_add(json
, "totalPeers", count
);
11103 json_object_int_add(json
, "dynamicPeers", dn_count
);
11106 bgp_show_bestpath_json(bgp
, json
);
11108 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11109 json
, JSON_C_TO_STRING_PRETTY
));
11110 json_object_free(json
);
11113 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
11115 vty_out(vty
, "No %s neighbor is configured\n",
11116 get_afi_safi_str(afi
, safi
, false));
11120 vty_out(vty
, "* - dynamic neighbor\n");
11121 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11122 dn_count
, bgp
->dynamic_neighbors_limit
);
11126 return CMD_SUCCESS
;
11129 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11130 int safi
, bool show_failed
,
11131 bool show_established
, bool use_json
)
11134 int afi_wildcard
= (afi
== AFI_MAX
);
11135 int safi_wildcard
= (safi
== SAFI_MAX
);
11136 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11137 bool nbr_output
= false;
11139 if (use_json
&& is_wildcard
)
11140 vty_out(vty
, "{\n");
11142 afi
= 1; /* AFI_IP */
11143 while (afi
< AFI_MAX
) {
11145 safi
= 1; /* SAFI_UNICAST */
11146 while (safi
< SAFI_MAX
) {
11147 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11152 * So limit output to those afi/safi
11154 * actualy have something interesting in
11159 vty_out(vty
, ",\n");
11163 vty_out(vty
, "\"%s\":",
11164 get_afi_safi_str(afi
,
11168 vty_out(vty
, "\n%s Summary:\n",
11169 get_afi_safi_str(afi
,
11174 bgp_show_summary(vty
, bgp
, afi
, safi
,
11175 show_failed
, show_established
,
11179 if (!safi_wildcard
)
11187 if (use_json
&& is_wildcard
)
11188 vty_out(vty
, "}\n");
11189 else if (!nbr_output
) {
11191 vty_out(vty
, "{}\n");
11193 vty_out(vty
, "%% No BGP neighbors found\n");
11197 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11198 safi_t safi
, bool show_failed
,
11199 bool show_established
,
11202 struct listnode
*node
, *nnode
;
11205 bool nbr_output
= false;
11208 vty_out(vty
, "{\n");
11210 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11214 vty_out(vty
, ",\n");
11218 vty_out(vty
, "\"%s\":",
11219 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11223 vty_out(vty
, "\nInstance %s:\n",
11224 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11228 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
11229 show_established
, use_json
);
11233 vty_out(vty
, "}\n");
11234 else if (!nbr_output
)
11235 vty_out(vty
, "%% BGP instance not found\n");
11238 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11239 safi_t safi
, bool show_failed
, bool show_established
,
11245 if (strmatch(name
, "all")) {
11246 bgp_show_all_instances_summary_vty(
11247 vty
, afi
, safi
, show_failed
, show_established
,
11249 return CMD_SUCCESS
;
11251 bgp
= bgp_lookup_by_name(name
);
11255 vty_out(vty
, "{}\n");
11258 "%% BGP instance not found\n");
11259 return CMD_WARNING
;
11262 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
,
11263 show_failed
, show_established
,
11265 return CMD_SUCCESS
;
11269 bgp
= bgp_get_default();
11272 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
11273 show_established
, use_json
);
11276 vty_out(vty
, "{}\n");
11278 vty_out(vty
, "%% BGP instance not found\n");
11279 return CMD_WARNING
;
11282 return CMD_SUCCESS
;
11285 /* `show [ip] bgp summary' commands. */
11286 DEFPY (show_ip_bgp_summary
,
11287 show_ip_bgp_summary_cmd
,
11288 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] [all$all] summary [established|failed] [json$uj]",
11292 BGP_INSTANCE_HELP_STR
11294 BGP_SAFI_WITH_LABEL_HELP_STR
11295 "Display the entries for all address families\n"
11296 "Summary of BGP neighbor status\n"
11297 "Show only sessions in Established state\n"
11298 "Show only sessions not in Established state\n"
11302 afi_t afi
= AFI_MAX
;
11303 safi_t safi
= SAFI_MAX
;
11304 bool show_failed
= false;
11305 bool show_established
= false;
11309 /* show [ip] bgp */
11310 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11312 /* [<vrf> VIEWVRFNAME] */
11313 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11314 vrf
= argv
[idx
+ 1]->arg
;
11315 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11317 } else if (argv_find(argv
, argc
, "view", &idx
))
11318 /* [<view> VIEWVRFNAME] */
11319 vrf
= argv
[idx
+ 1]->arg
;
11320 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11321 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11322 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11325 if (argv_find(argv
, argc
, "failed", &idx
))
11326 show_failed
= true;
11327 if (argv_find(argv
, argc
, "established", &idx
))
11328 show_established
= true;
11330 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, show_failed
,
11331 show_established
, uj
);
11334 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11337 return get_afi_safi_json_str(afi
, safi
);
11339 return get_afi_safi_vty_str(afi
, safi
);
11343 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11344 afi_t afi
, safi_t safi
,
11345 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11346 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11347 bool use_json
, json_object
*json_pref
)
11350 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11351 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11353 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11354 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11355 json_object_string_add(json_pref
, "sendMode",
11356 "advertisedAndReceived");
11357 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11358 json_object_string_add(json_pref
, "sendMode",
11360 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11361 json_object_string_add(json_pref
, "sendMode",
11364 vty_out(vty
, " Send-mode: ");
11365 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11366 vty_out(vty
, "advertised");
11367 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11368 vty_out(vty
, "%sreceived",
11369 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11373 vty_out(vty
, "\n");
11378 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11379 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11381 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11382 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11383 json_object_string_add(json_pref
, "recvMode",
11384 "advertisedAndReceived");
11385 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11386 json_object_string_add(json_pref
, "recvMode",
11388 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11389 json_object_string_add(json_pref
, "recvMode",
11392 vty_out(vty
, " Receive-mode: ");
11393 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11394 vty_out(vty
, "advertised");
11395 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11396 vty_out(vty
, "%sreceived",
11397 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11401 vty_out(vty
, "\n");
11406 static void bgp_show_neighnor_graceful_restart_rbit(struct vty
*vty
,
11411 bool rbit_status
= false;
11414 vty_out(vty
, "\n R bit: ");
11416 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11417 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11418 && (p
->status
== Established
)) {
11420 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_BIT_RCV
))
11421 rbit_status
= true;
11423 rbit_status
= false;
11428 json_object_boolean_true_add(json
, "rBit");
11430 vty_out(vty
, "True\n");
11433 json_object_boolean_false_add(json
, "rBit");
11435 vty_out(vty
, "False\n");
11439 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11444 const char *mode
= "NotApplicable";
11447 vty_out(vty
, "\n Remote GR Mode: ");
11449 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11450 && (peer
->status
== Established
)) {
11452 if ((peer
->nsf_af_count
== 0)
11453 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11457 } else if (peer
->nsf_af_count
== 0
11458 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11462 } else if (peer
->nsf_af_count
!= 0
11463 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11470 json_object_string_add(json
, "remoteGrMode", mode
);
11472 vty_out(vty
, mode
, "\n");
11475 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11480 const char *mode
= "Invalid";
11483 vty_out(vty
, " Local GR Mode: ");
11485 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11487 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11489 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11491 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11492 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11494 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11496 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11503 json_object_string_add(json
, "localGrMode", mode
);
11505 vty_out(vty
, mode
, "\n");
11509 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11510 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11514 json_object
*json_afi_safi
= NULL
;
11515 json_object
*json_timer
= NULL
;
11516 json_object
*json_endofrib_status
= NULL
;
11517 bool eor_flag
= false;
11519 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11520 for (safi
= SAFI_UNICAST
; safi
<= SAFI_MPLS_VPN
; safi
++) {
11521 if (!peer
->afc
[afi
][safi
])
11524 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11525 || !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11529 json_afi_safi
= json_object_new_object();
11530 json_endofrib_status
= json_object_new_object();
11531 json_timer
= json_object_new_object();
11534 if (peer
->eor_stime
[afi
][safi
]
11535 >= peer
->pkt_stime
[afi
][safi
])
11541 vty_out(vty
, " %s:\n",
11542 get_afi_safi_str(afi
, safi
, false));
11544 vty_out(vty
, " F bit: ");
11547 if (peer
->nsf
[afi
][safi
]
11548 && CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11549 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11552 json_object_boolean_true_add(
11553 json_afi_safi
, "fBit");
11555 vty_out(vty
, "True\n");
11558 json_object_boolean_false_add(
11559 json_afi_safi
, "fBit");
11561 vty_out(vty
, "False\n");
11565 vty_out(vty
, " End-of-RIB sent: ");
11567 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11568 PEER_STATUS_EOR_SEND
)) {
11570 json_object_boolean_true_add(
11571 json_endofrib_status
,
11574 PRINT_EOR_JSON(eor_flag
);
11576 vty_out(vty
, "Yes\n");
11578 " End-of-RIB sent after update: ");
11580 PRINT_EOR(eor_flag
);
11584 json_object_boolean_false_add(
11585 json_endofrib_status
,
11587 json_object_boolean_false_add(
11588 json_endofrib_status
,
11589 "endOfRibSentAfterUpdate");
11591 vty_out(vty
, "No\n");
11593 " End-of-RIB sent after update: ");
11594 vty_out(vty
, "No\n");
11599 vty_out(vty
, " End-of-RIB received: ");
11601 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11602 PEER_STATUS_EOR_RECEIVED
)) {
11604 json_object_boolean_true_add(
11605 json_endofrib_status
,
11608 vty_out(vty
, "Yes\n");
11611 json_object_boolean_false_add(
11612 json_endofrib_status
,
11615 vty_out(vty
, "No\n");
11619 json_object_int_add(json_timer
,
11621 peer
->bgp
->stalepath_time
);
11623 if (peer
->t_gr_stale
!= NULL
) {
11624 json_object_int_add(
11626 "stalePathTimerRemaining",
11627 thread_timer_remain_second(
11628 peer
->t_gr_stale
));
11631 /* Display Configured Selection
11632 * Deferral only when when
11633 * Gr mode is enabled.
11635 if (CHECK_FLAG(peer
->flags
,
11636 PEER_FLAG_GRACEFUL_RESTART
)) {
11637 json_object_int_add(
11639 "selectionDeferralTimer",
11640 peer
->bgp
->stalepath_time
);
11643 if (peer
->bgp
->gr_info
[afi
][safi
]
11647 json_object_int_add(
11649 "selectionDeferralTimerRemaining",
11650 thread_timer_remain_second(
11654 .t_select_deferral
));
11657 vty_out(vty
, " Timers:\n");
11659 " Configured Stale Path Time(sec): %u\n",
11660 peer
->bgp
->stalepath_time
);
11662 if (peer
->t_gr_stale
!= NULL
)
11664 " Stale Path Remaining(sec): %ld\n",
11665 thread_timer_remain_second(
11666 peer
->t_gr_stale
));
11667 /* Display Configured Selection
11668 * Deferral only when when
11669 * Gr mode is enabled.
11671 if (CHECK_FLAG(peer
->flags
,
11672 PEER_FLAG_GRACEFUL_RESTART
))
11674 " Configured Selection Deferral Time(sec): %u\n",
11675 peer
->bgp
->select_defer_time
);
11677 if (peer
->bgp
->gr_info
[afi
][safi
]
11681 " Selection Deferral Time Remaining(sec): %ld\n",
11682 thread_timer_remain_second(
11686 .t_select_deferral
));
11689 json_object_object_add(json_afi_safi
,
11691 json_endofrib_status
);
11692 json_object_object_add(json_afi_safi
, "timers",
11694 json_object_object_add(
11695 json
, get_afi_safi_str(afi
, safi
, true),
11702 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
11708 json_object
*json_timer
= NULL
;
11710 json_timer
= json_object_new_object();
11712 json_object_int_add(json_timer
, "configuredRestartTimer",
11713 p
->bgp
->restart_time
);
11715 json_object_int_add(json_timer
, "receivedRestartTimer",
11718 if (p
->t_gr_restart
!= NULL
)
11719 json_object_int_add(
11720 json_timer
, "restartTimerRemaining",
11721 thread_timer_remain_second(p
->t_gr_restart
));
11723 json_object_object_add(json
, "timers", json_timer
);
11726 vty_out(vty
, " Timers:\n");
11727 vty_out(vty
, " Configured Restart Time(sec): %u\n",
11728 p
->bgp
->restart_time
);
11730 vty_out(vty
, " Received Restart Time(sec): %u\n",
11732 if (p
->t_gr_restart
!= NULL
)
11733 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11734 thread_timer_remain_second(p
->t_gr_restart
));
11735 if (p
->t_gr_restart
!= NULL
) {
11736 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11737 thread_timer_remain_second(p
->t_gr_restart
));
11742 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
11743 bool use_json
, json_object
*json
)
11745 char buf
[SU_ADDRSTRLEN
] = {0};
11746 char dn_flag
[2] = {0};
11747 /* '*' + v6 address of neighbor */
11748 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
11750 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11755 json_object_string_add(
11756 json
, "neighborAddr",
11757 BGP_PEER_SU_UNSPEC(p
)
11759 : sockunion2str(&p
->su
, buf
,
11762 vty_out(vty
, "BGP neighbor on %s: %s\n", p
->conf_if
,
11763 BGP_PEER_SU_UNSPEC(p
)
11765 : sockunion2str(&p
->su
, buf
,
11768 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
11772 json_object_string_add(json
, "neighborAddr",
11775 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
11778 /* more gr info in new format */
11779 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
11782 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
11783 safi_t safi
, bool use_json
,
11784 json_object
*json_neigh
)
11786 struct bgp_filter
*filter
;
11787 struct peer_af
*paf
;
11788 char orf_pfx_name
[BUFSIZ
];
11790 json_object
*json_af
= NULL
;
11791 json_object
*json_prefA
= NULL
;
11792 json_object
*json_prefB
= NULL
;
11793 json_object
*json_addr
= NULL
;
11794 json_object
*json_advmap
= NULL
;
11797 json_addr
= json_object_new_object();
11798 json_af
= json_object_new_object();
11799 filter
= &p
->filter
[afi
][safi
];
11801 if (peer_group_active(p
))
11802 json_object_string_add(json_addr
, "peerGroupMember",
11805 paf
= peer_af_find(p
, afi
, safi
);
11806 if (paf
&& PAF_SUBGRP(paf
)) {
11807 json_object_int_add(json_addr
, "updateGroupId",
11808 PAF_UPDGRP(paf
)->id
);
11809 json_object_int_add(json_addr
, "subGroupId",
11810 PAF_SUBGRP(paf
)->id
);
11811 json_object_int_add(json_addr
, "packetQueueLength",
11812 bpacket_queue_virtual_length(paf
));
11815 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11816 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11817 PEER_CAP_ORF_PREFIX_SM_RCV
)
11818 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11819 PEER_CAP_ORF_PREFIX_RM_ADV
)
11820 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11821 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11822 json_object_int_add(json_af
, "orfType",
11824 json_prefA
= json_object_new_object();
11825 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
11826 PEER_CAP_ORF_PREFIX_SM_ADV
,
11827 PEER_CAP_ORF_PREFIX_RM_ADV
,
11828 PEER_CAP_ORF_PREFIX_SM_RCV
,
11829 PEER_CAP_ORF_PREFIX_RM_RCV
,
11830 use_json
, json_prefA
);
11831 json_object_object_add(json_af
, "orfPrefixList",
11835 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11836 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11837 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11838 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11839 PEER_CAP_ORF_PREFIX_RM_ADV
)
11840 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11841 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
11842 json_object_int_add(json_af
, "orfOldType",
11843 ORF_TYPE_PREFIX_OLD
);
11844 json_prefB
= json_object_new_object();
11845 bgp_show_peer_afi_orf_cap(
11846 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
11847 PEER_CAP_ORF_PREFIX_RM_ADV
,
11848 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
11849 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
11851 json_object_object_add(json_af
, "orfOldPrefixList",
11855 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11856 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11857 PEER_CAP_ORF_PREFIX_SM_RCV
)
11858 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11859 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11860 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11861 PEER_CAP_ORF_PREFIX_RM_ADV
)
11862 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11863 PEER_CAP_ORF_PREFIX_RM_RCV
)
11864 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11865 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
11866 json_object_object_add(json_addr
, "afDependentCap",
11869 json_object_free(json_af
);
11871 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
11872 p
->host
, afi
, safi
);
11873 orf_pfx_count
= prefix_bgp_show_prefix_list(
11874 NULL
, afi
, orf_pfx_name
, use_json
);
11876 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11877 PEER_STATUS_ORF_PREFIX_SEND
)
11878 || orf_pfx_count
) {
11879 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11880 PEER_STATUS_ORF_PREFIX_SEND
))
11881 json_object_boolean_true_add(json_neigh
,
11884 json_object_int_add(json_addr
, "orfRecvCounter",
11887 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11888 PEER_STATUS_ORF_WAIT_REFRESH
))
11889 json_object_string_add(
11890 json_addr
, "orfFirstUpdate",
11891 "deferredUntilORFOrRouteRefreshRecvd");
11893 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11894 PEER_FLAG_REFLECTOR_CLIENT
))
11895 json_object_boolean_true_add(json_addr
,
11896 "routeReflectorClient");
11897 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11898 PEER_FLAG_RSERVER_CLIENT
))
11899 json_object_boolean_true_add(json_addr
,
11900 "routeServerClient");
11901 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
11902 json_object_boolean_true_add(json_addr
,
11903 "inboundSoftConfigPermit");
11905 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11906 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
11907 json_object_boolean_true_add(
11909 "privateAsNumsAllReplacedInUpdatesToNbr");
11910 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11911 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
11912 json_object_boolean_true_add(
11914 "privateAsNumsReplacedInUpdatesToNbr");
11915 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11916 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
11917 json_object_boolean_true_add(
11919 "privateAsNumsAllRemovedInUpdatesToNbr");
11920 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11921 PEER_FLAG_REMOVE_PRIVATE_AS
))
11922 json_object_boolean_true_add(
11924 "privateAsNumsRemovedInUpdatesToNbr");
11926 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
11927 json_object_boolean_true_add(
11929 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
11932 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
11933 json_object_string_add(json_addr
,
11934 "overrideASNsInOutboundUpdates",
11935 "ifAspathEqualRemoteAs");
11937 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
11938 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11939 PEER_FLAG_FORCE_NEXTHOP_SELF
))
11940 json_object_boolean_true_add(json_addr
,
11941 "routerAlwaysNextHop");
11942 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11943 PEER_FLAG_AS_PATH_UNCHANGED
))
11944 json_object_boolean_true_add(
11945 json_addr
, "unchangedAsPathPropogatedToNbr");
11946 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11947 PEER_FLAG_NEXTHOP_UNCHANGED
))
11948 json_object_boolean_true_add(
11949 json_addr
, "unchangedNextHopPropogatedToNbr");
11950 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
11951 json_object_boolean_true_add(
11952 json_addr
, "unchangedMedPropogatedToNbr");
11953 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
11954 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11955 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
11956 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11957 PEER_FLAG_SEND_COMMUNITY
)
11958 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
11959 PEER_FLAG_SEND_EXT_COMMUNITY
))
11960 json_object_string_add(json_addr
,
11961 "commAttriSentToNbr",
11962 "extendedAndStandard");
11963 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11964 PEER_FLAG_SEND_EXT_COMMUNITY
))
11965 json_object_string_add(json_addr
,
11966 "commAttriSentToNbr",
11969 json_object_string_add(json_addr
,
11970 "commAttriSentToNbr",
11973 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11974 PEER_FLAG_DEFAULT_ORIGINATE
)) {
11975 if (p
->default_rmap
[afi
][safi
].name
)
11976 json_object_string_add(
11977 json_addr
, "defaultRouteMap",
11978 p
->default_rmap
[afi
][safi
].name
);
11980 if (paf
&& PAF_SUBGRP(paf
)
11981 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
11982 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
11983 json_object_boolean_true_add(json_addr
,
11986 json_object_boolean_true_add(json_addr
,
11990 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
11991 if (is_evpn_enabled())
11992 json_object_boolean_true_add(
11993 json_addr
, "advertiseAllVnis");
11996 if (filter
->plist
[FILTER_IN
].name
11997 || filter
->dlist
[FILTER_IN
].name
11998 || filter
->aslist
[FILTER_IN
].name
11999 || filter
->map
[RMAP_IN
].name
)
12000 json_object_boolean_true_add(json_addr
,
12001 "inboundPathPolicyConfig");
12002 if (filter
->plist
[FILTER_OUT
].name
12003 || filter
->dlist
[FILTER_OUT
].name
12004 || filter
->aslist
[FILTER_OUT
].name
12005 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12006 json_object_boolean_true_add(
12007 json_addr
, "outboundPathPolicyConfig");
12010 if (filter
->plist
[FILTER_IN
].name
)
12011 json_object_string_add(json_addr
,
12012 "incomingUpdatePrefixFilterList",
12013 filter
->plist
[FILTER_IN
].name
);
12014 if (filter
->plist
[FILTER_OUT
].name
)
12015 json_object_string_add(json_addr
,
12016 "outgoingUpdatePrefixFilterList",
12017 filter
->plist
[FILTER_OUT
].name
);
12019 /* distribute-list */
12020 if (filter
->dlist
[FILTER_IN
].name
)
12021 json_object_string_add(
12022 json_addr
, "incomingUpdateNetworkFilterList",
12023 filter
->dlist
[FILTER_IN
].name
);
12024 if (filter
->dlist
[FILTER_OUT
].name
)
12025 json_object_string_add(
12026 json_addr
, "outgoingUpdateNetworkFilterList",
12027 filter
->dlist
[FILTER_OUT
].name
);
12030 if (filter
->aslist
[FILTER_IN
].name
)
12031 json_object_string_add(json_addr
,
12032 "incomingUpdateAsPathFilterList",
12033 filter
->aslist
[FILTER_IN
].name
);
12034 if (filter
->aslist
[FILTER_OUT
].name
)
12035 json_object_string_add(json_addr
,
12036 "outgoingUpdateAsPathFilterList",
12037 filter
->aslist
[FILTER_OUT
].name
);
12040 if (filter
->map
[RMAP_IN
].name
)
12041 json_object_string_add(
12042 json_addr
, "routeMapForIncomingAdvertisements",
12043 filter
->map
[RMAP_IN
].name
);
12044 if (filter
->map
[RMAP_OUT
].name
)
12045 json_object_string_add(
12046 json_addr
, "routeMapForOutgoingAdvertisements",
12047 filter
->map
[RMAP_OUT
].name
);
12049 /* ebgp-requires-policy (inbound) */
12050 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12051 && !bgp_inbound_policy_exists(p
, filter
))
12052 json_object_string_add(
12053 json_addr
, "inboundEbgpRequiresPolicy",
12054 "Inbound updates discarded due to missing policy");
12056 /* ebgp-requires-policy (outbound) */
12057 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12058 && (!bgp_outbound_policy_exists(p
, filter
)))
12059 json_object_string_add(
12060 json_addr
, "outboundEbgpRequiresPolicy",
12061 "Outbound updates discarded due to missing policy");
12063 /* unsuppress-map */
12064 if (filter
->usmap
.name
)
12065 json_object_string_add(json_addr
,
12066 "selectiveUnsuppressRouteMap",
12067 filter
->usmap
.name
);
12069 /* advertise-map */
12070 if (filter
->advmap
.aname
) {
12071 json_advmap
= json_object_new_object();
12072 json_object_string_add(json_advmap
, "condition",
12073 filter
->advmap
.condition
12076 json_object_string_add(json_advmap
, "conditionMap",
12077 filter
->advmap
.cname
);
12078 json_object_string_add(json_advmap
, "advertiseMap",
12079 filter
->advmap
.aname
);
12080 json_object_string_add(json_advmap
, "advertiseStatus",
12081 filter
->advmap
.update_type
12085 json_object_object_add(json_addr
, "advertiseMap",
12089 /* Receive prefix count */
12090 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12091 p
->pcount
[afi
][safi
]);
12092 if (paf
&& PAF_SUBGRP(paf
))
12093 json_object_int_add(json_addr
, "sentPrefixCounter",
12094 (PAF_SUBGRP(paf
))->scount
);
12096 /* Maximum prefix */
12097 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12098 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12099 p
->pmax_out
[afi
][safi
]);
12101 /* Maximum prefix */
12102 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12103 json_object_int_add(json_addr
, "prefixAllowedMax",
12104 p
->pmax
[afi
][safi
]);
12105 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12106 PEER_FLAG_MAX_PREFIX_WARNING
))
12107 json_object_boolean_true_add(
12108 json_addr
, "prefixAllowedMaxWarning");
12109 json_object_int_add(json_addr
,
12110 "prefixAllowedWarningThresh",
12111 p
->pmax_threshold
[afi
][safi
]);
12112 if (p
->pmax_restart
[afi
][safi
])
12113 json_object_int_add(
12115 "prefixAllowedRestartIntervalMsecs",
12116 p
->pmax_restart
[afi
][safi
] * 60000);
12118 json_object_object_add(json_neigh
,
12119 get_afi_safi_str(afi
, safi
, true),
12123 filter
= &p
->filter
[afi
][safi
];
12125 vty_out(vty
, " For address family: %s\n",
12126 get_afi_safi_str(afi
, safi
, false));
12128 if (peer_group_active(p
))
12129 vty_out(vty
, " %s peer-group member\n",
12132 paf
= peer_af_find(p
, afi
, safi
);
12133 if (paf
&& PAF_SUBGRP(paf
)) {
12134 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12135 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12136 vty_out(vty
, " Packet Queue length %d\n",
12137 bpacket_queue_virtual_length(paf
));
12139 vty_out(vty
, " Not part of any update group\n");
12141 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12142 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12143 PEER_CAP_ORF_PREFIX_SM_RCV
)
12144 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12145 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12146 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12147 PEER_CAP_ORF_PREFIX_RM_ADV
)
12148 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12149 PEER_CAP_ORF_PREFIX_RM_RCV
)
12150 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12151 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12152 vty_out(vty
, " AF-dependant capabilities:\n");
12154 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12155 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12156 PEER_CAP_ORF_PREFIX_SM_RCV
)
12157 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12158 PEER_CAP_ORF_PREFIX_RM_ADV
)
12159 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12160 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12162 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12164 bgp_show_peer_afi_orf_cap(
12165 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12166 PEER_CAP_ORF_PREFIX_RM_ADV
,
12167 PEER_CAP_ORF_PREFIX_SM_RCV
,
12168 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12170 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12171 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12172 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12173 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12174 PEER_CAP_ORF_PREFIX_RM_ADV
)
12175 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12176 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12178 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12179 ORF_TYPE_PREFIX_OLD
);
12180 bgp_show_peer_afi_orf_cap(
12181 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12182 PEER_CAP_ORF_PREFIX_RM_ADV
,
12183 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12184 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12187 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12188 p
->host
, afi
, safi
);
12189 orf_pfx_count
= prefix_bgp_show_prefix_list(
12190 NULL
, afi
, orf_pfx_name
, use_json
);
12192 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12193 PEER_STATUS_ORF_PREFIX_SEND
)
12194 || orf_pfx_count
) {
12195 vty_out(vty
, " Outbound Route Filter (ORF):");
12196 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12197 PEER_STATUS_ORF_PREFIX_SEND
))
12198 vty_out(vty
, " sent;");
12200 vty_out(vty
, " received (%d entries)",
12202 vty_out(vty
, "\n");
12204 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12205 PEER_STATUS_ORF_WAIT_REFRESH
))
12207 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12209 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12210 PEER_FLAG_REFLECTOR_CLIENT
))
12211 vty_out(vty
, " Route-Reflector Client\n");
12212 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12213 PEER_FLAG_RSERVER_CLIENT
))
12214 vty_out(vty
, " Route-Server Client\n");
12215 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12217 " Inbound soft reconfiguration allowed\n");
12219 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12220 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12222 " Private AS numbers (all) replaced in updates to this neighbor\n");
12223 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12224 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12226 " Private AS numbers replaced in updates to this neighbor\n");
12227 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12228 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12230 " Private AS numbers (all) removed in updates to this neighbor\n");
12231 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12232 PEER_FLAG_REMOVE_PRIVATE_AS
))
12234 " Private AS numbers removed in updates to this neighbor\n");
12236 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12237 vty_out(vty
, " %s\n",
12238 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12239 ->human_description
);
12241 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12243 " Override ASNs in outbound updates if aspath equals remote-as\n");
12245 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12246 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12247 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12248 vty_out(vty
, " NEXT_HOP is always this router\n");
12249 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12250 PEER_FLAG_AS_PATH_UNCHANGED
))
12252 " AS_PATH is propagated unchanged to this neighbor\n");
12253 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12254 PEER_FLAG_NEXTHOP_UNCHANGED
))
12256 " NEXT_HOP is propagated unchanged to this neighbor\n");
12257 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12259 " MED is propagated unchanged to this neighbor\n");
12260 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12261 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12262 PEER_FLAG_SEND_EXT_COMMUNITY
)
12263 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12264 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12266 " Community attribute sent to this neighbor");
12267 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12268 PEER_FLAG_SEND_COMMUNITY
)
12269 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12270 PEER_FLAG_SEND_EXT_COMMUNITY
)
12271 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12272 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12273 vty_out(vty
, "(all)\n");
12274 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12275 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12276 vty_out(vty
, "(large)\n");
12277 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12278 PEER_FLAG_SEND_EXT_COMMUNITY
))
12279 vty_out(vty
, "(extended)\n");
12281 vty_out(vty
, "(standard)\n");
12283 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12284 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12285 vty_out(vty
, " Default information originate,");
12287 if (p
->default_rmap
[afi
][safi
].name
)
12288 vty_out(vty
, " default route-map %s%s,",
12289 p
->default_rmap
[afi
][safi
].map
? "*"
12291 p
->default_rmap
[afi
][safi
].name
);
12292 if (paf
&& PAF_SUBGRP(paf
)
12293 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12294 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12295 vty_out(vty
, " default sent\n");
12297 vty_out(vty
, " default not sent\n");
12300 /* advertise-vni-all */
12301 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12302 if (is_evpn_enabled())
12303 vty_out(vty
, " advertise-all-vni\n");
12306 if (filter
->plist
[FILTER_IN
].name
12307 || filter
->dlist
[FILTER_IN
].name
12308 || filter
->aslist
[FILTER_IN
].name
12309 || filter
->map
[RMAP_IN
].name
)
12310 vty_out(vty
, " Inbound path policy configured\n");
12311 if (filter
->plist
[FILTER_OUT
].name
12312 || filter
->dlist
[FILTER_OUT
].name
12313 || filter
->aslist
[FILTER_OUT
].name
12314 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12315 vty_out(vty
, " Outbound path policy configured\n");
12318 if (filter
->plist
[FILTER_IN
].name
)
12320 " Incoming update prefix filter list is %s%s\n",
12321 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12322 filter
->plist
[FILTER_IN
].name
);
12323 if (filter
->plist
[FILTER_OUT
].name
)
12325 " Outgoing update prefix filter list is %s%s\n",
12326 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12327 filter
->plist
[FILTER_OUT
].name
);
12329 /* distribute-list */
12330 if (filter
->dlist
[FILTER_IN
].name
)
12332 " Incoming update network filter list is %s%s\n",
12333 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12334 filter
->dlist
[FILTER_IN
].name
);
12335 if (filter
->dlist
[FILTER_OUT
].name
)
12337 " Outgoing update network filter list is %s%s\n",
12338 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12339 filter
->dlist
[FILTER_OUT
].name
);
12342 if (filter
->aslist
[FILTER_IN
].name
)
12344 " Incoming update AS path filter list is %s%s\n",
12345 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12346 filter
->aslist
[FILTER_IN
].name
);
12347 if (filter
->aslist
[FILTER_OUT
].name
)
12349 " Outgoing update AS path filter list is %s%s\n",
12350 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12351 filter
->aslist
[FILTER_OUT
].name
);
12354 if (filter
->map
[RMAP_IN
].name
)
12356 " Route map for incoming advertisements is %s%s\n",
12357 filter
->map
[RMAP_IN
].map
? "*" : "",
12358 filter
->map
[RMAP_IN
].name
);
12359 if (filter
->map
[RMAP_OUT
].name
)
12361 " Route map for outgoing advertisements is %s%s\n",
12362 filter
->map
[RMAP_OUT
].map
? "*" : "",
12363 filter
->map
[RMAP_OUT
].name
);
12365 /* ebgp-requires-policy (inbound) */
12366 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12367 && !bgp_inbound_policy_exists(p
, filter
))
12369 " Inbound updates discarded due to missing policy\n");
12371 /* ebgp-requires-policy (outbound) */
12372 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12373 && !bgp_outbound_policy_exists(p
, filter
))
12375 " Outbound updates discarded due to missing policy\n");
12377 /* unsuppress-map */
12378 if (filter
->usmap
.name
)
12380 " Route map for selective unsuppress is %s%s\n",
12381 filter
->usmap
.map
? "*" : "",
12382 filter
->usmap
.name
);
12384 /* advertise-map */
12385 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12387 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12388 filter
->advmap
.condition
? "EXIST"
12390 filter
->advmap
.cmap
? "*" : "",
12391 filter
->advmap
.cname
,
12392 filter
->advmap
.amap
? "*" : "",
12393 filter
->advmap
.aname
,
12394 filter
->advmap
.update_type
== ADVERTISE
12398 /* Receive prefix count */
12399 vty_out(vty
, " %u accepted prefixes\n",
12400 p
->pcount
[afi
][safi
]);
12402 /* maximum-prefix-out */
12403 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12404 PEER_FLAG_MAX_PREFIX_OUT
))
12406 " Maximum allowed prefixes sent %u\n",
12407 p
->pmax_out
[afi
][safi
]);
12409 /* Maximum prefix */
12410 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12412 " Maximum prefixes allowed %u%s\n",
12413 p
->pmax
[afi
][safi
],
12414 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12415 PEER_FLAG_MAX_PREFIX_WARNING
)
12416 ? " (warning-only)"
12418 vty_out(vty
, " Threshold for warning message %d%%",
12419 p
->pmax_threshold
[afi
][safi
]);
12420 if (p
->pmax_restart
[afi
][safi
])
12421 vty_out(vty
, ", restart interval %d min",
12422 p
->pmax_restart
[afi
][safi
]);
12423 vty_out(vty
, "\n");
12426 vty_out(vty
, "\n");
12430 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12434 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
12435 char timebuf
[BGP_UPTIME_LEN
];
12441 json_object
*json_neigh
= NULL
;
12447 json_neigh
= json_object_new_object();
12449 memset(dn_flag
, '\0', sizeof(dn_flag
));
12450 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12454 if (p
->conf_if
) /* Configured interface name. */
12455 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
12456 BGP_PEER_SU_UNSPEC(p
)
12458 : sockunion2str(&p
->su
, buf
,
12460 else /* Configured IP address. */
12461 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12466 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12467 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12469 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12470 json_object_string_add(
12471 json_neigh
, "bgpNeighborAddr",
12472 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
12474 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12476 if (p
->change_local_as
)
12477 json_object_int_add(json_neigh
, "localAs",
12478 p
->change_local_as
);
12480 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12482 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12483 json_object_boolean_true_add(json_neigh
,
12484 "localAsNoPrepend");
12486 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12487 json_object_boolean_true_add(json_neigh
,
12488 "localAsReplaceAs");
12490 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12491 || (p
->as_type
== AS_INTERNAL
))
12492 vty_out(vty
, "remote AS %u, ", p
->as
);
12494 vty_out(vty
, "remote AS Unspecified, ");
12495 vty_out(vty
, "local AS %u%s%s, ",
12496 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12497 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12500 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12504 /* peer type internal or confed-internal */
12505 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12507 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12508 json_object_boolean_true_add(
12509 json_neigh
, "nbrConfedInternalLink");
12511 json_object_boolean_true_add(json_neigh
,
12512 "nbrInternalLink");
12514 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12515 vty_out(vty
, "confed-internal link\n");
12517 vty_out(vty
, "internal link\n");
12519 /* peer type external or confed-external */
12520 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12522 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12523 json_object_boolean_true_add(
12524 json_neigh
, "nbrConfedExternalLink");
12526 json_object_boolean_true_add(json_neigh
,
12527 "nbrExternalLink");
12529 if (bgp_confederation_peers_check(bgp
, p
->as
))
12530 vty_out(vty
, "confed-external link\n");
12532 vty_out(vty
, "external link\n");
12536 json_object_boolean_true_add(json_neigh
,
12537 "nbrUnspecifiedLink");
12539 vty_out(vty
, "unspecified link\n");
12545 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12547 vty_out(vty
, " Description: %s\n", p
->desc
);
12553 json_object_string_add(json_neigh
, "hostname",
12557 json_object_string_add(json_neigh
, "domainname",
12560 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12561 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12564 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12571 json_object_string_add(json_neigh
, "peerGroup",
12575 struct prefix prefix
, *range
= NULL
;
12577 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12578 range
= peer_group_lookup_dynamic_neighbor_range(
12579 p
->group
, &prefix
);
12582 prefix2str(range
, buf1
, sizeof(buf1
));
12583 json_object_string_add(
12585 "peerSubnetRangeGroup", buf1
);
12590 " Member of peer-group %s for session parameters\n",
12594 struct prefix prefix
, *range
= NULL
;
12596 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12597 range
= peer_group_lookup_dynamic_neighbor_range(
12598 p
->group
, &prefix
);
12602 " Belongs to the subnet range group: %pFX\n",
12610 /* Administrative shutdown. */
12611 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12612 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12613 json_object_boolean_true_add(json_neigh
,
12617 json_object_int_add(json_neigh
, "bgpVersion", 4);
12618 json_object_string_add(
12619 json_neigh
, "remoteRouterId",
12620 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12621 json_object_string_add(
12622 json_neigh
, "localRouterId",
12623 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12626 /* Confederation */
12627 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12628 && bgp_confederation_peers_check(bgp
, p
->as
))
12629 json_object_boolean_true_add(json_neigh
,
12633 json_object_string_add(
12634 json_neigh
, "bgpState",
12635 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12637 if (p
->status
== Established
) {
12640 uptime
= bgp_clock();
12641 uptime
-= p
->uptime
;
12642 epoch_tbuf
= time(NULL
) - uptime
;
12644 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
12646 json_object_string_add(json_neigh
, "bgpTimerUpString",
12647 peer_uptime(p
->uptime
, timebuf
,
12650 json_object_int_add(json_neigh
,
12651 "bgpTimerUpEstablishedEpoch",
12655 else if (p
->status
== Active
) {
12656 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12657 json_object_string_add(json_neigh
, "bgpStateIs",
12659 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12660 json_object_string_add(json_neigh
, "bgpStateIs",
12668 uptime
= bgp_clock();
12669 uptime
-= p
->readtime
;
12670 gmtime_r(&uptime
, &tm
);
12672 json_object_int_add(json_neigh
, "bgpTimerLastRead",
12673 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12674 + (tm
.tm_hour
* 3600000));
12676 uptime
= bgp_clock();
12677 uptime
-= p
->last_write
;
12678 gmtime_r(&uptime
, &tm
);
12680 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
12681 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12682 + (tm
.tm_hour
* 3600000));
12684 uptime
= bgp_clock();
12685 uptime
-= p
->update_time
;
12686 gmtime_r(&uptime
, &tm
);
12688 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
12689 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12690 + (tm
.tm_hour
* 3600000));
12692 /* Configured timer values. */
12693 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
12694 p
->v_holdtime
* 1000);
12695 json_object_int_add(json_neigh
,
12696 "bgpTimerKeepAliveIntervalMsecs",
12697 p
->v_keepalive
* 1000);
12698 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
12699 json_object_int_add(json_neigh
,
12700 "bgpTimerDelayOpenTimeMsecs",
12701 p
->v_delayopen
* 1000);
12704 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12705 json_object_int_add(json_neigh
,
12706 "bgpTimerConfiguredHoldTimeMsecs",
12707 p
->holdtime
* 1000);
12708 json_object_int_add(
12710 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12711 p
->keepalive
* 1000);
12712 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12713 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12714 json_object_int_add(json_neigh
,
12715 "bgpTimerConfiguredHoldTimeMsecs",
12716 bgp
->default_holdtime
);
12717 json_object_int_add(
12719 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12720 bgp
->default_keepalive
);
12723 /* Administrative shutdown. */
12724 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12725 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12726 vty_out(vty
, " Administratively shut down\n");
12729 vty_out(vty
, " BGP version 4");
12730 vty_out(vty
, ", remote router ID %s",
12731 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12732 vty_out(vty
, ", local router ID %s\n",
12733 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12736 /* Confederation */
12737 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12738 && bgp_confederation_peers_check(bgp
, p
->as
))
12740 " Neighbor under common administration\n");
12743 vty_out(vty
, " BGP state = %s",
12744 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12746 if (p
->status
== Established
)
12747 vty_out(vty
, ", up for %8s",
12748 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
12751 else if (p
->status
== Active
) {
12752 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12753 vty_out(vty
, " (passive)");
12754 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12755 vty_out(vty
, " (NSF passive)");
12757 vty_out(vty
, "\n");
12760 vty_out(vty
, " Last read %s",
12761 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
12763 vty_out(vty
, ", Last write %s\n",
12764 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
12767 /* Configured timer values. */
12769 " Hold time is %d, keepalive interval is %d seconds\n",
12770 p
->v_holdtime
, p
->v_keepalive
);
12771 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12772 vty_out(vty
, " Configured hold time is %d",
12774 vty_out(vty
, ", keepalive interval is %d seconds\n",
12776 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12777 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12778 vty_out(vty
, " Configured hold time is %d",
12779 bgp
->default_holdtime
);
12780 vty_out(vty
, ", keepalive interval is %d seconds\n",
12781 bgp
->default_keepalive
);
12783 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
12785 " Configured DelayOpenTime is %d seconds\n",
12789 if (p
->status
== Established
) {
12790 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
12791 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
12792 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
12793 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
12794 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
12795 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
12796 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
12797 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
12798 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
12799 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
12800 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
12801 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
12802 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
12803 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
12804 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
12805 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
12806 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
12807 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
12808 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
12809 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
12811 json_object
*json_cap
= NULL
;
12813 json_cap
= json_object_new_object();
12816 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
12817 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
12818 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
12819 && CHECK_FLAG(p
->cap
,
12821 json_object_string_add(
12822 json_cap
, "4byteAs",
12823 "advertisedAndReceived");
12824 else if (CHECK_FLAG(p
->cap
,
12826 json_object_string_add(
12827 json_cap
, "4byteAs",
12829 else if (CHECK_FLAG(p
->cap
,
12831 json_object_string_add(
12832 json_cap
, "4byteAs",
12837 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
12838 || CHECK_FLAG(p
->cap
,
12839 PEER_CAP_ADDPATH_ADV
)) {
12840 json_object
*json_add
= NULL
;
12841 const char *print_store
;
12843 json_add
= json_object_new_object();
12845 FOREACH_AFI_SAFI (afi
, safi
) {
12846 json_object
*json_sub
= NULL
;
12848 json_object_new_object();
12849 print_store
= get_afi_safi_str(
12855 PEER_CAP_ADDPATH_AF_TX_ADV
)
12859 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
12864 PEER_CAP_ADDPATH_AF_TX_ADV
)
12869 PEER_CAP_ADDPATH_AF_TX_RCV
))
12870 json_object_boolean_true_add(
12872 "txAdvertisedAndReceived");
12878 PEER_CAP_ADDPATH_AF_TX_ADV
))
12879 json_object_boolean_true_add(
12887 PEER_CAP_ADDPATH_AF_TX_RCV
))
12888 json_object_boolean_true_add(
12896 PEER_CAP_ADDPATH_AF_RX_ADV
)
12900 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
12905 PEER_CAP_ADDPATH_AF_RX_ADV
)
12910 PEER_CAP_ADDPATH_AF_RX_RCV
))
12911 json_object_boolean_true_add(
12913 "rxAdvertisedAndReceived");
12919 PEER_CAP_ADDPATH_AF_RX_ADV
))
12920 json_object_boolean_true_add(
12928 PEER_CAP_ADDPATH_AF_RX_RCV
))
12929 json_object_boolean_true_add(
12937 PEER_CAP_ADDPATH_AF_TX_ADV
)
12941 PEER_CAP_ADDPATH_AF_TX_RCV
)
12945 PEER_CAP_ADDPATH_AF_RX_ADV
)
12949 PEER_CAP_ADDPATH_AF_RX_RCV
))
12950 json_object_object_add(
12959 json_object_object_add(
12960 json_cap
, "addPath", json_add
);
12964 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
12965 || CHECK_FLAG(p
->cap
,
12966 PEER_CAP_DYNAMIC_ADV
)) {
12967 if (CHECK_FLAG(p
->cap
,
12968 PEER_CAP_DYNAMIC_ADV
)
12969 && CHECK_FLAG(p
->cap
,
12970 PEER_CAP_DYNAMIC_RCV
))
12971 json_object_string_add(
12972 json_cap
, "dynamic",
12973 "advertisedAndReceived");
12974 else if (CHECK_FLAG(
12976 PEER_CAP_DYNAMIC_ADV
))
12977 json_object_string_add(
12978 json_cap
, "dynamic",
12980 else if (CHECK_FLAG(
12982 PEER_CAP_DYNAMIC_RCV
))
12983 json_object_string_add(
12984 json_cap
, "dynamic",
12988 /* Extended nexthop */
12989 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
12990 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
12991 json_object
*json_nxt
= NULL
;
12992 const char *print_store
;
12995 if (CHECK_FLAG(p
->cap
,
12997 && CHECK_FLAG(p
->cap
,
12998 PEER_CAP_ENHE_RCV
))
12999 json_object_string_add(
13002 "advertisedAndReceived");
13003 else if (CHECK_FLAG(p
->cap
,
13004 PEER_CAP_ENHE_ADV
))
13005 json_object_string_add(
13009 else if (CHECK_FLAG(p
->cap
,
13010 PEER_CAP_ENHE_RCV
))
13011 json_object_string_add(
13016 if (CHECK_FLAG(p
->cap
,
13017 PEER_CAP_ENHE_RCV
)) {
13019 json_object_new_object();
13021 for (safi
= SAFI_UNICAST
;
13022 safi
< SAFI_MAX
; safi
++) {
13027 PEER_CAP_ENHE_AF_RCV
)) {
13028 print_store
= get_afi_safi_str(
13031 json_object_string_add(
13034 "recieved"); /* misspelled for compatibility */
13037 json_object_object_add(
13039 "extendedNexthopFamililesByPeer",
13044 /* Route Refresh */
13045 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
13046 || CHECK_FLAG(p
->cap
,
13047 PEER_CAP_REFRESH_NEW_RCV
)
13048 || CHECK_FLAG(p
->cap
,
13049 PEER_CAP_REFRESH_OLD_RCV
)) {
13050 if (CHECK_FLAG(p
->cap
,
13051 PEER_CAP_REFRESH_ADV
)
13054 PEER_CAP_REFRESH_NEW_RCV
)
13057 PEER_CAP_REFRESH_OLD_RCV
))) {
13060 PEER_CAP_REFRESH_OLD_RCV
)
13063 PEER_CAP_REFRESH_NEW_RCV
))
13064 json_object_string_add(
13067 "advertisedAndReceivedOldNew");
13071 PEER_CAP_REFRESH_OLD_RCV
))
13072 json_object_string_add(
13075 "advertisedAndReceivedOld");
13077 json_object_string_add(
13080 "advertisedAndReceivedNew");
13085 PEER_CAP_REFRESH_ADV
))
13086 json_object_string_add(
13093 PEER_CAP_REFRESH_NEW_RCV
)
13096 PEER_CAP_REFRESH_OLD_RCV
))
13097 json_object_string_add(
13103 /* Multiprotocol Extensions */
13104 json_object
*json_multi
= NULL
;
13105 json_multi
= json_object_new_object();
13107 FOREACH_AFI_SAFI (afi
, safi
) {
13108 if (p
->afc_adv
[afi
][safi
]
13109 || p
->afc_recv
[afi
][safi
]) {
13110 json_object
*json_exten
= NULL
;
13112 json_object_new_object();
13114 if (p
->afc_adv
[afi
][safi
]
13115 && p
->afc_recv
[afi
][safi
])
13116 json_object_boolean_true_add(
13118 "advertisedAndReceived");
13119 else if (p
->afc_adv
[afi
][safi
])
13120 json_object_boolean_true_add(
13123 else if (p
->afc_recv
[afi
][safi
])
13124 json_object_boolean_true_add(
13128 json_object_object_add(
13130 get_afi_safi_str(afi
,
13136 json_object_object_add(
13137 json_cap
, "multiprotocolExtensions",
13140 /* Hostname capabilities */
13141 json_object
*json_hname
= NULL
;
13143 json_hname
= json_object_new_object();
13145 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13146 json_object_string_add(
13147 json_hname
, "advHostName",
13148 bgp
->peer_self
->hostname
13152 json_object_string_add(
13153 json_hname
, "advDomainName",
13154 bgp
->peer_self
->domainname
13161 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13162 json_object_string_add(
13163 json_hname
, "rcvHostName",
13164 p
->hostname
? p
->hostname
13166 json_object_string_add(
13167 json_hname
, "rcvDomainName",
13168 p
->domainname
? p
->domainname
13172 json_object_object_add(json_cap
, "hostName",
13175 /* Gracefull Restart */
13176 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
13177 || CHECK_FLAG(p
->cap
,
13178 PEER_CAP_RESTART_ADV
)) {
13179 if (CHECK_FLAG(p
->cap
,
13180 PEER_CAP_RESTART_ADV
)
13181 && CHECK_FLAG(p
->cap
,
13182 PEER_CAP_RESTART_RCV
))
13183 json_object_string_add(
13186 "advertisedAndReceived");
13187 else if (CHECK_FLAG(
13189 PEER_CAP_RESTART_ADV
))
13190 json_object_string_add(
13192 "gracefulRestartCapability",
13194 else if (CHECK_FLAG(
13196 PEER_CAP_RESTART_RCV
))
13197 json_object_string_add(
13199 "gracefulRestartCapability",
13202 if (CHECK_FLAG(p
->cap
,
13203 PEER_CAP_RESTART_RCV
)) {
13204 int restart_af_count
= 0;
13205 json_object
*json_restart
=
13208 json_object_new_object();
13210 json_object_int_add(
13212 "gracefulRestartRemoteTimerMsecs",
13213 p
->v_gr_restart
* 1000);
13215 FOREACH_AFI_SAFI (afi
, safi
) {
13220 PEER_CAP_RESTART_AF_RCV
)) {
13225 json_object_new_object();
13231 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13232 json_object_boolean_true_add(
13235 restart_af_count
++;
13236 json_object_object_add(
13245 if (!restart_af_count
) {
13246 json_object_string_add(
13248 "addressFamiliesByPeer",
13253 json_object_object_add(
13255 "addressFamiliesByPeer",
13259 json_object_object_add(json_neigh
,
13260 "neighborCapabilities",
13263 vty_out(vty
, " Neighbor capabilities:\n");
13266 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
13267 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13268 vty_out(vty
, " 4 Byte AS:");
13269 if (CHECK_FLAG(p
->cap
,
13271 vty_out(vty
, " advertised");
13272 if (CHECK_FLAG(p
->cap
,
13274 vty_out(vty
, " %sreceived",
13280 vty_out(vty
, "\n");
13284 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
13285 || CHECK_FLAG(p
->cap
,
13286 PEER_CAP_ADDPATH_ADV
)) {
13287 vty_out(vty
, " AddPath:\n");
13289 FOREACH_AFI_SAFI (afi
, safi
) {
13293 PEER_CAP_ADDPATH_AF_TX_ADV
)
13297 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13309 PEER_CAP_ADDPATH_AF_TX_ADV
))
13321 PEER_CAP_ADDPATH_AF_TX_RCV
))
13328 PEER_CAP_ADDPATH_AF_TX_ADV
)
13332 vty_out(vty
, "\n");
13338 PEER_CAP_ADDPATH_AF_RX_ADV
)
13342 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13354 PEER_CAP_ADDPATH_AF_RX_ADV
))
13366 PEER_CAP_ADDPATH_AF_RX_RCV
))
13373 PEER_CAP_ADDPATH_AF_RX_ADV
)
13377 vty_out(vty
, "\n");
13383 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
13384 || CHECK_FLAG(p
->cap
,
13385 PEER_CAP_DYNAMIC_ADV
)) {
13386 vty_out(vty
, " Dynamic:");
13387 if (CHECK_FLAG(p
->cap
,
13388 PEER_CAP_DYNAMIC_ADV
))
13389 vty_out(vty
, " advertised");
13390 if (CHECK_FLAG(p
->cap
,
13391 PEER_CAP_DYNAMIC_RCV
))
13392 vty_out(vty
, " %sreceived",
13395 PEER_CAP_DYNAMIC_ADV
)
13398 vty_out(vty
, "\n");
13401 /* Extended nexthop */
13402 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
13403 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13404 vty_out(vty
, " Extended nexthop:");
13405 if (CHECK_FLAG(p
->cap
,
13406 PEER_CAP_ENHE_ADV
))
13407 vty_out(vty
, " advertised");
13408 if (CHECK_FLAG(p
->cap
,
13409 PEER_CAP_ENHE_RCV
))
13410 vty_out(vty
, " %sreceived",
13416 vty_out(vty
, "\n");
13418 if (CHECK_FLAG(p
->cap
,
13419 PEER_CAP_ENHE_RCV
)) {
13421 " Address families by peer:\n ");
13422 for (safi
= SAFI_UNICAST
;
13423 safi
< SAFI_MAX
; safi
++)
13428 PEER_CAP_ENHE_AF_RCV
))
13438 /* Route Refresh */
13439 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
13440 || CHECK_FLAG(p
->cap
,
13441 PEER_CAP_REFRESH_NEW_RCV
)
13442 || CHECK_FLAG(p
->cap
,
13443 PEER_CAP_REFRESH_OLD_RCV
)) {
13444 vty_out(vty
, " Route refresh:");
13445 if (CHECK_FLAG(p
->cap
,
13446 PEER_CAP_REFRESH_ADV
))
13447 vty_out(vty
, " advertised");
13448 if (CHECK_FLAG(p
->cap
,
13449 PEER_CAP_REFRESH_NEW_RCV
)
13452 PEER_CAP_REFRESH_OLD_RCV
))
13453 vty_out(vty
, " %sreceived(%s)",
13456 PEER_CAP_REFRESH_ADV
)
13461 PEER_CAP_REFRESH_OLD_RCV
)
13464 PEER_CAP_REFRESH_NEW_RCV
))
13468 PEER_CAP_REFRESH_OLD_RCV
)
13472 vty_out(vty
, "\n");
13475 /* Multiprotocol Extensions */
13476 FOREACH_AFI_SAFI (afi
, safi
)
13477 if (p
->afc_adv
[afi
][safi
]
13478 || p
->afc_recv
[afi
][safi
]) {
13480 " Address Family %s:",
13485 if (p
->afc_adv
[afi
][safi
])
13488 if (p
->afc_recv
[afi
][safi
])
13495 vty_out(vty
, "\n");
13498 /* Hostname capability */
13499 vty_out(vty
, " Hostname Capability:");
13501 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13503 " advertised (name: %s,domain name: %s)",
13504 bgp
->peer_self
->hostname
13508 bgp
->peer_self
->domainname
13513 vty_out(vty
, " not advertised");
13516 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13518 " received (name: %s,domain name: %s)",
13519 p
->hostname
? p
->hostname
13521 p
->domainname
? p
->domainname
13524 vty_out(vty
, " not received");
13527 vty_out(vty
, "\n");
13529 /* Graceful Restart */
13530 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
13531 || CHECK_FLAG(p
->cap
,
13532 PEER_CAP_RESTART_ADV
)) {
13534 " Graceful Restart Capability:");
13535 if (CHECK_FLAG(p
->cap
,
13536 PEER_CAP_RESTART_ADV
))
13537 vty_out(vty
, " advertised");
13538 if (CHECK_FLAG(p
->cap
,
13539 PEER_CAP_RESTART_RCV
))
13540 vty_out(vty
, " %sreceived",
13543 PEER_CAP_RESTART_ADV
)
13546 vty_out(vty
, "\n");
13548 if (CHECK_FLAG(p
->cap
,
13549 PEER_CAP_RESTART_RCV
)) {
13550 int restart_af_count
= 0;
13553 " Remote Restart timer is %d seconds\n",
13556 " Address families by peer:\n ");
13558 FOREACH_AFI_SAFI (afi
, safi
)
13563 PEER_CAP_RESTART_AF_RCV
)) {
13577 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13579 : "not preserved");
13580 restart_af_count
++;
13582 if (!restart_af_count
)
13583 vty_out(vty
, "none");
13584 vty_out(vty
, "\n");
13586 } /* Gracefull Restart */
13591 /* graceful restart information */
13592 json_object
*json_grace
= NULL
;
13593 json_object
*json_grace_send
= NULL
;
13594 json_object
*json_grace_recv
= NULL
;
13595 int eor_send_af_count
= 0;
13596 int eor_receive_af_count
= 0;
13599 json_grace
= json_object_new_object();
13600 json_grace_send
= json_object_new_object();
13601 json_grace_recv
= json_object_new_object();
13603 if ((p
->status
== Established
)
13604 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13605 FOREACH_AFI_SAFI (afi
, safi
) {
13606 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13607 PEER_STATUS_EOR_SEND
)) {
13608 json_object_boolean_true_add(
13610 get_afi_safi_str(afi
,
13613 eor_send_af_count
++;
13616 FOREACH_AFI_SAFI (afi
, safi
) {
13618 p
->af_sflags
[afi
][safi
],
13619 PEER_STATUS_EOR_RECEIVED
)) {
13620 json_object_boolean_true_add(
13622 get_afi_safi_str(afi
,
13625 eor_receive_af_count
++;
13629 json_object_object_add(json_grace
, "endOfRibSend",
13631 json_object_object_add(json_grace
, "endOfRibRecv",
13635 if (p
->t_gr_restart
)
13636 json_object_int_add(json_grace
,
13637 "gracefulRestartTimerMsecs",
13638 thread_timer_remain_second(
13643 json_object_int_add(
13645 "gracefulStalepathTimerMsecs",
13646 thread_timer_remain_second(
13649 /* more gr info in new format */
13650 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
,
13652 json_object_object_add(
13653 json_neigh
, "gracefulRestartInfo", json_grace
);
13655 vty_out(vty
, " Graceful restart information:\n");
13656 if ((p
->status
== Established
)
13657 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13659 vty_out(vty
, " End-of-RIB send: ");
13660 FOREACH_AFI_SAFI (afi
, safi
) {
13661 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13662 PEER_STATUS_EOR_SEND
)) {
13663 vty_out(vty
, "%s%s",
13664 eor_send_af_count
? ", "
13669 eor_send_af_count
++;
13672 vty_out(vty
, "\n");
13673 vty_out(vty
, " End-of-RIB received: ");
13674 FOREACH_AFI_SAFI (afi
, safi
) {
13676 p
->af_sflags
[afi
][safi
],
13677 PEER_STATUS_EOR_RECEIVED
)) {
13678 vty_out(vty
, "%s%s",
13679 eor_receive_af_count
13682 get_afi_safi_str(afi
,
13685 eor_receive_af_count
++;
13688 vty_out(vty
, "\n");
13691 if (p
->t_gr_restart
)
13693 " The remaining time of restart timer is %ld\n",
13694 thread_timer_remain_second(
13699 " The remaining time of stalepath timer is %ld\n",
13700 thread_timer_remain_second(
13703 /* more gr info in new format */
13704 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
13708 json_object
*json_stat
= NULL
;
13709 json_stat
= json_object_new_object();
13710 /* Packet counts. */
13712 atomic_size_t outq_count
, inq_count
;
13713 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13714 memory_order_relaxed
);
13715 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13716 memory_order_relaxed
);
13718 json_object_int_add(json_stat
, "depthInq",
13719 (unsigned long)inq_count
);
13720 json_object_int_add(json_stat
, "depthOutq",
13721 (unsigned long)outq_count
);
13722 json_object_int_add(json_stat
, "opensSent",
13723 atomic_load_explicit(&p
->open_out
,
13724 memory_order_relaxed
));
13725 json_object_int_add(json_stat
, "opensRecv",
13726 atomic_load_explicit(&p
->open_in
,
13727 memory_order_relaxed
));
13728 json_object_int_add(json_stat
, "notificationsSent",
13729 atomic_load_explicit(&p
->notify_out
,
13730 memory_order_relaxed
));
13731 json_object_int_add(json_stat
, "notificationsRecv",
13732 atomic_load_explicit(&p
->notify_in
,
13733 memory_order_relaxed
));
13734 json_object_int_add(json_stat
, "updatesSent",
13735 atomic_load_explicit(&p
->update_out
,
13736 memory_order_relaxed
));
13737 json_object_int_add(json_stat
, "updatesRecv",
13738 atomic_load_explicit(&p
->update_in
,
13739 memory_order_relaxed
));
13740 json_object_int_add(json_stat
, "keepalivesSent",
13741 atomic_load_explicit(&p
->keepalive_out
,
13742 memory_order_relaxed
));
13743 json_object_int_add(json_stat
, "keepalivesRecv",
13744 atomic_load_explicit(&p
->keepalive_in
,
13745 memory_order_relaxed
));
13746 json_object_int_add(json_stat
, "routeRefreshSent",
13747 atomic_load_explicit(&p
->refresh_out
,
13748 memory_order_relaxed
));
13749 json_object_int_add(json_stat
, "routeRefreshRecv",
13750 atomic_load_explicit(&p
->refresh_in
,
13751 memory_order_relaxed
));
13752 json_object_int_add(json_stat
, "capabilitySent",
13753 atomic_load_explicit(&p
->dynamic_cap_out
,
13754 memory_order_relaxed
));
13755 json_object_int_add(json_stat
, "capabilityRecv",
13756 atomic_load_explicit(&p
->dynamic_cap_in
,
13757 memory_order_relaxed
));
13758 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
13759 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
13760 json_object_object_add(json_neigh
, "messageStats", json_stat
);
13762 atomic_size_t outq_count
, inq_count
;
13763 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13764 memory_order_relaxed
);
13765 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13766 memory_order_relaxed
);
13768 /* Packet counts. */
13769 vty_out(vty
, " Message statistics:\n");
13770 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
13771 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
13772 vty_out(vty
, " Sent Rcvd\n");
13773 vty_out(vty
, " Opens: %10d %10d\n",
13774 atomic_load_explicit(&p
->open_out
,
13775 memory_order_relaxed
),
13776 atomic_load_explicit(&p
->open_in
,
13777 memory_order_relaxed
));
13778 vty_out(vty
, " Notifications: %10d %10d\n",
13779 atomic_load_explicit(&p
->notify_out
,
13780 memory_order_relaxed
),
13781 atomic_load_explicit(&p
->notify_in
,
13782 memory_order_relaxed
));
13783 vty_out(vty
, " Updates: %10d %10d\n",
13784 atomic_load_explicit(&p
->update_out
,
13785 memory_order_relaxed
),
13786 atomic_load_explicit(&p
->update_in
,
13787 memory_order_relaxed
));
13788 vty_out(vty
, " Keepalives: %10d %10d\n",
13789 atomic_load_explicit(&p
->keepalive_out
,
13790 memory_order_relaxed
),
13791 atomic_load_explicit(&p
->keepalive_in
,
13792 memory_order_relaxed
));
13793 vty_out(vty
, " Route Refresh: %10d %10d\n",
13794 atomic_load_explicit(&p
->refresh_out
,
13795 memory_order_relaxed
),
13796 atomic_load_explicit(&p
->refresh_in
,
13797 memory_order_relaxed
));
13798 vty_out(vty
, " Capability: %10d %10d\n",
13799 atomic_load_explicit(&p
->dynamic_cap_out
,
13800 memory_order_relaxed
),
13801 atomic_load_explicit(&p
->dynamic_cap_in
,
13802 memory_order_relaxed
));
13803 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
13808 /* advertisement-interval */
13809 json_object_int_add(json_neigh
,
13810 "minBtwnAdvertisementRunsTimerMsecs",
13811 p
->v_routeadv
* 1000);
13813 /* Update-source. */
13814 if (p
->update_if
|| p
->update_source
) {
13816 json_object_string_add(json_neigh
,
13819 else if (p
->update_source
)
13820 json_object_string_add(
13821 json_neigh
, "updateSource",
13822 sockunion2str(p
->update_source
, buf1
,
13826 /* advertisement-interval */
13828 " Minimum time between advertisement runs is %d seconds\n",
13831 /* Update-source. */
13832 if (p
->update_if
|| p
->update_source
) {
13833 vty_out(vty
, " Update source is ");
13835 vty_out(vty
, "%s", p
->update_if
);
13836 else if (p
->update_source
)
13838 sockunion2str(p
->update_source
, buf1
,
13840 vty_out(vty
, "\n");
13843 vty_out(vty
, "\n");
13846 /* Address Family Information */
13847 json_object
*json_hold
= NULL
;
13850 json_hold
= json_object_new_object();
13852 FOREACH_AFI_SAFI (afi
, safi
)
13853 if (p
->afc
[afi
][safi
])
13854 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
13858 json_object_object_add(json_neigh
, "addressFamilyInfo",
13860 json_object_int_add(json_neigh
, "connectionsEstablished",
13862 json_object_int_add(json_neigh
, "connectionsDropped",
13865 vty_out(vty
, " Connections established %d; dropped %d\n",
13866 p
->established
, p
->dropped
);
13868 if (!p
->last_reset
) {
13870 json_object_string_add(json_neigh
, "lastReset",
13873 vty_out(vty
, " Last reset never\n");
13879 uptime
= bgp_clock();
13880 uptime
-= p
->resettime
;
13881 gmtime_r(&uptime
, &tm
);
13883 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
13885 + (tm
.tm_min
* 60000)
13886 + (tm
.tm_hour
* 3600000));
13887 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
13889 vty_out(vty
, " Last reset %s, ",
13890 peer_uptime(p
->resettime
, timebuf
,
13891 BGP_UPTIME_LEN
, 0, NULL
));
13893 bgp_show_peer_reset(vty
, p
, NULL
, false);
13894 if (p
->last_reset_cause_size
) {
13895 msg
= p
->last_reset_cause
;
13897 " Message received that caused BGP to send a NOTIFICATION:\n ");
13898 for (i
= 1; i
<= p
->last_reset_cause_size
;
13900 vty_out(vty
, "%02X", *msg
++);
13902 if (i
!= p
->last_reset_cause_size
) {
13904 vty_out(vty
, "\n ");
13905 } else if (i
% 4 == 0) {
13910 vty_out(vty
, "\n");
13915 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
13917 json_object_boolean_true_add(json_neigh
,
13918 "prefixesConfigExceedMax");
13921 " Peer had exceeded the max. no. of prefixes configured.\n");
13923 if (p
->t_pmax_restart
) {
13925 json_object_boolean_true_add(
13926 json_neigh
, "reducePrefixNumFrom");
13927 json_object_int_add(json_neigh
,
13928 "restartInTimerMsec",
13929 thread_timer_remain_second(
13934 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
13935 p
->host
, thread_timer_remain_second(
13936 p
->t_pmax_restart
));
13939 json_object_boolean_true_add(
13941 "reducePrefixNumAndClearIpBgp");
13944 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
13949 /* EBGP Multihop and GTSM */
13950 if (p
->sort
!= BGP_PEER_IBGP
) {
13952 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
13953 json_object_int_add(json_neigh
,
13954 "externalBgpNbrMaxHopsAway",
13956 else if (p
->ttl
> BGP_DEFAULT_TTL
)
13957 json_object_int_add(json_neigh
,
13958 "externalBgpNbrMaxHopsAway",
13961 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
13963 " External BGP neighbor may be up to %d hops away.\n",
13965 else if (p
->ttl
> BGP_DEFAULT_TTL
)
13967 " External BGP neighbor may be up to %d hops away.\n",
13971 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
) {
13973 json_object_int_add(json_neigh
,
13974 "internalBgpNbrMaxHopsAway",
13978 " Internal BGP neighbor may be up to %d hops away.\n",
13983 /* Local address. */
13986 json_object_string_add(json_neigh
, "hostLocal",
13987 sockunion2str(p
->su_local
, buf1
,
13989 json_object_int_add(json_neigh
, "portLocal",
13990 ntohs(p
->su_local
->sin
.sin_port
));
13992 vty_out(vty
, "Local host: %s, Local port: %d\n",
13993 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
13994 ntohs(p
->su_local
->sin
.sin_port
));
13997 /* Remote address. */
13998 if (p
->su_remote
) {
14000 json_object_string_add(json_neigh
, "hostForeign",
14001 sockunion2str(p
->su_remote
, buf1
,
14003 json_object_int_add(json_neigh
, "portForeign",
14004 ntohs(p
->su_remote
->sin
.sin_port
));
14006 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
14007 sockunion2str(p
->su_remote
, buf1
,
14009 ntohs(p
->su_remote
->sin
.sin_port
));
14012 /* Nexthop display. */
14015 json_object_string_add(json_neigh
, "nexthop",
14017 &p
->nexthop
.v4
, buf1
,
14019 json_object_string_add(json_neigh
, "nexthopGlobal",
14020 inet_ntop(AF_INET6
,
14021 &p
->nexthop
.v6_global
,
14022 buf1
, sizeof(buf1
)));
14023 json_object_string_add(json_neigh
, "nexthopLocal",
14024 inet_ntop(AF_INET6
,
14025 &p
->nexthop
.v6_local
,
14026 buf1
, sizeof(buf1
)));
14027 if (p
->shared_network
)
14028 json_object_string_add(json_neigh
,
14032 json_object_string_add(json_neigh
,
14034 "nonSharedNetwork");
14036 vty_out(vty
, "Nexthop: %s\n",
14037 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
14039 vty_out(vty
, "Nexthop global: %s\n",
14040 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
14042 vty_out(vty
, "Nexthop local: %s\n",
14043 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
14045 vty_out(vty
, "BGP connection: %s\n",
14046 p
->shared_network
? "shared network"
14047 : "non shared network");
14051 /* Timer information. */
14053 json_object_int_add(json_neigh
, "connectRetryTimer",
14055 if (p
->status
== Established
&& p
->rtt
)
14056 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14059 json_object_int_add(
14060 json_neigh
, "nextStartTimerDueInMsecs",
14061 thread_timer_remain_second(p
->t_start
) * 1000);
14063 json_object_int_add(
14064 json_neigh
, "nextConnectTimerDueInMsecs",
14065 thread_timer_remain_second(p
->t_connect
)
14067 if (p
->t_routeadv
) {
14068 json_object_int_add(json_neigh
, "mraiInterval",
14070 json_object_int_add(
14071 json_neigh
, "mraiTimerExpireInMsecs",
14072 thread_timer_remain_second(p
->t_routeadv
)
14076 json_object_int_add(json_neigh
, "authenticationEnabled",
14080 json_object_string_add(json_neigh
, "readThread", "on");
14082 json_object_string_add(json_neigh
, "readThread", "off");
14084 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14085 json_object_string_add(json_neigh
, "writeThread", "on");
14087 json_object_string_add(json_neigh
, "writeThread",
14090 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14092 if (p
->status
== Established
&& p
->rtt
)
14093 vty_out(vty
, "Estimated round trip time: %d ms\n",
14096 vty_out(vty
, "Next start timer due in %ld seconds\n",
14097 thread_timer_remain_second(p
->t_start
));
14099 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14100 thread_timer_remain_second(p
->t_connect
));
14103 "MRAI (interval %u) timer expires in %ld seconds\n",
14105 thread_timer_remain_second(p
->t_routeadv
));
14107 vty_out(vty
, "Peer Authentication Enabled\n");
14109 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14110 p
->t_read
? "on" : "off",
14111 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14116 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14117 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14118 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14121 vty_out(vty
, "\n");
14123 /* BFD information. */
14124 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
14127 if (p
->conf_if
) /* Configured interface name. */
14128 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14129 else /* Configured IP address. */
14130 json_object_object_add(json
, p
->host
, json_neigh
);
14134 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14135 enum show_type type
,
14136 union sockunion
*su
,
14137 const char *conf_if
, afi_t afi
,
14140 struct listnode
*node
, *nnode
;
14143 safi_t safi
= SAFI_UNICAST
;
14144 json_object
*json
= NULL
;
14145 json_object
*json_neighbor
= NULL
;
14148 json
= json_object_new_object();
14149 json_neighbor
= json_object_new_object();
14152 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14154 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14157 if ((peer
->afc
[afi
][safi
]) == 0)
14160 if (type
== show_all
) {
14161 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14165 json_object_object_add(json
, peer
->host
,
14167 json_neighbor
= NULL
;
14170 } else if (type
== show_peer
) {
14173 && !strcmp(peer
->conf_if
, conf_if
))
14175 && !strcmp(peer
->hostname
, conf_if
))) {
14177 bgp_show_peer_gr_status(vty
, peer
,
14182 if (sockunion_same(&peer
->su
, su
)) {
14184 bgp_show_peer_gr_status(vty
, peer
,
14189 if (use_json
&& find
)
14190 json_object_object_add(json
, peer
->host
,
14195 json_neighbor
= NULL
;
14200 if (type
== show_peer
&& !find
) {
14202 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14204 vty_out(vty
, "%% No such neighbor\n");
14207 vty_out(vty
, "%s\n",
14208 json_object_to_json_string_ext(
14209 json
, JSON_C_TO_STRING_PRETTY
));
14212 json_object_free(json_neighbor
);
14213 json_object_free(json
);
14215 vty_out(vty
, "\n");
14218 return CMD_SUCCESS
;
14221 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14222 enum show_type type
, union sockunion
*su
,
14223 const char *conf_if
, bool use_json
,
14226 struct listnode
*node
, *nnode
;
14229 bool nbr_output
= false;
14230 afi_t afi
= AFI_MAX
;
14231 safi_t safi
= SAFI_MAX
;
14233 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14235 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14239 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14240 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14245 bgp_show_peer(vty
, peer
, use_json
, json
);
14251 && !strcmp(peer
->conf_if
, conf_if
))
14253 && !strcmp(peer
->hostname
, conf_if
))) {
14255 bgp_show_peer(vty
, peer
, use_json
,
14259 if (sockunion_same(&peer
->su
, su
)) {
14261 bgp_show_peer(vty
, peer
, use_json
,
14266 case show_ipv4_peer
:
14267 case show_ipv6_peer
:
14268 FOREACH_SAFI (safi
) {
14269 if (peer
->afc
[afi
][safi
]) {
14272 && !strcmp(peer
->conf_if
, conf_if
))
14274 && !strcmp(peer
->hostname
, conf_if
))) {
14276 bgp_show_peer(vty
, peer
, use_json
,
14281 if (sockunion_same(&peer
->su
, su
)) {
14283 bgp_show_peer(vty
, peer
, use_json
,
14291 case show_ipv4_all
:
14292 case show_ipv6_all
:
14293 FOREACH_SAFI (safi
) {
14294 if (peer
->afc
[afi
][safi
]) {
14295 bgp_show_peer(vty
, peer
, use_json
, json
);
14304 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14305 type
== show_ipv6_peer
) && !find
) {
14307 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14309 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14312 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14313 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14314 vty_out(vty
, "%% No BGP neighbors found\n");
14317 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14318 json
, JSON_C_TO_STRING_PRETTY
));
14320 vty_out(vty
, "\n");
14323 return CMD_SUCCESS
;
14326 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14327 enum show_type type
,
14328 const char *ip_str
,
14329 afi_t afi
, bool use_json
)
14334 union sockunion su
;
14336 bgp
= bgp_get_default();
14342 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14346 ret
= str2sockunion(ip_str
, &su
);
14348 bgp_show_neighbor_graceful_restart(
14349 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14351 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14352 NULL
, afi
, use_json
);
14354 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14358 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14359 enum show_type type
,
14360 const char *ip_str
,
14363 struct listnode
*node
, *nnode
;
14365 union sockunion su
;
14366 json_object
*json
= NULL
;
14367 int ret
, is_first
= 1;
14368 bool nbr_output
= false;
14371 vty_out(vty
, "{\n");
14373 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14376 if (!(json
= json_object_new_object())) {
14378 EC_BGP_JSON_MEM_ERROR
,
14379 "Unable to allocate memory for JSON object");
14381 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14385 json_object_int_add(json
, "vrfId",
14386 (bgp
->vrf_id
== VRF_UNKNOWN
)
14388 : (int64_t)bgp
->vrf_id
);
14389 json_object_string_add(
14391 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14396 vty_out(vty
, ",\n");
14400 vty_out(vty
, "\"%s\":",
14401 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14405 vty_out(vty
, "\nInstance %s:\n",
14406 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14411 if (type
== show_peer
|| type
== show_ipv4_peer
||
14412 type
== show_ipv6_peer
) {
14413 ret
= str2sockunion(ip_str
, &su
);
14415 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14418 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14421 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14424 json_object_free(json
);
14429 vty_out(vty
, "}\n");
14430 else if (!nbr_output
)
14431 vty_out(vty
, "%% BGP instance not found\n");
14434 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14435 enum show_type type
, const char *ip_str
,
14440 union sockunion su
;
14441 json_object
*json
= NULL
;
14444 if (strmatch(name
, "all")) {
14445 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14447 return CMD_SUCCESS
;
14449 bgp
= bgp_lookup_by_name(name
);
14452 json
= json_object_new_object();
14453 vty_out(vty
, "%s\n",
14454 json_object_to_json_string_ext(
14456 JSON_C_TO_STRING_PRETTY
));
14457 json_object_free(json
);
14460 "%% BGP instance not found\n");
14462 return CMD_WARNING
;
14466 bgp
= bgp_get_default();
14470 json
= json_object_new_object();
14472 ret
= str2sockunion(ip_str
, &su
);
14474 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14477 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14480 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14483 json_object_free(json
);
14486 vty_out(vty
, "{}\n");
14488 vty_out(vty
, "%% BGP instance not found\n");
14491 return CMD_SUCCESS
;
14496 /* "show [ip] bgp neighbors graceful-restart" commands. */
14497 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
14498 show_ip_bgp_neighbors_graceful_restart_cmd
,
14499 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14505 "Neighbor to display information about\n"
14506 "Neighbor to display information about\n"
14507 "Neighbor on BGP configured interface\n"
14511 char *sh_arg
= NULL
;
14512 enum show_type sh_type
;
14514 afi_t afi
= AFI_MAX
;
14515 bool uj
= use_json(argc
, argv
);
14517 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14522 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14523 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14524 || argv_find(argv
, argc
, "WORD", &idx
)) {
14525 sh_type
= show_peer
;
14526 sh_arg
= argv
[idx
]->arg
;
14528 sh_type
= show_all
;
14530 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14531 return CMD_SUCCESS
;
14534 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14538 /* "show [ip] bgp neighbors" commands. */
14539 DEFUN (show_ip_bgp_neighbors
,
14540 show_ip_bgp_neighbors_cmd
,
14541 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14545 BGP_INSTANCE_HELP_STR
14548 "Detailed information on TCP and BGP neighbor connections\n"
14549 "Neighbor to display information about\n"
14550 "Neighbor to display information about\n"
14551 "Neighbor on BGP configured interface\n"
14555 char *sh_arg
= NULL
;
14556 enum show_type sh_type
;
14557 afi_t afi
= AFI_MAX
;
14559 bool uj
= use_json(argc
, argv
);
14563 /* [<vrf> VIEWVRFNAME] */
14564 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14565 vrf
= argv
[idx
+ 1]->arg
;
14566 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14568 } else if (argv_find(argv
, argc
, "view", &idx
))
14569 /* [<view> VIEWVRFNAME] */
14570 vrf
= argv
[idx
+ 1]->arg
;
14574 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14575 sh_type
= show_ipv4_all
;
14577 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14578 sh_type
= show_ipv6_all
;
14581 sh_type
= show_all
;
14584 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14585 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14586 || argv_find(argv
, argc
, "WORD", &idx
)) {
14587 sh_type
= show_peer
;
14588 sh_arg
= argv
[idx
]->arg
;
14591 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14592 sh_type
= show_ipv4_peer
;
14593 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14594 sh_type
= show_ipv6_peer
;
14597 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14600 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14601 paths' and `show ip mbgp paths'. Those functions results are the
14603 DEFUN (show_ip_bgp_paths
,
14604 show_ip_bgp_paths_cmd
,
14605 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14610 "Path information\n")
14612 vty_out(vty
, "Address Refcnt Path\n");
14613 aspath_print_all_vty(vty
);
14614 return CMD_SUCCESS
;
14619 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14622 struct community
*com
;
14624 com
= (struct community
*)bucket
->data
;
14625 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14626 community_str(com
, false));
14629 /* Show BGP's community internal data. */
14630 DEFUN (show_ip_bgp_community_info
,
14631 show_ip_bgp_community_info_cmd
,
14632 "show [ip] bgp community-info",
14636 "List all bgp community information\n")
14638 vty_out(vty
, "Address Refcnt Community\n");
14640 hash_iterate(community_hash(),
14641 (void (*)(struct hash_bucket
*,
14642 void *))community_show_all_iterator
,
14645 return CMD_SUCCESS
;
14648 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14651 struct lcommunity
*lcom
;
14653 lcom
= (struct lcommunity
*)bucket
->data
;
14654 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14655 lcommunity_str(lcom
, false));
14658 /* Show BGP's community internal data. */
14659 DEFUN (show_ip_bgp_lcommunity_info
,
14660 show_ip_bgp_lcommunity_info_cmd
,
14661 "show ip bgp large-community-info",
14665 "List all bgp large-community information\n")
14667 vty_out(vty
, "Address Refcnt Large-community\n");
14669 hash_iterate(lcommunity_hash(),
14670 (void (*)(struct hash_bucket
*,
14671 void *))lcommunity_show_all_iterator
,
14674 return CMD_SUCCESS
;
14676 /* Graceful Restart */
14678 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
14685 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
14687 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
14689 switch (bgp_global_gr_mode
) {
14691 case GLOBAL_HELPER
:
14692 vty_out(vty
, "Global BGP GR Mode : Helper\n");
14696 vty_out(vty
, "Global BGP GR Mode : Restart\n");
14699 case GLOBAL_DISABLE
:
14700 vty_out(vty
, "Global BGP GR Mode : Disable\n");
14703 case GLOBAL_INVALID
:
14705 "Global BGP GR Mode Invalid\n");
14708 vty_out(vty
, "\n");
14711 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
14712 enum show_type type
,
14713 const char *ip_str
,
14714 afi_t afi
, bool use_json
)
14716 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
14719 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
14721 bgp_show_neighbor_graceful_restart_vty(
14722 vty
, type
, ip_str
, afi
, use_json
);
14725 } else if (afi
!= AFI_MAX
) {
14726 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
14729 return CMD_ERR_INCOMPLETE
;
14732 return CMD_SUCCESS
;
14734 /* Graceful Restart */
14736 DEFUN (show_ip_bgp_attr_info
,
14737 show_ip_bgp_attr_info_cmd
,
14738 "show [ip] bgp attribute-info",
14742 "List all bgp attribute information\n")
14744 attr_show_all(vty
);
14745 return CMD_SUCCESS
;
14748 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
14749 afi_t afi
, safi_t safi
,
14750 bool use_json
, json_object
*json
)
14753 struct listnode
*node
;
14755 char buf1
[INET6_ADDRSTRLEN
];
14757 vpn_policy_direction_t dir
;
14760 json_object
*json_import_vrfs
= NULL
;
14761 json_object
*json_export_vrfs
= NULL
;
14763 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14766 vty_out(vty
, "%s\n",
14767 json_object_to_json_string_ext(
14769 JSON_C_TO_STRING_PRETTY
));
14770 json_object_free(json
);
14772 return CMD_WARNING
;
14775 /* Provide context for the block */
14776 json_object_string_add(json
, "vrf", name
? name
: "default");
14777 json_object_string_add(json
, "afiSafi",
14778 get_afi_safi_str(afi
, safi
, true));
14780 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14781 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
14782 json_object_string_add(json
, "importFromVrfs", "none");
14783 json_object_string_add(json
, "importRts", "none");
14785 json_import_vrfs
= json_object_new_array();
14787 for (ALL_LIST_ELEMENTS_RO(
14788 bgp
->vpn_policy
[afi
].import_vrf
,
14790 json_object_array_add(json_import_vrfs
,
14791 json_object_new_string(vname
));
14793 json_object_object_add(json
, "importFromVrfs",
14795 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14796 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14797 ecom_str
= ecommunity_ecom2str(
14798 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14799 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14800 json_object_string_add(json
, "importRts",
14802 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14804 json_object_string_add(json
, "importRts",
14808 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14809 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
14810 json_object_string_add(json
, "exportToVrfs", "none");
14811 json_object_string_add(json
, "routeDistinguisher",
14813 json_object_string_add(json
, "exportRts", "none");
14815 json_export_vrfs
= json_object_new_array();
14817 for (ALL_LIST_ELEMENTS_RO(
14818 bgp
->vpn_policy
[afi
].export_vrf
,
14820 json_object_array_add(json_export_vrfs
,
14821 json_object_new_string(vname
));
14822 json_object_object_add(json
, "exportToVrfs",
14824 json_object_string_add(json
, "routeDistinguisher",
14825 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
14826 buf1
, RD_ADDRSTRLEN
));
14828 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
14829 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14830 ecom_str
= ecommunity_ecom2str(
14831 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14832 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14833 json_object_string_add(json
, "exportRts",
14835 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14837 json_object_string_add(json
, "exportRts",
14842 vty_out(vty
, "%s\n",
14843 json_object_to_json_string_ext(json
,
14844 JSON_C_TO_STRING_PRETTY
));
14845 json_object_free(json
);
14848 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14851 vty_out(vty
, "%% No such BGP instance exist\n");
14852 return CMD_WARNING
;
14855 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14856 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
14858 "This VRF is not importing %s routes from any other VRF\n",
14859 get_afi_safi_str(afi
, safi
, false));
14862 "This VRF is importing %s routes from the following VRFs:\n",
14863 get_afi_safi_str(afi
, safi
, false));
14865 for (ALL_LIST_ELEMENTS_RO(
14866 bgp
->vpn_policy
[afi
].import_vrf
,
14868 vty_out(vty
, " %s\n", vname
);
14870 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
14872 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14873 ecom_str
= ecommunity_ecom2str(
14874 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14875 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14876 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
14878 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14880 vty_out(vty
, "Import RT(s):\n");
14883 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
14884 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
14886 "This VRF is not exporting %s routes to any other VRF\n",
14887 get_afi_safi_str(afi
, safi
, false));
14890 "This VRF is exporting %s routes to the following VRFs:\n",
14891 get_afi_safi_str(afi
, safi
, false));
14893 for (ALL_LIST_ELEMENTS_RO(
14894 bgp
->vpn_policy
[afi
].export_vrf
,
14896 vty_out(vty
, " %s\n", vname
);
14898 vty_out(vty
, "RD: %s\n",
14899 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
14900 buf1
, RD_ADDRSTRLEN
));
14902 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
14903 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
14904 ecom_str
= ecommunity_ecom2str(
14905 bgp
->vpn_policy
[afi
].rtlist
[dir
],
14906 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
14907 vty_out(vty
, "Export RT: %s\n", ecom_str
);
14908 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
14910 vty_out(vty
, "Import RT(s):\n");
14914 return CMD_SUCCESS
;
14917 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
14918 safi_t safi
, bool use_json
)
14920 struct listnode
*node
, *nnode
;
14922 char *vrf_name
= NULL
;
14923 json_object
*json
= NULL
;
14924 json_object
*json_vrf
= NULL
;
14925 json_object
*json_vrfs
= NULL
;
14928 json
= json_object_new_object();
14929 json_vrfs
= json_object_new_object();
14932 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14934 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
14935 vrf_name
= bgp
->name
;
14938 json_vrf
= json_object_new_object();
14940 vty_out(vty
, "\nInstance %s:\n",
14941 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14942 ? VRF_DEFAULT_NAME
: bgp
->name
);
14944 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
14946 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14947 json_object_object_add(json_vrfs
,
14948 VRF_DEFAULT_NAME
, json_vrf
);
14950 json_object_object_add(json_vrfs
, vrf_name
,
14956 json_object_object_add(json
, "vrfs", json_vrfs
);
14957 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
14958 JSON_C_TO_STRING_PRETTY
));
14959 json_object_free(json
);
14962 return CMD_SUCCESS
;
14965 /* "show [ip] bgp route-leak" command. */
14966 DEFUN (show_ip_bgp_route_leak
,
14967 show_ip_bgp_route_leak_cmd
,
14968 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
14972 BGP_INSTANCE_HELP_STR
14975 "Route leaking information\n"
14979 afi_t afi
= AFI_MAX
;
14980 safi_t safi
= SAFI_MAX
;
14982 bool uj
= use_json(argc
, argv
);
14984 json_object
*json
= NULL
;
14986 /* show [ip] bgp */
14987 if (argv_find(argv
, argc
, "ip", &idx
)) {
14989 safi
= SAFI_UNICAST
;
14991 /* [vrf VIEWVRFNAME] */
14992 if (argv_find(argv
, argc
, "view", &idx
)) {
14994 "%% This command is not applicable to BGP views\n");
14995 return CMD_WARNING
;
14998 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14999 vrf
= argv
[idx
+ 1]->arg
;
15000 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15003 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15004 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15005 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15008 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15010 "%% This command is applicable only for unicast ipv4|ipv6\n");
15011 return CMD_WARNING
;
15014 if (vrf
&& strmatch(vrf
, "all"))
15015 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15018 json
= json_object_new_object();
15020 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15023 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15026 struct listnode
*node
, *nnode
;
15029 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15030 vty_out(vty
, "\nInstance %s:\n",
15031 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15034 update_group_show(bgp
, afi
, safi
, vty
, 0);
15038 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15039 int safi
, uint64_t subgrp_id
)
15044 if (strmatch(name
, "all")) {
15045 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
15046 return CMD_SUCCESS
;
15048 bgp
= bgp_lookup_by_name(name
);
15051 bgp
= bgp_get_default();
15055 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
15056 return CMD_SUCCESS
;
15059 DEFUN (show_ip_bgp_updgrps
,
15060 show_ip_bgp_updgrps_cmd
,
15061 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
15065 BGP_INSTANCE_HELP_STR
15067 BGP_SAFI_WITH_LABEL_HELP_STR
15068 "Detailed info about dynamic update groups\n"
15069 "Specific subgroup to display detailed info for\n")
15072 afi_t afi
= AFI_IP6
;
15073 safi_t safi
= SAFI_UNICAST
;
15074 uint64_t subgrp_id
= 0;
15078 /* show [ip] bgp */
15079 if (argv_find(argv
, argc
, "ip", &idx
))
15081 /* [<vrf> VIEWVRFNAME] */
15082 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15083 vrf
= argv
[idx
+ 1]->arg
;
15084 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15086 } else if (argv_find(argv
, argc
, "view", &idx
))
15087 /* [<view> VIEWVRFNAME] */
15088 vrf
= argv
[idx
+ 1]->arg
;
15089 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15090 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15091 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15094 /* get subgroup id, if provided */
15096 if (argv
[idx
]->type
== VARIABLE_TKN
)
15097 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15099 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
15102 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15103 show_bgp_instance_all_ipv6_updgrps_cmd
,
15104 "show [ip] bgp <view|vrf> all update-groups",
15108 BGP_INSTANCE_ALL_HELP_STR
15109 "Detailed info about dynamic update groups\n")
15111 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15112 return CMD_SUCCESS
;
15115 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15116 show_bgp_l2vpn_evpn_updgrps_cmd
,
15117 "show [ip] bgp l2vpn evpn update-groups",
15121 "l2vpn address family\n"
15122 "evpn sub-address family\n"
15123 "Detailed info about dynamic update groups\n")
15126 uint64_t subgrp_id
= 0;
15128 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15129 return CMD_SUCCESS
;
15132 DEFUN (show_bgp_updgrps_stats
,
15133 show_bgp_updgrps_stats_cmd
,
15134 "show [ip] bgp update-groups statistics",
15138 "Detailed info about dynamic update groups\n"
15143 bgp
= bgp_get_default();
15145 update_group_show_stats(bgp
, vty
);
15147 return CMD_SUCCESS
;
15150 DEFUN (show_bgp_instance_updgrps_stats
,
15151 show_bgp_instance_updgrps_stats_cmd
,
15152 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15156 BGP_INSTANCE_HELP_STR
15157 "Detailed info about dynamic update groups\n"
15163 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15165 update_group_show_stats(bgp
, vty
);
15167 return CMD_SUCCESS
;
15170 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15171 afi_t afi
, safi_t safi
,
15172 const char *what
, uint64_t subgrp_id
)
15177 bgp
= bgp_lookup_by_name(name
);
15179 bgp
= bgp_get_default();
15182 if (!strcmp(what
, "advertise-queue"))
15183 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15185 else if (!strcmp(what
, "advertised-routes"))
15186 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15188 else if (!strcmp(what
, "packet-queue"))
15189 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15194 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15195 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15196 "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",
15197 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15199 "Detailed info about dynamic update groups\n"
15200 "Specific subgroup to display info for\n"
15201 "Advertisement queue\n"
15202 "Announced routes\n"
15205 uint64_t subgrp_id
= 0;
15209 subgrp_id
= strtoull(sgid
, NULL
, 10);
15214 afiz
= bgp_vty_afi_from_str(afi
);
15218 afiz
= bgp_vty_afi_from_str(afi
);
15219 if (afiz
!= AFI_IP
)
15221 "%% Cannot specify both 'ip' and 'ipv6'\n");
15222 return CMD_WARNING
;
15225 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15227 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15228 return CMD_SUCCESS
;
15231 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
15233 struct listnode
*node
, *nnode
;
15234 struct prefix
*range
;
15239 const char *peer_status
;
15240 const char *af_str
;
15245 conf
= group
->conf
;
15247 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15248 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15249 group
->name
, conf
->as
);
15250 } else if (conf
->as_type
== AS_INTERNAL
) {
15251 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15252 group
->name
, group
->bgp
->as
);
15254 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15257 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
15258 vty_out(vty
, " Peer-group type is internal\n");
15260 vty_out(vty
, " Peer-group type is external\n");
15262 /* Display AFs configured. */
15263 vty_out(vty
, " Configured address-families:");
15264 FOREACH_AFI_SAFI (afi
, safi
) {
15265 if (conf
->afc
[afi
][safi
]) {
15267 vty_out(vty
, " %s;", get_afi_safi_str(afi
, safi
, false));
15271 vty_out(vty
, " none\n");
15273 vty_out(vty
, "\n");
15275 /* Display listen ranges (for dynamic neighbors), if any */
15276 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15279 else if (afi
== AFI_IP6
)
15283 lr_count
= listcount(group
->listen_range
[afi
]);
15285 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
15289 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15291 vty_out(vty
, " %pFX\n", range
);
15295 /* Display group members and their status */
15296 if (listcount(group
->peer
)) {
15297 vty_out(vty
, " Peer-group members:\n");
15298 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15299 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15300 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15301 peer_status
= "Idle (Admin)";
15302 else if (CHECK_FLAG(peer
->sflags
,
15303 PEER_STATUS_PREFIX_OVERFLOW
))
15304 peer_status
= "Idle (PfxCt)";
15306 peer_status
= lookup_msg(bgp_status_msg
,
15307 peer
->status
, NULL
);
15309 dynamic
= peer_dynamic_neighbor(peer
);
15310 vty_out(vty
, " %s %s %s \n", peer
->host
,
15311 dynamic
? "(dynamic)" : "", peer_status
);
15315 return CMD_SUCCESS
;
15318 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15319 const char *group_name
)
15322 struct listnode
*node
, *nnode
;
15323 struct peer_group
*group
;
15324 bool found
= false;
15326 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15329 vty_out(vty
, "%% BGP instance not found\n");
15330 return CMD_WARNING
;
15333 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15335 if (strmatch(group
->name
, group_name
)) {
15336 bgp_show_one_peer_group(vty
, group
);
15341 bgp_show_one_peer_group(vty
, group
);
15345 if (group_name
&& !found
)
15346 vty_out(vty
, "%% No such peer-group\n");
15348 return CMD_SUCCESS
;
15351 DEFUN (show_ip_bgp_peer_groups
,
15352 show_ip_bgp_peer_groups_cmd
,
15353 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
15357 BGP_INSTANCE_HELP_STR
15358 "Detailed information on BGP peer groups\n"
15359 "Peer group name\n")
15364 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15366 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15368 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
15372 /* Redistribute VTY commands. */
15374 DEFUN_YANG (bgp_redistribute_ipv4
,
15375 bgp_redistribute_ipv4_cmd
,
15376 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15377 "Redistribute information from another routing protocol\n"
15378 FRR_IP_REDIST_HELP_STR_BGPD
)
15380 int idx_protocol
= 1;
15381 char base_xpath
[XPATH_MAXLEN
];
15383 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15384 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15385 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15386 argv
[idx_protocol
]->text
, "0");
15388 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15390 return nb_cli_apply_changes(vty
, base_xpath
);
15394 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15395 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15396 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15398 DEFUN_YANG (bgp_redistribute_ipv4_rmap
,
15399 bgp_redistribute_ipv4_rmap_cmd
,
15400 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15401 "Redistribute information from another routing protocol\n"
15402 FRR_IP_REDIST_HELP_STR_BGPD
15403 "Route map reference\n"
15404 "Pointer to route-map entries\n")
15406 int idx_protocol
= 1;
15408 char base_xpath
[XPATH_MAXLEN
];
15410 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15411 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15412 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15413 argv
[idx_protocol
]->text
, "0");
15415 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15416 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15417 argv
[idx_word
]->arg
);
15419 return nb_cli_apply_changes(vty
, base_xpath
);
15423 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15424 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15425 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15426 "Route map reference\n"
15427 "Pointer to route-map entries\n")
15429 DEFUN_YANG (bgp_redistribute_ipv4_metric
,
15430 bgp_redistribute_ipv4_metric_cmd
,
15431 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15432 "Redistribute information from another routing protocol\n"
15433 FRR_IP_REDIST_HELP_STR_BGPD
15434 "Metric for redistributed routes\n"
15435 "Default metric\n")
15437 int idx_protocol
= 1;
15438 int idx_number
= 3;
15439 char base_xpath
[XPATH_MAXLEN
];
15441 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15442 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15443 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15444 argv
[idx_protocol
]->text
, "0");
15446 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15447 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15448 argv
[idx_number
]->arg
);
15450 return nb_cli_apply_changes(vty
, base_xpath
);
15454 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15455 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15456 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15457 "Metric for redistributed routes\n"
15458 "Default metric\n")
15461 bgp_redistribute_ipv4_rmap_metric
,
15462 bgp_redistribute_ipv4_rmap_metric_cmd
,
15463 "redistribute " FRR_IP_REDIST_STR_BGPD
15464 " route-map WORD metric (0-4294967295)",
15465 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15466 "Route map reference\n"
15467 "Pointer to route-map entries\n"
15468 "Metric for redistributed routes\n"
15469 "Default metric\n")
15471 int idx_protocol
= 1;
15473 int idx_number
= 5;
15474 char base_xpath
[XPATH_MAXLEN
];
15476 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15477 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15478 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15479 argv
[idx_protocol
]->text
, "0");
15481 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15482 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15483 argv
[idx_word
]->arg
);
15484 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15485 argv
[idx_number
]->arg
);
15487 return nb_cli_apply_changes(vty
, base_xpath
);
15491 bgp_redistribute_ipv4_rmap_metric
,
15492 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15493 "redistribute " FRR_IP_REDIST_STR_BGPD
15494 " route-map WORD metric (0-4294967295)",
15495 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15496 "Route map reference\n"
15497 "Pointer to route-map entries\n"
15498 "Metric for redistributed routes\n"
15499 "Default metric\n")
15502 bgp_redistribute_ipv4_metric_rmap
,
15503 bgp_redistribute_ipv4_metric_rmap_cmd
,
15504 "redistribute " FRR_IP_REDIST_STR_BGPD
15505 " metric (0-4294967295) route-map WORD",
15506 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15507 "Metric for redistributed routes\n"
15509 "Route map reference\n"
15510 "Pointer to route-map entries\n")
15512 int idx_protocol
= 1;
15514 int idx_number
= 3;
15515 char base_xpath
[XPATH_MAXLEN
];
15517 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15518 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15519 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15520 argv
[idx_protocol
]->text
, "0");
15522 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15523 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15524 argv
[idx_number
]->arg
);
15525 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15526 argv
[idx_word
]->arg
);
15528 return nb_cli_apply_changes(vty
, base_xpath
);
15532 bgp_redistribute_ipv4_metric_rmap
,
15533 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15534 "redistribute " FRR_IP_REDIST_STR_BGPD
15535 " metric (0-4294967295) route-map WORD",
15536 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15537 "Metric for redistributed routes\n"
15539 "Route map reference\n"
15540 "Pointer to route-map entries\n")
15542 DEFUN_YANG (bgp_redistribute_ipv4_ospf
,
15543 bgp_redistribute_ipv4_ospf_cmd
,
15544 "redistribute <ospf|table> (1-65535)",
15545 "Redistribute information from another routing protocol\n"
15546 "Open Shortest Path First (OSPFv2)\n"
15547 "Non-main Kernel Routing Table\n"
15548 "Instance ID/Table ID\n")
15550 int idx_protocol
= 1;
15551 int idx_number
= 2;
15552 char base_xpath
[XPATH_MAXLEN
];
15554 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15555 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15556 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15557 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15559 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15561 return nb_cli_apply_changes(vty
, base_xpath
);
15564 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
15565 "redistribute <ospf|table> (1-65535)",
15566 "Redistribute information from another routing protocol\n"
15567 "Open Shortest Path First (OSPFv2)\n"
15568 "Non-main Kernel Routing Table\n"
15569 "Instance ID/Table ID\n")
15571 DEFUN_YANG (bgp_redistribute_ipv4_ospf_rmap
,
15572 bgp_redistribute_ipv4_ospf_rmap_cmd
,
15573 "redistribute <ospf|table> (1-65535) route-map WORD",
15574 "Redistribute information from another routing protocol\n"
15575 "Open Shortest Path First (OSPFv2)\n"
15576 "Non-main Kernel Routing Table\n"
15577 "Instance ID/Table ID\n"
15578 "Route map reference\n"
15579 "Pointer to route-map entries\n")
15581 int idx_protocol
= 1;
15582 int idx_number
= 2;
15584 char base_xpath
[XPATH_MAXLEN
];
15586 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15587 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15588 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15589 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15591 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15593 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15594 argv
[idx_word
]->arg
);
15596 return nb_cli_apply_changes(vty
, base_xpath
);
15599 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
15600 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
15601 "redistribute <ospf|table> (1-65535) route-map WORD",
15602 "Redistribute information from another routing protocol\n"
15603 "Open Shortest Path First (OSPFv2)\n"
15604 "Non-main Kernel Routing Table\n"
15605 "Instance ID/Table ID\n"
15606 "Route map reference\n"
15607 "Pointer to route-map entries\n")
15609 DEFUN_YANG(bgp_redistribute_ipv4_ospf_metric
,
15610 bgp_redistribute_ipv4_ospf_metric_cmd
,
15611 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15612 "Redistribute information from another routing protocol\n"
15613 "Open Shortest Path First (OSPFv2)\n"
15614 "Non-main Kernel Routing Table\n"
15615 "Instance ID/Table ID\n"
15616 "Metric for redistributed routes\n"
15617 "Default metric\n")
15619 int idx_protocol
= 1;
15620 int idx_number
= 2;
15621 int idx_number_2
= 4;
15622 char base_xpath
[XPATH_MAXLEN
];
15624 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15625 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15626 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15627 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15629 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15631 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15632 argv
[idx_number_2
]->arg
);
15634 return nb_cli_apply_changes(vty
, base_xpath
);
15637 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
15638 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
15639 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
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"
15645 "Default metric\n")
15648 bgp_redistribute_ipv4_ospf_rmap_metric
,
15649 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
15650 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15651 "Redistribute information from another routing protocol\n"
15652 "Open Shortest Path First (OSPFv2)\n"
15653 "Non-main Kernel Routing Table\n"
15654 "Instance ID/Table ID\n"
15655 "Route map reference\n"
15656 "Pointer to route-map entries\n"
15657 "Metric for redistributed routes\n"
15658 "Default metric\n")
15660 int idx_protocol
= 1;
15661 int idx_number
= 2;
15663 int idx_number_2
= 6;
15664 char base_xpath
[XPATH_MAXLEN
];
15666 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15667 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15668 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15669 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15671 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15673 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15674 argv
[idx_word
]->arg
);
15675 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15676 argv
[idx_number_2
]->arg
);
15678 return nb_cli_apply_changes(vty
, base_xpath
);
15682 bgp_redistribute_ipv4_ospf_rmap_metric
,
15683 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
15684 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15685 "Redistribute information from another routing protocol\n"
15686 "Open Shortest Path First (OSPFv2)\n"
15687 "Non-main Kernel Routing Table\n"
15688 "Instance ID/Table ID\n"
15689 "Route map reference\n"
15690 "Pointer to route-map entries\n"
15691 "Metric for redistributed routes\n"
15692 "Default metric\n")
15695 bgp_redistribute_ipv4_ospf_metric_rmap
,
15696 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
15697 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15698 "Redistribute information from another routing protocol\n"
15699 "Open Shortest Path First (OSPFv2)\n"
15700 "Non-main Kernel Routing Table\n"
15701 "Instance ID/Table ID\n"
15702 "Metric for redistributed routes\n"
15704 "Route map reference\n"
15705 "Pointer to route-map entries\n")
15707 int idx_protocol
= 1;
15708 int idx_number
= 2;
15709 int idx_number_2
= 4;
15711 char base_xpath
[XPATH_MAXLEN
];
15713 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15714 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15715 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15716 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15718 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15720 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15721 argv
[idx_number_2
]->arg
);
15722 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15723 argv
[idx_word
]->arg
);
15725 return nb_cli_apply_changes(vty
, base_xpath
);
15729 bgp_redistribute_ipv4_ospf_metric_rmap
,
15730 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
15731 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15732 "Redistribute information from another routing protocol\n"
15733 "Open Shortest Path First (OSPFv2)\n"
15734 "Non-main Kernel Routing Table\n"
15735 "Instance ID/Table ID\n"
15736 "Metric for redistributed routes\n"
15738 "Route map reference\n"
15739 "Pointer to route-map entries\n")
15741 DEFUN_YANG (no_bgp_redistribute_ipv4_ospf
,
15742 no_bgp_redistribute_ipv4_ospf_cmd
,
15743 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
15745 "Redistribute information from another routing protocol\n"
15746 "Open Shortest Path First (OSPFv2)\n"
15747 "Non-main Kernel Routing Table\n"
15748 "Instance ID/Table ID\n"
15749 "Metric for redistributed routes\n"
15751 "Route map reference\n"
15752 "Pointer to route-map entries\n")
15754 int idx_protocol
= 2;
15755 int idx_number
= 3;
15756 char base_xpath
[XPATH_MAXLEN
];
15758 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15759 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15760 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15761 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15763 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
15765 return nb_cli_apply_changes(vty
, base_xpath
);
15769 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
15770 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
15772 "Redistribute information from another routing protocol\n"
15773 "Open Shortest Path First (OSPFv2)\n"
15774 "Non-main Kernel Routing Table\n"
15775 "Instance ID/Table ID\n"
15776 "Metric for redistributed routes\n"
15778 "Route map reference\n"
15779 "Pointer to route-map entries\n")
15781 DEFUN_YANG (no_bgp_redistribute_ipv4
,
15782 no_bgp_redistribute_ipv4_cmd
,
15783 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
15785 "Redistribute information from another routing protocol\n"
15786 FRR_IP_REDIST_HELP_STR_BGPD
15787 "Metric for redistributed routes\n"
15789 "Route map reference\n"
15790 "Pointer to route-map entries\n")
15792 int idx_protocol
= 2;
15793 char base_xpath
[XPATH_MAXLEN
];
15795 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15796 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15797 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15798 argv
[idx_protocol
]->text
, "0");
15800 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
15802 return nb_cli_apply_changes(vty
, base_xpath
);
15806 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
15807 "no redistribute " FRR_IP_REDIST_STR_BGPD
15808 " [{metric (0-4294967295)|route-map WORD}]",
15810 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15811 "Metric for redistributed routes\n"
15813 "Route map reference\n"
15814 "Pointer to route-map entries\n")
15816 DEFUN_YANG (bgp_redistribute_ipv6
,
15817 bgp_redistribute_ipv6_cmd
,
15818 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
15819 "Redistribute information from another routing protocol\n"
15820 FRR_IP6_REDIST_HELP_STR_BGPD
)
15822 int idx_protocol
= 1;
15823 char base_xpath
[XPATH_MAXLEN
];
15825 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15826 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15827 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15828 argv
[idx_protocol
]->text
, "0");
15830 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15832 return nb_cli_apply_changes(vty
, base_xpath
);
15835 DEFUN_YANG (bgp_redistribute_ipv6_rmap
,
15836 bgp_redistribute_ipv6_rmap_cmd
,
15837 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
15838 "Redistribute information from another routing protocol\n"
15839 FRR_IP6_REDIST_HELP_STR_BGPD
15840 "Route map reference\n"
15841 "Pointer to route-map entries\n")
15843 int idx_protocol
= 1;
15845 char base_xpath
[XPATH_MAXLEN
];
15847 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15848 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15849 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15850 argv
[idx_protocol
]->text
, "0");
15852 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15853 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15854 argv
[idx_word
]->arg
);
15856 return nb_cli_apply_changes(vty
, base_xpath
);
15859 DEFUN_YANG (bgp_redistribute_ipv6_metric
,
15860 bgp_redistribute_ipv6_metric_cmd
,
15861 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
15862 "Redistribute information from another routing protocol\n"
15863 FRR_IP6_REDIST_HELP_STR_BGPD
15864 "Metric for redistributed routes\n"
15865 "Default metric\n")
15867 int idx_protocol
= 1;
15868 int idx_number
= 3;
15869 char base_xpath
[XPATH_MAXLEN
];
15871 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15872 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15873 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15874 argv
[idx_protocol
]->text
, "0");
15876 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15877 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15878 argv
[idx_number
]->arg
);
15880 return nb_cli_apply_changes(vty
, base_xpath
);
15884 bgp_redistribute_ipv6_rmap_metric
,
15885 bgp_redistribute_ipv6_rmap_metric_cmd
,
15886 "redistribute " FRR_IP6_REDIST_STR_BGPD
15887 " route-map WORD metric (0-4294967295)",
15888 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
15889 "Route map reference\n"
15890 "Pointer to route-map entries\n"
15891 "Metric for redistributed routes\n"
15892 "Default metric\n")
15894 int idx_protocol
= 1;
15896 int idx_number
= 5;
15897 char base_xpath
[XPATH_MAXLEN
];
15899 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15900 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15901 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15902 argv
[idx_protocol
]->text
, "0");
15904 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15905 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15906 argv
[idx_word
]->arg
);
15907 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15908 argv
[idx_number
]->arg
);
15910 return nb_cli_apply_changes(vty
, base_xpath
);
15914 bgp_redistribute_ipv6_metric_rmap
,
15915 bgp_redistribute_ipv6_metric_rmap_cmd
,
15916 "redistribute " FRR_IP6_REDIST_STR_BGPD
15917 " metric (0-4294967295) route-map WORD",
15918 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
15919 "Metric for redistributed routes\n"
15921 "Route map reference\n"
15922 "Pointer to route-map entries\n")
15924 int idx_protocol
= 1;
15926 int idx_number
= 3;
15927 char base_xpath
[XPATH_MAXLEN
];
15929 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15930 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15931 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15932 argv
[idx_protocol
]->text
, "0");
15934 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15935 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15936 argv
[idx_number
]->arg
);
15937 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15938 argv
[idx_word
]->arg
);
15940 return nb_cli_apply_changes(vty
, base_xpath
);
15944 no_bgp_redistribute_ipv6
,
15945 no_bgp_redistribute_ipv6_cmd
,
15946 "no redistribute " FRR_IP6_REDIST_STR_BGPD
15947 " [{metric (0-4294967295)|route-map WORD}]",
15949 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
15950 "Metric for redistributed routes\n"
15952 "Route map reference\n"
15953 "Pointer to route-map entries\n")
15955 int idx_protocol
= 2;
15956 char base_xpath
[XPATH_MAXLEN
];
15958 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15959 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
15960 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
15961 argv
[idx_protocol
]->text
, "0");
15963 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
15965 return nb_cli_apply_changes(vty
, base_xpath
);
15968 void cli_show_bgp_global_afi_safi_ip_unicast_redistribution_list(
15969 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
15971 uint32_t instance
= 0;
15973 vty_out(vty
, " redistribute %s",
15974 yang_dnode_get_string(dnode
, "./route-type"));
15975 if ((instance
= yang_dnode_get_uint16(dnode
, "./route-instance")))
15976 vty_out(vty
, " %d", instance
);
15977 if (yang_dnode_exists(dnode
, "./metric"))
15978 vty_out(vty
, " metric %u",
15979 yang_dnode_get_uint32(dnode
, "./metric"));
15980 if (yang_dnode_exists(dnode
, "./rmap-policy-import"))
15981 vty_out(vty
, " route-map %s",
15982 yang_dnode_get_string(dnode
, "./rmap-policy-import"));
15983 vty_out(vty
, "\n");
15986 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
15987 afi_t afi
, safi_t safi
)
15991 /* Unicast redistribution only. */
15992 if (safi
!= SAFI_UNICAST
)
15995 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
15996 /* Redistribute BGP does not make sense. */
15997 if (i
!= ZEBRA_ROUTE_BGP
) {
15998 struct list
*red_list
;
15999 struct listnode
*node
;
16000 struct bgp_redist
*red
;
16002 red_list
= bgp
->redist
[afi
][i
];
16006 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16007 /* "redistribute" configuration. */
16008 vty_out(vty
, " redistribute %s",
16009 zebra_route_string(i
));
16011 vty_out(vty
, " %d", red
->instance
);
16012 if (red
->redist_metric_flag
)
16013 vty_out(vty
, " metric %u",
16014 red
->redist_metric
);
16015 if (red
->rmap
.name
)
16016 vty_out(vty
, " route-map %s",
16018 vty_out(vty
, "\n");
16024 /* peer-group helpers for config-write */
16026 static bool peergroup_flag_check(struct peer
*peer
, uint32_t flag
)
16028 if (!peer_group_active(peer
)) {
16029 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16030 return !CHECK_FLAG(peer
->flags
, flag
);
16032 return !!CHECK_FLAG(peer
->flags
, flag
);
16035 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16038 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16041 if (!peer_group_active(peer
)) {
16042 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16043 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16045 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16048 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16051 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16052 uint8_t type
, int direct
)
16054 struct bgp_filter
*filter
;
16056 if (peer_group_active(peer
))
16057 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16060 filter
= &peer
->filter
[afi
][safi
];
16062 case PEER_FT_DISTRIBUTE_LIST
:
16063 return !!(filter
->dlist
[direct
].name
);
16064 case PEER_FT_FILTER_LIST
:
16065 return !!(filter
->aslist
[direct
].name
);
16066 case PEER_FT_PREFIX_LIST
:
16067 return !!(filter
->plist
[direct
].name
);
16068 case PEER_FT_ROUTE_MAP
:
16069 return !!(filter
->map
[direct
].name
);
16070 case PEER_FT_UNSUPPRESS_MAP
:
16071 return !!(filter
->usmap
.name
);
16072 case PEER_FT_ADVERTISE_MAP
:
16073 return !!(filter
->advmap
.aname
16074 && ((filter
->advmap
.condition
== direct
)
16075 && filter
->advmap
.cname
));
16081 /* Return true if the addpath type is set for peer and different from
16084 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16087 enum bgp_addpath_strat type
, g_type
;
16089 type
= peer
->addpath_type
[afi
][safi
];
16091 if (type
!= BGP_ADDPATH_NONE
) {
16092 if (peer_group_active(peer
)) {
16093 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16095 if (type
!= g_type
)
16107 /* This is part of the address-family block (unicast only) */
16108 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16113 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16114 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16115 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16116 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16117 bgp
->vpn_policy
[afi
]
16118 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16120 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16121 bgp
->vpn_policy
[afi
]
16122 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16124 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16125 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16126 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16127 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16130 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16131 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16133 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16136 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16137 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16138 bgp
->vpn_policy
[afi
].tovpn_label
);
16141 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16142 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
16143 char buf
[RD_ADDRSTRLEN
];
16144 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
16145 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
16148 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16149 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16151 char buf
[PREFIX_STRLEN
];
16152 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16153 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16156 vty_out(vty
, "%*snexthop vpn export %s\n",
16160 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16161 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16163 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16164 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16166 char *b
= ecommunity_ecom2str(
16167 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16168 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16169 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16170 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16172 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16173 char *b
= ecommunity_ecom2str(
16174 bgp
->vpn_policy
[afi
]
16175 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16176 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16177 ECOMMUNITY_ROUTE_TARGET
);
16178 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16179 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16181 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16182 char *b
= ecommunity_ecom2str(
16183 bgp
->vpn_policy
[afi
]
16184 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16185 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16186 ECOMMUNITY_ROUTE_TARGET
);
16187 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16188 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16192 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16193 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16194 bgp
->vpn_policy
[afi
]
16195 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16197 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16198 char *b
= ecommunity_ecom2str(
16199 bgp
->vpn_policy
[afi
]
16200 .import_redirect_rtlist
,
16201 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16202 ECOMMUNITY_ROUTE_TARGET
);
16204 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16205 != ECOMMUNITY_SIZE
)
16206 vty_out(vty
, "%*srt6 redirect import %s\n",
16209 vty_out(vty
, "%*srt redirect import %s\n",
16211 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16215 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16216 afi_t afi
, safi_t safi
)
16218 struct bgp_filter
*filter
;
16222 filter
= &peer
->filter
[afi
][safi
];
16224 /* distribute-list. */
16225 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16227 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16228 filter
->dlist
[FILTER_IN
].name
);
16230 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16232 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16233 filter
->dlist
[FILTER_OUT
].name
);
16236 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16238 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16239 filter
->plist
[FILTER_IN
].name
);
16241 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16243 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16244 filter
->plist
[FILTER_OUT
].name
);
16247 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16248 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16249 filter
->map
[RMAP_IN
].name
);
16251 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16253 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16254 filter
->map
[RMAP_OUT
].name
);
16256 /* unsuppress-map */
16257 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16258 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16259 filter
->usmap
.name
);
16261 /* advertise-map : always applied in OUT direction*/
16262 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16263 CONDITION_NON_EXIST
))
16265 " neighbor %s advertise-map %s non-exist-map %s\n",
16266 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16268 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16270 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16271 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16274 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16276 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16277 filter
->aslist
[FILTER_IN
].name
);
16279 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16281 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16282 filter
->aslist
[FILTER_OUT
].name
);
16285 /* BGP peer configuration display function. */
16286 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16289 struct peer
*g_peer
= NULL
;
16290 char buf
[SU_ADDRSTRLEN
];
16292 int if_pg_printed
= false;
16293 int if_ras_printed
= false;
16295 /* Skip dynamic neighbors. */
16296 if (peer_dynamic_neighbor(peer
))
16300 addr
= peer
->conf_if
;
16304 /************************************
16305 ****** Global to the neighbor ******
16306 ************************************/
16307 if (peer
->conf_if
) {
16308 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16309 vty_out(vty
, " neighbor %s interface v6only", addr
);
16311 vty_out(vty
, " neighbor %s interface", addr
);
16313 if (peer_group_active(peer
)) {
16314 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16315 if_pg_printed
= true;
16316 } else if (peer
->as_type
== AS_SPECIFIED
) {
16317 vty_out(vty
, " remote-as %u", peer
->as
);
16318 if_ras_printed
= true;
16319 } else if (peer
->as_type
== AS_INTERNAL
) {
16320 vty_out(vty
, " remote-as internal");
16321 if_ras_printed
= true;
16322 } else if (peer
->as_type
== AS_EXTERNAL
) {
16323 vty_out(vty
, " remote-as external");
16324 if_ras_printed
= true;
16327 vty_out(vty
, "\n");
16330 /* remote-as and peer-group */
16331 /* peer is a member of a peer-group */
16332 if (peer_group_active(peer
)) {
16333 g_peer
= peer
->group
->conf
;
16335 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16336 if (peer
->as_type
== AS_SPECIFIED
) {
16337 vty_out(vty
, " neighbor %s remote-as %u\n",
16339 } else if (peer
->as_type
== AS_INTERNAL
) {
16341 " neighbor %s remote-as internal\n",
16343 } else if (peer
->as_type
== AS_EXTERNAL
) {
16345 " neighbor %s remote-as external\n",
16350 /* For swpX peers we displayed the peer-group
16351 * via 'neighbor swpX interface peer-group PGNAME' */
16352 if (!if_pg_printed
)
16353 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16354 peer
->group
->name
);
16357 /* peer is NOT a member of a peer-group */
16359 /* peer is a peer-group, declare the peer-group */
16360 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16361 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16364 if (!if_ras_printed
) {
16365 if (peer
->as_type
== AS_SPECIFIED
) {
16366 vty_out(vty
, " neighbor %s remote-as %u\n",
16368 } else if (peer
->as_type
== AS_INTERNAL
) {
16370 " neighbor %s remote-as internal\n",
16372 } else if (peer
->as_type
== AS_EXTERNAL
) {
16374 " neighbor %s remote-as external\n",
16381 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16382 vty_out(vty
, " neighbor %s local-as %u", addr
,
16383 peer
->change_local_as
);
16384 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16385 vty_out(vty
, " no-prepend");
16386 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16387 vty_out(vty
, " replace-as");
16388 vty_out(vty
, "\n");
16393 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16397 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16398 if (peer
->tx_shutdown_message
)
16399 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16400 peer
->tx_shutdown_message
);
16402 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16405 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16406 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16407 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16410 if (peer
->bfd_info
) {
16411 if (!peer_group_active(peer
) || !g_peer
->bfd_info
) {
16412 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16417 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16418 vty_out(vty
, " neighbor %s password %s\n", addr
,
16421 /* neighbor solo */
16422 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16423 if (!peer_group_active(peer
)) {
16424 vty_out(vty
, " neighbor %s solo\n", addr
);
16429 if (peer
->port
!= BGP_PORT_DEFAULT
) {
16430 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
16433 /* Local interface name */
16434 if (peer
->ifname
) {
16435 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
16439 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
16440 vty_out(vty
, " neighbor %s passive\n", addr
);
16442 /* ebgp-multihop */
16443 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
16444 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
16445 && peer
->ttl
== MAXTTL
)) {
16446 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
16447 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
16452 /* ttl-security hops */
16453 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
16454 if (!peer_group_active(peer
)
16455 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
16456 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
16457 addr
, peer
->gtsm_hops
);
16461 /* disable-connected-check */
16462 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
16463 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
16465 /* enforce-first-as */
16466 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
16467 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
16469 /* update-source */
16470 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
16471 if (peer
->update_source
)
16472 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16473 sockunion2str(peer
->update_source
, buf
,
16475 else if (peer
->update_if
)
16476 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16480 /* advertisement-interval */
16481 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
16482 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
16486 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
16487 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
16488 peer
->keepalive
, peer
->holdtime
);
16490 /* timers connect */
16491 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
16492 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16494 /* need special-case handling for changed default values due to
16495 * config profile / version (because there is no "timers bgp connect"
16496 * command, we need to save this per-peer :/)
16498 else if (!peer_group_active(peer
) && !peer
->connect
&&
16499 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
16500 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16501 peer
->bgp
->default_connect_retry
);
16503 /* timers delayopen */
16504 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
16505 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16507 /* Save config even though flag is not set if default values have been
16510 else if (!peer_group_active(peer
) && !peer
->delayopen
16511 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
16512 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16513 peer
->bgp
->default_delayopen
);
16515 /* capability dynamic */
16516 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
16517 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
16519 /* capability extended-nexthop */
16520 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
16521 if (!peer
->conf_if
) {
16522 if (CHECK_FLAG(peer
->flags_invert
,
16523 PEER_FLAG_CAPABILITY_ENHE
))
16525 " no neighbor %s capability extended-nexthop\n",
16529 " neighbor %s capability extended-nexthop\n",
16534 /* dont-capability-negotiation */
16535 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
16536 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
16538 /* override-capability */
16539 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
16540 vty_out(vty
, " neighbor %s override-capability\n", addr
);
16542 /* strict-capability-match */
16543 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
16544 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
16546 /* Sender side AS path loop detection. */
16547 if (peer
->as_path_loop_detection
)
16548 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
16551 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16552 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
16554 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16555 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
16557 " neighbor %s graceful-restart-helper\n", addr
);
16558 } else if (CHECK_FLAG(
16559 peer
->peer_gr_new_status_flag
,
16560 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
16562 " neighbor %s graceful-restart\n", addr
);
16564 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16565 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
16567 peer
->peer_gr_new_status_flag
,
16568 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
16569 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
16575 /* BGP peer configuration display function. */
16576 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
16577 struct peer
*peer
, afi_t afi
, safi_t safi
)
16579 struct peer
*g_peer
= NULL
;
16581 bool flag_scomm
, flag_secomm
, flag_slcomm
;
16583 /* Skip dynamic neighbors. */
16584 if (peer_dynamic_neighbor(peer
))
16588 addr
= peer
->conf_if
;
16592 /************************************
16593 ****** Per AF to the neighbor ******
16594 ************************************/
16595 if (peer_group_active(peer
)) {
16596 g_peer
= peer
->group
->conf
;
16598 /* If the peer-group is active but peer is not, print a 'no
16600 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
16601 vty_out(vty
, " no neighbor %s activate\n", addr
);
16604 /* If the peer-group is not active but peer is, print an
16606 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
16607 vty_out(vty
, " neighbor %s activate\n", addr
);
16610 if (peer
->afc
[afi
][safi
]) {
16611 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
16612 if (CHECK_FLAG(bgp
->flags
,
16613 BGP_FLAG_NO_DEFAULT_IPV4
)) {
16614 vty_out(vty
, " neighbor %s activate\n",
16618 vty_out(vty
, " neighbor %s activate\n", addr
);
16620 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
16621 if (!CHECK_FLAG(bgp
->flags
,
16622 BGP_FLAG_NO_DEFAULT_IPV4
)) {
16624 " no neighbor %s activate\n",
16631 /* addpath TX knobs */
16632 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
16633 switch (peer
->addpath_type
[afi
][safi
]) {
16634 case BGP_ADDPATH_ALL
:
16635 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
16638 case BGP_ADDPATH_BEST_PER_AS
:
16640 " neighbor %s addpath-tx-bestpath-per-AS\n",
16643 case BGP_ADDPATH_MAX
:
16644 case BGP_ADDPATH_NONE
:
16649 /* ORF capability. */
16650 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
16651 || peergroup_af_flag_check(peer
, afi
, safi
,
16652 PEER_FLAG_ORF_PREFIX_RM
)) {
16653 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
16655 if (peergroup_af_flag_check(peer
, afi
, safi
,
16656 PEER_FLAG_ORF_PREFIX_SM
)
16657 && peergroup_af_flag_check(peer
, afi
, safi
,
16658 PEER_FLAG_ORF_PREFIX_RM
))
16659 vty_out(vty
, " both");
16660 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16661 PEER_FLAG_ORF_PREFIX_SM
))
16662 vty_out(vty
, " send");
16664 vty_out(vty
, " receive");
16665 vty_out(vty
, "\n");
16668 /* Route reflector client. */
16669 if (peergroup_af_flag_check(peer
, afi
, safi
,
16670 PEER_FLAG_REFLECTOR_CLIENT
)) {
16671 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
16674 /* next-hop-self force */
16675 if (peergroup_af_flag_check(peer
, afi
, safi
,
16676 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
16677 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
16680 /* next-hop-self */
16681 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
16682 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
16685 /* remove-private-AS */
16686 if (peergroup_af_flag_check(peer
, afi
, safi
,
16687 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
16688 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
16692 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16693 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
16694 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
16698 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16699 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
16700 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
16703 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16704 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
16705 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
16709 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
16710 vty_out(vty
, " neighbor %s as-override\n", addr
);
16713 /* send-community print. */
16714 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16715 PEER_FLAG_SEND_COMMUNITY
);
16716 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16717 PEER_FLAG_SEND_EXT_COMMUNITY
);
16718 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16719 PEER_FLAG_SEND_LARGE_COMMUNITY
);
16721 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
16722 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
16725 vty_out(vty
, " no neighbor %s send-community\n", addr
);
16728 " no neighbor %s send-community extended\n",
16732 vty_out(vty
, " no neighbor %s send-community large\n",
16736 /* Default information */
16737 if (peergroup_af_flag_check(peer
, afi
, safi
,
16738 PEER_FLAG_DEFAULT_ORIGINATE
)) {
16739 vty_out(vty
, " neighbor %s default-originate", addr
);
16741 if (peer
->default_rmap
[afi
][safi
].name
)
16742 vty_out(vty
, " route-map %s",
16743 peer
->default_rmap
[afi
][safi
].name
);
16745 vty_out(vty
, "\n");
16748 /* Soft reconfiguration inbound. */
16749 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
16750 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
16754 /* maximum-prefix. */
16755 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
16756 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
16757 peer
->pmax
[afi
][safi
]);
16759 if (peer
->pmax_threshold
[afi
][safi
]
16760 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
16761 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
16762 if (peer_af_flag_check(peer
, afi
, safi
,
16763 PEER_FLAG_MAX_PREFIX_WARNING
))
16764 vty_out(vty
, " warning-only");
16765 if (peer
->pmax_restart
[afi
][safi
])
16766 vty_out(vty
, " restart %u",
16767 peer
->pmax_restart
[afi
][safi
]);
16768 if (peer_af_flag_check(peer
, afi
, safi
,
16769 PEER_FLAG_MAX_PREFIX_FORCE
))
16770 vty_out(vty
, " force");
16772 vty_out(vty
, "\n");
16775 /* maximum-prefix-out */
16776 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
16777 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
16778 addr
, peer
->pmax_out
[afi
][safi
]);
16780 /* Route server client. */
16781 if (peergroup_af_flag_check(peer
, afi
, safi
,
16782 PEER_FLAG_RSERVER_CLIENT
)) {
16783 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
16786 /* Nexthop-local unchanged. */
16787 if (peergroup_af_flag_check(peer
, afi
, safi
,
16788 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
16789 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
16792 /* allowas-in <1-10> */
16793 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
16794 if (peer_af_flag_check(peer
, afi
, safi
,
16795 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
16796 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
16797 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
16798 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
16800 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
16801 peer
->allowas_in
[afi
][safi
]);
16806 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
16807 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
16808 peer
->weight
[afi
][safi
]);
16811 bgp_config_write_filter(vty
, peer
, afi
, safi
);
16813 /* atribute-unchanged. */
16814 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
16815 || (safi
!= SAFI_EVPN
16816 && peer_af_flag_check(peer
, afi
, safi
,
16817 PEER_FLAG_NEXTHOP_UNCHANGED
))
16818 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
16820 if (!peer_group_active(peer
)
16821 || peergroup_af_flag_check(peer
, afi
, safi
,
16822 PEER_FLAG_AS_PATH_UNCHANGED
)
16823 || peergroup_af_flag_check(peer
, afi
, safi
,
16824 PEER_FLAG_NEXTHOP_UNCHANGED
)
16825 || peergroup_af_flag_check(peer
, afi
, safi
,
16826 PEER_FLAG_MED_UNCHANGED
)) {
16829 " neighbor %s attribute-unchanged%s%s%s\n",
16831 peer_af_flag_check(peer
, afi
, safi
,
16832 PEER_FLAG_AS_PATH_UNCHANGED
)
16835 peer_af_flag_check(peer
, afi
, safi
,
16836 PEER_FLAG_NEXTHOP_UNCHANGED
)
16839 peer_af_flag_check(peer
, afi
, safi
,
16840 PEER_FLAG_MED_UNCHANGED
)
16847 /* Address family based peer configuration display. */
16848 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
16852 struct peer_group
*group
;
16853 struct listnode
*node
, *nnode
;
16856 vty_frame(vty
, " !\n address-family ");
16857 if (afi
== AFI_IP
) {
16858 if (safi
== SAFI_UNICAST
)
16859 vty_frame(vty
, "ipv4 unicast");
16860 else if (safi
== SAFI_LABELED_UNICAST
)
16861 vty_frame(vty
, "ipv4 labeled-unicast");
16862 else if (safi
== SAFI_MULTICAST
)
16863 vty_frame(vty
, "ipv4 multicast");
16864 else if (safi
== SAFI_MPLS_VPN
)
16865 vty_frame(vty
, "ipv4 vpn");
16866 else if (safi
== SAFI_ENCAP
)
16867 vty_frame(vty
, "ipv4 encap");
16868 else if (safi
== SAFI_FLOWSPEC
)
16869 vty_frame(vty
, "ipv4 flowspec");
16870 } else if (afi
== AFI_IP6
) {
16871 if (safi
== SAFI_UNICAST
)
16872 vty_frame(vty
, "ipv6 unicast");
16873 else if (safi
== SAFI_LABELED_UNICAST
)
16874 vty_frame(vty
, "ipv6 labeled-unicast");
16875 else if (safi
== SAFI_MULTICAST
)
16876 vty_frame(vty
, "ipv6 multicast");
16877 else if (safi
== SAFI_MPLS_VPN
)
16878 vty_frame(vty
, "ipv6 vpn");
16879 else if (safi
== SAFI_ENCAP
)
16880 vty_frame(vty
, "ipv6 encap");
16881 else if (safi
== SAFI_FLOWSPEC
)
16882 vty_frame(vty
, "ipv6 flowspec");
16883 } else if (afi
== AFI_L2VPN
) {
16884 if (safi
== SAFI_EVPN
)
16885 vty_frame(vty
, "l2vpn evpn");
16887 vty_frame(vty
, "\n");
16889 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
16891 bgp_config_write_network(vty
, bgp
, afi
, safi
);
16893 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
16895 /* BGP flag dampening. */
16896 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
16897 bgp_config_write_damp(vty
, afi
, safi
);
16899 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
16900 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
16902 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
16903 /* Skip dynamic neighbors. */
16904 if (peer_dynamic_neighbor(peer
))
16907 /* Do not display doppelganger peers */
16908 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
16909 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
16912 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
16913 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
16915 if (safi
== SAFI_EVPN
)
16916 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
16918 if (safi
== SAFI_FLOWSPEC
)
16919 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
16921 if (safi
== SAFI_UNICAST
) {
16922 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
16923 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
16924 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
16926 vty_out(vty
, " export vpn\n");
16928 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
16929 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
16931 vty_out(vty
, " import vpn\n");
16933 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
16934 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
16937 for (ALL_LIST_ELEMENTS_RO(
16938 bgp
->vpn_policy
[afi
].import_vrf
, node
,
16940 vty_out(vty
, " import vrf %s\n", name
);
16944 vty_endframe(vty
, " exit-address-family\n");
16947 int bgp_config_write(struct vty
*vty
)
16950 struct peer_group
*group
;
16952 struct listnode
*node
, *nnode
;
16953 struct listnode
*mnode
, *mnnode
;
16955 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
16956 vty_out(vty
, "bgp route-map delay-timer %u\n",
16957 bm
->rmap_update_timer
);
16959 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
16960 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
16961 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
16962 vty_out(vty
, " %d", bm
->v_establish_wait
);
16963 vty_out(vty
, "\n");
16966 if (bm
->wait_for_fib
)
16967 vty_out(vty
, "bgp suppress-fib-pending\n");
16969 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
16970 vty_out(vty
, "bgp graceful-shutdown\n");
16972 /* No-RIB (Zebra) option flag configuration */
16973 if (bgp_option_check(BGP_OPT_NO_FIB
))
16974 vty_out(vty
, "bgp no-rib\n");
16976 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
16977 vty_out(vty
, "no bgp send-extra-data zebra\n");
16979 /* BGP configuration. */
16980 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
16982 /* skip all auto created vrf as they dont have user config */
16983 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
16986 /* Router bgp ASN */
16987 vty_out(vty
, "router bgp %u", bgp
->as
);
16990 vty_out(vty
, " %s %s",
16991 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
16992 ? "view" : "vrf", bgp
->name
);
16993 vty_out(vty
, "\n");
16995 /* BGP fast-external-failover. */
16996 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
16997 vty_out(vty
, " no bgp fast-external-failover\n");
16999 /* BGP router ID. */
17000 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17001 vty_out(vty
, " bgp router-id %pI4\n",
17002 &bgp
->router_id_static
);
17004 /* Suppress fib pending */
17005 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17006 vty_out(vty
, " bgp suppress-fib-pending\n");
17008 /* BGP log-neighbor-changes. */
17009 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17010 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17011 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17012 CHECK_FLAG(bgp
->flags
,
17013 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17017 /* BGP configuration. */
17018 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17019 vty_out(vty
, " bgp always-compare-med\n");
17021 /* RFC8212 default eBGP policy. */
17022 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17023 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17024 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17025 CHECK_FLAG(bgp
->flags
,
17026 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17030 /* draft-ietf-idr-deprecate-as-set-confed-set */
17031 if (bgp
->reject_as_sets
)
17032 vty_out(vty
, " bgp reject-as-sets\n");
17034 /* BGP default ipv4-unicast. */
17035 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
))
17036 vty_out(vty
, " no bgp default ipv4-unicast\n");
17038 /* BGP default local-preference. */
17039 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17040 vty_out(vty
, " bgp default local-preference %u\n",
17041 bgp
->default_local_pref
);
17043 /* BGP default show-hostname */
17044 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17045 != SAVE_BGP_SHOW_HOSTNAME
)
17046 vty_out(vty
, " %sbgp default show-hostname\n",
17047 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17051 /* BGP default show-nexthop-hostname */
17052 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17053 != SAVE_BGP_SHOW_HOSTNAME
)
17054 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17055 CHECK_FLAG(bgp
->flags
,
17056 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17060 /* BGP default subgroup-pkt-queue-max. */
17061 if (bgp
->default_subgroup_pkt_queue_max
17062 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17063 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17064 bgp
->default_subgroup_pkt_queue_max
);
17066 /* BGP client-to-client reflection. */
17067 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17068 vty_out(vty
, " no bgp client-to-client reflection\n");
17070 /* BGP cluster ID. */
17071 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17072 vty_out(vty
, " bgp cluster-id %pI4\n",
17075 /* Disable ebgp connected nexthop check */
17076 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17078 " bgp disable-ebgp-connected-route-check\n");
17080 /* Confederation identifier*/
17081 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17082 vty_out(vty
, " bgp confederation identifier %u\n",
17085 /* Confederation peer */
17086 if (bgp
->confed_peers_cnt
> 0) {
17089 vty_out(vty
, " bgp confederation peers");
17091 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17092 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17094 vty_out(vty
, "\n");
17097 /* BGP deterministic-med. */
17098 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17099 != SAVE_BGP_DETERMINISTIC_MED
)
17100 vty_out(vty
, " %sbgp deterministic-med\n",
17101 CHECK_FLAG(bgp
->flags
,
17102 BGP_FLAG_DETERMINISTIC_MED
)
17106 /* BGP update-delay. */
17107 bgp_config_write_update_delay(vty
, bgp
);
17109 if (bgp
->v_maxmed_onstartup
17110 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17111 vty_out(vty
, " bgp max-med on-startup %u",
17112 bgp
->v_maxmed_onstartup
);
17113 if (bgp
->maxmed_onstartup_value
17114 != BGP_MAXMED_VALUE_DEFAULT
)
17115 vty_out(vty
, " %u",
17116 bgp
->maxmed_onstartup_value
);
17117 vty_out(vty
, "\n");
17119 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17120 vty_out(vty
, " bgp max-med administrative");
17121 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17122 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17123 vty_out(vty
, "\n");
17127 bgp_config_write_wpkt_quanta(vty
, bgp
);
17129 bgp_config_write_rpkt_quanta(vty
, bgp
);
17131 /* coalesce time */
17132 bgp_config_write_coalesce_time(vty
, bgp
);
17134 /* BGP per-instance graceful-shutdown */
17135 /* BGP-wide settings and per-instance settings are mutually
17138 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17139 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17140 vty_out(vty
, " bgp graceful-shutdown\n");
17142 /* BGP graceful-restart. */
17143 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17145 " bgp graceful-restart stalepath-time %u\n",
17146 bgp
->stalepath_time
);
17148 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17149 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17150 bgp
->restart_time
);
17152 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17154 " bgp graceful-restart select-defer-time %u\n",
17155 bgp
->select_defer_time
);
17157 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17158 vty_out(vty
, " bgp graceful-restart\n");
17160 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17161 vty_out(vty
, " bgp graceful-restart-disable\n");
17163 /* BGP graceful-restart Preserve State F bit. */
17164 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17166 " bgp graceful-restart preserve-fw-state\n");
17168 /* Stale timer for RIB */
17169 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17171 " bgp graceful-restart rib-stale-time %u\n",
17172 bgp
->rib_stale_time
);
17174 /* BGP bestpath method. */
17175 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17176 vty_out(vty
, " bgp bestpath as-path ignore\n");
17177 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17178 vty_out(vty
, " bgp bestpath as-path confed\n");
17180 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17181 if (CHECK_FLAG(bgp
->flags
,
17182 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17184 " bgp bestpath as-path multipath-relax as-set\n");
17187 " bgp bestpath as-path multipath-relax\n");
17191 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17193 " bgp route-reflector allow-outbound-policy\n");
17195 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17196 vty_out(vty
, " bgp bestpath compare-routerid\n");
17197 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17198 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17199 vty_out(vty
, " bgp bestpath med");
17200 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17201 vty_out(vty
, " confed");
17202 if (CHECK_FLAG(bgp
->flags
,
17203 BGP_FLAG_MED_MISSING_AS_WORST
))
17204 vty_out(vty
, " missing-as-worst");
17205 vty_out(vty
, "\n");
17208 /* Link bandwidth handling. */
17209 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17210 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17211 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17212 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17213 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17214 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17216 /* BGP network import check. */
17217 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17218 != SAVE_BGP_IMPORT_CHECK
)
17219 vty_out(vty
, " %sbgp network import-check\n",
17220 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17224 /* BGP timers configuration. */
17225 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17226 && bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17227 vty_out(vty
, " timers bgp %u %u\n",
17228 bgp
->default_keepalive
, bgp
->default_holdtime
);
17231 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17232 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17235 /* Normal neighbor configuration. */
17236 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17237 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17238 bgp_config_write_peer_global(vty
, bgp
, peer
);
17241 /* listen range and limit for dynamic BGP neighbors */
17242 bgp_config_write_listen(vty
, bgp
);
17245 * BGP default autoshutdown neighbors
17247 * This must be placed after any peer and peer-group
17248 * configuration, to avoid setting all peers to shutdown after
17249 * a daemon restart, which is undesired behavior. (see #2286)
17251 if (bgp
->autoshutdown
)
17252 vty_out(vty
, " bgp default shutdown\n");
17254 /* BGP instance administrative shutdown */
17255 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17256 vty_out(vty
, " bgp shutdown\n");
17258 /* IPv4 unicast configuration. */
17259 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17261 /* IPv4 multicast configuration. */
17262 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17264 /* IPv4 labeled-unicast configuration. */
17265 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17267 /* IPv4 VPN configuration. */
17268 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17270 /* ENCAPv4 configuration. */
17271 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17273 /* FLOWSPEC v4 configuration. */
17274 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17276 /* IPv6 unicast configuration. */
17277 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17279 /* IPv6 multicast configuration. */
17280 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17282 /* IPv6 labeled-unicast configuration. */
17283 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17284 SAFI_LABELED_UNICAST
);
17286 /* IPv6 VPN configuration. */
17287 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17289 /* ENCAPv6 configuration. */
17290 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17292 /* FLOWSPEC v6 configuration. */
17293 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17295 /* EVPN configuration. */
17296 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17298 hook_call(bgp_inst_config_write
, bgp
, vty
);
17300 #ifdef ENABLE_BGP_VNC
17301 bgp_rfapi_cfg_write(vty
, bgp
);
17304 vty_out(vty
, "!\n");
17310 /* BGP node structure. */
17311 static struct cmd_node bgp_node
= {
17314 .parent_node
= CONFIG_NODE
,
17315 .prompt
= "%s(config-router)# ",
17316 .config_write
= bgp_config_write
,
17319 static struct cmd_node bgp_ipv4_unicast_node
= {
17320 .name
= "bgp ipv4 unicast",
17321 .node
= BGP_IPV4_NODE
,
17322 .parent_node
= BGP_NODE
,
17323 .prompt
= "%s(config-router-af)# ",
17326 static struct cmd_node bgp_ipv4_multicast_node
= {
17327 .name
= "bgp ipv4 multicast",
17328 .node
= BGP_IPV4M_NODE
,
17329 .parent_node
= BGP_NODE
,
17330 .prompt
= "%s(config-router-af)# ",
17333 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
17334 .name
= "bgp ipv4 labeled unicast",
17335 .node
= BGP_IPV4L_NODE
,
17336 .parent_node
= BGP_NODE
,
17337 .prompt
= "%s(config-router-af)# ",
17340 static struct cmd_node bgp_ipv6_unicast_node
= {
17341 .name
= "bgp ipv6",
17342 .node
= BGP_IPV6_NODE
,
17343 .parent_node
= BGP_NODE
,
17344 .prompt
= "%s(config-router-af)# ",
17347 static struct cmd_node bgp_ipv6_multicast_node
= {
17348 .name
= "bgp ipv6 multicast",
17349 .node
= BGP_IPV6M_NODE
,
17350 .parent_node
= BGP_NODE
,
17351 .prompt
= "%s(config-router-af)# ",
17354 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
17355 .name
= "bgp ipv6 labeled unicast",
17356 .node
= BGP_IPV6L_NODE
,
17357 .parent_node
= BGP_NODE
,
17358 .prompt
= "%s(config-router-af)# ",
17361 static struct cmd_node bgp_vpnv4_node
= {
17362 .name
= "bgp vpnv4",
17363 .node
= BGP_VPNV4_NODE
,
17364 .parent_node
= BGP_NODE
,
17365 .prompt
= "%s(config-router-af)# ",
17368 static struct cmd_node bgp_vpnv6_node
= {
17369 .name
= "bgp vpnv6",
17370 .node
= BGP_VPNV6_NODE
,
17371 .parent_node
= BGP_NODE
,
17372 .prompt
= "%s(config-router-af-vpnv6)# ",
17375 static struct cmd_node bgp_evpn_node
= {
17376 .name
= "bgp evpn",
17377 .node
= BGP_EVPN_NODE
,
17378 .parent_node
= BGP_NODE
,
17379 .prompt
= "%s(config-router-evpn)# ",
17382 static struct cmd_node bgp_evpn_vni_node
= {
17383 .name
= "bgp evpn vni",
17384 .node
= BGP_EVPN_VNI_NODE
,
17385 .parent_node
= BGP_EVPN_NODE
,
17386 .prompt
= "%s(config-router-af-vni)# ",
17389 static struct cmd_node bgp_flowspecv4_node
= {
17390 .name
= "bgp ipv4 flowspec",
17391 .node
= BGP_FLOWSPECV4_NODE
,
17392 .parent_node
= BGP_NODE
,
17393 .prompt
= "%s(config-router-af)# ",
17396 static struct cmd_node bgp_flowspecv6_node
= {
17397 .name
= "bgp ipv6 flowspec",
17398 .node
= BGP_FLOWSPECV6_NODE
,
17399 .parent_node
= BGP_NODE
,
17400 .prompt
= "%s(config-router-af-vpnv6)# ",
17403 static void community_list_vty(void);
17405 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
17409 struct listnode
*lnbgp
, *lnpeer
;
17411 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17412 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
17413 /* only provide suggestions on the appropriate input
17415 * they'll otherwise show up multiple times */
17416 enum cmd_token_type match_type
;
17417 char *name
= peer
->host
;
17419 if (peer
->conf_if
) {
17420 match_type
= VARIABLE_TKN
;
17421 name
= peer
->conf_if
;
17422 } else if (strchr(peer
->host
, ':'))
17423 match_type
= IPV6_TKN
;
17425 match_type
= IPV4_TKN
;
17427 if (token
->type
!= match_type
)
17430 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
17435 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
17436 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
17437 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
17438 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
17439 {.completions
= NULL
}};
17441 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
17444 struct peer_group
*group
;
17445 struct listnode
*lnbgp
, *lnpeer
;
17447 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17448 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
17449 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
17454 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
17455 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
17456 {.completions
= NULL
} };
17458 void bgp_vty_init(void)
17460 cmd_variable_handler_register(bgp_var_neighbor
);
17461 cmd_variable_handler_register(bgp_var_peergroup
);
17463 /* Install bgp top node. */
17464 install_node(&bgp_node
);
17465 install_node(&bgp_ipv4_unicast_node
);
17466 install_node(&bgp_ipv4_multicast_node
);
17467 install_node(&bgp_ipv4_labeled_unicast_node
);
17468 install_node(&bgp_ipv6_unicast_node
);
17469 install_node(&bgp_ipv6_multicast_node
);
17470 install_node(&bgp_ipv6_labeled_unicast_node
);
17471 install_node(&bgp_vpnv4_node
);
17472 install_node(&bgp_vpnv6_node
);
17473 install_node(&bgp_evpn_node
);
17474 install_node(&bgp_evpn_vni_node
);
17475 install_node(&bgp_flowspecv4_node
);
17476 install_node(&bgp_flowspecv6_node
);
17478 /* Install default VTY commands to new nodes. */
17479 install_default(BGP_NODE
);
17480 install_default(BGP_IPV4_NODE
);
17481 install_default(BGP_IPV4M_NODE
);
17482 install_default(BGP_IPV4L_NODE
);
17483 install_default(BGP_IPV6_NODE
);
17484 install_default(BGP_IPV6M_NODE
);
17485 install_default(BGP_IPV6L_NODE
);
17486 install_default(BGP_VPNV4_NODE
);
17487 install_default(BGP_VPNV6_NODE
);
17488 install_default(BGP_FLOWSPECV4_NODE
);
17489 install_default(BGP_FLOWSPECV6_NODE
);
17490 install_default(BGP_EVPN_NODE
);
17491 install_default(BGP_EVPN_VNI_NODE
);
17493 /* "bgp local-mac" hidden commands. */
17494 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
17495 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
17497 /* "bgp suppress-fib-pending" global */
17498 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
17500 /* bgp route-map delay-timer commands. */
17501 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17502 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17504 /* global bgp update-delay command */
17505 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
17506 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
17508 /* global bgp graceful-shutdown command */
17509 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
17510 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
17512 /* Dummy commands (Currently not supported) */
17513 install_element(BGP_NODE
, &no_synchronization_cmd
);
17514 install_element(BGP_NODE
, &no_auto_summary_cmd
);
17516 /* "router bgp" commands. */
17517 install_element(CONFIG_NODE
, &router_bgp_cmd
);
17519 /* "no router bgp" commands. */
17520 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
17522 /* "bgp router-id" commands. */
17523 install_element(BGP_NODE
, &bgp_router_id_cmd
);
17524 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
17526 /* "bgp suppress-fib-pending" command */
17527 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
17529 /* "bgp cluster-id" commands. */
17530 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
17531 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
17533 /* "bgp no-rib" commands. */
17534 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
17535 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
17537 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
17539 /* "bgp confederation" commands. */
17540 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
17541 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
17543 /* "bgp confederation peers" commands. */
17544 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
17545 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
17547 /* bgp max-med command */
17548 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
17549 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
17550 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
17551 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
17552 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
17554 /* bgp disable-ebgp-connected-nh-check */
17555 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
17556 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
17558 /* bgp update-delay command */
17559 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
17560 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
17562 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
17563 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
17565 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
17566 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
17568 /* "maximum-paths" commands. */
17569 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
17570 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
17571 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
17572 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
17573 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
17574 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
17575 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
17576 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
17577 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
17578 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
17579 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17580 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17581 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
17582 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17583 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17585 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
17586 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
17587 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17588 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17589 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17590 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
17591 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
17592 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17593 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17594 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17596 /* "timers bgp" commands. */
17597 install_element(BGP_NODE
, &bgp_timers_cmd
);
17598 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
17600 /* route-map delay-timer commands - per instance for backwards compat.
17602 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17603 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17605 /* "bgp client-to-client reflection" commands */
17606 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
17607 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
17609 /* "bgp always-compare-med" commands */
17610 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
17611 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
17613 /* bgp ebgp-requires-policy */
17614 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
17615 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
17617 /* bgp reject-as-sets */
17618 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
17619 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
17621 /* "bgp deterministic-med" commands */
17622 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
17623 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
17625 /* "bgp graceful-restart" command */
17626 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
17627 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
17629 /* "bgp graceful-restart-disable" command */
17630 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
17631 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
17633 /* "neighbor a:b:c:d graceful-restart" command */
17634 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
17635 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
17637 /* "neighbor a:b:c:d graceful-restart-disable" command */
17638 install_element(BGP_NODE
,
17639 &bgp_neighbor_graceful_restart_disable_set_cmd
);
17640 install_element(BGP_NODE
,
17641 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
17643 /* "neighbor a:b:c:d graceful-restart-helper" command */
17644 install_element(BGP_NODE
,
17645 &bgp_neighbor_graceful_restart_helper_set_cmd
);
17646 install_element(BGP_NODE
,
17647 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
17649 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
17650 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
17651 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
17652 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
17653 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
17654 install_element(BGP_NODE
,
17655 &no_bgp_graceful_restart_select_defer_time_cmd
);
17656 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
17657 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
17659 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
17660 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
17661 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
17662 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
17664 /* "bgp graceful-shutdown" commands */
17665 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
17666 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
17668 /* "bgp fast-external-failover" commands */
17669 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
17670 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
17672 /* "bgp bestpath compare-routerid" commands */
17673 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
17674 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
17676 /* "bgp bestpath as-path ignore" commands */
17677 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
17678 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
17680 /* "bgp bestpath as-path confed" commands */
17681 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
17682 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
17684 /* "bgp bestpath as-path multipath-relax" commands */
17685 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
17686 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
17688 /* "bgp log-neighbor-changes" commands */
17689 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
17690 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
17692 /* "bgp bestpath med" commands */
17693 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
17694 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
17696 /* "bgp bestpath bandwidth" commands */
17697 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
17698 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
17700 /* "no bgp default ipv4-unicast" commands. */
17701 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
17702 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
17704 /* "bgp network import-check" commands. */
17705 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
17706 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
17707 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
17709 /* "bgp default local-preference" commands. */
17710 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
17711 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
17713 /* bgp default show-hostname */
17714 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
17715 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
17717 /* bgp default show-nexthop-hostname */
17718 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
17719 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
17721 /* "bgp default subgroup-pkt-queue-max" commands. */
17722 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
17723 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
17725 /* bgp ibgp-allow-policy-mods command */
17726 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
17727 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
17729 /* "bgp listen limit" commands. */
17730 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
17731 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
17733 /* "bgp listen range" commands. */
17734 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
17735 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
17737 /* "bgp default shutdown" command */
17738 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
17740 /* "bgp shutdown" commands */
17741 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
17742 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
17743 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
17744 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
17746 /* "neighbor remote-as" commands. */
17747 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
17748 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
17749 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
17750 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
17751 install_element(BGP_NODE
,
17752 &neighbor_interface_v6only_config_remote_as_cmd
);
17753 install_element(BGP_NODE
, &no_neighbor_cmd
);
17754 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
17756 /* "neighbor peer-group" commands. */
17757 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
17758 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
17759 install_element(BGP_NODE
,
17760 &no_neighbor_interface_peer_group_remote_as_cmd
);
17762 /* "neighbor local-as" commands. */
17763 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
17764 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
17765 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
17766 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
17768 /* "neighbor solo" commands. */
17769 install_element(BGP_NODE
, &neighbor_solo_cmd
);
17770 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
17772 /* "neighbor password" commands. */
17773 install_element(BGP_NODE
, &neighbor_password_cmd
);
17774 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
17776 /* "neighbor activate" commands. */
17777 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
17778 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
17779 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
17780 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
17781 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
17782 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
17783 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
17784 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
17785 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
17786 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
17787 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
17788 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
17790 /* "no neighbor activate" commands. */
17791 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
17792 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
17793 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
17794 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
17795 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
17796 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
17797 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
17798 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
17799 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
17800 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
17801 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
17802 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
17804 /* "neighbor peer-group" set commands. */
17805 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
17806 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17807 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17808 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17809 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17810 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17811 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17812 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
17813 install_element(BGP_FLOWSPECV4_NODE
,
17814 &neighbor_set_peer_group_hidden_cmd
);
17815 install_element(BGP_FLOWSPECV6_NODE
,
17816 &neighbor_set_peer_group_hidden_cmd
);
17818 /* "no neighbor peer-group unset" commands. */
17819 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
17820 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17821 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17822 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17823 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17824 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17825 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17826 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
17827 install_element(BGP_FLOWSPECV4_NODE
,
17828 &no_neighbor_set_peer_group_hidden_cmd
);
17829 install_element(BGP_FLOWSPECV6_NODE
,
17830 &no_neighbor_set_peer_group_hidden_cmd
);
17832 /* "neighbor softreconfiguration inbound" commands.*/
17833 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
17834 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
17835 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
17836 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17837 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
17838 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17839 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
17840 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17841 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
17842 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17843 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
17844 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17845 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
17846 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17847 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
17848 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17849 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
17850 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17851 install_element(BGP_FLOWSPECV4_NODE
,
17852 &neighbor_soft_reconfiguration_cmd
);
17853 install_element(BGP_FLOWSPECV4_NODE
,
17854 &no_neighbor_soft_reconfiguration_cmd
);
17855 install_element(BGP_FLOWSPECV6_NODE
,
17856 &neighbor_soft_reconfiguration_cmd
);
17857 install_element(BGP_FLOWSPECV6_NODE
,
17858 &no_neighbor_soft_reconfiguration_cmd
);
17859 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
17860 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
17862 /* "neighbor attribute-unchanged" commands. */
17863 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
17864 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
17865 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
17866 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
17867 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
17868 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
17869 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
17870 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
17871 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
17872 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
17873 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
17874 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
17875 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
17876 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
17877 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
17878 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
17879 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
17880 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
17882 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
17883 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
17885 /* "nexthop-local unchanged" commands */
17886 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
17887 install_element(BGP_IPV6_NODE
,
17888 &no_neighbor_nexthop_local_unchanged_cmd
);
17890 /* "neighbor next-hop-self" commands. */
17891 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
17892 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
17893 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
17894 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
17895 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
17896 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
17897 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
17898 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
17899 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
17900 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
17901 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
17902 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
17903 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
17904 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
17905 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
17906 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
17907 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
17908 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
17909 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
17910 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
17912 /* "neighbor next-hop-self force" commands. */
17913 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
17914 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
17915 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17916 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
17917 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
17918 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17919 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17920 install_element(BGP_IPV4_NODE
,
17921 &no_neighbor_nexthop_self_all_hidden_cmd
);
17922 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
17923 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17924 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17925 install_element(BGP_IPV4M_NODE
,
17926 &no_neighbor_nexthop_self_all_hidden_cmd
);
17927 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
17928 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17929 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17930 install_element(BGP_IPV4L_NODE
,
17931 &no_neighbor_nexthop_self_all_hidden_cmd
);
17932 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
17933 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17934 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17935 install_element(BGP_IPV6_NODE
,
17936 &no_neighbor_nexthop_self_all_hidden_cmd
);
17937 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
17938 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17939 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17940 install_element(BGP_IPV6M_NODE
,
17941 &no_neighbor_nexthop_self_all_hidden_cmd
);
17942 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
17943 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17944 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17945 install_element(BGP_IPV6L_NODE
,
17946 &no_neighbor_nexthop_self_all_hidden_cmd
);
17947 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
17948 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17949 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17950 install_element(BGP_VPNV4_NODE
,
17951 &no_neighbor_nexthop_self_all_hidden_cmd
);
17952 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
17953 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17954 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
17955 install_element(BGP_VPNV6_NODE
,
17956 &no_neighbor_nexthop_self_all_hidden_cmd
);
17957 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
17958 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
17960 /* "neighbor as-override" commands. */
17961 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
17962 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
17963 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
17964 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
17965 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
17966 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
17967 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
17968 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
17969 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
17970 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
17971 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
17972 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
17973 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
17974 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
17975 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
17976 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
17977 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
17978 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
17980 /* "neighbor remove-private-AS" commands. */
17981 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
17982 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
17983 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
17984 install_element(BGP_NODE
,
17985 &no_neighbor_remove_private_as_all_hidden_cmd
);
17986 install_element(BGP_NODE
,
17987 &neighbor_remove_private_as_replace_as_hidden_cmd
);
17988 install_element(BGP_NODE
,
17989 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
17990 install_element(BGP_NODE
,
17991 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
17994 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
17995 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
17996 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
17997 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
17998 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
17999 install_element(BGP_IPV4_NODE
,
18000 &neighbor_remove_private_as_replace_as_cmd
);
18001 install_element(BGP_IPV4_NODE
,
18002 &no_neighbor_remove_private_as_replace_as_cmd
);
18003 install_element(BGP_IPV4_NODE
,
18004 &neighbor_remove_private_as_all_replace_as_cmd
);
18005 install_element(BGP_IPV4_NODE
,
18006 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18007 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
18008 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
18009 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
18010 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18011 install_element(BGP_IPV4M_NODE
,
18012 &neighbor_remove_private_as_replace_as_cmd
);
18013 install_element(BGP_IPV4M_NODE
,
18014 &no_neighbor_remove_private_as_replace_as_cmd
);
18015 install_element(BGP_IPV4M_NODE
,
18016 &neighbor_remove_private_as_all_replace_as_cmd
);
18017 install_element(BGP_IPV4M_NODE
,
18018 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18019 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
18020 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
18021 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
18022 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18023 install_element(BGP_IPV4L_NODE
,
18024 &neighbor_remove_private_as_replace_as_cmd
);
18025 install_element(BGP_IPV4L_NODE
,
18026 &no_neighbor_remove_private_as_replace_as_cmd
);
18027 install_element(BGP_IPV4L_NODE
,
18028 &neighbor_remove_private_as_all_replace_as_cmd
);
18029 install_element(BGP_IPV4L_NODE
,
18030 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18031 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
18032 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18033 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18034 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18035 install_element(BGP_IPV6_NODE
,
18036 &neighbor_remove_private_as_replace_as_cmd
);
18037 install_element(BGP_IPV6_NODE
,
18038 &no_neighbor_remove_private_as_replace_as_cmd
);
18039 install_element(BGP_IPV6_NODE
,
18040 &neighbor_remove_private_as_all_replace_as_cmd
);
18041 install_element(BGP_IPV6_NODE
,
18042 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18043 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
18044 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
18045 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
18046 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18047 install_element(BGP_IPV6M_NODE
,
18048 &neighbor_remove_private_as_replace_as_cmd
);
18049 install_element(BGP_IPV6M_NODE
,
18050 &no_neighbor_remove_private_as_replace_as_cmd
);
18051 install_element(BGP_IPV6M_NODE
,
18052 &neighbor_remove_private_as_all_replace_as_cmd
);
18053 install_element(BGP_IPV6M_NODE
,
18054 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18055 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
18056 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
18057 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
18058 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18059 install_element(BGP_IPV6L_NODE
,
18060 &neighbor_remove_private_as_replace_as_cmd
);
18061 install_element(BGP_IPV6L_NODE
,
18062 &no_neighbor_remove_private_as_replace_as_cmd
);
18063 install_element(BGP_IPV6L_NODE
,
18064 &neighbor_remove_private_as_all_replace_as_cmd
);
18065 install_element(BGP_IPV6L_NODE
,
18066 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18067 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
18068 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18069 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18070 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18071 install_element(BGP_VPNV4_NODE
,
18072 &neighbor_remove_private_as_replace_as_cmd
);
18073 install_element(BGP_VPNV4_NODE
,
18074 &no_neighbor_remove_private_as_replace_as_cmd
);
18075 install_element(BGP_VPNV4_NODE
,
18076 &neighbor_remove_private_as_all_replace_as_cmd
);
18077 install_element(BGP_VPNV4_NODE
,
18078 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18079 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
18080 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18081 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18082 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18083 install_element(BGP_VPNV6_NODE
,
18084 &neighbor_remove_private_as_replace_as_cmd
);
18085 install_element(BGP_VPNV6_NODE
,
18086 &no_neighbor_remove_private_as_replace_as_cmd
);
18087 install_element(BGP_VPNV6_NODE
,
18088 &neighbor_remove_private_as_all_replace_as_cmd
);
18089 install_element(BGP_VPNV6_NODE
,
18090 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18092 /* "neighbor send-community" commands.*/
18093 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
18094 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
18095 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
18096 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
18097 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
18098 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
18099 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
18100 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
18101 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
18102 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
18103 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
18104 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
18105 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
18106 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
18107 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
18108 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
18109 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
18110 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
18111 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
18112 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
18113 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
18114 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
18115 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
18116 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
18117 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
18118 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
18119 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
18120 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
18121 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
18122 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
18123 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
18124 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
18125 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
18126 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
18127 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
18128 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
18130 /* "neighbor route-reflector" commands.*/
18131 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
18132 install_element(BGP_NODE
,
18133 &no_neighbor_route_reflector_client_hidden_cmd
);
18134 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
18135 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
18136 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
18137 install_element(BGP_IPV4M_NODE
,
18138 &no_neighbor_route_reflector_client_cmd
);
18139 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
18140 install_element(BGP_IPV4L_NODE
,
18141 &no_neighbor_route_reflector_client_cmd
);
18142 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
18143 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
18144 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
18145 install_element(BGP_IPV6M_NODE
,
18146 &no_neighbor_route_reflector_client_cmd
);
18147 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
18148 install_element(BGP_IPV6L_NODE
,
18149 &no_neighbor_route_reflector_client_cmd
);
18150 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
18151 install_element(BGP_VPNV4_NODE
,
18152 &no_neighbor_route_reflector_client_cmd
);
18153 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
18154 install_element(BGP_VPNV6_NODE
,
18155 &no_neighbor_route_reflector_client_cmd
);
18156 install_element(BGP_FLOWSPECV4_NODE
,
18157 &neighbor_route_reflector_client_cmd
);
18158 install_element(BGP_FLOWSPECV4_NODE
,
18159 &no_neighbor_route_reflector_client_cmd
);
18160 install_element(BGP_FLOWSPECV6_NODE
,
18161 &neighbor_route_reflector_client_cmd
);
18162 install_element(BGP_FLOWSPECV6_NODE
,
18163 &no_neighbor_route_reflector_client_cmd
);
18164 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
18165 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
18167 /* "neighbor route-server" commands.*/
18168 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
18169 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
18170 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
18171 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
18172 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
18173 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
18174 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
18175 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
18176 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
18177 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
18178 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
18179 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
18180 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
18181 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
18182 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
18183 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
18184 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
18185 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
18186 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
18187 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
18188 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
18189 install_element(BGP_FLOWSPECV4_NODE
,
18190 &no_neighbor_route_server_client_cmd
);
18191 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
18192 install_element(BGP_FLOWSPECV6_NODE
,
18193 &no_neighbor_route_server_client_cmd
);
18195 /* "neighbor addpath-tx-all-paths" commands.*/
18196 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
18197 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
18198 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18199 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18200 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18201 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18202 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18203 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18204 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18205 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18206 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18207 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18208 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18209 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18210 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18211 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18212 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18213 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18215 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
18216 install_element(BGP_NODE
,
18217 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18218 install_element(BGP_NODE
,
18219 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18220 install_element(BGP_IPV4_NODE
,
18221 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18222 install_element(BGP_IPV4_NODE
,
18223 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18224 install_element(BGP_IPV4M_NODE
,
18225 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18226 install_element(BGP_IPV4M_NODE
,
18227 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18228 install_element(BGP_IPV4L_NODE
,
18229 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18230 install_element(BGP_IPV4L_NODE
,
18231 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18232 install_element(BGP_IPV6_NODE
,
18233 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18234 install_element(BGP_IPV6_NODE
,
18235 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18236 install_element(BGP_IPV6M_NODE
,
18237 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18238 install_element(BGP_IPV6M_NODE
,
18239 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18240 install_element(BGP_IPV6L_NODE
,
18241 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18242 install_element(BGP_IPV6L_NODE
,
18243 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18244 install_element(BGP_VPNV4_NODE
,
18245 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18246 install_element(BGP_VPNV4_NODE
,
18247 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18248 install_element(BGP_VPNV6_NODE
,
18249 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18250 install_element(BGP_VPNV6_NODE
,
18251 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18253 /* "neighbor sender-as-path-loop-detection" commands. */
18254 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
18255 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
18257 /* "neighbor passive" commands. */
18258 install_element(BGP_NODE
, &neighbor_passive_cmd
);
18259 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
18262 /* "neighbor shutdown" commands. */
18263 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
18264 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
18265 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
18266 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
18267 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
18268 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
18270 /* "neighbor capability extended-nexthop" commands.*/
18271 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
18272 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
18274 /* "neighbor capability orf prefix-list" commands.*/
18275 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
18276 install_element(BGP_NODE
,
18277 &no_neighbor_capability_orf_prefix_hidden_cmd
);
18278 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
18279 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18280 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18281 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18282 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18283 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18284 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
18285 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18286 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18287 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18288 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18289 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18291 /* "neighbor capability dynamic" commands.*/
18292 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
18293 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
18295 /* "neighbor dont-capability-negotiate" commands. */
18296 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
18297 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
18299 /* "neighbor ebgp-multihop" commands. */
18300 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
18301 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
18302 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
18304 /* "neighbor disable-connected-check" commands. */
18305 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
18306 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
18308 /* "neighbor enforce-first-as" commands. */
18309 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
18310 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
18312 /* "neighbor description" commands. */
18313 install_element(BGP_NODE
, &neighbor_description_cmd
);
18314 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
18315 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
18317 /* "neighbor update-source" commands. "*/
18318 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
18319 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
18321 /* "neighbor default-originate" commands. */
18322 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
18323 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
18324 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
18325 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
18326 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
18327 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
18328 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
18329 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
18330 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
18331 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
18332 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
18333 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
18334 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
18335 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
18336 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
18337 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
18338 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
18339 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
18340 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
18341 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
18342 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
18344 /* "neighbor port" commands. */
18345 install_element(BGP_NODE
, &neighbor_port_cmd
);
18346 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
18348 /* "neighbor weight" commands. */
18349 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
18350 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
18352 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
18353 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
18354 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
18355 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
18356 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
18357 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
18358 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
18359 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
18360 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
18361 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
18362 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
18363 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
18364 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
18365 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
18366 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
18367 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
18369 /* "neighbor override-capability" commands. */
18370 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
18371 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
18373 /* "neighbor strict-capability-match" commands. */
18374 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
18375 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
18377 /* "neighbor timers" commands. */
18378 install_element(BGP_NODE
, &neighbor_timers_cmd
);
18379 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
18381 /* "neighbor timers connect" commands. */
18382 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
18383 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
18385 /* "neighbor timers delayopen" commands. */
18386 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
18387 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
18389 /* "neighbor advertisement-interval" commands. */
18390 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
18391 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
18393 /* "neighbor interface" commands. */
18394 install_element(BGP_NODE
, &neighbor_interface_cmd
);
18395 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
18397 /* "neighbor distribute" commands. */
18398 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
18399 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
18400 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
18401 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
18402 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
18403 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
18404 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
18405 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
18406 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
18407 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
18408 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
18409 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
18410 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
18411 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
18412 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
18413 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
18414 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
18415 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
18417 /* "neighbor prefix-list" commands. */
18418 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
18419 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
18420 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
18421 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
18422 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
18423 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
18424 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
18425 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
18426 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
18427 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
18428 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
18429 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
18430 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
18431 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
18432 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
18433 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
18434 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
18435 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
18436 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
18437 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
18438 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
18439 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
18441 /* "neighbor filter-list" commands. */
18442 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
18443 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
18444 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
18445 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
18446 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
18447 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
18448 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
18449 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
18450 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
18451 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
18452 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
18453 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
18454 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
18455 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
18456 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
18457 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
18458 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
18459 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
18460 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
18461 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
18462 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
18463 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
18465 /* "neighbor route-map" commands. */
18466 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
18467 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
18468 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
18469 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
18470 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
18471 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
18472 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
18473 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
18474 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
18475 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
18476 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
18477 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
18478 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
18479 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
18480 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
18481 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
18482 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
18483 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
18484 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
18485 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
18486 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
18487 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
18488 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
18489 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
18491 /* "neighbor unsuppress-map" commands. */
18492 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
18493 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
18494 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
18495 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18496 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
18497 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18498 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
18499 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18500 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
18501 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18502 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
18503 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18504 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
18505 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18506 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
18507 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18508 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
18509 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18511 /* "neighbor advertise-map" commands. */
18512 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
18513 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
18514 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
18515 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
18516 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
18517 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
18518 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
18519 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
18520 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
18522 /* neighbor maximum-prefix-out commands. */
18523 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
18524 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18525 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18526 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18527 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18528 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18529 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18530 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18531 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18532 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18533 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18534 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18535 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18536 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18537 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18538 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18539 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18540 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18542 /* "neighbor maximum-prefix" commands. */
18543 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
18544 install_element(BGP_NODE
,
18545 &neighbor_maximum_prefix_threshold_hidden_cmd
);
18546 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
18547 install_element(BGP_NODE
,
18548 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
18549 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
18550 install_element(BGP_NODE
,
18551 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
18552 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
18553 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
18554 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18555 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18556 install_element(BGP_IPV4_NODE
,
18557 &neighbor_maximum_prefix_threshold_warning_cmd
);
18558 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18559 install_element(BGP_IPV4_NODE
,
18560 &neighbor_maximum_prefix_threshold_restart_cmd
);
18561 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18562 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
18563 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18564 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18565 install_element(BGP_IPV4M_NODE
,
18566 &neighbor_maximum_prefix_threshold_warning_cmd
);
18567 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18568 install_element(BGP_IPV4M_NODE
,
18569 &neighbor_maximum_prefix_threshold_restart_cmd
);
18570 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18571 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
18572 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18573 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18574 install_element(BGP_IPV4L_NODE
,
18575 &neighbor_maximum_prefix_threshold_warning_cmd
);
18576 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18577 install_element(BGP_IPV4L_NODE
,
18578 &neighbor_maximum_prefix_threshold_restart_cmd
);
18579 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18580 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
18581 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18582 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18583 install_element(BGP_IPV6_NODE
,
18584 &neighbor_maximum_prefix_threshold_warning_cmd
);
18585 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18586 install_element(BGP_IPV6_NODE
,
18587 &neighbor_maximum_prefix_threshold_restart_cmd
);
18588 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18589 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
18590 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18591 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18592 install_element(BGP_IPV6M_NODE
,
18593 &neighbor_maximum_prefix_threshold_warning_cmd
);
18594 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18595 install_element(BGP_IPV6M_NODE
,
18596 &neighbor_maximum_prefix_threshold_restart_cmd
);
18597 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18598 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
18599 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18600 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18601 install_element(BGP_IPV6L_NODE
,
18602 &neighbor_maximum_prefix_threshold_warning_cmd
);
18603 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18604 install_element(BGP_IPV6L_NODE
,
18605 &neighbor_maximum_prefix_threshold_restart_cmd
);
18606 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18607 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
18608 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18609 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18610 install_element(BGP_VPNV4_NODE
,
18611 &neighbor_maximum_prefix_threshold_warning_cmd
);
18612 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18613 install_element(BGP_VPNV4_NODE
,
18614 &neighbor_maximum_prefix_threshold_restart_cmd
);
18615 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18616 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
18617 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18618 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18619 install_element(BGP_VPNV6_NODE
,
18620 &neighbor_maximum_prefix_threshold_warning_cmd
);
18621 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18622 install_element(BGP_VPNV6_NODE
,
18623 &neighbor_maximum_prefix_threshold_restart_cmd
);
18624 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18626 /* "neighbor allowas-in" */
18627 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
18628 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
18629 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
18630 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
18631 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
18632 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
18633 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
18634 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
18635 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
18636 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
18637 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
18638 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
18639 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
18640 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
18641 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
18642 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
18643 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
18644 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
18645 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
18646 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
18648 /* address-family commands. */
18649 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
18650 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
18651 #ifdef KEEP_OLD_VPN_COMMANDS
18652 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
18653 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
18654 #endif /* KEEP_OLD_VPN_COMMANDS */
18656 install_element(BGP_NODE
, &address_family_evpn_cmd
);
18658 /* "exit-address-family" command. */
18659 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
18660 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
18661 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
18662 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
18663 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
18664 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
18665 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
18666 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
18667 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
18668 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
18669 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
18671 /* "clear ip bgp commands" */
18672 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
18674 /* clear ip bgp prefix */
18675 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
18676 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
18677 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
18679 /* "show [ip] bgp summary" commands. */
18680 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
18681 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
18682 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
18683 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
18684 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
18685 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
18686 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
18688 /* "show [ip] bgp neighbors" commands. */
18689 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
18691 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
18693 /* "show [ip] bgp peer-group" commands. */
18694 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
18696 /* "show [ip] bgp paths" commands. */
18697 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
18699 /* "show [ip] bgp community" commands. */
18700 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
18702 /* "show ip bgp large-community" commands. */
18703 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
18704 /* "show [ip] bgp attribute-info" commands. */
18705 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
18706 /* "show [ip] bgp route-leak" command */
18707 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
18709 /* "redistribute" commands. */
18710 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
18711 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
18712 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
18713 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
18714 install_element(BGP_NODE
,
18715 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
18716 install_element(BGP_NODE
,
18717 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
18718 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
18719 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
18720 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
18721 install_element(BGP_NODE
,
18722 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
18723 install_element(BGP_NODE
,
18724 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
18725 install_element(BGP_NODE
,
18726 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
18727 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
18728 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
18729 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
18730 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
18731 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
18732 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
18733 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
18734 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
18735 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
18736 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
18737 install_element(BGP_IPV4_NODE
,
18738 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
18739 install_element(BGP_IPV4_NODE
,
18740 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
18741 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
18742 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
18743 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
18744 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
18745 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
18746 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
18748 /* import|export vpn [route-map WORD] */
18749 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
18750 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
18752 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
18753 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
18755 /* ttl_security commands */
18756 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
18757 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
18759 /* "show [ip] bgp memory" commands. */
18760 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
18762 /* "show bgp martian next-hop" */
18763 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
18765 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
18767 /* "show [ip] bgp views" commands. */
18768 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
18770 /* "show [ip] bgp vrfs" commands. */
18771 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
18773 /* Community-list. */
18774 community_list_vty();
18776 /* vpn-policy commands */
18777 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
18778 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
18779 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
18780 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
18781 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
18782 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
18783 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
18784 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
18785 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
18786 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
18787 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
18788 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
18790 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
18791 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
18793 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
18794 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
18795 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
18796 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
18797 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
18798 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
18799 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
18800 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
18801 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
18802 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
18805 #include "memory.h"
18806 #include "bgp_regex.h"
18807 #include "bgp_clist.h"
18808 #include "bgp_ecommunity.h"
18810 /* VTY functions. */
18812 /* Direction value to string conversion. */
18813 static const char *community_direct_str(int direct
)
18816 case COMMUNITY_DENY
:
18818 case COMMUNITY_PERMIT
:
18825 /* Display error string. */
18826 static void community_list_perror(struct vty
*vty
, int ret
)
18829 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
18830 vty_out(vty
, "%% Can't find community-list\n");
18832 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
18833 vty_out(vty
, "%% Malformed community-list value\n");
18835 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
18837 "%% Community name conflict, previously defined as standard community\n");
18839 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
18841 "%% Community name conflict, previously defined as expanded community\n");
18846 /* "community-list" keyword help string. */
18847 #define COMMUNITY_LIST_STR "Add a community list entry\n"
18849 /*community-list standard */
18850 DEFUN (community_list_standard
,
18851 bgp_community_list_standard_cmd
,
18852 "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
18855 "Community list number (standard)\n"
18856 "Add an standard community-list entry\n"
18857 "Community list name\n"
18858 "Sequence number of an entry\n"
18859 "Sequence number\n"
18860 "Specify community to reject\n"
18861 "Specify community to accept\n"
18864 char *cl_name_or_number
= NULL
;
18867 int style
= COMMUNITY_LIST_STANDARD
;
18870 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
18872 seq
= argv
[idx
]->arg
;
18875 argv_find(argv
, argc
, "(1-99)", &idx
);
18876 argv_find(argv
, argc
, "WORD", &idx
);
18877 cl_name_or_number
= argv
[idx
]->arg
;
18878 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
18880 argv_find(argv
, argc
, "AA:NN", &idx
);
18881 char *str
= argv_concat(argv
, argc
, idx
);
18883 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
18886 XFREE(MTYPE_TMP
, str
);
18889 /* Display error string. */
18890 community_list_perror(vty
, ret
);
18891 return CMD_WARNING_CONFIG_FAILED
;
18894 return CMD_SUCCESS
;
18897 DEFUN (no_community_list_standard_all
,
18898 no_bgp_community_list_standard_all_cmd
,
18899 "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
18903 "Community list number (standard)\n"
18904 "Add an standard community-list entry\n"
18905 "Community list name\n"
18906 "Sequence number of an entry\n"
18907 "Sequence number\n"
18908 "Specify community to reject\n"
18909 "Specify community to accept\n"
18912 char *cl_name_or_number
= NULL
;
18915 int style
= COMMUNITY_LIST_STANDARD
;
18919 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
18921 seq
= argv
[idx
]->arg
;
18924 argv_find(argv
, argc
, "permit", &idx
);
18925 argv_find(argv
, argc
, "deny", &idx
);
18928 direct
= argv_find(argv
, argc
, "permit", &idx
)
18933 argv_find(argv
, argc
, "AA:NN", &idx
);
18934 str
= argv_concat(argv
, argc
, idx
);
18938 argv_find(argv
, argc
, "(1-99)", &idx
);
18939 argv_find(argv
, argc
, "WORD", &idx
);
18940 cl_name_or_number
= argv
[idx
]->arg
;
18942 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
18945 XFREE(MTYPE_TMP
, str
);
18948 community_list_perror(vty
, ret
);
18949 return CMD_WARNING_CONFIG_FAILED
;
18952 return CMD_SUCCESS
;
18955 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
18956 "no bgp community-list <(1-99)|standard WORD>",
18957 NO_STR BGP_STR COMMUNITY_LIST_STR
18958 "Community list number (standard)\n"
18959 "Add an standard community-list entry\n"
18960 "Community list name\n")
18962 /*community-list expanded */
18963 DEFUN (community_list_expanded_all
,
18964 bgp_community_list_expanded_all_cmd
,
18965 "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
18968 "Community list number (expanded)\n"
18969 "Add an expanded community-list entry\n"
18970 "Community list name\n"
18971 "Sequence number of an entry\n"
18972 "Sequence number\n"
18973 "Specify community to reject\n"
18974 "Specify community to accept\n"
18977 char *cl_name_or_number
= NULL
;
18980 int style
= COMMUNITY_LIST_EXPANDED
;
18983 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
18985 seq
= argv
[idx
]->arg
;
18989 argv_find(argv
, argc
, "(100-500)", &idx
);
18990 argv_find(argv
, argc
, "WORD", &idx
);
18991 cl_name_or_number
= argv
[idx
]->arg
;
18992 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
18994 argv_find(argv
, argc
, "AA:NN", &idx
);
18995 char *str
= argv_concat(argv
, argc
, idx
);
18997 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19000 XFREE(MTYPE_TMP
, str
);
19003 /* Display error string. */
19004 community_list_perror(vty
, ret
);
19005 return CMD_WARNING_CONFIG_FAILED
;
19008 return CMD_SUCCESS
;
19011 DEFUN (no_community_list_expanded_all
,
19012 no_bgp_community_list_expanded_all_cmd
,
19013 "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19017 "Community list number (expanded)\n"
19018 "Add an expanded community-list entry\n"
19019 "Community list name\n"
19020 "Sequence number of an entry\n"
19021 "Sequence number\n"
19022 "Specify community to reject\n"
19023 "Specify community to accept\n"
19026 char *cl_name_or_number
= NULL
;
19030 int style
= COMMUNITY_LIST_EXPANDED
;
19033 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
19035 seq
= argv
[idx
]->arg
;
19038 argv_find(argv
, argc
, "permit", &idx
);
19039 argv_find(argv
, argc
, "deny", &idx
);
19042 direct
= argv_find(argv
, argc
, "permit", &idx
)
19047 argv_find(argv
, argc
, "AA:NN", &idx
);
19048 str
= argv_concat(argv
, argc
, idx
);
19052 argv_find(argv
, argc
, "(100-500)", &idx
);
19053 argv_find(argv
, argc
, "WORD", &idx
);
19054 cl_name_or_number
= argv
[idx
]->arg
;
19056 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19059 XFREE(MTYPE_TMP
, str
);
19062 community_list_perror(vty
, ret
);
19063 return CMD_WARNING_CONFIG_FAILED
;
19066 return CMD_SUCCESS
;
19069 ALIAS(no_community_list_expanded_all
,
19070 no_bgp_community_list_expanded_all_list_cmd
,
19071 "no bgp community-list <(100-500)|expanded WORD>",
19072 NO_STR BGP_STR COMMUNITY_LIST_STR
19073 "Community list number (expanded)\n"
19074 "Add an expanded community-list entry\n"
19075 "Community list name\n")
19077 /* Return configuration string of community-list entry. */
19078 static const char *community_list_config_str(struct community_entry
*entry
)
19085 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
19086 str
= community_str(entry
->u
.com
, false);
19087 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
19088 str
= lcommunity_str(entry
->u
.lcom
, false);
19090 str
= entry
->config
;
19095 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
19097 struct community_entry
*entry
;
19099 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19100 if (entry
== list
->head
) {
19101 if (all_digit(list
->name
))
19102 vty_out(vty
, "Community %s list %s\n",
19103 entry
->style
== COMMUNITY_LIST_STANDARD
19105 : "(expanded) access",
19108 vty_out(vty
, "Named Community %s list %s\n",
19109 entry
->style
== COMMUNITY_LIST_STANDARD
19115 vty_out(vty
, " %s\n",
19116 community_direct_str(entry
->direct
));
19118 vty_out(vty
, " %s %s\n",
19119 community_direct_str(entry
->direct
),
19120 community_list_config_str(entry
));
19124 DEFUN (show_community_list
,
19125 show_bgp_community_list_cmd
,
19126 "show bgp community-list",
19129 "List community-list\n")
19131 struct community_list
*list
;
19132 struct community_list_master
*cm
;
19134 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19136 return CMD_SUCCESS
;
19138 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19139 community_list_show(vty
, list
);
19141 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19142 community_list_show(vty
, list
);
19144 return CMD_SUCCESS
;
19147 DEFUN (show_community_list_arg
,
19148 show_bgp_community_list_arg_cmd
,
19149 "show bgp community-list <(1-500)|WORD> detail",
19152 "List community-list\n"
19153 "Community-list number\n"
19154 "Community-list name\n"
19155 "Detailed information on community-list\n")
19157 int idx_comm_list
= 3;
19158 struct community_list
*list
;
19160 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
19161 COMMUNITY_LIST_MASTER
);
19163 vty_out(vty
, "%% Can't find community-list\n");
19164 return CMD_WARNING
;
19167 community_list_show(vty
, list
);
19169 return CMD_SUCCESS
;
19173 * Large Community code.
19175 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
19176 struct cmd_token
**argv
, int style
,
19177 int reject_all_digit_name
)
19186 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19187 seq
= argv
[idx
]->arg
;
19190 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19193 /* All digit name check. */
19195 argv_find(argv
, argc
, "WORD", &idx
);
19196 argv_find(argv
, argc
, "(1-99)", &idx
);
19197 argv_find(argv
, argc
, "(100-500)", &idx
);
19198 cl_name
= argv
[idx
]->arg
;
19199 if (reject_all_digit_name
&& all_digit(cl_name
)) {
19200 vty_out(vty
, "%% Community name cannot have all digits\n");
19201 return CMD_WARNING_CONFIG_FAILED
;
19205 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
19206 argv_find(argv
, argc
, "LINE", &idx
);
19207 /* Concat community string argument. */
19209 str
= argv_concat(argv
, argc
, idx
);
19213 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
19215 /* Free temporary community list string allocated by
19217 XFREE(MTYPE_TMP
, str
);
19220 community_list_perror(vty
, ret
);
19221 return CMD_WARNING_CONFIG_FAILED
;
19223 return CMD_SUCCESS
;
19226 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
19227 struct cmd_token
**argv
, int style
)
19235 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19236 seq
= argv
[idx
]->arg
;
19239 argv_find(argv
, argc
, "permit", &idx
);
19240 argv_find(argv
, argc
, "deny", &idx
);
19243 /* Check the list direct. */
19244 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
19245 direct
= COMMUNITY_PERMIT
;
19247 direct
= COMMUNITY_DENY
;
19250 argv_find(argv
, argc
, "LINE", &idx
);
19251 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
19252 /* Concat community string argument. */
19253 str
= argv_concat(argv
, argc
, idx
);
19257 argv_find(argv
, argc
, "(1-99)", &idx
);
19258 argv_find(argv
, argc
, "(100-500)", &idx
);
19259 argv_find(argv
, argc
, "WORD", &idx
);
19261 /* Unset community list. */
19262 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
19265 /* Free temporary community list string allocated by
19267 XFREE(MTYPE_TMP
, str
);
19270 community_list_perror(vty
, ret
);
19271 return CMD_WARNING_CONFIG_FAILED
;
19274 return CMD_SUCCESS
;
19277 /* "large-community-list" keyword help string. */
19278 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
19279 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
19281 DEFUN (lcommunity_list_standard
,
19282 bgp_lcommunity_list_standard_cmd
,
19283 "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...",
19285 LCOMMUNITY_LIST_STR
19286 "Large Community list number (standard)\n"
19287 "Sequence number of an entry\n"
19288 "Sequence number\n"
19289 "Specify large community to reject\n"
19290 "Specify large community to accept\n"
19291 LCOMMUNITY_VAL_STR
)
19293 return lcommunity_list_set_vty(vty
, argc
, argv
,
19294 LARGE_COMMUNITY_LIST_STANDARD
, 0);
19297 DEFUN (lcommunity_list_expanded
,
19298 bgp_lcommunity_list_expanded_cmd
,
19299 "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...",
19301 LCOMMUNITY_LIST_STR
19302 "Large Community list number (expanded)\n"
19303 "Sequence number of an entry\n"
19304 "Sequence number\n"
19305 "Specify large community to reject\n"
19306 "Specify large community to accept\n"
19307 "An ordered list as a regular-expression\n")
19309 return lcommunity_list_set_vty(vty
, argc
, argv
,
19310 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
19313 DEFUN (lcommunity_list_name_standard
,
19314 bgp_lcommunity_list_name_standard_cmd
,
19315 "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...",
19317 LCOMMUNITY_LIST_STR
19318 "Specify standard large-community-list\n"
19319 "Large Community list name\n"
19320 "Sequence number of an entry\n"
19321 "Sequence number\n"
19322 "Specify large community to reject\n"
19323 "Specify large community to accept\n"
19324 LCOMMUNITY_VAL_STR
)
19326 return lcommunity_list_set_vty(vty
, argc
, argv
,
19327 LARGE_COMMUNITY_LIST_STANDARD
, 1);
19330 DEFUN (lcommunity_list_name_expanded
,
19331 bgp_lcommunity_list_name_expanded_cmd
,
19332 "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...",
19334 LCOMMUNITY_LIST_STR
19335 "Specify expanded large-community-list\n"
19336 "Large Community list name\n"
19337 "Sequence number of an entry\n"
19338 "Sequence number\n"
19339 "Specify large community to reject\n"
19340 "Specify large community to accept\n"
19341 "An ordered list as a regular-expression\n")
19343 return lcommunity_list_set_vty(vty
, argc
, argv
,
19344 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
19347 DEFUN (no_lcommunity_list_all
,
19348 no_bgp_lcommunity_list_all_cmd
,
19349 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
19352 LCOMMUNITY_LIST_STR
19353 "Large Community list number (standard)\n"
19354 "Large Community list number (expanded)\n"
19355 "Large Community list name\n")
19357 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19358 LARGE_COMMUNITY_LIST_STANDARD
);
19361 DEFUN (no_lcommunity_list_name_standard_all
,
19362 no_bgp_lcommunity_list_name_standard_all_cmd
,
19363 "no bgp large-community-list standard WORD",
19366 LCOMMUNITY_LIST_STR
19367 "Specify standard large-community-list\n"
19368 "Large Community list name\n")
19370 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19371 LARGE_COMMUNITY_LIST_STANDARD
);
19374 DEFUN (no_lcommunity_list_name_expanded_all
,
19375 no_bgp_lcommunity_list_name_expanded_all_cmd
,
19376 "no bgp large-community-list expanded WORD",
19379 LCOMMUNITY_LIST_STR
19380 "Specify expanded large-community-list\n"
19381 "Large Community list name\n")
19383 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19384 LARGE_COMMUNITY_LIST_EXPANDED
);
19387 DEFUN (no_lcommunity_list_standard
,
19388 no_bgp_lcommunity_list_standard_cmd
,
19389 "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...",
19392 LCOMMUNITY_LIST_STR
19393 "Large Community list number (standard)\n"
19394 "Sequence number of an entry\n"
19395 "Sequence number\n"
19396 "Specify large community to reject\n"
19397 "Specify large community to accept\n"
19398 LCOMMUNITY_VAL_STR
)
19400 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19401 LARGE_COMMUNITY_LIST_STANDARD
);
19404 DEFUN (no_lcommunity_list_expanded
,
19405 no_bgp_lcommunity_list_expanded_cmd
,
19406 "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...",
19409 LCOMMUNITY_LIST_STR
19410 "Large Community list number (expanded)\n"
19411 "Sequence number of an entry\n"
19412 "Sequence number\n"
19413 "Specify large community to reject\n"
19414 "Specify large community to accept\n"
19415 "An ordered list as a regular-expression\n")
19417 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19418 LARGE_COMMUNITY_LIST_EXPANDED
);
19421 DEFUN (no_lcommunity_list_name_standard
,
19422 no_bgp_lcommunity_list_name_standard_cmd
,
19423 "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...",
19426 LCOMMUNITY_LIST_STR
19427 "Specify standard large-community-list\n"
19428 "Large Community list name\n"
19429 "Sequence number of an entry\n"
19430 "Sequence number\n"
19431 "Specify large community to reject\n"
19432 "Specify large community to accept\n"
19433 LCOMMUNITY_VAL_STR
)
19435 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19436 LARGE_COMMUNITY_LIST_STANDARD
);
19439 DEFUN (no_lcommunity_list_name_expanded
,
19440 no_bgp_lcommunity_list_name_expanded_cmd
,
19441 "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...",
19444 LCOMMUNITY_LIST_STR
19445 "Specify expanded large-community-list\n"
19446 "Large community list name\n"
19447 "Sequence number of an entry\n"
19448 "Sequence number\n"
19449 "Specify large community to reject\n"
19450 "Specify large community to accept\n"
19451 "An ordered list as a regular-expression\n")
19453 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19454 LARGE_COMMUNITY_LIST_EXPANDED
);
19457 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
19459 struct community_entry
*entry
;
19461 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19462 if (entry
== list
->head
) {
19463 if (all_digit(list
->name
))
19464 vty_out(vty
, "Large community %s list %s\n",
19466 LARGE_COMMUNITY_LIST_STANDARD
19468 : "(expanded) access",
19472 "Named large community %s list %s\n",
19474 LARGE_COMMUNITY_LIST_STANDARD
19480 vty_out(vty
, " %s\n",
19481 community_direct_str(entry
->direct
));
19483 vty_out(vty
, " %s %s\n",
19484 community_direct_str(entry
->direct
),
19485 community_list_config_str(entry
));
19489 DEFUN (show_lcommunity_list
,
19490 show_bgp_lcommunity_list_cmd
,
19491 "show bgp large-community-list",
19494 "List large-community list\n")
19496 struct community_list
*list
;
19497 struct community_list_master
*cm
;
19499 cm
= community_list_master_lookup(bgp_clist
,
19500 LARGE_COMMUNITY_LIST_MASTER
);
19502 return CMD_SUCCESS
;
19504 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19505 lcommunity_list_show(vty
, list
);
19507 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19508 lcommunity_list_show(vty
, list
);
19510 return CMD_SUCCESS
;
19513 DEFUN (show_lcommunity_list_arg
,
19514 show_bgp_lcommunity_list_arg_cmd
,
19515 "show bgp large-community-list <(1-500)|WORD> detail",
19518 "List large-community list\n"
19519 "Large-community-list number\n"
19520 "Large-community-list name\n"
19521 "Detailed information on large-community-list\n")
19523 struct community_list
*list
;
19525 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
19526 LARGE_COMMUNITY_LIST_MASTER
);
19528 vty_out(vty
, "%% Can't find large-community-list\n");
19529 return CMD_WARNING
;
19532 lcommunity_list_show(vty
, list
);
19534 return CMD_SUCCESS
;
19537 /* "extcommunity-list" keyword help string. */
19538 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
19539 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
19541 DEFUN (extcommunity_list_standard
,
19542 bgp_extcommunity_list_standard_cmd
,
19543 "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19545 EXTCOMMUNITY_LIST_STR
19546 "Extended Community list number (standard)\n"
19547 "Specify standard extcommunity-list\n"
19548 "Community list name\n"
19549 "Sequence number of an entry\n"
19550 "Sequence number\n"
19551 "Specify community to reject\n"
19552 "Specify community to accept\n"
19553 EXTCOMMUNITY_VAL_STR
)
19555 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19557 char *cl_number_or_name
= NULL
;
19562 argv_find(argv
, argc
, "(1-99)", &idx
);
19563 argv_find(argv
, argc
, "WORD", &idx
);
19564 cl_number_or_name
= argv
[idx
]->arg
;
19566 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19567 seq
= argv
[idx
]->arg
;
19569 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19571 argv_find(argv
, argc
, "AA:NN", &idx
);
19572 char *str
= argv_concat(argv
, argc
, idx
);
19574 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19577 XFREE(MTYPE_TMP
, str
);
19580 community_list_perror(vty
, ret
);
19581 return CMD_WARNING_CONFIG_FAILED
;
19584 return CMD_SUCCESS
;
19587 DEFUN (extcommunity_list_name_expanded
,
19588 bgp_extcommunity_list_name_expanded_cmd
,
19589 "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...",
19591 EXTCOMMUNITY_LIST_STR
19592 "Extended Community list number (expanded)\n"
19593 "Specify expanded extcommunity-list\n"
19594 "Extended Community list name\n"
19595 "Sequence number of an entry\n"
19596 "Sequence number\n"
19597 "Specify community to reject\n"
19598 "Specify community to accept\n"
19599 "An ordered list as a regular-expression\n")
19601 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
19603 char *cl_number_or_name
= NULL
;
19607 argv_find(argv
, argc
, "(100-500)", &idx
);
19608 argv_find(argv
, argc
, "WORD", &idx
);
19609 cl_number_or_name
= argv
[idx
]->arg
;
19611 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19612 seq
= argv
[idx
]->arg
;
19614 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19616 argv_find(argv
, argc
, "LINE", &idx
);
19617 char *str
= argv_concat(argv
, argc
, idx
);
19619 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19622 XFREE(MTYPE_TMP
, str
);
19625 community_list_perror(vty
, ret
);
19626 return CMD_WARNING_CONFIG_FAILED
;
19629 return CMD_SUCCESS
;
19632 DEFUN (no_extcommunity_list_standard_all
,
19633 no_bgp_extcommunity_list_standard_all_cmd
,
19634 "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
19637 EXTCOMMUNITY_LIST_STR
19638 "Extended Community list number (standard)\n"
19639 "Specify standard extcommunity-list\n"
19640 "Community list name\n"
19641 "Sequence number of an entry\n"
19642 "Sequence number\n"
19643 "Specify community to reject\n"
19644 "Specify community to accept\n"
19645 EXTCOMMUNITY_VAL_STR
)
19647 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19649 char *cl_number_or_name
= NULL
;
19654 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19655 seq
= argv
[idx
]->arg
;
19658 argv_find(argv
, argc
, "permit", &idx
);
19659 argv_find(argv
, argc
, "deny", &idx
);
19661 direct
= argv_find(argv
, argc
, "permit", &idx
)
19666 argv_find(argv
, argc
, "AA:NN", &idx
);
19667 str
= argv_concat(argv
, argc
, idx
);
19671 argv_find(argv
, argc
, "(1-99)", &idx
);
19672 argv_find(argv
, argc
, "WORD", &idx
);
19673 cl_number_or_name
= argv
[idx
]->arg
;
19675 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
19676 seq
, direct
, style
);
19678 XFREE(MTYPE_TMP
, str
);
19681 community_list_perror(vty
, ret
);
19682 return CMD_WARNING_CONFIG_FAILED
;
19685 return CMD_SUCCESS
;
19688 ALIAS(no_extcommunity_list_standard_all
,
19689 no_bgp_extcommunity_list_standard_all_list_cmd
,
19690 "no bgp extcommunity-list <(1-99)|standard WORD>",
19691 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
19692 "Extended Community list number (standard)\n"
19693 "Specify standard extcommunity-list\n"
19694 "Community list name\n")
19696 DEFUN (no_extcommunity_list_expanded_all
,
19697 no_bgp_extcommunity_list_expanded_all_cmd
,
19698 "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...",
19701 EXTCOMMUNITY_LIST_STR
19702 "Extended Community list number (expanded)\n"
19703 "Specify expanded extcommunity-list\n"
19704 "Extended Community list name\n"
19705 "Sequence number of an entry\n"
19706 "Sequence number\n"
19707 "Specify community to reject\n"
19708 "Specify community to accept\n"
19709 "An ordered list as a regular-expression\n")
19711 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
19713 char *cl_number_or_name
= NULL
;
19718 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
19719 seq
= argv
[idx
]->arg
;
19722 argv_find(argv
, argc
, "permit", &idx
);
19723 argv_find(argv
, argc
, "deny", &idx
);
19726 direct
= argv_find(argv
, argc
, "permit", &idx
)
19731 argv_find(argv
, argc
, "LINE", &idx
);
19732 str
= argv_concat(argv
, argc
, idx
);
19736 argv_find(argv
, argc
, "(100-500)", &idx
);
19737 argv_find(argv
, argc
, "WORD", &idx
);
19738 cl_number_or_name
= argv
[idx
]->arg
;
19740 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
19741 seq
, direct
, style
);
19743 XFREE(MTYPE_TMP
, str
);
19746 community_list_perror(vty
, ret
);
19747 return CMD_WARNING_CONFIG_FAILED
;
19750 return CMD_SUCCESS
;
19753 ALIAS(no_extcommunity_list_expanded_all
,
19754 no_bgp_extcommunity_list_expanded_all_list_cmd
,
19755 "no bgp extcommunity-list <(100-500)|expanded WORD>",
19756 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
19757 "Extended Community list number (expanded)\n"
19758 "Specify expanded extcommunity-list\n"
19759 "Extended Community list name\n")
19761 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
19763 struct community_entry
*entry
;
19765 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19766 if (entry
== list
->head
) {
19767 if (all_digit(list
->name
))
19768 vty_out(vty
, "Extended community %s list %s\n",
19769 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
19771 : "(expanded) access",
19775 "Named extended community %s list %s\n",
19776 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
19782 vty_out(vty
, " %s\n",
19783 community_direct_str(entry
->direct
));
19785 vty_out(vty
, " %s %s\n",
19786 community_direct_str(entry
->direct
),
19787 community_list_config_str(entry
));
19791 DEFUN (show_extcommunity_list
,
19792 show_bgp_extcommunity_list_cmd
,
19793 "show bgp extcommunity-list",
19796 "List extended-community list\n")
19798 struct community_list
*list
;
19799 struct community_list_master
*cm
;
19801 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
19803 return CMD_SUCCESS
;
19805 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19806 extcommunity_list_show(vty
, list
);
19808 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19809 extcommunity_list_show(vty
, list
);
19811 return CMD_SUCCESS
;
19814 DEFUN (show_extcommunity_list_arg
,
19815 show_bgp_extcommunity_list_arg_cmd
,
19816 "show bgp extcommunity-list <(1-500)|WORD> detail",
19819 "List extended-community list\n"
19820 "Extcommunity-list number\n"
19821 "Extcommunity-list name\n"
19822 "Detailed information on extcommunity-list\n")
19824 int idx_comm_list
= 3;
19825 struct community_list
*list
;
19827 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
19828 EXTCOMMUNITY_LIST_MASTER
);
19830 vty_out(vty
, "%% Can't find extcommunity-list\n");
19831 return CMD_WARNING
;
19834 extcommunity_list_show(vty
, list
);
19836 return CMD_SUCCESS
;
19839 /* Display community-list and extcommunity-list configuration. */
19840 static int community_list_config_write(struct vty
*vty
)
19842 struct community_list
*list
;
19843 struct community_entry
*entry
;
19844 struct community_list_master
*cm
;
19847 /* Community-list. */
19848 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19850 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19851 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19853 "bgp community-list %s seq %" PRId64
" %s %s\n",
19854 list
->name
, entry
->seq
,
19855 community_direct_str(entry
->direct
),
19856 community_list_config_str(entry
));
19859 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19860 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19862 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
19863 entry
->style
== COMMUNITY_LIST_STANDARD
19866 list
->name
, entry
->seq
,
19867 community_direct_str(entry
->direct
),
19868 community_list_config_str(entry
));
19872 /* Extcommunity-list. */
19873 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
19875 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19876 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19878 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
19879 list
->name
, entry
->seq
,
19880 community_direct_str(entry
->direct
),
19881 community_list_config_str(entry
));
19884 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19885 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19887 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
19888 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
19891 list
->name
, entry
->seq
,
19892 community_direct_str(entry
->direct
),
19893 community_list_config_str(entry
));
19898 /* lcommunity-list. */
19899 cm
= community_list_master_lookup(bgp_clist
,
19900 LARGE_COMMUNITY_LIST_MASTER
);
19902 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19903 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19905 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
19906 list
->name
, entry
->seq
,
19907 community_direct_str(entry
->direct
),
19908 community_list_config_str(entry
));
19911 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19912 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19914 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
19916 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
19919 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
19920 community_list_config_str(entry
));
19927 static int community_list_config_write(struct vty
*vty
);
19928 static struct cmd_node community_list_node
= {
19929 .name
= "community list",
19930 .node
= COMMUNITY_LIST_NODE
,
19932 .config_write
= community_list_config_write
,
19935 static void community_list_vty(void)
19937 install_node(&community_list_node
);
19939 /* Community-list. */
19940 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
19941 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
19942 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
19943 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
19944 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
19945 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
19946 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
19947 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
19949 /* Extcommunity-list. */
19950 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
19951 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
19952 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
19953 install_element(CONFIG_NODE
,
19954 &no_bgp_extcommunity_list_standard_all_list_cmd
);
19955 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
19956 install_element(CONFIG_NODE
,
19957 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
19958 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
19959 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
19961 /* Large Community List */
19962 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
19963 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
19964 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
19965 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
19966 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
19967 install_element(CONFIG_NODE
,
19968 &no_bgp_lcommunity_list_name_standard_all_cmd
);
19969 install_element(CONFIG_NODE
,
19970 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
19971 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
19972 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
19973 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
19974 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
19975 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
19976 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);