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"
27 #include "lib/printfrr.h"
42 #include "bgpd/bgpd.h"
43 #include "bgpd/bgp_attr_evpn.h"
44 #include "bgpd/bgp_advertise.h"
45 #include "bgpd/bgp_attr.h"
46 #include "bgpd/bgp_aspath.h"
47 #include "bgpd/bgp_community.h"
48 #include "bgpd/bgp_ecommunity.h"
49 #include "bgpd/bgp_lcommunity.h"
50 #include "bgpd/bgp_damp.h"
51 #include "bgpd/bgp_debug.h"
52 #include "bgpd/bgp_errors.h"
53 #include "bgpd/bgp_fsm.h"
54 #include "bgpd/bgp_nexthop.h"
55 #include "bgpd/bgp_open.h"
56 #include "bgpd/bgp_regex.h"
57 #include "bgpd/bgp_route.h"
58 #include "bgpd/bgp_mplsvpn.h"
59 #include "bgpd/bgp_zebra.h"
60 #include "bgpd/bgp_table.h"
61 #include "bgpd/bgp_vty.h"
62 #include "bgpd/bgp_mpath.h"
63 #include "bgpd/bgp_packet.h"
64 #include "bgpd/bgp_updgrp.h"
65 #include "bgpd/bgp_bfd.h"
66 #include "bgpd/bgp_io.h"
67 #include "bgpd/bgp_evpn.h"
68 #include "bgpd/bgp_evpn_vty.h"
69 #include "bgpd/bgp_evpn_mh.h"
70 #include "bgpd/bgp_addpath.h"
71 #include "bgpd/bgp_mac.h"
72 #include "bgpd/bgp_flowspec.h"
74 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
77 #include "northbound.h"
78 #include "northbound_cli.h"
79 #include "bgpd/bgp_nb.h"
82 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
85 .match_profile
= "traditional",
86 .match_version
= "< 7.4",
90 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
91 { .val_bool
= true, .match_profile
= "datacenter", },
92 { .val_bool
= false },
94 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
95 { .val_bool
= true, .match_profile
= "datacenter", },
96 { .val_bool
= false },
98 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
99 { .val_bool
= true, .match_profile
= "datacenter", },
100 { .val_bool
= false },
102 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
103 { .val_bool
= true, .match_profile
= "datacenter", },
104 { .val_bool
= false },
106 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
107 { .val_ulong
= 10, .match_profile
= "datacenter", },
108 { .val_ulong
= 120 },
110 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
111 { .val_ulong
= 9, .match_profile
= "datacenter", },
112 { .val_ulong
= 180 },
114 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
115 { .val_ulong
= 3, .match_profile
= "datacenter", },
118 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
119 { .val_bool
= false, .match_profile
= "datacenter", },
120 { .val_bool
= false, .match_version
= "< 7.4", },
121 { .val_bool
= true },
123 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
124 { .val_bool
= false, .match_version
= "< 7.6", },
125 { .val_bool
= true },
128 DEFINE_HOOK(bgp_inst_config_write
,
129 (struct bgp
*bgp
, struct vty
*vty
),
131 DEFINE_HOOK(bgp_snmp_update_last_changed
, (struct bgp
*bgp
), (bgp
));
134 "The Graceful Restart No Operation was executed as cmd same as previous one."
136 "The Graceful Restart command used is not valid at this moment."
137 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
138 struct prefix
*range
, int exact
);
140 /* Show BGP peer's information. */
150 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
151 struct prefix
*range
, int exact
);
153 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
158 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
161 afi_t afi
, bool use_json
);
163 static int peer_and_group_lookup_nb(struct vty
*vty
, const char *peer_str
,
164 char *base_xpath
, int xpath_len
,
167 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
173 return BGP_IPV4_NODE
;
175 return BGP_IPV4M_NODE
;
176 case SAFI_LABELED_UNICAST
:
177 return BGP_IPV4L_NODE
;
179 return BGP_VPNV4_NODE
;
181 return BGP_FLOWSPECV4_NODE
;
184 return BGP_IPV4_NODE
;
190 return BGP_IPV6_NODE
;
192 return BGP_IPV6M_NODE
;
193 case SAFI_LABELED_UNICAST
:
194 return BGP_IPV6L_NODE
;
196 return BGP_VPNV6_NODE
;
198 return BGP_FLOWSPECV6_NODE
;
201 return BGP_IPV4_NODE
;
205 return BGP_EVPN_NODE
;
208 // We should never be here but to clarify the switch statement..
209 return BGP_IPV4_NODE
;
212 // Impossible to happen
213 return BGP_IPV4_NODE
;
216 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
219 if (safi
== SAFI_UNICAST
)
220 return "IPv4 Unicast";
221 if (safi
== SAFI_MULTICAST
)
222 return "IPv4 Multicast";
223 if (safi
== SAFI_LABELED_UNICAST
)
224 return "IPv4 Labeled Unicast";
225 if (safi
== SAFI_MPLS_VPN
)
227 if (safi
== SAFI_ENCAP
)
229 if (safi
== SAFI_FLOWSPEC
)
230 return "IPv4 Flowspec";
231 } else if (afi
== AFI_IP6
) {
232 if (safi
== SAFI_UNICAST
)
233 return "IPv6 Unicast";
234 if (safi
== SAFI_MULTICAST
)
235 return "IPv6 Multicast";
236 if (safi
== SAFI_LABELED_UNICAST
)
237 return "IPv6 Labeled Unicast";
238 if (safi
== SAFI_MPLS_VPN
)
240 if (safi
== SAFI_ENCAP
)
242 if (safi
== SAFI_FLOWSPEC
)
243 return "IPv6 Flowspec";
244 } else if (afi
== AFI_L2VPN
) {
245 if (safi
== SAFI_EVPN
)
253 * Please note that we have intentionally camelCased
254 * the return strings here. So if you want
255 * to use this function, please ensure you
256 * are doing this within json output
258 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
261 if (safi
== SAFI_UNICAST
)
262 return "ipv4Unicast";
263 if (safi
== SAFI_MULTICAST
)
264 return "ipv4Multicast";
265 if (safi
== SAFI_LABELED_UNICAST
)
266 return "ipv4LabeledUnicast";
267 if (safi
== SAFI_MPLS_VPN
)
269 if (safi
== SAFI_ENCAP
)
271 if (safi
== SAFI_FLOWSPEC
)
272 return "ipv4Flowspec";
273 } else if (afi
== AFI_IP6
) {
274 if (safi
== SAFI_UNICAST
)
275 return "ipv6Unicast";
276 if (safi
== SAFI_MULTICAST
)
277 return "ipv6Multicast";
278 if (safi
== SAFI_LABELED_UNICAST
)
279 return "ipv6LabeledUnicast";
280 if (safi
== SAFI_MPLS_VPN
)
282 if (safi
== SAFI_ENCAP
)
284 if (safi
== SAFI_FLOWSPEC
)
285 return "ipv6Flowspec";
286 } else if (afi
== AFI_L2VPN
) {
287 if (safi
== SAFI_EVPN
)
294 /* return string maps to afi-safi specific container names
295 * defined in bgp yang file.
297 const char *bgp_afi_safi_get_container_str(afi_t afi
, safi_t safi
)
300 if (safi
== SAFI_UNICAST
)
301 return "ipv4-unicast";
302 if (safi
== SAFI_MULTICAST
)
303 return "ipv4-multicast";
304 if (safi
== SAFI_LABELED_UNICAST
)
305 return "ipv4-labeled-unicast";
306 if (safi
== SAFI_MPLS_VPN
)
307 return "l3vpn-ipv4-unicast";
308 if (safi
== SAFI_FLOWSPEC
)
309 return "ipv4-flowspec";
310 } else if (afi
== AFI_IP6
) {
311 if (safi
== SAFI_UNICAST
)
312 return "ipv6-unicast";
313 if (safi
== SAFI_MULTICAST
)
314 return "ipv6-multicast";
315 if (safi
== SAFI_LABELED_UNICAST
)
316 return "ipv6-labeled-unicast";
317 if (safi
== SAFI_MPLS_VPN
)
318 return "l3vpn-ipv6-unicast";
319 if (safi
== SAFI_FLOWSPEC
)
320 return "ipv6-flowspec";
321 } else if (afi
== AFI_L2VPN
) {
322 if (safi
== SAFI_EVPN
)
329 /* Utility function to get address family from current node. */
330 afi_t
bgp_node_afi(struct vty
*vty
)
338 case BGP_FLOWSPECV6_NODE
:
351 /* Utility function to get subsequent address family from current
353 safi_t
bgp_node_safi(struct vty
*vty
)
359 safi
= SAFI_MPLS_VPN
;
363 safi
= SAFI_MULTICAST
;
370 safi
= SAFI_LABELED_UNICAST
;
372 case BGP_FLOWSPECV4_NODE
:
373 case BGP_FLOWSPECV6_NODE
:
374 safi
= SAFI_FLOWSPEC
;
384 * Converts an AFI in string form to afi_t
386 * @param afi string, one of
390 * @return the corresponding afi_t
392 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
394 afi_t afi
= AFI_MAX
; /* unknown */
395 if (strmatch(afi_str
, "ipv4"))
397 else if (strmatch(afi_str
, "ipv6"))
399 else if (strmatch(afi_str
, "l2vpn"))
404 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
408 if (argv_find(argv
, argc
, "ipv4", index
)) {
412 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
416 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
424 /* supports <unicast|multicast|vpn|labeled-unicast> */
425 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
427 safi_t safi
= SAFI_MAX
; /* unknown */
428 if (strmatch(safi_str
, "multicast"))
429 safi
= SAFI_MULTICAST
;
430 else if (strmatch(safi_str
, "unicast"))
432 else if (strmatch(safi_str
, "vpn"))
433 safi
= SAFI_MPLS_VPN
;
434 else if (strmatch(safi_str
, "evpn"))
436 else if (strmatch(safi_str
, "labeled-unicast"))
437 safi
= SAFI_LABELED_UNICAST
;
438 else if (strmatch(safi_str
, "flowspec"))
439 safi
= SAFI_FLOWSPEC
;
443 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
447 if (argv_find(argv
, argc
, "unicast", index
)) {
450 *safi
= SAFI_UNICAST
;
451 } else if (argv_find(argv
, argc
, "multicast", index
)) {
454 *safi
= SAFI_MULTICAST
;
455 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
458 *safi
= SAFI_LABELED_UNICAST
;
459 } else if (argv_find(argv
, argc
, "vpn", index
)) {
462 *safi
= SAFI_MPLS_VPN
;
463 } else if (argv_find(argv
, argc
, "evpn", index
)) {
467 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
470 *safi
= SAFI_FLOWSPEC
;
475 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
476 enum bgp_instance_type inst_type
)
478 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
480 if (ret
== BGP_CREATED
) {
481 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
482 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
484 if (DFLT_BGP_IMPORT_CHECK
)
485 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
486 if (DFLT_BGP_SHOW_HOSTNAME
)
487 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
488 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
489 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
490 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
491 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
492 if (DFLT_BGP_DETERMINISTIC_MED
)
493 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
494 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
495 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
496 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
497 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
505 * bgp_vty_find_and_parse_afi_safi_bgp
507 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
508 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
509 * to appropriate values for the calling function. This is to allow the
510 * calling function to make decisions appropriate for the show command
511 * that is being parsed.
513 * The show commands are generally of the form:
514 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
515 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
517 * Since we use argv_find if the show command in particular doesn't have:
519 * [<view|vrf> VIEWVRFNAME]
520 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
521 * The command parsing should still be ok.
523 * vty -> The vty for the command so we can output some useful data in
524 * the event of a parse error in the vrf.
525 * argv -> The command tokens
526 * argc -> How many command tokens we have
527 * idx -> The current place in the command, generally should be 0 for this
529 * afi -> The parsed afi if it was included in the show command, returned here
530 * safi -> The parsed safi if it was included in the show command, returned here
531 * bgp -> Pointer to the bgp data structure we need to fill in.
532 * use_json -> json is configured or not
534 * The function returns the correct location in the parse tree for the
537 * Returns 0 for failure to parse correctly, else the idx position of where
538 * it found the last token.
540 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
541 struct cmd_token
**argv
, int argc
,
542 int *idx
, afi_t
*afi
, safi_t
*safi
,
543 struct bgp
**bgp
, bool use_json
)
545 char *vrf_name
= NULL
;
551 if (argv_find(argv
, argc
, "ip", idx
))
554 if (argv_find(argv
, argc
, "view", idx
))
555 vrf_name
= argv
[*idx
+ 1]->arg
;
556 else if (argv_find(argv
, argc
, "vrf", idx
)) {
557 vrf_name
= argv
[*idx
+ 1]->arg
;
558 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
562 if (strmatch(vrf_name
, "all"))
565 *bgp
= bgp_lookup_by_name(vrf_name
);
568 json_object
*json
= NULL
;
569 json
= json_object_new_object();
570 json_object_string_add(
572 "View/Vrf is unknown");
574 json_object_to_json_string_ext(json
,
575 JSON_C_TO_STRING_PRETTY
));
576 json_object_free(json
);
579 vty_out(vty
, "View/Vrf %s is unknown\n",
586 *bgp
= bgp_get_default();
589 json_object
*json
= NULL
;
590 json
= json_object_new_object();
591 json_object_string_add(
593 "Default BGP instance not found");
595 json_object_to_json_string_ext(json
,
596 JSON_C_TO_STRING_PRETTY
));
597 json_object_free(json
);
601 "Default BGP instance not found\n");
607 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
608 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
614 bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
616 struct interface
*ifp
= NULL
;
618 if (su
->sa
.sa_family
== AF_INET
)
619 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
620 else if (su
->sa
.sa_family
== AF_INET6
)
621 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
622 su
->sin6
.sin6_scope_id
,
631 /* Utility function for looking up peer or peer group. */
632 /* This is used only for configuration, so disallow if attempted on
633 * a dynamic neighbor.
635 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
637 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
640 struct peer
*peer
= NULL
;
641 struct peer_group
*group
= NULL
;
647 ret
= str2sockunion(peer_str
, &su
);
649 /* IP address, locate peer. */
650 peer
= peer_lookup(bgp
, &su
);
652 /* Not IP, could match either peer configured on interface or a
654 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
656 group
= peer_group_lookup(bgp
, peer_str
);
660 if (peer_dynamic_neighbor(peer
)) {
662 "%% Operation not allowed on a dynamic neighbor\n");
672 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
677 int bgp_nb_errmsg_return(char *errmsg
, size_t errmsg_len
, int ret
)
679 const char *str
= NULL
;
682 case BGP_ERR_INVALID_VALUE
:
683 str
= "Invalid value";
685 case BGP_ERR_INVALID_FLAG
:
686 str
= "Invalid flag";
688 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
689 str
= "Peer-group has been shutdown. Activate the peer-group first";
691 case BGP_ERR_PEER_FLAG_CONFLICT
:
692 str
= "Can't set override-capability and strict-capability-match at the same time";
694 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
695 str
= "Specify remote-as or peer-group remote AS first";
697 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
698 str
= "Cannot change the peer-group. Deconfigure first";
700 case BGP_ERR_PEER_GROUP_MISMATCH
:
701 str
= "Peer is not a member of this peer-group";
703 case BGP_ERR_PEER_FILTER_CONFLICT
:
704 str
= "Prefix/distribute list can not co-exist";
706 case BGP_ERR_NOT_INTERNAL_PEER
:
707 str
= "Invalid command. Not an internal neighbor";
709 case BGP_ERR_REMOVE_PRIVATE_AS
:
710 str
= "remove-private-AS cannot be configured for IBGP peers";
712 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
713 str
= "Local-AS allowed only for EBGP peers";
715 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
716 str
= "Cannot have local-as same as BGP AS number";
718 case BGP_ERR_TCPSIG_FAILED
:
719 str
= "Error while applying TCP-Sig to session(s)";
721 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
722 str
= "ebgp-multihop and ttl-security cannot be configured together";
724 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
725 str
= "ttl-security only allowed for EBGP peers";
727 case BGP_ERR_AS_OVERRIDE
:
728 str
= "as-override cannot be configured for IBGP peers";
730 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
731 str
= "Invalid limit for number of dynamic neighbors";
733 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
734 str
= "Dynamic neighbor listen range already exists";
736 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
737 str
= "Operation not allowed on a dynamic neighbor";
739 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
740 str
= "Operation not allowed on a directly connected neighbor";
742 case BGP_ERR_PEER_SAFI_CONFLICT
:
743 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
745 case BGP_ERR_GR_INVALID_CMD
:
746 str
= "The Graceful Restart command used is not valid at this moment.";
748 case BGP_ERR_GR_OPERATION_FAILED
:
749 str
= "The Graceful Restart Operation failed due to an err.";
751 case BGP_GR_NO_OPERATION
:
754 case BGP_ERR_PEER_GROUP_MEMBER
:
755 str
= "Peer-group member cannot override remote-as of peer-group";
757 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
758 str
= "Peer-group members must be all internal or all external";
762 snprintf(errmsg
, errmsg_len
, "%s", str
);
769 int bgp_vty_return(struct vty
*vty
, int ret
)
771 const char *str
= NULL
;
774 case BGP_ERR_INVALID_VALUE
:
775 str
= "Invalid value";
777 case BGP_ERR_INVALID_FLAG
:
778 str
= "Invalid flag";
780 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
781 str
= "Peer-group has been shutdown. Activate the peer-group first";
783 case BGP_ERR_PEER_FLAG_CONFLICT
:
784 str
= "Can't set override-capability and strict-capability-match at the same time";
786 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
787 str
= "Specify remote-as or peer-group remote AS first";
789 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
790 str
= "Cannot change the peer-group. Deconfigure first";
792 case BGP_ERR_PEER_GROUP_MISMATCH
:
793 str
= "Peer is not a member of this peer-group";
795 case BGP_ERR_PEER_FILTER_CONFLICT
:
796 str
= "Prefix/distribute list can not co-exist";
798 case BGP_ERR_NOT_INTERNAL_PEER
:
799 str
= "Invalid command. Not an internal neighbor";
801 case BGP_ERR_REMOVE_PRIVATE_AS
:
802 str
= "remove-private-AS cannot be configured for IBGP peers";
804 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
805 str
= "Local-AS allowed only for EBGP peers";
807 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
808 str
= "Cannot have local-as same as BGP AS number";
810 case BGP_ERR_TCPSIG_FAILED
:
811 str
= "Error while applying TCP-Sig to session(s)";
813 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
814 str
= "ebgp-multihop and ttl-security cannot be configured together";
816 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
817 str
= "ttl-security only allowed for EBGP peers";
819 case BGP_ERR_AS_OVERRIDE
:
820 str
= "as-override cannot be configured for IBGP peers";
822 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
823 str
= "Invalid limit for number of dynamic neighbors";
825 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
826 str
= "Dynamic neighbor listen range already exists";
828 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
829 str
= "Operation not allowed on a dynamic neighbor";
831 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
832 str
= "Operation not allowed on a directly connected neighbor";
834 case BGP_ERR_PEER_SAFI_CONFLICT
:
835 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
837 case BGP_ERR_GR_INVALID_CMD
:
838 str
= "The Graceful Restart command used is not valid at this moment.";
840 case BGP_ERR_GR_OPERATION_FAILED
:
841 str
= "The Graceful Restart Operation failed due to an err.";
843 case BGP_GR_NO_OPERATION
:
848 vty_out(vty
, "%% %s\n", str
);
849 return CMD_WARNING_CONFIG_FAILED
;
854 /* BGP clear sort. */
863 static void bgp_clear_vty_error(struct peer
*peer
, afi_t afi
, safi_t safi
,
864 int error
, char *errmsg
, size_t errmsg_len
)
867 case BGP_ERR_AF_UNCONFIGURED
:
868 snprintf(errmsg
, errmsg_len
,
869 "%%BGP: Enable %s address family for the neighbor %s",
870 get_afi_safi_str(afi
, safi
, false), peer
->host
);
872 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
875 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig",
883 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
884 struct listnode
**nnode
, enum bgp_clear_type stype
)
889 /* if afi/.safi not specified, spin thru all of them */
890 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
894 FOREACH_AFI_SAFI (tmp_afi
, tmp_safi
) {
895 paf
= peer_af_find(peer
, tmp_afi
, tmp_safi
);
896 if (paf
&& paf
->subgroup
)
897 SET_FLAG(paf
->subgroup
->sflags
,
898 SUBGRP_STATUS_FORCE_UPDATES
);
900 if (!peer
->afc
[tmp_afi
][tmp_safi
])
903 if (stype
== BGP_CLEAR_SOFT_NONE
)
904 ret
= peer_clear(peer
, nnode
);
906 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
909 /* if afi specified and safi not, spin thru safis on this afi */
910 } else if (safi
== SAFI_UNSPEC
) {
913 for (tmp_safi
= SAFI_UNICAST
;
914 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
915 if (!peer
->afc
[afi
][tmp_safi
])
918 paf
= peer_af_find(peer
, afi
, tmp_safi
);
919 if (paf
&& paf
->subgroup
)
920 SET_FLAG(paf
->subgroup
->sflags
,
921 SUBGRP_STATUS_FORCE_UPDATES
);
923 if (stype
== BGP_CLEAR_SOFT_NONE
)
924 ret
= peer_clear(peer
, nnode
);
926 ret
= peer_clear_soft(peer
, afi
,
929 /* both afi/safi specified, let the caller know if not defined */
931 if (!peer
->afc
[afi
][safi
])
934 paf
= peer_af_find(peer
, afi
, safi
);
935 if (paf
&& paf
->subgroup
)
936 SET_FLAG(paf
->subgroup
->sflags
,
937 SUBGRP_STATUS_FORCE_UPDATES
);
939 if (stype
== BGP_CLEAR_SOFT_NONE
)
940 ret
= peer_clear(peer
, nnode
);
942 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
948 /* `clear ip bgp' functions. */
949 static int bgp_clear(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
950 enum clear_sort sort
, enum bgp_clear_type stype
,
951 const char *arg
, char *errmsg
, size_t errmsg_len
)
957 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
959 /* Clear all neighbors. */
961 * Pass along pointer to next node to peer_clear() when walking all
962 * nodes on the BGP instance as that may get freed if it is a
965 if (sort
== clear_all
) {
966 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
968 bgp_peer_gr_flags_update(peer
);
970 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
971 gr_router_detected
= true;
973 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
977 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
981 if (gr_router_detected
982 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
983 bgp_zebra_send_capabilities(bgp
, false);
984 } else if (!gr_router_detected
985 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
986 bgp_zebra_send_capabilities(bgp
, true);
989 /* This is to apply read-only mode on this clear. */
990 if (stype
== BGP_CLEAR_SOFT_NONE
)
991 bgp
->update_delay_over
= 0;
996 /* Clear specified neighbor. */
997 if (sort
== clear_peer
) {
1000 /* Make sockunion for lookup. */
1001 ret
= str2sockunion(arg
, &su
);
1003 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1005 peer
= peer_lookup_by_hostname(bgp
, arg
);
1009 "Malformed address or name: %s",
1015 peer
= peer_lookup(bgp
, &su
);
1017 snprintf(errmsg
, errmsg_len
,
1018 "%%BGP: Unknown neighbor - \"%s\"",
1024 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1025 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1027 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1029 /* if afi/safi not defined for this peer, let caller know */
1031 ret
= BGP_ERR_AF_UNCONFIGURED
;
1034 bgp_clear_vty_error(peer
, afi
, safi
, ret
, errmsg
,
1040 /* Clear all neighbors belonging to a specific peer-group. */
1041 if (sort
== clear_group
) {
1042 struct peer_group
*group
;
1044 group
= peer_group_lookup(bgp
, arg
);
1046 snprintf(errmsg
, errmsg_len
,
1047 "%%BGP: No such peer-group %s", arg
);
1051 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1052 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1055 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1056 errmsg
, errmsg_len
);
1064 "%%BGP: No %s peer belonging to peer-group %s is configured",
1065 get_afi_safi_str(afi
, safi
, false), arg
);
1070 /* Clear all external (eBGP) neighbors. */
1071 if (sort
== clear_external
) {
1072 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1073 if (peer
->sort
== BGP_PEER_IBGP
)
1076 bgp_peer_gr_flags_update(peer
);
1078 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1079 gr_router_detected
= true;
1081 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1084 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1085 errmsg
, errmsg_len
);
1090 if (gr_router_detected
1091 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1092 bgp_zebra_send_capabilities(bgp
, false);
1093 } else if (!gr_router_detected
1094 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1095 bgp_zebra_send_capabilities(bgp
, true);
1099 snprintf(errmsg
, errmsg_len
,
1100 "%%BGP: No external %s peer is configured",
1101 get_afi_safi_str(afi
, safi
, false));
1106 /* Clear all neighbors belonging to a specific AS. */
1107 if (sort
== clear_as
) {
1108 as_t as
= strtoul(arg
, NULL
, 10);
1110 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1114 bgp_peer_gr_flags_update(peer
);
1116 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1117 gr_router_detected
= true;
1119 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1122 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1123 errmsg
, errmsg_len
);
1128 if (gr_router_detected
1129 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1130 bgp_zebra_send_capabilities(bgp
, false);
1131 } else if (!gr_router_detected
1132 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1133 bgp_zebra_send_capabilities(bgp
, true);
1137 snprintf(errmsg
, errmsg_len
,
1138 "%%BGP: No %s peer is configured with AS %s",
1139 get_afi_safi_str(afi
, safi
, false), arg
);
1147 static int bgp_clear_vty(const char *name
, afi_t afi
, safi_t safi
,
1148 enum clear_sort sort
, enum bgp_clear_type stype
,
1149 const char *arg
, char *errmsg
, size_t errmsg_len
)
1153 /* BGP structure lookup. */
1155 bgp
= bgp_lookup_by_name(name
);
1157 snprintf(errmsg
, errmsg_len
,
1158 "Can't find BGP instance %s", name
);
1162 bgp
= bgp_get_default();
1164 snprintf(errmsg
, errmsg_len
,
1165 "No BGP process is configured");
1170 return bgp_clear(bgp
, afi
, safi
, sort
, stype
, arg
, errmsg
, errmsg_len
);
1173 /* clear soft inbound */
1174 int bgp_clear_star_soft_in(const char *name
, char *errmsg
, size_t errmsg_len
)
1180 FOREACH_AFI_SAFI (afi
, safi
) {
1181 ret
= bgp_clear_vty(name
, afi
, safi
, clear_all
,
1182 BGP_CLEAR_SOFT_IN
, NULL
, errmsg
,
1184 if (ret
!= CMD_SUCCESS
)
1191 /* clear soft outbound */
1192 int bgp_clear_star_soft_out(const char *name
, char *errmsg
, size_t errmsg_len
)
1198 FOREACH_AFI_SAFI (afi
, safi
) {
1199 ret
= bgp_clear_vty(name
, afi
, safi
, clear_all
,
1200 BGP_CLEAR_SOFT_OUT
, NULL
, errmsg
,
1202 if (ret
!= CMD_SUCCESS
)
1210 #ifndef VTYSH_EXTRACT_PL
1211 #include "bgpd/bgp_vty_clippy.c"
1214 DEFUN_HIDDEN (bgp_local_mac
,
1216 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1218 "Local MAC config\n"
1219 "VxLAN Network Identifier\n"
1223 "mac-mobility sequence\n"
1233 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1234 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1235 vty_out(vty
, "%% Malformed MAC address\n");
1238 memset(&ip
, 0, sizeof(ip
));
1239 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1241 bgp
= bgp_get_default();
1243 vty_out(vty
, "Default BGP instance is not there\n");
1247 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1250 vty_out(vty
, "Internal error\n");
1257 DEFUN_HIDDEN (no_bgp_local_mac
,
1258 no_bgp_local_mac_cmd
,
1259 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1262 "Local MAC config\n"
1263 "VxLAN Network Identifier\n"
1274 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1275 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1276 vty_out(vty
, "%% Malformed MAC address\n");
1279 memset(&ip
, 0, sizeof(ip
));
1281 bgp
= bgp_get_default();
1283 vty_out(vty
, "Default BGP instance is not there\n");
1287 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1289 vty_out(vty
, "Internal error\n");
1296 DEFUN (no_synchronization
,
1297 no_synchronization_cmd
,
1298 "no synchronization",
1300 "Perform IGP synchronization\n")
1305 DEFUN (no_auto_summary
,
1306 no_auto_summary_cmd
,
1309 "Enable automatic network number summarization\n")
1314 /* "router bgp" commands. */
1315 DEFUN_YANG_NOSH(router_bgp
,
1317 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1318 ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR
)
1321 int idx_view_vrf
= 3;
1323 int ret
= CMD_SUCCESS
;
1326 const char *name
= NULL
;
1327 char as_str
[12] = {'\0'};
1328 enum bgp_instance_type inst_type
;
1329 char base_xpath
[XPATH_MAXLEN
];
1331 // "router bgp" without an ASN
1333 // Pending: Make VRF option available for ASN less config
1334 bgp
= bgp_get_default();
1337 vty_out(vty
, "%% No BGP process is configured\n");
1338 return CMD_WARNING_CONFIG_FAILED
;
1341 if (listcount(bm
->bgp
) > 1) {
1342 vty_out(vty
, "%% Please specify ASN and VRF\n");
1343 return CMD_WARNING_CONFIG_FAILED
;
1346 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1347 "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME
);
1349 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
1350 snprintf(as_str
, 12, "%d", bgp
->as
);
1351 nb_cli_enqueue_change(vty
, "./global/local-as", NB_OP_MODIFY
,
1353 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
) {
1354 nb_cli_enqueue_change(vty
,
1355 "./global/instance-type-view",
1356 NB_OP_MODIFY
, "true");
1359 nb_cli_pending_commit_check(vty
);
1360 ret
= nb_cli_apply_changes(vty
, base_xpath
);
1361 if (ret
== CMD_SUCCESS
) {
1362 VTY_PUSH_XPATH(BGP_NODE
, base_xpath
);
1365 * For backward compatibility with old commands we still
1366 * need to use the qobj infrastructure.
1368 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1376 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1377 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1379 name
= argv
[idx_vrf
]->arg
;
1381 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1382 if (strmatch(name
, VRF_DEFAULT_NAME
))
1385 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1386 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view")) {
1387 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1390 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1391 "frr-bgp:bgp", "bgp", name
? name
: VRF_DEFAULT_NAME
);
1393 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
1394 nb_cli_enqueue_change(vty
, "./global/local-as", NB_OP_MODIFY
,
1395 argv
[idx_asn
]->arg
);
1396 if (inst_type
== BGP_INSTANCE_TYPE_VIEW
) {
1397 nb_cli_enqueue_change(vty
,
1398 "./global/instance-type-view",
1399 NB_OP_MODIFY
, "true");
1402 nb_cli_pending_commit_check(vty
);
1403 ret
= nb_cli_apply_changes(vty
, base_xpath
);
1404 if (ret
== CMD_SUCCESS
) {
1405 VTY_PUSH_XPATH(BGP_NODE
, base_xpath
);
1408 * For backward compatibility with old commands we still
1409 * need to use the qobj infrastructure.
1411 bgp
= bgp_lookup(as
, name
);
1413 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1420 /* "no router bgp" commands. */
1421 DEFUN_YANG(no_router_bgp
,
1423 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1424 NO_STR ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR
)
1430 const char *name
= NULL
;
1431 char base_xpath
[XPATH_MAXLEN
];
1432 const struct lyd_node
*bgp_glb_dnode
;
1434 // "no router bgp" without an ASN
1436 // Pending: Make VRF option available for ASN less config
1437 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1438 "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME
);
1440 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
1442 if (!bgp_glb_dnode
) {
1443 vty_out(vty
, "%% No BGP process is configured\n");
1444 return CMD_WARNING_CONFIG_FAILED
;
1447 if (listcount(bm
->bgp
) > 1) {
1448 vty_out(vty
, "%% Please specify ASN and VRF\n");
1449 return CMD_WARNING_CONFIG_FAILED
;
1452 /* tcli mode bgp would not be set until apply stage. */
1453 bgp
= nb_running_get_entry(bgp_glb_dnode
, NULL
, false);
1458 vty_out(vty
, "%% Please unconfigure l3vni %u",
1460 return CMD_WARNING_CONFIG_FAILED
;
1463 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1466 name
= argv
[idx_vrf
]->arg
;
1468 /* Lookup bgp structure. */
1469 bgp
= bgp_lookup(as
, name
);
1471 vty_out(vty
, "%% Can't find BGP instance\n");
1472 return CMD_WARNING_CONFIG_FAILED
;
1476 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1478 return CMD_WARNING_CONFIG_FAILED
;
1481 /* Cannot delete default instance if vrf instances exist */
1482 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1483 struct listnode
*node
;
1484 struct bgp
*tmp_bgp
;
1486 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1487 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1489 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1490 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1491 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1492 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1493 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1494 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1495 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1496 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1497 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1498 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1499 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1500 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1501 (bgp
== bgp_get_evpn() &&
1502 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1503 BGP_L2VPN_EVPN_ADVERTISE_IPV4_UNICAST
) ||
1504 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1505 BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST
))) ||
1506 (tmp_bgp
->vnihash
&& hashcount(tmp_bgp
->vnihash
))) {
1508 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1509 return CMD_WARNING_CONFIG_FAILED
;
1514 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1515 "frr-bgp:bgp", "bgp",
1516 bgp
->name
? bgp
->name
: VRF_DEFAULT_NAME
);
1518 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
1520 return nb_cli_apply_changes(vty
, base_xpath
);
1523 void cli_show_router_bgp(struct vty
*vty
, struct lyd_node
*dnode
,
1526 const struct lyd_node
*vrf_dnode
;
1527 const char *vrf_name
;
1530 vrf_dnode
= yang_dnode_get_parent(dnode
, "control-plane-protocol");
1531 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
1532 as
= yang_dnode_get_uint32(dnode
, "./global/local-as");
1534 vty_out(vty
, "!\n");
1535 vty_out(vty
, "router bgp %u", as
);
1536 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
))
1537 vty_out(vty
, " vrf %s", vrf_name
);
1541 /* BGP router-id. */
1543 DEFPY_YANG(bgp_router_id
, bgp_router_id_cmd
, "bgp router-id A.B.C.D",
1545 "Override configured router identifier\n"
1546 "Manually configured router identifier\n")
1548 nb_cli_enqueue_change(vty
, "./global/router-id", NB_OP_MODIFY
,
1551 return nb_cli_apply_changes(vty
, NULL
);
1554 DEFPY_YANG(no_bgp_router_id
, no_bgp_router_id_cmd
, "no bgp router-id [A.B.C.D]",
1556 "Override configured router identifier\n"
1557 "Manually configured router identifier\n")
1559 nb_cli_enqueue_change(vty
, "./global/router-id", NB_OP_DESTROY
,
1560 router_id_str
? router_id_str
: NULL
);
1562 return nb_cli_apply_changes(vty
, NULL
);
1565 void cli_show_router_bgp_router_id(struct vty
*vty
, struct lyd_node
*dnode
,
1568 vty_out(vty
, " bgp router-id %s\n", yang_dnode_get_string(dnode
, NULL
));
1571 DEFPY (bgp_global_suppress_fib_pending
,
1572 bgp_global_suppress_fib_pending_cmd
,
1573 "[no] bgp suppress-fib-pending",
1576 "Advertise only routes that are programmed in kernel to peers globally\n")
1578 bm_wait_for_fib_set(!no
);
1583 DEFPY (bgp_suppress_fib_pending
,
1584 bgp_suppress_fib_pending_cmd
,
1585 "[no] bgp suppress-fib-pending",
1588 "Advertise only routes that are programmed in kernel to peers\n")
1590 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1592 bgp_suppress_fib_pending_set(bgp
, !no
);
1597 /* BGP Cluster ID. */
1598 DEFUN_YANG(bgp_cluster_id
,
1600 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1602 "Configure Route-Reflector Cluster-id\n"
1603 "Route-Reflector Cluster-id in IP address format\n"
1604 "Route-Reflector Cluster-id as 32 bit quantity\n")
1608 nb_cli_enqueue_change(
1609 vty
, "./global/route-reflector/route-reflector-cluster-id",
1610 NB_OP_MODIFY
, argv
[idx_ipv4
]->arg
);
1612 return nb_cli_apply_changes(vty
, NULL
);
1615 DEFUN_YANG(no_bgp_cluster_id
,
1616 no_bgp_cluster_id_cmd
,
1617 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1619 "Configure Route-Reflector Cluster-id\n"
1620 "Route-Reflector Cluster-id in IP address format\n"
1621 "Route-Reflector Cluster-id as 32 bit quantity\n")
1623 nb_cli_enqueue_change(
1624 vty
, "./global/route-reflector/route-reflector-cluster-id",
1625 NB_OP_DESTROY
, NULL
);
1627 return nb_cli_apply_changes(vty
, NULL
);
1634 "Disable BGP route installation to RIB (Zebra)\n")
1636 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1638 "%% No-RIB option is already set, nothing to do here.\n");
1642 bgp_option_norib_set_runtime();
1647 DEFPY (no_bgp_norib
,
1652 "Disable BGP route installation to RIB (Zebra)\n")
1654 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1656 "%% No-RIB option is not set, nothing to do here.\n");
1660 bgp_option_norib_unset_runtime();
1665 DEFPY (no_bgp_send_extra_data
,
1666 no_bgp_send_extra_data_cmd
,
1667 "[no] bgp send-extra-data zebra",
1670 "Extra data to Zebra for display/use\n"
1674 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1676 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1681 DEFUN_YANG(bgp_confederation_identifier
,
1682 bgp_confederation_identifier_cmd
,
1683 "bgp confederation identifier (1-4294967295)",
1684 "BGP specific commands\n"
1685 "AS confederation parameters\n"
1687 "Set routing domain confederation AS\n")
1691 nb_cli_enqueue_change(vty
, "./global/confederation/identifier",
1692 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
1694 return nb_cli_apply_changes(vty
, NULL
);
1697 DEFUN_YANG(no_bgp_confederation_identifier
,
1698 no_bgp_confederation_identifier_cmd
,
1699 "no bgp confederation identifier [(1-4294967295)]",
1701 "BGP specific commands\n"
1702 "AS confederation parameters\n"
1704 "Set routing domain confederation AS\n")
1706 nb_cli_enqueue_change(vty
, "./global/confederation/identifier",
1707 NB_OP_DESTROY
, NULL
);
1709 return nb_cli_apply_changes(vty
, NULL
);
1712 void cli_show_router_bgp_confederation_identifier(struct vty
*vty
,
1713 struct lyd_node
*dnode
,
1716 vty_out(vty
, " bgp confederation identifier %u\n",
1717 yang_dnode_get_uint32(dnode
, NULL
));
1720 DEFUN_YANG(bgp_confederation_peers
,
1721 bgp_confederation_peers_cmd
,
1722 "bgp confederation peers (1-4294967295)...",
1723 "BGP specific commands\n"
1724 "AS confederation parameters\n"
1725 "Peer ASs in BGP confederation\n" AS_STR
)
1730 for (i
= idx_asn
; i
< argc
; i
++)
1731 nb_cli_enqueue_change(vty
, "./global/confederation/member-as",
1732 NB_OP_CREATE
, argv
[i
]->arg
);
1734 return nb_cli_apply_changes(vty
, NULL
);
1737 DEFUN_YANG(no_bgp_confederation_peers
,
1738 no_bgp_confederation_peers_cmd
,
1739 "no bgp confederation peers (1-4294967295)...",
1741 "BGP specific commands\n"
1742 "AS confederation parameters\n"
1743 "Peer ASs in BGP confederation\n" AS_STR
)
1748 for (i
= idx_asn
; i
< argc
; i
++)
1749 nb_cli_enqueue_change(vty
, "./global/confederation/member-as",
1750 NB_OP_DESTROY
, argv
[i
]->arg
);
1752 return nb_cli_apply_changes(vty
, NULL
);
1755 void cli_show_router_bgp_confederation_member_as(struct vty
*vty
,
1756 struct lyd_node
*dnode
,
1759 vty_out(vty
, " bgp confederation peers %u \n",
1760 yang_dnode_get_uint32(dnode
, NULL
));
1764 * Central routine for maximum-paths configuration.
1765 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1766 * @set: 1 for setting values, 0 for removing the max-paths config.
1768 int bgp_maxpaths_config_vty(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1769 int peer_type
, uint16_t maxpaths
, uint16_t options
,
1770 int set
, char *errmsg
, size_t errmsg_len
)
1775 if (maxpaths
> multipath_num
) {
1778 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1779 maxpaths
, multipath_num
);
1780 return CMD_WARNING_CONFIG_FAILED
;
1782 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1785 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1790 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1791 (set
== 1) ? "" : "un",
1792 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1793 maxpaths
, afi
, safi
);
1794 return CMD_WARNING_CONFIG_FAILED
;
1797 bgp_recalculate_all_bestpaths(bgp
);
1802 void cli_show_router_bgp_med_config(struct vty
*vty
, struct lyd_node
*dnode
,
1805 if (yang_dnode_get_bool(dnode
, "./enable-med-admin")) {
1806 uint32_t med_admin_val
;
1808 vty_out(vty
, " bgp max-med administrative");
1809 if ((med_admin_val
=
1810 yang_dnode_get_uint32(dnode
, "./max-med-admin"))
1811 != BGP_MAXMED_VALUE_DEFAULT
)
1812 vty_out(vty
, " %u", med_admin_val
);
1816 if (yang_dnode_exists(dnode
, "./max-med-onstart-up-time")) {
1817 uint32_t onstartup_val
;
1819 vty_out(vty
, " bgp max-med on-startup %u",
1820 yang_dnode_get_uint32(dnode
,
1821 "./max-med-onstart-up-time"));
1822 onstartup_val
= yang_dnode_get_uint32(
1823 dnode
, "./max-med-onstart-up-value");
1824 if (onstartup_val
!= BGP_MAXMED_VALUE_DEFAULT
)
1825 vty_out(vty
, " %u", onstartup_val
);
1831 DEFUN_YANG(bgp_maxmed_admin
,
1832 bgp_maxmed_admin_cmd
,
1833 "bgp max-med administrative ",
1835 "Advertise routes with max-med\n"
1836 "Administratively applied, for an indefinite period\n")
1838 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1839 NB_OP_MODIFY
, "true");
1841 return nb_cli_apply_changes(vty
, NULL
);
1844 DEFUN_YANG(bgp_maxmed_admin_medv
,
1845 bgp_maxmed_admin_medv_cmd
,
1846 "bgp max-med administrative (0-4294967295)",
1848 "Advertise routes with max-med\n"
1849 "Administratively applied, for an indefinite period\n"
1850 "Max MED value to be used\n")
1854 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1855 NB_OP_MODIFY
, "true");
1857 nb_cli_enqueue_change(vty
, "./global/med-config/max-med-admin",
1858 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
1860 return nb_cli_apply_changes(vty
, NULL
);
1863 DEFUN_YANG(no_bgp_maxmed_admin
,
1864 no_bgp_maxmed_admin_cmd
,
1865 "no bgp max-med administrative [(0-4294967295)]",
1867 "Advertise routes with max-med\n"
1868 "Administratively applied, for an indefinite period\n"
1869 "Max MED value to be used\n")
1871 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1872 NB_OP_MODIFY
, "false");
1874 nb_cli_enqueue_change(vty
, "./global/med-config/max-med-admin",
1875 NB_OP_MODIFY
, NULL
);
1877 return nb_cli_apply_changes(vty
, NULL
);
1880 DEFUN_YANG (bgp_maxmed_onstartup
,
1881 bgp_maxmed_onstartup_cmd
,
1882 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1884 "Advertise routes with max-med\n"
1885 "Effective on a startup\n"
1886 "Time (seconds) period for max-med\n"
1887 "Max MED value to be used\n")
1891 argv_find(argv
, argc
, "(5-86400)", &idx
);
1892 nb_cli_enqueue_change(vty
,
1893 "./global/med-config/max-med-onstart-up-time",
1894 NB_OP_MODIFY
, argv
[idx
]->arg
);
1896 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1897 nb_cli_enqueue_change(
1898 vty
, "./global/med-config/max-med-onstart-up-value",
1899 NB_OP_MODIFY
, argv
[idx
]->arg
);
1901 nb_cli_enqueue_change(
1902 vty
, "./global/med-config/max-med-onstart-up-value",
1903 NB_OP_MODIFY
, NULL
);
1905 return nb_cli_apply_changes(vty
, NULL
);
1908 DEFUN_YANG (no_bgp_maxmed_onstartup
,
1909 no_bgp_maxmed_onstartup_cmd
,
1910 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1912 "Advertise routes with max-med\n"
1913 "Effective on a startup\n"
1914 "Time (seconds) period for max-med\n"
1915 "Max MED value to be used\n")
1917 nb_cli_enqueue_change(vty
,
1918 "./global/med-config/max-med-onstart-up-time",
1919 NB_OP_DESTROY
, NULL
);
1921 nb_cli_enqueue_change(vty
,
1922 "./global/med-config/max-med-onstart-up-value",
1923 NB_OP_MODIFY
, NULL
);
1925 return nb_cli_apply_changes(vty
, NULL
);
1928 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
1929 uint16_t update_delay
,
1930 uint16_t establish_wait
)
1932 struct listnode
*node
, *nnode
;
1934 bool vrf_cfg
= false;
1937 * See if update-delay is set per-vrf and warn user to delete it
1938 * Note that we only need to check this if this is the first time
1939 * setting the global config.
1941 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
1942 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1943 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1945 "%% update-delay configuration found in vrf %s\n",
1946 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
1956 "%%Failed: global update-delay config not permitted\n");
1960 if (!establish_wait
) { /* update-delay <delay> */
1961 bm
->v_update_delay
= update_delay
;
1962 bm
->v_establish_wait
= bm
->v_update_delay
;
1964 /* update-delay <delay> <establish-wait> */
1965 if (update_delay
< establish_wait
) {
1967 "%%Failed: update-delay less than the establish-wait!\n");
1968 return CMD_WARNING_CONFIG_FAILED
;
1971 bm
->v_update_delay
= update_delay
;
1972 bm
->v_establish_wait
= establish_wait
;
1975 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1976 bgp
->v_update_delay
= bm
->v_update_delay
;
1977 bgp
->v_establish_wait
= bm
->v_establish_wait
;
1983 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
1985 struct listnode
*node
, *nnode
;
1988 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1989 bm
->v_establish_wait
= bm
->v_update_delay
;
1991 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1992 bgp
->v_update_delay
= bm
->v_update_delay
;
1993 bgp
->v_establish_wait
= bm
->v_establish_wait
;
1999 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
2000 uint16_t establish_wait
)
2002 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2004 /* if configured globally, per-instance config is not allowed */
2005 if (bm
->v_update_delay
) {
2007 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2008 return CMD_WARNING_CONFIG_FAILED
;
2012 if (!establish_wait
) /* update-delay <delay> */
2014 bgp
->v_update_delay
= update_delay
;
2015 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2019 /* update-delay <delay> <establish-wait> */
2020 if (update_delay
< establish_wait
) {
2022 "%%Failed: update-delay less than the establish-wait!\n");
2023 return CMD_WARNING_CONFIG_FAILED
;
2026 bgp
->v_update_delay
= update_delay
;
2027 bgp
->v_establish_wait
= establish_wait
;
2032 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2034 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2036 /* If configured globally, cannot remove from one bgp instance */
2037 if (bm
->v_update_delay
) {
2039 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2040 return CMD_WARNING_CONFIG_FAILED
;
2042 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2043 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2048 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2050 /* If configured globally, no need to display per-instance value */
2051 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2052 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2053 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2054 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2059 /* Global update-delay configuration */
2060 DEFPY (bgp_global_update_delay
,
2061 bgp_global_update_delay_cmd
,
2062 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2064 "Force initial delay for best-path and updates for all bgp instances\n"
2065 "Max delay in seconds\n"
2066 "Establish wait in seconds\n")
2068 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2071 /* Global update-delay deconfiguration */
2072 DEFPY (no_bgp_global_update_delay
,
2073 no_bgp_global_update_delay_cmd
,
2074 "no bgp update-delay [(0-3600) [(1-3600)]]",
2077 "Force initial delay for best-path and updates\n"
2078 "Max delay in seconds\n"
2079 "Establish wait in seconds\n")
2081 return bgp_global_update_delay_deconfig_vty(vty
);
2084 /* Update-delay configuration */
2086 DEFPY (bgp_update_delay
,
2087 bgp_update_delay_cmd
,
2088 "update-delay (0-3600)$delay [(1-3600)$wait]",
2089 "Force initial delay for best-path and updates\n"
2090 "Max delay in seconds\n"
2091 "Establish wait in seconds\n")
2093 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2096 /* Update-delay deconfiguration */
2097 DEFPY (no_bgp_update_delay
,
2098 no_bgp_update_delay_cmd
,
2099 "no update-delay [(0-3600) [(1-3600)]]",
2101 "Force initial delay for best-path and updates\n"
2102 "Max delay in seconds\n"
2103 "Establish wait in seconds\n")
2105 return bgp_update_delay_deconfig_vty(vty
);
2109 int bgp_wpkt_quanta_config_vty(struct bgp
*bgp
, uint32_t quanta
, bool set
)
2111 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2112 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2117 int bgp_rpkt_quanta_config_vty(struct bgp
*bgp
, uint32_t quanta
, bool set
)
2119 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2120 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2125 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2128 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2129 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2130 vty_out(vty
, " write-quanta %d\n", quanta
);
2133 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2136 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2137 if (quanta
!= BGP_READ_PACKET_MAX
)
2138 vty_out(vty
, " read-quanta %d\n", quanta
);
2141 /* Packet quanta configuration
2143 * XXX: The value set here controls the size of a stack buffer in the IO
2144 * thread. When changing these limits be careful to prevent stack overflow.
2146 * Furthermore, the maximums used here should correspond to
2147 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2149 DEFPY_YANG (bgp_wpkt_quanta
,
2150 bgp_wpkt_quanta_cmd
,
2151 "[no] write-quanta (1-64)$quanta",
2153 "How many packets to write to peer socket per run\n"
2154 "Number of packets\n")
2157 nb_cli_enqueue_change(
2159 "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta",
2160 NB_OP_MODIFY
, quanta_str
);
2162 nb_cli_enqueue_change(
2164 "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta",
2165 NB_OP_MODIFY
, NULL
);
2167 return nb_cli_apply_changes(vty
, NULL
);
2170 DEFPY_YANG (bgp_rpkt_quanta
,
2171 bgp_rpkt_quanta_cmd
,
2172 "[no] read-quanta (1-10)$quanta",
2174 "How many packets to read from peer socket per I/O cycle\n"
2175 "Number of packets\n")
2178 nb_cli_enqueue_change(
2180 "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta",
2181 NB_OP_MODIFY
, quanta_str
);
2183 nb_cli_enqueue_change(
2185 "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta",
2186 NB_OP_MODIFY
, NULL
);
2188 return nb_cli_apply_changes(vty
, NULL
);
2191 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2193 if (!bgp
->heuristic_coalesce
)
2194 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2197 void cli_show_router_global_update_group_config_coalesce_time(
2198 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2200 vty_out(vty
, " coalesce-time %u\n", yang_dnode_get_uint32(dnode
, NULL
));
2204 DEFUN_YANG (bgp_coalesce_time
,
2205 bgp_coalesce_time_cmd
,
2206 "coalesce-time (0-4294967295)",
2207 "Subgroup coalesce timer\n"
2208 "Subgroup coalesce timer value (in ms)\n")
2212 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
2213 nb_cli_enqueue_change(
2214 vty
, "./global/global-update-group-config/coalesce-time",
2215 NB_OP_MODIFY
, argv
[idx
]->arg
);
2217 return nb_cli_apply_changes(vty
, NULL
);
2220 DEFUN_YANG(no_bgp_coalesce_time
,
2221 no_bgp_coalesce_time_cmd
,
2222 "no coalesce-time (0-4294967295)",
2224 "Subgroup coalesce timer\n"
2225 "Subgroup coalesce timer value (in ms)\n")
2227 nb_cli_enqueue_change(
2228 vty
, "./global/global-update-group-config/coalesce-time",
2229 NB_OP_MODIFY
, NULL
);
2231 return nb_cli_apply_changes(vty
, NULL
);
2234 /* Maximum-paths configuration */
2235 DEFUN_YANG (bgp_maxpaths
,
2237 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2238 "Forward packets over multiple paths\n"
2239 "Number of paths\n")
2242 char base_xpath
[XPATH_MAXLEN
];
2246 afi
= bgp_node_afi(vty
);
2247 safi
= bgp_node_safi(vty
);
2250 base_xpath
, sizeof(base_xpath
),
2251 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ebgp/maximum-paths",
2252 yang_afi_safi_value2identity(afi
, safi
),
2253 bgp_afi_safi_get_container_str(afi
, safi
));
2255 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2256 argv
[idx_number
]->arg
);
2258 return nb_cli_apply_changes(vty
, NULL
);
2261 void cli_show_bgp_global_afi_safi_unicast_use_multiple_paths_ebgp_maximum_paths(
2262 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2264 vty_out(vty
, " maximum-paths %d\n",
2265 yang_dnode_get_uint16(dnode
, NULL
));
2268 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2269 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2270 "Forward packets over multiple paths\n"
2271 "Number of paths\n")
2273 DEFUN_YANG (bgp_maxpaths_ibgp
,
2274 bgp_maxpaths_ibgp_cmd
,
2275 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2276 "Forward packets over multiple paths\n"
2278 "Number of paths\n")
2281 char base_xpath
[XPATH_MAXLEN
];
2285 afi
= bgp_node_afi(vty
);
2286 safi
= bgp_node_safi(vty
);
2289 base_xpath
, sizeof(base_xpath
),
2290 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2291 yang_afi_safi_value2identity(afi
, safi
),
2292 bgp_afi_safi_get_container_str(afi
, safi
));
2294 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2295 argv
[idx_number
]->arg
);
2297 return nb_cli_apply_changes(vty
, NULL
);
2300 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2301 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2302 "Forward packets over multiple paths\n"
2304 "Number of paths\n")
2306 DEFUN_YANG (bgp_maxpaths_ibgp_cluster
,
2307 bgp_maxpaths_ibgp_cluster_cmd
,
2308 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2309 "Forward packets over multiple paths\n"
2312 "Match the cluster length\n")
2315 char base_xpath
[XPATH_MAXLEN
];
2319 afi
= bgp_node_afi(vty
);
2320 safi
= bgp_node_safi(vty
);
2323 base_xpath
, sizeof(base_xpath
),
2324 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2325 yang_afi_safi_value2identity(afi
, safi
),
2326 bgp_afi_safi_get_container_str(afi
, safi
));
2328 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2329 argv
[idx_number
]->arg
);
2332 base_xpath
, sizeof(base_xpath
),
2333 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/cluster-length-list",
2334 yang_afi_safi_value2identity(afi
, safi
),
2335 bgp_afi_safi_get_container_str(afi
, safi
));
2337 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, "true");
2339 return nb_cli_apply_changes(vty
, NULL
);
2342 void cli_show_bgp_global_afi_safi_ip_unicast_use_multiple_paths_ibgp_maximum_paths(
2343 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2345 vty_out(vty
, " maximum-paths ibgp %d",
2346 yang_dnode_get_uint16(dnode
, "./maximum-paths"));
2347 if (yang_dnode_get_bool(dnode
, "./cluster-length-list"))
2348 vty_out(vty
, " equal-cluster-length");
2352 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2353 "maximum-paths ibgp " CMD_RANGE_STR(
2354 1, MULTIPATH_NUM
) " equal-cluster-length",
2355 "Forward packets over multiple paths\n"
2358 "Match the cluster length\n")
2360 DEFUN_YANG (no_bgp_maxpaths
,
2361 no_bgp_maxpaths_cmd
,
2362 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2364 "Forward packets over multiple paths\n"
2365 "Number of paths\n")
2367 char base_xpath
[XPATH_MAXLEN
];
2371 afi
= bgp_node_afi(vty
);
2372 safi
= bgp_node_safi(vty
);
2375 base_xpath
, sizeof(base_xpath
),
2376 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ebgp/maximum-paths",
2377 yang_afi_safi_value2identity(afi
, safi
),
2378 bgp_afi_safi_get_container_str(afi
, safi
));
2380 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, NULL
);
2382 return nb_cli_apply_changes(vty
, NULL
);
2385 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2386 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2387 "Forward packets over multiple paths\n"
2388 "Number of paths\n")
2390 DEFUN_YANG (no_bgp_maxpaths_ibgp
,
2391 no_bgp_maxpaths_ibgp_cmd
,
2392 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2394 "Forward packets over multiple paths\n"
2397 "Match the cluster length\n")
2399 char base_xpath
[XPATH_MAXLEN
];
2403 afi
= bgp_node_afi(vty
);
2404 safi
= bgp_node_safi(vty
);
2407 base_xpath
, sizeof(base_xpath
),
2408 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2409 yang_afi_safi_value2identity(afi
, safi
),
2410 bgp_afi_safi_get_container_str(afi
, safi
));
2412 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, NULL
);
2415 base_xpath
, sizeof(base_xpath
),
2416 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/cluster-length-list",
2417 yang_afi_safi_value2identity(afi
, safi
),
2418 bgp_afi_safi_get_container_str(afi
, safi
));
2420 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, "false");
2422 return nb_cli_apply_changes(vty
, NULL
);
2425 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2426 "no maximum-paths ibgp [" CMD_RANGE_STR(
2427 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2429 "Forward packets over multiple paths\n"
2432 "Match the cluster length\n")
2434 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2435 afi_t afi
, safi_t safi
)
2437 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2438 vty_out(vty
, " maximum-paths %d\n",
2439 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2442 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2443 vty_out(vty
, " maximum-paths ibgp %d",
2444 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2445 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
2446 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
2447 vty_out(vty
, " equal-cluster-length");
2454 DEFUN_YANG (bgp_timers
,
2456 "timers bgp (0-65535) (0-65535)",
2457 "Adjust routing timers\n"
2459 "Keepalive interval\n"
2463 int idx_number_2
= 3;
2465 nb_cli_enqueue_change(vty
, "./global/global-config-timers/keepalive",
2466 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
2467 nb_cli_enqueue_change(vty
, "./global/global-config-timers/hold-time",
2468 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
2470 return nb_cli_apply_changes(vty
, NULL
);
2473 DEFUN_YANG (no_bgp_timers
,
2475 "no timers bgp [(0-65535) (0-65535)]",
2477 "Adjust routing timers\n"
2479 "Keepalive interval\n"
2482 nb_cli_enqueue_change(vty
, "./global/global-config-timers/keepalive",
2483 NB_OP_DESTROY
, NULL
);
2484 nb_cli_enqueue_change(vty
, "./global/global-config-timers/hold-time",
2485 NB_OP_DESTROY
, NULL
);
2487 return nb_cli_apply_changes(vty
, NULL
);
2490 void cli_show_router_bgp_route_reflector(struct vty
*vty
,
2491 struct lyd_node
*dnode
,
2494 if (yang_dnode_get_bool(dnode
, "./no-client-reflect"))
2495 vty_out(vty
, " no bgp client-to-client reflection\n");
2497 if (yang_dnode_get_bool(dnode
, "./allow-outbound-policy"))
2498 vty_out(vty
, " bgp route-reflector allow-outbound-policy\n");
2500 if (yang_dnode_exists(dnode
, "./route-reflector-cluster-id"))
2501 vty_out(vty
, " bgp cluster-id %s\n",
2502 yang_dnode_get_string(dnode
,
2503 "./route-reflector-cluster-id"));
2506 DEFUN_YANG(bgp_client_to_client_reflection
,
2507 bgp_client_to_client_reflection_cmd
,
2508 "bgp client-to-client reflection",
2509 "BGP specific commands\n"
2510 "Configure client to client route reflection\n"
2511 "reflection of routes allowed\n")
2513 nb_cli_enqueue_change(vty
, "./global/route-reflector/no-client-reflect",
2514 NB_OP_MODIFY
, "false");
2516 return nb_cli_apply_changes(vty
, NULL
);
2519 DEFUN_YANG(no_bgp_client_to_client_reflection
,
2520 no_bgp_client_to_client_reflection_cmd
,
2521 "no bgp client-to-client reflection",
2523 "BGP specific commands\n"
2524 "Configure client to client route reflection\n"
2525 "reflection of routes allowed\n")
2527 nb_cli_enqueue_change(vty
, "./global/route-reflector/no-client-reflect",
2528 NB_OP_MODIFY
, "true");
2530 return nb_cli_apply_changes(vty
, NULL
);
2533 void cli_show_router_bgp_route_selection(struct vty
*vty
,
2534 struct lyd_node
*dnode
,
2538 if (yang_dnode_get_bool(dnode
, "./always-compare-med"))
2539 vty_out(vty
, " bgp always-compare-med\n");
2541 if (yang_dnode_get_bool(dnode
, "./ignore-as-path-length"))
2542 vty_out(vty
, " bgp bestpath as-path ignore\n");
2544 if (yang_dnode_get_bool(dnode
, "./aspath-confed"))
2545 vty_out(vty
, " bgp bestpath as-path confed\n");
2547 if (yang_dnode_get_bool(dnode
, "./external-compare-router-id"))
2548 vty_out(vty
, " bgp bestpath compare-routerid\n");
2550 if (yang_dnode_get_bool(dnode
, "./allow-multiple-as")) {
2551 if (yang_dnode_get_bool(dnode
, "./multi-path-as-set"))
2553 " bgp bestpath as-path multipath-relax as-set\n");
2555 vty_out(vty
, " bgp bestpath as-path multipath-relax\n");
2558 if (yang_dnode_get_bool(dnode
, "./deterministic-med"))
2559 vty_out(vty
, " bgp deterministic-med\n");
2561 if (yang_dnode_get_bool(dnode
, "./confed-med")
2562 || yang_dnode_get_bool(dnode
, "./missing-as-worst-med")) {
2563 vty_out(vty
, " bgp bestpath med");
2564 if (yang_dnode_get_bool(dnode
, "./confed-med"))
2565 vty_out(vty
, " confed");
2566 if (yang_dnode_get_bool(dnode
, "./missing-as-worst-med"))
2567 vty_out(vty
, " missing-as-worst");
2572 /* "bgp always-compare-med" configuration. */
2573 DEFUN_YANG(bgp_always_compare_med
,
2574 bgp_always_compare_med_cmd
,
2575 "bgp always-compare-med",
2576 "BGP specific commands\n"
2577 "Allow comparing MED from different neighbors\n")
2579 nb_cli_enqueue_change(
2580 vty
, "./global/route-selection-options/always-compare-med",
2581 NB_OP_MODIFY
, "true");
2583 return nb_cli_apply_changes(vty
, NULL
);
2586 DEFUN_YANG(no_bgp_always_compare_med
,
2587 no_bgp_always_compare_med_cmd
,
2588 "no bgp always-compare-med",
2590 "BGP specific commands\n"
2591 "Allow comparing MED from different neighbors\n")
2593 nb_cli_enqueue_change(
2594 vty
, "./global/route-selection-options/always-compare-med",
2595 NB_OP_MODIFY
, "false");
2597 return nb_cli_apply_changes(vty
, NULL
);
2600 DEFUN_YANG(bgp_suppress_duplicates
,
2601 bgp_suppress_duplicates_cmd
,
2602 "bgp suppress-duplicates",
2603 "BGP specific commands\n"
2604 "Suppress duplicate updates if the route actually not changed\n")
2606 nb_cli_enqueue_change(vty
, "./global/suppress-duplicates",
2607 NB_OP_MODIFY
, "true");
2608 return nb_cli_apply_changes(vty
, NULL
);
2611 DEFUN_YANG(no_bgp_suppress_duplicates
,
2612 no_bgp_suppress_duplicates_cmd
,
2613 "no bgp suppress-duplicates",
2615 "BGP specific commands\n"
2616 "Suppress duplicate updates if the route actually not changed\n")
2618 nb_cli_enqueue_change(vty
, "./global/suppress-duplicates",
2619 NB_OP_MODIFY
, "false");
2620 return nb_cli_apply_changes(vty
, NULL
);
2623 void cli_show_router_bgp_suppress_duplicates(struct vty
*vty
,
2624 struct lyd_node
*dnode
,
2627 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SUPPRESS_DUPLICATES
)
2628 vty_out(vty
, " bgp suppress-duplicates\n");
2631 DEFUN_YANG(bgp_ebgp_requires_policy
,
2632 bgp_ebgp_requires_policy_cmd
,
2633 "bgp ebgp-requires-policy",
2634 "BGP specific commands\n"
2635 "Require in and out policy for eBGP peers (RFC8212)\n")
2637 nb_cli_enqueue_change(vty
, "./global/ebgp-requires-policy",
2638 NB_OP_MODIFY
, "true");
2639 return nb_cli_apply_changes(vty
, NULL
);
2642 DEFUN_YANG(no_bgp_ebgp_requires_policy
,
2643 no_bgp_ebgp_requires_policy_cmd
,
2644 "no bgp ebgp-requires-policy",
2646 "BGP specific commands\n"
2647 "Require in and out policy for eBGP peers (RFC8212)\n")
2649 nb_cli_enqueue_change(vty
, "./global/ebgp-requires-policy",
2650 NB_OP_MODIFY
, "false");
2651 return nb_cli_apply_changes(vty
, NULL
);
2654 void cli_show_router_bgp_ebgp_requires_policy(struct vty
*vty
,
2655 struct lyd_node
*dnode
,
2658 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_EBGP_REQUIRES_POLICY
)
2659 vty_out(vty
, " bgp ebgp-requires-policy\n");
2662 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2663 "bgp reject-as-sets",
2664 "BGP specific commands\n"
2665 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2667 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2668 struct listnode
*node
, *nnode
;
2671 bgp
->reject_as_sets
= true;
2673 /* Reset existing BGP sessions to reject routes
2674 * with aspath containing AS_SET or AS_CONFED_SET.
2676 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2677 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2678 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2679 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2680 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2687 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2688 "no bgp reject-as-sets",
2690 "BGP specific commands\n"
2691 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2693 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2694 struct listnode
*node
, *nnode
;
2697 bgp
->reject_as_sets
= false;
2699 /* Reset existing BGP sessions to reject routes
2700 * with aspath containing AS_SET or AS_CONFED_SET.
2702 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2703 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2704 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2705 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2706 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2713 /* "bgp deterministic-med" configuration. */
2714 DEFUN_YANG (bgp_deterministic_med
,
2715 bgp_deterministic_med_cmd
,
2716 "bgp deterministic-med",
2717 "BGP specific commands\n"
2718 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2720 nb_cli_enqueue_change(
2721 vty
, "./global/route-selection-options/deterministic-med",
2722 NB_OP_MODIFY
, "true");
2724 return nb_cli_apply_changes(vty
, NULL
);
2727 DEFUN_YANG (no_bgp_deterministic_med
,
2728 no_bgp_deterministic_med_cmd
,
2729 "no bgp deterministic-med",
2731 "BGP specific commands\n"
2732 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2734 nb_cli_enqueue_change(
2735 vty
, "./global/route-selection-options/deterministic-med",
2736 NB_OP_MODIFY
, "false");
2738 return nb_cli_apply_changes(vty
, NULL
);
2741 /* "bgp graceful-restart mode" configuration. */
2742 DEFUN (bgp_graceful_restart
,
2743 bgp_graceful_restart_cmd
,
2744 "bgp graceful-restart",
2745 "BGP specific commands\n"
2749 int ret
= BGP_GR_FAILURE
;
2751 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2752 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2754 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2756 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2758 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2761 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2762 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2764 "Graceful restart configuration changed, reset all peers to take effect\n");
2765 return bgp_vty_return(vty
, ret
);
2768 DEFUN (no_bgp_graceful_restart
,
2769 no_bgp_graceful_restart_cmd
,
2770 "no bgp graceful-restart",
2772 "BGP specific commands\n"
2776 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2778 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2779 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2781 int ret
= BGP_GR_FAILURE
;
2783 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2785 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2788 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2789 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2791 "Graceful restart configuration changed, reset all peers to take effect\n");
2793 return bgp_vty_return(vty
, ret
);
2796 DEFUN (bgp_graceful_restart_stalepath_time
,
2797 bgp_graceful_restart_stalepath_time_cmd
,
2798 "bgp graceful-restart stalepath-time (1-4095)",
2799 "BGP specific commands\n"
2800 "Graceful restart capability parameters\n"
2801 "Set the max time to hold onto restarting peer's stale paths\n"
2802 "Delay value (seconds)\n")
2804 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2808 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2809 bgp
->stalepath_time
= stalepath
;
2813 DEFUN (bgp_graceful_restart_restart_time
,
2814 bgp_graceful_restart_restart_time_cmd
,
2815 "bgp graceful-restart restart-time (1-4095)",
2816 "BGP specific commands\n"
2817 "Graceful restart capability parameters\n"
2818 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2819 "Delay value (seconds)\n")
2821 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2825 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2826 bgp
->restart_time
= restart
;
2830 DEFUN (bgp_graceful_restart_select_defer_time
,
2831 bgp_graceful_restart_select_defer_time_cmd
,
2832 "bgp graceful-restart select-defer-time (0-3600)",
2833 "BGP specific commands\n"
2834 "Graceful restart capability parameters\n"
2835 "Set the time to defer the BGP route selection after restart\n"
2836 "Delay value (seconds, 0 - disable)\n")
2838 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2840 uint32_t defer_time
;
2842 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2843 bgp
->select_defer_time
= defer_time
;
2844 if (defer_time
== 0)
2845 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2847 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2852 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2853 no_bgp_graceful_restart_stalepath_time_cmd
,
2854 "no bgp graceful-restart stalepath-time [(1-4095)]",
2856 "BGP specific commands\n"
2857 "Graceful restart capability parameters\n"
2858 "Set the max time to hold onto restarting peer's stale paths\n"
2859 "Delay value (seconds)\n")
2861 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2863 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2867 DEFUN (no_bgp_graceful_restart_restart_time
,
2868 no_bgp_graceful_restart_restart_time_cmd
,
2869 "no bgp graceful-restart restart-time [(1-4095)]",
2871 "BGP specific commands\n"
2872 "Graceful restart capability parameters\n"
2873 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2874 "Delay value (seconds)\n")
2876 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2878 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2882 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2883 no_bgp_graceful_restart_select_defer_time_cmd
,
2884 "no bgp graceful-restart select-defer-time [(0-3600)]",
2886 "BGP specific commands\n"
2887 "Graceful restart capability parameters\n"
2888 "Set the time to defer the BGP route selection after restart\n"
2889 "Delay value (seconds)\n")
2891 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2893 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2894 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2899 DEFUN (bgp_graceful_restart_preserve_fw
,
2900 bgp_graceful_restart_preserve_fw_cmd
,
2901 "bgp graceful-restart preserve-fw-state",
2902 "BGP specific commands\n"
2903 "Graceful restart capability parameters\n"
2904 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2906 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2907 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2911 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2912 no_bgp_graceful_restart_preserve_fw_cmd
,
2913 "no bgp graceful-restart preserve-fw-state",
2915 "BGP specific commands\n"
2916 "Graceful restart capability parameters\n"
2917 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2919 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2920 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2924 DEFUN (bgp_graceful_restart_disable
,
2925 bgp_graceful_restart_disable_cmd
,
2926 "bgp graceful-restart-disable",
2927 "BGP specific commands\n"
2930 int ret
= BGP_GR_FAILURE
;
2932 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2934 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
2936 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2938 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
2940 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
2943 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2945 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
2947 "Graceful restart configuration changed, reset all peers to take effect\n");
2949 return bgp_vty_return(vty
, ret
);
2952 DEFUN (no_bgp_graceful_restart_disable
,
2953 no_bgp_graceful_restart_disable_cmd
,
2954 "no bgp graceful-restart-disable",
2956 "BGP specific commands\n"
2960 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2962 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2964 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
2966 int ret
= BGP_GR_FAILURE
;
2968 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
2970 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2973 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2975 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
2977 "Graceful restart configuration changed, reset all peers to take effect\n");
2979 return bgp_vty_return(vty
, ret
);
2982 DEFUN (bgp_neighbor_graceful_restart_set
,
2983 bgp_neighbor_graceful_restart_set_cmd
,
2984 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
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_set_cmd : START ");
3000 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3002 return CMD_WARNING_CONFIG_FAILED
;
3004 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
3006 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3007 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3009 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3011 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
3013 "Graceful restart configuration changed, reset this peer to take effect\n");
3015 return bgp_vty_return(vty
, ret
);
3018 DEFUN (no_bgp_neighbor_graceful_restart
,
3019 no_bgp_neighbor_graceful_restart_set_cmd
,
3020 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3028 int ret
= BGP_GR_FAILURE
;
3031 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3033 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3035 return CMD_WARNING_CONFIG_FAILED
;
3037 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3039 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3041 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
3043 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3044 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3046 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3048 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3050 "Graceful restart configuration changed, reset this peer to take effect\n");
3052 return bgp_vty_return(vty
, ret
);
3055 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3056 bgp_neighbor_graceful_restart_helper_set_cmd
,
3057 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3060 GR_NEIGHBOR_HELPER_CMD
3065 int ret
= BGP_GR_FAILURE
;
3067 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3069 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3071 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3073 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3076 return CMD_WARNING_CONFIG_FAILED
;
3079 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3081 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3082 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3084 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3086 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3088 "Graceful restart configuration changed, reset this peer to take effect\n");
3090 return bgp_vty_return(vty
, ret
);
3093 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3094 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3095 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3099 NO_GR_NEIGHBOR_HELPER_CMD
3103 int ret
= BGP_GR_FAILURE
;
3106 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3108 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3110 return CMD_WARNING_CONFIG_FAILED
;
3112 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3114 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3116 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3118 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3119 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3121 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3123 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3125 "Graceful restart configuration changed, reset this peer to take effect\n");
3127 return bgp_vty_return(vty
, ret
);
3130 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3131 bgp_neighbor_graceful_restart_disable_set_cmd
,
3132 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3135 GR_NEIGHBOR_DISABLE_CMD
3140 int ret
= BGP_GR_FAILURE
;
3142 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3144 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3146 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3148 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3150 return CMD_WARNING_CONFIG_FAILED
;
3152 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3154 if (peer
->bgp
->t_startup
)
3155 bgp_peer_gr_flags_update(peer
);
3157 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3158 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3160 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3162 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3164 "Graceful restart configuration changed, reset this peer to take effect\n");
3166 return bgp_vty_return(vty
, ret
);
3169 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3170 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3171 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3175 NO_GR_NEIGHBOR_DISABLE_CMD
3179 int ret
= BGP_GR_FAILURE
;
3182 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3184 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3186 return CMD_WARNING_CONFIG_FAILED
;
3188 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3190 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3192 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3194 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3195 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3197 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3199 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3201 "Graceful restart configuration changed, reset this peer to take effect\n");
3203 return bgp_vty_return(vty
, ret
);
3206 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3207 bgp_graceful_restart_disable_eor_cmd
,
3208 "bgp graceful-restart disable-eor",
3209 "BGP specific commands\n"
3210 "Graceful restart configuration parameters\n"
3211 "Disable EOR Check\n")
3213 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3214 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3219 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3220 no_bgp_graceful_restart_disable_eor_cmd
,
3221 "no bgp graceful-restart disable-eor",
3223 "BGP specific commands\n"
3224 "Graceful restart configuration parameters\n"
3225 "Disable EOR Check\n")
3227 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3228 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3233 DEFUN (bgp_graceful_restart_rib_stale_time
,
3234 bgp_graceful_restart_rib_stale_time_cmd
,
3235 "bgp graceful-restart rib-stale-time (1-3600)",
3236 "BGP specific commands\n"
3237 "Graceful restart configuration parameters\n"
3238 "Specify the stale route removal timer in rib\n"
3239 "Delay value (seconds)\n")
3241 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3243 uint32_t stale_time
;
3245 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3246 bgp
->rib_stale_time
= stale_time
;
3247 /* Send the stale timer update message to RIB */
3248 if (bgp_zebra_stale_timer_update(bgp
))
3254 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3255 no_bgp_graceful_restart_rib_stale_time_cmd
,
3256 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3258 "BGP specific commands\n"
3259 "Graceful restart configuration parameters\n"
3260 "Specify the stale route removal timer in rib\n"
3261 "Delay value (seconds)\n")
3263 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3265 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3266 /* Send the stale timer update message to RIB */
3267 if (bgp_zebra_stale_timer_update(bgp
))
3273 static inline int bgp_initiate_graceful_shut_unshut(struct bgp
*bgp
,
3277 bgp_static_redo_import_check(bgp
);
3278 bgp_redistribute_redo(bgp
);
3279 if (bgp_clear_star_soft_out(bgp
->name
, errmsg
, errmsg_len
) < 0)
3281 if (bgp_clear_star_soft_in(bgp
->name
, errmsg
, errmsg_len
) < 0)
3287 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3289 struct listnode
*node
, *nnode
;
3291 bool vrf_cfg
= false;
3292 char errmsg
[BUFSIZ
] = {'\0'};
3294 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3297 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3298 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3299 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3301 "%% graceful-shutdown configuration found in vrf %s\n",
3302 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3303 VRF_DEFAULT_NAME
: bgp
->name
);
3310 "%%Failed: global graceful-shutdown not permitted\n");
3314 /* Set flag globally */
3315 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3317 /* Initiate processing for all BGP instances. */
3318 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3319 if (bgp_initiate_graceful_shut_unshut(bgp
, errmsg
,
3323 vty_out(vty
, "%s\n", errmsg
);
3329 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3331 struct listnode
*node
, *nnode
;
3333 char errmsg
[BUFSIZ
] = {'\0'};
3335 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3338 /* Unset flag globally */
3339 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3341 /* Initiate processing for all BGP instances. */
3342 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3343 if (bgp_initiate_graceful_shut_unshut(bgp
, errmsg
,
3347 vty_out(vty
, "%s\n", errmsg
);
3353 /* "bgp graceful-shutdown" configuration */
3354 DEFUN (bgp_graceful_shutdown
,
3355 bgp_graceful_shutdown_cmd
,
3356 "bgp graceful-shutdown",
3358 "Graceful shutdown parameters\n")
3360 if (vty
->node
== CONFIG_NODE
)
3361 return bgp_global_graceful_shutdown_config_vty(vty
);
3363 nb_cli_enqueue_change(vty
, "./global/graceful-shutdown/enable",
3364 NB_OP_MODIFY
, "true");
3366 return nb_cli_apply_changes(vty
, NULL
);
3369 DEFUN_YANG (no_bgp_graceful_shutdown
,
3370 no_bgp_graceful_shutdown_cmd
,
3371 "no bgp graceful-shutdown",
3374 "Graceful shutdown parameters\n")
3376 if (vty
->node
== CONFIG_NODE
)
3377 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3379 nb_cli_enqueue_change(vty
, "./global/graceful-shutdown/enable",
3380 NB_OP_MODIFY
, "false");
3382 return nb_cli_apply_changes(vty
, NULL
);
3385 void cli_show_router_bgp_graceful_shutdown(struct vty
*vty
,
3386 struct lyd_node
*dnode
,
3389 if (yang_dnode_get_bool(dnode
, NULL
))
3390 vty_out(vty
, " bgp graceful-shutdown\n");
3393 /* "bgp fast-external-failover" configuration. */
3394 DEFUN_YANG (bgp_fast_external_failover
,
3395 bgp_fast_external_failover_cmd
,
3396 "bgp fast-external-failover",
3398 "Immediately reset session if a link to a directly connected external peer goes down\n")
3400 nb_cli_enqueue_change(vty
, "./global/fast-external-failover",
3401 NB_OP_MODIFY
, "false");
3403 return nb_cli_apply_changes(vty
, NULL
);
3406 DEFUN_YANG (no_bgp_fast_external_failover
,
3407 no_bgp_fast_external_failover_cmd
,
3408 "no bgp fast-external-failover",
3411 "Immediately reset session if a link to a directly connected external peer goes down\n")
3413 nb_cli_enqueue_change(vty
, "./global/fast-external-failover",
3414 NB_OP_MODIFY
, "true");
3416 return nb_cli_apply_changes(vty
, NULL
);
3419 void cli_show_router_bgp_fast_external_failover(struct vty
*vty
,
3420 struct lyd_node
*dnode
,
3423 if (!yang_dnode_get_bool(dnode
, NULL
))
3424 vty_out(vty
, " no bgp fast-external-failover\n");
3427 /* "bgp bestpath compare-routerid" configuration. */
3428 DEFUN_YANG(bgp_bestpath_compare_router_id
,
3429 bgp_bestpath_compare_router_id_cmd
,
3430 "bgp bestpath compare-routerid",
3431 "BGP specific commands\n"
3432 "Change the default bestpath selection\n"
3433 "Compare router-id for identical EBGP paths\n")
3435 nb_cli_enqueue_change(
3437 "./global/route-selection-options/external-compare-router-id",
3438 NB_OP_MODIFY
, "true");
3440 return nb_cli_apply_changes(vty
, NULL
);
3443 DEFUN_YANG(no_bgp_bestpath_compare_router_id
,
3444 no_bgp_bestpath_compare_router_id_cmd
,
3445 "no bgp bestpath compare-routerid",
3447 "BGP specific commands\n"
3448 "Change the default bestpath selection\n"
3449 "Compare router-id for identical EBGP paths\n")
3451 nb_cli_enqueue_change(
3453 "./global/route-selection-options/external-compare-router-id",
3454 NB_OP_MODIFY
, "false");
3456 return nb_cli_apply_changes(vty
, NULL
);
3459 /* "bgp bestpath as-path ignore" configuration. */
3460 DEFUN_YANG(bgp_bestpath_aspath_ignore
,
3461 bgp_bestpath_aspath_ignore_cmd
,
3462 "bgp bestpath as-path ignore",
3463 "BGP specific commands\n"
3464 "Change the default bestpath selection\n"
3465 "AS-path attribute\n"
3466 "Ignore as-path length in selecting a route\n")
3468 nb_cli_enqueue_change(
3469 vty
, "./global/route-selection-options/ignore-as-path-length",
3470 NB_OP_MODIFY
, "true");
3472 return nb_cli_apply_changes(vty
, NULL
);
3475 DEFUN_YANG(no_bgp_bestpath_aspath_ignore
,
3476 no_bgp_bestpath_aspath_ignore_cmd
,
3477 "no bgp bestpath as-path ignore",
3479 "BGP specific commands\n"
3480 "Change the default bestpath selection\n"
3481 "AS-path attribute\n"
3482 "Ignore as-path length in selecting a route\n")
3484 nb_cli_enqueue_change(
3485 vty
, "./global/route-selection-options/ignore-as-path-length",
3486 NB_OP_MODIFY
, "false");
3488 return nb_cli_apply_changes(vty
, NULL
);
3491 /* "bgp bestpath as-path confed" configuration. */
3492 DEFUN_YANG (bgp_bestpath_aspath_confed
,
3493 bgp_bestpath_aspath_confed_cmd
,
3494 "bgp bestpath as-path confed",
3495 "BGP specific commands\n"
3496 "Change the default bestpath selection\n"
3497 "AS-path attribute\n"
3498 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3500 nb_cli_enqueue_change(vty
,
3501 "./global/route-selection-options/aspath-confed",
3502 NB_OP_MODIFY
, "true");
3504 return nb_cli_apply_changes(vty
, NULL
);
3507 DEFUN_YANG (no_bgp_bestpath_aspath_confed
,
3508 no_bgp_bestpath_aspath_confed_cmd
,
3509 "no bgp bestpath as-path confed",
3511 "BGP specific commands\n"
3512 "Change the default bestpath selection\n"
3513 "AS-path attribute\n"
3514 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3516 nb_cli_enqueue_change(vty
,
3517 "./global/route-selection-options/aspath-confed",
3518 NB_OP_MODIFY
, "false");
3520 return nb_cli_apply_changes(vty
, NULL
);
3523 /* "bgp bestpath as-path multipath-relax" configuration. */
3524 DEFUN_YANG (bgp_bestpath_aspath_multipath_relax
,
3525 bgp_bestpath_aspath_multipath_relax_cmd
,
3526 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3527 "BGP specific commands\n"
3528 "Change the default bestpath selection\n"
3529 "AS-path attribute\n"
3530 "Allow load sharing across routes that have different AS paths (but same length)\n"
3531 "Generate an AS_SET\n"
3532 "Do not generate an AS_SET\n")
3536 nb_cli_enqueue_change(
3537 vty
, "./global/route-selection-options/allow-multiple-as",
3538 NB_OP_MODIFY
, "true");
3539 if (argv_find(argv
, argc
, "as-set", &idx
))
3540 nb_cli_enqueue_change(
3542 "./global/route-selection-options/multi-path-as-set",
3543 NB_OP_MODIFY
, "true");
3545 nb_cli_enqueue_change(
3547 "./global/route-selection-options/multi-path-as-set",
3548 NB_OP_MODIFY
, "false");
3550 return nb_cli_apply_changes(vty
, NULL
);
3553 DEFUN_YANG (no_bgp_bestpath_aspath_multipath_relax
,
3554 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3555 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3557 "BGP specific commands\n"
3558 "Change the default bestpath selection\n"
3559 "AS-path attribute\n"
3560 "Allow load sharing across routes that have different AS paths (but same length)\n"
3561 "Generate an AS_SET\n"
3562 "Do not generate an AS_SET\n")
3564 nb_cli_enqueue_change(
3565 vty
, "./global/route-selection-options/allow-multiple-as",
3566 NB_OP_MODIFY
, "false");
3567 nb_cli_enqueue_change(
3568 vty
, "./global/route-selection-options/multi-path-as-set",
3569 NB_OP_MODIFY
, "false");
3571 return nb_cli_apply_changes(vty
, NULL
);
3574 /* "bgp log-neighbor-changes" configuration. */
3575 DEFUN_YANG(bgp_log_neighbor_changes
,
3576 bgp_log_neighbor_changes_cmd
,
3577 "bgp log-neighbor-changes",
3578 "BGP specific commands\n"
3579 "Log neighbor up/down and reset reason\n")
3581 nb_cli_enqueue_change(
3582 vty
, "./global/global-neighbor-config/log-neighbor-changes",
3583 NB_OP_MODIFY
, "true");
3585 return nb_cli_apply_changes(vty
, NULL
);
3588 DEFUN_YANG(no_bgp_log_neighbor_changes
,
3589 no_bgp_log_neighbor_changes_cmd
,
3590 "no bgp log-neighbor-changes",
3592 "BGP specific commands\n"
3593 "Log neighbor up/down and reset reason\n")
3595 nb_cli_enqueue_change(
3596 vty
, "./global/global-neighbor-config/log-neighbor-changes",
3597 NB_OP_MODIFY
, "false");
3599 return nb_cli_apply_changes(vty
, NULL
);
3602 /* "bgp bestpath med" configuration. */
3603 DEFUN_YANG (bgp_bestpath_med
,
3604 bgp_bestpath_med_cmd
,
3605 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3606 "BGP specific commands\n"
3607 "Change the default bestpath selection\n"
3609 "Compare MED among confederation paths\n"
3610 "Treat missing MED as the least preferred one\n"
3611 "Treat missing MED as the least preferred one\n"
3612 "Compare MED among confederation paths\n")
3615 bool confed
= false;
3616 bool worst_med
= false;
3619 if (argv_find(argv
, argc
, "confed", &idx
))
3622 nb_cli_enqueue_change(vty
,
3623 "./global/route-selection-options/confed-med",
3624 NB_OP_MODIFY
, confed
? "true" : "false");
3627 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3630 nb_cli_enqueue_change(
3631 vty
, "./global/route-selection-options/missing-as-worst-med",
3632 NB_OP_MODIFY
, worst_med
? "true" : "false");
3634 return nb_cli_apply_changes(vty
, NULL
);
3637 DEFUN_YANG (no_bgp_bestpath_med
,
3638 no_bgp_bestpath_med_cmd
,
3639 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3641 "BGP specific commands\n"
3642 "Change the default bestpath selection\n"
3644 "Compare MED among confederation paths\n"
3645 "Treat missing MED as the least preferred one\n"
3646 "Treat missing MED as the least preferred one\n"
3647 "Compare MED among confederation paths\n")
3651 if (argv_find(argv
, argc
, "confed", &idx
))
3652 nb_cli_enqueue_change(
3653 vty
, "./global/route-selection-options/confed-med",
3654 NB_OP_MODIFY
, "false");
3657 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3658 nb_cli_enqueue_change(
3660 "./global/route-selection-options/missing-as-worst-med",
3661 NB_OP_MODIFY
, "false");
3663 return nb_cli_apply_changes(vty
, NULL
);
3666 /* "bgp bestpath bandwidth" configuration. */
3667 DEFPY (bgp_bestpath_bw
,
3668 bgp_bestpath_bw_cmd
,
3669 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3670 "BGP specific commands\n"
3671 "Change the default bestpath selection\n"
3672 "Link Bandwidth attribute\n"
3673 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3674 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3675 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3677 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3682 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3683 return CMD_ERR_INCOMPLETE
;
3685 if (!strcmp(bw_cfg
, "ignore"))
3686 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3687 else if (!strcmp(bw_cfg
, "skip-missing"))
3688 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3689 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3690 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3692 return CMD_ERR_NO_MATCH
;
3694 /* This config is used in route install, so redo that. */
3695 FOREACH_AFI_SAFI (afi
, safi
) {
3696 if (!bgp_fibupd_safi(safi
))
3698 bgp_zebra_announce_table(bgp
, afi
, safi
);
3704 DEFPY (no_bgp_bestpath_bw
,
3705 no_bgp_bestpath_bw_cmd
,
3706 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3708 "BGP specific commands\n"
3709 "Change the default bestpath selection\n"
3710 "Link Bandwidth attribute\n"
3711 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3712 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3713 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3715 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3719 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3721 /* This config is used in route install, so redo that. */
3722 FOREACH_AFI_SAFI (afi
, safi
) {
3723 if (!bgp_fibupd_safi(safi
))
3725 bgp_zebra_announce_table(bgp
, afi
, safi
);
3730 /* "no bgp default ipv6-unicast". */
3731 DEFUN(no_bgp_default_ipv6_unicast
, no_bgp_default_ipv6_unicast_cmd
,
3732 "no bgp default ipv6-unicast", NO_STR
3733 "BGP specific commands\n"
3734 "Configure BGP defaults\n"
3735 "Activate ipv6-unicast for a peer by default\n")
3737 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3738 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DEFAULT_IPV6
);
3742 DEFUN(bgp_default_ipv6_unicast
, bgp_default_ipv6_unicast_cmd
,
3743 "bgp default ipv6-unicast",
3744 "BGP specific commands\n"
3745 "Configure BGP defaults\n"
3746 "Activate ipv6-unicast for a peer by default\n")
3748 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3749 SET_FLAG(bgp
->flags
, BGP_FLAG_DEFAULT_IPV6
);
3753 /* "no bgp default ipv4-unicast". */
3754 DEFUN (no_bgp_default_ipv4_unicast
,
3755 no_bgp_default_ipv4_unicast_cmd
,
3756 "no bgp default ipv4-unicast",
3758 "BGP specific commands\n"
3759 "Configure BGP defaults\n"
3760 "Activate ipv4-unicast for a peer by default\n")
3762 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3763 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
);
3767 DEFUN (bgp_default_ipv4_unicast
,
3768 bgp_default_ipv4_unicast_cmd
,
3769 "bgp default ipv4-unicast",
3770 "BGP specific commands\n"
3771 "Configure BGP defaults\n"
3772 "Activate ipv4-unicast for a peer by default\n")
3774 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3775 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
);
3779 /* Display hostname in certain command outputs */
3780 DEFUN_YANG (bgp_default_show_hostname
,
3781 bgp_default_show_hostname_cmd
,
3782 "bgp default show-hostname",
3783 "BGP specific commands\n"
3784 "Configure BGP defaults\n"
3785 "Show hostname in certain command outputs\n")
3787 nb_cli_enqueue_change(vty
, "./global/show-hostname", NB_OP_MODIFY
,
3790 return nb_cli_apply_changes(vty
, NULL
);
3793 DEFUN_YANG(no_bgp_default_show_hostname
,
3794 no_bgp_default_show_hostname_cmd
,
3795 "no bgp default show-hostname",
3797 "BGP specific commands\n"
3798 "Configure BGP defaults\n"
3799 "Show hostname in certain command outputs\n")
3801 nb_cli_enqueue_change(vty
, "./global/show-hostname", NB_OP_MODIFY
,
3804 return nb_cli_apply_changes(vty
, NULL
);
3807 void cli_show_router_bgp_show_hostname(struct vty
*vty
, struct lyd_node
*dnode
,
3810 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SHOW_HOSTNAME
)
3811 vty_out(vty
, " bgp default show-hostname\n");
3814 /* Display hostname in certain command outputs */
3815 DEFUN_YANG(bgp_default_show_nexthop_hostname
,
3816 bgp_default_show_nexthop_hostname_cmd
,
3817 "bgp default show-nexthop-hostname",
3818 "BGP specific commands\n"
3819 "Configure BGP defaults\n"
3820 "Show hostname for nexthop in certain command outputs\n")
3822 nb_cli_enqueue_change(vty
, "./global/show-nexthop-hostname",
3823 NB_OP_MODIFY
, "true");
3825 return nb_cli_apply_changes(vty
, NULL
);
3828 DEFUN (no_bgp_default_show_nexthop_hostname
,
3829 no_bgp_default_show_nexthop_hostname_cmd
,
3830 "no bgp default show-nexthop-hostname",
3832 "BGP specific commands\n"
3833 "Configure BGP defaults\n"
3834 "Show hostname for nexthop in certain command outputs\n")
3836 nb_cli_enqueue_change(vty
, "./global/show-nexthop-hostname",
3837 NB_OP_MODIFY
, "false");
3839 return nb_cli_apply_changes(vty
, NULL
);
3842 void cli_show_router_bgp_show_nexthop_hostname(struct vty
*vty
,
3843 struct lyd_node
*dnode
,
3846 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SHOW_HOSTNAME
)
3847 vty_out(vty
, " bgp default show-nexthop-hostname\n");
3850 /* "bgp network import-check" configuration. */
3851 DEFUN_YANG(bgp_network_import_check
,
3852 bgp_network_import_check_cmd
,
3853 "bgp network import-check",
3854 "BGP specific commands\n"
3855 "BGP network command\n"
3856 "Check BGP network route exists in IGP\n")
3858 nb_cli_enqueue_change(vty
, "./global/import-check", NB_OP_MODIFY
,
3861 return nb_cli_apply_changes(vty
, NULL
);
3864 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
3865 "bgp network import-check exact",
3866 "BGP specific commands\n"
3867 "BGP network command\n"
3868 "Check BGP network route exists in IGP\n"
3869 "Match route precisely\n")
3871 DEFUN_YANG(no_bgp_network_import_check
,
3872 no_bgp_network_import_check_cmd
,
3873 "no bgp network import-check",
3875 "BGP specific commands\n"
3876 "BGP network command\n"
3877 "Check BGP network route exists in IGP\n")
3879 nb_cli_enqueue_change(vty
, "./global/import-check", NB_OP_MODIFY
,
3882 return nb_cli_apply_changes(vty
, NULL
);
3885 void cli_show_router_bgp_import_check(struct vty
*vty
, struct lyd_node
*dnode
,
3888 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_IMPORT_CHECK
)
3889 vty_out(vty
, " bgp network import-check\n");
3892 DEFUN_YANG(bgp_default_local_preference
,
3893 bgp_default_local_preference_cmd
,
3894 "bgp default local-preference (0-4294967295)",
3895 "BGP specific commands\n"
3896 "Configure BGP defaults\n"
3897 "local preference (higher=more preferred)\n"
3898 "Configure default local preference value\n")
3902 nb_cli_enqueue_change(vty
, "./global/local-pref", NB_OP_MODIFY
,
3903 argv
[idx_number
]->arg
);
3905 return nb_cli_apply_changes(vty
, NULL
);
3908 DEFUN_YANG(no_bgp_default_local_preference
,
3909 no_bgp_default_local_preference_cmd
,
3910 "no bgp default local-preference [(0-4294967295)]",
3912 "BGP specific commands\n"
3913 "Configure BGP defaults\n"
3914 "local preference (higher=more preferred)\n"
3915 "Configure default local preference value\n")
3917 nb_cli_enqueue_change(vty
, "./global/local-pref", NB_OP_MODIFY
, NULL
);
3919 return nb_cli_apply_changes(vty
, NULL
);
3922 void cli_show_router_bgp_local_pref(struct vty
*vty
, struct lyd_node
*dnode
,
3925 vty_out(vty
, " bgp default local-preference %u\n",
3926 yang_dnode_get_uint32(dnode
, NULL
));
3930 DEFUN_YANG(bgp_default_subgroup_pkt_queue_max
,
3931 bgp_default_subgroup_pkt_queue_max_cmd
,
3932 "bgp default subgroup-pkt-queue-max (20-100)",
3933 "BGP specific commands\n"
3934 "Configure BGP defaults\n"
3935 "subgroup-pkt-queue-max\n"
3936 "Configure subgroup packet queue max\n")
3940 nb_cli_enqueue_change(
3942 "./global/global-update-group-config/subgroup-pkt-queue-size",
3943 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
3945 return nb_cli_apply_changes(vty
, NULL
);
3948 DEFUN_YANG(no_bgp_default_subgroup_pkt_queue_max
,
3949 no_bgp_default_subgroup_pkt_queue_max_cmd
,
3950 "no bgp default subgroup-pkt-queue-max [(20-100)]",
3952 "BGP specific commands\n"
3953 "Configure BGP defaults\n"
3954 "subgroup-pkt-queue-max\n"
3955 "Configure subgroup packet queue max\n")
3957 nb_cli_enqueue_change(
3959 "./global/global-update-group-config/subgroup-pkt-queue-size",
3960 NB_OP_MODIFY
, NULL
);
3962 return nb_cli_apply_changes(vty
, NULL
);
3965 void cli_show_router_global_update_group_config_subgroup_pkt_queue_size(
3966 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
3968 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
3969 yang_dnode_get_uint32(dnode
, NULL
));
3972 DEFUN_YANG(bgp_rr_allow_outbound_policy
,
3973 bgp_rr_allow_outbound_policy_cmd
,
3974 "bgp route-reflector allow-outbound-policy",
3975 "BGP specific commands\n"
3976 "Allow modifications made by out route-map\n"
3977 "on ibgp neighbors\n")
3979 nb_cli_enqueue_change(vty
,
3980 "./global/route-reflector/allow-outbound-policy",
3981 NB_OP_MODIFY
, "true");
3983 return nb_cli_apply_changes(vty
, NULL
);
3986 DEFUN_YANG(no_bgp_rr_allow_outbound_policy
,
3987 no_bgp_rr_allow_outbound_policy_cmd
,
3988 "no bgp route-reflector allow-outbound-policy",
3990 "BGP specific commands\n"
3991 "Allow modifications made by out route-map\n"
3992 "on ibgp neighbors\n")
3994 nb_cli_enqueue_change(vty
,
3995 "./global/route-reflector/allow-outbound-policy",
3996 NB_OP_MODIFY
, "false");
3998 return nb_cli_apply_changes(vty
, NULL
);
4002 void cli_show_router_global_neighbor_config(struct vty
*vty
,
4003 struct lyd_node
*dnode
,
4006 uint32_t write_quanta
, read_quanta
;
4008 if (yang_dnode_get_bool(dnode
, "./log-neighbor-changes"))
4009 vty_out(vty
, " bgp log-neighbor-changes\n");
4011 if (yang_dnode_exists(dnode
, "./dynamic-neighbors-limit")) {
4012 uint32_t listen_limit
= yang_dnode_get_uint32(
4013 dnode
, "./dynamic-neighbors-limit");
4014 vty_out(vty
, " bgp listen limit %u\n", listen_limit
);
4017 write_quanta
= yang_dnode_get_uint32(
4018 dnode
, "./packet-quanta-config/wpkt-quanta");
4019 if (write_quanta
!= BGP_WRITE_PACKET_MAX
)
4020 vty_out(vty
, " write-quanta %d\n", write_quanta
);
4022 read_quanta
= yang_dnode_get_uint32(
4023 dnode
, "./packet-quanta-config/rpkt-quanta");
4025 if (read_quanta
!= BGP_READ_PACKET_MAX
)
4026 vty_out(vty
, " read-quanta %d\n", read_quanta
);
4029 DEFUN_YANG(bgp_listen_limit
,
4030 bgp_listen_limit_cmd
,
4031 "bgp listen limit (1-5000)",
4032 "BGP specific commands\n"
4033 "BGP Dynamic Neighbors listen commands\n"
4034 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4035 "Configure Dynamic Neighbors listen limit value\n")
4039 nb_cli_enqueue_change(
4040 vty
, "./global/global-neighbor-config/dynamic-neighbors-limit",
4041 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
4043 return nb_cli_apply_changes(vty
, NULL
);
4046 DEFUN_YANG(no_bgp_listen_limit
,
4047 no_bgp_listen_limit_cmd
,
4048 "no bgp listen limit [(1-5000)]",
4050 "BGP specific commands\n"
4051 "BGP Dynamic Neighbors listen commands\n"
4052 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4053 "Configure Dynamic Neighbors listen limit value\n")
4055 nb_cli_enqueue_change(
4056 vty
, "./global/global-neighbor-config/dynamic-neighbors-limit",
4057 NB_OP_DESTROY
, NULL
);
4059 return nb_cli_apply_changes(vty
, NULL
);
4064 * Check if this listen range is already configured. Check for exact
4065 * match or overlap based on input.
4067 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4068 struct prefix
*range
, int exact
)
4070 struct listnode
*node
, *nnode
;
4071 struct listnode
*node1
, *nnode1
;
4072 struct peer_group
*group
;
4077 afi
= family2afi(range
->family
);
4078 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4079 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4082 match
= prefix_same(range
, lr
);
4084 match
= (prefix_match(range
, lr
)
4085 || prefix_match(lr
, range
));
4094 DEFUN (bgp_listen_range
,
4095 bgp_listen_range_cmd
,
4096 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4097 "BGP specific commands\n"
4098 "Configure BGP dynamic neighbors listen range\n"
4099 "Configure BGP dynamic neighbors listen range\n"
4101 "Member of the peer-group\n"
4102 "Peer-group name\n")
4104 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4105 struct prefix range
;
4106 struct peer_group
*group
, *existing_group
;
4111 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4112 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4113 char *prefix
= argv
[idx
]->arg
;
4114 argv_find(argv
, argc
, "PGNAME", &idx
);
4115 char *peergroup
= argv
[idx
]->arg
;
4117 /* Convert IP prefix string to struct prefix. */
4118 ret
= str2prefix(prefix
, &range
);
4120 vty_out(vty
, "%% Malformed listen range\n");
4121 return CMD_WARNING_CONFIG_FAILED
;
4124 afi
= family2afi(range
.family
);
4126 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4128 "%% Malformed listen range (link-local address)\n");
4129 return CMD_WARNING_CONFIG_FAILED
;
4134 /* Check if same listen range is already configured. */
4135 existing_group
= listen_range_exists(bgp
, &range
, 1);
4136 if (existing_group
) {
4137 if (strcmp(existing_group
->name
, peergroup
) == 0)
4141 "%% Same listen range is attached to peer-group %s\n",
4142 existing_group
->name
);
4143 return CMD_WARNING_CONFIG_FAILED
;
4147 /* Check if an overlapping listen range exists. */
4148 if (listen_range_exists(bgp
, &range
, 0)) {
4150 "%% Listen range overlaps with existing listen range\n");
4151 return CMD_WARNING_CONFIG_FAILED
;
4154 group
= peer_group_lookup(bgp
, peergroup
);
4156 vty_out(vty
, "%% Configure the peer-group first\n");
4157 return CMD_WARNING_CONFIG_FAILED
;
4160 ret
= peer_group_listen_range_add(group
, &range
);
4161 return bgp_vty_return(vty
, ret
);
4164 DEFUN (no_bgp_listen_range
,
4165 no_bgp_listen_range_cmd
,
4166 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4168 "BGP specific commands\n"
4169 "Unconfigure BGP dynamic neighbors listen range\n"
4170 "Unconfigure BGP dynamic neighbors listen range\n"
4172 "Member of the peer-group\n"
4173 "Peer-group name\n")
4175 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4176 struct prefix range
;
4177 struct peer_group
*group
;
4182 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4183 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4184 char *prefix
= argv
[idx
]->arg
;
4185 argv_find(argv
, argc
, "PGNAME", &idx
);
4186 char *peergroup
= argv
[idx
]->arg
;
4188 /* Convert IP prefix string to struct prefix. */
4189 ret
= str2prefix(prefix
, &range
);
4191 vty_out(vty
, "%% Malformed listen range\n");
4192 return CMD_WARNING_CONFIG_FAILED
;
4195 afi
= family2afi(range
.family
);
4197 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4199 "%% Malformed listen range (link-local address)\n");
4200 return CMD_WARNING_CONFIG_FAILED
;
4205 group
= peer_group_lookup(bgp
, peergroup
);
4207 vty_out(vty
, "%% Peer-group does not exist\n");
4208 return CMD_WARNING_CONFIG_FAILED
;
4211 ret
= peer_group_listen_range_del(group
, &range
);
4212 return bgp_vty_return(vty
, ret
);
4215 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4217 struct peer_group
*group
;
4218 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4219 struct prefix
*range
;
4222 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4223 vty_out(vty
, " bgp listen limit %d\n",
4224 bgp
->dynamic_neighbors_limit
);
4226 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4227 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4228 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4231 " bgp listen range %pFX peer-group %s\n",
4232 range
, group
->name
);
4239 DEFUN_YANG(bgp_disable_connected_route_check
,
4240 bgp_disable_connected_route_check_cmd
,
4241 "bgp disable-ebgp-connected-route-check",
4242 "BGP specific commands\n"
4243 "Disable checking if nexthop is connected on ebgp sessions\n")
4245 nb_cli_enqueue_change(vty
,
4246 "./global/ebgp-multihop-connected-route-check",
4247 NB_OP_MODIFY
, "true");
4249 return nb_cli_apply_changes(vty
, NULL
);
4252 DEFUN_YANG(no_bgp_disable_connected_route_check
,
4253 no_bgp_disable_connected_route_check_cmd
,
4254 "no bgp disable-ebgp-connected-route-check",
4256 "BGP specific commands\n"
4257 "Disable checking if nexthop is connected on ebgp sessions\n")
4259 nb_cli_enqueue_change(vty
,
4260 "./global/ebgp-multihop-connected-route-check",
4261 NB_OP_MODIFY
, "false");
4263 return nb_cli_apply_changes(vty
, NULL
);
4266 void cli_show_router_global_ebgp_multihop_connected_route_check(
4267 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
4269 if (yang_dnode_get_bool(dnode
, NULL
))
4270 vty_out(vty
, " bgp disable-ebgp-connected-route-check\n");
4273 DEFUN_YANG(bgp_default_shutdown
,
4274 bgp_default_shutdown_cmd
,
4275 "[no] bgp default shutdown",
4277 "Configure BGP defaults\n"
4278 "Apply administrative shutdown to newly configured peers\n")
4280 nb_cli_enqueue_change(vty
, "./global/default-shutdown", NB_OP_MODIFY
,
4281 strmatch(argv
[0]->text
, "no") ? "false" : "true");
4283 return nb_cli_apply_changes(vty
, NULL
);
4286 void cli_show_router_bgp_default_shutdown(struct vty
*vty
,
4287 struct lyd_node
*dnode
,
4290 if (yang_dnode_get_bool(dnode
, NULL
))
4291 vty_out(vty
, " bgp default shutdown\n");
4294 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4296 "Administrative shutdown of the BGP instance\n"
4297 "Add a shutdown message (RFC 8203)\n"
4298 "Shutdown message\n")
4300 char *msgstr
= NULL
;
4302 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4305 msgstr
= argv_concat(argv
, argc
, 3);
4307 bgp_shutdown_enable(bgp
, msgstr
);
4308 XFREE(MTYPE_TMP
, msgstr
);
4313 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4314 BGP_STR
"Administrative shutdown of the BGP instance\n")
4316 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4318 bgp_shutdown_enable(bgp
, NULL
);
4323 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4324 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4326 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4328 bgp_shutdown_disable(bgp
);
4333 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4334 "no bgp shutdown message MSG...", NO_STR BGP_STR
4335 "Administrative shutdown of the BGP instance\n"
4336 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4338 DEFUN_YANG(neighbor_remote_as
,
4339 neighbor_remote_as_cmd
,
4340 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4341 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4342 "Specify a BGP neighbor\n" AS_STR
4343 "Internal BGP peer\n"
4344 "External BGP peer\n")
4347 int idx_remote_as
= 3;
4348 char base_xpath
[XPATH_MAXLEN
];
4349 char unnbr_xpath
[XPATH_MAXLEN
];
4350 char prgrp_xpath
[XPATH_MAXLEN
];
4352 const char *as_type_str
= "as-specified";
4354 if (str2sockunion(argv
[idx_peer
]->arg
, &su
) < 0) {
4355 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
4356 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, argv
[idx_peer
]->arg
, "");
4358 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
4359 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
, "");
4361 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4362 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4363 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4364 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
,
4365 "%s%s", VTY_CURR_XPATH
,
4367 snprintf(base_xpath
, sizeof(base_xpath
),
4368 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
,
4372 "%% Create the peer-group or interface first\n");
4373 return CMD_WARNING_CONFIG_FAILED
;
4376 snprintf(base_xpath
, sizeof(base_xpath
),
4377 FRR_BGP_NEIGHBOR_NUM_XPATH
, argv
[idx_peer
]->arg
, "");
4380 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4381 as_type_str
= "internal";
4382 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4383 as_type_str
= "external";
4385 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4386 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4388 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4389 NB_OP_MODIFY
, as_type_str
);
4391 return nb_cli_apply_changes(vty
, base_xpath
);
4394 int peer_conf_interface_create(struct bgp
*bgp
, const char *conf_if
,
4395 bool v6only
, const char *peer_group_name
,
4396 int as_type
, as_t as
, char *errmsg
,
4400 struct peer_group
*group
;
4403 group
= peer_group_lookup(bgp
, conf_if
);
4406 snprintf(errmsg
, errmsg_len
,
4407 "Name conflict with peer-group \n");
4411 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4413 if (as_type
!= AS_UNSPECIFIED
)
4414 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
);
4416 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
, as_type
,
4420 snprintf(errmsg
, errmsg_len
,
4421 "BGP failed to create peer\n");
4426 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4428 /* Request zebra to initiate IPv6 RAs on this interface. We do
4430 * any unnumbered peer in order to not worry about run-time
4432 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4434 * gets deleted later etc.)
4437 bgp_zebra_initiate_radv(bgp
, peer
);
4440 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4441 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4443 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4445 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4447 /* v6only flag changed. Reset bgp seesion */
4448 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4449 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4450 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4451 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4453 bgp_session_reset(peer
);
4456 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4457 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4458 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4459 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4462 if (peer_group_name
) {
4463 group
= peer_group_lookup(bgp
, peer_group_name
);
4465 snprintf(errmsg
, errmsg_len
,
4466 "Configure the peer-group first\n");
4470 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4473 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
4476 DEFUN_YANG(neighbor_interface_config
,
4477 neighbor_interface_config_cmd
,
4478 "neighbor WORD interface [peer-group PGNAME]",
4480 "Interface name or neighbor tag\n"
4481 "Enable BGP on interface\n"
4482 "Member of the peer-group\n"
4483 "Peer-group name\n")
4486 int idx_peer_group_word
= 4;
4487 char base_xpath
[XPATH_MAXLEN
];
4489 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4490 argv
[idx_word
]->arg
, "");
4492 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4493 if (argc
> idx_peer_group_word
)
4494 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_MODIFY
,
4495 argv
[idx_peer_group_word
]->arg
);
4497 return nb_cli_apply_changes(vty
, base_xpath
);
4500 DEFUN_YANG(neighbor_interface_config_v6only
,
4501 neighbor_interface_config_v6only_cmd
,
4502 "neighbor WORD interface v6only [peer-group PGNAME]",
4504 "Interface name or neighbor tag\n"
4505 "Enable BGP on interface\n"
4506 "Enable BGP with v6 link-local only\n"
4507 "Member of the peer-group\n"
4508 "Peer-group name\n")
4511 int idx_peer_group_word
= 5;
4512 char base_xpath
[XPATH_MAXLEN
];
4514 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4515 argv
[idx_word
]->arg
, "");
4517 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4518 if (argc
> idx_peer_group_word
)
4519 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_MODIFY
,
4520 argv
[idx_peer_group_word
]->arg
);
4522 nb_cli_enqueue_change(vty
, "./v6only", NB_OP_MODIFY
, "true");
4524 return nb_cli_apply_changes(vty
, base_xpath
);
4529 neighbor_interface_config_remote_as
,
4530 neighbor_interface_config_remote_as_cmd
,
4531 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4533 "Interface name or neighbor tag\n"
4534 "Enable BGP on interface\n"
4535 "Specify a BGP neighbor\n" AS_STR
4536 "Internal BGP peer\n"
4537 "External BGP peer\n")
4540 int idx_remote_as
= 4;
4541 char base_xpath
[XPATH_MAXLEN
];
4542 const char *as_type_str
= "as-specified";
4544 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4545 argv
[idx_word
]->arg
, "");
4547 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4549 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4550 as_type_str
= "internal";
4551 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4552 as_type_str
= "external";
4554 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4555 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4557 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4558 NB_OP_MODIFY
, as_type_str
);
4560 return nb_cli_apply_changes(vty
, base_xpath
);
4564 neighbor_interface_v6only_config_remote_as
,
4565 neighbor_interface_v6only_config_remote_as_cmd
,
4566 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4568 "Interface name or neighbor tag\n"
4569 "Enable BGP with v6 link-local only\n"
4570 "Enable BGP on interface\n"
4571 "Specify a BGP neighbor\n" AS_STR
4572 "Internal BGP peer\n"
4573 "External BGP peer\n")
4576 int idx_remote_as
= 5;
4577 char base_xpath
[XPATH_MAXLEN
];
4578 const char *as_type_str
= "as-specified";
4580 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4581 argv
[idx_word
]->arg
, "");
4583 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4585 nb_cli_enqueue_change(vty
, "./v6only", NB_OP_MODIFY
, "true");
4587 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4588 as_type_str
= "internal";
4589 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4590 as_type_str
= "external";
4592 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4593 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4595 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4596 NB_OP_MODIFY
, as_type_str
);
4598 return nb_cli_apply_changes(vty
, base_xpath
);
4601 DEFUN_YANG(neighbor_peer_group
, neighbor_peer_group_cmd
,
4602 "neighbor WORD peer-group",
4604 "Interface name or neighbor tag\n"
4605 "Configure peer-group\n")
4607 char base_xpath
[XPATH_MAXLEN
];
4610 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4611 argv
[idx_word
]->arg
, "");
4613 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4615 return nb_cli_apply_changes(vty
, base_xpath
);
4618 DEFUN_YANG(no_neighbor
,
4620 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4623 "Specify a BGP neighbor\n" AS_STR
4624 "Internal BGP peer\n"
4625 "External BGP peer\n")
4628 char base_xpath
[XPATH_MAXLEN
];
4629 char num_xpath
[XPATH_MAXLEN
];
4630 char unnbr_xpath
[XPATH_MAXLEN
];
4631 char prgrp_xpath
[XPATH_MAXLEN
];
4634 if (str2sockunion(argv
[idx_peer
]->arg
, &su
) == 0) {
4635 snprintf(num_xpath
, sizeof(num_xpath
),
4636 FRR_BGP_NEIGHBOR_NUM_XPATH
, argv
[idx_peer
]->arg
, "");
4637 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4638 VTY_CURR_XPATH
, num_xpath
+ 1)) {
4639 strlcpy(base_xpath
, num_xpath
, sizeof(base_xpath
));
4642 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
4643 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, argv
[idx_peer
]->arg
, "");
4645 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
4646 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
, "");
4648 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4649 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4650 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4651 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
,
4652 "%s%s", VTY_CURR_XPATH
,
4654 strlcpy(base_xpath
, prgrp_xpath
, sizeof(base_xpath
));
4657 "%% Create the peer-group or interface first\n");
4658 return CMD_WARNING_CONFIG_FAILED
;
4662 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_DESTROY
, NULL
);
4664 return nb_cli_apply_changes(vty
, NULL
);
4667 DEFUN_YANG(no_neighbor_interface_config
,
4668 no_neighbor_interface_config_cmd
,
4669 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4672 "Configure BGP on interface\n"
4673 "Enable BGP with v6 link-local only\n"
4674 "Member of the peer-group\n"
4676 "Specify a BGP neighbor\n" AS_STR
4677 "Internal BGP peer\n"
4678 "External BGP peer\n")
4681 char base_xpath
[XPATH_MAXLEN
];
4683 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4684 argv
[idx_word
]->arg
, "");
4686 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
4688 return nb_cli_apply_changes(vty
, base_xpath
);
4691 DEFUN_YANG(no_neighbor_peer_group
,
4692 no_neighbor_peer_group_cmd
,
4693 "no neighbor WORD peer-group",
4696 "Configure peer-group\n")
4698 char base_xpath
[XPATH_MAXLEN
];
4701 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4702 argv
[idx_word
]->arg
, "");
4704 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
4706 return nb_cli_apply_changes(vty
, base_xpath
);
4709 DEFUN_YANG(no_neighbor_interface_peer_group_remote_as
,
4710 no_neighbor_interface_peer_group_remote_as_cmd
,
4711 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4713 "Interface name or neighbor tag\n"
4714 "Specify a BGP neighbor\n" AS_STR
4715 "Internal BGP peer\n"
4716 "External BGP peer\n")
4719 char base_xpath
[XPATH_MAXLEN
];
4720 char unnbr_xpath
[XPATH_MAXLEN
];
4721 char prgrp_xpath
[XPATH_MAXLEN
];
4723 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4724 argv
[idx_peer
]->arg
, "");
4726 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4727 argv
[idx_peer
]->arg
, "");
4729 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4730 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4731 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4732 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4733 VTY_CURR_XPATH
, prgrp_xpath
+ 1)) {
4734 strlcpy(base_xpath
, prgrp_xpath
, sizeof(base_xpath
));
4736 vty_out(vty
, "%% Create the peer-group or interface first\n");
4737 return CMD_WARNING_CONFIG_FAILED
;
4740 strlcat(base_xpath
, "/neighbor-remote-as/remote-as-type",
4741 sizeof(base_xpath
));
4743 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_DESTROY
, NULL
);
4745 return nb_cli_apply_changes(vty
, NULL
);
4748 DEFUN_YANG(neighbor_local_as
,
4749 neighbor_local_as_cmd
,
4750 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4751 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4752 "Specify a local-as number\n"
4753 "AS number used as local AS\n")
4757 char base_xpath
[XPATH_MAXLEN
];
4759 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4760 sizeof(base_xpath
), NULL
)
4762 return CMD_WARNING_CONFIG_FAILED
;
4764 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4765 argv
[idx_number
]->arg
);
4767 return nb_cli_apply_changes(vty
, base_xpath
);
4771 neighbor_local_as_no_prepend
, neighbor_local_as_no_prepend_cmd
,
4772 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4773 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4774 "Specify a local-as number\n"
4775 "AS number used as local AS\n"
4776 "Do not prepend local-as to updates from ebgp peers\n")
4780 char base_xpath
[XPATH_MAXLEN
];
4782 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4783 sizeof(base_xpath
), NULL
)
4785 return CMD_WARNING_CONFIG_FAILED
;
4787 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4788 argv
[idx_number
]->arg
);
4789 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4792 return nb_cli_apply_changes(vty
, base_xpath
);
4796 neighbor_local_as_no_prepend_replace_as
,
4797 neighbor_local_as_no_prepend_replace_as_cmd
,
4798 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4799 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4800 "Specify a local-as number\n"
4801 "AS number used as local AS\n"
4802 "Do not prepend local-as to updates from ebgp peers\n"
4803 "Do not prepend local-as to updates from ibgp peers\n")
4807 char base_xpath
[XPATH_MAXLEN
];
4809 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4810 sizeof(base_xpath
), NULL
)
4812 return CMD_WARNING_CONFIG_FAILED
;
4814 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4815 argv
[idx_number
]->arg
);
4816 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4818 nb_cli_enqueue_change(vty
, "./local-as/no-replace-as", NB_OP_MODIFY
,
4821 return nb_cli_apply_changes(vty
, base_xpath
);
4824 DEFUN_YANG(no_neighbor_local_as
,
4825 no_neighbor_local_as_cmd
,
4826 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4827 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4828 "Specify a local-as number\n"
4829 "AS number used as local AS\n"
4830 "Do not prepend local-as to updates from ebgp peers\n"
4831 "Do not prepend local-as to updates from ibgp peers\n")
4834 char base_xpath
[XPATH_MAXLEN
];
4836 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4837 sizeof(base_xpath
), NULL
)
4839 return CMD_WARNING_CONFIG_FAILED
;
4841 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_DESTROY
, NULL
);
4842 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4844 nb_cli_enqueue_change(vty
, "./local-as/no-replace-as", NB_OP_MODIFY
,
4847 return nb_cli_apply_changes(vty
, base_xpath
);
4851 DEFUN (neighbor_solo
,
4853 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4856 "Solo peer - part of its own update group\n")
4862 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4864 return CMD_WARNING_CONFIG_FAILED
;
4866 ret
= update_group_adjust_soloness(peer
, 1);
4867 return bgp_vty_return(vty
, ret
);
4870 DEFUN (no_neighbor_solo
,
4871 no_neighbor_solo_cmd
,
4872 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4876 "Solo peer - part of its own update group\n")
4882 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4884 return CMD_WARNING_CONFIG_FAILED
;
4886 ret
= update_group_adjust_soloness(peer
, 0);
4887 return bgp_vty_return(vty
, ret
);
4890 DEFUN_YANG(neighbor_password
,
4891 neighbor_password_cmd
,
4892 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
4893 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4899 char base_xpath
[XPATH_MAXLEN
];
4901 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4902 sizeof(base_xpath
), NULL
)
4904 return CMD_WARNING_CONFIG_FAILED
;
4906 nb_cli_enqueue_change(vty
, "./password", NB_OP_MODIFY
,
4907 argv
[idx_line
]->arg
);
4909 return nb_cli_apply_changes(vty
, base_xpath
);
4912 DEFUN_YANG(no_neighbor_password
,
4913 no_neighbor_password_cmd
,
4914 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
4915 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4920 char base_xpath
[XPATH_MAXLEN
];
4922 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4923 sizeof(base_xpath
), NULL
)
4925 return CMD_WARNING_CONFIG_FAILED
;
4927 nb_cli_enqueue_change(vty
, "./password", NB_OP_DESTROY
, NULL
);
4929 return nb_cli_apply_changes(vty
, base_xpath
);
4932 DEFUN_YANG(neighbor_activate
,
4933 neighbor_activate_cmd
,
4934 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4935 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4936 "Enable the Address Family for this Neighbor\n")
4939 char base_xpath
[XPATH_MAXLEN
];
4940 char af_xpath
[XPATH_MAXLEN
];
4941 afi_t afi
= bgp_node_afi(vty
);
4942 safi_t safi
= bgp_node_safi(vty
);
4944 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
4945 yang_afi_safi_value2identity(afi
, safi
));
4946 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4947 sizeof(base_xpath
), af_xpath
)
4949 return CMD_WARNING_CONFIG_FAILED
;
4951 nb_cli_enqueue_change(vty
, "./enabled", NB_OP_MODIFY
, "true");
4953 return nb_cli_apply_changes(vty
, base_xpath
);
4956 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
4957 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4958 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4959 "Enable the Address Family for this Neighbor\n")
4961 DEFUN_YANG(no_neighbor_activate
,
4962 no_neighbor_activate_cmd
,
4963 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4966 "Enable the Address Family for this Neighbor\n")
4969 char base_xpath
[XPATH_MAXLEN
];
4970 char af_xpath
[XPATH_MAXLEN
];
4971 afi_t afi
= bgp_node_afi(vty
);
4972 safi_t safi
= bgp_node_safi(vty
);
4974 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
4975 yang_afi_safi_value2identity(afi
, safi
));
4977 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4978 sizeof(base_xpath
), af_xpath
)
4980 return CMD_WARNING_CONFIG_FAILED
;
4982 nb_cli_enqueue_change(vty
, "./enabled", NB_OP_MODIFY
, "false");
4984 return nb_cli_apply_changes(vty
, base_xpath
);
4987 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
4988 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4989 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4990 "Enable the Address Family for this Neighbor\n")
4992 DEFUN (neighbor_set_peer_group
,
4993 neighbor_set_peer_group_cmd
,
4994 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4997 "Member of the peer-group\n"
4998 "Peer-group name\n")
5000 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
5007 struct peer_group
*group
;
5009 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
5011 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
5013 vty_out(vty
, "%% Malformed address or name: %s\n",
5014 argv
[idx_peer
]->arg
);
5015 return CMD_WARNING_CONFIG_FAILED
;
5018 if (peer_address_self_check(bgp
, &su
)) {
5020 "%% Can not configure the local system as neighbor\n");
5021 return CMD_WARNING_CONFIG_FAILED
;
5024 /* Disallow for dynamic neighbor. */
5025 peer
= peer_lookup(bgp
, &su
);
5026 if (peer
&& peer_dynamic_neighbor(peer
)) {
5028 "%% Operation not allowed on a dynamic neighbor\n");
5029 return CMD_WARNING_CONFIG_FAILED
;
5033 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5035 vty_out(vty
, "%% Configure the peer-group first\n");
5036 return CMD_WARNING_CONFIG_FAILED
;
5039 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5041 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
5043 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
5045 return CMD_WARNING_CONFIG_FAILED
;
5048 return bgp_vty_return(vty
, ret
);
5051 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5052 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5053 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5054 "Member of the peer-group\n"
5055 "Peer-group name\n")
5057 DEFUN_YANG (no_neighbor_set_peer_group
,
5058 no_neighbor_set_peer_group_cmd
,
5059 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group [PGNAME]",
5063 "Member of the peer-group\n"
5064 "Peer-group name\n")
5067 char base_xpath
[XPATH_MAXLEN
];
5069 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5070 sizeof(base_xpath
), NULL
)
5072 return CMD_WARNING_CONFIG_FAILED
;
5074 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_DESTROY
, NULL
);
5076 return nb_cli_apply_changes(vty
, base_xpath
);
5079 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5080 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group [PGNAME]",
5081 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5082 "Member of the peer-group\n"
5083 "Peer-group name\n")
5085 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
5086 uint32_t flag
, int set
)
5091 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5093 return CMD_WARNING_CONFIG_FAILED
;
5096 * If 'neighbor <interface>', then this is for directly connected peers,
5097 * we should not accept disable-connected-check.
5099 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5101 "%s is directly connected peer, cannot accept disable-connected-check\n",
5103 return CMD_WARNING_CONFIG_FAILED
;
5106 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5107 peer_tx_shutdown_message_unset(peer
);
5110 ret
= peer_flag_set(peer
, flag
);
5112 ret
= peer_flag_unset(peer
, flag
);
5114 return bgp_vty_return(vty
, ret
);
5117 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
5119 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
5122 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
5125 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
5128 int peer_flag_modify_nb(struct bgp
*bgp
, const char *ip_str
, struct peer
*peer
,
5129 uint32_t flag
, bool set
, char *errmsg
,
5135 * If 'neighbor <interface>', then this is for directly connected peers,
5136 * we should not accept disable-connected-check.
5138 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5141 "%s is directly connected peer, cannot accept disable-connected-check\n",
5146 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5147 peer_tx_shutdown_message_unset(peer
);
5150 ret
= peer_flag_set(peer
, flag
);
5152 ret
= peer_flag_unset(peer
, flag
);
5154 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
5157 /* neighbor passive. */
5158 DEFUN_YANG(neighbor_passive
,
5159 neighbor_passive_cmd
,
5160 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5163 "Don't send open messages to this neighbor\n")
5166 char base_xpath
[XPATH_MAXLEN
];
5168 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5169 sizeof(base_xpath
), NULL
)
5171 return CMD_WARNING_CONFIG_FAILED
;
5173 nb_cli_enqueue_change(vty
, "./passive-mode", NB_OP_MODIFY
, "true");
5175 return nb_cli_apply_changes(vty
, base_xpath
);
5178 DEFUN_YANG(no_neighbor_passive
,
5179 no_neighbor_passive_cmd
,
5180 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5183 "Don't send open messages to this neighbor\n")
5186 char base_xpath
[XPATH_MAXLEN
];
5188 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5189 sizeof(base_xpath
), NULL
)
5191 return CMD_WARNING_CONFIG_FAILED
;
5193 nb_cli_enqueue_change(vty
, "./passive-mode", NB_OP_MODIFY
, "false");
5195 return nb_cli_apply_changes(vty
, base_xpath
);
5198 /* neighbor shutdown. */
5199 DEFUN_YANG(neighbor_shutdown_msg
,
5200 neighbor_shutdown_msg_cmd
,
5201 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5202 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5203 "Administratively shut down this neighbor\n"
5204 "Add a shutdown message (RFC 8203)\n"
5205 "Shutdown message\n")
5208 char base_xpath
[XPATH_MAXLEN
];
5210 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5211 sizeof(base_xpath
), NULL
)
5213 return CMD_WARNING_CONFIG_FAILED
;
5218 message
= argv_concat(argv
, argc
, 4);
5219 nb_cli_enqueue_change(vty
, "./admin-shutdown/message",
5220 NB_OP_MODIFY
, message
);
5223 nb_cli_enqueue_change(vty
, "./admin-shutdown/enable", NB_OP_MODIFY
,
5226 return nb_cli_apply_changes(vty
, base_xpath
);
5229 ALIAS_YANG(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5230 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5231 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5232 "Administratively shut down this neighbor\n")
5234 DEFUN_YANG(no_neighbor_shutdown_msg
,
5235 no_neighbor_shutdown_msg_cmd
,
5236 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5239 "Administratively shut down this neighbor\n"
5240 "Remove a shutdown message (RFC 8203)\n"
5241 "Shutdown message\n")
5244 char base_xpath
[XPATH_MAXLEN
];
5246 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5247 sizeof(base_xpath
), NULL
)
5249 return CMD_WARNING_CONFIG_FAILED
;
5251 nb_cli_enqueue_change(vty
, "./admin-shutdown/enable", NB_OP_MODIFY
,
5254 return nb_cli_apply_changes(vty
, base_xpath
);
5257 ALIAS_YANG(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5258 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5259 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5260 "Administratively shut down this neighbor\n")
5262 DEFUN(neighbor_shutdown_rtt
,
5263 neighbor_shutdown_rtt_cmd
,
5264 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5267 "Administratively shut down this neighbor\n"
5268 "Shutdown if round-trip-time is higher than expected\n"
5269 "Round-trip-time in milliseconds\n"
5270 "Specify the number of keepalives before shutdown\n"
5271 "The number of keepalives with higher RTT to shutdown\n")
5278 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5281 return CMD_WARNING_CONFIG_FAILED
;
5283 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5285 if (argv_find(argv
, argc
, "count", &idx_count
))
5286 peer
->rtt_keepalive_conf
=
5287 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5289 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5290 PEER_FLAG_RTT_SHUTDOWN
);
5293 DEFUN(no_neighbor_shutdown_rtt
,
5294 no_neighbor_shutdown_rtt_cmd
,
5295 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5299 "Administratively shut down this neighbor\n"
5300 "Shutdown if round-trip-time is higher than expected\n"
5301 "Round-trip-time in milliseconds\n"
5302 "Specify the number of keepalives before shutdown\n"
5303 "The number of keepalives with higher RTT to shutdown\n")
5308 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5311 return CMD_WARNING_CONFIG_FAILED
;
5313 peer
->rtt_expected
= 0;
5314 peer
->rtt_keepalive_conf
= 1;
5316 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5317 PEER_FLAG_RTT_SHUTDOWN
);
5320 /* neighbor capability dynamic. */
5321 DEFUN_YANG (neighbor_capability_dynamic
,
5322 neighbor_capability_dynamic_cmd
,
5323 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5326 "Advertise capability to the peer\n"
5327 "Advertise dynamic capability to this neighbor\n")
5330 char base_xpath
[XPATH_MAXLEN
];
5332 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5333 sizeof(base_xpath
), NULL
)
5335 return CMD_WARNING_CONFIG_FAILED
;
5337 nb_cli_enqueue_change(vty
, "./capability-options/dynamic-capability",
5338 NB_OP_MODIFY
, "true");
5340 return nb_cli_apply_changes(vty
, base_xpath
);
5343 DEFUN_YANG (no_neighbor_capability_dynamic
,
5344 no_neighbor_capability_dynamic_cmd
,
5345 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5349 "Advertise capability to the peer\n"
5350 "Advertise dynamic capability to this neighbor\n")
5353 char base_xpath
[XPATH_MAXLEN
];
5355 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5356 sizeof(base_xpath
), NULL
)
5358 return CMD_WARNING_CONFIG_FAILED
;
5360 nb_cli_enqueue_change(vty
, "./capability-options/dynamic-capability",
5361 NB_OP_MODIFY
, "false");
5363 return nb_cli_apply_changes(vty
, base_xpath
);
5366 /* neighbor dont-capability-negotiate */
5367 DEFUN (neighbor_dont_capability_negotiate
,
5368 neighbor_dont_capability_negotiate_cmd
,
5369 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5372 "Do not perform capability negotiation\n")
5375 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5376 PEER_FLAG_DONT_CAPABILITY
);
5379 DEFUN (no_neighbor_dont_capability_negotiate
,
5380 no_neighbor_dont_capability_negotiate_cmd
,
5381 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5385 "Do not perform capability negotiation\n")
5388 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5389 PEER_FLAG_DONT_CAPABILITY
);
5392 /* neighbor capability extended next hop encoding */
5393 DEFUN_YANG (neighbor_capability_enhe
,
5394 neighbor_capability_enhe_cmd
,
5395 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5398 "Advertise capability to the peer\n"
5399 "Advertise extended next-hop capability to the peer\n")
5402 char base_xpath
[XPATH_MAXLEN
];
5404 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5405 sizeof(base_xpath
), NULL
)
5407 return CMD_WARNING_CONFIG_FAILED
;
5409 nb_cli_enqueue_change(
5410 vty
, "./capability-options/extended-nexthop-capability",
5411 NB_OP_MODIFY
, "true");
5413 return nb_cli_apply_changes(vty
, base_xpath
);
5416 DEFUN_YANG (no_neighbor_capability_enhe
,
5417 no_neighbor_capability_enhe_cmd
,
5418 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5422 "Advertise capability to the peer\n"
5423 "Advertise extended next-hop capability to the peer\n")
5426 char base_xpath
[XPATH_MAXLEN
];
5428 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5429 sizeof(base_xpath
), NULL
)
5431 return CMD_WARNING_CONFIG_FAILED
;
5433 nb_cli_enqueue_change(
5434 vty
, "./capability-options/extended-nexthop-capability",
5435 NB_OP_MODIFY
, "false");
5437 return nb_cli_apply_changes(vty
, base_xpath
);
5440 int peer_af_flag_modify_nb(struct peer
*peer
, afi_t afi
, safi_t safi
,
5441 uint32_t flag
, int set
, char *errmsg
,
5447 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5449 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5451 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
5454 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5455 afi_t afi
, safi_t safi
, uint32_t flag
,
5461 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5463 return CMD_WARNING_CONFIG_FAILED
;
5466 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5468 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5470 return bgp_vty_return(vty
, ret
);
5473 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5474 afi_t afi
, safi_t safi
, uint32_t flag
)
5476 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5479 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5480 afi_t afi
, safi_t safi
, uint32_t flag
)
5482 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5485 /* neighbor capability orf prefix-list. */
5486 DEFUN (neighbor_capability_orf_prefix
,
5487 neighbor_capability_orf_prefix_cmd
,
5488 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5491 "Advertise capability to the peer\n"
5492 "Advertise ORF capability to the peer\n"
5493 "Advertise prefixlist ORF capability to this neighbor\n"
5494 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5495 "Capability to RECEIVE the ORF from this neighbor\n"
5496 "Capability to SEND the ORF to this neighbor\n")
5498 int idx_send_recv
= 5;
5499 char *peer_str
= argv
[1]->arg
;
5501 afi_t afi
= bgp_node_afi(vty
);
5502 safi_t safi
= bgp_node_safi(vty
);
5504 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5506 return CMD_WARNING_CONFIG_FAILED
;
5508 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5509 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5510 PEER_FLAG_ORF_PREFIX_SM
);
5512 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5513 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5514 PEER_FLAG_ORF_PREFIX_RM
);
5516 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5517 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5518 PEER_FLAG_ORF_PREFIX_SM
)
5519 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5520 PEER_FLAG_ORF_PREFIX_RM
);
5522 return CMD_WARNING_CONFIG_FAILED
;
5526 neighbor_capability_orf_prefix
,
5527 neighbor_capability_orf_prefix_hidden_cmd
,
5528 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5529 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5530 "Advertise capability to the peer\n"
5531 "Advertise ORF capability to the peer\n"
5532 "Advertise prefixlist ORF capability to this neighbor\n"
5533 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5534 "Capability to RECEIVE the ORF from this neighbor\n"
5535 "Capability to SEND the ORF to this neighbor\n")
5537 DEFUN (no_neighbor_capability_orf_prefix
,
5538 no_neighbor_capability_orf_prefix_cmd
,
5539 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5543 "Advertise capability to the peer\n"
5544 "Advertise ORF capability to the peer\n"
5545 "Advertise prefixlist ORF capability to this neighbor\n"
5546 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5547 "Capability to RECEIVE the ORF from this neighbor\n"
5548 "Capability to SEND the ORF to this neighbor\n")
5550 int idx_send_recv
= 6;
5551 char *peer_str
= argv
[2]->arg
;
5553 afi_t afi
= bgp_node_afi(vty
);
5554 safi_t safi
= bgp_node_safi(vty
);
5556 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5558 return CMD_WARNING_CONFIG_FAILED
;
5560 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5561 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5562 PEER_FLAG_ORF_PREFIX_SM
);
5564 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5565 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5566 PEER_FLAG_ORF_PREFIX_RM
);
5568 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5569 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5570 PEER_FLAG_ORF_PREFIX_SM
)
5571 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5572 PEER_FLAG_ORF_PREFIX_RM
);
5574 return CMD_WARNING_CONFIG_FAILED
;
5578 no_neighbor_capability_orf_prefix
,
5579 no_neighbor_capability_orf_prefix_hidden_cmd
,
5580 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5581 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5582 "Advertise capability to the peer\n"
5583 "Advertise ORF capability to the peer\n"
5584 "Advertise prefixlist ORF capability to this neighbor\n"
5585 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5586 "Capability to RECEIVE the ORF from this neighbor\n"
5587 "Capability to SEND the ORF to this neighbor\n")
5589 /* neighbor next-hop-self. */
5590 DEFUN_YANG (neighbor_nexthop_self
,
5591 neighbor_nexthop_self_cmd
,
5592 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5595 "Disable the next hop calculation for this neighbor\n")
5598 char base_xpath
[XPATH_MAXLEN
];
5599 char af_xpath
[XPATH_MAXLEN
];
5600 char attr_xpath
[XPATH_MAXLEN
];
5601 afi_t afi
= bgp_node_afi(vty
);
5602 safi_t safi
= bgp_node_safi(vty
);
5604 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5605 yang_afi_safi_value2identity(afi
, safi
));
5607 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5608 sizeof(base_xpath
), af_xpath
)
5610 return CMD_WARNING_CONFIG_FAILED
;
5612 snprintf(attr_xpath
, sizeof(attr_xpath
),
5613 "./%s/nexthop-self/next-hop-self",
5614 bgp_afi_safi_get_container_str(afi
, safi
));
5616 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5618 return nb_cli_apply_changes(vty
, base_xpath
);
5621 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5622 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5623 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5624 "Disable the next hop calculation for this neighbor\n")
5626 /* neighbor next-hop-self. */
5627 DEFUN_YANG(neighbor_nexthop_self_force
,
5628 neighbor_nexthop_self_force_cmd
,
5629 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5632 "Disable the next hop calculation for this neighbor\n"
5633 "Set the next hop to self for reflected routes\n")
5636 char base_xpath
[XPATH_MAXLEN
];
5637 char af_xpath
[XPATH_MAXLEN
];
5638 char attr_xpath
[XPATH_MAXLEN
];
5639 afi_t afi
= bgp_node_afi(vty
);
5640 safi_t safi
= bgp_node_safi(vty
);
5642 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5643 yang_afi_safi_value2identity(afi
, safi
));
5645 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5646 sizeof(base_xpath
), af_xpath
)
5648 return CMD_WARNING_CONFIG_FAILED
;
5650 snprintf(attr_xpath
, sizeof(attr_xpath
),
5651 "./%s/nexthop-self/next-hop-self-force",
5652 bgp_afi_safi_get_container_str(afi
, safi
));
5654 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5656 return nb_cli_apply_changes(vty
, base_xpath
);
5659 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5660 neighbor_nexthop_self_force_hidden_cmd
,
5661 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5662 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5663 "Disable the next hop calculation for this neighbor\n"
5664 "Set the next hop to self for reflected routes\n")
5666 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5667 neighbor_nexthop_self_all_hidden_cmd
,
5668 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5669 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5670 "Disable the next hop calculation for this neighbor\n"
5671 "Set the next hop to self for reflected routes\n")
5673 DEFUN_YANG (no_neighbor_nexthop_self
,
5674 no_neighbor_nexthop_self_cmd
,
5675 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5679 "Disable the next hop calculation for this neighbor\n")
5682 char base_xpath
[XPATH_MAXLEN
];
5683 char af_xpath
[XPATH_MAXLEN
];
5684 char attr_xpath
[XPATH_MAXLEN
];
5685 afi_t afi
= bgp_node_afi(vty
);
5686 safi_t safi
= bgp_node_safi(vty
);
5688 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5689 yang_afi_safi_value2identity(afi
, safi
));
5691 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5692 sizeof(base_xpath
), af_xpath
)
5694 return CMD_WARNING_CONFIG_FAILED
;
5696 snprintf(attr_xpath
, sizeof(attr_xpath
),
5697 "./%s/nexthop-self/next-hop-self",
5698 bgp_afi_safi_get_container_str(afi
, safi
));
5700 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5702 return nb_cli_apply_changes(vty
, base_xpath
);
5705 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5706 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5707 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5708 "Disable the next hop calculation for this neighbor\n")
5710 DEFUN_YANG (no_neighbor_nexthop_self_force
,
5711 no_neighbor_nexthop_self_force_cmd
,
5712 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5716 "Disable the next hop calculation for this neighbor\n"
5717 "Set the next hop to self for reflected routes\n")
5720 char base_xpath
[XPATH_MAXLEN
];
5721 char af_xpath
[XPATH_MAXLEN
];
5722 char attr_xpath
[XPATH_MAXLEN
];
5723 afi_t afi
= bgp_node_afi(vty
);
5724 safi_t safi
= bgp_node_safi(vty
);
5726 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5727 yang_afi_safi_value2identity(afi
, safi
));
5729 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5730 sizeof(base_xpath
), af_xpath
)
5732 return CMD_WARNING_CONFIG_FAILED
;
5734 snprintf(attr_xpath
, sizeof(attr_xpath
),
5735 "./%s/nexthop-self/next-hop-self-force",
5736 bgp_afi_safi_get_container_str(afi
, safi
));
5738 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5740 return nb_cli_apply_changes(vty
, base_xpath
);
5743 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5744 no_neighbor_nexthop_self_force_hidden_cmd
,
5745 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5746 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5747 "Disable the next hop calculation for this neighbor\n"
5748 "Set the next hop to self for reflected routes\n")
5750 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5751 no_neighbor_nexthop_self_all_hidden_cmd
,
5752 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5753 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5754 "Disable the next hop calculation for this neighbor\n"
5755 "Set the next hop to self for reflected routes\n")
5757 /* neighbor as-override */
5758 DEFUN_YANG (neighbor_as_override
,
5759 neighbor_as_override_cmd
,
5760 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5763 "Override ASNs in outbound updates if aspath equals remote-as\n")
5766 char base_xpath
[XPATH_MAXLEN
];
5767 char af_xpath
[XPATH_MAXLEN
];
5768 char attr_xpath
[XPATH_MAXLEN
];
5769 afi_t afi
= bgp_node_afi(vty
);
5770 safi_t safi
= bgp_node_safi(vty
);
5772 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5773 yang_afi_safi_value2identity(afi
, safi
));
5775 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5776 sizeof(base_xpath
), af_xpath
)
5778 return CMD_WARNING_CONFIG_FAILED
;
5780 snprintf(attr_xpath
, sizeof(attr_xpath
),
5781 "./%s/as-path-options/replace-peer-as",
5782 bgp_afi_safi_get_container_str(afi
, safi
));
5784 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5786 return nb_cli_apply_changes(vty
, base_xpath
);
5789 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5790 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5791 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5792 "Override ASNs in outbound updates if aspath equals remote-as\n")
5794 DEFUN_YANG (no_neighbor_as_override
,
5795 no_neighbor_as_override_cmd
,
5796 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5800 "Override ASNs in outbound updates if aspath equals remote-as\n")
5803 char base_xpath
[XPATH_MAXLEN
];
5804 char af_xpath
[XPATH_MAXLEN
];
5805 char attr_xpath
[XPATH_MAXLEN
];
5806 afi_t afi
= bgp_node_afi(vty
);
5807 safi_t safi
= bgp_node_safi(vty
);
5809 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5810 yang_afi_safi_value2identity(afi
, safi
));
5812 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5813 sizeof(base_xpath
), af_xpath
)
5815 return CMD_WARNING_CONFIG_FAILED
;
5817 snprintf(attr_xpath
, sizeof(attr_xpath
),
5818 "./%s/as-path-options/replace-peer-as",
5819 bgp_afi_safi_get_container_str(afi
, safi
));
5821 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5823 return nb_cli_apply_changes(vty
, base_xpath
);
5826 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5827 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5828 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5829 "Override ASNs in outbound updates if aspath equals remote-as\n")
5831 /* neighbor remove-private-AS. */
5832 DEFUN_YANG (neighbor_remove_private_as
,
5833 neighbor_remove_private_as_cmd
,
5834 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5837 "Remove private ASNs in outbound updates\n")
5840 char base_xpath
[XPATH_MAXLEN
];
5841 char af_xpath
[XPATH_MAXLEN
];
5842 char attr_xpath
[XPATH_MAXLEN
];
5843 afi_t afi
= bgp_node_afi(vty
);
5844 safi_t safi
= bgp_node_safi(vty
);
5846 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5847 yang_afi_safi_value2identity(afi
, safi
));
5849 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5850 sizeof(base_xpath
), af_xpath
)
5852 return CMD_WARNING_CONFIG_FAILED
;
5854 snprintf(attr_xpath
, sizeof(attr_xpath
),
5855 "./%s/private-as/remove-private-as",
5856 bgp_afi_safi_get_container_str(afi
, safi
));
5858 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5860 return nb_cli_apply_changes(vty
, base_xpath
);
5863 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5864 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5865 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5866 "Remove private ASNs in outbound updates\n")
5868 DEFUN_YANG (neighbor_remove_private_as_all
,
5869 neighbor_remove_private_as_all_cmd
,
5870 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5873 "Remove private ASNs in outbound updates\n"
5874 "Apply to all AS numbers\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-all",
5893 bgp_afi_safi_get_container_str(afi
, safi
));
5895 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5897 return nb_cli_apply_changes(vty
, base_xpath
);
5900 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5901 neighbor_remove_private_as_all_hidden_cmd
,
5902 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5903 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5904 "Remove private ASNs in outbound updates\n"
5905 "Apply to all AS numbers")
5907 DEFUN_YANG (neighbor_remove_private_as_replace_as
,
5908 neighbor_remove_private_as_replace_as_cmd
,
5909 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5912 "Remove private ASNs in outbound updates\n"
5913 "Replace private ASNs with our ASN in outbound updates\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
);
5922 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5923 yang_afi_safi_value2identity(afi
, safi
));
5925 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5926 sizeof(base_xpath
), af_xpath
)
5928 return CMD_WARNING_CONFIG_FAILED
;
5930 snprintf(attr_xpath
, sizeof(attr_xpath
),
5931 "./%s/private-as/remove-private-as-replace",
5932 bgp_afi_safi_get_container_str(afi
, safi
));
5934 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5936 return nb_cli_apply_changes(vty
, base_xpath
);
5939 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5940 neighbor_remove_private_as_replace_as_hidden_cmd
,
5941 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5942 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5943 "Remove private ASNs in outbound updates\n"
5944 "Replace private ASNs with our ASN in outbound updates\n")
5946 DEFUN_YANG (neighbor_remove_private_as_all_replace_as
,
5947 neighbor_remove_private_as_all_replace_as_cmd
,
5948 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5951 "Remove private ASNs in outbound updates\n"
5952 "Apply to all AS numbers\n"
5953 "Replace private ASNs with our ASN in outbound updates\n")
5956 char base_xpath
[XPATH_MAXLEN
];
5957 char af_xpath
[XPATH_MAXLEN
];
5958 char attr_xpath
[XPATH_MAXLEN
];
5959 afi_t afi
= bgp_node_afi(vty
);
5960 safi_t safi
= bgp_node_safi(vty
);
5962 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5963 yang_afi_safi_value2identity(afi
, safi
));
5965 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5966 sizeof(base_xpath
), af_xpath
)
5968 return CMD_WARNING_CONFIG_FAILED
;
5970 snprintf(attr_xpath
, sizeof(attr_xpath
),
5971 "./%s/private-as/remove-private-as-all-replace",
5972 bgp_afi_safi_get_container_str(afi
, safi
));
5974 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5976 return nb_cli_apply_changes(vty
, base_xpath
);
5980 neighbor_remove_private_as_all_replace_as
,
5981 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5982 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5983 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5984 "Remove private ASNs in outbound updates\n"
5985 "Apply to all AS numbers\n"
5986 "Replace private ASNs with our ASN in outbound updates\n")
5988 DEFUN_YANG (no_neighbor_remove_private_as
,
5989 no_neighbor_remove_private_as_cmd
,
5990 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5994 "Remove private ASNs in outbound updates\n")
5997 char base_xpath
[XPATH_MAXLEN
];
5998 char af_xpath
[XPATH_MAXLEN
];
5999 char attr_xpath
[XPATH_MAXLEN
];
6000 afi_t afi
= bgp_node_afi(vty
);
6001 safi_t safi
= bgp_node_safi(vty
);
6003 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6004 yang_afi_safi_value2identity(afi
, safi
));
6006 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6007 sizeof(base_xpath
), af_xpath
)
6009 return CMD_WARNING_CONFIG_FAILED
;
6011 snprintf(attr_xpath
, sizeof(attr_xpath
),
6012 "./%s/private-as/remove-private-as",
6013 bgp_afi_safi_get_container_str(afi
, safi
));
6015 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6017 return nb_cli_apply_changes(vty
, base_xpath
);
6020 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
6021 no_neighbor_remove_private_as_hidden_cmd
,
6022 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
6023 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6024 "Remove private ASNs in outbound updates\n")
6026 DEFUN_YANG (no_neighbor_remove_private_as_all
,
6027 no_neighbor_remove_private_as_all_cmd
,
6028 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
6032 "Remove private ASNs in outbound updates\n"
6033 "Apply to all AS numbers\n")
6036 char base_xpath
[XPATH_MAXLEN
];
6037 char af_xpath
[XPATH_MAXLEN
];
6038 char attr_xpath
[XPATH_MAXLEN
];
6039 afi_t afi
= bgp_node_afi(vty
);
6040 safi_t safi
= bgp_node_safi(vty
);
6042 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6043 yang_afi_safi_value2identity(afi
, safi
));
6045 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6046 sizeof(base_xpath
), af_xpath
)
6048 return CMD_WARNING_CONFIG_FAILED
;
6050 snprintf(attr_xpath
, sizeof(attr_xpath
),
6051 "./%s/private-as/remove-private-as-all",
6052 bgp_afi_safi_get_container_str(afi
, safi
));
6054 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6056 return nb_cli_apply_changes(vty
, base_xpath
);
6059 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
6060 no_neighbor_remove_private_as_all_hidden_cmd
,
6061 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
6062 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6063 "Remove private ASNs in outbound updates\n"
6064 "Apply to all AS numbers\n")
6066 DEFUN_YANG (no_neighbor_remove_private_as_replace_as
,
6067 no_neighbor_remove_private_as_replace_as_cmd
,
6068 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
6072 "Remove private ASNs in outbound updates\n"
6073 "Replace private ASNs with our ASN in outbound updates\n")
6076 char base_xpath
[XPATH_MAXLEN
];
6077 char af_xpath
[XPATH_MAXLEN
];
6078 char attr_xpath
[XPATH_MAXLEN
];
6079 afi_t afi
= bgp_node_afi(vty
);
6080 safi_t safi
= bgp_node_safi(vty
);
6082 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6083 yang_afi_safi_value2identity(afi
, safi
));
6085 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6086 sizeof(base_xpath
), af_xpath
)
6088 return CMD_WARNING_CONFIG_FAILED
;
6090 snprintf(attr_xpath
, sizeof(attr_xpath
),
6091 "./%s/private-as/remove-private-as-replace",
6092 bgp_afi_safi_get_container_str(afi
, safi
));
6094 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6096 return nb_cli_apply_changes(vty
, base_xpath
);
6099 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
6100 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
6101 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
6102 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6103 "Remove private ASNs in outbound updates\n"
6104 "Replace private ASNs with our ASN in outbound updates\n")
6106 DEFUN_YANG (no_neighbor_remove_private_as_all_replace_as
,
6107 no_neighbor_remove_private_as_all_replace_as_cmd
,
6108 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6112 "Remove private ASNs in outbound updates\n"
6113 "Apply to all AS numbers\n"
6114 "Replace private ASNs with our ASN in outbound updates\n")
6117 char base_xpath
[XPATH_MAXLEN
];
6118 char af_xpath
[XPATH_MAXLEN
];
6119 char attr_xpath
[XPATH_MAXLEN
];
6120 afi_t afi
= bgp_node_afi(vty
);
6121 safi_t safi
= bgp_node_safi(vty
);
6123 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6124 yang_afi_safi_value2identity(afi
, safi
));
6126 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6127 sizeof(base_xpath
), af_xpath
)
6129 return CMD_WARNING_CONFIG_FAILED
;
6131 snprintf(attr_xpath
, sizeof(attr_xpath
),
6132 "./%s/private-as/remove-private-as-all-replace",
6133 bgp_afi_safi_get_container_str(afi
, safi
));
6135 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6137 return nb_cli_apply_changes(vty
, base_xpath
);
6141 no_neighbor_remove_private_as_all_replace_as
,
6142 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
6143 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6144 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6145 "Remove private ASNs in outbound updates\n"
6146 "Apply to all AS numbers\n"
6147 "Replace private ASNs with our ASN in outbound updates\n")
6150 /* neighbor send-community. */
6151 DEFUN_YANG (neighbor_send_community
,
6152 neighbor_send_community_cmd
,
6153 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6156 "Send Community attribute to this neighbor\n")
6159 char *peer_str
= argv
[idx_peer
]->arg
;
6160 char base_xpath
[XPATH_MAXLEN
];
6161 char af_xpath
[XPATH_MAXLEN
];
6162 char std_xpath
[XPATH_MAXLEN
];
6163 afi_t afi
= bgp_node_afi(vty
);
6164 safi_t safi
= bgp_node_safi(vty
);
6166 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6167 yang_afi_safi_value2identity(afi
, safi
));
6169 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6170 sizeof(base_xpath
), af_xpath
)
6172 return CMD_WARNING_CONFIG_FAILED
;
6174 snprintf(std_xpath
, sizeof(std_xpath
),
6175 "./%s/send-community/send-community",
6176 bgp_afi_safi_get_container_str(afi
, safi
));
6178 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6180 return nb_cli_apply_changes(vty
, base_xpath
);
6183 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
6184 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6185 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6186 "Send Community attribute to this neighbor\n")
6188 DEFUN_YANG (no_neighbor_send_community
,
6189 no_neighbor_send_community_cmd
,
6190 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6194 "Send Community attribute to this neighbor\n")
6197 char *peer_str
= argv
[idx_peer
]->arg
;
6198 char base_xpath
[XPATH_MAXLEN
];
6199 char af_xpath
[XPATH_MAXLEN
];
6200 char std_xpath
[XPATH_MAXLEN
];
6201 afi_t afi
= bgp_node_afi(vty
);
6202 safi_t safi
= bgp_node_safi(vty
);
6204 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6205 yang_afi_safi_value2identity(afi
, safi
));
6207 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6208 sizeof(base_xpath
), af_xpath
)
6210 return CMD_WARNING_CONFIG_FAILED
;
6212 snprintf(std_xpath
, sizeof(std_xpath
),
6213 "./%s/send-community/send-community",
6214 bgp_afi_safi_get_container_str(afi
, safi
));
6216 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6218 return nb_cli_apply_changes(vty
, base_xpath
);
6221 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
6222 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6223 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6224 "Send Community attribute to this neighbor\n")
6226 /* neighbor send-community extended. */
6227 DEFUN_YANG (neighbor_send_community_type
,
6228 neighbor_send_community_type_cmd
,
6229 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6232 "Send Community attribute to this neighbor\n"
6233 "Send Standard and Extended Community attributes\n"
6234 "Send Standard, Large and Extended Community attributes\n"
6235 "Send Extended Community attributes\n"
6236 "Send Standard Community attributes\n"
6237 "Send Large Community attributes\n")
6239 const char *type
= argv
[argc
- 1]->text
;
6240 char *peer_str
= argv
[1]->arg
;
6241 char base_xpath
[XPATH_MAXLEN
];
6242 char af_xpath
[XPATH_MAXLEN
];
6243 char std_xpath
[XPATH_MAXLEN
];
6244 char ext_xpath
[XPATH_MAXLEN
];
6245 char lrg_xpath
[XPATH_MAXLEN
];
6246 afi_t afi
= bgp_node_afi(vty
);
6247 safi_t safi
= bgp_node_safi(vty
);
6249 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6250 yang_afi_safi_value2identity(afi
, safi
));
6252 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6253 sizeof(base_xpath
), af_xpath
)
6255 return CMD_WARNING_CONFIG_FAILED
;
6257 if (strmatch(type
, "standard")) {
6258 snprintf(std_xpath
, sizeof(std_xpath
),
6259 "./%s/send-community/send-community",
6260 bgp_afi_safi_get_container_str(afi
, safi
));
6262 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6265 if (strmatch(type
, "extended")) {
6266 snprintf(ext_xpath
, sizeof(ext_xpath
),
6267 "./%s/send-community/send-ext-community",
6268 bgp_afi_safi_get_container_str(afi
, safi
));
6270 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6273 if (strmatch(type
, "large")) {
6274 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6275 "./%s/send-community/send-large-community",
6276 bgp_afi_safi_get_container_str(afi
, safi
));
6278 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "true");
6281 if (strmatch(type
, "both")) {
6282 snprintf(std_xpath
, sizeof(std_xpath
),
6283 "./%s/send-community/send-community",
6284 bgp_afi_safi_get_container_str(afi
, safi
));
6286 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6288 snprintf(ext_xpath
, sizeof(ext_xpath
),
6289 "./%s/send-community/send-ext-community",
6290 bgp_afi_safi_get_container_str(afi
, safi
));
6292 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6295 if (strmatch(type
, "all")) {
6296 snprintf(std_xpath
, sizeof(std_xpath
),
6297 "./%s/send-community/send-community",
6298 bgp_afi_safi_get_container_str(afi
, safi
));
6300 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6302 snprintf(ext_xpath
, sizeof(ext_xpath
),
6303 "./%s/send-community/send-ext-community",
6304 bgp_afi_safi_get_container_str(afi
, safi
));
6306 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6308 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6309 "./%s/send-community/send-large-community",
6310 bgp_afi_safi_get_container_str(afi
, safi
));
6312 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "true");
6315 return nb_cli_apply_changes(vty
, base_xpath
);
6319 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6320 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6321 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6322 "Send Community attribute to this neighbor\n"
6323 "Send Standard and Extended Community attributes\n"
6324 "Send Standard, Large and Extended Community attributes\n"
6325 "Send Extended Community attributes\n"
6326 "Send Standard Community attributes\n"
6327 "Send Large Community attributes\n")
6329 DEFUN_YANG (no_neighbor_send_community_type
,
6330 no_neighbor_send_community_type_cmd
,
6331 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6335 "Send Community attribute to this neighbor\n"
6336 "Send Standard and Extended Community attributes\n"
6337 "Send Standard, Large and Extended Community attributes\n"
6338 "Send Extended Community attributes\n"
6339 "Send Standard Community attributes\n"
6340 "Send Large Community attributes\n")
6342 const char *type
= argv
[argc
- 1]->text
;
6343 char *peer_str
= argv
[2]->arg
;
6344 char base_xpath
[XPATH_MAXLEN
];
6345 char af_xpath
[XPATH_MAXLEN
];
6346 char std_xpath
[XPATH_MAXLEN
];
6347 char ext_xpath
[XPATH_MAXLEN
];
6348 char lrg_xpath
[XPATH_MAXLEN
];
6349 afi_t afi
= bgp_node_afi(vty
);
6350 safi_t safi
= bgp_node_safi(vty
);
6352 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6353 yang_afi_safi_value2identity(afi
, safi
));
6355 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6356 sizeof(base_xpath
), af_xpath
)
6358 return CMD_WARNING_CONFIG_FAILED
;
6360 if (strmatch(type
, "standard")) {
6361 snprintf(std_xpath
, sizeof(std_xpath
),
6362 "./%s/send-community/send-community",
6363 bgp_afi_safi_get_container_str(afi
, safi
));
6365 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6368 if (strmatch(type
, "extended")) {
6369 snprintf(ext_xpath
, sizeof(ext_xpath
),
6370 "./%s/send-community/send-ext-community",
6371 bgp_afi_safi_get_container_str(afi
, safi
));
6373 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6376 if (strmatch(type
, "large")) {
6377 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6378 "./%s/send-community/send-large-community",
6379 bgp_afi_safi_get_container_str(afi
, safi
));
6381 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "false");
6384 if (strmatch(type
, "both")) {
6385 snprintf(std_xpath
, sizeof(std_xpath
),
6386 "./%s/send-community/send-community",
6387 bgp_afi_safi_get_container_str(afi
, safi
));
6389 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6391 snprintf(ext_xpath
, sizeof(ext_xpath
),
6392 "./%s/send-community/send-ext-community",
6393 bgp_afi_safi_get_container_str(afi
, safi
));
6395 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6398 if (strmatch(type
, "all")) {
6399 snprintf(std_xpath
, sizeof(std_xpath
),
6400 "./%s/send-community/send-community",
6401 bgp_afi_safi_get_container_str(afi
, safi
));
6403 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6405 snprintf(ext_xpath
, sizeof(ext_xpath
),
6406 "./%s/send-community/send-ext-community",
6407 bgp_afi_safi_get_container_str(afi
, safi
));
6409 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6411 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6412 "./%s/send-community/send-large-community",
6413 bgp_afi_safi_get_container_str(afi
, safi
));
6415 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "false");
6418 return nb_cli_apply_changes(vty
, base_xpath
);
6422 no_neighbor_send_community_type
,
6423 no_neighbor_send_community_type_hidden_cmd
,
6424 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6425 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6426 "Send Community attribute to this neighbor\n"
6427 "Send Standard and Extended Community attributes\n"
6428 "Send Standard, Large and Extended Community attributes\n"
6429 "Send Extended Community attributes\n"
6430 "Send Standard Community attributes\n"
6431 "Send Large Community attributes\n")
6433 /* neighbor soft-reconfig. */
6434 DEFUN_YANG (neighbor_soft_reconfiguration
,
6435 neighbor_soft_reconfiguration_cmd
,
6436 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6437 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6438 "Per neighbor soft reconfiguration\n"
6439 "Allow inbound soft reconfiguration for this neighbor\n")
6442 char base_xpath
[XPATH_MAXLEN
];
6443 char af_xpath
[XPATH_MAXLEN
];
6444 char soft_xpath
[XPATH_MAXLEN
];
6445 afi_t afi
= bgp_node_afi(vty
);
6446 safi_t safi
= bgp_node_safi(vty
);
6448 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6449 yang_afi_safi_value2identity(afi
, safi
));
6451 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6452 sizeof(base_xpath
), af_xpath
)
6454 return CMD_WARNING_CONFIG_FAILED
;
6456 snprintf(soft_xpath
, sizeof(soft_xpath
), "./%s/soft-reconfiguration",
6457 bgp_afi_safi_get_container_str(afi
, safi
));
6459 nb_cli_enqueue_change(vty
, soft_xpath
, NB_OP_MODIFY
, "true");
6461 return nb_cli_apply_changes(vty
, base_xpath
);
6464 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6465 neighbor_soft_reconfiguration_hidden_cmd
,
6466 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6467 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6468 "Per neighbor soft reconfiguration\n"
6469 "Allow inbound soft reconfiguration for this neighbor\n")
6471 DEFUN_YANG (no_neighbor_soft_reconfiguration
,
6472 no_neighbor_soft_reconfiguration_cmd
,
6473 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6474 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6475 "Per neighbor soft reconfiguration\n"
6476 "Allow inbound soft reconfiguration for this neighbor\n")
6479 char base_xpath
[XPATH_MAXLEN
];
6480 char af_xpath
[XPATH_MAXLEN
];
6481 char soft_xpath
[XPATH_MAXLEN
];
6482 afi_t afi
= bgp_node_afi(vty
);
6483 safi_t safi
= bgp_node_safi(vty
);
6485 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6486 yang_afi_safi_value2identity(afi
, safi
));
6488 snprintf(soft_xpath
, sizeof(soft_xpath
), "./%s/soft-reconfiguration",
6489 bgp_afi_safi_get_container_str(afi
, safi
));
6491 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6492 sizeof(base_xpath
), af_xpath
)
6494 return CMD_WARNING_CONFIG_FAILED
;
6496 nb_cli_enqueue_change(vty
, soft_xpath
, NB_OP_MODIFY
, "false");
6498 return nb_cli_apply_changes(vty
, base_xpath
);
6501 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6502 no_neighbor_soft_reconfiguration_hidden_cmd
,
6503 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6504 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6505 "Per neighbor soft reconfiguration\n"
6506 "Allow inbound soft reconfiguration for this neighbor\n")
6508 DEFUN_YANG (neighbor_route_reflector_client
,
6509 neighbor_route_reflector_client_cmd
,
6510 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6513 "Configure a neighbor as Route Reflector client\n")
6516 char base_xpath
[XPATH_MAXLEN
];
6517 char af_xpath
[XPATH_MAXLEN
];
6518 char attr_xpath
[XPATH_MAXLEN
];
6519 afi_t afi
= bgp_node_afi(vty
);
6520 safi_t safi
= bgp_node_safi(vty
);
6522 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6523 yang_afi_safi_value2identity(afi
, safi
));
6525 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6526 sizeof(base_xpath
), af_xpath
)
6528 return CMD_WARNING_CONFIG_FAILED
;
6530 snprintf(attr_xpath
, sizeof(attr_xpath
),
6531 "./%s/route-reflector/route-reflector-client",
6532 bgp_afi_safi_get_container_str(afi
, safi
));
6534 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6536 return nb_cli_apply_changes(vty
, base_xpath
);
6539 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6540 neighbor_route_reflector_client_hidden_cmd
,
6541 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6542 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6543 "Configure a neighbor as Route Reflector client\n")
6545 DEFUN_YANG (no_neighbor_route_reflector_client
,
6546 no_neighbor_route_reflector_client_cmd
,
6547 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6551 "Configure a neighbor as Route Reflector client\n")
6554 char base_xpath
[XPATH_MAXLEN
];
6555 char af_xpath
[XPATH_MAXLEN
];
6556 char attr_xpath
[XPATH_MAXLEN
];
6557 afi_t afi
= bgp_node_afi(vty
);
6558 safi_t safi
= bgp_node_safi(vty
);
6560 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6561 yang_afi_safi_value2identity(afi
, safi
));
6563 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6564 sizeof(base_xpath
), af_xpath
)
6566 return CMD_WARNING_CONFIG_FAILED
;
6568 snprintf(attr_xpath
, sizeof(attr_xpath
),
6569 "./%s/route-reflector/route-reflector-client",
6570 bgp_afi_safi_get_container_str(afi
, safi
));
6572 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6574 return nb_cli_apply_changes(vty
, base_xpath
);
6577 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6578 no_neighbor_route_reflector_client_hidden_cmd
,
6579 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6580 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6581 "Configure a neighbor as Route Reflector client\n")
6583 /* neighbor route-server-client. */
6584 DEFUN_YANG (neighbor_route_server_client
,
6585 neighbor_route_server_client_cmd
,
6586 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6589 "Configure a neighbor as Route Server client\n")
6592 char base_xpath
[XPATH_MAXLEN
];
6593 char af_xpath
[XPATH_MAXLEN
];
6594 char attr_xpath
[XPATH_MAXLEN
];
6595 afi_t afi
= bgp_node_afi(vty
);
6596 safi_t safi
= bgp_node_safi(vty
);
6598 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6599 yang_afi_safi_value2identity(afi
, safi
));
6601 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6602 sizeof(base_xpath
), af_xpath
)
6604 return CMD_WARNING_CONFIG_FAILED
;
6606 snprintf(attr_xpath
, sizeof(attr_xpath
),
6607 "./%s/route-server/route-server-client",
6608 bgp_afi_safi_get_container_str(afi
, safi
));
6610 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6612 return nb_cli_apply_changes(vty
, base_xpath
);
6615 ALIAS_HIDDEN(neighbor_route_server_client
,
6616 neighbor_route_server_client_hidden_cmd
,
6617 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6618 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6619 "Configure a neighbor as Route Server client\n")
6621 DEFUN_YANG (no_neighbor_route_server_client
,
6622 no_neighbor_route_server_client_cmd
,
6623 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6627 "Configure a neighbor as Route Server client\n")
6630 char base_xpath
[XPATH_MAXLEN
];
6631 char af_xpath
[XPATH_MAXLEN
];
6632 char attr_xpath
[XPATH_MAXLEN
];
6633 afi_t afi
= bgp_node_afi(vty
);
6634 safi_t safi
= bgp_node_safi(vty
);
6636 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6637 yang_afi_safi_value2identity(afi
, safi
));
6639 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6640 sizeof(base_xpath
), af_xpath
)
6642 return CMD_WARNING_CONFIG_FAILED
;
6644 snprintf(attr_xpath
, sizeof(attr_xpath
),
6645 "./%s/route-server/route-server-client",
6646 bgp_afi_safi_get_container_str(afi
, safi
));
6648 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6650 return nb_cli_apply_changes(vty
, base_xpath
);
6653 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6654 no_neighbor_route_server_client_hidden_cmd
,
6655 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6656 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6657 "Configure a neighbor as Route Server client\n")
6659 DEFUN (neighbor_nexthop_local_unchanged
,
6660 neighbor_nexthop_local_unchanged_cmd
,
6661 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6664 "Configure treatment of outgoing link-local nexthop attribute\n"
6665 "Leave link-local nexthop unchanged for this peer\n")
6668 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6670 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6673 DEFUN (no_neighbor_nexthop_local_unchanged
,
6674 no_neighbor_nexthop_local_unchanged_cmd
,
6675 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6679 "Configure treatment of outgoing link-local-nexthop attribute\n"
6680 "Leave link-local nexthop unchanged for this peer\n")
6683 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6684 bgp_node_afi(vty
), bgp_node_safi(vty
),
6685 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6688 DEFUN_YANG (neighbor_attr_unchanged
,
6689 neighbor_attr_unchanged_cmd
,
6690 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6693 "BGP attribute is propagated unchanged to this neighbor\n"
6694 "As-path attribute\n"
6695 "Nexthop attribute\n"
6699 char *peer_str
= argv
[1]->arg
;
6700 bool aspath
= false;
6701 bool nexthop
= false;
6703 afi_t afi
= bgp_node_afi(vty
);
6704 safi_t safi
= bgp_node_safi(vty
);
6705 char base_xpath
[XPATH_MAXLEN
];
6706 char af_xpath
[XPATH_MAXLEN
];
6707 char as_xpath
[XPATH_MAXLEN
];
6708 char nxthop_xpath
[XPATH_MAXLEN
];
6709 char med_xpath
[XPATH_MAXLEN
];
6711 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6712 yang_afi_safi_value2identity(afi
, safi
));
6714 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6715 sizeof(base_xpath
), af_xpath
)
6717 return CMD_WARNING_CONFIG_FAILED
;
6719 if (argv_find(argv
, argc
, "as-path", &idx
))
6723 if (argv_find(argv
, argc
, "next-hop", &idx
))
6727 if (argv_find(argv
, argc
, "med", &idx
))
6730 snprintf(as_xpath
, sizeof(as_xpath
),
6731 "./%s/attr-unchanged/as-path-unchanged",
6732 bgp_afi_safi_get_container_str(afi
, safi
));
6733 snprintf(nxthop_xpath
, sizeof(nxthop_xpath
),
6734 "./%s/attr-unchanged/next-hop-unchanged",
6735 bgp_afi_safi_get_container_str(afi
, safi
));
6736 snprintf(med_xpath
, sizeof(med_xpath
),
6737 "./%s/attr-unchanged/med-unchanged",
6738 bgp_afi_safi_get_container_str(afi
, safi
));
6740 /* no flags means all of them! */
6741 if (!aspath
&& !nexthop
&& !med
) {
6742 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "true");
6743 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "true");
6744 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "true");
6747 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
,
6750 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
,
6754 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
,
6757 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
,
6761 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
,
6764 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
,
6768 return nb_cli_apply_changes(vty
, base_xpath
);
6772 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6773 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6774 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6775 "BGP attribute is propagated unchanged to this neighbor\n"
6776 "As-path attribute\n"
6777 "Nexthop attribute\n"
6780 DEFUN_YANG (no_neighbor_attr_unchanged
,
6781 no_neighbor_attr_unchanged_cmd
,
6782 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6786 "BGP attribute is propagated unchanged to this neighbor\n"
6787 "As-path attribute\n"
6788 "Nexthop attribute\n"
6792 char *peer_str
= argv
[2]->arg
;
6793 bool aspath
= false;
6794 bool nexthop
= false;
6796 afi_t afi
= bgp_node_afi(vty
);
6797 safi_t safi
= bgp_node_safi(vty
);
6798 char base_xpath
[XPATH_MAXLEN
];
6799 char af_xpath
[XPATH_MAXLEN
];
6800 char as_xpath
[XPATH_MAXLEN
];
6801 char nxthop_xpath
[XPATH_MAXLEN
];
6802 char med_xpath
[XPATH_MAXLEN
];
6804 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6805 yang_afi_safi_value2identity(afi
, safi
));
6807 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6808 sizeof(base_xpath
), af_xpath
)
6810 return CMD_WARNING_CONFIG_FAILED
;
6812 if (argv_find(argv
, argc
, "as-path", &idx
))
6816 if (argv_find(argv
, argc
, "next-hop", &idx
))
6820 if (argv_find(argv
, argc
, "med", &idx
))
6823 snprintf(as_xpath
, sizeof(as_xpath
),
6824 "./%s/attr-unchanged/as-path-unchanged",
6825 bgp_afi_safi_get_container_str(afi
, safi
));
6826 snprintf(nxthop_xpath
, sizeof(nxthop_xpath
),
6827 "./%s/attr-unchanged/next-hop-unchanged",
6828 bgp_afi_safi_get_container_str(afi
, safi
));
6829 snprintf(med_xpath
, sizeof(med_xpath
),
6830 "./%s/attr-unchanged/med-unchanged",
6831 bgp_afi_safi_get_container_str(afi
, safi
));
6833 /* no flags means all of them! */
6834 if (!aspath
&& !nexthop
&& !med
) {
6835 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "false");
6836 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "false");
6837 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "false");
6841 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "false");
6844 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "false");
6847 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "false");
6849 return nb_cli_apply_changes(vty
, base_xpath
);
6853 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6854 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6855 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6856 "BGP attribute is propagated unchanged to this neighbor\n"
6857 "As-path attribute\n"
6858 "Nexthop attribute\n"
6861 /* neighbor ebgp-multihop. */
6862 DEFUN_YANG (neighbor_ebgp_multihop
,
6863 neighbor_ebgp_multihop_cmd
,
6864 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6865 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6866 "Allow EBGP neighbors not on directly connected networks\n")
6869 char base_xpath
[XPATH_MAXLEN
];
6871 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6872 sizeof(base_xpath
), NULL
)
6874 return CMD_WARNING_CONFIG_FAILED
;
6876 nb_cli_enqueue_change(vty
, "./ebgp-multihop/enabled", NB_OP_MODIFY
,
6879 return nb_cli_apply_changes(vty
, base_xpath
);
6882 DEFUN_YANG (neighbor_ebgp_multihop_ttl
,
6883 neighbor_ebgp_multihop_ttl_cmd
,
6884 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6885 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6886 "Allow EBGP neighbors not on directly connected networks\n"
6887 "maximum hop count\n")
6891 char base_xpath
[XPATH_MAXLEN
];
6893 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6894 sizeof(base_xpath
), NULL
)
6896 return CMD_WARNING_CONFIG_FAILED
;
6898 nb_cli_enqueue_change(vty
, "./ebgp-multihop/multihop-ttl", NB_OP_MODIFY
,
6899 argv
[idx_number
]->arg
);
6901 return nb_cli_apply_changes(vty
, base_xpath
);
6904 DEFUN_YANG (no_neighbor_ebgp_multihop
,
6905 no_neighbor_ebgp_multihop_cmd
,
6906 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6907 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6908 "Allow EBGP neighbors not on directly connected networks\n"
6909 "maximum hop count\n")
6912 char base_xpath
[XPATH_MAXLEN
];
6914 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6915 sizeof(base_xpath
), NULL
)
6917 return CMD_WARNING_CONFIG_FAILED
;
6920 nb_cli_enqueue_change(vty
, "./ebgp-multihop/multihop-ttl",
6921 NB_OP_DESTROY
, NULL
);
6923 nb_cli_enqueue_change(vty
, "./ebgp-multihop/enabled",
6924 NB_OP_MODIFY
, "false");
6926 return nb_cli_apply_changes(vty
, base_xpath
);
6930 /* disable-connected-check */
6931 DEFUN_YANG (neighbor_disable_connected_check
,
6932 neighbor_disable_connected_check_cmd
,
6933 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6934 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6935 "one-hop away EBGP peer using loopback address\n"
6936 "Enforce EBGP neighbors perform multihop\n")
6939 char base_xpath
[XPATH_MAXLEN
];
6941 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6942 sizeof(base_xpath
), NULL
)
6944 return CMD_WARNING_CONFIG_FAILED
;
6946 nb_cli_enqueue_change(vty
, "./ebgp-multihop/disable-connected-check",
6947 NB_OP_MODIFY
, "true");
6949 return nb_cli_apply_changes(vty
, base_xpath
);
6952 DEFUN_YANG (no_neighbor_disable_connected_check
,
6953 no_neighbor_disable_connected_check_cmd
,
6954 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6955 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6956 "one-hop away EBGP peer using loopback address\n"
6957 "Enforce EBGP neighbors perform multihop\n")
6960 char base_xpath
[XPATH_MAXLEN
];
6962 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6963 sizeof(base_xpath
), NULL
)
6965 return CMD_WARNING_CONFIG_FAILED
;
6967 nb_cli_enqueue_change(vty
, "./ebgp-multihop/disable-connected-check",
6968 NB_OP_MODIFY
, "false");
6970 return nb_cli_apply_changes(vty
, base_xpath
);
6974 /* enforce-first-as */
6975 DEFUN_YANG (neighbor_enforce_first_as
,
6976 neighbor_enforce_first_as_cmd
,
6977 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6978 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6979 "Enforce the first AS for EBGP routes\n")
6982 char base_xpath
[XPATH_MAXLEN
];
6984 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6985 sizeof(base_xpath
), NULL
)
6987 return CMD_WARNING_CONFIG_FAILED
;
6989 nb_cli_enqueue_change(vty
, "./enforce-first-as", NB_OP_MODIFY
, "true");
6991 return nb_cli_apply_changes(vty
, base_xpath
);
6994 DEFUN_YANG (no_neighbor_enforce_first_as
,
6995 no_neighbor_enforce_first_as_cmd
,
6996 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6997 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6998 "Enforce the first AS for EBGP routes\n")
7001 char base_xpath
[XPATH_MAXLEN
];
7003 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7004 sizeof(base_xpath
), NULL
)
7006 return CMD_WARNING_CONFIG_FAILED
;
7008 nb_cli_enqueue_change(vty
, "./enforce-first-as", NB_OP_MODIFY
, "false");
7010 return nb_cli_apply_changes(vty
, base_xpath
);
7013 static int peer_and_group_lookup_nb(struct vty
*vty
, const char *peer_str
,
7014 char *base_xpath
, int xpath_len
,
7018 char num_xpath
[XPATH_MAXLEN
];
7019 char unnbr_xpath
[XPATH_MAXLEN
];
7020 char prgrp_xpath
[XPATH_MAXLEN
];
7022 if (str2sockunion(peer_str
, &su
) == 0) {
7023 snprintf(num_xpath
, sizeof(num_xpath
),
7024 "/neighbors/neighbor[remote-address='%s']", peer_str
);
7025 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
7026 VTY_CURR_XPATH
, num_xpath
)) {
7027 snprintf(base_xpath
, xpath_len
,
7028 FRR_BGP_NEIGHBOR_NUM_XPATH
, peer_str
,
7029 xpath
? xpath
: "");
7032 "%% Specify remote-as or peer-group commands first\n");
7037 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
7038 "/neighbors/unnumbered-neighbor[interface='%s']",
7041 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
7042 "/peer-groups/peer-group[peer-group-name='%s']",
7045 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
7046 VTY_CURR_XPATH
, unnbr_xpath
)) {
7047 snprintf(base_xpath
, xpath_len
,
7048 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, peer_str
,
7049 xpath
? xpath
: "");
7050 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
,
7051 "%s%s", VTY_CURR_XPATH
,
7053 snprintf(base_xpath
, xpath_len
,
7054 FRR_BGP_PEER_GROUP_XPATH
, peer_str
,
7055 xpath
? xpath
: "");
7058 "%% Create the peer-group or interface first\n");
7066 DEFUN_YANG (neighbor_description
,
7067 neighbor_description_cmd
,
7068 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
7069 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7070 "Neighbor specific description\n"
7071 "Up to 80 characters describing this neighbor\n")
7076 char base_xpath
[XPATH_MAXLEN
];
7079 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7080 sizeof(base_xpath
), NULL
)
7082 return CMD_WARNING_CONFIG_FAILED
;
7084 str
= argv_concat(argv
, argc
, idx_line
);
7086 nb_cli_enqueue_change(vty
, "./description", NB_OP_MODIFY
, str
);
7088 ret
= nb_cli_apply_changes(vty
, base_xpath
);
7090 XFREE(MTYPE_TMP
, str
);
7095 DEFUN_YANG (no_neighbor_description
,
7096 no_neighbor_description_cmd
,
7097 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
7098 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7099 "Neighbor specific description\n")
7102 char base_xpath
[XPATH_MAXLEN
];
7104 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7105 sizeof(base_xpath
), NULL
)
7107 return CMD_WARNING_CONFIG_FAILED
;
7109 nb_cli_enqueue_change(vty
, "./description", NB_OP_DESTROY
, NULL
);
7111 return nb_cli_apply_changes(vty
, base_xpath
);
7114 ALIAS_YANG(no_neighbor_description
, no_neighbor_description_comment_cmd
,
7115 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
7116 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7117 "Neighbor specific description\n"
7118 "Up to 80 characters describing this neighbor\n")
7120 #define BGP_UPDATE_SOURCE_HELP_STR \
7123 "Interface name (requires zebra to be running)\n"
7125 DEFUN_YANG (neighbor_update_source
,
7126 neighbor_update_source_cmd
,
7127 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
7128 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7129 "Source of routing updates\n"
7130 BGP_UPDATE_SOURCE_HELP_STR
)
7135 char base_xpath
[XPATH_MAXLEN
];
7137 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7138 sizeof(base_xpath
), NULL
)
7140 return CMD_WARNING_CONFIG_FAILED
;
7142 if (str2sockunion(argv
[idx_peer_2
]->arg
, &su
) == 0)
7143 nb_cli_enqueue_change(vty
, "./update-source/ip", NB_OP_MODIFY
,
7144 argv
[idx_peer_2
]->arg
);
7146 nb_cli_enqueue_change(vty
, "./update-source/interface",
7147 NB_OP_MODIFY
, argv
[idx_peer_2
]->arg
);
7149 return nb_cli_apply_changes(vty
, base_xpath
);
7152 DEFUN_YANG (no_neighbor_update_source
,
7153 no_neighbor_update_source_cmd
,
7154 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
7157 "Source of routing updates\n"
7158 BGP_UPDATE_SOURCE_HELP_STR
)
7161 char base_xpath
[XPATH_MAXLEN
];
7163 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7164 sizeof(base_xpath
), NULL
)
7166 return CMD_WARNING_CONFIG_FAILED
;
7168 nb_cli_enqueue_change(vty
, "./update-source/ip", NB_OP_DESTROY
, NULL
);
7169 nb_cli_enqueue_change(vty
, "./update-source/interface", NB_OP_DESTROY
,
7172 return nb_cli_apply_changes(vty
, base_xpath
);
7175 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
7176 afi_t afi
, safi_t safi
,
7177 const char *rmap
, int set
)
7181 struct route_map
*route_map
= NULL
;
7183 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
7185 return CMD_WARNING_CONFIG_FAILED
;
7189 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
7190 ret
= peer_default_originate_set(peer
, afi
, safi
,
7193 ret
= peer_default_originate_unset(peer
, afi
, safi
);
7195 return bgp_vty_return(vty
, ret
);
7198 /* neighbor default-originate. */
7199 DEFUN (neighbor_default_originate
,
7200 neighbor_default_originate_cmd
,
7201 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
7204 "Originate default route to this neighbor\n")
7207 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
7209 bgp_node_safi(vty
), NULL
, 1);
7212 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
7213 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
7214 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7215 "Originate default route to this neighbor\n")
7217 DEFUN (neighbor_default_originate_rmap
,
7218 neighbor_default_originate_rmap_cmd
,
7219 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
7222 "Originate default route to this neighbor\n"
7223 "Route-map to specify criteria to originate default\n"
7228 return peer_default_originate_set_vty(
7229 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7230 argv
[idx_word
]->arg
, 1);
7234 neighbor_default_originate_rmap
,
7235 neighbor_default_originate_rmap_hidden_cmd
,
7236 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
7237 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7238 "Originate default route to this neighbor\n"
7239 "Route-map to specify criteria to originate default\n"
7242 DEFUN (no_neighbor_default_originate
,
7243 no_neighbor_default_originate_cmd
,
7244 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
7248 "Originate default route to this neighbor\n"
7249 "Route-map to specify criteria to originate default\n"
7253 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
7255 bgp_node_safi(vty
), NULL
, 0);
7259 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
7260 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
7261 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7262 "Originate default route to this neighbor\n"
7263 "Route-map to specify criteria to originate default\n"
7267 /* Set specified peer's BGP port. */
7268 DEFUN_YANG (neighbor_port
,
7270 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
7273 "Neighbor's BGP port\n"
7274 "TCP port number\n")
7278 char base_xpath
[XPATH_MAXLEN
];
7280 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7281 argv
[idx_ip
]->arg
, "");
7283 nb_cli_enqueue_change(vty
, "./local-port", NB_OP_MODIFY
,
7284 argv
[idx_number
]->arg
);
7286 return nb_cli_apply_changes(vty
, base_xpath
);
7289 DEFUN_YANG (no_neighbor_port
,
7290 no_neighbor_port_cmd
,
7291 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
7292 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR
7293 "Neighbor's BGP port\n"
7294 "TCP port number\n")
7297 char base_xpath
[XPATH_MAXLEN
];
7299 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7300 argv
[idx_ip
]->arg
, "");
7302 nb_cli_enqueue_change(vty
, "./local-port", NB_OP_DESTROY
, NULL
);
7304 return nb_cli_apply_changes(vty
, base_xpath
);
7307 DEFUN_YANG (neighbor_weight
,
7308 neighbor_weight_cmd
,
7309 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7310 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7311 "Set default weight for routes from this neighbor\n"
7316 char base_xpath
[XPATH_MAXLEN
];
7317 char af_xpath
[XPATH_MAXLEN
];
7318 char attr_xpath
[XPATH_MAXLEN
];
7319 afi_t afi
= bgp_node_afi(vty
);
7320 safi_t safi
= bgp_node_safi(vty
);
7322 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
7323 yang_afi_safi_value2identity(afi
, safi
));
7325 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7326 sizeof(base_xpath
), af_xpath
)
7328 return CMD_WARNING_CONFIG_FAILED
;
7330 snprintf(attr_xpath
, sizeof(attr_xpath
), "./%s/weight/weight-attribute",
7331 bgp_afi_safi_get_container_str(afi
, safi
));
7333 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
,
7334 argv
[idx_number
]->arg
);
7336 return nb_cli_apply_changes(vty
, base_xpath
);
7339 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
7340 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7341 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7342 "Set default weight for routes from this neighbor\n"
7345 DEFUN_YANG (no_neighbor_weight
,
7346 no_neighbor_weight_cmd
,
7347 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7348 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7349 "Set default weight for routes from this neighbor\n"
7353 char base_xpath
[XPATH_MAXLEN
];
7354 char af_xpath
[XPATH_MAXLEN
];
7355 char attr_xpath
[XPATH_MAXLEN
];
7356 afi_t afi
= bgp_node_afi(vty
);
7357 safi_t safi
= bgp_node_safi(vty
);
7359 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
7360 yang_afi_safi_value2identity(afi
, safi
));
7362 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7363 sizeof(base_xpath
), af_xpath
)
7365 return CMD_WARNING_CONFIG_FAILED
;
7367 snprintf(attr_xpath
, sizeof(attr_xpath
), "./%s/weight/weight-attribute",
7368 bgp_afi_safi_get_container_str(afi
, safi
));
7370 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_DESTROY
, NULL
);
7372 return nb_cli_apply_changes(vty
, base_xpath
);
7375 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
7376 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7377 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7378 "Set default weight for routes from this neighbor\n"
7382 /* Override capability negotiation. */
7383 DEFUN_YANG (neighbor_override_capability
,
7384 neighbor_override_capability_cmd
,
7385 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7388 "Override capability negotiation result\n")
7391 char base_xpath
[XPATH_MAXLEN
];
7393 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7394 sizeof(base_xpath
), NULL
)
7396 return CMD_WARNING_CONFIG_FAILED
;
7398 nb_cli_enqueue_change(
7399 vty
, "./capability-options/override-capability",
7400 NB_OP_MODIFY
, "true");
7402 return nb_cli_apply_changes(vty
, base_xpath
);
7405 DEFUN_YANG (no_neighbor_override_capability
,
7406 no_neighbor_override_capability_cmd
,
7407 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7411 "Override capability negotiation result\n")
7414 char base_xpath
[XPATH_MAXLEN
];
7416 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7417 sizeof(base_xpath
), NULL
)
7419 return CMD_WARNING_CONFIG_FAILED
;
7421 nb_cli_enqueue_change(
7422 vty
, "./capability-options/override-capability",
7423 NB_OP_MODIFY
, "false");
7425 return nb_cli_apply_changes(vty
, base_xpath
);
7428 DEFUN_YANG (neighbor_strict_capability
,
7429 neighbor_strict_capability_cmd
,
7430 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7433 "Strict capability negotiation match\n")
7436 char base_xpath
[XPATH_MAXLEN
];
7438 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7439 sizeof(base_xpath
), NULL
)
7441 return CMD_WARNING_CONFIG_FAILED
;
7443 nb_cli_enqueue_change(
7444 vty
, "./capability-options/strict-capability",
7445 NB_OP_MODIFY
, "true");
7447 return nb_cli_apply_changes(vty
, base_xpath
);
7450 DEFUN_YANG (no_neighbor_strict_capability
,
7451 no_neighbor_strict_capability_cmd
,
7452 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7456 "Strict capability negotiation match\n")
7459 char base_xpath
[XPATH_MAXLEN
];
7461 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7462 sizeof(base_xpath
), NULL
)
7464 return CMD_WARNING_CONFIG_FAILED
;
7466 nb_cli_enqueue_change(
7467 vty
, "./capability-options/strict-capability",
7468 NB_OP_MODIFY
, "false");
7470 return nb_cli_apply_changes(vty
, base_xpath
);
7473 DEFUN_YANG (neighbor_timers
,
7474 neighbor_timers_cmd
,
7475 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7476 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7477 "BGP per neighbor timers\n"
7478 "Keepalive interval\n"
7483 int idx_number_2
= 4;
7484 char base_xpath
[XPATH_MAXLEN
];
7486 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7487 sizeof(base_xpath
), NULL
)
7489 return CMD_WARNING_CONFIG_FAILED
;
7491 nb_cli_enqueue_change(vty
, "./timers/keepalive", NB_OP_MODIFY
,
7492 argv
[idx_number
]->arg
);
7494 nb_cli_enqueue_change(vty
, "./timers/hold-time", NB_OP_MODIFY
,
7495 argv
[idx_number_2
]->arg
);
7497 return nb_cli_apply_changes(vty
, base_xpath
);
7500 DEFUN_YANG (no_neighbor_timers
,
7501 no_neighbor_timers_cmd
,
7502 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7503 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7504 "BGP per neighbor timers\n"
7505 "Keepalive interval\n"
7509 char base_xpath
[XPATH_MAXLEN
];
7511 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7512 sizeof(base_xpath
), NULL
)
7514 return CMD_WARNING_CONFIG_FAILED
;
7516 nb_cli_enqueue_change(vty
, "./timers/hold-time", NB_OP_DESTROY
, NULL
);
7518 nb_cli_enqueue_change(vty
, "./timers/keepalive", NB_OP_DESTROY
, NULL
);
7520 return nb_cli_apply_changes(vty
, base_xpath
);
7523 DEFUN_YANG (neighbor_timers_connect
,
7524 neighbor_timers_connect_cmd
,
7525 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7526 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7527 "BGP per neighbor timers\n"
7528 "BGP connect timer\n"
7533 char base_xpath
[XPATH_MAXLEN
];
7535 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7536 sizeof(base_xpath
), NULL
)
7538 return CMD_WARNING_CONFIG_FAILED
;
7540 nb_cli_enqueue_change(vty
, "./timers/connect-time", NB_OP_MODIFY
,
7541 argv
[idx_number
]->arg
);
7543 return nb_cli_apply_changes(vty
, base_xpath
);
7546 DEFUN_YANG (no_neighbor_timers_connect
,
7547 no_neighbor_timers_connect_cmd
,
7548 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7549 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7550 "BGP per neighbor timers\n"
7551 "BGP connect timer\n"
7555 char base_xpath
[XPATH_MAXLEN
];
7557 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7558 sizeof(base_xpath
), NULL
)
7560 return CMD_WARNING_CONFIG_FAILED
;
7562 nb_cli_enqueue_change(vty
, "./timers/connect-time", NB_OP_DESTROY
,
7565 return nb_cli_apply_changes(vty
, base_xpath
);
7568 DEFPY (neighbor_timers_delayopen
,
7569 neighbor_timers_delayopen_cmd
,
7570 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7573 "BGP per neighbor timers\n"
7574 "RFC 4271 DelayOpenTimer\n"
7575 "DelayOpenTime timer interval\n")
7579 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7581 return CMD_WARNING_CONFIG_FAILED
;
7584 if (peer_timers_delayopen_unset(peer
))
7585 return CMD_WARNING_CONFIG_FAILED
;
7587 if (peer_timers_delayopen_set(peer
, interval
))
7588 return CMD_WARNING_CONFIG_FAILED
;
7594 DEFPY (no_neighbor_timers_delayopen
,
7595 no_neighbor_timers_delayopen_cmd
,
7596 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7600 "BGP per neighbor timers\n"
7601 "RFC 4271 DelayOpenTimer\n"
7602 "DelayOpenTime timer interval\n")
7606 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7608 return CMD_WARNING_CONFIG_FAILED
;
7610 if (peer_timers_delayopen_unset(peer
))
7611 return CMD_WARNING_CONFIG_FAILED
;
7616 DEFUN_YANG (neighbor_advertise_interval
,
7617 neighbor_advertise_interval_cmd
,
7618 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7619 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7620 "Minimum interval between sending BGP routing updates\n"
7621 "time in seconds\n")
7625 char base_xpath
[XPATH_MAXLEN
];
7627 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7628 sizeof(base_xpath
), NULL
)
7630 return CMD_WARNING_CONFIG_FAILED
;
7632 nb_cli_enqueue_change(vty
, "./timers/advertise-interval", NB_OP_MODIFY
,
7633 argv
[idx_number
]->arg
);
7635 return nb_cli_apply_changes(vty
, base_xpath
);
7638 DEFUN_YANG (no_neighbor_advertise_interval
,
7639 no_neighbor_advertise_interval_cmd
,
7640 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7641 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7642 "Minimum interval between sending BGP routing updates\n"
7643 "time in seconds\n")
7646 char base_xpath
[XPATH_MAXLEN
];
7648 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7649 sizeof(base_xpath
), NULL
)
7651 return CMD_WARNING_CONFIG_FAILED
;
7653 nb_cli_enqueue_change(vty
, "./timers/advertise-interval", NB_OP_DESTROY
,
7656 return nb_cli_apply_changes(vty
, base_xpath
);
7660 /* Time to wait before processing route-map updates */
7661 DEFUN (bgp_set_route_map_delay_timer
,
7662 bgp_set_route_map_delay_timer_cmd
,
7663 "bgp route-map delay-timer (0-600)",
7665 "BGP route-map delay timer\n"
7666 "Time in secs to wait before processing route-map changes\n"
7667 "0 disables the timer, no route updates happen when route-maps change\n")
7670 uint32_t rmap_delay_timer
;
7672 if (argv
[idx_number
]->arg
) {
7673 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7674 bm
->rmap_update_timer
= rmap_delay_timer
;
7676 /* if the dynamic update handling is being disabled, and a timer
7678 * running, stop the timer and act as if the timer has already
7681 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7682 BGP_TIMER_OFF(bm
->t_rmap_update
);
7683 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7688 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7689 return CMD_WARNING_CONFIG_FAILED
;
7693 DEFUN (no_bgp_set_route_map_delay_timer
,
7694 no_bgp_set_route_map_delay_timer_cmd
,
7695 "no bgp route-map delay-timer [(0-600)]",
7698 "Default BGP route-map delay timer\n"
7699 "Reset to default time to wait for processing route-map changes\n"
7700 "0 disables the timer, no route updates happen when route-maps change\n")
7703 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7708 DEFUN_YANG (neighbor_interface
,
7709 neighbor_interface_cmd
,
7710 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7711 NEIGHBOR_STR NEIGHBOR_ADDR_STR
7717 char base_xpath
[XPATH_MAXLEN
];
7719 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7720 argv
[idx_ip
]->arg
, "");
7722 nb_cli_enqueue_change(vty
, "./local-interface", NB_OP_MODIFY
,
7723 argv
[idx_word
]->arg
);
7725 return nb_cli_apply_changes(vty
, base_xpath
);
7728 DEFUN_YANG (no_neighbor_interface
,
7729 no_neighbor_interface_cmd
,
7730 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
7731 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7736 char base_xpath
[XPATH_MAXLEN
];
7738 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7739 argv
[idx_peer
]->arg
, "");
7741 nb_cli_enqueue_change(vty
, "./local-interface", NB_OP_DESTROY
, NULL
);
7743 return nb_cli_apply_changes(vty
, base_xpath
);
7746 DEFUN (neighbor_distribute_list
,
7747 neighbor_distribute_list_cmd
,
7748 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7751 "Filter updates to/from this neighbor\n"
7752 "IP access-list number\n"
7753 "IP access-list number (expanded range)\n"
7754 "IP Access-list name\n"
7755 "Filter incoming updates\n"
7756 "Filter outgoing updates\n")
7763 const char *pstr
= argv
[idx_peer
]->arg
;
7764 const char *acl
= argv
[idx_acl
]->arg
;
7765 const char *inout
= argv
[argc
- 1]->text
;
7767 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7769 return CMD_WARNING_CONFIG_FAILED
;
7771 /* Check filter direction. */
7772 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7773 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7776 return bgp_vty_return(vty
, ret
);
7780 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7781 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7782 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7783 "Filter updates to/from this neighbor\n"
7784 "IP access-list number\n"
7785 "IP access-list number (expanded range)\n"
7786 "IP Access-list name\n"
7787 "Filter incoming updates\n"
7788 "Filter outgoing updates\n")
7790 DEFUN (no_neighbor_distribute_list
,
7791 no_neighbor_distribute_list_cmd
,
7792 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7796 "Filter updates to/from this neighbor\n"
7797 "IP access-list number\n"
7798 "IP access-list number (expanded range)\n"
7799 "IP Access-list name\n"
7800 "Filter incoming updates\n"
7801 "Filter outgoing updates\n")
7807 const char *pstr
= argv
[idx_peer
]->arg
;
7808 const char *inout
= argv
[argc
- 1]->text
;
7810 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7812 return CMD_WARNING_CONFIG_FAILED
;
7814 /* Check filter direction. */
7815 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7816 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7819 return bgp_vty_return(vty
, ret
);
7823 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7824 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7825 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7826 "Filter updates to/from this neighbor\n"
7827 "IP access-list number\n"
7828 "IP access-list number (expanded range)\n"
7829 "IP Access-list name\n"
7830 "Filter incoming updates\n"
7831 "Filter outgoing updates\n")
7833 /* Set prefix list to the peer. */
7835 neighbor_prefix_list
, neighbor_prefix_list_cmd
,
7836 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor_str prefix-list WORD$prefix_str <in|out>$direction",
7837 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7838 "Filter updates to/from this neighbor\n"
7839 "Name of a prefix list\n"
7840 "Filter incoming updates\n"
7841 "Filter outgoing updates\n")
7843 char base_xpath
[XPATH_MAXLEN
];
7844 char af_xpath
[XPATH_MAXLEN
];
7845 char plist_xpath
[XPATH_MAXLEN
];
7846 afi_t afi
= bgp_node_afi(vty
);
7847 safi_t safi
= bgp_node_safi(vty
);
7849 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
7850 yang_afi_safi_value2identity(afi
, safi
));
7851 if (peer_and_group_lookup_nb(vty
, neighbor_str
, base_xpath
,
7852 sizeof(base_xpath
), af_xpath
)
7854 return CMD_WARNING_CONFIG_FAILED
;
7856 if (strmatch(direction
, "in"))
7857 snprintf(plist_xpath
, sizeof(plist_xpath
),
7858 "./%s/filter-config/plist-import",
7859 bgp_afi_safi_get_container_str(afi
, safi
));
7860 else if (strmatch(direction
, "out"))
7861 snprintf(plist_xpath
, sizeof(plist_xpath
),
7862 "./%s/filter-config/plist-export",
7863 bgp_afi_safi_get_container_str(afi
, safi
));
7866 nb_cli_enqueue_change(vty
, plist_xpath
, NB_OP_MODIFY
,
7869 nb_cli_enqueue_change(vty
, plist_xpath
, NB_OP_DESTROY
, NULL
);
7871 return nb_cli_apply_changes(vty
, base_xpath
);
7874 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7875 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7876 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7877 "Filter updates to/from this neighbor\n"
7878 "Name of a prefix list\n"
7879 "Filter incoming updates\n"
7880 "Filter outgoing updates\n")
7882 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7883 safi_t safi
, const char *name_str
,
7884 const char *direct_str
)
7888 int direct
= FILTER_IN
;
7890 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7892 return CMD_WARNING_CONFIG_FAILED
;
7894 /* Check filter direction. */
7895 if (strncmp(direct_str
, "i", 1) == 0)
7897 else if (strncmp(direct_str
, "o", 1) == 0)
7898 direct
= FILTER_OUT
;
7900 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7902 return bgp_vty_return(vty
, ret
);
7905 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7906 safi_t safi
, const char *direct_str
)
7910 int direct
= FILTER_IN
;
7912 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7914 return CMD_WARNING_CONFIG_FAILED
;
7916 /* Check filter direction. */
7917 if (strncmp(direct_str
, "i", 1) == 0)
7919 else if (strncmp(direct_str
, "o", 1) == 0)
7920 direct
= FILTER_OUT
;
7922 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7924 return bgp_vty_return(vty
, ret
);
7927 DEFUN (neighbor_filter_list
,
7928 neighbor_filter_list_cmd
,
7929 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7932 "Establish BGP filters\n"
7933 "AS path access-list name\n"
7934 "Filter incoming routes\n"
7935 "Filter outgoing routes\n")
7940 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7941 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7942 argv
[idx_in_out
]->arg
);
7945 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7946 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7947 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7948 "Establish BGP filters\n"
7949 "AS path access-list name\n"
7950 "Filter incoming routes\n"
7951 "Filter outgoing routes\n")
7953 DEFUN (no_neighbor_filter_list
,
7954 no_neighbor_filter_list_cmd
,
7955 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7959 "Establish BGP filters\n"
7960 "AS path access-list name\n"
7961 "Filter incoming routes\n"
7962 "Filter outgoing routes\n")
7966 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7967 bgp_node_afi(vty
), bgp_node_safi(vty
),
7968 argv
[idx_in_out
]->arg
);
7971 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7972 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7973 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7974 "Establish BGP filters\n"
7975 "AS path access-list name\n"
7976 "Filter incoming routes\n"
7977 "Filter outgoing routes\n")
7979 /* Set advertise-map to the peer. */
7980 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7981 afi_t afi
, safi_t safi
,
7982 const char *advertise_str
,
7983 const char *condition_str
, bool condition
,
7986 int ret
= CMD_WARNING_CONFIG_FAILED
;
7988 struct route_map
*advertise_map
;
7989 struct route_map
*condition_map
;
7991 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7995 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7996 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7999 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
8000 advertise_map
, condition_str
,
8001 condition_map
, condition
);
8003 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
8004 advertise_map
, condition_str
,
8005 condition_map
, condition
);
8007 return bgp_vty_return(vty
, ret
);
8010 DEFPY (neighbor_advertise_map
,
8011 neighbor_advertise_map_cmd
,
8012 "[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",
8016 "Route-map to conditionally advertise routes\n"
8017 "Name of advertise map\n"
8018 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
8019 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
8020 "Name of the exist or non exist map\n")
8022 bool condition
= CONDITION_EXIST
;
8024 if (!strcmp(exist
, "non-exist-map"))
8025 condition
= CONDITION_NON_EXIST
;
8027 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
8028 bgp_node_safi(vty
), advertise_str
,
8029 condition_str
, condition
, !no
);
8032 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
8033 "[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",
8034 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8035 "Route-map to conditionally advertise routes\n"
8036 "Name of advertise map\n"
8037 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
8038 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
8039 "Name of the exist or non exist map\n")
8041 /* Set route-map to the peer. */
8043 neighbor_route_map
, neighbor_route_map_cmd
,
8044 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor_str route-map WORD$rmap_str <in|out>$direction",
8045 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8046 "Apply route map to neighbor\n"
8047 "Name of route map\n"
8048 "Apply map to incoming routes\n"
8049 "Apply map to outbound routes\n")
8051 char base_xpath
[XPATH_MAXLEN
];
8052 char af_xpath
[XPATH_MAXLEN
];
8053 char rmap_xpath
[XPATH_MAXLEN
];
8054 afi_t afi
= bgp_node_afi(vty
);
8055 safi_t safi
= bgp_node_safi(vty
);
8057 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8058 yang_afi_safi_value2identity(afi
, safi
));
8059 if (peer_and_group_lookup_nb(vty
, neighbor_str
, base_xpath
,
8060 sizeof(base_xpath
), af_xpath
)
8062 return CMD_WARNING_CONFIG_FAILED
;
8064 if (strmatch(direction
, "in"))
8065 snprintf(rmap_xpath
, sizeof(rmap_xpath
),
8066 "./%s/filter-config/rmap-import",
8067 bgp_afi_safi_get_container_str(afi
, safi
));
8068 else if (strmatch(direction
, "out"))
8069 snprintf(rmap_xpath
, sizeof(rmap_xpath
),
8070 "./%s/filter-config/rmap-export",
8071 bgp_afi_safi_get_container_str(afi
, safi
));
8074 if (!yang_dnode_exists(
8075 vty
->candidate_config
->dnode
,
8076 "/frr-route-map:lib/route-map[name='%s']",
8078 if (vty_shell_serv(vty
))
8080 "The route-map '%s' does not exist.\n",
8083 nb_cli_enqueue_change(vty
, rmap_xpath
, NB_OP_MODIFY
, rmap_str
);
8085 nb_cli_enqueue_change(vty
, rmap_xpath
, NB_OP_DESTROY
, NULL
);
8087 return nb_cli_apply_changes(vty
, base_xpath
);
8090 /* Set unsuppress-map to the peer. */
8091 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
8092 afi_t afi
, safi_t safi
,
8093 const char *name_str
)
8097 struct route_map
*route_map
;
8099 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8101 return CMD_WARNING_CONFIG_FAILED
;
8103 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
8104 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
8106 return bgp_vty_return(vty
, ret
);
8109 /* Unset route-map from the peer. */
8110 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
8111 afi_t afi
, safi_t safi
)
8116 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8118 return CMD_WARNING_CONFIG_FAILED
;
8120 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
8122 return bgp_vty_return(vty
, ret
);
8125 DEFUN (neighbor_unsuppress_map
,
8126 neighbor_unsuppress_map_cmd
,
8127 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8130 "Route-map to selectively unsuppress suppressed routes\n"
8131 "Name of route map\n")
8135 return peer_unsuppress_map_set_vty(
8136 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8137 argv
[idx_word
]->arg
);
8140 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
8141 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8142 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8143 "Route-map to selectively unsuppress suppressed routes\n"
8144 "Name of route map\n")
8146 DEFUN (no_neighbor_unsuppress_map
,
8147 no_neighbor_unsuppress_map_cmd
,
8148 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8152 "Route-map to selectively unsuppress suppressed routes\n"
8153 "Name of route map\n")
8156 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
8158 bgp_node_safi(vty
));
8161 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
8162 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8163 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8164 "Route-map to selectively unsuppress suppressed routes\n"
8165 "Name of route map\n")
8167 /* Maximum number of prefix to be sent to the neighbor. */
8168 DEFUN_YANG(neighbor_maximum_prefix_out
,
8169 neighbor_maximum_prefix_out_cmd
,
8170 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
8171 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8172 "Maximum number of prefixes to be sent to this peer\n"
8173 "Maximum no. of prefix limit\n")
8175 char base_xpath
[XPATH_MAXLEN
];
8176 char af_xpath
[XPATH_MAXLEN
];
8177 char attr_xpath
[XPATH_MAXLEN
];
8180 afi_t afi
= bgp_node_afi(vty
);
8181 safi_t safi
= bgp_node_safi(vty
);
8183 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8184 yang_afi_safi_value2identity(afi
, safi
));
8185 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8186 sizeof(base_xpath
), af_xpath
)
8188 return CMD_WARNING_CONFIG_FAILED
;
8190 snprintf(attr_xpath
, sizeof(attr_xpath
),
8191 "/%s/prefix-limit/direction-list[direction='out']",
8192 bgp_afi_safi_get_container_str(afi
, safi
));
8193 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8195 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8197 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8198 argv
[idx_number
]->arg
);
8200 return nb_cli_apply_changes(vty
, base_xpath
);
8203 DEFUN_YANG(no_neighbor_maximum_prefix_out
,
8204 no_neighbor_maximum_prefix_out_cmd
,
8205 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out",
8206 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8207 "Maximum number of prefixes to be sent to this peer\n")
8209 char base_xpath
[XPATH_MAXLEN
];
8210 char af_xpath
[XPATH_MAXLEN
];
8211 char attr_xpath
[XPATH_MAXLEN
];
8213 afi_t afi
= bgp_node_afi(vty
);
8214 safi_t safi
= bgp_node_safi(vty
);
8216 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8217 yang_afi_safi_value2identity(afi
, safi
));
8218 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8219 sizeof(base_xpath
), af_xpath
)
8221 return CMD_WARNING_CONFIG_FAILED
;
8223 snprintf(attr_xpath
, sizeof(attr_xpath
),
8224 "/%s/prefix-limit/direction-list[direction='out']",
8225 bgp_afi_safi_get_container_str(afi
, safi
));
8226 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8228 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
8230 return nb_cli_apply_changes(vty
, base_xpath
);
8233 /* Maximum number of prefix configuration. Prefix count is different
8234 for each peer configuration. So this configuration can be set for
8235 each peer configuration. */
8236 DEFUN_YANG(neighbor_maximum_prefix
,
8237 neighbor_maximum_prefix_cmd
,
8238 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8239 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8240 "Maximum number of prefix accept from this peer\n"
8241 "maximum no. of prefix limit\n"
8242 "Force checking all received routes not only accepted\n")
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
);
8269 if (argv_find(argv
, argc
, "force", &idx_force
))
8270 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8273 return nb_cli_apply_changes(vty
, base_xpath
);
8276 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8277 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8278 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8279 "Maximum number of prefix accept from this peer\n"
8280 "maximum no. of prefix limit\n"
8281 "Force checking all received routes not only accepted\n")
8283 DEFUN_YANG(neighbor_maximum_prefix_threshold
,
8284 neighbor_maximum_prefix_threshold_cmd
,
8285 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8286 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8287 "Maximum number of prefix accept from this peer\n"
8288 "maximum no. of prefix limit\n"
8289 "Threshold value (%) at which to generate a warning msg\n"
8290 "Force checking all received routes not only accepted\n")
8294 int idx_number_2
= 4;
8296 char base_xpath
[XPATH_MAXLEN
];
8297 char af_xpath
[XPATH_MAXLEN
];
8298 char attr_xpath
[XPATH_MAXLEN
];
8299 afi_t afi
= bgp_node_afi(vty
);
8300 safi_t safi
= bgp_node_safi(vty
);
8302 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8303 yang_afi_safi_value2identity(afi
, safi
));
8304 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8305 sizeof(base_xpath
), af_xpath
)
8307 return CMD_WARNING_CONFIG_FAILED
;
8309 snprintf(attr_xpath
, sizeof(attr_xpath
),
8310 "/%s/prefix-limit/direction-list[direction='in']",
8311 bgp_afi_safi_get_container_str(afi
, safi
));
8312 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8314 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8316 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8317 argv
[idx_number
]->arg
);
8319 nb_cli_enqueue_change(vty
, "./options/shutdown-threshold-pct",
8320 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8322 if (argv_find(argv
, argc
, "force", &idx_force
))
8323 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8326 return nb_cli_apply_changes(vty
, base_xpath
);
8330 neighbor_maximum_prefix_threshold
,
8331 neighbor_maximum_prefix_threshold_hidden_cmd
,
8332 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8333 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8334 "Maximum number of prefix accept from this peer\n"
8335 "maximum no. of prefix limit\n"
8336 "Threshold value (%) at which to generate a warning msg\n"
8337 "Force checking all received routes not only accepted\n")
8339 DEFUN_YANG(neighbor_maximum_prefix_warning
,
8340 neighbor_maximum_prefix_warning_cmd
,
8341 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8342 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8343 "Maximum number of prefix accept from this peer\n"
8344 "maximum no. of prefix limit\n"
8345 "Only give warning message when limit is exceeded\n"
8346 "Force checking all received routes not only accepted\n")
8351 char base_xpath
[XPATH_MAXLEN
];
8352 char af_xpath
[XPATH_MAXLEN
];
8353 char attr_xpath
[XPATH_MAXLEN
];
8354 afi_t afi
= bgp_node_afi(vty
);
8355 safi_t safi
= bgp_node_safi(vty
);
8357 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8358 yang_afi_safi_value2identity(afi
, safi
));
8359 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8360 sizeof(base_xpath
), af_xpath
)
8362 return CMD_WARNING_CONFIG_FAILED
;
8364 snprintf(attr_xpath
, sizeof(attr_xpath
),
8365 "/%s/prefix-limit/direction-list[direction='in']",
8366 bgp_afi_safi_get_container_str(afi
, safi
));
8367 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8369 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8371 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8372 argv
[idx_number
]->arg
);
8374 nb_cli_enqueue_change(vty
, "./options/warning-only", NB_OP_MODIFY
,
8376 if (argv_find(argv
, argc
, "force", &idx_force
))
8377 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8380 return nb_cli_apply_changes(vty
, base_xpath
);
8384 neighbor_maximum_prefix_warning
,
8385 neighbor_maximum_prefix_warning_hidden_cmd
,
8386 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8387 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8388 "Maximum number of prefix accept from this peer\n"
8389 "maximum no. of prefix limit\n"
8390 "Only give warning message when limit is exceeded\n"
8391 "Force checking all received routes not only accepted\n")
8393 DEFUN_YANG(neighbor_maximum_prefix_threshold_warning
,
8394 neighbor_maximum_prefix_threshold_warning_cmd
,
8395 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8396 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8397 "Maximum number of prefix accept from this peer\n"
8398 "maximum no. of prefix limit\n"
8399 "Threshold value (%) at which to generate a warning msg\n"
8400 "Only give warning message when limit is exceeded\n"
8401 "Force checking all received routes not only accepted\n")
8405 int idx_number_2
= 4;
8407 char base_xpath
[XPATH_MAXLEN
];
8408 char af_xpath
[XPATH_MAXLEN
];
8409 char attr_xpath
[XPATH_MAXLEN
];
8410 afi_t afi
= bgp_node_afi(vty
);
8411 safi_t safi
= bgp_node_safi(vty
);
8413 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8414 yang_afi_safi_value2identity(afi
, safi
));
8415 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8416 sizeof(base_xpath
), af_xpath
)
8418 return CMD_WARNING_CONFIG_FAILED
;
8420 snprintf(attr_xpath
, sizeof(attr_xpath
),
8421 "/%s/prefix-limit/direction-list[direction='in']",
8422 bgp_afi_safi_get_container_str(afi
, safi
));
8423 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8425 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8427 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8428 argv
[idx_number
]->arg
);
8429 nb_cli_enqueue_change(vty
, "./options/tw-shutdown-threshold-pct",
8430 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8431 nb_cli_enqueue_change(vty
, "./options/tw-warning-only", NB_OP_MODIFY
,
8433 if (argv_find(argv
, argc
, "force", &idx_force
))
8434 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8437 return nb_cli_apply_changes(vty
, base_xpath
);
8441 neighbor_maximum_prefix_threshold_warning
,
8442 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8443 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8444 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8445 "Maximum number of prefix accept from this peer\n"
8446 "maximum no. of prefix limit\n"
8447 "Threshold value (%) at which to generate a warning msg\n"
8448 "Only give warning message when limit is exceeded\n"
8449 "Force checking all received routes not only accepted\n")
8451 DEFUN_YANG(neighbor_maximum_prefix_restart
,
8452 neighbor_maximum_prefix_restart_cmd
,
8453 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8454 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8455 "Maximum number of prefix accept from this peer\n"
8456 "maximum no. of prefix limit\n"
8457 "Restart bgp connection after limit is exceeded\n"
8458 "Restart interval in minutes\n"
8459 "Force checking all received routes not only accepted\n")
8463 int idx_number_2
= 5;
8465 char base_xpath
[XPATH_MAXLEN
];
8466 char af_xpath
[XPATH_MAXLEN
];
8467 char attr_xpath
[XPATH_MAXLEN
];
8468 afi_t afi
= bgp_node_afi(vty
);
8469 safi_t safi
= bgp_node_safi(vty
);
8471 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8472 yang_afi_safi_value2identity(afi
, safi
));
8473 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8474 sizeof(base_xpath
), af_xpath
)
8476 return CMD_WARNING_CONFIG_FAILED
;
8478 snprintf(attr_xpath
, sizeof(attr_xpath
),
8479 "/%s/prefix-limit/direction-list[direction='in']",
8480 bgp_afi_safi_get_container_str(afi
, safi
));
8481 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8483 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8485 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8486 argv
[idx_number
]->arg
);
8487 nb_cli_enqueue_change(vty
, "./options/restart-timer", NB_OP_MODIFY
,
8488 argv
[idx_number_2
]->arg
);
8489 if (argv_find(argv
, argc
, "force", &idx_force
))
8490 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8493 return nb_cli_apply_changes(vty
, base_xpath
);
8497 neighbor_maximum_prefix_restart
,
8498 neighbor_maximum_prefix_restart_hidden_cmd
,
8499 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8500 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8501 "Maximum number of prefix accept from this peer\n"
8502 "maximum no. of prefix limit\n"
8503 "Restart bgp connection after limit is exceeded\n"
8504 "Restart interval in minutes\n"
8505 "Force checking all received routes not only accepted\n")
8507 DEFUN_YANG(neighbor_maximum_prefix_threshold_restart
,
8508 neighbor_maximum_prefix_threshold_restart_cmd
,
8509 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8510 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8511 "Maximum number of prefixes to accept from this peer\n"
8512 "maximum no. of prefix limit\n"
8513 "Threshold value (%) at which to generate a warning msg\n"
8514 "Restart bgp connection after limit is exceeded\n"
8515 "Restart interval in minutes\n"
8516 "Force checking all received routes not only accepted\n")
8520 int idx_number_2
= 4;
8521 int idx_number_3
= 6;
8523 char base_xpath
[XPATH_MAXLEN
];
8524 char af_xpath
[XPATH_MAXLEN
];
8525 char attr_xpath
[XPATH_MAXLEN
];
8526 afi_t afi
= bgp_node_afi(vty
);
8527 safi_t safi
= bgp_node_safi(vty
);
8529 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8530 yang_afi_safi_value2identity(afi
, safi
));
8531 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8532 sizeof(base_xpath
), af_xpath
)
8534 return CMD_WARNING_CONFIG_FAILED
;
8536 snprintf(attr_xpath
, sizeof(attr_xpath
),
8537 "/%s/prefix-limit/direction-list[direction='in']",
8538 bgp_afi_safi_get_container_str(afi
, safi
));
8539 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8541 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8543 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8544 argv
[idx_number
]->arg
);
8545 nb_cli_enqueue_change(vty
, "./options/tr-shutdown-threshold-pct",
8546 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8547 nb_cli_enqueue_change(vty
, "./options/tr-restart-timer", NB_OP_MODIFY
,
8548 argv
[idx_number_3
]->arg
);
8549 if (argv_find(argv
, argc
, "force", &idx_force
))
8550 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8553 return nb_cli_apply_changes(vty
, base_xpath
);
8557 neighbor_maximum_prefix_threshold_restart
,
8558 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8559 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8560 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8561 "Maximum number of prefixes to accept from this peer\n"
8562 "maximum no. of prefix limit\n"
8563 "Threshold value (%) at which to generate a warning msg\n"
8564 "Restart bgp connection after limit is exceeded\n"
8565 "Restart interval in minutes\n"
8566 "Force checking all received routes not only accepted\n")
8568 DEFUN_YANG(no_neighbor_maximum_prefix
,
8569 no_neighbor_maximum_prefix_cmd
,
8570 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8571 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8572 "Maximum number of prefixes to accept from this peer\n"
8573 "maximum no. of prefix limit\n"
8574 "Threshold value (%) at which to generate a warning msg\n"
8575 "Restart bgp connection after limit is exceeded\n"
8576 "Restart interval in minutes\n"
8577 "Only give warning message when limit is exceeded\n"
8578 "Force checking all received routes not only accepted\n")
8581 char base_xpath
[XPATH_MAXLEN
];
8582 char af_xpath
[XPATH_MAXLEN
];
8583 char attr_xpath
[XPATH_MAXLEN
];
8584 afi_t afi
= bgp_node_afi(vty
);
8585 safi_t safi
= bgp_node_safi(vty
);
8587 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8588 yang_afi_safi_value2identity(afi
, safi
));
8589 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8590 sizeof(base_xpath
), af_xpath
)
8592 return CMD_WARNING_CONFIG_FAILED
;
8594 snprintf(attr_xpath
, sizeof(attr_xpath
),
8595 "/%s/prefix-limit/direction-list[direction='in']",
8596 bgp_afi_safi_get_container_str(afi
, safi
));
8597 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8599 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
8601 return nb_cli_apply_changes(vty
, base_xpath
);
8605 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8606 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8607 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8608 "Maximum number of prefixes to accept from this peer\n"
8609 "maximum no. of prefix limit\n"
8610 "Threshold value (%) at which to generate a warning msg\n"
8611 "Restart bgp connection after limit is exceeded\n"
8612 "Restart interval in minutes\n"
8613 "Only give warning message when limit is exceeded\n"
8614 "Force checking all received routes not only accepted\n")
8617 /* "neighbor allowas-in" */
8618 DEFUN (neighbor_allowas_in
,
8619 neighbor_allowas_in_cmd
,
8620 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8623 "Accept as-path with my AS present in it\n"
8624 "Number of occurrences of AS number\n"
8625 "Only accept my AS in the as-path if the route was originated in my AS\n")
8628 int idx_number_origin
= 3;
8634 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8636 return CMD_WARNING_CONFIG_FAILED
;
8638 if (argc
<= idx_number_origin
)
8641 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8644 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8647 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8650 return bgp_vty_return(vty
, ret
);
8654 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8655 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8656 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8657 "Accept as-path with my AS present in it\n"
8658 "Number of occurrences of AS number\n"
8659 "Only accept my AS in the as-path if the route was originated in my AS\n")
8661 DEFUN (no_neighbor_allowas_in
,
8662 no_neighbor_allowas_in_cmd
,
8663 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8667 "allow local ASN appears in aspath attribute\n"
8668 "Number of occurrences of AS number\n"
8669 "Only accept my AS in the as-path if the route was originated in my AS\n")
8675 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8677 return CMD_WARNING_CONFIG_FAILED
;
8679 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8680 bgp_node_safi(vty
));
8682 return bgp_vty_return(vty
, ret
);
8686 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8687 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8688 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8689 "allow local ASN appears in aspath attribute\n"
8690 "Number of occurrences of AS number\n"
8691 "Only accept my AS in the as-path if the route was originated in my AS\n")
8693 DEFUN_YANG (neighbor_ttl_security
,
8694 neighbor_ttl_security_cmd
,
8695 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8698 "BGP ttl-security parameters\n"
8699 "Specify the maximum number of hops to the BGP peer\n"
8700 "Number of hops to BGP peer\n")
8704 char base_xpath
[XPATH_MAXLEN
];
8706 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8707 sizeof(base_xpath
), NULL
)
8709 return CMD_WARNING_CONFIG_FAILED
;
8711 nb_cli_enqueue_change(vty
, "./ttl-security", NB_OP_MODIFY
,
8712 argv
[idx_number
]->arg
);
8714 return nb_cli_apply_changes(vty
, base_xpath
);
8717 DEFUN_YANG(no_neighbor_ttl_security
,
8718 no_neighbor_ttl_security_cmd
,
8719 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8720 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8721 "BGP ttl-security parameters\n"
8722 "Specify the maximum number of hops to the BGP peer\n"
8723 "Number of hops to BGP peer\n")
8726 char base_xpath
[XPATH_MAXLEN
];
8728 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8729 sizeof(base_xpath
), NULL
)
8731 return CMD_WARNING_CONFIG_FAILED
;
8733 nb_cli_enqueue_change(vty
, "./ttl-security", NB_OP_DESTROY
, NULL
);
8735 return nb_cli_apply_changes(vty
, base_xpath
);
8738 DEFUN (neighbor_addpath_tx_all_paths
,
8739 neighbor_addpath_tx_all_paths_cmd
,
8740 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8743 "Use addpath to advertise all paths to a neighbor\n")
8748 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8750 return CMD_WARNING_CONFIG_FAILED
;
8752 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8757 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8758 neighbor_addpath_tx_all_paths_hidden_cmd
,
8759 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8760 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8761 "Use addpath to advertise all paths to a neighbor\n")
8763 DEFUN (no_neighbor_addpath_tx_all_paths
,
8764 no_neighbor_addpath_tx_all_paths_cmd
,
8765 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8769 "Use addpath to advertise all paths to a neighbor\n")
8774 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8776 return CMD_WARNING_CONFIG_FAILED
;
8778 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8779 != BGP_ADDPATH_ALL
) {
8781 "%% Peer not currently configured to transmit all paths.");
8782 return CMD_WARNING_CONFIG_FAILED
;
8785 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8791 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8792 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8793 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8794 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8795 "Use addpath to advertise all paths to a neighbor\n")
8797 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8798 neighbor_addpath_tx_bestpath_per_as_cmd
,
8799 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8802 "Use addpath to advertise the bestpath per each neighboring AS\n")
8807 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8809 return CMD_WARNING_CONFIG_FAILED
;
8811 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8812 BGP_ADDPATH_BEST_PER_AS
);
8817 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8818 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8819 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8820 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8821 "Use addpath to advertise the bestpath per each neighboring AS\n")
8823 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8824 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8825 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8829 "Use addpath to advertise the bestpath per each neighboring AS\n")
8834 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8836 return CMD_WARNING_CONFIG_FAILED
;
8838 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8839 != BGP_ADDPATH_BEST_PER_AS
) {
8841 "%% Peer not currently configured to transmit all best path per as.");
8842 return CMD_WARNING_CONFIG_FAILED
;
8845 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8851 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8852 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8853 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8854 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8855 "Use addpath to advertise the bestpath per each neighboring AS\n")
8858 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8859 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8862 "Detect AS loops before sending to neighbor\n")
8866 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8868 return CMD_WARNING_CONFIG_FAILED
;
8870 peer
->as_path_loop_detection
= true;
8876 no_neighbor_aspath_loop_detection
,
8877 no_neighbor_aspath_loop_detection_cmd
,
8878 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8882 "Detect AS loops before sending to neighbor\n")
8886 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8888 return CMD_WARNING_CONFIG_FAILED
;
8890 peer
->as_path_loop_detection
= false;
8895 DEFPY(neighbor_damp
,
8897 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor dampening [(1-45)$half [(1-20000)$reuse (1-20000)$suppress (1-255)$max]]",
8900 "Enable neighbor route-flap dampening\n"
8901 "Half-life time for the penalty\n"
8902 "Value to start reusing a route\n"
8903 "Value to start suppressing a route\n"
8904 "Maximum duration to suppress a stable route\n")
8906 struct peer
*peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8909 return CMD_WARNING_CONFIG_FAILED
;
8911 half
= DEFAULT_HALF_LIFE
;
8913 reuse
= DEFAULT_REUSE
;
8914 suppress
= DEFAULT_SUPPRESS
;
8917 if (suppress
< reuse
) {
8919 "Suppress value cannot be less than reuse value\n");
8920 return CMD_WARNING_CONFIG_FAILED
;
8922 bgp_peer_damp_enable(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8923 half
* 60, reuse
, suppress
, max
* 60);
8927 DEFPY(no_neighbor_damp
,
8928 no_neighbor_damp_cmd
,
8929 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor dampening [HALF [REUSE SUPPRESS MAX]]",
8933 "Enable neighbor route-flap dampening\n"
8934 "Half-life time for the penalty\n"
8935 "Value to start reusing a route\n"
8936 "Value to start suppressing a route\n"
8937 "Maximum duration to suppress a stable route\n")
8939 struct peer
*peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8942 return CMD_WARNING_CONFIG_FAILED
;
8943 bgp_peer_damp_disable(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
8947 DEFPY (show_ip_bgp_neighbor_damp_param
,
8948 show_ip_bgp_neighbor_damp_param_cmd
,
8949 "show [ip] bgp [<ipv4|ipv6> [unicast]] neighbors <A.B.C.D|X:X::X:X|WORD>$neighbor dampening parameters [json]$json",
8954 "Address Family modifier\n"
8957 "Neighbor route-flap dampening information\n"
8958 "Display detail of configured dampening parameters\n"
8961 bool use_json
= false;
8964 safi_t safi
= SAFI_UNICAST
;
8967 if (argv_find(argv
, argc
, "ip", &idx
))
8969 if (argv_find(argv
, argc
, "ipv4", &idx
))
8971 if (argv_find(argv
, argc
, "ipv6", &idx
))
8973 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8978 bgp_show_peer_dampening_parameters(vty
, peer
, afi
, safi
, use_json
);
8982 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8983 struct ecommunity
**list
, bool is_rt6
)
8985 struct ecommunity
*ecom
= NULL
;
8986 struct ecommunity
*ecomadd
;
8988 for (; argc
; --argc
, ++argv
) {
8990 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8991 ECOMMUNITY_ROUTE_TARGET
,
8994 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8995 ECOMMUNITY_ROUTE_TARGET
,
8998 vty_out(vty
, "Malformed community-list value\n");
9000 ecommunity_free(&ecom
);
9001 return CMD_WARNING_CONFIG_FAILED
;
9005 ecommunity_merge(ecom
, ecomadd
);
9006 ecommunity_free(&ecomadd
);
9013 ecommunity_free(&*list
);
9020 bool vpn_policy_check_import(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
9021 bool v2vimport
, char *errmsg
, size_t errmsg_len
)
9024 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9025 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
9026 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9027 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
9029 errmsg
, errmsg_len
, "%s",
9030 "%% error: Please unconfigure import vrf commands before using vpn commands");
9034 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9035 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
9036 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9037 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
9039 errmsg
, errmsg_len
, "%s",
9040 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands");
9048 * v2vimport is true if we are handling a `import vrf ...` command
9050 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
9054 switch (vty
->node
) {
9063 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
9068 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9069 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
9070 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9071 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
9073 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
9077 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9078 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
9079 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9080 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
9082 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
9091 af_rd_vpn_export_cmd
,
9092 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
9094 "Specify route distinguisher\n"
9095 "Between current address-family and vpn\n"
9096 "For routes leaked from current address-family to vpn\n"
9097 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
9099 char base_xpath
[XPATH_MAXLEN
];
9104 afi
= bgp_node_afi(vty
);
9105 safi
= bgp_node_safi(vty
);
9108 base_xpath
, sizeof(base_xpath
),
9109 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9110 yang_afi_safi_value2identity(afi
, safi
),
9111 bgp_afi_safi_get_container_str(afi
, safi
));
9113 if (argv_find(argv
, argc
, "no", &idx
))
9114 nb_cli_enqueue_change(vty
, "./rd", NB_OP_DESTROY
, NULL
);
9116 nb_cli_enqueue_change(vty
, "./rd", NB_OP_MODIFY
, rd_str
);
9118 return nb_cli_apply_changes(vty
, base_xpath
);
9121 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rd(
9122 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9126 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
9127 yang_dnode_get_string(dnode
, NULL
));
9130 ALIAS (af_rd_vpn_export
,
9131 af_no_rd_vpn_export_cmd
,
9134 "Specify route distinguisher\n"
9135 "Between current address-family and vpn\n"
9136 "For routes leaked from current address-family to vpn\n")
9138 DEFPY (af_label_vpn_export
,
9139 af_label_vpn_export_cmd
,
9140 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
9142 "label value for VRF\n"
9143 "Between current address-family and vpn\n"
9144 "For routes leaked from current address-family to vpn\n"
9145 "Label Value <0-1048575>\n"
9146 "Automatically assign a label\n")
9148 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9149 mpls_label_t label
= MPLS_LABEL_NONE
;
9154 if (argv_find(argv
, argc
, "no", &idx
))
9157 /* If "no ...", squash trailing parameter */
9163 label
= label_val
; /* parser should force unsigned */
9166 afi
= vpn_policy_getafi(vty
, bgp
, false);
9168 return CMD_WARNING_CONFIG_FAILED
;
9171 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9172 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
9177 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9179 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9180 bgp_get_default(), bgp
);
9182 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9183 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
9185 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
9188 * label has previously been automatically
9189 * assigned by labelpool: release it
9191 * NB if tovpn_label == MPLS_LABEL_NONE it
9192 * means the automatic assignment is in flight
9193 * and therefore the labelpool callback must
9194 * detect that the auto label is not needed.
9197 bgp_lp_release(LP_TYPE_VRF
,
9198 &bgp
->vpn_policy
[afi
],
9199 bgp
->vpn_policy
[afi
].tovpn_label
);
9201 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9202 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9205 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
9207 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9208 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9209 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
9210 vpn_leak_label_callback
);
9213 /* post-change: re-export vpn routes */
9214 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9215 bgp_get_default(), bgp
);
9217 hook_call(bgp_snmp_update_last_changed
, bgp
);
9221 ALIAS (af_label_vpn_export
,
9222 af_no_label_vpn_export_cmd
,
9223 "no label vpn export",
9225 "label value for VRF\n"
9226 "Between current address-family and vpn\n"
9227 "For routes leaked from current address-family to vpn\n")
9229 DEFPY_YANG (af_nexthop_vpn_export
,
9230 af_nexthop_vpn_export_cmd
,
9231 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
9233 "Specify next hop to use for VRF advertised prefixes\n"
9234 "Between current address-family and vpn\n"
9235 "For routes leaked from current address-family to vpn\n"
9239 char base_xpath
[XPATH_MAXLEN
];
9247 vty_out(vty
, "%% Nexthop required\n");
9248 return CMD_WARNING_CONFIG_FAILED
;
9250 if (!sockunion2hostprefix(nexthop_su
, &p
))
9251 return CMD_WARNING_CONFIG_FAILED
;
9254 afi
= bgp_node_afi(vty
);
9255 safi
= bgp_node_safi(vty
);
9258 base_xpath
, sizeof(base_xpath
),
9259 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9260 yang_afi_safi_value2identity(afi
, safi
),
9261 bgp_afi_safi_get_container_str(afi
, safi
));
9263 if (argv_find(argv
, argc
, "no", &idx
))
9264 nb_cli_enqueue_change(vty
, "./nexthop", NB_OP_DESTROY
, NULL
);
9266 nb_cli_enqueue_change(vty
, "./nexthop", NB_OP_MODIFY
,
9269 return nb_cli_apply_changes(vty
, base_xpath
);
9272 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_nexthop(
9273 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9277 vty_out(vty
, "%*snexthop vpn export %s\n", indent
, "",
9278 yang_dnode_get_string(dnode
, NULL
));
9281 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9283 if (!strcmp(dstr
, "import")) {
9284 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9285 } else if (!strcmp(dstr
, "export")) {
9286 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9287 } else if (!strcmp(dstr
, "both")) {
9288 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9289 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9291 vty_out(vty
, "%% direction parse error\n");
9292 return CMD_WARNING_CONFIG_FAILED
;
9297 DEFPY (af_rt_vpn_imexport
,
9298 af_rt_vpn_imexport_cmd
,
9299 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9301 "Specify route target list\n"
9302 "Specify route target list\n"
9303 "Between current address-family and vpn\n"
9304 "For routes leaked from vpn to current address-family: match any\n"
9305 "For routes leaked from current address-family to vpn: set\n"
9306 "both import: match any and export: set\n"
9307 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9309 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9311 struct ecommunity
*ecom
= NULL
;
9312 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9313 vpn_policy_direction_t dir
;
9318 if (argv_find(argv
, argc
, "no", &idx
))
9321 afi
= vpn_policy_getafi(vty
, bgp
, false);
9323 return CMD_WARNING_CONFIG_FAILED
;
9325 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9326 if (ret
!= CMD_SUCCESS
)
9330 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9331 vty_out(vty
, "%% Missing RTLIST\n");
9332 return CMD_WARNING_CONFIG_FAILED
;
9334 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9335 if (ret
!= CMD_SUCCESS
) {
9340 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9344 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9347 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9349 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9350 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9351 ecommunity_dup(ecom
);
9353 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9355 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9356 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9359 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9363 ecommunity_free(&ecom
);
9368 ALIAS (af_rt_vpn_imexport
,
9369 af_no_rt_vpn_imexport_cmd
,
9370 "no <rt|route-target> vpn <import|export|both>$direction_str",
9372 "Specify route target list\n"
9373 "Specify route target list\n"
9374 "Between current address-family and vpn\n"
9375 "For routes leaked from vpn to current address-family\n"
9376 "For routes leaked from current address-family to vpn\n"
9377 "both import and export\n")
9379 DEFPY_YANG (af_route_map_vpn_imexport
,
9380 af_route_map_vpn_imexport_cmd
,
9381 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9382 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9384 "Specify route map\n"
9385 "Between current address-family and vpn\n"
9386 "For routes leaked from vpn to current address-family\n"
9387 "For routes leaked from current address-family to vpn\n"
9388 "name of route-map\n")
9390 char base_xpath
[XPATH_MAXLEN
];
9395 afi
= bgp_node_afi(vty
);
9396 safi
= bgp_node_safi(vty
);
9399 base_xpath
, sizeof(base_xpath
),
9400 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9401 yang_afi_safi_value2identity(afi
, safi
),
9402 bgp_afi_safi_get_container_str(afi
, safi
));
9404 if (argv_find(argv
, argc
, "no", &idx
)) {
9405 if (!strcmp(direction_str
, "import"))
9406 nb_cli_enqueue_change(vty
, "./rmap-import",
9407 NB_OP_DESTROY
, NULL
);
9408 else if (!strcmp(direction_str
, "export"))
9409 nb_cli_enqueue_change(vty
, "./rmap-export",
9410 NB_OP_DESTROY
, NULL
);
9412 if (!strcmp(direction_str
, "import"))
9413 nb_cli_enqueue_change(vty
, "./rmap-import",
9414 NB_OP_MODIFY
, rmap_str
);
9415 if (!strcmp(direction_str
, "export"))
9416 nb_cli_enqueue_change(vty
, "./rmap-export",
9417 NB_OP_MODIFY
, rmap_str
);
9419 return nb_cli_apply_changes(vty
, base_xpath
);
9422 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_import(
9423 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9427 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
9428 yang_dnode_get_string(dnode
, NULL
));
9431 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_export(
9432 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9436 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
9437 yang_dnode_get_string(dnode
, NULL
));
9440 ALIAS (af_route_map_vpn_imexport
,
9441 af_no_route_map_vpn_imexport_cmd
,
9442 "no route-map vpn <import|export>$direction_str",
9444 "Specify route map\n"
9445 "Between current address-family and vpn\n"
9446 "For routes leaked from vpn to current address-family\n"
9447 "For routes leaked from current address-family to vpn\n")
9449 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9450 "import vrf route-map RMAP$rmap_str",
9451 "Import routes from another VRF\n"
9452 "Vrf routes being filtered\n"
9453 "Specify route map\n"
9454 "name of route-map\n")
9456 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9457 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9459 struct bgp
*bgp_default
;
9461 afi
= vpn_policy_getafi(vty
, bgp
, true);
9463 return CMD_WARNING_CONFIG_FAILED
;
9465 bgp_default
= bgp_get_default();
9470 /* Auto-create assuming the same AS */
9471 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9472 BGP_INSTANCE_TYPE_DEFAULT
);
9476 "VRF default is not configured as a bgp instance\n");
9481 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9483 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9484 XFREE(MTYPE_ROUTE_MAP_NAME
,
9485 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9486 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9487 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9488 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9489 route_map_lookup_warn_noexist(vty
, rmap_str
);
9490 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9493 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9494 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9496 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9501 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9502 "no import vrf route-map [RMAP$rmap_str]",
9504 "Import routes from another VRF\n"
9505 "Vrf routes being filtered\n"
9506 "Specify route map\n"
9507 "name of route-map\n")
9509 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9510 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9513 afi
= vpn_policy_getafi(vty
, bgp
, true);
9515 return CMD_WARNING_CONFIG_FAILED
;
9517 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9519 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9520 XFREE(MTYPE_ROUTE_MAP_NAME
,
9521 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9522 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9523 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9525 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9526 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9527 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9529 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9534 DEFPY_YANG(bgp_imexport_vrf
,
9535 bgp_imexport_vrf_cmd
,
9536 "[no] import vrf VIEWVRFNAME$import_name",
9538 "Import routes from another VRF\n"
9539 "VRF to import from\n"
9540 "The name of the VRF\n")
9542 char base_xpath
[XPATH_MAXLEN
];
9547 if (import_name
== NULL
) {
9548 vty_out(vty
, "%% Missing import name\n");
9552 if (strcmp(import_name
, "route-map") == 0) {
9553 vty_out(vty
, "%% Must include route-map name\n");
9557 afi
= bgp_node_afi(vty
);
9558 safi
= bgp_node_safi(vty
);
9561 base_xpath
, sizeof(base_xpath
),
9562 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vrf-list[vrf='%s']",
9563 yang_afi_safi_value2identity(afi
, safi
),
9564 bgp_afi_safi_get_container_str(afi
, safi
), import_name
);
9566 if (argv_find(argv
, argc
, "no", &idx
))
9567 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
9569 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
9571 return nb_cli_apply_changes(vty
, base_xpath
);
9574 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vrfs(
9575 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9577 vty_out(vty
, " import vrf %s\n",
9578 yang_dnode_get_string(dnode
, "./vrf"));
9581 /* This command is valid only in a bgp vrf instance or the default instance */
9582 DEFPY_YANG (bgp_imexport_vpn
,
9583 bgp_imexport_vpn_cmd
,
9584 "[no] <import|export>$direction_str vpn",
9586 "Import routes to this address-family\n"
9587 "Export routes from this address-family\n"
9588 "to/from default instance VPN RIB\n")
9590 char base_xpath
[XPATH_MAXLEN
];
9595 afi
= bgp_node_afi(vty
);
9596 safi
= bgp_node_safi(vty
);
9598 if (!strcmp(direction_str
, "import")) {
9600 base_xpath
, sizeof(base_xpath
),
9601 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vpn",
9602 yang_afi_safi_value2identity(afi
, safi
),
9603 bgp_afi_safi_get_container_str(afi
, safi
));
9604 } else if (!strcmp(direction_str
, "export")) {
9606 base_xpath
, sizeof(base_xpath
),
9607 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/export-vpn",
9608 yang_afi_safi_value2identity(afi
, safi
),
9609 bgp_afi_safi_get_container_str(afi
, safi
));
9611 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9612 return CMD_WARNING_CONFIG_FAILED
;
9615 if (argv_find(argv
, argc
, "no", &idx
))
9616 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
9618 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, "true");
9620 return nb_cli_apply_changes(vty
, base_xpath
);
9623 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vpn(
9624 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9626 if (yang_dnode_get_bool(dnode
, NULL
))
9627 vty_out(vty
, " import vpn\n");
9630 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_export_vpn(
9631 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9633 if (yang_dnode_get_bool(dnode
, NULL
))
9634 vty_out(vty
, " export vpn\n");
9637 DEFPY (af_routetarget_import
,
9638 af_routetarget_import_cmd
,
9639 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9641 "Specify route target list\n"
9642 "Specify route target list\n"
9643 "Specify route target list\n"
9644 "Specify route target list\n"
9645 "Flow-spec redirect type route target\n"
9646 "Import routes to this address-family\n"
9647 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9649 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9651 struct ecommunity
*ecom
= NULL
;
9653 int idx
= 0, idx_unused
= 0;
9657 if (argv_find(argv
, argc
, "no", &idx
))
9660 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9661 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9664 afi
= vpn_policy_getafi(vty
, bgp
, false);
9666 return CMD_WARNING_CONFIG_FAILED
;
9668 if (rt6
&& afi
!= AFI_IP6
)
9669 return CMD_WARNING_CONFIG_FAILED
;
9672 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9673 vty_out(vty
, "%% Missing RTLIST\n");
9674 return CMD_WARNING_CONFIG_FAILED
;
9676 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9677 if (ret
!= CMD_SUCCESS
)
9682 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9683 ecommunity_free(&bgp
->vpn_policy
[afi
]
9684 .import_redirect_rtlist
);
9685 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9686 ecommunity_dup(ecom
);
9688 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9689 ecommunity_free(&bgp
->vpn_policy
[afi
]
9690 .import_redirect_rtlist
);
9691 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9695 ecommunity_free(&ecom
);
9700 void cli_show_bgp_global_afi_safi_header(struct vty
*vty
,
9701 struct lyd_node
*dnode
,
9704 const char *af_name
;
9708 af_name
= yang_dnode_get_string(dnode
, "./afi-safi-name");
9709 yang_afi_safi_identity2value(af_name
, &afi
, &safi
);
9711 vty_out(vty
, " !\n address-family ");
9712 if (afi
== AFI_IP
) {
9713 if (safi
== SAFI_UNICAST
)
9714 vty_out(vty
, "ipv4 unicast");
9715 else if (safi
== SAFI_LABELED_UNICAST
)
9716 vty_out(vty
, "ipv4 labeled-unicast");
9717 else if (safi
== SAFI_MULTICAST
)
9718 vty_out(vty
, "ipv4 multicast");
9719 else if (safi
== SAFI_MPLS_VPN
)
9720 vty_out(vty
, "ipv4 vpn");
9721 else if (safi
== SAFI_ENCAP
)
9722 vty_out(vty
, "ipv4 encap");
9723 else if (safi
== SAFI_FLOWSPEC
)
9724 vty_out(vty
, "ipv4 flowspec");
9725 } else if (afi
== AFI_IP6
) {
9726 if (safi
== SAFI_UNICAST
)
9727 vty_out(vty
, "ipv6 unicast");
9728 else if (safi
== SAFI_LABELED_UNICAST
)
9729 vty_out(vty
, "ipv6 labeled-unicast");
9730 else if (safi
== SAFI_MULTICAST
)
9731 vty_out(vty
, "ipv6 multicast");
9732 else if (safi
== SAFI_MPLS_VPN
)
9733 vty_out(vty
, "ipv6 vpn");
9734 else if (safi
== SAFI_ENCAP
)
9735 vty_out(vty
, "ipv6 encap");
9736 else if (safi
== SAFI_FLOWSPEC
)
9737 vty_out(vty
, "ipv6 flowspec");
9738 } else if (afi
== AFI_L2VPN
) {
9739 if (safi
== SAFI_EVPN
)
9740 vty_out(vty
, "l2vpn evpn");
9745 DEFUN_NOSH (address_family_ipv4_safi
,
9746 address_family_ipv4_safi_cmd
,
9747 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9748 "Enter Address Family command mode\n"
9750 BGP_SAFI_WITH_LABEL_HELP_STR
)
9753 safi_t safi
= SAFI_UNICAST
;
9754 const struct lyd_node
*vrf_dnode
, *bgp_glb_dnode
;
9755 const char *vrf_name
= NULL
;
9758 safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9760 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
9762 vrf_dnode
= yang_dnode_get_parent(bgp_glb_dnode
,
9763 "control-plane-protocol");
9764 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
9766 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
)
9767 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9768 && safi
!= SAFI_EVPN
) {
9770 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9771 return CMD_WARNING_CONFIG_FAILED
;
9774 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9779 DEFUN_NOSH (address_family_ipv6_safi
,
9780 address_family_ipv6_safi_cmd
,
9781 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9782 "Enter Address Family command mode\n"
9784 BGP_SAFI_WITH_LABEL_HELP_STR
)
9786 safi_t safi
= SAFI_UNICAST
;
9787 const struct lyd_node
*vrf_dnode
, *bgp_glb_dnode
;
9788 const char *vrf_name
= NULL
;
9791 safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9792 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
9794 vrf_dnode
= yang_dnode_get_parent(bgp_glb_dnode
,
9795 "control-plane-protocol");
9796 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
9798 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
)
9799 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9800 && safi
!= SAFI_EVPN
) {
9802 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9803 return CMD_WARNING_CONFIG_FAILED
;
9806 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9811 #ifdef KEEP_OLD_VPN_COMMANDS
9812 DEFUN_NOSH (address_family_vpnv4
,
9813 address_family_vpnv4_cmd
,
9814 "address-family vpnv4 [unicast]",
9815 "Enter Address Family command mode\n"
9817 "Address Family modifier\n")
9819 vty
->node
= BGP_VPNV4_NODE
;
9823 DEFUN_NOSH (address_family_vpnv6
,
9824 address_family_vpnv6_cmd
,
9825 "address-family vpnv6 [unicast]",
9826 "Enter Address Family command mode\n"
9828 "Address Family modifier\n")
9830 vty
->node
= BGP_VPNV6_NODE
;
9833 #endif /* KEEP_OLD_VPN_COMMANDS */
9835 DEFUN_NOSH (address_family_evpn
,
9836 address_family_evpn_cmd
,
9837 "address-family l2vpn evpn",
9838 "Enter Address Family command mode\n"
9840 "Address Family modifier\n")
9842 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9843 vty
->node
= BGP_EVPN_NODE
;
9847 DEFUN_NOSH (exit_address_family
,
9848 exit_address_family_cmd
,
9849 "exit-address-family",
9850 "Exit from Address Family configuration mode\n")
9852 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9853 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9854 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9855 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9856 || vty
->node
== BGP_EVPN_NODE
9857 || vty
->node
== BGP_FLOWSPECV4_NODE
9858 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9859 vty
->node
= BGP_NODE
;
9863 void cli_show_bgp_global_afi_safi_header_end(struct vty
*vty
,
9864 struct lyd_node
*dnode
9865 __attribute__((__unused__
)))
9867 vty_out(vty
, " exit-address-family\n");
9870 /* Recalculate bestpath and re-advertise a prefix */
9871 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9872 const char *ip_str
, afi_t afi
, safi_t safi
,
9873 struct prefix_rd
*prd
)
9876 struct prefix match
;
9877 struct bgp_dest
*dest
;
9878 struct bgp_dest
*rm
;
9880 struct bgp_table
*table
;
9881 struct bgp_table
*rib
;
9883 /* BGP structure lookup. */
9885 bgp
= bgp_lookup_by_name(view_name
);
9887 vty_out(vty
, "%% Can't find BGP instance %s\n",
9892 bgp
= bgp_get_default();
9894 vty_out(vty
, "%% No BGP process is configured\n");
9899 /* Check IP address argument. */
9900 ret
= str2prefix(ip_str
, &match
);
9902 vty_out(vty
, "%% address is malformed\n");
9906 match
.family
= afi2family(afi
);
9907 rib
= bgp
->rib
[afi
][safi
];
9909 if (safi
== SAFI_MPLS_VPN
) {
9910 for (dest
= bgp_table_top(rib
); dest
;
9911 dest
= bgp_route_next(dest
)) {
9912 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9914 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9917 table
= bgp_dest_get_bgp_table_info(dest
);
9921 if ((rm
= bgp_node_match(table
, &match
)) != NULL
) {
9922 const struct prefix
*rm_p
=
9923 bgp_dest_get_prefix(rm
);
9925 if (rm_p
->prefixlen
== match
.prefixlen
) {
9927 BGP_NODE_USER_CLEAR
);
9928 bgp_process(bgp
, rm
, afi
, safi
);
9930 bgp_dest_unlock_node(rm
);
9934 if ((dest
= bgp_node_match(rib
, &match
)) != NULL
) {
9935 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9937 if (dest_p
->prefixlen
== match
.prefixlen
) {
9938 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9939 bgp_process(bgp
, dest
, afi
, safi
);
9941 bgp_dest_unlock_node(dest
);
9948 /* one clear bgp command to rule them all */
9949 DEFUN (clear_ip_bgp_all
,
9950 clear_ip_bgp_all_cmd
,
9951 "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>]",
9955 BGP_INSTANCE_HELP_STR
9958 BGP_SAFI_WITH_LABEL_HELP_STR
9959 "Address Family modifier\n"
9961 "BGP IPv4 neighbor to clear\n"
9962 "BGP IPv6 neighbor to clear\n"
9963 "BGP neighbor on interface to clear\n"
9964 "Clear peers with the AS number\n"
9965 "Clear all external peers\n"
9966 "Clear all members of peer-group\n"
9967 "BGP peer-group name\n"
9972 "Push out prefix-list ORF and do inbound soft reconfig\n"
9977 afi_t afi
= AFI_UNSPEC
;
9978 safi_t safi
= SAFI_UNSPEC
;
9979 enum clear_sort clr_sort
= clear_peer
;
9980 enum bgp_clear_type clr_type
;
9981 char *clr_arg
= NULL
;
9984 char errmsg
[BUFSIZ
] = {'\0'};
9987 /* clear [ip] bgp */
9988 if (argv_find(argv
, argc
, "ip", &idx
))
9991 /* [<vrf> VIEWVRFNAME] */
9992 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9993 vrf
= argv
[idx
+ 1]->arg
;
9995 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9997 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9998 /* [<view> VIEWVRFNAME] */
9999 vrf
= argv
[idx
+ 1]->arg
;
10002 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
10003 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
10004 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
10006 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
10007 if (argv_find(argv
, argc
, "*", &idx
)) {
10008 clr_sort
= clear_all
;
10009 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
10010 clr_sort
= clear_peer
;
10011 clr_arg
= argv
[idx
]->arg
;
10012 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
10013 clr_sort
= clear_peer
;
10014 clr_arg
= argv
[idx
]->arg
;
10015 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
10016 clr_sort
= clear_group
;
10018 clr_arg
= argv
[idx
]->arg
;
10019 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
10020 clr_sort
= clear_peer
;
10021 clr_arg
= argv
[idx
]->arg
;
10022 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
10023 clr_sort
= clear_peer
;
10024 clr_arg
= argv
[idx
]->arg
;
10025 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
10026 clr_sort
= clear_as
;
10027 clr_arg
= argv
[idx
]->arg
;
10028 } else if (argv_find(argv
, argc
, "external", &idx
)) {
10029 clr_sort
= clear_external
;
10032 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
10033 if (argv_find(argv
, argc
, "soft", &idx
)) {
10034 if (argv_find(argv
, argc
, "in", &idx
)
10035 || argv_find(argv
, argc
, "out", &idx
))
10036 clr_type
= strmatch(argv
[idx
]->text
, "in")
10037 ? BGP_CLEAR_SOFT_IN
10038 : BGP_CLEAR_SOFT_OUT
;
10040 clr_type
= BGP_CLEAR_SOFT_BOTH
;
10041 } else if (argv_find(argv
, argc
, "in", &idx
)) {
10042 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
10043 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
10044 : BGP_CLEAR_SOFT_IN
;
10045 } else if (argv_find(argv
, argc
, "out", &idx
)) {
10046 clr_type
= BGP_CLEAR_SOFT_OUT
;
10048 clr_type
= BGP_CLEAR_SOFT_NONE
;
10050 ret
= bgp_clear_vty(vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
, errmsg
,
10053 vty_out(vty
, "Error description: %s\n", errmsg
);
10058 DEFUN (clear_ip_bgp_prefix
,
10059 clear_ip_bgp_prefix_cmd
,
10060 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
10064 BGP_INSTANCE_HELP_STR
10065 "Clear bestpath and re-advertise\n"
10069 char *prefix
= NULL
;
10073 /* [<view|vrf> VIEWVRFNAME] */
10074 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10075 vrf
= argv
[idx
+ 1]->arg
;
10077 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10079 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10080 /* [<view> VIEWVRFNAME] */
10081 vrf
= argv
[idx
+ 1]->arg
;
10085 prefix
= argv
[argc
- 1]->arg
;
10087 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
10090 DEFUN (clear_bgp_ipv6_safi_prefix
,
10091 clear_bgp_ipv6_safi_prefix_cmd
,
10092 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10098 "Clear bestpath and re-advertise\n"
10102 int idx_ipv6_prefix
= 0;
10103 safi_t safi
= SAFI_UNICAST
;
10104 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10105 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10107 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10108 return bgp_clear_prefix(
10109 vty
, NULL
, prefix
, AFI_IP6
,
10113 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
10114 clear_bgp_instance_ipv6_safi_prefix_cmd
,
10115 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10119 BGP_INSTANCE_HELP_STR
10122 "Clear bestpath and re-advertise\n"
10126 int idx_vrfview
= 0;
10127 int idx_ipv6_prefix
= 0;
10128 safi_t safi
= SAFI_UNICAST
;
10129 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10130 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10131 char *vrfview
= NULL
;
10133 /* [<view|vrf> VIEWVRFNAME] */
10134 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
10135 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10136 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
10138 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
10139 /* [<view> VIEWVRFNAME] */
10140 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10142 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10144 return bgp_clear_prefix(
10145 vty
, vrfview
, prefix
,
10146 AFI_IP6
, safi
, NULL
);
10149 DEFUN (show_bgp_views
,
10150 show_bgp_views_cmd
,
10151 "show [ip] bgp views",
10155 "Show the defined BGP views\n")
10157 struct list
*inst
= bm
->bgp
;
10158 struct listnode
*node
;
10161 vty_out(vty
, "Defined BGP views:\n");
10162 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10164 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10166 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
10170 return CMD_SUCCESS
;
10173 DEFUN (show_bgp_vrfs
,
10175 "show [ip] bgp vrfs [json]",
10182 char buf
[ETHER_ADDR_STRLEN
];
10183 struct list
*inst
= bm
->bgp
;
10184 struct listnode
*node
;
10186 bool uj
= use_json(argc
, argv
);
10187 json_object
*json
= NULL
;
10188 json_object
*json_vrfs
= NULL
;
10192 json
= json_object_new_object();
10193 json_vrfs
= json_object_new_object();
10196 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10197 const char *name
, *type
;
10199 struct listnode
*node2
, *nnode2
;
10200 int peers_cfg
, peers_estb
;
10201 json_object
*json_vrf
= NULL
;
10204 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10208 if (!uj
&& count
== 1) {
10210 "%4s %-5s %-16s %9s %10s %-37s\n",
10211 "Type", "Id", "routerId", "#PeersCfg",
10212 "#PeersEstb", "Name");
10213 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10214 "L3-VNI", "RouterMAC", "Interface");
10217 peers_cfg
= peers_estb
= 0;
10219 json_vrf
= json_object_new_object();
10222 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
10223 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10226 if (peer
->status
== Established
)
10230 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10231 name
= VRF_DEFAULT_NAME
;
10240 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10242 : (int64_t)bgp
->vrf_id
;
10243 char buf
[BUFSIZ
] = {0};
10245 json_object_string_add(json_vrf
, "type", type
);
10246 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
10247 json_object_string_add(json_vrf
, "routerId",
10249 &bgp
->router_id
, buf
,
10251 json_object_int_add(json_vrf
, "numConfiguredPeers",
10253 json_object_int_add(json_vrf
, "numEstablishedPeers",
10256 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
10257 json_object_string_add(
10259 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
10260 json_object_string_add(json_vrf
, "interface",
10261 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10263 json_object_object_add(json_vrfs
, name
, json_vrf
);
10265 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10267 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10268 : (int)bgp
->vrf_id
,
10269 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10270 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
10272 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
10273 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10279 json_object_object_add(json
, "vrfs", json_vrfs
);
10281 json_object_int_add(json
, "totalVrfs", count
);
10283 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10284 json
, JSON_C_TO_STRING_PRETTY
));
10285 json_object_free(json
);
10289 "\nTotal number of VRFs (including default): %d\n",
10293 return CMD_SUCCESS
;
10296 DEFUN (show_bgp_mac_hash
,
10297 show_bgp_mac_hash_cmd
,
10298 "show bgp mac hash",
10302 "Mac Address database\n")
10304 bgp_mac_dump_table(vty
);
10306 return CMD_SUCCESS
;
10309 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10311 struct vty
*vty
= (struct vty
*)args
;
10312 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10314 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10317 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10319 vty_out(vty
, "self nexthop database:\n");
10320 bgp_nexthop_show_address_hash(vty
, bgp
);
10322 vty_out(vty
, "Tunnel-ip database:\n");
10323 hash_iterate(bgp
->tip_hash
,
10324 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10328 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10329 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10330 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10331 "martian next-hops\n"
10332 "martian next-hop database\n")
10334 struct bgp
*bgp
= NULL
;
10338 /* [<vrf> VIEWVRFNAME] */
10339 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10340 name
= argv
[idx
+ 1]->arg
;
10341 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10343 } else if (argv_find(argv
, argc
, "view", &idx
))
10344 /* [<view> VIEWVRFNAME] */
10345 name
= argv
[idx
+ 1]->arg
;
10347 bgp
= bgp_lookup_by_name(name
);
10349 bgp
= bgp_get_default();
10352 vty_out(vty
, "%% No BGP process is configured\n");
10353 return CMD_WARNING
;
10355 bgp_show_martian_nexthops(vty
, bgp
);
10357 return CMD_SUCCESS
;
10360 DEFUN (show_bgp_memory
,
10361 show_bgp_memory_cmd
,
10362 "show [ip] bgp memory",
10366 "Global BGP memory statistics\n")
10368 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10369 unsigned long count
;
10371 /* RIB related usage stats */
10372 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10373 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10374 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10375 count
* sizeof(struct bgp_dest
)));
10377 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10378 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10379 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10380 count
* sizeof(struct bgp_path_info
)));
10381 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10382 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10385 memstrbuf
, sizeof(memstrbuf
),
10386 count
* sizeof(struct bgp_path_info_extra
)));
10388 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10389 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10390 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10391 count
* sizeof(struct bgp_static
)));
10393 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10394 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10395 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10396 count
* sizeof(struct bpacket
)));
10399 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10400 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10401 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10402 count
* sizeof(struct bgp_adj_in
)));
10403 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10404 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10405 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10406 count
* sizeof(struct bgp_adj_out
)));
10408 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10409 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10411 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10412 count
* sizeof(struct bgp_nexthop_cache
)));
10414 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10415 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10417 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10418 count
* sizeof(struct bgp_damp_info
)));
10421 count
= attr_count();
10422 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10423 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10424 count
* sizeof(struct attr
)));
10426 if ((count
= attr_unknown_count()))
10427 vty_out(vty
, "%ld unknown attributes\n", count
);
10429 /* AS_PATH attributes */
10430 count
= aspath_count();
10431 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10432 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10433 count
* sizeof(struct aspath
)));
10435 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10436 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10437 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10438 count
* sizeof(struct assegment
)));
10440 /* Other attributes */
10441 if ((count
= community_count()))
10442 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10443 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10444 count
* sizeof(struct community
)));
10445 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10446 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10447 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10448 count
* sizeof(struct ecommunity
)));
10449 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10451 "%ld BGP large-community entries, using %s of memory\n",
10452 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10453 count
* sizeof(struct lcommunity
)));
10455 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10456 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10457 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10458 count
* sizeof(struct cluster_list
)));
10460 /* Peer related usage */
10461 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10462 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10463 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10464 count
* sizeof(struct peer
)));
10466 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10467 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10468 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10469 count
* sizeof(struct peer_group
)));
10472 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10473 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10474 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10475 count
* sizeof(regex_t
)));
10476 return CMD_SUCCESS
;
10479 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10481 json_object
*bestpath
= json_object_new_object();
10483 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10484 json_object_string_add(bestpath
, "asPath", "ignore");
10486 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10487 json_object_string_add(bestpath
, "asPath", "confed");
10489 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10490 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10491 json_object_string_add(bestpath
, "multiPathRelax",
10494 json_object_string_add(bestpath
, "multiPathRelax",
10497 json_object_string_add(bestpath
, "multiPathRelax", "false");
10499 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10500 json_object_string_add(bestpath
, "compareRouterId", "true");
10501 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10502 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10503 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10504 json_object_string_add(bestpath
, "med", "confed");
10505 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10506 json_object_string_add(bestpath
, "med",
10507 "missing-as-worst");
10509 json_object_string_add(bestpath
, "med", "true");
10512 json_object_object_add(json
, "bestPath", bestpath
);
10515 /* Print the error code/subcode for why the peer is down */
10516 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10517 json_object
*json_peer
, bool use_json
)
10519 const char *code_str
;
10520 const char *subcode_str
;
10523 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10524 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10525 char errorcodesubcode_hexstr
[5];
10526 char errorcodesubcode_str
[256];
10528 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10529 subcode_str
= bgp_notify_subcode_str(
10531 peer
->notify
.subcode
);
10533 snprintf(errorcodesubcode_hexstr
,
10534 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10535 peer
->notify
.code
, peer
->notify
.subcode
);
10536 json_object_string_add(json_peer
,
10537 "lastErrorCodeSubcode",
10538 errorcodesubcode_hexstr
);
10539 snprintf(errorcodesubcode_str
, 255, "%s%s",
10540 code_str
, subcode_str
);
10541 json_object_string_add(json_peer
,
10542 "lastNotificationReason",
10543 errorcodesubcode_str
);
10544 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10545 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10546 && (peer
->notify
.subcode
10547 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10548 || peer
->notify
.subcode
10549 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10550 && peer
->notify
.length
) {
10552 const char *msg_str
;
10554 msg_str
= bgp_notify_admin_message(
10555 msgbuf
, sizeof(msgbuf
),
10556 (uint8_t *)peer
->notify
.data
,
10557 peer
->notify
.length
);
10559 json_object_string_add(
10561 "lastShutdownDescription",
10566 json_object_string_add(json_peer
, "lastResetDueTo",
10567 peer_down_str
[(int)peer
->last_reset
]);
10568 json_object_int_add(json_peer
, "lastResetCode",
10571 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10572 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10573 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10575 bgp_notify_subcode_str(peer
->notify
.code
,
10576 peer
->notify
.subcode
);
10577 vty_out(vty
, " Notification %s (%s%s)\n",
10578 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10581 code_str
, subcode_str
);
10583 vty_out(vty
, " %s\n",
10584 peer_down_str
[(int)peer
->last_reset
]);
10589 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10592 return ((peer
->status
!= Established
) ||
10593 !peer
->afc_recv
[afi
][safi
]);
10596 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10597 struct peer
*peer
, json_object
*json_peer
,
10598 int max_neighbor_width
, bool use_json
)
10600 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10604 if (peer_dynamic_neighbor(peer
))
10605 json_object_boolean_true_add(json_peer
,
10607 if (peer
->hostname
)
10608 json_object_string_add(json_peer
, "hostname",
10611 if (peer
->domainname
)
10612 json_object_string_add(json_peer
, "domainname",
10614 json_object_int_add(json_peer
, "connectionsEstablished",
10615 peer
->established
);
10616 json_object_int_add(json_peer
, "connectionsDropped",
10618 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10619 use_json
, json_peer
);
10620 if (peer
->status
== Established
)
10621 json_object_string_add(json_peer
, "lastResetDueTo",
10622 "AFI/SAFI Not Negotiated");
10624 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10627 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10629 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10630 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10631 peer
->hostname
, peer
->host
);
10633 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10635 /* pad the neighbor column with spaces */
10636 if (len
< max_neighbor_width
)
10637 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10639 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10641 peer_uptime(peer
->uptime
, timebuf
,
10642 BGP_UPTIME_LEN
, 0, NULL
));
10643 if (peer
->status
== Established
)
10644 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10646 bgp_show_peer_reset(vty
, peer
, NULL
,
10651 /* If the peer's description includes whitespaces
10652 * then return the first occurrence. Also strip description
10653 * to the given size if needed.
10655 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10657 static char stripped
[BUFSIZ
];
10659 uint32_t len
= size
> strlen(desc
) ? strlen(desc
) : size
;
10661 pnt
= strchr(desc
, ' ');
10663 len
= size
> (uint32_t)(pnt
- desc
) ? (uint32_t)(pnt
- desc
)
10666 strlcpy(stripped
, desc
, len
+ 1);
10671 /* Show BGP peer's summary information. */
10672 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10673 uint8_t show_flags
)
10676 struct listnode
*node
, *nnode
;
10677 unsigned int count
= 0, dn_count
= 0;
10678 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10679 char neighbor_buf
[VTY_BUFSIZ
];
10680 int neighbor_col_default_width
= 16;
10681 int len
, failed_count
= 0;
10682 int max_neighbor_width
= 0;
10684 json_object
*json
= NULL
;
10685 json_object
*json_peer
= NULL
;
10686 json_object
*json_peers
= NULL
;
10687 struct peer_af
*paf
;
10688 struct bgp_filter
*filter
;
10689 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10690 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10691 bool show_established
=
10692 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10693 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10695 /* labeled-unicast routes are installed in the unicast table so in order
10697 * display the correct PfxRcd value we must look at SAFI_UNICAST
10700 if (safi
== SAFI_LABELED_UNICAST
)
10701 pfx_rcd_safi
= SAFI_UNICAST
;
10703 pfx_rcd_safi
= safi
;
10706 json
= json_object_new_object();
10707 json_peers
= json_object_new_object();
10708 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10709 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10712 if (peer
->afc
[afi
][safi
]) {
10713 /* See if we have at least a single failed peer */
10714 if (bgp_has_peer_failed(peer
, afi
, safi
))
10718 if (peer_dynamic_neighbor(peer
))
10723 /* Loop over all neighbors that will be displayed to determine
10725 * characters are needed for the Neighbor column
10727 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10728 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10731 if (peer
->afc
[afi
][safi
]) {
10732 memset(dn_flag
, '\0', sizeof(dn_flag
));
10733 if (peer_dynamic_neighbor(peer
))
10737 && CHECK_FLAG(bgp
->flags
,
10738 BGP_FLAG_SHOW_HOSTNAME
))
10739 snprintf(neighbor_buf
,
10740 sizeof(neighbor_buf
),
10741 "%s%s(%s) ", dn_flag
,
10742 peer
->hostname
, peer
->host
);
10744 snprintf(neighbor_buf
,
10745 sizeof(neighbor_buf
), "%s%s ",
10746 dn_flag
, peer
->host
);
10748 len
= strlen(neighbor_buf
);
10750 if (len
> max_neighbor_width
)
10751 max_neighbor_width
= len
;
10753 /* See if we have at least a single failed peer */
10754 if (bgp_has_peer_failed(peer
, afi
, safi
))
10760 /* Originally we displayed the Neighbor column as 16
10761 * characters wide so make that the default
10763 if (max_neighbor_width
< neighbor_col_default_width
)
10764 max_neighbor_width
= neighbor_col_default_width
;
10767 if (show_failed
&& !failed_count
) {
10769 json_object_int_add(json
, "failedPeersCount", 0);
10770 json_object_int_add(json
, "dynamicPeers", dn_count
);
10771 json_object_int_add(json
, "totalPeers", count
);
10773 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10774 json
, JSON_C_TO_STRING_PRETTY
));
10775 json_object_free(json
);
10777 vty_out(vty
, "%% No failed BGP neighbors found\n");
10778 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
10780 return CMD_SUCCESS
;
10783 count
= 0; /* Reset the value as its used again */
10784 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10785 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10788 if (!peer
->afc
[afi
][safi
])
10792 unsigned long ents
;
10793 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10796 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10798 : (int64_t)bgp
->vrf_id
;
10800 /* Usage summary and header */
10802 char buf
[BUFSIZ
] = {0};
10804 json_object_string_add(
10806 inet_ntop(AF_INET
, &bgp
->router_id
, buf
,
10808 json_object_int_add(json
, "as", bgp
->as
);
10809 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10810 json_object_string_add(
10813 == BGP_INSTANCE_TYPE_DEFAULT
)
10818 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10819 &bgp
->router_id
, bgp
->as
,
10820 bgp
->vrf_id
== VRF_UNKNOWN
10822 : (int)bgp
->vrf_id
);
10823 vty_out(vty
, "\n");
10826 if (bgp_update_delay_configured(bgp
)) {
10828 json_object_int_add(
10829 json
, "updateDelayLimit",
10830 bgp
->v_update_delay
);
10832 if (bgp
->v_update_delay
10833 != bgp
->v_establish_wait
)
10834 json_object_int_add(
10836 "updateDelayEstablishWait",
10837 bgp
->v_establish_wait
);
10839 if (bgp_update_delay_active(bgp
)) {
10840 json_object_string_add(
10842 "updateDelayFirstNeighbor",
10843 bgp
->update_delay_begin_time
);
10844 json_object_boolean_true_add(
10846 "updateDelayInProgress");
10848 if (bgp
->update_delay_over
) {
10849 json_object_string_add(
10851 "updateDelayFirstNeighbor",
10852 bgp
->update_delay_begin_time
);
10853 json_object_string_add(
10855 "updateDelayBestpathResumed",
10856 bgp
->update_delay_end_time
);
10857 json_object_string_add(
10859 "updateDelayZebraUpdateResume",
10860 bgp
->update_delay_zebra_resume_time
);
10861 json_object_string_add(
10863 "updateDelayPeerUpdateResume",
10864 bgp
->update_delay_peers_resume_time
);
10869 "Read-only mode update-delay limit: %d seconds\n",
10870 bgp
->v_update_delay
);
10871 if (bgp
->v_update_delay
10872 != bgp
->v_establish_wait
)
10874 " Establish wait: %d seconds\n",
10875 bgp
->v_establish_wait
);
10877 if (bgp_update_delay_active(bgp
)) {
10879 " First neighbor established: %s\n",
10880 bgp
->update_delay_begin_time
);
10882 " Delay in progress\n");
10884 if (bgp
->update_delay_over
) {
10886 " First neighbor established: %s\n",
10887 bgp
->update_delay_begin_time
);
10889 " Best-paths resumed: %s\n",
10890 bgp
->update_delay_end_time
);
10892 " zebra update resumed: %s\n",
10893 bgp
->update_delay_zebra_resume_time
);
10895 " peers update resumed: %s\n",
10896 bgp
->update_delay_peers_resume_time
);
10903 if (bgp_maxmed_onstartup_configured(bgp
)
10904 && bgp
->maxmed_active
)
10905 json_object_boolean_true_add(
10906 json
, "maxMedOnStartup");
10907 if (bgp
->v_maxmed_admin
)
10908 json_object_boolean_true_add(
10909 json
, "maxMedAdministrative");
10911 json_object_int_add(
10912 json
, "tableVersion",
10913 bgp_table_version(bgp
->rib
[afi
][safi
]));
10915 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10916 json_object_int_add(json
, "ribCount", ents
);
10917 json_object_int_add(
10919 ents
* sizeof(struct bgp_dest
));
10921 ents
= bgp
->af_peer_count
[afi
][safi
];
10922 json_object_int_add(json
, "peerCount", ents
);
10923 json_object_int_add(json
, "peerMemory",
10924 ents
* sizeof(struct peer
));
10926 if ((ents
= listcount(bgp
->group
))) {
10927 json_object_int_add(
10928 json
, "peerGroupCount", ents
);
10929 json_object_int_add(
10930 json
, "peerGroupMemory",
10931 ents
* sizeof(struct
10935 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10936 BGP_CONFIG_DAMPENING
))
10937 json_object_boolean_true_add(
10938 json
, "dampeningEnabled");
10940 if (bgp_maxmed_onstartup_configured(bgp
)
10941 && bgp
->maxmed_active
)
10943 "Max-med on-startup active\n");
10944 if (bgp
->v_maxmed_admin
)
10946 "Max-med administrative active\n");
10948 vty_out(vty
, "BGP table version %" PRIu64
"\n",
10949 bgp_table_version(bgp
->rib
[afi
][safi
]));
10951 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10953 "RIB entries %ld, using %s of memory\n",
10956 memstrbuf
, sizeof(memstrbuf
),
10961 /* Peer related usage */
10962 ents
= bgp
->af_peer_count
[afi
][safi
];
10963 vty_out(vty
, "Peers %ld, using %s of memory\n",
10966 memstrbuf
, sizeof(memstrbuf
),
10967 ents
* sizeof(struct peer
)));
10969 if ((ents
= listcount(bgp
->group
)))
10971 "Peer groups %ld, using %s of memory\n",
10976 ents
* sizeof(struct
10979 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10980 BGP_CONFIG_DAMPENING
))
10981 vty_out(vty
, "Dampening enabled.\n");
10982 vty_out(vty
, "\n");
10984 /* Subtract 8 here because 'Neighbor' is
10986 vty_out(vty
, "Neighbor");
10987 vty_out(vty
, "%*s", max_neighbor_width
- 8,
10991 BGP_SHOW_SUMMARY_HEADER_FAILED
);
10995 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
10996 : BGP_SHOW_SUMMARY_HEADER_ALL
);
11000 paf
= peer_af_find(peer
, afi
, safi
);
11001 filter
= &peer
->filter
[afi
][safi
];
11004 /* Works for both failed & successful cases */
11005 if (peer_dynamic_neighbor(peer
))
11012 bgp_has_peer_failed(peer
, afi
, safi
)) {
11013 json_peer
= json_object_new_object();
11014 bgp_show_failed_summary(vty
, bgp
, peer
,
11015 json_peer
, 0, use_json
);
11016 } else if (!show_failed
) {
11017 if (show_established
11018 && bgp_has_peer_failed(peer
, afi
, safi
))
11021 json_peer
= json_object_new_object();
11022 if (peer_dynamic_neighbor(peer
)) {
11023 json_object_boolean_true_add(json_peer
,
11027 if (peer
->hostname
)
11028 json_object_string_add(json_peer
, "hostname",
11031 if (peer
->domainname
)
11032 json_object_string_add(json_peer
, "domainname",
11035 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
11036 json_object_int_add(
11037 json_peer
, "localAs",
11038 peer
->change_local_as
11039 ? peer
->change_local_as
11041 json_object_int_add(json_peer
, "version", 4);
11042 json_object_int_add(json_peer
, "msgRcvd",
11043 PEER_TOTAL_RX(peer
));
11044 json_object_int_add(json_peer
, "msgSent",
11045 PEER_TOTAL_TX(peer
));
11047 atomic_size_t outq_count
, inq_count
;
11048 outq_count
= atomic_load_explicit(
11049 &peer
->obuf
->count
,
11050 memory_order_relaxed
);
11051 inq_count
= atomic_load_explicit(
11052 &peer
->ibuf
->count
,
11053 memory_order_relaxed
);
11055 json_object_int_add(json_peer
, "tableVersion",
11056 peer
->version
[afi
][safi
]);
11057 json_object_int_add(json_peer
, "outq",
11059 json_object_int_add(json_peer
, "inq",
11061 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
11062 use_json
, json_peer
);
11064 json_object_int_add(json_peer
, "pfxRcd",
11065 peer
->pcount
[afi
][pfx_rcd_safi
]);
11067 if (paf
&& PAF_SUBGRP(paf
))
11068 json_object_int_add(
11069 json_peer
, "pfxSnt",
11070 (PAF_SUBGRP(paf
))->scount
);
11072 json_object_int_add(json_peer
, "pfxSnt",
11075 /* BGP FSM state */
11076 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11077 || CHECK_FLAG(peer
->bgp
->flags
,
11078 BGP_FLAG_SHUTDOWN
))
11079 json_object_string_add(json_peer
,
11082 else if (peer
->afc_recv
[afi
][safi
])
11083 json_object_string_add(
11084 json_peer
, "state",
11085 lookup_msg(bgp_status_msg
,
11086 peer
->status
, NULL
));
11087 else if (CHECK_FLAG(
11089 PEER_STATUS_PREFIX_OVERFLOW
))
11090 json_object_string_add(json_peer
,
11094 json_object_string_add(
11095 json_peer
, "state",
11096 lookup_msg(bgp_status_msg
,
11097 peer
->status
, NULL
));
11099 /* BGP peer state */
11100 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11101 || CHECK_FLAG(peer
->bgp
->flags
,
11102 BGP_FLAG_SHUTDOWN
))
11103 json_object_string_add(json_peer
,
11106 else if (CHECK_FLAG(
11108 PEER_STATUS_PREFIX_OVERFLOW
))
11109 json_object_string_add(json_peer
,
11112 else if (CHECK_FLAG(peer
->flags
,
11113 PEER_FLAG_PASSIVE
))
11114 json_object_string_add(json_peer
,
11117 else if (CHECK_FLAG(peer
->sflags
,
11118 PEER_STATUS_NSF_WAIT
))
11119 json_object_string_add(json_peer
,
11122 else if (CHECK_FLAG(
11124 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11125 && (!bgp_inbound_policy_exists(peer
,
11127 || !bgp_outbound_policy_exists(
11129 json_object_string_add(json_peer
,
11133 json_object_string_add(
11134 json_peer
, "peerState", "OK");
11136 json_object_int_add(json_peer
, "connectionsEstablished",
11137 peer
->established
);
11138 json_object_int_add(json_peer
, "connectionsDropped",
11141 json_object_string_add(
11142 json_peer
, "desc", peer
->desc
);
11144 /* Avoid creating empty peer dicts in JSON */
11145 if (json_peer
== NULL
)
11149 json_object_string_add(json_peer
, "idType",
11151 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11152 json_object_string_add(json_peer
, "idType",
11154 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11155 json_object_string_add(json_peer
, "idType",
11157 json_object_object_add(json_peers
, peer
->host
,
11161 bgp_has_peer_failed(peer
, afi
, safi
)) {
11162 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11163 max_neighbor_width
,
11165 } else if (!show_failed
) {
11166 if (show_established
11167 && bgp_has_peer_failed(peer
, afi
, safi
))
11170 memset(dn_flag
, '\0', sizeof(dn_flag
));
11171 if (peer_dynamic_neighbor(peer
)) {
11176 && CHECK_FLAG(bgp
->flags
,
11177 BGP_FLAG_SHOW_HOSTNAME
))
11178 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11182 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11184 /* pad the neighbor column with spaces */
11185 if (len
< max_neighbor_width
)
11186 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11189 atomic_size_t outq_count
, inq_count
;
11190 outq_count
= atomic_load_explicit(
11191 &peer
->obuf
->count
,
11192 memory_order_relaxed
);
11193 inq_count
= atomic_load_explicit(
11194 &peer
->ibuf
->count
,
11195 memory_order_relaxed
);
11199 "4 %10u %10u %9u %9u %8" PRIu64
11202 peer
->change_local_as
11203 ? peer
->change_local_as
11205 PEER_TOTAL_RX(peer
),
11206 PEER_TOTAL_TX(peer
),
11207 peer
->version
[afi
][safi
],
11208 inq_count
, outq_count
,
11209 peer_uptime(peer
->uptime
,
11214 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11216 peer
->as
, PEER_TOTAL_RX(peer
),
11217 PEER_TOTAL_TX(peer
),
11218 peer
->version
[afi
][safi
],
11219 inq_count
, outq_count
,
11220 peer_uptime(peer
->uptime
,
11225 if (peer
->status
== Established
) {
11226 if (peer
->afc_recv
[afi
][safi
]) {
11229 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11230 && !bgp_inbound_policy_exists(
11232 vty_out(vty
, " %12s",
11241 vty_out(vty
, " NoNeg");
11244 if (paf
&& PAF_SUBGRP(paf
)) {
11247 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11248 && !bgp_outbound_policy_exists(
11250 vty_out(vty
, " %8s",
11259 vty_out(vty
, " NoNeg");
11262 if (CHECK_FLAG(peer
->flags
,
11263 PEER_FLAG_SHUTDOWN
)
11264 || CHECK_FLAG(peer
->bgp
->flags
,
11265 BGP_FLAG_SHUTDOWN
))
11266 vty_out(vty
, " Idle (Admin)");
11267 else if (CHECK_FLAG(
11269 PEER_STATUS_PREFIX_OVERFLOW
))
11270 vty_out(vty
, " Idle (PfxCt)");
11272 vty_out(vty
, " %12s",
11273 lookup_msg(bgp_status_msg
,
11274 peer
->status
, NULL
));
11276 vty_out(vty
, " %8u", 0);
11279 vty_out(vty
, " %s",
11280 bgp_peer_description_stripped(
11282 show_wide
? 64 : 20));
11284 vty_out(vty
, " N/A");
11285 vty_out(vty
, "\n");
11292 json_object_object_add(json
, "peers", json_peers
);
11293 json_object_int_add(json
, "failedPeers", failed_count
);
11294 json_object_int_add(json
, "totalPeers", count
);
11295 json_object_int_add(json
, "dynamicPeers", dn_count
);
11298 bgp_show_bestpath_json(bgp
, json
);
11300 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11301 json
, JSON_C_TO_STRING_PRETTY
));
11302 json_object_free(json
);
11305 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
11307 vty_out(vty
, "No %s neighbor is configured\n",
11308 get_afi_safi_str(afi
, safi
, false));
11312 vty_out(vty
, "* - dynamic neighbor\n");
11313 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11314 dn_count
, bgp
->dynamic_neighbors_limit
);
11318 return CMD_SUCCESS
;
11321 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11322 int safi
, uint8_t show_flags
)
11325 int afi_wildcard
= (afi
== AFI_MAX
);
11326 int safi_wildcard
= (safi
== SAFI_MAX
);
11327 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11328 bool nbr_output
= false;
11329 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11331 if (use_json
&& is_wildcard
)
11332 vty_out(vty
, "{\n");
11334 afi
= 1; /* AFI_IP */
11335 while (afi
< AFI_MAX
) {
11337 safi
= 1; /* SAFI_UNICAST */
11338 while (safi
< SAFI_MAX
) {
11339 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11344 * So limit output to those afi/safi
11346 * actualy have something interesting in
11351 vty_out(vty
, ",\n");
11355 vty_out(vty
, "\"%s\":",
11356 get_afi_safi_str(afi
,
11360 vty_out(vty
, "\n%s Summary:\n",
11361 get_afi_safi_str(afi
,
11366 bgp_show_summary(vty
, bgp
, afi
, safi
,
11370 if (!safi_wildcard
)
11378 if (use_json
&& is_wildcard
)
11379 vty_out(vty
, "}\n");
11380 else if (!nbr_output
) {
11382 vty_out(vty
, "{}\n");
11384 vty_out(vty
, "%% No BGP neighbors found\n");
11388 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11389 safi_t safi
, uint8_t show_flags
)
11391 struct listnode
*node
, *nnode
;
11394 bool nbr_output
= false;
11395 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11398 vty_out(vty
, "{\n");
11400 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11404 vty_out(vty
, ",\n");
11408 vty_out(vty
, "\"%s\":",
11409 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11413 vty_out(vty
, "\nInstance %s:\n",
11414 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11418 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_flags
);
11422 vty_out(vty
, "}\n");
11423 else if (!nbr_output
)
11424 vty_out(vty
, "%% BGP instance not found\n");
11427 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11428 safi_t safi
, uint8_t show_flags
)
11431 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11434 if (strmatch(name
, "all")) {
11435 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11437 return CMD_SUCCESS
;
11439 bgp
= bgp_lookup_by_name(name
);
11443 vty_out(vty
, "{}\n");
11446 "%% BGP instance not found\n");
11447 return CMD_WARNING
;
11450 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
,
11452 return CMD_SUCCESS
;
11456 bgp
= bgp_get_default();
11459 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_flags
);
11462 vty_out(vty
, "{}\n");
11464 vty_out(vty
, "%% BGP instance not found\n");
11465 return CMD_WARNING
;
11468 return CMD_SUCCESS
;
11471 /* `show [ip] bgp summary' commands. */
11472 DEFPY (show_ip_bgp_summary
,
11473 show_ip_bgp_summary_cmd
,
11474 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] [all$all] summary [established|failed] [wide] [json$uj]",
11478 BGP_INSTANCE_HELP_STR
11480 BGP_SAFI_WITH_LABEL_HELP_STR
11481 "Display the entries for all address families\n"
11482 "Summary of BGP neighbor status\n"
11483 "Show only sessions in Established state\n"
11484 "Show only sessions not in Established state\n"
11485 "Increase table width for longer output\n"
11489 afi_t afi
= AFI_MAX
;
11490 safi_t safi
= SAFI_MAX
;
11491 uint8_t show_flags
= 0;
11495 /* show [ip] bgp */
11496 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11498 /* [<vrf> VIEWVRFNAME] */
11499 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11500 vrf
= argv
[idx
+ 1]->arg
;
11501 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11503 } else if (argv_find(argv
, argc
, "view", &idx
))
11504 /* [<view> VIEWVRFNAME] */
11505 vrf
= argv
[idx
+ 1]->arg
;
11506 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11507 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11508 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11511 if (argv_find(argv
, argc
, "failed", &idx
))
11512 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11514 if (argv_find(argv
, argc
, "established", &idx
))
11515 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11517 if (argv_find(argv
, argc
, "wide", &idx
))
11518 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11520 if (argv_find(argv
, argc
, "json", &idx
))
11521 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11523 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, show_flags
);
11526 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11529 return get_afi_safi_json_str(afi
, safi
);
11531 return get_afi_safi_vty_str(afi
, safi
);
11535 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11536 afi_t afi
, safi_t safi
,
11537 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11538 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11539 bool use_json
, json_object
*json_pref
)
11542 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11543 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11545 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11546 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11547 json_object_string_add(json_pref
, "sendMode",
11548 "advertisedAndReceived");
11549 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11550 json_object_string_add(json_pref
, "sendMode",
11552 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11553 json_object_string_add(json_pref
, "sendMode",
11556 vty_out(vty
, " Send-mode: ");
11557 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11558 vty_out(vty
, "advertised");
11559 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11560 vty_out(vty
, "%sreceived",
11561 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11565 vty_out(vty
, "\n");
11570 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11571 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11573 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11574 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11575 json_object_string_add(json_pref
, "recvMode",
11576 "advertisedAndReceived");
11577 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11578 json_object_string_add(json_pref
, "recvMode",
11580 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11581 json_object_string_add(json_pref
, "recvMode",
11584 vty_out(vty
, " Receive-mode: ");
11585 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11586 vty_out(vty
, "advertised");
11587 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11588 vty_out(vty
, "%sreceived",
11589 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11593 vty_out(vty
, "\n");
11598 static void bgp_show_neighnor_graceful_restart_rbit(struct vty
*vty
,
11603 bool rbit_status
= false;
11606 vty_out(vty
, "\n R bit: ");
11608 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11609 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11610 && (p
->status
== Established
)) {
11612 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_BIT_RCV
))
11613 rbit_status
= true;
11615 rbit_status
= false;
11620 json_object_boolean_true_add(json
, "rBit");
11622 vty_out(vty
, "True\n");
11625 json_object_boolean_false_add(json
, "rBit");
11627 vty_out(vty
, "False\n");
11631 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11636 const char *mode
= "NotApplicable";
11639 vty_out(vty
, "\n Remote GR Mode: ");
11641 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11642 && (peer
->status
== Established
)) {
11644 if ((peer
->nsf_af_count
== 0)
11645 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11649 } else if (peer
->nsf_af_count
== 0
11650 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11654 } else if (peer
->nsf_af_count
!= 0
11655 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11662 json_object_string_add(json
, "remoteGrMode", mode
);
11664 vty_out(vty
, mode
, "\n");
11667 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11672 const char *mode
= "Invalid";
11675 vty_out(vty
, " Local GR Mode: ");
11677 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11679 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11681 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11683 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11684 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11686 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11688 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11695 json_object_string_add(json
, "localGrMode", mode
);
11697 vty_out(vty
, mode
, "\n");
11701 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11702 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11706 json_object
*json_afi_safi
= NULL
;
11707 json_object
*json_timer
= NULL
;
11708 json_object
*json_endofrib_status
= NULL
;
11709 bool eor_flag
= false;
11711 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11712 for (safi
= SAFI_UNICAST
; safi
<= SAFI_MPLS_VPN
; safi
++) {
11713 if (!peer
->afc
[afi
][safi
])
11716 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11717 || !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11721 json_afi_safi
= json_object_new_object();
11722 json_endofrib_status
= json_object_new_object();
11723 json_timer
= json_object_new_object();
11726 if (peer
->eor_stime
[afi
][safi
]
11727 >= peer
->pkt_stime
[afi
][safi
])
11733 vty_out(vty
, " %s:\n",
11734 get_afi_safi_str(afi
, safi
, false));
11736 vty_out(vty
, " F bit: ");
11739 if (peer
->nsf
[afi
][safi
]
11740 && CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11741 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11744 json_object_boolean_true_add(
11745 json_afi_safi
, "fBit");
11747 vty_out(vty
, "True\n");
11750 json_object_boolean_false_add(
11751 json_afi_safi
, "fBit");
11753 vty_out(vty
, "False\n");
11757 vty_out(vty
, " End-of-RIB sent: ");
11759 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11760 PEER_STATUS_EOR_SEND
)) {
11762 json_object_boolean_true_add(
11763 json_endofrib_status
,
11766 PRINT_EOR_JSON(eor_flag
);
11768 vty_out(vty
, "Yes\n");
11770 " End-of-RIB sent after update: ");
11772 PRINT_EOR(eor_flag
);
11776 json_object_boolean_false_add(
11777 json_endofrib_status
,
11779 json_object_boolean_false_add(
11780 json_endofrib_status
,
11781 "endOfRibSentAfterUpdate");
11783 vty_out(vty
, "No\n");
11785 " End-of-RIB sent after update: ");
11786 vty_out(vty
, "No\n");
11791 vty_out(vty
, " End-of-RIB received: ");
11793 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11794 PEER_STATUS_EOR_RECEIVED
)) {
11796 json_object_boolean_true_add(
11797 json_endofrib_status
,
11800 vty_out(vty
, "Yes\n");
11803 json_object_boolean_false_add(
11804 json_endofrib_status
,
11807 vty_out(vty
, "No\n");
11811 json_object_int_add(json_timer
,
11813 peer
->bgp
->stalepath_time
);
11815 if (peer
->t_gr_stale
!= NULL
) {
11816 json_object_int_add(
11818 "stalePathTimerRemaining",
11819 thread_timer_remain_second(
11820 peer
->t_gr_stale
));
11823 /* Display Configured Selection
11824 * Deferral only when when
11825 * Gr mode is enabled.
11827 if (CHECK_FLAG(peer
->flags
,
11828 PEER_FLAG_GRACEFUL_RESTART
)) {
11829 json_object_int_add(
11831 "selectionDeferralTimer",
11832 peer
->bgp
->stalepath_time
);
11835 if (peer
->bgp
->gr_info
[afi
][safi
]
11839 json_object_int_add(
11841 "selectionDeferralTimerRemaining",
11842 thread_timer_remain_second(
11846 .t_select_deferral
));
11849 vty_out(vty
, " Timers:\n");
11851 " Configured Stale Path Time(sec): %u\n",
11852 peer
->bgp
->stalepath_time
);
11854 if (peer
->t_gr_stale
!= NULL
)
11856 " Stale Path Remaining(sec): %ld\n",
11857 thread_timer_remain_second(
11858 peer
->t_gr_stale
));
11859 /* Display Configured Selection
11860 * Deferral only when when
11861 * Gr mode is enabled.
11863 if (CHECK_FLAG(peer
->flags
,
11864 PEER_FLAG_GRACEFUL_RESTART
))
11866 " Configured Selection Deferral Time(sec): %u\n",
11867 peer
->bgp
->select_defer_time
);
11869 if (peer
->bgp
->gr_info
[afi
][safi
]
11873 " Selection Deferral Time Remaining(sec): %ld\n",
11874 thread_timer_remain_second(
11878 .t_select_deferral
));
11881 json_object_object_add(json_afi_safi
,
11883 json_endofrib_status
);
11884 json_object_object_add(json_afi_safi
, "timers",
11886 json_object_object_add(
11887 json
, get_afi_safi_str(afi
, safi
, true),
11894 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
11900 json_object
*json_timer
= NULL
;
11902 json_timer
= json_object_new_object();
11904 json_object_int_add(json_timer
, "configuredRestartTimer",
11905 p
->bgp
->restart_time
);
11907 json_object_int_add(json_timer
, "receivedRestartTimer",
11910 if (p
->t_gr_restart
!= NULL
)
11911 json_object_int_add(
11912 json_timer
, "restartTimerRemaining",
11913 thread_timer_remain_second(p
->t_gr_restart
));
11915 json_object_object_add(json
, "timers", json_timer
);
11918 vty_out(vty
, " Timers:\n");
11919 vty_out(vty
, " Configured Restart Time(sec): %u\n",
11920 p
->bgp
->restart_time
);
11922 vty_out(vty
, " Received Restart Time(sec): %u\n",
11924 if (p
->t_gr_restart
!= NULL
)
11925 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11926 thread_timer_remain_second(p
->t_gr_restart
));
11927 if (p
->t_gr_restart
!= NULL
) {
11928 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11929 thread_timer_remain_second(p
->t_gr_restart
));
11934 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
11935 bool use_json
, json_object
*json
)
11937 char buf
[SU_ADDRSTRLEN
] = {0};
11938 char dn_flag
[2] = {0};
11939 /* '*' + v6 address of neighbor */
11940 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
11942 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11947 json_object_string_add(
11948 json
, "neighborAddr",
11949 BGP_PEER_SU_UNSPEC(p
)
11951 : sockunion2str(&p
->su
, buf
,
11954 vty_out(vty
, "BGP neighbor on %s: %s\n", p
->conf_if
,
11955 BGP_PEER_SU_UNSPEC(p
)
11957 : sockunion2str(&p
->su
, buf
,
11960 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
11964 json_object_string_add(json
, "neighborAddr",
11967 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
11970 /* more gr info in new format */
11971 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
11974 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
11975 safi_t safi
, bool use_json
,
11976 json_object
*json_neigh
)
11978 struct bgp_filter
*filter
;
11979 struct peer_af
*paf
;
11980 char orf_pfx_name
[BUFSIZ
];
11982 json_object
*json_af
= NULL
;
11983 json_object
*json_prefA
= NULL
;
11984 json_object
*json_prefB
= NULL
;
11985 json_object
*json_addr
= NULL
;
11986 json_object
*json_advmap
= NULL
;
11989 json_addr
= json_object_new_object();
11990 json_af
= json_object_new_object();
11991 filter
= &p
->filter
[afi
][safi
];
11993 if (peer_group_active(p
))
11994 json_object_string_add(json_addr
, "peerGroupMember",
11997 paf
= peer_af_find(p
, afi
, safi
);
11998 if (paf
&& PAF_SUBGRP(paf
)) {
11999 json_object_int_add(json_addr
, "updateGroupId",
12000 PAF_UPDGRP(paf
)->id
);
12001 json_object_int_add(json_addr
, "subGroupId",
12002 PAF_SUBGRP(paf
)->id
);
12003 json_object_int_add(json_addr
, "packetQueueLength",
12004 bpacket_queue_virtual_length(paf
));
12007 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12008 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12009 PEER_CAP_ORF_PREFIX_SM_RCV
)
12010 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12011 PEER_CAP_ORF_PREFIX_RM_ADV
)
12012 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12013 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12014 json_object_int_add(json_af
, "orfType",
12016 json_prefA
= json_object_new_object();
12017 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
12018 PEER_CAP_ORF_PREFIX_SM_ADV
,
12019 PEER_CAP_ORF_PREFIX_RM_ADV
,
12020 PEER_CAP_ORF_PREFIX_SM_RCV
,
12021 PEER_CAP_ORF_PREFIX_RM_RCV
,
12022 use_json
, json_prefA
);
12023 json_object_object_add(json_af
, "orfPrefixList",
12027 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12028 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12029 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12030 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12031 PEER_CAP_ORF_PREFIX_RM_ADV
)
12032 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12033 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12034 json_object_int_add(json_af
, "orfOldType",
12035 ORF_TYPE_PREFIX_OLD
);
12036 json_prefB
= json_object_new_object();
12037 bgp_show_peer_afi_orf_cap(
12038 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12039 PEER_CAP_ORF_PREFIX_RM_ADV
,
12040 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12041 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
12043 json_object_object_add(json_af
, "orfOldPrefixList",
12047 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12048 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12049 PEER_CAP_ORF_PREFIX_SM_RCV
)
12050 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12051 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12052 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12053 PEER_CAP_ORF_PREFIX_RM_ADV
)
12054 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12055 PEER_CAP_ORF_PREFIX_RM_RCV
)
12056 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12057 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12058 json_object_object_add(json_addr
, "afDependentCap",
12061 json_object_free(json_af
);
12063 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12064 p
->host
, afi
, safi
);
12065 orf_pfx_count
= prefix_bgp_show_prefix_list(
12066 NULL
, afi
, orf_pfx_name
, use_json
);
12068 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12069 PEER_STATUS_ORF_PREFIX_SEND
)
12070 || orf_pfx_count
) {
12071 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12072 PEER_STATUS_ORF_PREFIX_SEND
))
12073 json_object_boolean_true_add(json_neigh
,
12076 json_object_int_add(json_addr
, "orfRecvCounter",
12079 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12080 PEER_STATUS_ORF_WAIT_REFRESH
))
12081 json_object_string_add(
12082 json_addr
, "orfFirstUpdate",
12083 "deferredUntilORFOrRouteRefreshRecvd");
12085 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12086 PEER_FLAG_REFLECTOR_CLIENT
))
12087 json_object_boolean_true_add(json_addr
,
12088 "routeReflectorClient");
12089 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12090 PEER_FLAG_RSERVER_CLIENT
))
12091 json_object_boolean_true_add(json_addr
,
12092 "routeServerClient");
12093 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12094 json_object_boolean_true_add(json_addr
,
12095 "inboundSoftConfigPermit");
12097 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12098 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12099 json_object_boolean_true_add(
12101 "privateAsNumsAllReplacedInUpdatesToNbr");
12102 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12103 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12104 json_object_boolean_true_add(
12106 "privateAsNumsReplacedInUpdatesToNbr");
12107 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12108 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12109 json_object_boolean_true_add(
12111 "privateAsNumsAllRemovedInUpdatesToNbr");
12112 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12113 PEER_FLAG_REMOVE_PRIVATE_AS
))
12114 json_object_boolean_true_add(
12116 "privateAsNumsRemovedInUpdatesToNbr");
12118 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12119 json_object_boolean_true_add(
12121 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12124 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12125 json_object_string_add(json_addr
,
12126 "overrideASNsInOutboundUpdates",
12127 "ifAspathEqualRemoteAs");
12129 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12130 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12131 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12132 json_object_boolean_true_add(json_addr
,
12133 "routerAlwaysNextHop");
12134 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12135 PEER_FLAG_AS_PATH_UNCHANGED
))
12136 json_object_boolean_true_add(
12137 json_addr
, "unchangedAsPathPropogatedToNbr");
12138 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12139 PEER_FLAG_NEXTHOP_UNCHANGED
))
12140 json_object_boolean_true_add(
12141 json_addr
, "unchangedNextHopPropogatedToNbr");
12142 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12143 json_object_boolean_true_add(
12144 json_addr
, "unchangedMedPropogatedToNbr");
12145 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12146 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12147 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12148 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12149 PEER_FLAG_SEND_COMMUNITY
)
12150 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12151 PEER_FLAG_SEND_EXT_COMMUNITY
))
12152 json_object_string_add(json_addr
,
12153 "commAttriSentToNbr",
12154 "extendedAndStandard");
12155 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12156 PEER_FLAG_SEND_EXT_COMMUNITY
))
12157 json_object_string_add(json_addr
,
12158 "commAttriSentToNbr",
12161 json_object_string_add(json_addr
,
12162 "commAttriSentToNbr",
12165 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12166 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12167 if (p
->default_rmap
[afi
][safi
].name
)
12168 json_object_string_add(
12169 json_addr
, "defaultRouteMap",
12170 p
->default_rmap
[afi
][safi
].name
);
12172 if (paf
&& PAF_SUBGRP(paf
)
12173 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12174 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12175 json_object_boolean_true_add(json_addr
,
12178 json_object_boolean_true_add(json_addr
,
12182 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12183 if (is_evpn_enabled())
12184 json_object_boolean_true_add(
12185 json_addr
, "advertiseAllVnis");
12188 if (filter
->plist
[FILTER_IN
].name
12189 || filter
->dlist
[FILTER_IN
].name
12190 || filter
->aslist
[FILTER_IN
].name
12191 || filter
->map
[RMAP_IN
].name
)
12192 json_object_boolean_true_add(json_addr
,
12193 "inboundPathPolicyConfig");
12194 if (filter
->plist
[FILTER_OUT
].name
12195 || filter
->dlist
[FILTER_OUT
].name
12196 || filter
->aslist
[FILTER_OUT
].name
12197 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12198 json_object_boolean_true_add(
12199 json_addr
, "outboundPathPolicyConfig");
12202 if (filter
->plist
[FILTER_IN
].name
)
12203 json_object_string_add(json_addr
,
12204 "incomingUpdatePrefixFilterList",
12205 filter
->plist
[FILTER_IN
].name
);
12206 if (filter
->plist
[FILTER_OUT
].name
)
12207 json_object_string_add(json_addr
,
12208 "outgoingUpdatePrefixFilterList",
12209 filter
->plist
[FILTER_OUT
].name
);
12211 /* distribute-list */
12212 if (filter
->dlist
[FILTER_IN
].name
)
12213 json_object_string_add(
12214 json_addr
, "incomingUpdateNetworkFilterList",
12215 filter
->dlist
[FILTER_IN
].name
);
12216 if (filter
->dlist
[FILTER_OUT
].name
)
12217 json_object_string_add(
12218 json_addr
, "outgoingUpdateNetworkFilterList",
12219 filter
->dlist
[FILTER_OUT
].name
);
12222 if (filter
->aslist
[FILTER_IN
].name
)
12223 json_object_string_add(json_addr
,
12224 "incomingUpdateAsPathFilterList",
12225 filter
->aslist
[FILTER_IN
].name
);
12226 if (filter
->aslist
[FILTER_OUT
].name
)
12227 json_object_string_add(json_addr
,
12228 "outgoingUpdateAsPathFilterList",
12229 filter
->aslist
[FILTER_OUT
].name
);
12232 if (filter
->map
[RMAP_IN
].name
)
12233 json_object_string_add(
12234 json_addr
, "routeMapForIncomingAdvertisements",
12235 filter
->map
[RMAP_IN
].name
);
12236 if (filter
->map
[RMAP_OUT
].name
)
12237 json_object_string_add(
12238 json_addr
, "routeMapForOutgoingAdvertisements",
12239 filter
->map
[RMAP_OUT
].name
);
12241 /* ebgp-requires-policy (inbound) */
12242 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12243 && !bgp_inbound_policy_exists(p
, filter
))
12244 json_object_string_add(
12245 json_addr
, "inboundEbgpRequiresPolicy",
12246 "Inbound updates discarded due to missing policy");
12248 /* ebgp-requires-policy (outbound) */
12249 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12250 && (!bgp_outbound_policy_exists(p
, filter
)))
12251 json_object_string_add(
12252 json_addr
, "outboundEbgpRequiresPolicy",
12253 "Outbound updates discarded due to missing policy");
12255 /* unsuppress-map */
12256 if (filter
->usmap
.name
)
12257 json_object_string_add(json_addr
,
12258 "selectiveUnsuppressRouteMap",
12259 filter
->usmap
.name
);
12261 /* advertise-map */
12262 if (filter
->advmap
.aname
) {
12263 json_advmap
= json_object_new_object();
12264 json_object_string_add(json_advmap
, "condition",
12265 filter
->advmap
.condition
12268 json_object_string_add(json_advmap
, "conditionMap",
12269 filter
->advmap
.cname
);
12270 json_object_string_add(json_advmap
, "advertiseMap",
12271 filter
->advmap
.aname
);
12272 json_object_string_add(json_advmap
, "advertiseStatus",
12273 filter
->advmap
.update_type
12277 json_object_object_add(json_addr
, "advertiseMap",
12281 /* Receive prefix count */
12282 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12283 p
->pcount
[afi
][safi
]);
12284 if (paf
&& PAF_SUBGRP(paf
))
12285 json_object_int_add(json_addr
, "sentPrefixCounter",
12286 (PAF_SUBGRP(paf
))->scount
);
12288 /* Maximum prefix */
12289 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12290 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12291 p
->pmax_out
[afi
][safi
]);
12293 /* Maximum prefix */
12294 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12295 json_object_int_add(json_addr
, "prefixAllowedMax",
12296 p
->pmax
[afi
][safi
]);
12297 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12298 PEER_FLAG_MAX_PREFIX_WARNING
))
12299 json_object_boolean_true_add(
12300 json_addr
, "prefixAllowedMaxWarning");
12301 json_object_int_add(json_addr
,
12302 "prefixAllowedWarningThresh",
12303 p
->pmax_threshold
[afi
][safi
]);
12304 if (p
->pmax_restart
[afi
][safi
])
12305 json_object_int_add(
12307 "prefixAllowedRestartIntervalMsecs",
12308 p
->pmax_restart
[afi
][safi
] * 60000);
12310 json_object_object_add(json_neigh
,
12311 get_afi_safi_str(afi
, safi
, true),
12315 filter
= &p
->filter
[afi
][safi
];
12317 vty_out(vty
, " For address family: %s\n",
12318 get_afi_safi_str(afi
, safi
, false));
12320 if (peer_group_active(p
))
12321 vty_out(vty
, " %s peer-group member\n",
12324 paf
= peer_af_find(p
, afi
, safi
);
12325 if (paf
&& PAF_SUBGRP(paf
)) {
12326 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12327 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12328 vty_out(vty
, " Packet Queue length %d\n",
12329 bpacket_queue_virtual_length(paf
));
12331 vty_out(vty
, " Not part of any update group\n");
12333 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12334 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12335 PEER_CAP_ORF_PREFIX_SM_RCV
)
12336 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12337 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12338 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12339 PEER_CAP_ORF_PREFIX_RM_ADV
)
12340 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12341 PEER_CAP_ORF_PREFIX_RM_RCV
)
12342 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12343 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12344 vty_out(vty
, " AF-dependant capabilities:\n");
12346 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12347 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12348 PEER_CAP_ORF_PREFIX_SM_RCV
)
12349 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12350 PEER_CAP_ORF_PREFIX_RM_ADV
)
12351 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12352 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12354 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12356 bgp_show_peer_afi_orf_cap(
12357 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12358 PEER_CAP_ORF_PREFIX_RM_ADV
,
12359 PEER_CAP_ORF_PREFIX_SM_RCV
,
12360 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12362 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12363 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12364 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12365 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12366 PEER_CAP_ORF_PREFIX_RM_ADV
)
12367 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12368 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12370 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12371 ORF_TYPE_PREFIX_OLD
);
12372 bgp_show_peer_afi_orf_cap(
12373 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12374 PEER_CAP_ORF_PREFIX_RM_ADV
,
12375 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12376 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12379 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12380 p
->host
, afi
, safi
);
12381 orf_pfx_count
= prefix_bgp_show_prefix_list(
12382 NULL
, afi
, orf_pfx_name
, use_json
);
12384 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12385 PEER_STATUS_ORF_PREFIX_SEND
)
12386 || orf_pfx_count
) {
12387 vty_out(vty
, " Outbound Route Filter (ORF):");
12388 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12389 PEER_STATUS_ORF_PREFIX_SEND
))
12390 vty_out(vty
, " sent;");
12392 vty_out(vty
, " received (%d entries)",
12394 vty_out(vty
, "\n");
12396 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12397 PEER_STATUS_ORF_WAIT_REFRESH
))
12399 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12401 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12402 PEER_FLAG_REFLECTOR_CLIENT
))
12403 vty_out(vty
, " Route-Reflector Client\n");
12404 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12405 PEER_FLAG_RSERVER_CLIENT
))
12406 vty_out(vty
, " Route-Server Client\n");
12407 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12409 " Inbound soft reconfiguration allowed\n");
12411 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12412 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12414 " Private AS numbers (all) replaced in updates to this neighbor\n");
12415 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12416 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12418 " Private AS numbers replaced in updates to this neighbor\n");
12419 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12420 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12422 " Private AS numbers (all) removed in updates to this neighbor\n");
12423 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12424 PEER_FLAG_REMOVE_PRIVATE_AS
))
12426 " Private AS numbers removed in updates to this neighbor\n");
12428 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12429 vty_out(vty
, " %s\n",
12430 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12431 ->human_description
);
12433 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12435 " Override ASNs in outbound updates if aspath equals remote-as\n");
12437 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12438 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12439 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12440 vty_out(vty
, " NEXT_HOP is always this router\n");
12441 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12442 PEER_FLAG_AS_PATH_UNCHANGED
))
12444 " AS_PATH is propagated unchanged to this neighbor\n");
12445 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12446 PEER_FLAG_NEXTHOP_UNCHANGED
))
12448 " NEXT_HOP is propagated unchanged to this neighbor\n");
12449 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12451 " MED is propagated unchanged to this neighbor\n");
12452 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12453 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12454 PEER_FLAG_SEND_EXT_COMMUNITY
)
12455 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12456 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12458 " Community attribute sent to this neighbor");
12459 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12460 PEER_FLAG_SEND_COMMUNITY
)
12461 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12462 PEER_FLAG_SEND_EXT_COMMUNITY
)
12463 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12464 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12465 vty_out(vty
, "(all)\n");
12466 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12467 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12468 vty_out(vty
, "(large)\n");
12469 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12470 PEER_FLAG_SEND_EXT_COMMUNITY
))
12471 vty_out(vty
, "(extended)\n");
12473 vty_out(vty
, "(standard)\n");
12475 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12476 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12477 vty_out(vty
, " Default information originate,");
12479 if (p
->default_rmap
[afi
][safi
].name
)
12480 vty_out(vty
, " default route-map %s%s,",
12481 p
->default_rmap
[afi
][safi
].map
? "*"
12483 p
->default_rmap
[afi
][safi
].name
);
12484 if (paf
&& PAF_SUBGRP(paf
)
12485 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12486 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12487 vty_out(vty
, " default sent\n");
12489 vty_out(vty
, " default not sent\n");
12492 /* advertise-vni-all */
12493 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12494 if (is_evpn_enabled())
12495 vty_out(vty
, " advertise-all-vni\n");
12498 if (filter
->plist
[FILTER_IN
].name
12499 || filter
->dlist
[FILTER_IN
].name
12500 || filter
->aslist
[FILTER_IN
].name
12501 || filter
->map
[RMAP_IN
].name
)
12502 vty_out(vty
, " Inbound path policy configured\n");
12503 if (filter
->plist
[FILTER_OUT
].name
12504 || filter
->dlist
[FILTER_OUT
].name
12505 || filter
->aslist
[FILTER_OUT
].name
12506 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12507 vty_out(vty
, " Outbound path policy configured\n");
12510 if (filter
->plist
[FILTER_IN
].name
)
12512 " Incoming update prefix filter list is %s%s\n",
12513 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12514 filter
->plist
[FILTER_IN
].name
);
12515 if (filter
->plist
[FILTER_OUT
].name
)
12517 " Outgoing update prefix filter list is %s%s\n",
12518 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12519 filter
->plist
[FILTER_OUT
].name
);
12521 /* distribute-list */
12522 if (filter
->dlist
[FILTER_IN
].name
)
12524 " Incoming update network filter list is %s%s\n",
12525 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12526 filter
->dlist
[FILTER_IN
].name
);
12527 if (filter
->dlist
[FILTER_OUT
].name
)
12529 " Outgoing update network filter list is %s%s\n",
12530 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12531 filter
->dlist
[FILTER_OUT
].name
);
12534 if (filter
->aslist
[FILTER_IN
].name
)
12536 " Incoming update AS path filter list is %s%s\n",
12537 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12538 filter
->aslist
[FILTER_IN
].name
);
12539 if (filter
->aslist
[FILTER_OUT
].name
)
12541 " Outgoing update AS path filter list is %s%s\n",
12542 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12543 filter
->aslist
[FILTER_OUT
].name
);
12546 if (filter
->map
[RMAP_IN
].name
)
12548 " Route map for incoming advertisements is %s%s\n",
12549 filter
->map
[RMAP_IN
].map
? "*" : "",
12550 filter
->map
[RMAP_IN
].name
);
12551 if (filter
->map
[RMAP_OUT
].name
)
12553 " Route map for outgoing advertisements is %s%s\n",
12554 filter
->map
[RMAP_OUT
].map
? "*" : "",
12555 filter
->map
[RMAP_OUT
].name
);
12557 /* ebgp-requires-policy (inbound) */
12558 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12559 && !bgp_inbound_policy_exists(p
, filter
))
12561 " Inbound updates discarded due to missing policy\n");
12563 /* ebgp-requires-policy (outbound) */
12564 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12565 && !bgp_outbound_policy_exists(p
, filter
))
12567 " Outbound updates discarded due to missing policy\n");
12569 /* unsuppress-map */
12570 if (filter
->usmap
.name
)
12572 " Route map for selective unsuppress is %s%s\n",
12573 filter
->usmap
.map
? "*" : "",
12574 filter
->usmap
.name
);
12576 /* advertise-map */
12577 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12579 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12580 filter
->advmap
.condition
? "EXIST"
12582 filter
->advmap
.cmap
? "*" : "",
12583 filter
->advmap
.cname
,
12584 filter
->advmap
.amap
? "*" : "",
12585 filter
->advmap
.aname
,
12586 filter
->advmap
.update_type
== ADVERTISE
12590 /* Receive prefix count */
12591 vty_out(vty
, " %u accepted prefixes\n",
12592 p
->pcount
[afi
][safi
]);
12594 /* maximum-prefix-out */
12595 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12596 PEER_FLAG_MAX_PREFIX_OUT
))
12598 " Maximum allowed prefixes sent %u\n",
12599 p
->pmax_out
[afi
][safi
]);
12601 /* Maximum prefix */
12602 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12604 " Maximum prefixes allowed %u%s\n",
12605 p
->pmax
[afi
][safi
],
12606 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12607 PEER_FLAG_MAX_PREFIX_WARNING
)
12608 ? " (warning-only)"
12610 vty_out(vty
, " Threshold for warning message %d%%",
12611 p
->pmax_threshold
[afi
][safi
]);
12612 if (p
->pmax_restart
[afi
][safi
])
12613 vty_out(vty
, ", restart interval %d min",
12614 p
->pmax_restart
[afi
][safi
]);
12615 vty_out(vty
, "\n");
12618 vty_out(vty
, "\n");
12622 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12626 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
12627 char timebuf
[BGP_UPTIME_LEN
];
12633 json_object
*json_neigh
= NULL
;
12639 json_neigh
= json_object_new_object();
12641 memset(dn_flag
, '\0', sizeof(dn_flag
));
12642 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12646 if (p
->conf_if
) /* Configured interface name. */
12647 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
12648 BGP_PEER_SU_UNSPEC(p
)
12650 : sockunion2str(&p
->su
, buf
,
12652 else /* Configured IP address. */
12653 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12658 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12659 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12661 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12662 json_object_string_add(
12663 json_neigh
, "bgpNeighborAddr",
12664 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
12666 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12668 if (p
->change_local_as
)
12669 json_object_int_add(json_neigh
, "localAs",
12670 p
->change_local_as
);
12672 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12674 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12675 json_object_boolean_true_add(json_neigh
,
12676 "localAsNoPrepend");
12678 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12679 json_object_boolean_true_add(json_neigh
,
12680 "localAsReplaceAs");
12682 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12683 || (p
->as_type
== AS_INTERNAL
))
12684 vty_out(vty
, "remote AS %u, ", p
->as
);
12686 vty_out(vty
, "remote AS Unspecified, ");
12687 vty_out(vty
, "local AS %u%s%s, ",
12688 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12689 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12692 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12696 /* peer type internal or confed-internal */
12697 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12699 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12700 json_object_boolean_true_add(
12701 json_neigh
, "nbrConfedInternalLink");
12703 json_object_boolean_true_add(json_neigh
,
12704 "nbrInternalLink");
12706 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12707 vty_out(vty
, "confed-internal link\n");
12709 vty_out(vty
, "internal link\n");
12711 /* peer type external or confed-external */
12712 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12714 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12715 json_object_boolean_true_add(
12716 json_neigh
, "nbrConfedExternalLink");
12718 json_object_boolean_true_add(json_neigh
,
12719 "nbrExternalLink");
12721 if (bgp_confederation_peers_check(bgp
, p
->as
))
12722 vty_out(vty
, "confed-external link\n");
12724 vty_out(vty
, "external link\n");
12728 json_object_boolean_true_add(json_neigh
,
12729 "nbrUnspecifiedLink");
12731 vty_out(vty
, "unspecified link\n");
12737 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12739 vty_out(vty
, " Description: %s\n", p
->desc
);
12745 json_object_string_add(json_neigh
, "hostname",
12749 json_object_string_add(json_neigh
, "domainname",
12752 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12753 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12756 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12763 json_object_string_add(json_neigh
, "peerGroup",
12767 struct prefix prefix
, *range
= NULL
;
12769 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12770 range
= peer_group_lookup_dynamic_neighbor_range(
12771 p
->group
, &prefix
);
12774 prefix2str(range
, buf1
, sizeof(buf1
));
12775 json_object_string_add(
12777 "peerSubnetRangeGroup", buf1
);
12782 " Member of peer-group %s for session parameters\n",
12786 struct prefix prefix
, *range
= NULL
;
12788 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12789 range
= peer_group_lookup_dynamic_neighbor_range(
12790 p
->group
, &prefix
);
12794 " Belongs to the subnet range group: %pFX\n",
12802 /* Administrative shutdown. */
12803 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12804 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12805 json_object_boolean_true_add(json_neigh
,
12809 json_object_int_add(json_neigh
, "bgpVersion", 4);
12810 json_object_string_add(
12811 json_neigh
, "remoteRouterId",
12812 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12813 json_object_string_add(
12814 json_neigh
, "localRouterId",
12815 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12818 /* Confederation */
12819 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12820 && bgp_confederation_peers_check(bgp
, p
->as
))
12821 json_object_boolean_true_add(json_neigh
,
12825 json_object_string_add(
12826 json_neigh
, "bgpState",
12827 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12829 if (p
->status
== Established
) {
12832 uptime
= bgp_clock();
12833 uptime
-= p
->uptime
;
12834 epoch_tbuf
= time(NULL
) - uptime
;
12836 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
12838 json_object_string_add(json_neigh
, "bgpTimerUpString",
12839 peer_uptime(p
->uptime
, timebuf
,
12842 json_object_int_add(json_neigh
,
12843 "bgpTimerUpEstablishedEpoch",
12847 else if (p
->status
== Active
) {
12848 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12849 json_object_string_add(json_neigh
, "bgpStateIs",
12851 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12852 json_object_string_add(json_neigh
, "bgpStateIs",
12860 uptime
= bgp_clock();
12861 uptime
-= p
->readtime
;
12862 gmtime_r(&uptime
, &tm
);
12864 json_object_int_add(json_neigh
, "bgpTimerLastRead",
12865 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12866 + (tm
.tm_hour
* 3600000));
12868 uptime
= bgp_clock();
12869 uptime
-= p
->last_write
;
12870 gmtime_r(&uptime
, &tm
);
12872 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
12873 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12874 + (tm
.tm_hour
* 3600000));
12876 uptime
= bgp_clock();
12877 uptime
-= p
->update_time
;
12878 gmtime_r(&uptime
, &tm
);
12880 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
12881 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12882 + (tm
.tm_hour
* 3600000));
12884 /* Configured timer values. */
12885 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
12886 p
->v_holdtime
* 1000);
12887 json_object_int_add(json_neigh
,
12888 "bgpTimerKeepAliveIntervalMsecs",
12889 p
->v_keepalive
* 1000);
12890 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
12891 json_object_int_add(json_neigh
,
12892 "bgpTimerDelayOpenTimeMsecs",
12893 p
->v_delayopen
* 1000);
12896 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12897 json_object_int_add(json_neigh
,
12898 "bgpTimerConfiguredHoldTimeMsecs",
12899 p
->holdtime
* 1000);
12900 json_object_int_add(
12902 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12903 p
->keepalive
* 1000);
12904 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12905 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12906 json_object_int_add(json_neigh
,
12907 "bgpTimerConfiguredHoldTimeMsecs",
12908 bgp
->default_holdtime
);
12909 json_object_int_add(
12911 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12912 bgp
->default_keepalive
);
12915 /* Administrative shutdown. */
12916 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12917 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12918 vty_out(vty
, " Administratively shut down\n");
12921 vty_out(vty
, " BGP version 4");
12922 vty_out(vty
, ", remote router ID %s",
12923 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12924 vty_out(vty
, ", local router ID %s\n",
12925 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12928 /* Confederation */
12929 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12930 && bgp_confederation_peers_check(bgp
, p
->as
))
12932 " Neighbor under common administration\n");
12935 vty_out(vty
, " BGP state = %s",
12936 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12938 if (p
->status
== Established
)
12939 vty_out(vty
, ", up for %8s",
12940 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
12943 else if (p
->status
== Active
) {
12944 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12945 vty_out(vty
, " (passive)");
12946 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12947 vty_out(vty
, " (NSF passive)");
12949 vty_out(vty
, "\n");
12952 vty_out(vty
, " Last read %s",
12953 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
12955 vty_out(vty
, ", Last write %s\n",
12956 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
12959 /* Configured timer values. */
12961 " Hold time is %d, keepalive interval is %d seconds\n",
12962 p
->v_holdtime
, p
->v_keepalive
);
12963 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12964 vty_out(vty
, " Configured hold time is %d",
12966 vty_out(vty
, ", keepalive interval is %d seconds\n",
12968 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12969 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12970 vty_out(vty
, " Configured hold time is %d",
12971 bgp
->default_holdtime
);
12972 vty_out(vty
, ", keepalive interval is %d seconds\n",
12973 bgp
->default_keepalive
);
12975 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
12977 " Configured DelayOpenTime is %d seconds\n",
12981 if (p
->status
== Established
) {
12982 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
12983 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
12984 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
12985 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
12986 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
12987 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
12988 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
12989 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
12990 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
12991 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
12992 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
12993 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
12994 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
12995 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
12996 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
12997 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
12998 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
12999 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
13000 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
13001 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
13003 json_object
*json_cap
= NULL
;
13005 json_cap
= json_object_new_object();
13008 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
13009 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13010 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
13011 && CHECK_FLAG(p
->cap
,
13013 json_object_string_add(
13014 json_cap
, "4byteAs",
13015 "advertisedAndReceived");
13016 else if (CHECK_FLAG(p
->cap
,
13018 json_object_string_add(
13019 json_cap
, "4byteAs",
13021 else if (CHECK_FLAG(p
->cap
,
13023 json_object_string_add(
13024 json_cap
, "4byteAs",
13028 /* Extended Message Support */
13029 if (CHECK_FLAG(p
->cap
,
13030 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13033 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13034 json_object_string_add(
13035 json_cap
, "extendedMessage",
13036 "advertisedAndReceived");
13037 else if (CHECK_FLAG(
13039 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13040 json_object_string_add(
13041 json_cap
, "extendedMessage",
13043 else if (CHECK_FLAG(
13045 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13046 json_object_string_add(
13047 json_cap
, "extendedMessage",
13051 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
13052 || CHECK_FLAG(p
->cap
,
13053 PEER_CAP_ADDPATH_ADV
)) {
13054 json_object
*json_add
= NULL
;
13055 const char *print_store
;
13057 json_add
= json_object_new_object();
13059 FOREACH_AFI_SAFI (afi
, safi
) {
13060 json_object
*json_sub
= NULL
;
13062 json_object_new_object();
13063 print_store
= get_afi_safi_str(
13069 PEER_CAP_ADDPATH_AF_TX_ADV
)
13073 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13078 PEER_CAP_ADDPATH_AF_TX_ADV
)
13083 PEER_CAP_ADDPATH_AF_TX_RCV
))
13084 json_object_boolean_true_add(
13086 "txAdvertisedAndReceived");
13092 PEER_CAP_ADDPATH_AF_TX_ADV
))
13093 json_object_boolean_true_add(
13101 PEER_CAP_ADDPATH_AF_TX_RCV
))
13102 json_object_boolean_true_add(
13110 PEER_CAP_ADDPATH_AF_RX_ADV
)
13114 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13119 PEER_CAP_ADDPATH_AF_RX_ADV
)
13124 PEER_CAP_ADDPATH_AF_RX_RCV
))
13125 json_object_boolean_true_add(
13127 "rxAdvertisedAndReceived");
13133 PEER_CAP_ADDPATH_AF_RX_ADV
))
13134 json_object_boolean_true_add(
13142 PEER_CAP_ADDPATH_AF_RX_RCV
))
13143 json_object_boolean_true_add(
13151 PEER_CAP_ADDPATH_AF_TX_ADV
)
13155 PEER_CAP_ADDPATH_AF_TX_RCV
)
13159 PEER_CAP_ADDPATH_AF_RX_ADV
)
13163 PEER_CAP_ADDPATH_AF_RX_RCV
))
13164 json_object_object_add(
13173 json_object_object_add(
13174 json_cap
, "addPath", json_add
);
13178 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
13179 || CHECK_FLAG(p
->cap
,
13180 PEER_CAP_DYNAMIC_ADV
)) {
13181 if (CHECK_FLAG(p
->cap
,
13182 PEER_CAP_DYNAMIC_ADV
)
13183 && CHECK_FLAG(p
->cap
,
13184 PEER_CAP_DYNAMIC_RCV
))
13185 json_object_string_add(
13186 json_cap
, "dynamic",
13187 "advertisedAndReceived");
13188 else if (CHECK_FLAG(
13190 PEER_CAP_DYNAMIC_ADV
))
13191 json_object_string_add(
13192 json_cap
, "dynamic",
13194 else if (CHECK_FLAG(
13196 PEER_CAP_DYNAMIC_RCV
))
13197 json_object_string_add(
13198 json_cap
, "dynamic",
13202 /* Extended nexthop */
13203 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
13204 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13205 json_object
*json_nxt
= NULL
;
13206 const char *print_store
;
13209 if (CHECK_FLAG(p
->cap
,
13211 && CHECK_FLAG(p
->cap
,
13212 PEER_CAP_ENHE_RCV
))
13213 json_object_string_add(
13216 "advertisedAndReceived");
13217 else if (CHECK_FLAG(p
->cap
,
13218 PEER_CAP_ENHE_ADV
))
13219 json_object_string_add(
13223 else if (CHECK_FLAG(p
->cap
,
13224 PEER_CAP_ENHE_RCV
))
13225 json_object_string_add(
13230 if (CHECK_FLAG(p
->cap
,
13231 PEER_CAP_ENHE_RCV
)) {
13233 json_object_new_object();
13235 for (safi
= SAFI_UNICAST
;
13236 safi
< SAFI_MAX
; safi
++) {
13241 PEER_CAP_ENHE_AF_RCV
)) {
13242 print_store
= get_afi_safi_str(
13245 json_object_string_add(
13248 "recieved"); /* misspelled for compatibility */
13251 json_object_object_add(
13253 "extendedNexthopFamililesByPeer",
13258 /* Route Refresh */
13259 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
13260 || CHECK_FLAG(p
->cap
,
13261 PEER_CAP_REFRESH_NEW_RCV
)
13262 || CHECK_FLAG(p
->cap
,
13263 PEER_CAP_REFRESH_OLD_RCV
)) {
13264 if (CHECK_FLAG(p
->cap
,
13265 PEER_CAP_REFRESH_ADV
)
13268 PEER_CAP_REFRESH_NEW_RCV
)
13271 PEER_CAP_REFRESH_OLD_RCV
))) {
13274 PEER_CAP_REFRESH_OLD_RCV
)
13277 PEER_CAP_REFRESH_NEW_RCV
))
13278 json_object_string_add(
13281 "advertisedAndReceivedOldNew");
13285 PEER_CAP_REFRESH_OLD_RCV
))
13286 json_object_string_add(
13289 "advertisedAndReceivedOld");
13291 json_object_string_add(
13294 "advertisedAndReceivedNew");
13299 PEER_CAP_REFRESH_ADV
))
13300 json_object_string_add(
13307 PEER_CAP_REFRESH_NEW_RCV
)
13310 PEER_CAP_REFRESH_OLD_RCV
))
13311 json_object_string_add(
13317 /* Enhanced Route Refresh */
13318 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
)
13319 || CHECK_FLAG(p
->cap
,
13320 PEER_CAP_ENHANCED_RR_RCV
)) {
13321 if (CHECK_FLAG(p
->cap
,
13322 PEER_CAP_ENHANCED_RR_ADV
)
13325 PEER_CAP_ENHANCED_RR_RCV
))
13326 json_object_string_add(
13328 "enhancedRouteRefresh",
13329 "advertisedAndReceived");
13333 PEER_CAP_ENHANCED_RR_ADV
))
13334 json_object_string_add(
13336 "enhancedRouteRefresh",
13341 PEER_CAP_ENHANCED_RR_RCV
))
13342 json_object_string_add(
13344 "enhancedRouteRefresh",
13348 /* Multiprotocol Extensions */
13349 json_object
*json_multi
= NULL
;
13350 json_multi
= json_object_new_object();
13352 FOREACH_AFI_SAFI (afi
, safi
) {
13353 if (p
->afc_adv
[afi
][safi
]
13354 || p
->afc_recv
[afi
][safi
]) {
13355 json_object
*json_exten
= NULL
;
13357 json_object_new_object();
13359 if (p
->afc_adv
[afi
][safi
]
13360 && p
->afc_recv
[afi
][safi
])
13361 json_object_boolean_true_add(
13363 "advertisedAndReceived");
13364 else if (p
->afc_adv
[afi
][safi
])
13365 json_object_boolean_true_add(
13368 else if (p
->afc_recv
[afi
][safi
])
13369 json_object_boolean_true_add(
13373 json_object_object_add(
13375 get_afi_safi_str(afi
,
13381 json_object_object_add(
13382 json_cap
, "multiprotocolExtensions",
13385 /* Hostname capabilities */
13386 json_object
*json_hname
= NULL
;
13388 json_hname
= json_object_new_object();
13390 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13391 json_object_string_add(
13392 json_hname
, "advHostName",
13393 bgp
->peer_self
->hostname
13397 json_object_string_add(
13398 json_hname
, "advDomainName",
13399 bgp
->peer_self
->domainname
13406 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13407 json_object_string_add(
13408 json_hname
, "rcvHostName",
13409 p
->hostname
? p
->hostname
13411 json_object_string_add(
13412 json_hname
, "rcvDomainName",
13413 p
->domainname
? p
->domainname
13417 json_object_object_add(json_cap
, "hostName",
13420 /* Gracefull Restart */
13421 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
13422 || CHECK_FLAG(p
->cap
,
13423 PEER_CAP_RESTART_ADV
)) {
13424 if (CHECK_FLAG(p
->cap
,
13425 PEER_CAP_RESTART_ADV
)
13426 && CHECK_FLAG(p
->cap
,
13427 PEER_CAP_RESTART_RCV
))
13428 json_object_string_add(
13431 "advertisedAndReceived");
13432 else if (CHECK_FLAG(
13434 PEER_CAP_RESTART_ADV
))
13435 json_object_string_add(
13437 "gracefulRestartCapability",
13439 else if (CHECK_FLAG(
13441 PEER_CAP_RESTART_RCV
))
13442 json_object_string_add(
13444 "gracefulRestartCapability",
13447 if (CHECK_FLAG(p
->cap
,
13448 PEER_CAP_RESTART_RCV
)) {
13449 int restart_af_count
= 0;
13450 json_object
*json_restart
=
13453 json_object_new_object();
13455 json_object_int_add(
13457 "gracefulRestartRemoteTimerMsecs",
13458 p
->v_gr_restart
* 1000);
13460 FOREACH_AFI_SAFI (afi
, safi
) {
13465 PEER_CAP_RESTART_AF_RCV
)) {
13470 json_object_new_object();
13476 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13477 json_object_boolean_true_add(
13480 restart_af_count
++;
13481 json_object_object_add(
13490 if (!restart_af_count
) {
13491 json_object_string_add(
13493 "addressFamiliesByPeer",
13498 json_object_object_add(
13500 "addressFamiliesByPeer",
13504 json_object_object_add(json_neigh
,
13505 "neighborCapabilities",
13508 vty_out(vty
, " Neighbor capabilities:\n");
13511 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
13512 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13513 vty_out(vty
, " 4 Byte AS:");
13514 if (CHECK_FLAG(p
->cap
,
13516 vty_out(vty
, " advertised");
13517 if (CHECK_FLAG(p
->cap
,
13519 vty_out(vty
, " %sreceived",
13525 vty_out(vty
, "\n");
13528 /* Extended Message Support */
13529 if (CHECK_FLAG(p
->cap
,
13530 PEER_CAP_EXTENDED_MESSAGE_RCV
)
13533 PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13534 vty_out(vty
, " Extended Message:");
13537 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13538 vty_out(vty
, " advertised");
13541 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13542 vty_out(vty
, " %sreceived",
13545 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13548 vty_out(vty
, "\n");
13552 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
13553 || CHECK_FLAG(p
->cap
,
13554 PEER_CAP_ADDPATH_ADV
)) {
13555 vty_out(vty
, " AddPath:\n");
13557 FOREACH_AFI_SAFI (afi
, safi
) {
13561 PEER_CAP_ADDPATH_AF_TX_ADV
)
13565 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13577 PEER_CAP_ADDPATH_AF_TX_ADV
))
13589 PEER_CAP_ADDPATH_AF_TX_RCV
))
13596 PEER_CAP_ADDPATH_AF_TX_ADV
)
13600 vty_out(vty
, "\n");
13606 PEER_CAP_ADDPATH_AF_RX_ADV
)
13610 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13622 PEER_CAP_ADDPATH_AF_RX_ADV
))
13634 PEER_CAP_ADDPATH_AF_RX_RCV
))
13641 PEER_CAP_ADDPATH_AF_RX_ADV
)
13645 vty_out(vty
, "\n");
13651 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
13652 || CHECK_FLAG(p
->cap
,
13653 PEER_CAP_DYNAMIC_ADV
)) {
13654 vty_out(vty
, " Dynamic:");
13655 if (CHECK_FLAG(p
->cap
,
13656 PEER_CAP_DYNAMIC_ADV
))
13657 vty_out(vty
, " advertised");
13658 if (CHECK_FLAG(p
->cap
,
13659 PEER_CAP_DYNAMIC_RCV
))
13660 vty_out(vty
, " %sreceived",
13663 PEER_CAP_DYNAMIC_ADV
)
13666 vty_out(vty
, "\n");
13669 /* Extended nexthop */
13670 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
13671 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13672 vty_out(vty
, " Extended nexthop:");
13673 if (CHECK_FLAG(p
->cap
,
13674 PEER_CAP_ENHE_ADV
))
13675 vty_out(vty
, " advertised");
13676 if (CHECK_FLAG(p
->cap
,
13677 PEER_CAP_ENHE_RCV
))
13678 vty_out(vty
, " %sreceived",
13684 vty_out(vty
, "\n");
13686 if (CHECK_FLAG(p
->cap
,
13687 PEER_CAP_ENHE_RCV
)) {
13689 " Address families by peer:\n ");
13690 for (safi
= SAFI_UNICAST
;
13691 safi
< SAFI_MAX
; safi
++)
13696 PEER_CAP_ENHE_AF_RCV
))
13706 /* Route Refresh */
13707 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
13708 || CHECK_FLAG(p
->cap
,
13709 PEER_CAP_REFRESH_NEW_RCV
)
13710 || CHECK_FLAG(p
->cap
,
13711 PEER_CAP_REFRESH_OLD_RCV
)) {
13712 vty_out(vty
, " Route refresh:");
13713 if (CHECK_FLAG(p
->cap
,
13714 PEER_CAP_REFRESH_ADV
))
13715 vty_out(vty
, " advertised");
13716 if (CHECK_FLAG(p
->cap
,
13717 PEER_CAP_REFRESH_NEW_RCV
)
13720 PEER_CAP_REFRESH_OLD_RCV
))
13721 vty_out(vty
, " %sreceived(%s)",
13724 PEER_CAP_REFRESH_ADV
)
13729 PEER_CAP_REFRESH_OLD_RCV
)
13732 PEER_CAP_REFRESH_NEW_RCV
))
13736 PEER_CAP_REFRESH_OLD_RCV
)
13740 vty_out(vty
, "\n");
13743 /* Enhanced Route Refresh */
13744 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
)
13745 || CHECK_FLAG(p
->cap
,
13746 PEER_CAP_ENHANCED_RR_RCV
)) {
13748 " Enhanced Route Refresh:");
13751 PEER_CAP_ENHANCED_RR_ADV
))
13752 vty_out(vty
, " advertised");
13755 PEER_CAP_ENHANCED_RR_RCV
))
13756 vty_out(vty
, " %sreceived",
13759 PEER_CAP_REFRESH_ADV
)
13762 vty_out(vty
, "\n");
13765 /* Multiprotocol Extensions */
13766 FOREACH_AFI_SAFI (afi
, safi
)
13767 if (p
->afc_adv
[afi
][safi
]
13768 || p
->afc_recv
[afi
][safi
]) {
13770 " Address Family %s:",
13775 if (p
->afc_adv
[afi
][safi
])
13778 if (p
->afc_recv
[afi
][safi
])
13785 vty_out(vty
, "\n");
13788 /* Hostname capability */
13789 vty_out(vty
, " Hostname Capability:");
13791 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13793 " advertised (name: %s,domain name: %s)",
13794 bgp
->peer_self
->hostname
13798 bgp
->peer_self
->domainname
13803 vty_out(vty
, " not advertised");
13806 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13808 " received (name: %s,domain name: %s)",
13809 p
->hostname
? p
->hostname
13811 p
->domainname
? p
->domainname
13814 vty_out(vty
, " not received");
13817 vty_out(vty
, "\n");
13819 /* Graceful Restart */
13820 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
13821 || CHECK_FLAG(p
->cap
,
13822 PEER_CAP_RESTART_ADV
)) {
13824 " Graceful Restart Capability:");
13825 if (CHECK_FLAG(p
->cap
,
13826 PEER_CAP_RESTART_ADV
))
13827 vty_out(vty
, " advertised");
13828 if (CHECK_FLAG(p
->cap
,
13829 PEER_CAP_RESTART_RCV
))
13830 vty_out(vty
, " %sreceived",
13833 PEER_CAP_RESTART_ADV
)
13836 vty_out(vty
, "\n");
13838 if (CHECK_FLAG(p
->cap
,
13839 PEER_CAP_RESTART_RCV
)) {
13840 int restart_af_count
= 0;
13843 " Remote Restart timer is %d seconds\n",
13846 " Address families by peer:\n ");
13848 FOREACH_AFI_SAFI (afi
, safi
)
13853 PEER_CAP_RESTART_AF_RCV
)) {
13867 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13869 : "not preserved");
13870 restart_af_count
++;
13872 if (!restart_af_count
)
13873 vty_out(vty
, "none");
13874 vty_out(vty
, "\n");
13876 } /* Gracefull Restart */
13881 /* graceful restart information */
13882 json_object
*json_grace
= NULL
;
13883 json_object
*json_grace_send
= NULL
;
13884 json_object
*json_grace_recv
= NULL
;
13885 int eor_send_af_count
= 0;
13886 int eor_receive_af_count
= 0;
13889 json_grace
= json_object_new_object();
13890 json_grace_send
= json_object_new_object();
13891 json_grace_recv
= json_object_new_object();
13893 if ((p
->status
== Established
)
13894 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13895 FOREACH_AFI_SAFI (afi
, safi
) {
13896 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13897 PEER_STATUS_EOR_SEND
)) {
13898 json_object_boolean_true_add(
13900 get_afi_safi_str(afi
,
13903 eor_send_af_count
++;
13906 FOREACH_AFI_SAFI (afi
, safi
) {
13908 p
->af_sflags
[afi
][safi
],
13909 PEER_STATUS_EOR_RECEIVED
)) {
13910 json_object_boolean_true_add(
13912 get_afi_safi_str(afi
,
13915 eor_receive_af_count
++;
13919 json_object_object_add(json_grace
, "endOfRibSend",
13921 json_object_object_add(json_grace
, "endOfRibRecv",
13925 if (p
->t_gr_restart
)
13926 json_object_int_add(json_grace
,
13927 "gracefulRestartTimerMsecs",
13928 thread_timer_remain_second(
13933 json_object_int_add(
13935 "gracefulStalepathTimerMsecs",
13936 thread_timer_remain_second(
13939 /* more gr info in new format */
13940 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
,
13942 json_object_object_add(
13943 json_neigh
, "gracefulRestartInfo", json_grace
);
13945 vty_out(vty
, " Graceful restart information:\n");
13946 if ((p
->status
== Established
)
13947 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13949 vty_out(vty
, " End-of-RIB send: ");
13950 FOREACH_AFI_SAFI (afi
, safi
) {
13951 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13952 PEER_STATUS_EOR_SEND
)) {
13953 vty_out(vty
, "%s%s",
13954 eor_send_af_count
? ", "
13959 eor_send_af_count
++;
13962 vty_out(vty
, "\n");
13963 vty_out(vty
, " End-of-RIB received: ");
13964 FOREACH_AFI_SAFI (afi
, safi
) {
13966 p
->af_sflags
[afi
][safi
],
13967 PEER_STATUS_EOR_RECEIVED
)) {
13968 vty_out(vty
, "%s%s",
13969 eor_receive_af_count
13972 get_afi_safi_str(afi
,
13975 eor_receive_af_count
++;
13978 vty_out(vty
, "\n");
13981 if (p
->t_gr_restart
)
13983 " The remaining time of restart timer is %ld\n",
13984 thread_timer_remain_second(
13989 " The remaining time of stalepath timer is %ld\n",
13990 thread_timer_remain_second(
13993 /* more gr info in new format */
13994 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
13998 json_object
*json_stat
= NULL
;
13999 json_stat
= json_object_new_object();
14000 /* Packet counts. */
14002 atomic_size_t outq_count
, inq_count
;
14003 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14004 memory_order_relaxed
);
14005 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14006 memory_order_relaxed
);
14008 json_object_int_add(json_stat
, "depthInq",
14009 (unsigned long)inq_count
);
14010 json_object_int_add(json_stat
, "depthOutq",
14011 (unsigned long)outq_count
);
14012 json_object_int_add(json_stat
, "opensSent",
14013 atomic_load_explicit(&p
->open_out
,
14014 memory_order_relaxed
));
14015 json_object_int_add(json_stat
, "opensRecv",
14016 atomic_load_explicit(&p
->open_in
,
14017 memory_order_relaxed
));
14018 json_object_int_add(json_stat
, "notificationsSent",
14019 atomic_load_explicit(&p
->notify_out
,
14020 memory_order_relaxed
));
14021 json_object_int_add(json_stat
, "notificationsRecv",
14022 atomic_load_explicit(&p
->notify_in
,
14023 memory_order_relaxed
));
14024 json_object_int_add(json_stat
, "updatesSent",
14025 atomic_load_explicit(&p
->update_out
,
14026 memory_order_relaxed
));
14027 json_object_int_add(json_stat
, "updatesRecv",
14028 atomic_load_explicit(&p
->update_in
,
14029 memory_order_relaxed
));
14030 json_object_int_add(json_stat
, "keepalivesSent",
14031 atomic_load_explicit(&p
->keepalive_out
,
14032 memory_order_relaxed
));
14033 json_object_int_add(json_stat
, "keepalivesRecv",
14034 atomic_load_explicit(&p
->keepalive_in
,
14035 memory_order_relaxed
));
14036 json_object_int_add(json_stat
, "routeRefreshSent",
14037 atomic_load_explicit(&p
->refresh_out
,
14038 memory_order_relaxed
));
14039 json_object_int_add(json_stat
, "routeRefreshRecv",
14040 atomic_load_explicit(&p
->refresh_in
,
14041 memory_order_relaxed
));
14042 json_object_int_add(json_stat
, "capabilitySent",
14043 atomic_load_explicit(&p
->dynamic_cap_out
,
14044 memory_order_relaxed
));
14045 json_object_int_add(json_stat
, "capabilityRecv",
14046 atomic_load_explicit(&p
->dynamic_cap_in
,
14047 memory_order_relaxed
));
14048 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
14049 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
14050 json_object_object_add(json_neigh
, "messageStats", json_stat
);
14052 atomic_size_t outq_count
, inq_count
;
14053 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14054 memory_order_relaxed
);
14055 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14056 memory_order_relaxed
);
14058 /* Packet counts. */
14059 vty_out(vty
, " Message statistics:\n");
14060 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
14061 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
14062 vty_out(vty
, " Sent Rcvd\n");
14063 vty_out(vty
, " Opens: %10d %10d\n",
14064 atomic_load_explicit(&p
->open_out
,
14065 memory_order_relaxed
),
14066 atomic_load_explicit(&p
->open_in
,
14067 memory_order_relaxed
));
14068 vty_out(vty
, " Notifications: %10d %10d\n",
14069 atomic_load_explicit(&p
->notify_out
,
14070 memory_order_relaxed
),
14071 atomic_load_explicit(&p
->notify_in
,
14072 memory_order_relaxed
));
14073 vty_out(vty
, " Updates: %10d %10d\n",
14074 atomic_load_explicit(&p
->update_out
,
14075 memory_order_relaxed
),
14076 atomic_load_explicit(&p
->update_in
,
14077 memory_order_relaxed
));
14078 vty_out(vty
, " Keepalives: %10d %10d\n",
14079 atomic_load_explicit(&p
->keepalive_out
,
14080 memory_order_relaxed
),
14081 atomic_load_explicit(&p
->keepalive_in
,
14082 memory_order_relaxed
));
14083 vty_out(vty
, " Route Refresh: %10d %10d\n",
14084 atomic_load_explicit(&p
->refresh_out
,
14085 memory_order_relaxed
),
14086 atomic_load_explicit(&p
->refresh_in
,
14087 memory_order_relaxed
));
14088 vty_out(vty
, " Capability: %10d %10d\n",
14089 atomic_load_explicit(&p
->dynamic_cap_out
,
14090 memory_order_relaxed
),
14091 atomic_load_explicit(&p
->dynamic_cap_in
,
14092 memory_order_relaxed
));
14093 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
14098 /* advertisement-interval */
14099 json_object_int_add(json_neigh
,
14100 "minBtwnAdvertisementRunsTimerMsecs",
14101 p
->v_routeadv
* 1000);
14103 /* Update-source. */
14104 if (p
->update_if
|| p
->update_source
) {
14106 json_object_string_add(json_neigh
,
14109 else if (p
->update_source
)
14110 json_object_string_add(
14111 json_neigh
, "updateSource",
14112 sockunion2str(p
->update_source
, buf1
,
14116 /* advertisement-interval */
14118 " Minimum time between advertisement runs is %d seconds\n",
14121 /* Update-source. */
14122 if (p
->update_if
|| p
->update_source
) {
14123 vty_out(vty
, " Update source is ");
14125 vty_out(vty
, "%s", p
->update_if
);
14126 else if (p
->update_source
)
14128 sockunion2str(p
->update_source
, buf1
,
14130 vty_out(vty
, "\n");
14133 vty_out(vty
, "\n");
14136 /* Address Family Information */
14137 json_object
*json_hold
= NULL
;
14140 json_hold
= json_object_new_object();
14142 FOREACH_AFI_SAFI (afi
, safi
)
14143 if (p
->afc
[afi
][safi
])
14144 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14148 json_object_object_add(json_neigh
, "addressFamilyInfo",
14150 json_object_int_add(json_neigh
, "connectionsEstablished",
14152 json_object_int_add(json_neigh
, "connectionsDropped",
14155 vty_out(vty
, " Connections established %d; dropped %d\n",
14156 p
->established
, p
->dropped
);
14158 if (!p
->last_reset
) {
14160 json_object_string_add(json_neigh
, "lastReset",
14163 vty_out(vty
, " Last reset never\n");
14169 uptime
= bgp_clock();
14170 uptime
-= p
->resettime
;
14171 gmtime_r(&uptime
, &tm
);
14173 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14175 + (tm
.tm_min
* 60000)
14176 + (tm
.tm_hour
* 3600000));
14177 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14179 vty_out(vty
, " Last reset %s, ",
14180 peer_uptime(p
->resettime
, timebuf
,
14181 BGP_UPTIME_LEN
, 0, NULL
));
14183 bgp_show_peer_reset(vty
, p
, NULL
, false);
14184 if (p
->last_reset_cause_size
) {
14185 msg
= p
->last_reset_cause
;
14187 " Message received that caused BGP to send a NOTIFICATION:\n ");
14188 for (i
= 1; i
<= p
->last_reset_cause_size
;
14190 vty_out(vty
, "%02X", *msg
++);
14192 if (i
!= p
->last_reset_cause_size
) {
14194 vty_out(vty
, "\n ");
14195 } else if (i
% 4 == 0) {
14200 vty_out(vty
, "\n");
14205 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14207 json_object_boolean_true_add(json_neigh
,
14208 "prefixesConfigExceedMax");
14211 " Peer had exceeded the max. no. of prefixes configured.\n");
14213 if (p
->t_pmax_restart
) {
14215 json_object_boolean_true_add(
14216 json_neigh
, "reducePrefixNumFrom");
14217 json_object_int_add(json_neigh
,
14218 "restartInTimerMsec",
14219 thread_timer_remain_second(
14224 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14225 p
->host
, thread_timer_remain_second(
14226 p
->t_pmax_restart
));
14229 json_object_boolean_true_add(
14231 "reducePrefixNumAndClearIpBgp");
14234 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14239 /* EBGP Multihop and GTSM */
14240 if (p
->sort
!= BGP_PEER_IBGP
) {
14242 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14243 json_object_int_add(json_neigh
,
14244 "externalBgpNbrMaxHopsAway",
14246 else if (p
->ttl
> BGP_DEFAULT_TTL
)
14247 json_object_int_add(json_neigh
,
14248 "externalBgpNbrMaxHopsAway",
14251 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14253 " External BGP neighbor may be up to %d hops away.\n",
14255 else if (p
->ttl
> BGP_DEFAULT_TTL
)
14257 " External BGP neighbor may be up to %d hops away.\n",
14261 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
) {
14263 json_object_int_add(json_neigh
,
14264 "internalBgpNbrMaxHopsAway",
14268 " Internal BGP neighbor may be up to %d hops away.\n",
14273 /* Local address. */
14276 json_object_string_add(json_neigh
, "hostLocal",
14277 sockunion2str(p
->su_local
, buf1
,
14279 json_object_int_add(json_neigh
, "portLocal",
14280 ntohs(p
->su_local
->sin
.sin_port
));
14282 vty_out(vty
, "Local host: %s, Local port: %d\n",
14283 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
14284 ntohs(p
->su_local
->sin
.sin_port
));
14287 /* Remote address. */
14288 if (p
->su_remote
) {
14290 json_object_string_add(json_neigh
, "hostForeign",
14291 sockunion2str(p
->su_remote
, buf1
,
14293 json_object_int_add(json_neigh
, "portForeign",
14294 ntohs(p
->su_remote
->sin
.sin_port
));
14296 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
14297 sockunion2str(p
->su_remote
, buf1
,
14299 ntohs(p
->su_remote
->sin
.sin_port
));
14302 /* Nexthop display. */
14305 json_object_string_add(json_neigh
, "nexthop",
14307 &p
->nexthop
.v4
, buf1
,
14309 json_object_string_add(json_neigh
, "nexthopGlobal",
14310 inet_ntop(AF_INET6
,
14311 &p
->nexthop
.v6_global
,
14312 buf1
, sizeof(buf1
)));
14313 json_object_string_add(json_neigh
, "nexthopLocal",
14314 inet_ntop(AF_INET6
,
14315 &p
->nexthop
.v6_local
,
14316 buf1
, sizeof(buf1
)));
14317 if (p
->shared_network
)
14318 json_object_string_add(json_neigh
,
14322 json_object_string_add(json_neigh
,
14324 "nonSharedNetwork");
14326 vty_out(vty
, "Nexthop: %s\n",
14327 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
14329 vty_out(vty
, "Nexthop global: %s\n",
14330 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
14332 vty_out(vty
, "Nexthop local: %s\n",
14333 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
14335 vty_out(vty
, "BGP connection: %s\n",
14336 p
->shared_network
? "shared network"
14337 : "non shared network");
14341 /* Timer information. */
14343 json_object_int_add(json_neigh
, "connectRetryTimer",
14345 if (p
->status
== Established
&& p
->rtt
)
14346 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14349 json_object_int_add(
14350 json_neigh
, "nextStartTimerDueInMsecs",
14351 thread_timer_remain_second(p
->t_start
) * 1000);
14353 json_object_int_add(
14354 json_neigh
, "nextConnectTimerDueInMsecs",
14355 thread_timer_remain_second(p
->t_connect
)
14357 if (p
->t_routeadv
) {
14358 json_object_int_add(json_neigh
, "mraiInterval",
14360 json_object_int_add(
14361 json_neigh
, "mraiTimerExpireInMsecs",
14362 thread_timer_remain_second(p
->t_routeadv
)
14366 json_object_int_add(json_neigh
, "authenticationEnabled",
14370 json_object_string_add(json_neigh
, "readThread", "on");
14372 json_object_string_add(json_neigh
, "readThread", "off");
14374 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14375 json_object_string_add(json_neigh
, "writeThread", "on");
14377 json_object_string_add(json_neigh
, "writeThread",
14380 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14382 if (p
->status
== Established
&& p
->rtt
)
14383 vty_out(vty
, "Estimated round trip time: %d ms\n",
14386 vty_out(vty
, "Next start timer due in %ld seconds\n",
14387 thread_timer_remain_second(p
->t_start
));
14389 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14390 thread_timer_remain_second(p
->t_connect
));
14393 "MRAI (interval %u) timer expires in %ld seconds\n",
14395 thread_timer_remain_second(p
->t_routeadv
));
14397 vty_out(vty
, "Peer Authentication Enabled\n");
14399 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14400 p
->t_read
? "on" : "off",
14401 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14406 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14407 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14408 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14411 vty_out(vty
, "\n");
14413 /* BFD information. */
14414 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
14417 if (p
->conf_if
) /* Configured interface name. */
14418 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14419 else /* Configured IP address. */
14420 json_object_object_add(json
, p
->host
, json_neigh
);
14424 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14425 enum show_type type
,
14426 union sockunion
*su
,
14427 const char *conf_if
, afi_t afi
,
14430 struct listnode
*node
, *nnode
;
14433 safi_t safi
= SAFI_UNICAST
;
14434 json_object
*json
= NULL
;
14435 json_object
*json_neighbor
= NULL
;
14438 json
= json_object_new_object();
14439 json_neighbor
= json_object_new_object();
14442 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14444 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14447 if ((peer
->afc
[afi
][safi
]) == 0)
14450 if (type
== show_all
) {
14451 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14455 json_object_object_add(json
, peer
->host
,
14457 json_neighbor
= NULL
;
14460 } else if (type
== show_peer
) {
14463 && !strcmp(peer
->conf_if
, conf_if
))
14465 && !strcmp(peer
->hostname
, conf_if
))) {
14467 bgp_show_peer_gr_status(vty
, peer
,
14472 if (sockunion_same(&peer
->su
, su
)) {
14474 bgp_show_peer_gr_status(vty
, peer
,
14479 if (use_json
&& find
)
14480 json_object_object_add(json
, peer
->host
,
14485 json_neighbor
= NULL
;
14490 if (type
== show_peer
&& !find
) {
14492 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14494 vty_out(vty
, "%% No such neighbor\n");
14497 vty_out(vty
, "%s\n",
14498 json_object_to_json_string_ext(
14499 json
, JSON_C_TO_STRING_PRETTY
));
14502 json_object_free(json_neighbor
);
14503 json_object_free(json
);
14505 vty_out(vty
, "\n");
14508 return CMD_SUCCESS
;
14511 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14512 enum show_type type
, union sockunion
*su
,
14513 const char *conf_if
, bool use_json
,
14516 struct listnode
*node
, *nnode
;
14519 bool nbr_output
= false;
14520 afi_t afi
= AFI_MAX
;
14521 safi_t safi
= SAFI_MAX
;
14523 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14525 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14529 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14530 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14535 bgp_show_peer(vty
, peer
, use_json
, json
);
14541 && !strcmp(peer
->conf_if
, conf_if
))
14543 && !strcmp(peer
->hostname
, conf_if
))) {
14545 bgp_show_peer(vty
, peer
, use_json
,
14549 if (sockunion_same(&peer
->su
, su
)) {
14551 bgp_show_peer(vty
, peer
, use_json
,
14556 case show_ipv4_peer
:
14557 case show_ipv6_peer
:
14558 FOREACH_SAFI (safi
) {
14559 if (peer
->afc
[afi
][safi
]) {
14562 && !strcmp(peer
->conf_if
, conf_if
))
14564 && !strcmp(peer
->hostname
, conf_if
))) {
14566 bgp_show_peer(vty
, peer
, use_json
,
14571 if (sockunion_same(&peer
->su
, su
)) {
14573 bgp_show_peer(vty
, peer
, use_json
,
14581 case show_ipv4_all
:
14582 case show_ipv6_all
:
14583 FOREACH_SAFI (safi
) {
14584 if (peer
->afc
[afi
][safi
]) {
14585 bgp_show_peer(vty
, peer
, use_json
, json
);
14594 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14595 type
== show_ipv6_peer
) && !find
) {
14597 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14599 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14602 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14603 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14604 vty_out(vty
, "%% No BGP neighbors found\n");
14607 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14608 json
, JSON_C_TO_STRING_PRETTY
));
14610 vty_out(vty
, "\n");
14613 return CMD_SUCCESS
;
14616 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14617 enum show_type type
,
14618 const char *ip_str
,
14619 afi_t afi
, bool use_json
)
14624 union sockunion su
;
14626 bgp
= bgp_get_default();
14632 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14636 ret
= str2sockunion(ip_str
, &su
);
14638 bgp_show_neighbor_graceful_restart(
14639 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14641 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14642 NULL
, afi
, use_json
);
14644 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14648 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14649 enum show_type type
,
14650 const char *ip_str
,
14653 struct listnode
*node
, *nnode
;
14655 union sockunion su
;
14656 json_object
*json
= NULL
;
14657 int ret
, is_first
= 1;
14658 bool nbr_output
= false;
14661 vty_out(vty
, "{\n");
14663 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14666 if (!(json
= json_object_new_object())) {
14668 EC_BGP_JSON_MEM_ERROR
,
14669 "Unable to allocate memory for JSON object");
14671 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14675 json_object_int_add(json
, "vrfId",
14676 (bgp
->vrf_id
== VRF_UNKNOWN
)
14678 : (int64_t)bgp
->vrf_id
);
14679 json_object_string_add(
14681 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14686 vty_out(vty
, ",\n");
14690 vty_out(vty
, "\"%s\":",
14691 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14695 vty_out(vty
, "\nInstance %s:\n",
14696 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14701 if (type
== show_peer
|| type
== show_ipv4_peer
||
14702 type
== show_ipv6_peer
) {
14703 ret
= str2sockunion(ip_str
, &su
);
14705 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14708 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14711 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14714 json_object_free(json
);
14719 vty_out(vty
, "}\n");
14720 else if (!nbr_output
)
14721 vty_out(vty
, "%% BGP instance not found\n");
14724 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14725 enum show_type type
, const char *ip_str
,
14730 union sockunion su
;
14731 json_object
*json
= NULL
;
14734 if (strmatch(name
, "all")) {
14735 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14737 return CMD_SUCCESS
;
14739 bgp
= bgp_lookup_by_name(name
);
14742 json
= json_object_new_object();
14743 vty_out(vty
, "%s\n",
14744 json_object_to_json_string_ext(
14746 JSON_C_TO_STRING_PRETTY
));
14747 json_object_free(json
);
14750 "%% BGP instance not found\n");
14752 return CMD_WARNING
;
14756 bgp
= bgp_get_default();
14760 json
= json_object_new_object();
14762 ret
= str2sockunion(ip_str
, &su
);
14764 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14767 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14770 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14773 json_object_free(json
);
14776 vty_out(vty
, "{}\n");
14778 vty_out(vty
, "%% BGP instance not found\n");
14781 return CMD_SUCCESS
;
14786 /* "show [ip] bgp neighbors graceful-restart" commands. */
14787 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
14788 show_ip_bgp_neighbors_graceful_restart_cmd
,
14789 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14795 "Neighbor to display information about\n"
14796 "Neighbor to display information about\n"
14797 "Neighbor on BGP configured interface\n"
14801 char *sh_arg
= NULL
;
14802 enum show_type sh_type
;
14804 afi_t afi
= AFI_MAX
;
14805 bool uj
= use_json(argc
, argv
);
14807 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14812 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14813 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14814 || argv_find(argv
, argc
, "WORD", &idx
)) {
14815 sh_type
= show_peer
;
14816 sh_arg
= argv
[idx
]->arg
;
14818 sh_type
= show_all
;
14820 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14821 return CMD_SUCCESS
;
14824 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14828 /* "show [ip] bgp neighbors" commands. */
14829 DEFUN (show_ip_bgp_neighbors
,
14830 show_ip_bgp_neighbors_cmd
,
14831 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14835 BGP_INSTANCE_HELP_STR
14838 "Detailed information on TCP and BGP neighbor connections\n"
14839 "Neighbor to display information about\n"
14840 "Neighbor to display information about\n"
14841 "Neighbor on BGP configured interface\n"
14845 char *sh_arg
= NULL
;
14846 enum show_type sh_type
;
14847 afi_t afi
= AFI_MAX
;
14849 bool uj
= use_json(argc
, argv
);
14853 /* [<vrf> VIEWVRFNAME] */
14854 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14855 vrf
= argv
[idx
+ 1]->arg
;
14856 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14858 } else if (argv_find(argv
, argc
, "view", &idx
))
14859 /* [<view> VIEWVRFNAME] */
14860 vrf
= argv
[idx
+ 1]->arg
;
14864 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14865 sh_type
= show_ipv4_all
;
14867 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14868 sh_type
= show_ipv6_all
;
14871 sh_type
= show_all
;
14874 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14875 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14876 || argv_find(argv
, argc
, "WORD", &idx
)) {
14877 sh_type
= show_peer
;
14878 sh_arg
= argv
[idx
]->arg
;
14881 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14882 sh_type
= show_ipv4_peer
;
14883 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14884 sh_type
= show_ipv6_peer
;
14887 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14890 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14891 paths' and `show ip mbgp paths'. Those functions results are the
14893 DEFUN (show_ip_bgp_paths
,
14894 show_ip_bgp_paths_cmd
,
14895 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14900 "Path information\n")
14902 vty_out(vty
, "Address Refcnt Path\n");
14903 aspath_print_all_vty(vty
);
14904 return CMD_SUCCESS
;
14909 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14912 struct community
*com
;
14914 com
= (struct community
*)bucket
->data
;
14915 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14916 community_str(com
, false));
14919 /* Show BGP's community internal data. */
14920 DEFUN (show_ip_bgp_community_info
,
14921 show_ip_bgp_community_info_cmd
,
14922 "show [ip] bgp community-info",
14926 "List all bgp community information\n")
14928 vty_out(vty
, "Address Refcnt Community\n");
14930 hash_iterate(community_hash(),
14931 (void (*)(struct hash_bucket
*,
14932 void *))community_show_all_iterator
,
14935 return CMD_SUCCESS
;
14938 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14941 struct lcommunity
*lcom
;
14943 lcom
= (struct lcommunity
*)bucket
->data
;
14944 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14945 lcommunity_str(lcom
, false));
14948 /* Show BGP's community internal data. */
14949 DEFUN (show_ip_bgp_lcommunity_info
,
14950 show_ip_bgp_lcommunity_info_cmd
,
14951 "show ip bgp large-community-info",
14955 "List all bgp large-community information\n")
14957 vty_out(vty
, "Address Refcnt Large-community\n");
14959 hash_iterate(lcommunity_hash(),
14960 (void (*)(struct hash_bucket
*,
14961 void *))lcommunity_show_all_iterator
,
14964 return CMD_SUCCESS
;
14966 /* Graceful Restart */
14968 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
14975 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
14977 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
14979 switch (bgp_global_gr_mode
) {
14981 case GLOBAL_HELPER
:
14982 vty_out(vty
, "Global BGP GR Mode : Helper\n");
14986 vty_out(vty
, "Global BGP GR Mode : Restart\n");
14989 case GLOBAL_DISABLE
:
14990 vty_out(vty
, "Global BGP GR Mode : Disable\n");
14993 case GLOBAL_INVALID
:
14995 "Global BGP GR Mode Invalid\n");
14998 vty_out(vty
, "\n");
15001 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
15002 enum show_type type
,
15003 const char *ip_str
,
15004 afi_t afi
, bool use_json
)
15006 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
15009 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
15011 bgp_show_neighbor_graceful_restart_vty(
15012 vty
, type
, ip_str
, afi
, use_json
);
15015 } else if (afi
!= AFI_MAX
) {
15016 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
15019 return CMD_ERR_INCOMPLETE
;
15022 return CMD_SUCCESS
;
15024 /* Graceful Restart */
15026 DEFUN (show_ip_bgp_attr_info
,
15027 show_ip_bgp_attr_info_cmd
,
15028 "show [ip] bgp attribute-info",
15032 "List all bgp attribute information\n")
15034 attr_show_all(vty
);
15035 return CMD_SUCCESS
;
15038 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
15039 afi_t afi
, safi_t safi
,
15040 bool use_json
, json_object
*json
)
15043 struct listnode
*node
;
15045 char buf1
[INET6_ADDRSTRLEN
];
15047 vpn_policy_direction_t dir
;
15050 json_object
*json_import_vrfs
= NULL
;
15051 json_object
*json_export_vrfs
= NULL
;
15053 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15056 vty_out(vty
, "%s\n",
15057 json_object_to_json_string_ext(
15059 JSON_C_TO_STRING_PRETTY
));
15060 json_object_free(json
);
15062 return CMD_WARNING
;
15065 /* Provide context for the block */
15066 json_object_string_add(json
, "vrf", name
? name
: "default");
15067 json_object_string_add(json
, "afiSafi",
15068 get_afi_safi_str(afi
, safi
, true));
15070 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15071 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15072 json_object_string_add(json
, "importFromVrfs", "none");
15073 json_object_string_add(json
, "importRts", "none");
15075 json_import_vrfs
= json_object_new_array();
15077 for (ALL_LIST_ELEMENTS_RO(
15078 bgp
->vpn_policy
[afi
].import_vrf
,
15080 json_object_array_add(json_import_vrfs
,
15081 json_object_new_string(vname
));
15083 json_object_object_add(json
, "importFromVrfs",
15085 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15086 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15087 ecom_str
= ecommunity_ecom2str(
15088 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15089 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15090 json_object_string_add(json
, "importRts",
15092 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15094 json_object_string_add(json
, "importRts",
15098 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15099 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15100 json_object_string_add(json
, "exportToVrfs", "none");
15101 json_object_string_add(json
, "routeDistinguisher",
15103 json_object_string_add(json
, "exportRts", "none");
15105 json_export_vrfs
= json_object_new_array();
15107 for (ALL_LIST_ELEMENTS_RO(
15108 bgp
->vpn_policy
[afi
].export_vrf
,
15110 json_object_array_add(json_export_vrfs
,
15111 json_object_new_string(vname
));
15112 json_object_object_add(json
, "exportToVrfs",
15114 json_object_string_add(json
, "routeDistinguisher",
15115 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
15116 buf1
, RD_ADDRSTRLEN
));
15118 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15119 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15120 ecom_str
= ecommunity_ecom2str(
15121 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15122 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15123 json_object_string_add(json
, "exportRts",
15125 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15127 json_object_string_add(json
, "exportRts",
15132 vty_out(vty
, "%s\n",
15133 json_object_to_json_string_ext(json
,
15134 JSON_C_TO_STRING_PRETTY
));
15135 json_object_free(json
);
15138 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15141 vty_out(vty
, "%% No such BGP instance exist\n");
15142 return CMD_WARNING
;
15145 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15146 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15148 "This VRF is not importing %s routes from any other VRF\n",
15149 get_afi_safi_str(afi
, safi
, false));
15152 "This VRF is importing %s routes from the following VRFs:\n",
15153 get_afi_safi_str(afi
, safi
, false));
15155 for (ALL_LIST_ELEMENTS_RO(
15156 bgp
->vpn_policy
[afi
].import_vrf
,
15158 vty_out(vty
, " %s\n", vname
);
15160 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15162 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15163 ecom_str
= ecommunity_ecom2str(
15164 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15165 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15166 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15168 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15170 vty_out(vty
, "Import RT(s):\n");
15173 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15174 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15176 "This VRF is not exporting %s routes to any other VRF\n",
15177 get_afi_safi_str(afi
, safi
, false));
15180 "This VRF is exporting %s routes to the following VRFs:\n",
15181 get_afi_safi_str(afi
, safi
, false));
15183 for (ALL_LIST_ELEMENTS_RO(
15184 bgp
->vpn_policy
[afi
].export_vrf
,
15186 vty_out(vty
, " %s\n", vname
);
15188 vty_out(vty
, "RD: %s\n",
15189 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
15190 buf1
, RD_ADDRSTRLEN
));
15192 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15193 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15194 ecom_str
= ecommunity_ecom2str(
15195 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15196 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15197 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15198 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15200 vty_out(vty
, "Import RT(s):\n");
15204 return CMD_SUCCESS
;
15207 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15208 safi_t safi
, bool use_json
)
15210 struct listnode
*node
, *nnode
;
15212 char *vrf_name
= NULL
;
15213 json_object
*json
= NULL
;
15214 json_object
*json_vrf
= NULL
;
15215 json_object
*json_vrfs
= NULL
;
15218 json
= json_object_new_object();
15219 json_vrfs
= json_object_new_object();
15222 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15224 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15225 vrf_name
= bgp
->name
;
15228 json_vrf
= json_object_new_object();
15230 vty_out(vty
, "\nInstance %s:\n",
15231 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15232 ? VRF_DEFAULT_NAME
: bgp
->name
);
15234 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15236 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15237 json_object_object_add(json_vrfs
,
15238 VRF_DEFAULT_NAME
, json_vrf
);
15240 json_object_object_add(json_vrfs
, vrf_name
,
15246 json_object_object_add(json
, "vrfs", json_vrfs
);
15247 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
15248 JSON_C_TO_STRING_PRETTY
));
15249 json_object_free(json
);
15252 return CMD_SUCCESS
;
15255 /* "show [ip] bgp route-leak" command. */
15256 DEFUN (show_ip_bgp_route_leak
,
15257 show_ip_bgp_route_leak_cmd
,
15258 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15262 BGP_INSTANCE_HELP_STR
15265 "Route leaking information\n"
15269 afi_t afi
= AFI_MAX
;
15270 safi_t safi
= SAFI_MAX
;
15272 bool uj
= use_json(argc
, argv
);
15274 json_object
*json
= NULL
;
15276 /* show [ip] bgp */
15277 if (argv_find(argv
, argc
, "ip", &idx
)) {
15279 safi
= SAFI_UNICAST
;
15281 /* [vrf VIEWVRFNAME] */
15282 if (argv_find(argv
, argc
, "view", &idx
)) {
15284 "%% This command is not applicable to BGP views\n");
15285 return CMD_WARNING
;
15288 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15289 vrf
= argv
[idx
+ 1]->arg
;
15290 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15293 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15294 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15295 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15298 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15300 "%% This command is applicable only for unicast ipv4|ipv6\n");
15301 return CMD_WARNING
;
15304 if (vrf
&& strmatch(vrf
, "all"))
15305 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15308 json
= json_object_new_object();
15310 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15313 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15316 struct listnode
*node
, *nnode
;
15319 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15320 vty_out(vty
, "\nInstance %s:\n",
15321 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15324 update_group_show(bgp
, afi
, safi
, vty
, 0);
15328 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15329 int safi
, uint64_t subgrp_id
)
15334 if (strmatch(name
, "all")) {
15335 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
15336 return CMD_SUCCESS
;
15338 bgp
= bgp_lookup_by_name(name
);
15341 bgp
= bgp_get_default();
15345 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
15346 return CMD_SUCCESS
;
15349 DEFUN (show_ip_bgp_updgrps
,
15350 show_ip_bgp_updgrps_cmd
,
15351 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
15355 BGP_INSTANCE_HELP_STR
15357 BGP_SAFI_WITH_LABEL_HELP_STR
15358 "Detailed info about dynamic update groups\n"
15359 "Specific subgroup to display detailed info for\n")
15362 afi_t afi
= AFI_IP6
;
15363 safi_t safi
= SAFI_UNICAST
;
15364 uint64_t subgrp_id
= 0;
15368 /* show [ip] bgp */
15369 if (argv_find(argv
, argc
, "ip", &idx
))
15371 /* [<vrf> VIEWVRFNAME] */
15372 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15373 vrf
= argv
[idx
+ 1]->arg
;
15374 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15376 } else if (argv_find(argv
, argc
, "view", &idx
))
15377 /* [<view> VIEWVRFNAME] */
15378 vrf
= argv
[idx
+ 1]->arg
;
15379 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15380 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15381 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15384 /* get subgroup id, if provided */
15386 if (argv
[idx
]->type
== VARIABLE_TKN
)
15387 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15389 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
15392 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15393 show_bgp_instance_all_ipv6_updgrps_cmd
,
15394 "show [ip] bgp <view|vrf> all update-groups",
15398 BGP_INSTANCE_ALL_HELP_STR
15399 "Detailed info about dynamic update groups\n")
15401 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15402 return CMD_SUCCESS
;
15405 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15406 show_bgp_l2vpn_evpn_updgrps_cmd
,
15407 "show [ip] bgp l2vpn evpn update-groups",
15411 "l2vpn address family\n"
15412 "evpn sub-address family\n"
15413 "Detailed info about dynamic update groups\n")
15416 uint64_t subgrp_id
= 0;
15418 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15419 return CMD_SUCCESS
;
15422 DEFUN (show_bgp_updgrps_stats
,
15423 show_bgp_updgrps_stats_cmd
,
15424 "show [ip] bgp update-groups statistics",
15428 "Detailed info about dynamic update groups\n"
15433 bgp
= bgp_get_default();
15435 update_group_show_stats(bgp
, vty
);
15437 return CMD_SUCCESS
;
15440 DEFUN (show_bgp_instance_updgrps_stats
,
15441 show_bgp_instance_updgrps_stats_cmd
,
15442 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15446 BGP_INSTANCE_HELP_STR
15447 "Detailed info about dynamic update groups\n"
15453 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15455 update_group_show_stats(bgp
, vty
);
15457 return CMD_SUCCESS
;
15460 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15461 afi_t afi
, safi_t safi
,
15462 const char *what
, uint64_t subgrp_id
)
15467 bgp
= bgp_lookup_by_name(name
);
15469 bgp
= bgp_get_default();
15472 if (!strcmp(what
, "advertise-queue"))
15473 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15475 else if (!strcmp(what
, "advertised-routes"))
15476 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15478 else if (!strcmp(what
, "packet-queue"))
15479 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15484 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15485 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15486 "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",
15487 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15489 "Detailed info about dynamic update groups\n"
15490 "Specific subgroup to display info for\n"
15491 "Advertisement queue\n"
15492 "Announced routes\n"
15495 uint64_t subgrp_id
= 0;
15499 subgrp_id
= strtoull(sgid
, NULL
, 10);
15504 afiz
= bgp_vty_afi_from_str(afi
);
15508 afiz
= bgp_vty_afi_from_str(afi
);
15509 if (afiz
!= AFI_IP
)
15511 "%% Cannot specify both 'ip' and 'ipv6'\n");
15512 return CMD_WARNING
;
15515 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15517 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15518 return CMD_SUCCESS
;
15521 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
,
15524 struct listnode
*node
, *nnode
;
15525 struct prefix
*range
;
15530 const char *peer_status
;
15534 json_object
*json_peer_group
= NULL
;
15535 json_object
*json_peer_group_afc
= NULL
;
15536 json_object
*json_peer_group_members
= NULL
;
15537 json_object
*json_peer_group_dynamic
= NULL
;
15538 json_object
*json_peer_group_dynamic_af
= NULL
;
15539 json_object
*json_peer_group_ranges
= NULL
;
15541 conf
= group
->conf
;
15544 json_peer_group
= json_object_new_object();
15545 json_peer_group_afc
= json_object_new_array();
15548 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15550 json_object_int_add(json_peer_group
, "remoteAs",
15553 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15554 group
->name
, conf
->as
);
15555 } else if (conf
->as_type
== AS_INTERNAL
) {
15557 json_object_int_add(json_peer_group
, "remoteAs",
15560 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15561 group
->name
, group
->bgp
->as
);
15564 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15567 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
)) {
15569 json_object_string_add(json_peer_group
, "type",
15572 vty_out(vty
, " Peer-group type is internal\n");
15575 json_object_string_add(json_peer_group
, "type",
15578 vty_out(vty
, " Peer-group type is external\n");
15581 /* Display AFs configured. */
15583 vty_out(vty
, " Configured address-families:");
15585 FOREACH_AFI_SAFI (afi
, safi
) {
15586 if (conf
->afc
[afi
][safi
]) {
15589 json_object_array_add(
15590 json_peer_group_afc
,
15591 json_object_new_string(get_afi_safi_str(
15592 afi
, safi
, false)));
15594 vty_out(vty
, " %s;",
15595 get_afi_safi_str(afi
, safi
, false));
15600 json_object_object_add(json_peer_group
,
15601 "addressFamiliesConfigured",
15602 json_peer_group_afc
);
15605 vty_out(vty
, " none\n");
15607 vty_out(vty
, "\n");
15610 /* Display listen ranges (for dynamic neighbors), if any */
15611 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15612 lr_count
= listcount(group
->listen_range
[afi
]);
15615 if (!json_peer_group_dynamic
)
15616 json_peer_group_dynamic
=
15617 json_object_new_object();
15619 json_peer_group_dynamic_af
=
15620 json_object_new_object();
15621 json_peer_group_ranges
=
15622 json_object_new_array();
15623 json_object_int_add(json_peer_group_dynamic_af
,
15624 "count", lr_count
);
15626 vty_out(vty
, " %d %s listen range(s)\n",
15627 lr_count
, afi2str(afi
));
15630 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15635 snprintfrr(buf
, sizeof(buf
), "%pFX",
15638 json_object_array_add(
15639 json_peer_group_ranges
,
15640 json_object_new_string(buf
));
15642 vty_out(vty
, " %pFX\n", range
);
15647 json_object_object_add(
15648 json_peer_group_dynamic_af
, "ranges",
15649 json_peer_group_ranges
);
15651 json_object_object_add(
15652 json_peer_group_dynamic
, afi2str(afi
),
15653 json_peer_group_dynamic_af
);
15658 if (json_peer_group_dynamic
)
15659 json_object_object_add(json_peer_group
, "dynamicRanges",
15660 json_peer_group_dynamic
);
15662 /* Display group members and their status */
15663 if (listcount(group
->peer
)) {
15665 json_peer_group_members
= json_object_new_object();
15667 vty_out(vty
, " Peer-group members:\n");
15668 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15669 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15670 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15671 peer_status
= "Idle (Admin)";
15672 else if (CHECK_FLAG(peer
->sflags
,
15673 PEER_STATUS_PREFIX_OVERFLOW
))
15674 peer_status
= "Idle (PfxCt)";
15676 peer_status
= lookup_msg(bgp_status_msg
,
15677 peer
->status
, NULL
);
15679 dynamic
= peer_dynamic_neighbor(peer
);
15682 json_object
*json_peer_group_member
=
15683 json_object_new_object();
15685 json_object_string_add(json_peer_group_member
,
15686 "status", peer_status
);
15689 json_object_boolean_true_add(
15690 json_peer_group_member
,
15693 json_object_object_add(json_peer_group_members
,
15695 json_peer_group_member
);
15697 vty_out(vty
, " %s %s %s \n", peer
->host
,
15698 dynamic
? "(dynamic)" : "",
15703 json_object_object_add(json_peer_group
, "members",
15704 json_peer_group_members
);
15708 json_object_object_add(json
, group
->name
, json_peer_group
);
15710 return CMD_SUCCESS
;
15713 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15714 const char *group_name
, bool uj
)
15717 struct listnode
*node
, *nnode
;
15718 struct peer_group
*group
;
15719 bool found
= false;
15720 json_object
*json
= NULL
;
15723 json
= json_object_new_object();
15725 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15729 vty_out(vty
, "%s\n",
15730 json_object_to_json_string_ext(
15731 json
, JSON_C_TO_STRING_PRETTY
));
15732 json_object_free(json
);
15734 vty_out(vty
, "%% BGP instance not found\n");
15737 return CMD_WARNING
;
15740 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15742 if (strmatch(group
->name
, group_name
)) {
15743 bgp_show_one_peer_group(vty
, group
, json
);
15748 bgp_show_one_peer_group(vty
, group
, json
);
15752 if (group_name
&& !found
&& !uj
)
15753 vty_out(vty
, "%% No such peer-group\n");
15756 vty_out(vty
, "%s\n",
15757 json_object_to_json_string_ext(
15758 json
, JSON_C_TO_STRING_PRETTY
));
15759 json_object_free(json
);
15762 return CMD_SUCCESS
;
15765 DEFUN(show_ip_bgp_peer_groups
, show_ip_bgp_peer_groups_cmd
,
15766 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME] [json]",
15767 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR
15768 "Detailed information on BGP peer groups\n"
15769 "Peer group name\n" JSON_STR
)
15773 bool uj
= use_json(argc
, argv
);
15775 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15777 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15779 return bgp_show_peer_group_vty(vty
, vrf
, pg
, uj
);
15783 /* Redistribute VTY commands. */
15785 DEFUN_YANG (bgp_redistribute_ipv4
,
15786 bgp_redistribute_ipv4_cmd
,
15787 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15788 "Redistribute information from another routing protocol\n"
15789 FRR_IP_REDIST_HELP_STR_BGPD
)
15791 int idx_protocol
= 1;
15792 char base_xpath
[XPATH_MAXLEN
];
15794 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15795 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15796 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15797 argv
[idx_protocol
]->text
, "0");
15799 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15801 return nb_cli_apply_changes(vty
, base_xpath
);
15805 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15806 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15807 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15809 DEFUN_YANG (bgp_redistribute_ipv4_rmap
,
15810 bgp_redistribute_ipv4_rmap_cmd
,
15811 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15812 "Redistribute information from another routing protocol\n"
15813 FRR_IP_REDIST_HELP_STR_BGPD
15814 "Route map reference\n"
15815 "Pointer to route-map entries\n")
15817 int idx_protocol
= 1;
15819 char base_xpath
[XPATH_MAXLEN
];
15821 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15822 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15823 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15824 argv
[idx_protocol
]->text
, "0");
15826 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15827 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15828 argv
[idx_word
]->arg
);
15830 return nb_cli_apply_changes(vty
, base_xpath
);
15834 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15835 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15836 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15837 "Route map reference\n"
15838 "Pointer to route-map entries\n")
15840 DEFUN_YANG (bgp_redistribute_ipv4_metric
,
15841 bgp_redistribute_ipv4_metric_cmd
,
15842 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15843 "Redistribute information from another routing protocol\n"
15844 FRR_IP_REDIST_HELP_STR_BGPD
15845 "Metric for redistributed routes\n"
15846 "Default metric\n")
15848 int idx_protocol
= 1;
15849 int idx_number
= 3;
15850 char base_xpath
[XPATH_MAXLEN
];
15852 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15853 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15854 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15855 argv
[idx_protocol
]->text
, "0");
15857 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15858 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15859 argv
[idx_number
]->arg
);
15861 return nb_cli_apply_changes(vty
, base_xpath
);
15865 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15866 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15867 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15868 "Metric for redistributed routes\n"
15869 "Default metric\n")
15872 bgp_redistribute_ipv4_rmap_metric
,
15873 bgp_redistribute_ipv4_rmap_metric_cmd
,
15874 "redistribute " FRR_IP_REDIST_STR_BGPD
15875 " route-map WORD metric (0-4294967295)",
15876 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15877 "Route map reference\n"
15878 "Pointer to route-map entries\n"
15879 "Metric for redistributed routes\n"
15880 "Default metric\n")
15882 int idx_protocol
= 1;
15884 int idx_number
= 5;
15885 char base_xpath
[XPATH_MAXLEN
];
15887 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15888 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15889 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15890 argv
[idx_protocol
]->text
, "0");
15892 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15893 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15894 argv
[idx_word
]->arg
);
15895 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15896 argv
[idx_number
]->arg
);
15898 return nb_cli_apply_changes(vty
, base_xpath
);
15902 bgp_redistribute_ipv4_rmap_metric
,
15903 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15904 "redistribute " FRR_IP_REDIST_STR_BGPD
15905 " route-map WORD metric (0-4294967295)",
15906 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15907 "Route map reference\n"
15908 "Pointer to route-map entries\n"
15909 "Metric for redistributed routes\n"
15910 "Default metric\n")
15913 bgp_redistribute_ipv4_metric_rmap
,
15914 bgp_redistribute_ipv4_metric_rmap_cmd
,
15915 "redistribute " FRR_IP_REDIST_STR_BGPD
15916 " metric (0-4294967295) route-map WORD",
15917 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15918 "Metric for redistributed routes\n"
15920 "Route map reference\n"
15921 "Pointer to route-map entries\n")
15923 int idx_protocol
= 1;
15925 int idx_number
= 3;
15926 char base_xpath
[XPATH_MAXLEN
];
15928 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15929 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15930 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15931 argv
[idx_protocol
]->text
, "0");
15933 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15934 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15935 argv
[idx_number
]->arg
);
15936 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15937 argv
[idx_word
]->arg
);
15939 return nb_cli_apply_changes(vty
, base_xpath
);
15943 bgp_redistribute_ipv4_metric_rmap
,
15944 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15945 "redistribute " FRR_IP_REDIST_STR_BGPD
15946 " metric (0-4294967295) route-map WORD",
15947 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15948 "Metric for redistributed routes\n"
15950 "Route map reference\n"
15951 "Pointer to route-map entries\n")
15953 DEFUN_YANG (bgp_redistribute_ipv4_ospf
,
15954 bgp_redistribute_ipv4_ospf_cmd
,
15955 "redistribute <ospf|table> (1-65535)",
15956 "Redistribute information from another routing protocol\n"
15957 "Open Shortest Path First (OSPFv2)\n"
15958 "Non-main Kernel Routing Table\n"
15959 "Instance ID/Table ID\n")
15961 int idx_protocol
= 1;
15962 int idx_number
= 2;
15963 char base_xpath
[XPATH_MAXLEN
];
15965 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15966 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15967 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15968 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15970 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15972 return nb_cli_apply_changes(vty
, base_xpath
);
15975 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
15976 "redistribute <ospf|table> (1-65535)",
15977 "Redistribute information from another routing protocol\n"
15978 "Open Shortest Path First (OSPFv2)\n"
15979 "Non-main Kernel Routing Table\n"
15980 "Instance ID/Table ID\n")
15982 DEFUN_YANG (bgp_redistribute_ipv4_ospf_rmap
,
15983 bgp_redistribute_ipv4_ospf_rmap_cmd
,
15984 "redistribute <ospf|table> (1-65535) route-map WORD",
15985 "Redistribute information from another routing protocol\n"
15986 "Open Shortest Path First (OSPFv2)\n"
15987 "Non-main Kernel Routing Table\n"
15988 "Instance ID/Table ID\n"
15989 "Route map reference\n"
15990 "Pointer to route-map entries\n")
15992 int idx_protocol
= 1;
15993 int idx_number
= 2;
15995 char base_xpath
[XPATH_MAXLEN
];
15997 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15998 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15999 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16000 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
16002 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16004 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16005 argv
[idx_word
]->arg
);
16007 return nb_cli_apply_changes(vty
, base_xpath
);
16010 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
16011 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
16012 "redistribute <ospf|table> (1-65535) route-map WORD",
16013 "Redistribute information from another routing protocol\n"
16014 "Open Shortest Path First (OSPFv2)\n"
16015 "Non-main Kernel Routing Table\n"
16016 "Instance ID/Table ID\n"
16017 "Route map reference\n"
16018 "Pointer to route-map entries\n")
16020 DEFUN_YANG(bgp_redistribute_ipv4_ospf_metric
,
16021 bgp_redistribute_ipv4_ospf_metric_cmd
,
16022 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16023 "Redistribute information from another routing protocol\n"
16024 "Open Shortest Path First (OSPFv2)\n"
16025 "Non-main Kernel Routing Table\n"
16026 "Instance ID/Table ID\n"
16027 "Metric for redistributed routes\n"
16028 "Default metric\n")
16030 int idx_protocol
= 1;
16031 int idx_number
= 2;
16032 int idx_number_2
= 4;
16033 char base_xpath
[XPATH_MAXLEN
];
16035 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16036 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16037 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16038 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
16040 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16042 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16043 argv
[idx_number_2
]->arg
);
16045 return nb_cli_apply_changes(vty
, base_xpath
);
16048 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
16049 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
16050 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
16051 "Redistribute information from another routing protocol\n"
16052 "Open Shortest Path First (OSPFv2)\n"
16053 "Non-main Kernel Routing Table\n"
16054 "Instance ID/Table ID\n"
16055 "Metric for redistributed routes\n"
16056 "Default metric\n")
16059 bgp_redistribute_ipv4_ospf_rmap_metric
,
16060 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
16061 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
16062 "Redistribute information from another routing protocol\n"
16063 "Open Shortest Path First (OSPFv2)\n"
16064 "Non-main Kernel Routing Table\n"
16065 "Instance ID/Table ID\n"
16066 "Route map reference\n"
16067 "Pointer to route-map entries\n"
16068 "Metric for redistributed routes\n"
16069 "Default metric\n")
16071 int idx_protocol
= 1;
16072 int idx_number
= 2;
16074 int idx_number_2
= 6;
16075 char base_xpath
[XPATH_MAXLEN
];
16077 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16078 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16079 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16080 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
16082 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16084 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16085 argv
[idx_word
]->arg
);
16086 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16087 argv
[idx_number_2
]->arg
);
16089 return nb_cli_apply_changes(vty
, base_xpath
);
16093 bgp_redistribute_ipv4_ospf_rmap_metric
,
16094 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
16095 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
16096 "Redistribute information from another routing protocol\n"
16097 "Open Shortest Path First (OSPFv2)\n"
16098 "Non-main Kernel Routing Table\n"
16099 "Instance ID/Table ID\n"
16100 "Route map reference\n"
16101 "Pointer to route-map entries\n"
16102 "Metric for redistributed routes\n"
16103 "Default metric\n")
16106 bgp_redistribute_ipv4_ospf_metric_rmap
,
16107 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
16108 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
16109 "Redistribute information from another routing protocol\n"
16110 "Open Shortest Path First (OSPFv2)\n"
16111 "Non-main Kernel Routing Table\n"
16112 "Instance ID/Table ID\n"
16113 "Metric for redistributed routes\n"
16115 "Route map reference\n"
16116 "Pointer to route-map entries\n")
16118 int idx_protocol
= 1;
16119 int idx_number
= 2;
16120 int idx_number_2
= 4;
16122 char base_xpath
[XPATH_MAXLEN
];
16124 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16125 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16126 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16127 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
16129 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16131 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16132 argv
[idx_number_2
]->arg
);
16133 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16134 argv
[idx_word
]->arg
);
16136 return nb_cli_apply_changes(vty
, base_xpath
);
16140 bgp_redistribute_ipv4_ospf_metric_rmap
,
16141 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
16142 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
16143 "Redistribute information from another routing protocol\n"
16144 "Open Shortest Path First (OSPFv2)\n"
16145 "Non-main Kernel Routing Table\n"
16146 "Instance ID/Table ID\n"
16147 "Metric for redistributed routes\n"
16149 "Route map reference\n"
16150 "Pointer to route-map entries\n")
16152 DEFUN_YANG (no_bgp_redistribute_ipv4_ospf
,
16153 no_bgp_redistribute_ipv4_ospf_cmd
,
16154 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
16156 "Redistribute information from another routing protocol\n"
16157 "Open Shortest Path First (OSPFv2)\n"
16158 "Non-main Kernel Routing Table\n"
16159 "Instance ID/Table ID\n"
16160 "Metric for redistributed routes\n"
16162 "Route map reference\n"
16163 "Pointer to route-map entries\n")
16165 int idx_protocol
= 2;
16166 int idx_number
= 3;
16167 char base_xpath
[XPATH_MAXLEN
];
16169 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16170 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16171 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16172 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
16174 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
16176 return nb_cli_apply_changes(vty
, base_xpath
);
16180 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16181 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
16183 "Redistribute information from another routing protocol\n"
16184 "Open Shortest Path First (OSPFv2)\n"
16185 "Non-main Kernel Routing Table\n"
16186 "Instance ID/Table ID\n"
16187 "Metric for redistributed routes\n"
16189 "Route map reference\n"
16190 "Pointer to route-map entries\n")
16192 DEFUN_YANG (no_bgp_redistribute_ipv4
,
16193 no_bgp_redistribute_ipv4_cmd
,
16194 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
16196 "Redistribute information from another routing protocol\n"
16197 FRR_IP_REDIST_HELP_STR_BGPD
16198 "Metric for redistributed routes\n"
16200 "Route map reference\n"
16201 "Pointer to route-map entries\n")
16203 int idx_protocol
= 2;
16204 char base_xpath
[XPATH_MAXLEN
];
16206 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16207 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16208 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16209 argv
[idx_protocol
]->text
, "0");
16211 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
16213 return nb_cli_apply_changes(vty
, base_xpath
);
16217 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16218 "no redistribute " FRR_IP_REDIST_STR_BGPD
16219 " [{metric (0-4294967295)|route-map WORD}]",
16221 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16222 "Metric for redistributed routes\n"
16224 "Route map reference\n"
16225 "Pointer to route-map entries\n")
16227 DEFUN_YANG (bgp_redistribute_ipv6
,
16228 bgp_redistribute_ipv6_cmd
,
16229 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16230 "Redistribute information from another routing protocol\n"
16231 FRR_IP6_REDIST_HELP_STR_BGPD
)
16233 int idx_protocol
= 1;
16234 char base_xpath
[XPATH_MAXLEN
];
16236 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16237 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16238 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16239 argv
[idx_protocol
]->text
, "0");
16241 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16243 return nb_cli_apply_changes(vty
, base_xpath
);
16246 DEFUN_YANG (bgp_redistribute_ipv6_rmap
,
16247 bgp_redistribute_ipv6_rmap_cmd
,
16248 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
16249 "Redistribute information from another routing protocol\n"
16250 FRR_IP6_REDIST_HELP_STR_BGPD
16251 "Route map reference\n"
16252 "Pointer to route-map entries\n")
16254 int idx_protocol
= 1;
16256 char base_xpath
[XPATH_MAXLEN
];
16258 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16259 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16260 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16261 argv
[idx_protocol
]->text
, "0");
16263 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16264 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16265 argv
[idx_word
]->arg
);
16267 return nb_cli_apply_changes(vty
, base_xpath
);
16270 DEFUN_YANG (bgp_redistribute_ipv6_metric
,
16271 bgp_redistribute_ipv6_metric_cmd
,
16272 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16273 "Redistribute information from another routing protocol\n"
16274 FRR_IP6_REDIST_HELP_STR_BGPD
16275 "Metric for redistributed routes\n"
16276 "Default metric\n")
16278 int idx_protocol
= 1;
16279 int idx_number
= 3;
16280 char base_xpath
[XPATH_MAXLEN
];
16282 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16283 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16284 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16285 argv
[idx_protocol
]->text
, "0");
16287 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16288 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16289 argv
[idx_number
]->arg
);
16291 return nb_cli_apply_changes(vty
, base_xpath
);
16295 bgp_redistribute_ipv6_rmap_metric
,
16296 bgp_redistribute_ipv6_rmap_metric_cmd
,
16297 "redistribute " FRR_IP6_REDIST_STR_BGPD
16298 " route-map WORD metric (0-4294967295)",
16299 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
16300 "Route map reference\n"
16301 "Pointer to route-map entries\n"
16302 "Metric for redistributed routes\n"
16303 "Default metric\n")
16305 int idx_protocol
= 1;
16307 int idx_number
= 5;
16308 char base_xpath
[XPATH_MAXLEN
];
16310 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16311 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16312 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16313 argv
[idx_protocol
]->text
, "0");
16315 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16316 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16317 argv
[idx_word
]->arg
);
16318 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16319 argv
[idx_number
]->arg
);
16321 return nb_cli_apply_changes(vty
, base_xpath
);
16325 bgp_redistribute_ipv6_metric_rmap
,
16326 bgp_redistribute_ipv6_metric_rmap_cmd
,
16327 "redistribute " FRR_IP6_REDIST_STR_BGPD
16328 " metric (0-4294967295) route-map WORD",
16329 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
16330 "Metric for redistributed routes\n"
16332 "Route map reference\n"
16333 "Pointer to route-map entries\n")
16335 int idx_protocol
= 1;
16337 int idx_number
= 3;
16338 char base_xpath
[XPATH_MAXLEN
];
16340 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16341 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16342 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16343 argv
[idx_protocol
]->text
, "0");
16345 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16346 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16347 argv
[idx_number
]->arg
);
16348 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16349 argv
[idx_word
]->arg
);
16351 return nb_cli_apply_changes(vty
, base_xpath
);
16355 no_bgp_redistribute_ipv6
,
16356 no_bgp_redistribute_ipv6_cmd
,
16357 "no redistribute " FRR_IP6_REDIST_STR_BGPD
16358 " [{metric (0-4294967295)|route-map WORD}]",
16360 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
16361 "Metric for redistributed routes\n"
16363 "Route map reference\n"
16364 "Pointer to route-map entries\n")
16366 int idx_protocol
= 2;
16367 char base_xpath
[XPATH_MAXLEN
];
16369 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16370 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16371 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16372 argv
[idx_protocol
]->text
, "0");
16374 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
16376 return nb_cli_apply_changes(vty
, base_xpath
);
16379 void cli_show_bgp_global_afi_safi_ip_unicast_redistribution_list(
16380 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
16382 uint32_t instance
= 0;
16384 vty_out(vty
, " redistribute %s",
16385 yang_dnode_get_string(dnode
, "./route-type"));
16386 if ((instance
= yang_dnode_get_uint16(dnode
, "./route-instance")))
16387 vty_out(vty
, " %d", instance
);
16388 if (yang_dnode_exists(dnode
, "./metric"))
16389 vty_out(vty
, " metric %u",
16390 yang_dnode_get_uint32(dnode
, "./metric"));
16391 if (yang_dnode_exists(dnode
, "./rmap-policy-import"))
16392 vty_out(vty
, " route-map %s",
16393 yang_dnode_get_string(dnode
, "./rmap-policy-import"));
16394 vty_out(vty
, "\n");
16397 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16398 afi_t afi
, safi_t safi
)
16402 /* Unicast redistribution only. */
16403 if (safi
!= SAFI_UNICAST
)
16406 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16407 /* Redistribute BGP does not make sense. */
16408 if (i
!= ZEBRA_ROUTE_BGP
) {
16409 struct list
*red_list
;
16410 struct listnode
*node
;
16411 struct bgp_redist
*red
;
16413 red_list
= bgp
->redist
[afi
][i
];
16417 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16418 /* "redistribute" configuration. */
16419 vty_out(vty
, " redistribute %s",
16420 zebra_route_string(i
));
16422 vty_out(vty
, " %d", red
->instance
);
16423 if (red
->redist_metric_flag
)
16424 vty_out(vty
, " metric %u",
16425 red
->redist_metric
);
16426 if (red
->rmap
.name
)
16427 vty_out(vty
, " route-map %s",
16429 vty_out(vty
, "\n");
16435 /* peer-group helpers for config-write */
16437 static bool peergroup_flag_check(struct peer
*peer
, uint32_t flag
)
16439 if (!peer_group_active(peer
)) {
16440 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16441 return !CHECK_FLAG(peer
->flags
, flag
);
16443 return !!CHECK_FLAG(peer
->flags
, flag
);
16446 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16449 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16452 if (!peer_group_active(peer
)) {
16453 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16454 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16456 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16459 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16462 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16463 uint8_t type
, int direct
)
16465 struct bgp_filter
*filter
;
16467 if (peer_group_active(peer
))
16468 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16471 filter
= &peer
->filter
[afi
][safi
];
16473 case PEER_FT_DISTRIBUTE_LIST
:
16474 return !!(filter
->dlist
[direct
].name
);
16475 case PEER_FT_FILTER_LIST
:
16476 return !!(filter
->aslist
[direct
].name
);
16477 case PEER_FT_PREFIX_LIST
:
16478 return !!(filter
->plist
[direct
].name
);
16479 case PEER_FT_ROUTE_MAP
:
16480 return !!(filter
->map
[direct
].name
);
16481 case PEER_FT_UNSUPPRESS_MAP
:
16482 return !!(filter
->usmap
.name
);
16483 case PEER_FT_ADVERTISE_MAP
:
16484 return !!(filter
->advmap
.aname
16485 && ((filter
->advmap
.condition
== direct
)
16486 && filter
->advmap
.cname
));
16492 /* Return true if the addpath type is set for peer and different from
16495 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16498 enum bgp_addpath_strat type
, g_type
;
16500 type
= peer
->addpath_type
[afi
][safi
];
16502 if (type
!= BGP_ADDPATH_NONE
) {
16503 if (peer_group_active(peer
)) {
16504 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16506 if (type
!= g_type
)
16518 /* This is part of the address-family block (unicast only) */
16519 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16524 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16525 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16526 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16527 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16528 bgp
->vpn_policy
[afi
]
16529 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16531 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16532 bgp
->vpn_policy
[afi
]
16533 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16535 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16536 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16537 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16538 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16541 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16542 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16544 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16547 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16548 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16549 bgp
->vpn_policy
[afi
].tovpn_label
);
16552 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16553 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
16554 char buf
[RD_ADDRSTRLEN
];
16555 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
16556 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
16559 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16560 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16562 char buf
[PREFIX_STRLEN
];
16563 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16564 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16567 vty_out(vty
, "%*snexthop vpn export %s\n",
16571 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16572 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16574 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16575 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16577 char *b
= ecommunity_ecom2str(
16578 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16579 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16580 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16581 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16583 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16584 char *b
= ecommunity_ecom2str(
16585 bgp
->vpn_policy
[afi
]
16586 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16587 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16588 ECOMMUNITY_ROUTE_TARGET
);
16589 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16590 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16592 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16593 char *b
= ecommunity_ecom2str(
16594 bgp
->vpn_policy
[afi
]
16595 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16596 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16597 ECOMMUNITY_ROUTE_TARGET
);
16598 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16599 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16603 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16604 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16605 bgp
->vpn_policy
[afi
]
16606 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16608 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16609 char *b
= ecommunity_ecom2str(
16610 bgp
->vpn_policy
[afi
]
16611 .import_redirect_rtlist
,
16612 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16613 ECOMMUNITY_ROUTE_TARGET
);
16615 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16616 != ECOMMUNITY_SIZE
)
16617 vty_out(vty
, "%*srt6 redirect import %s\n",
16620 vty_out(vty
, "%*srt redirect import %s\n",
16622 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16626 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16627 afi_t afi
, safi_t safi
)
16629 struct bgp_filter
*filter
;
16633 filter
= &peer
->filter
[afi
][safi
];
16635 /* distribute-list. */
16636 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16638 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16639 filter
->dlist
[FILTER_IN
].name
);
16641 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16643 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16644 filter
->dlist
[FILTER_OUT
].name
);
16647 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16649 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16650 filter
->plist
[FILTER_IN
].name
);
16652 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16654 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16655 filter
->plist
[FILTER_OUT
].name
);
16658 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16659 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16660 filter
->map
[RMAP_IN
].name
);
16662 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16664 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16665 filter
->map
[RMAP_OUT
].name
);
16667 /* unsuppress-map */
16668 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16669 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16670 filter
->usmap
.name
);
16672 /* advertise-map : always applied in OUT direction*/
16673 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16674 CONDITION_NON_EXIST
))
16676 " neighbor %s advertise-map %s non-exist-map %s\n",
16677 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16679 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16681 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16682 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16685 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16687 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16688 filter
->aslist
[FILTER_IN
].name
);
16690 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16692 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16693 filter
->aslist
[FILTER_OUT
].name
);
16696 /* BGP peer configuration display function. */
16697 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16700 struct peer
*g_peer
= NULL
;
16701 char buf
[SU_ADDRSTRLEN
];
16703 int if_pg_printed
= false;
16704 int if_ras_printed
= false;
16706 /* Skip dynamic neighbors. */
16707 if (peer_dynamic_neighbor(peer
))
16711 addr
= peer
->conf_if
;
16715 /************************************
16716 ****** Global to the neighbor ******
16717 ************************************/
16718 if (peer
->conf_if
) {
16719 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16720 vty_out(vty
, " neighbor %s interface v6only", addr
);
16722 vty_out(vty
, " neighbor %s interface", addr
);
16724 if (peer_group_active(peer
)) {
16725 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16726 if_pg_printed
= true;
16727 } else if (peer
->as_type
== AS_SPECIFIED
) {
16728 vty_out(vty
, " remote-as %u", peer
->as
);
16729 if_ras_printed
= true;
16730 } else if (peer
->as_type
== AS_INTERNAL
) {
16731 vty_out(vty
, " remote-as internal");
16732 if_ras_printed
= true;
16733 } else if (peer
->as_type
== AS_EXTERNAL
) {
16734 vty_out(vty
, " remote-as external");
16735 if_ras_printed
= true;
16738 vty_out(vty
, "\n");
16741 /* remote-as and peer-group */
16742 /* peer is a member of a peer-group */
16743 if (peer_group_active(peer
)) {
16744 g_peer
= peer
->group
->conf
;
16746 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16747 if (peer
->as_type
== AS_SPECIFIED
) {
16748 vty_out(vty
, " neighbor %s remote-as %u\n",
16750 } else if (peer
->as_type
== AS_INTERNAL
) {
16752 " neighbor %s remote-as internal\n",
16754 } else if (peer
->as_type
== AS_EXTERNAL
) {
16756 " neighbor %s remote-as external\n",
16761 /* For swpX peers we displayed the peer-group
16762 * via 'neighbor swpX interface peer-group PGNAME' */
16763 if (!if_pg_printed
)
16764 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16765 peer
->group
->name
);
16768 /* peer is NOT a member of a peer-group */
16770 /* peer is a peer-group, declare the peer-group */
16771 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16772 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16775 if (!if_ras_printed
) {
16776 if (peer
->as_type
== AS_SPECIFIED
) {
16777 vty_out(vty
, " neighbor %s remote-as %u\n",
16779 } else if (peer
->as_type
== AS_INTERNAL
) {
16781 " neighbor %s remote-as internal\n",
16783 } else if (peer
->as_type
== AS_EXTERNAL
) {
16785 " neighbor %s remote-as external\n",
16792 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16793 vty_out(vty
, " neighbor %s local-as %u", addr
,
16794 peer
->change_local_as
);
16795 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16796 vty_out(vty
, " no-prepend");
16797 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16798 vty_out(vty
, " replace-as");
16799 vty_out(vty
, "\n");
16804 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16808 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16809 if (peer
->tx_shutdown_message
)
16810 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16811 peer
->tx_shutdown_message
);
16813 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16816 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16817 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16818 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16821 if (peer
->bfd_info
) {
16822 if (!peer_group_active(peer
) || !g_peer
->bfd_info
) {
16823 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16828 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16829 vty_out(vty
, " neighbor %s password %s\n", addr
,
16832 /* neighbor solo */
16833 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16834 if (!peer_group_active(peer
)) {
16835 vty_out(vty
, " neighbor %s solo\n", addr
);
16840 if (peer
->port
!= BGP_PORT_DEFAULT
) {
16841 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
16844 /* Local interface name */
16845 if (peer
->ifname
) {
16846 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
16850 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
16851 vty_out(vty
, " neighbor %s passive\n", addr
);
16853 /* ebgp-multihop */
16854 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
16855 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
16856 && peer
->ttl
== MAXTTL
)) {
16857 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
16858 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
16863 /* ttl-security hops */
16864 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
16865 if (!peer_group_active(peer
)
16866 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
16867 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
16868 addr
, peer
->gtsm_hops
);
16872 /* disable-connected-check */
16873 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
16874 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
16876 /* enforce-first-as */
16877 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
16878 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
16880 /* update-source */
16881 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
16882 if (peer
->update_source
)
16883 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16884 sockunion2str(peer
->update_source
, buf
,
16886 else if (peer
->update_if
)
16887 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16891 /* advertisement-interval */
16892 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
16893 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
16897 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
16898 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
16899 peer
->keepalive
, peer
->holdtime
);
16901 /* timers connect */
16902 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
16903 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16905 /* need special-case handling for changed default values due to
16906 * config profile / version (because there is no "timers bgp connect"
16907 * command, we need to save this per-peer :/)
16909 else if (!peer_group_active(peer
) && !peer
->connect
&&
16910 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
16911 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16912 peer
->bgp
->default_connect_retry
);
16914 /* timers delayopen */
16915 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
16916 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16918 /* Save config even though flag is not set if default values have been
16921 else if (!peer_group_active(peer
) && !peer
->delayopen
16922 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
16923 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16924 peer
->bgp
->default_delayopen
);
16926 /* capability dynamic */
16927 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
16928 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
16930 /* capability extended-nexthop */
16931 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
16932 if (!peer
->conf_if
) {
16933 if (CHECK_FLAG(peer
->flags_invert
,
16934 PEER_FLAG_CAPABILITY_ENHE
))
16936 " no neighbor %s capability extended-nexthop\n",
16940 " neighbor %s capability extended-nexthop\n",
16945 /* dont-capability-negotiation */
16946 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
16947 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
16949 /* override-capability */
16950 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
16951 vty_out(vty
, " neighbor %s override-capability\n", addr
);
16953 /* strict-capability-match */
16954 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
16955 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
16957 /* Sender side AS path loop detection. */
16958 if (peer
->as_path_loop_detection
)
16959 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
16962 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16963 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
16965 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16966 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
16968 " neighbor %s graceful-restart-helper\n", addr
);
16969 } else if (CHECK_FLAG(
16970 peer
->peer_gr_new_status_flag
,
16971 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
16973 " neighbor %s graceful-restart\n", addr
);
16975 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16976 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
16978 peer
->peer_gr_new_status_flag
,
16979 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
16980 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
16986 /* BGP peer configuration display function. */
16987 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
16988 struct peer
*peer
, afi_t afi
, safi_t safi
)
16990 struct peer
*g_peer
= NULL
;
16992 bool flag_scomm
, flag_secomm
, flag_slcomm
;
16994 /* Skip dynamic neighbors. */
16995 if (peer_dynamic_neighbor(peer
))
16999 addr
= peer
->conf_if
;
17003 /************************************
17004 ****** Per AF to the neighbor ******
17005 ************************************/
17006 if (peer_group_active(peer
)) {
17007 g_peer
= peer
->group
->conf
;
17009 /* If the peer-group is active but peer is not, print a 'no
17011 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
17012 vty_out(vty
, " no neighbor %s activate\n", addr
);
17015 /* If the peer-group is not active but peer is, print an
17017 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
17018 vty_out(vty
, " neighbor %s activate\n", addr
);
17021 if (peer
->afc
[afi
][safi
]) {
17022 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
17023 && safi
== SAFI_UNICAST
) {
17025 && CHECK_FLAG(bgp
->flags
,
17026 BGP_FLAG_NO_DEFAULT_IPV4
)) {
17027 vty_out(vty
, " neighbor %s activate\n",
17029 } else if (afi
== AFI_IP6
17032 BGP_FLAG_DEFAULT_IPV6
)) {
17033 vty_out(vty
, " neighbor %s activate\n",
17037 vty_out(vty
, " neighbor %s activate\n", addr
);
17040 if ((afi
== AFI_IP
|| afi
== AFI_IP6
)
17041 && safi
== SAFI_UNICAST
) {
17043 && !CHECK_FLAG(bgp
->flags
,
17044 BGP_FLAG_NO_DEFAULT_IPV4
)) {
17046 " no neighbor %s activate\n",
17048 } else if (afi
== AFI_IP6
17051 BGP_FLAG_DEFAULT_IPV6
)) {
17053 " no neighbor %s activate\n",
17060 /* addpath TX knobs */
17061 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
17062 switch (peer
->addpath_type
[afi
][safi
]) {
17063 case BGP_ADDPATH_ALL
:
17064 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
17067 case BGP_ADDPATH_BEST_PER_AS
:
17069 " neighbor %s addpath-tx-bestpath-per-AS\n",
17072 case BGP_ADDPATH_MAX
:
17073 case BGP_ADDPATH_NONE
:
17078 /* ORF capability. */
17079 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
17080 || peergroup_af_flag_check(peer
, afi
, safi
,
17081 PEER_FLAG_ORF_PREFIX_RM
)) {
17082 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
17084 if (peergroup_af_flag_check(peer
, afi
, safi
,
17085 PEER_FLAG_ORF_PREFIX_SM
)
17086 && peergroup_af_flag_check(peer
, afi
, safi
,
17087 PEER_FLAG_ORF_PREFIX_RM
))
17088 vty_out(vty
, " both");
17089 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17090 PEER_FLAG_ORF_PREFIX_SM
))
17091 vty_out(vty
, " send");
17093 vty_out(vty
, " receive");
17094 vty_out(vty
, "\n");
17097 /* Route reflector client. */
17098 if (peergroup_af_flag_check(peer
, afi
, safi
,
17099 PEER_FLAG_REFLECTOR_CLIENT
)) {
17100 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
17103 /* next-hop-self force */
17104 if (peergroup_af_flag_check(peer
, afi
, safi
,
17105 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
17106 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
17109 /* next-hop-self */
17110 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
17111 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
17114 /* remove-private-AS */
17115 if (peergroup_af_flag_check(peer
, afi
, safi
,
17116 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
17117 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
17121 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17122 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
17123 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
17127 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17128 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
17129 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
17132 else if (peergroup_af_flag_check(peer
, afi
, safi
,
17133 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
17134 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
17138 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
17139 vty_out(vty
, " neighbor %s as-override\n", addr
);
17142 /* send-community print. */
17143 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17144 PEER_FLAG_SEND_COMMUNITY
);
17145 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17146 PEER_FLAG_SEND_EXT_COMMUNITY
);
17147 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
17148 PEER_FLAG_SEND_LARGE_COMMUNITY
);
17150 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
17151 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
17154 vty_out(vty
, " no neighbor %s send-community\n", addr
);
17157 " no neighbor %s send-community extended\n",
17161 vty_out(vty
, " no neighbor %s send-community large\n",
17165 /* Default information */
17166 if (peergroup_af_flag_check(peer
, afi
, safi
,
17167 PEER_FLAG_DEFAULT_ORIGINATE
)) {
17168 vty_out(vty
, " neighbor %s default-originate", addr
);
17170 if (peer
->default_rmap
[afi
][safi
].name
)
17171 vty_out(vty
, " route-map %s",
17172 peer
->default_rmap
[afi
][safi
].name
);
17174 vty_out(vty
, "\n");
17177 /* Soft reconfiguration inbound. */
17178 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
17179 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
17183 /* maximum-prefix. */
17184 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
17185 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
17186 peer
->pmax
[afi
][safi
]);
17188 if (peer
->pmax_threshold
[afi
][safi
]
17189 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
17190 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
17191 if (peer_af_flag_check(peer
, afi
, safi
,
17192 PEER_FLAG_MAX_PREFIX_WARNING
))
17193 vty_out(vty
, " warning-only");
17194 if (peer
->pmax_restart
[afi
][safi
])
17195 vty_out(vty
, " restart %u",
17196 peer
->pmax_restart
[afi
][safi
]);
17197 if (peer_af_flag_check(peer
, afi
, safi
,
17198 PEER_FLAG_MAX_PREFIX_FORCE
))
17199 vty_out(vty
, " force");
17201 vty_out(vty
, "\n");
17204 /* maximum-prefix-out */
17205 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17206 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17207 addr
, peer
->pmax_out
[afi
][safi
]);
17209 /* Route server client. */
17210 if (peergroup_af_flag_check(peer
, afi
, safi
,
17211 PEER_FLAG_RSERVER_CLIENT
)) {
17212 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17215 /* Nexthop-local unchanged. */
17216 if (peergroup_af_flag_check(peer
, afi
, safi
,
17217 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17218 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17221 /* allowas-in <1-10> */
17222 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17223 if (peer_af_flag_check(peer
, afi
, safi
,
17224 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17225 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17226 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17227 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17229 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17230 peer
->allowas_in
[afi
][safi
]);
17235 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17236 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17237 peer
->weight
[afi
][safi
]);
17240 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17242 /* atribute-unchanged. */
17243 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17244 || (safi
!= SAFI_EVPN
17245 && peer_af_flag_check(peer
, afi
, safi
,
17246 PEER_FLAG_NEXTHOP_UNCHANGED
))
17247 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17249 if (!peer_group_active(peer
)
17250 || peergroup_af_flag_check(peer
, afi
, safi
,
17251 PEER_FLAG_AS_PATH_UNCHANGED
)
17252 || peergroup_af_flag_check(peer
, afi
, safi
,
17253 PEER_FLAG_NEXTHOP_UNCHANGED
)
17254 || peergroup_af_flag_check(peer
, afi
, safi
,
17255 PEER_FLAG_MED_UNCHANGED
)) {
17258 " neighbor %s attribute-unchanged%s%s%s\n",
17260 peer_af_flag_check(peer
, afi
, safi
,
17261 PEER_FLAG_AS_PATH_UNCHANGED
)
17264 peer_af_flag_check(peer
, afi
, safi
,
17265 PEER_FLAG_NEXTHOP_UNCHANGED
)
17268 peer_af_flag_check(peer
, afi
, safi
,
17269 PEER_FLAG_MED_UNCHANGED
)
17276 /* Address family based peer configuration display. */
17277 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17281 struct peer_group
*group
;
17282 struct listnode
*node
, *nnode
;
17285 vty_frame(vty
, " !\n address-family ");
17286 if (afi
== AFI_IP
) {
17287 if (safi
== SAFI_UNICAST
)
17288 vty_frame(vty
, "ipv4 unicast");
17289 else if (safi
== SAFI_LABELED_UNICAST
)
17290 vty_frame(vty
, "ipv4 labeled-unicast");
17291 else if (safi
== SAFI_MULTICAST
)
17292 vty_frame(vty
, "ipv4 multicast");
17293 else if (safi
== SAFI_MPLS_VPN
)
17294 vty_frame(vty
, "ipv4 vpn");
17295 else if (safi
== SAFI_ENCAP
)
17296 vty_frame(vty
, "ipv4 encap");
17297 else if (safi
== SAFI_FLOWSPEC
)
17298 vty_frame(vty
, "ipv4 flowspec");
17299 } else if (afi
== AFI_IP6
) {
17300 if (safi
== SAFI_UNICAST
)
17301 vty_frame(vty
, "ipv6 unicast");
17302 else if (safi
== SAFI_LABELED_UNICAST
)
17303 vty_frame(vty
, "ipv6 labeled-unicast");
17304 else if (safi
== SAFI_MULTICAST
)
17305 vty_frame(vty
, "ipv6 multicast");
17306 else if (safi
== SAFI_MPLS_VPN
)
17307 vty_frame(vty
, "ipv6 vpn");
17308 else if (safi
== SAFI_ENCAP
)
17309 vty_frame(vty
, "ipv6 encap");
17310 else if (safi
== SAFI_FLOWSPEC
)
17311 vty_frame(vty
, "ipv6 flowspec");
17312 } else if (afi
== AFI_L2VPN
) {
17313 if (safi
== SAFI_EVPN
)
17314 vty_frame(vty
, "l2vpn evpn");
17316 vty_frame(vty
, "\n");
17318 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17320 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17322 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17324 /* BGP flag dampening. */
17325 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17326 bgp_config_write_damp(vty
, bgp
, afi
, safi
);
17327 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, node
, group
))
17328 if (peer_af_flag_check(group
->conf
, afi
, safi
,
17329 PEER_FLAG_CONFIG_DAMPENING
))
17330 bgp_config_write_peer_damp(vty
, group
->conf
, afi
, safi
);
17331 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, node
, peer
))
17332 if (peer_af_flag_check(peer
, afi
, safi
,
17333 PEER_FLAG_CONFIG_DAMPENING
))
17334 bgp_config_write_peer_damp(vty
, peer
, afi
, safi
);
17336 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17337 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17339 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17340 /* Skip dynamic neighbors. */
17341 if (peer_dynamic_neighbor(peer
))
17344 /* Do not display doppelganger peers */
17345 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17346 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17349 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17350 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17352 if (safi
== SAFI_EVPN
)
17353 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17355 if (safi
== SAFI_FLOWSPEC
)
17356 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17358 if (safi
== SAFI_UNICAST
) {
17359 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17360 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17361 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17363 vty_out(vty
, " export vpn\n");
17365 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17366 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17368 vty_out(vty
, " import vpn\n");
17370 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17371 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17374 for (ALL_LIST_ELEMENTS_RO(
17375 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17377 vty_out(vty
, " import vrf %s\n", name
);
17381 vty_endframe(vty
, " exit-address-family\n");
17384 int bgp_config_write(struct vty
*vty
)
17387 struct peer_group
*group
;
17389 struct listnode
*node
, *nnode
;
17390 struct listnode
*mnode
, *mnnode
;
17392 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17393 vty_out(vty
, "bgp route-map delay-timer %u\n",
17394 bm
->rmap_update_timer
);
17396 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17397 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17398 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17399 vty_out(vty
, " %d", bm
->v_establish_wait
);
17400 vty_out(vty
, "\n");
17403 if (bm
->wait_for_fib
)
17404 vty_out(vty
, "bgp suppress-fib-pending\n");
17406 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17407 vty_out(vty
, "bgp graceful-shutdown\n");
17409 /* No-RIB (Zebra) option flag configuration */
17410 if (bgp_option_check(BGP_OPT_NO_FIB
))
17411 vty_out(vty
, "bgp no-rib\n");
17413 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17414 vty_out(vty
, "no bgp send-extra-data zebra\n");
17416 /* BGP configuration. */
17417 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17419 /* skip all auto created vrf as they dont have user config */
17420 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17423 /* Router bgp ASN */
17424 vty_out(vty
, "router bgp %u", bgp
->as
);
17427 vty_out(vty
, " %s %s",
17428 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17429 ? "view" : "vrf", bgp
->name
);
17430 vty_out(vty
, "\n");
17432 /* BGP fast-external-failover. */
17433 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17434 vty_out(vty
, " no bgp fast-external-failover\n");
17436 /* BGP router ID. */
17437 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17438 vty_out(vty
, " bgp router-id %pI4\n",
17439 &bgp
->router_id_static
);
17441 /* Suppress fib pending */
17442 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17443 vty_out(vty
, " bgp suppress-fib-pending\n");
17445 /* BGP log-neighbor-changes. */
17446 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17447 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17448 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17449 CHECK_FLAG(bgp
->flags
,
17450 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17454 /* BGP configuration. */
17455 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17456 vty_out(vty
, " bgp always-compare-med\n");
17458 /* RFC8212 default eBGP policy. */
17459 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17460 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17461 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17462 CHECK_FLAG(bgp
->flags
,
17463 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17467 /* draft-ietf-idr-deprecate-as-set-confed-set */
17468 if (bgp
->reject_as_sets
)
17469 vty_out(vty
, " bgp reject-as-sets\n");
17471 /* Suppress duplicate updates if the route actually not changed
17473 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17474 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17475 vty_out(vty
, " %sbgp suppress-duplicates\n",
17476 CHECK_FLAG(bgp
->flags
,
17477 BGP_FLAG_SUPPRESS_DUPLICATES
)
17481 /* BGP default ipv4-unicast. */
17482 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
))
17483 vty_out(vty
, " no bgp default ipv4-unicast\n");
17485 /* BGP default ipv6-unicast. */
17486 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DEFAULT_IPV6
))
17487 vty_out(vty
, " bgp default ipv6-unicast\n");
17489 /* BGP default local-preference. */
17490 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17491 vty_out(vty
, " bgp default local-preference %u\n",
17492 bgp
->default_local_pref
);
17494 /* BGP default show-hostname */
17495 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17496 != SAVE_BGP_SHOW_HOSTNAME
)
17497 vty_out(vty
, " %sbgp default show-hostname\n",
17498 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17502 /* BGP default show-nexthop-hostname */
17503 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17504 != SAVE_BGP_SHOW_HOSTNAME
)
17505 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17506 CHECK_FLAG(bgp
->flags
,
17507 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17511 /* BGP default subgroup-pkt-queue-max. */
17512 if (bgp
->default_subgroup_pkt_queue_max
17513 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17514 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17515 bgp
->default_subgroup_pkt_queue_max
);
17517 /* BGP client-to-client reflection. */
17518 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17519 vty_out(vty
, " no bgp client-to-client reflection\n");
17521 /* BGP cluster ID. */
17522 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17523 vty_out(vty
, " bgp cluster-id %pI4\n",
17526 /* Disable ebgp connected nexthop check */
17527 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17529 " bgp disable-ebgp-connected-route-check\n");
17531 /* Confederation identifier*/
17532 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17533 vty_out(vty
, " bgp confederation identifier %u\n",
17536 /* Confederation peer */
17537 if (bgp
->confed_peers_cnt
> 0) {
17540 vty_out(vty
, " bgp confederation peers");
17542 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17543 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17545 vty_out(vty
, "\n");
17548 /* BGP deterministic-med. */
17549 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17550 != SAVE_BGP_DETERMINISTIC_MED
)
17551 vty_out(vty
, " %sbgp deterministic-med\n",
17552 CHECK_FLAG(bgp
->flags
,
17553 BGP_FLAG_DETERMINISTIC_MED
)
17557 /* BGP update-delay. */
17558 bgp_config_write_update_delay(vty
, bgp
);
17560 if (bgp
->v_maxmed_onstartup
17561 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17562 vty_out(vty
, " bgp max-med on-startup %u",
17563 bgp
->v_maxmed_onstartup
);
17564 if (bgp
->maxmed_onstartup_value
17565 != BGP_MAXMED_VALUE_DEFAULT
)
17566 vty_out(vty
, " %u",
17567 bgp
->maxmed_onstartup_value
);
17568 vty_out(vty
, "\n");
17570 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17571 vty_out(vty
, " bgp max-med administrative");
17572 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17573 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17574 vty_out(vty
, "\n");
17578 bgp_config_write_wpkt_quanta(vty
, bgp
);
17580 bgp_config_write_rpkt_quanta(vty
, bgp
);
17582 /* coalesce time */
17583 bgp_config_write_coalesce_time(vty
, bgp
);
17585 /* BGP per-instance graceful-shutdown */
17586 /* BGP-wide settings and per-instance settings are mutually
17589 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17590 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17591 vty_out(vty
, " bgp graceful-shutdown\n");
17593 /* BGP graceful-restart. */
17594 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17596 " bgp graceful-restart stalepath-time %u\n",
17597 bgp
->stalepath_time
);
17599 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17600 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17601 bgp
->restart_time
);
17603 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17605 " bgp graceful-restart select-defer-time %u\n",
17606 bgp
->select_defer_time
);
17608 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17609 vty_out(vty
, " bgp graceful-restart\n");
17611 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17612 vty_out(vty
, " bgp graceful-restart-disable\n");
17614 /* BGP graceful-restart Preserve State F bit. */
17615 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17617 " bgp graceful-restart preserve-fw-state\n");
17619 /* Stale timer for RIB */
17620 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17622 " bgp graceful-restart rib-stale-time %u\n",
17623 bgp
->rib_stale_time
);
17625 /* BGP bestpath method. */
17626 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17627 vty_out(vty
, " bgp bestpath as-path ignore\n");
17628 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17629 vty_out(vty
, " bgp bestpath as-path confed\n");
17631 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17632 if (CHECK_FLAG(bgp
->flags
,
17633 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17635 " bgp bestpath as-path multipath-relax as-set\n");
17638 " bgp bestpath as-path multipath-relax\n");
17642 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17644 " bgp route-reflector allow-outbound-policy\n");
17646 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17647 vty_out(vty
, " bgp bestpath compare-routerid\n");
17648 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17649 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17650 vty_out(vty
, " bgp bestpath med");
17651 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17652 vty_out(vty
, " confed");
17653 if (CHECK_FLAG(bgp
->flags
,
17654 BGP_FLAG_MED_MISSING_AS_WORST
))
17655 vty_out(vty
, " missing-as-worst");
17656 vty_out(vty
, "\n");
17659 /* Link bandwidth handling. */
17660 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17661 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17662 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17663 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17664 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17665 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17667 /* BGP network import check. */
17668 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17669 != SAVE_BGP_IMPORT_CHECK
)
17670 vty_out(vty
, " %sbgp network import-check\n",
17671 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17675 /* BGP timers configuration. */
17676 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17677 && bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17678 vty_out(vty
, " timers bgp %u %u\n",
17679 bgp
->default_keepalive
, bgp
->default_holdtime
);
17682 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17683 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17686 /* Normal neighbor configuration. */
17687 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17688 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17689 bgp_config_write_peer_global(vty
, bgp
, peer
);
17692 /* listen range and limit for dynamic BGP neighbors */
17693 bgp_config_write_listen(vty
, bgp
);
17696 * BGP default autoshutdown neighbors
17698 * This must be placed after any peer and peer-group
17699 * configuration, to avoid setting all peers to shutdown after
17700 * a daemon restart, which is undesired behavior. (see #2286)
17702 if (bgp
->autoshutdown
)
17703 vty_out(vty
, " bgp default shutdown\n");
17705 /* BGP instance administrative shutdown */
17706 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17707 vty_out(vty
, " bgp shutdown\n");
17709 /* IPv4 unicast configuration. */
17710 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17712 /* IPv4 multicast configuration. */
17713 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17715 /* IPv4 labeled-unicast configuration. */
17716 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17718 /* IPv4 VPN configuration. */
17719 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17721 /* ENCAPv4 configuration. */
17722 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17724 /* FLOWSPEC v4 configuration. */
17725 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17727 /* IPv6 unicast configuration. */
17728 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17730 /* IPv6 multicast configuration. */
17731 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17733 /* IPv6 labeled-unicast configuration. */
17734 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17735 SAFI_LABELED_UNICAST
);
17737 /* IPv6 VPN configuration. */
17738 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17740 /* ENCAPv6 configuration. */
17741 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17743 /* FLOWSPEC v6 configuration. */
17744 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17746 /* EVPN configuration. */
17747 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17749 hook_call(bgp_inst_config_write
, bgp
, vty
);
17751 #ifdef ENABLE_BGP_VNC
17752 bgp_rfapi_cfg_write(vty
, bgp
);
17755 vty_out(vty
, "!\n");
17761 /* BGP node structure. */
17762 static struct cmd_node bgp_node
= {
17765 .parent_node
= CONFIG_NODE
,
17766 .prompt
= "%s(config-router)# ",
17767 .config_write
= bgp_config_write
,
17770 static struct cmd_node bgp_ipv4_unicast_node
= {
17771 .name
= "bgp ipv4 unicast",
17772 .node
= BGP_IPV4_NODE
,
17773 .parent_node
= BGP_NODE
,
17774 .prompt
= "%s(config-router-af)# ",
17777 static struct cmd_node bgp_ipv4_multicast_node
= {
17778 .name
= "bgp ipv4 multicast",
17779 .node
= BGP_IPV4M_NODE
,
17780 .parent_node
= BGP_NODE
,
17781 .prompt
= "%s(config-router-af)# ",
17784 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
17785 .name
= "bgp ipv4 labeled unicast",
17786 .node
= BGP_IPV4L_NODE
,
17787 .parent_node
= BGP_NODE
,
17788 .prompt
= "%s(config-router-af)# ",
17791 static struct cmd_node bgp_ipv6_unicast_node
= {
17792 .name
= "bgp ipv6",
17793 .node
= BGP_IPV6_NODE
,
17794 .parent_node
= BGP_NODE
,
17795 .prompt
= "%s(config-router-af)# ",
17798 static struct cmd_node bgp_ipv6_multicast_node
= {
17799 .name
= "bgp ipv6 multicast",
17800 .node
= BGP_IPV6M_NODE
,
17801 .parent_node
= BGP_NODE
,
17802 .prompt
= "%s(config-router-af)# ",
17805 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
17806 .name
= "bgp ipv6 labeled unicast",
17807 .node
= BGP_IPV6L_NODE
,
17808 .parent_node
= BGP_NODE
,
17809 .prompt
= "%s(config-router-af)# ",
17812 static struct cmd_node bgp_vpnv4_node
= {
17813 .name
= "bgp vpnv4",
17814 .node
= BGP_VPNV4_NODE
,
17815 .parent_node
= BGP_NODE
,
17816 .prompt
= "%s(config-router-af)# ",
17819 static struct cmd_node bgp_vpnv6_node
= {
17820 .name
= "bgp vpnv6",
17821 .node
= BGP_VPNV6_NODE
,
17822 .parent_node
= BGP_NODE
,
17823 .prompt
= "%s(config-router-af-vpnv6)# ",
17826 static struct cmd_node bgp_evpn_node
= {
17827 .name
= "bgp evpn",
17828 .node
= BGP_EVPN_NODE
,
17829 .parent_node
= BGP_NODE
,
17830 .prompt
= "%s(config-router-evpn)# ",
17833 static struct cmd_node bgp_evpn_vni_node
= {
17834 .name
= "bgp evpn vni",
17835 .node
= BGP_EVPN_VNI_NODE
,
17836 .parent_node
= BGP_EVPN_NODE
,
17837 .prompt
= "%s(config-router-af-vni)# ",
17840 static struct cmd_node bgp_flowspecv4_node
= {
17841 .name
= "bgp ipv4 flowspec",
17842 .node
= BGP_FLOWSPECV4_NODE
,
17843 .parent_node
= BGP_NODE
,
17844 .prompt
= "%s(config-router-af)# ",
17847 static struct cmd_node bgp_flowspecv6_node
= {
17848 .name
= "bgp ipv6 flowspec",
17849 .node
= BGP_FLOWSPECV6_NODE
,
17850 .parent_node
= BGP_NODE
,
17851 .prompt
= "%s(config-router-af-vpnv6)# ",
17854 static void community_list_vty(void);
17856 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
17860 struct listnode
*lnbgp
, *lnpeer
;
17862 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17863 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
17864 /* only provide suggestions on the appropriate input
17866 * they'll otherwise show up multiple times */
17867 enum cmd_token_type match_type
;
17868 char *name
= peer
->host
;
17870 if (peer
->conf_if
) {
17871 match_type
= VARIABLE_TKN
;
17872 name
= peer
->conf_if
;
17873 } else if (strchr(peer
->host
, ':'))
17874 match_type
= IPV6_TKN
;
17876 match_type
= IPV4_TKN
;
17878 if (token
->type
!= match_type
)
17881 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
17886 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
17887 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
17888 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
17889 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
17890 {.completions
= NULL
}};
17892 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
17895 struct peer_group
*group
;
17896 struct listnode
*lnbgp
, *lnpeer
;
17898 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17899 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
17900 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
17905 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
17906 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
17907 {.completions
= NULL
} };
17909 void bgp_vty_init(void)
17911 cmd_variable_handler_register(bgp_var_neighbor
);
17912 cmd_variable_handler_register(bgp_var_peergroup
);
17914 /* Install bgp top node. */
17915 install_node(&bgp_node
);
17916 install_node(&bgp_ipv4_unicast_node
);
17917 install_node(&bgp_ipv4_multicast_node
);
17918 install_node(&bgp_ipv4_labeled_unicast_node
);
17919 install_node(&bgp_ipv6_unicast_node
);
17920 install_node(&bgp_ipv6_multicast_node
);
17921 install_node(&bgp_ipv6_labeled_unicast_node
);
17922 install_node(&bgp_vpnv4_node
);
17923 install_node(&bgp_vpnv6_node
);
17924 install_node(&bgp_evpn_node
);
17925 install_node(&bgp_evpn_vni_node
);
17926 install_node(&bgp_flowspecv4_node
);
17927 install_node(&bgp_flowspecv6_node
);
17929 /* Install default VTY commands to new nodes. */
17930 install_default(BGP_NODE
);
17931 install_default(BGP_IPV4_NODE
);
17932 install_default(BGP_IPV4M_NODE
);
17933 install_default(BGP_IPV4L_NODE
);
17934 install_default(BGP_IPV6_NODE
);
17935 install_default(BGP_IPV6M_NODE
);
17936 install_default(BGP_IPV6L_NODE
);
17937 install_default(BGP_VPNV4_NODE
);
17938 install_default(BGP_VPNV6_NODE
);
17939 install_default(BGP_FLOWSPECV4_NODE
);
17940 install_default(BGP_FLOWSPECV6_NODE
);
17941 install_default(BGP_EVPN_NODE
);
17942 install_default(BGP_EVPN_VNI_NODE
);
17944 /* "bgp local-mac" hidden commands. */
17945 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
17946 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
17948 /* "bgp suppress-fib-pending" global */
17949 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
17951 /* bgp route-map delay-timer commands. */
17952 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17953 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17955 /* global bgp update-delay command */
17956 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
17957 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
17959 /* global bgp graceful-shutdown command */
17960 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
17961 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
17963 /* Dummy commands (Currently not supported) */
17964 install_element(BGP_NODE
, &no_synchronization_cmd
);
17965 install_element(BGP_NODE
, &no_auto_summary_cmd
);
17967 /* "router bgp" commands. */
17968 install_element(CONFIG_NODE
, &router_bgp_cmd
);
17970 /* "no router bgp" commands. */
17971 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
17973 /* "bgp router-id" commands. */
17974 install_element(BGP_NODE
, &bgp_router_id_cmd
);
17975 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
17977 /* "bgp suppress-fib-pending" command */
17978 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
17980 /* "bgp cluster-id" commands. */
17981 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
17982 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
17984 /* "bgp no-rib" commands. */
17985 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
17986 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
17988 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
17990 /* "bgp confederation" commands. */
17991 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
17992 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
17994 /* "bgp confederation peers" commands. */
17995 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
17996 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
17998 /* bgp max-med command */
17999 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
18000 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
18001 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
18002 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
18003 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
18005 /* bgp disable-ebgp-connected-nh-check */
18006 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
18007 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
18009 /* bgp update-delay command */
18010 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
18011 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
18013 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
18014 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
18016 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
18017 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
18019 /* "maximum-paths" commands. */
18020 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
18021 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
18022 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
18023 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
18024 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
18025 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
18026 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
18027 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
18028 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
18029 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
18030 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18031 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18032 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
18033 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18034 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18036 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
18037 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
18038 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18039 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18040 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18041 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
18042 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
18043 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
18044 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
18045 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
18047 /* "timers bgp" commands. */
18048 install_element(BGP_NODE
, &bgp_timers_cmd
);
18049 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
18051 /* route-map delay-timer commands - per instance for backwards compat.
18053 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
18054 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
18056 /* "bgp client-to-client reflection" commands */
18057 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
18058 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
18060 /* "bgp always-compare-med" commands */
18061 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
18062 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
18064 /* bgp ebgp-requires-policy */
18065 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
18066 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
18068 /* bgp suppress-duplicates */
18069 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
18070 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
18072 /* bgp reject-as-sets */
18073 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
18074 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
18076 /* "bgp deterministic-med" commands */
18077 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
18078 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
18080 /* "bgp graceful-restart" command */
18081 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
18082 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
18084 /* "bgp graceful-restart-disable" command */
18085 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
18086 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
18088 /* "neighbor a:b:c:d graceful-restart" command */
18089 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
18090 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
18092 /* "neighbor a:b:c:d graceful-restart-disable" command */
18093 install_element(BGP_NODE
,
18094 &bgp_neighbor_graceful_restart_disable_set_cmd
);
18095 install_element(BGP_NODE
,
18096 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
18098 /* "neighbor a:b:c:d graceful-restart-helper" command */
18099 install_element(BGP_NODE
,
18100 &bgp_neighbor_graceful_restart_helper_set_cmd
);
18101 install_element(BGP_NODE
,
18102 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
18104 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
18105 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
18106 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
18107 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
18108 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
18109 install_element(BGP_NODE
,
18110 &no_bgp_graceful_restart_select_defer_time_cmd
);
18111 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
18112 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
18114 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
18115 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
18116 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
18117 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
18119 /* "bgp graceful-shutdown" commands */
18120 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
18121 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
18123 /* "bgp fast-external-failover" commands */
18124 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
18125 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
18127 /* "bgp bestpath compare-routerid" commands */
18128 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
18129 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
18131 /* "bgp bestpath as-path ignore" commands */
18132 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
18133 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
18135 /* "bgp bestpath as-path confed" commands */
18136 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
18137 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
18139 /* "bgp bestpath as-path multipath-relax" commands */
18140 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
18141 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
18143 /* "bgp log-neighbor-changes" commands */
18144 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
18145 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
18147 /* "bgp bestpath med" commands */
18148 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
18149 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
18151 /* "bgp bestpath bandwidth" commands */
18152 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
18153 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
18155 /* "no bgp default ipv4-unicast" commands. */
18156 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
18157 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
18159 /* "no bgp default ipv6-unicast" commands. */
18160 install_element(BGP_NODE
, &no_bgp_default_ipv6_unicast_cmd
);
18161 install_element(BGP_NODE
, &bgp_default_ipv6_unicast_cmd
);
18163 /* "bgp network import-check" commands. */
18164 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
18165 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
18166 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
18168 /* "bgp default local-preference" commands. */
18169 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
18170 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
18172 /* bgp default show-hostname */
18173 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
18174 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
18176 /* bgp default show-nexthop-hostname */
18177 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
18178 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
18180 /* "bgp default subgroup-pkt-queue-max" commands. */
18181 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
18182 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
18184 /* bgp ibgp-allow-policy-mods command */
18185 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
18186 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
18188 /* "bgp listen limit" commands. */
18189 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
18190 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
18192 /* "bgp listen range" commands. */
18193 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
18194 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
18196 /* "bgp default shutdown" command */
18197 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
18199 /* "bgp shutdown" commands */
18200 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
18201 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
18202 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
18203 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
18205 /* "neighbor remote-as" commands. */
18206 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
18207 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
18208 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
18209 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
18210 install_element(BGP_NODE
,
18211 &neighbor_interface_v6only_config_remote_as_cmd
);
18212 install_element(BGP_NODE
, &no_neighbor_cmd
);
18213 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
18215 /* "neighbor peer-group" commands. */
18216 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
18217 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
18218 install_element(BGP_NODE
,
18219 &no_neighbor_interface_peer_group_remote_as_cmd
);
18221 /* "neighbor local-as" commands. */
18222 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
18223 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
18224 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
18225 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
18227 /* "neighbor solo" commands. */
18228 install_element(BGP_NODE
, &neighbor_solo_cmd
);
18229 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
18231 /* "neighbor password" commands. */
18232 install_element(BGP_NODE
, &neighbor_password_cmd
);
18233 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
18235 /* "neighbor activate" commands. */
18236 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
18237 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
18238 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
18239 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
18240 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
18241 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
18242 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
18243 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
18244 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
18245 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
18246 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
18247 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
18249 /* "no neighbor activate" commands. */
18250 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
18251 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
18252 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
18253 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
18254 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
18255 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
18256 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
18257 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
18258 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
18259 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
18260 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
18261 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
18263 /* "neighbor peer-group" set commands. */
18264 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
18265 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18266 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18267 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18268 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18269 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18270 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18271 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18272 install_element(BGP_FLOWSPECV4_NODE
,
18273 &neighbor_set_peer_group_hidden_cmd
);
18274 install_element(BGP_FLOWSPECV6_NODE
,
18275 &neighbor_set_peer_group_hidden_cmd
);
18277 /* "no neighbor peer-group unset" commands. */
18278 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
18279 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18280 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18281 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18282 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18283 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18284 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18285 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18286 install_element(BGP_FLOWSPECV4_NODE
,
18287 &no_neighbor_set_peer_group_hidden_cmd
);
18288 install_element(BGP_FLOWSPECV6_NODE
,
18289 &no_neighbor_set_peer_group_hidden_cmd
);
18291 /* "neighbor softreconfiguration inbound" commands.*/
18292 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
18293 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
18294 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18295 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18296 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18297 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18298 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18299 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18300 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18301 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18302 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18303 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18304 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18305 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18306 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18307 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18308 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18309 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18310 install_element(BGP_FLOWSPECV4_NODE
,
18311 &neighbor_soft_reconfiguration_cmd
);
18312 install_element(BGP_FLOWSPECV4_NODE
,
18313 &no_neighbor_soft_reconfiguration_cmd
);
18314 install_element(BGP_FLOWSPECV6_NODE
,
18315 &neighbor_soft_reconfiguration_cmd
);
18316 install_element(BGP_FLOWSPECV6_NODE
,
18317 &no_neighbor_soft_reconfiguration_cmd
);
18318 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
18319 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18321 /* "neighbor attribute-unchanged" commands. */
18322 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
18323 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
18324 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
18325 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18326 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
18327 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18328 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
18329 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18330 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
18331 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18332 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
18333 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18334 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
18335 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18336 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
18337 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18338 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
18339 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18341 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
18342 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
18344 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
18345 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18346 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
18347 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18349 /* "nexthop-local unchanged" commands */
18350 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
18351 install_element(BGP_IPV6_NODE
,
18352 &no_neighbor_nexthop_local_unchanged_cmd
);
18354 /* "neighbor next-hop-self" commands. */
18355 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
18356 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
18357 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
18358 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18359 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
18360 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
18361 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
18362 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
18363 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
18364 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18365 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
18366 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
18367 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
18368 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
18369 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
18370 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18371 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
18372 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18373 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
18374 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
18376 /* "neighbor next-hop-self force" commands. */
18377 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
18378 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
18379 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18380 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
18381 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18382 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18383 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18384 install_element(BGP_IPV4_NODE
,
18385 &no_neighbor_nexthop_self_all_hidden_cmd
);
18386 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
18387 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18388 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18389 install_element(BGP_IPV4M_NODE
,
18390 &no_neighbor_nexthop_self_all_hidden_cmd
);
18391 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
18392 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18393 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18394 install_element(BGP_IPV4L_NODE
,
18395 &no_neighbor_nexthop_self_all_hidden_cmd
);
18396 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18397 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18398 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18399 install_element(BGP_IPV6_NODE
,
18400 &no_neighbor_nexthop_self_all_hidden_cmd
);
18401 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
18402 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18403 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18404 install_element(BGP_IPV6M_NODE
,
18405 &no_neighbor_nexthop_self_all_hidden_cmd
);
18406 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
18407 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18408 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18409 install_element(BGP_IPV6L_NODE
,
18410 &no_neighbor_nexthop_self_all_hidden_cmd
);
18411 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18412 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18413 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18414 install_element(BGP_VPNV4_NODE
,
18415 &no_neighbor_nexthop_self_all_hidden_cmd
);
18416 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18417 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18418 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18419 install_element(BGP_VPNV6_NODE
,
18420 &no_neighbor_nexthop_self_all_hidden_cmd
);
18421 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
18422 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18424 /* "neighbor as-override" commands. */
18425 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
18426 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
18427 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
18428 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
18429 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
18430 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
18431 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
18432 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
18433 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
18434 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
18435 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
18436 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
18437 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
18438 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
18439 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
18440 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
18441 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
18442 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
18444 /* "neighbor remove-private-AS" commands. */
18445 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
18446 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
18447 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
18448 install_element(BGP_NODE
,
18449 &no_neighbor_remove_private_as_all_hidden_cmd
);
18450 install_element(BGP_NODE
,
18451 &neighbor_remove_private_as_replace_as_hidden_cmd
);
18452 install_element(BGP_NODE
,
18453 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
18454 install_element(BGP_NODE
,
18455 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18458 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18459 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
18460 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18461 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18462 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18463 install_element(BGP_IPV4_NODE
,
18464 &neighbor_remove_private_as_replace_as_cmd
);
18465 install_element(BGP_IPV4_NODE
,
18466 &no_neighbor_remove_private_as_replace_as_cmd
);
18467 install_element(BGP_IPV4_NODE
,
18468 &neighbor_remove_private_as_all_replace_as_cmd
);
18469 install_element(BGP_IPV4_NODE
,
18470 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18471 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
18472 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
18473 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
18474 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18475 install_element(BGP_IPV4M_NODE
,
18476 &neighbor_remove_private_as_replace_as_cmd
);
18477 install_element(BGP_IPV4M_NODE
,
18478 &no_neighbor_remove_private_as_replace_as_cmd
);
18479 install_element(BGP_IPV4M_NODE
,
18480 &neighbor_remove_private_as_all_replace_as_cmd
);
18481 install_element(BGP_IPV4M_NODE
,
18482 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18483 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
18484 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
18485 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
18486 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18487 install_element(BGP_IPV4L_NODE
,
18488 &neighbor_remove_private_as_replace_as_cmd
);
18489 install_element(BGP_IPV4L_NODE
,
18490 &no_neighbor_remove_private_as_replace_as_cmd
);
18491 install_element(BGP_IPV4L_NODE
,
18492 &neighbor_remove_private_as_all_replace_as_cmd
);
18493 install_element(BGP_IPV4L_NODE
,
18494 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18495 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
18496 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18497 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18498 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18499 install_element(BGP_IPV6_NODE
,
18500 &neighbor_remove_private_as_replace_as_cmd
);
18501 install_element(BGP_IPV6_NODE
,
18502 &no_neighbor_remove_private_as_replace_as_cmd
);
18503 install_element(BGP_IPV6_NODE
,
18504 &neighbor_remove_private_as_all_replace_as_cmd
);
18505 install_element(BGP_IPV6_NODE
,
18506 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18507 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
18508 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
18509 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
18510 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18511 install_element(BGP_IPV6M_NODE
,
18512 &neighbor_remove_private_as_replace_as_cmd
);
18513 install_element(BGP_IPV6M_NODE
,
18514 &no_neighbor_remove_private_as_replace_as_cmd
);
18515 install_element(BGP_IPV6M_NODE
,
18516 &neighbor_remove_private_as_all_replace_as_cmd
);
18517 install_element(BGP_IPV6M_NODE
,
18518 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18519 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
18520 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
18521 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
18522 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18523 install_element(BGP_IPV6L_NODE
,
18524 &neighbor_remove_private_as_replace_as_cmd
);
18525 install_element(BGP_IPV6L_NODE
,
18526 &no_neighbor_remove_private_as_replace_as_cmd
);
18527 install_element(BGP_IPV6L_NODE
,
18528 &neighbor_remove_private_as_all_replace_as_cmd
);
18529 install_element(BGP_IPV6L_NODE
,
18530 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18531 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
18532 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18533 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18534 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18535 install_element(BGP_VPNV4_NODE
,
18536 &neighbor_remove_private_as_replace_as_cmd
);
18537 install_element(BGP_VPNV4_NODE
,
18538 &no_neighbor_remove_private_as_replace_as_cmd
);
18539 install_element(BGP_VPNV4_NODE
,
18540 &neighbor_remove_private_as_all_replace_as_cmd
);
18541 install_element(BGP_VPNV4_NODE
,
18542 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18543 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
18544 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18545 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18546 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18547 install_element(BGP_VPNV6_NODE
,
18548 &neighbor_remove_private_as_replace_as_cmd
);
18549 install_element(BGP_VPNV6_NODE
,
18550 &no_neighbor_remove_private_as_replace_as_cmd
);
18551 install_element(BGP_VPNV6_NODE
,
18552 &neighbor_remove_private_as_all_replace_as_cmd
);
18553 install_element(BGP_VPNV6_NODE
,
18554 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18556 /* "neighbor send-community" commands.*/
18557 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
18558 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
18559 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
18560 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
18561 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
18562 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
18563 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
18564 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
18565 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
18566 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
18567 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
18568 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
18569 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
18570 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
18571 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
18572 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
18573 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
18574 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
18575 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
18576 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
18577 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
18578 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
18579 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
18580 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
18581 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
18582 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
18583 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
18584 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
18585 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
18586 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
18587 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
18588 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
18589 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
18590 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
18591 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
18592 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
18594 /* "neighbor route-reflector" commands.*/
18595 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
18596 install_element(BGP_NODE
,
18597 &no_neighbor_route_reflector_client_hidden_cmd
);
18598 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
18599 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
18600 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
18601 install_element(BGP_IPV4M_NODE
,
18602 &no_neighbor_route_reflector_client_cmd
);
18603 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
18604 install_element(BGP_IPV4L_NODE
,
18605 &no_neighbor_route_reflector_client_cmd
);
18606 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
18607 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
18608 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
18609 install_element(BGP_IPV6M_NODE
,
18610 &no_neighbor_route_reflector_client_cmd
);
18611 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
18612 install_element(BGP_IPV6L_NODE
,
18613 &no_neighbor_route_reflector_client_cmd
);
18614 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
18615 install_element(BGP_VPNV4_NODE
,
18616 &no_neighbor_route_reflector_client_cmd
);
18617 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
18618 install_element(BGP_VPNV6_NODE
,
18619 &no_neighbor_route_reflector_client_cmd
);
18620 install_element(BGP_FLOWSPECV4_NODE
,
18621 &neighbor_route_reflector_client_cmd
);
18622 install_element(BGP_FLOWSPECV4_NODE
,
18623 &no_neighbor_route_reflector_client_cmd
);
18624 install_element(BGP_FLOWSPECV6_NODE
,
18625 &neighbor_route_reflector_client_cmd
);
18626 install_element(BGP_FLOWSPECV6_NODE
,
18627 &no_neighbor_route_reflector_client_cmd
);
18628 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
18629 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
18631 /* "neighbor route-server" commands.*/
18632 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
18633 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
18634 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
18635 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
18636 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
18637 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
18638 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
18639 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
18640 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
18641 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
18642 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
18643 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
18644 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
18645 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
18646 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
18647 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
18648 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
18649 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
18650 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
18651 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
18652 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
18653 install_element(BGP_FLOWSPECV4_NODE
,
18654 &no_neighbor_route_server_client_cmd
);
18655 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
18656 install_element(BGP_FLOWSPECV6_NODE
,
18657 &no_neighbor_route_server_client_cmd
);
18659 /* "neighbor addpath-tx-all-paths" commands.*/
18660 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
18661 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
18662 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18663 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18664 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18665 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18666 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18667 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18668 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18669 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18670 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18671 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18672 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18673 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18674 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18675 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18676 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18677 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18679 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
18680 install_element(BGP_NODE
,
18681 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18682 install_element(BGP_NODE
,
18683 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18684 install_element(BGP_IPV4_NODE
,
18685 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18686 install_element(BGP_IPV4_NODE
,
18687 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18688 install_element(BGP_IPV4M_NODE
,
18689 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18690 install_element(BGP_IPV4M_NODE
,
18691 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18692 install_element(BGP_IPV4L_NODE
,
18693 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18694 install_element(BGP_IPV4L_NODE
,
18695 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18696 install_element(BGP_IPV6_NODE
,
18697 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18698 install_element(BGP_IPV6_NODE
,
18699 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18700 install_element(BGP_IPV6M_NODE
,
18701 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18702 install_element(BGP_IPV6M_NODE
,
18703 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18704 install_element(BGP_IPV6L_NODE
,
18705 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18706 install_element(BGP_IPV6L_NODE
,
18707 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18708 install_element(BGP_VPNV4_NODE
,
18709 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18710 install_element(BGP_VPNV4_NODE
,
18711 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18712 install_element(BGP_VPNV6_NODE
,
18713 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18714 install_element(BGP_VPNV6_NODE
,
18715 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18717 /* "neighbor sender-as-path-loop-detection" commands. */
18718 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
18719 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
18721 /* "neighbor passive" commands. */
18722 install_element(BGP_NODE
, &neighbor_passive_cmd
);
18723 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
18726 /* "neighbor shutdown" commands. */
18727 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
18728 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
18729 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
18730 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
18731 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
18732 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
18734 /* "neighbor capability extended-nexthop" commands.*/
18735 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
18736 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
18738 /* "neighbor capability orf prefix-list" commands.*/
18739 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
18740 install_element(BGP_NODE
,
18741 &no_neighbor_capability_orf_prefix_hidden_cmd
);
18742 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
18743 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18744 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18745 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18746 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18747 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18748 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
18749 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18750 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18751 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18752 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18753 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18755 /* "neighbor capability dynamic" commands.*/
18756 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
18757 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
18759 /* "neighbor dont-capability-negotiate" commands. */
18760 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
18761 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
18763 /* "neighbor ebgp-multihop" commands. */
18764 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
18765 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
18766 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
18768 /* "neighbor disable-connected-check" commands. */
18769 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
18770 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
18772 /* "neighbor enforce-first-as" commands. */
18773 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
18774 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
18776 /* "neighbor description" commands. */
18777 install_element(BGP_NODE
, &neighbor_description_cmd
);
18778 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
18779 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
18781 /* "neighbor update-source" commands. "*/
18782 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
18783 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
18785 /* "neighbor default-originate" commands. */
18786 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
18787 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
18788 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
18789 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
18790 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
18791 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
18792 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
18793 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
18794 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
18795 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
18796 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
18797 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
18798 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
18799 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
18800 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
18801 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
18802 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
18803 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
18804 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
18805 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
18806 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
18808 /* "neighbor port" commands. */
18809 install_element(BGP_NODE
, &neighbor_port_cmd
);
18810 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
18812 /* "neighbor weight" commands. */
18813 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
18814 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
18816 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
18817 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
18818 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
18819 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
18820 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
18821 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
18822 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
18823 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
18824 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
18825 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
18826 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
18827 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
18828 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
18829 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
18830 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
18831 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
18833 /* "neighbor override-capability" commands. */
18834 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
18835 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
18837 /* "neighbor strict-capability-match" commands. */
18838 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
18839 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
18841 /* "neighbor timers" commands. */
18842 install_element(BGP_NODE
, &neighbor_timers_cmd
);
18843 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
18845 /* "neighbor timers connect" commands. */
18846 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
18847 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
18849 /* "neighbor timers delayopen" commands. */
18850 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
18851 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
18853 /* "neighbor advertisement-interval" commands. */
18854 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
18855 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
18857 /* "neighbor interface" commands. */
18858 install_element(BGP_NODE
, &neighbor_interface_cmd
);
18859 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
18861 /* "neighbor distribute" commands. */
18862 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
18863 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
18864 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
18865 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
18866 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
18867 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
18868 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
18869 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
18870 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
18871 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
18872 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
18873 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
18874 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
18875 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
18876 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
18877 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
18878 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
18879 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
18881 /* "neighbor prefix-list" commands. */
18882 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
18883 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
18884 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
18885 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
18886 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
18887 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
18888 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
18889 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
18890 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
18891 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
18892 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
18894 /* "neighbor filter-list" commands. */
18895 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
18896 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
18897 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
18898 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
18899 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
18900 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
18901 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
18902 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
18903 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
18904 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
18905 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
18906 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
18907 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
18908 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
18909 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
18910 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
18911 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
18912 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
18913 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
18914 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
18915 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
18916 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
18918 /* "neighbor route-map" commands. */
18919 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
18920 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
18921 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
18922 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
18923 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
18924 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
18925 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
18926 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
18927 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
18928 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
18929 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
18931 /* "neighbor unsuppress-map" commands. */
18932 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
18933 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
18934 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
18935 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18936 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
18937 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18938 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
18939 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18940 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
18941 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18942 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
18943 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18944 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
18945 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18946 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
18947 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18948 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
18949 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18951 /* "neighbor advertise-map" commands. */
18952 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
18953 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
18954 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
18955 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
18956 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
18957 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
18958 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
18959 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
18960 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
18962 /* neighbor maximum-prefix-out commands. */
18963 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
18964 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18965 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18966 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18967 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18968 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18969 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18970 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18971 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18972 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18973 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18974 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18975 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18976 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18977 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18978 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18979 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18980 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18982 /* "neighbor maximum-prefix" commands. */
18983 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
18984 install_element(BGP_NODE
,
18985 &neighbor_maximum_prefix_threshold_hidden_cmd
);
18986 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
18987 install_element(BGP_NODE
,
18988 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
18989 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
18990 install_element(BGP_NODE
,
18991 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
18992 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
18993 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
18994 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18995 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18996 install_element(BGP_IPV4_NODE
,
18997 &neighbor_maximum_prefix_threshold_warning_cmd
);
18998 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18999 install_element(BGP_IPV4_NODE
,
19000 &neighbor_maximum_prefix_threshold_restart_cmd
);
19001 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19002 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
19003 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19004 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19005 install_element(BGP_IPV4M_NODE
,
19006 &neighbor_maximum_prefix_threshold_warning_cmd
);
19007 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19008 install_element(BGP_IPV4M_NODE
,
19009 &neighbor_maximum_prefix_threshold_restart_cmd
);
19010 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19011 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
19012 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19013 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19014 install_element(BGP_IPV4L_NODE
,
19015 &neighbor_maximum_prefix_threshold_warning_cmd
);
19016 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19017 install_element(BGP_IPV4L_NODE
,
19018 &neighbor_maximum_prefix_threshold_restart_cmd
);
19019 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19020 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
19021 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19022 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19023 install_element(BGP_IPV6_NODE
,
19024 &neighbor_maximum_prefix_threshold_warning_cmd
);
19025 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19026 install_element(BGP_IPV6_NODE
,
19027 &neighbor_maximum_prefix_threshold_restart_cmd
);
19028 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19029 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
19030 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19031 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19032 install_element(BGP_IPV6M_NODE
,
19033 &neighbor_maximum_prefix_threshold_warning_cmd
);
19034 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19035 install_element(BGP_IPV6M_NODE
,
19036 &neighbor_maximum_prefix_threshold_restart_cmd
);
19037 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
19038 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
19039 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19040 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19041 install_element(BGP_IPV6L_NODE
,
19042 &neighbor_maximum_prefix_threshold_warning_cmd
);
19043 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19044 install_element(BGP_IPV6L_NODE
,
19045 &neighbor_maximum_prefix_threshold_restart_cmd
);
19046 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
19047 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
19048 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19049 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19050 install_element(BGP_VPNV4_NODE
,
19051 &neighbor_maximum_prefix_threshold_warning_cmd
);
19052 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19053 install_element(BGP_VPNV4_NODE
,
19054 &neighbor_maximum_prefix_threshold_restart_cmd
);
19055 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
19056 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
19057 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
19058 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
19059 install_element(BGP_VPNV6_NODE
,
19060 &neighbor_maximum_prefix_threshold_warning_cmd
);
19061 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
19062 install_element(BGP_VPNV6_NODE
,
19063 &neighbor_maximum_prefix_threshold_restart_cmd
);
19064 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
19066 /* "neighbor allowas-in" */
19067 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
19068 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
19069 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
19070 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
19071 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
19072 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
19073 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
19074 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
19075 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
19076 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
19077 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
19078 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
19079 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
19080 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
19081 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
19082 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
19083 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
19084 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
19085 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
19086 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
19088 /* "neighbor dampening" commands. */
19089 install_element(BGP_NODE
, &neighbor_damp_cmd
);
19090 install_element(BGP_NODE
, &no_neighbor_damp_cmd
);
19091 install_element(BGP_IPV4_NODE
, &neighbor_damp_cmd
);
19092 install_element(BGP_IPV4_NODE
, &no_neighbor_damp_cmd
);
19093 install_element(BGP_IPV4M_NODE
, &neighbor_damp_cmd
);
19094 install_element(BGP_IPV4M_NODE
, &no_neighbor_damp_cmd
);
19095 install_element(BGP_IPV4L_NODE
, &neighbor_damp_cmd
);
19096 install_element(BGP_IPV4L_NODE
, &no_neighbor_damp_cmd
);
19097 install_element(BGP_IPV6_NODE
, &neighbor_damp_cmd
);
19098 install_element(BGP_IPV6_NODE
, &no_neighbor_damp_cmd
);
19099 install_element(BGP_IPV6M_NODE
, &neighbor_damp_cmd
);
19100 install_element(BGP_IPV6M_NODE
, &no_neighbor_damp_cmd
);
19101 install_element(BGP_IPV6L_NODE
, &neighbor_damp_cmd
);
19102 install_element(BGP_IPV6L_NODE
, &no_neighbor_damp_cmd
);
19103 install_element(VIEW_NODE
, &show_ip_bgp_neighbor_damp_param_cmd
);
19105 /* address-family commands. */
19106 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
19107 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
19108 #ifdef KEEP_OLD_VPN_COMMANDS
19109 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
19110 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
19111 #endif /* KEEP_OLD_VPN_COMMANDS */
19113 install_element(BGP_NODE
, &address_family_evpn_cmd
);
19115 /* "exit-address-family" command. */
19116 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
19117 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
19118 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
19119 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
19120 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
19121 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
19122 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
19123 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
19124 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
19125 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
19126 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
19128 /* "clear ip bgp commands" */
19129 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
19131 /* clear ip bgp prefix */
19132 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
19133 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
19134 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
19136 /* "show [ip] bgp summary" commands. */
19137 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
19138 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
19139 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
19140 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
19141 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
19142 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
19143 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
19145 /* "show [ip] bgp neighbors" commands. */
19146 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
19148 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
19150 /* "show [ip] bgp peer-group" commands. */
19151 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
19153 /* "show [ip] bgp paths" commands. */
19154 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
19156 /* "show [ip] bgp community" commands. */
19157 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
19159 /* "show ip bgp large-community" commands. */
19160 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
19161 /* "show [ip] bgp attribute-info" commands. */
19162 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
19163 /* "show [ip] bgp route-leak" command */
19164 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
19166 /* "redistribute" commands. */
19167 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
19168 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
19169 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
19170 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
19171 install_element(BGP_NODE
,
19172 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
19173 install_element(BGP_NODE
,
19174 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
19175 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
19176 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
19177 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
19178 install_element(BGP_NODE
,
19179 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
19180 install_element(BGP_NODE
,
19181 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
19182 install_element(BGP_NODE
,
19183 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
19184 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
19185 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
19186 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
19187 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
19188 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
19189 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
19190 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
19191 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
19192 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
19193 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
19194 install_element(BGP_IPV4_NODE
,
19195 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
19196 install_element(BGP_IPV4_NODE
,
19197 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
19198 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
19199 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
19200 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
19201 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
19202 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
19203 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
19205 /* import|export vpn [route-map WORD] */
19206 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
19207 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
19209 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
19210 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
19212 /* ttl_security commands */
19213 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
19214 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
19216 /* "show [ip] bgp memory" commands. */
19217 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
19219 /* "show bgp martian next-hop" */
19220 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
19222 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
19224 /* "show [ip] bgp views" commands. */
19225 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
19227 /* "show [ip] bgp vrfs" commands. */
19228 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
19230 /* Community-list. */
19231 community_list_vty();
19233 /* vpn-policy commands */
19234 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
19235 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
19236 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
19237 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
19238 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
19239 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
19240 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
19241 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
19242 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
19243 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
19244 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
19245 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
19247 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
19248 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
19250 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
19251 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
19252 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
19253 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
19254 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
19255 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
19256 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19257 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19258 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
19259 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
19262 #include "memory.h"
19263 #include "bgp_regex.h"
19264 #include "bgp_clist.h"
19265 #include "bgp_ecommunity.h"
19267 /* VTY functions. */
19269 /* Direction value to string conversion. */
19270 static const char *community_direct_str(int direct
)
19273 case COMMUNITY_DENY
:
19275 case COMMUNITY_PERMIT
:
19282 /* Display error string. */
19283 static void community_list_perror(struct vty
*vty
, int ret
)
19286 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
19287 vty_out(vty
, "%% Can't find community-list\n");
19289 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
19290 vty_out(vty
, "%% Malformed community-list value\n");
19292 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
19294 "%% Community name conflict, previously defined as standard community\n");
19296 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
19298 "%% Community name conflict, previously defined as expanded community\n");
19303 /* "community-list" keyword help string. */
19304 #define COMMUNITY_LIST_STR "Add a community list entry\n"
19306 /*community-list standard */
19307 DEFUN (community_list_standard
,
19308 bgp_community_list_standard_cmd
,
19309 "bgp community-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
19312 "Community list number (standard)\n"
19313 "Add an standard community-list entry\n"
19314 "Community list name\n"
19315 "Sequence number of an entry\n"
19316 "Sequence number\n"
19317 "Specify community to reject\n"
19318 "Specify community to accept\n"
19321 char *cl_name_or_number
= NULL
;
19324 int style
= COMMUNITY_LIST_STANDARD
;
19327 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19329 seq
= argv
[idx
]->arg
;
19332 argv_find(argv
, argc
, "(1-99)", &idx
);
19333 argv_find(argv
, argc
, "WORD", &idx
);
19334 cl_name_or_number
= argv
[idx
]->arg
;
19335 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19337 argv_find(argv
, argc
, "AA:NN", &idx
);
19338 char *str
= argv_concat(argv
, argc
, idx
);
19340 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19343 XFREE(MTYPE_TMP
, str
);
19346 /* Display error string. */
19347 community_list_perror(vty
, ret
);
19348 return CMD_WARNING_CONFIG_FAILED
;
19351 return CMD_SUCCESS
;
19354 DEFUN (no_community_list_standard_all
,
19355 no_bgp_community_list_standard_all_cmd
,
19356 "no bgp community-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
19360 "Community list number (standard)\n"
19361 "Add an standard community-list entry\n"
19362 "Community list name\n"
19363 "Sequence number of an entry\n"
19364 "Sequence number\n"
19365 "Specify community to reject\n"
19366 "Specify community to accept\n"
19369 char *cl_name_or_number
= NULL
;
19372 int style
= COMMUNITY_LIST_STANDARD
;
19376 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19378 seq
= argv
[idx
]->arg
;
19381 argv_find(argv
, argc
, "permit", &idx
);
19382 argv_find(argv
, argc
, "deny", &idx
);
19385 direct
= argv_find(argv
, argc
, "permit", &idx
)
19390 argv_find(argv
, argc
, "AA:NN", &idx
);
19391 str
= argv_concat(argv
, argc
, idx
);
19395 argv_find(argv
, argc
, "(1-99)", &idx
);
19396 argv_find(argv
, argc
, "WORD", &idx
);
19397 cl_name_or_number
= argv
[idx
]->arg
;
19399 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19402 XFREE(MTYPE_TMP
, str
);
19405 community_list_perror(vty
, ret
);
19406 return CMD_WARNING_CONFIG_FAILED
;
19409 return CMD_SUCCESS
;
19412 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
19413 "no bgp community-list <(1-99)|standard WORD>",
19414 NO_STR BGP_STR COMMUNITY_LIST_STR
19415 "Community list number (standard)\n"
19416 "Add an standard community-list entry\n"
19417 "Community list name\n")
19419 /*community-list expanded */
19420 DEFUN (community_list_expanded_all
,
19421 bgp_community_list_expanded_all_cmd
,
19422 "bgp community-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
19425 "Community list number (expanded)\n"
19426 "Add an expanded community-list entry\n"
19427 "Community list name\n"
19428 "Sequence number of an entry\n"
19429 "Sequence number\n"
19430 "Specify community to reject\n"
19431 "Specify community to accept\n"
19434 char *cl_name_or_number
= NULL
;
19437 int style
= COMMUNITY_LIST_EXPANDED
;
19440 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19442 seq
= argv
[idx
]->arg
;
19446 argv_find(argv
, argc
, "(100-500)", &idx
);
19447 argv_find(argv
, argc
, "WORD", &idx
);
19448 cl_name_or_number
= argv
[idx
]->arg
;
19449 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19451 argv_find(argv
, argc
, "AA:NN", &idx
);
19452 char *str
= argv_concat(argv
, argc
, idx
);
19454 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19457 XFREE(MTYPE_TMP
, str
);
19460 /* Display error string. */
19461 community_list_perror(vty
, ret
);
19462 return CMD_WARNING_CONFIG_FAILED
;
19465 return CMD_SUCCESS
;
19468 DEFUN (no_community_list_expanded_all
,
19469 no_bgp_community_list_expanded_all_cmd
,
19470 "no bgp community-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
19474 "Community list number (expanded)\n"
19475 "Add an expanded community-list entry\n"
19476 "Community list name\n"
19477 "Sequence number of an entry\n"
19478 "Sequence number\n"
19479 "Specify community to reject\n"
19480 "Specify community to accept\n"
19483 char *cl_name_or_number
= NULL
;
19487 int style
= COMMUNITY_LIST_EXPANDED
;
19490 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19492 seq
= argv
[idx
]->arg
;
19495 argv_find(argv
, argc
, "permit", &idx
);
19496 argv_find(argv
, argc
, "deny", &idx
);
19499 direct
= argv_find(argv
, argc
, "permit", &idx
)
19504 argv_find(argv
, argc
, "AA:NN", &idx
);
19505 str
= argv_concat(argv
, argc
, idx
);
19509 argv_find(argv
, argc
, "(100-500)", &idx
);
19510 argv_find(argv
, argc
, "WORD", &idx
);
19511 cl_name_or_number
= argv
[idx
]->arg
;
19513 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19516 XFREE(MTYPE_TMP
, str
);
19519 community_list_perror(vty
, ret
);
19520 return CMD_WARNING_CONFIG_FAILED
;
19523 return CMD_SUCCESS
;
19526 ALIAS(no_community_list_expanded_all
,
19527 no_bgp_community_list_expanded_all_list_cmd
,
19528 "no bgp community-list <(100-500)|expanded WORD>",
19529 NO_STR BGP_STR COMMUNITY_LIST_STR
19530 "Community list number (expanded)\n"
19531 "Add an expanded community-list entry\n"
19532 "Community list name\n")
19534 /* Return configuration string of community-list entry. */
19535 static const char *community_list_config_str(struct community_entry
*entry
)
19542 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
19543 str
= community_str(entry
->u
.com
, false);
19544 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
19545 str
= lcommunity_str(entry
->u
.lcom
, false);
19547 str
= entry
->config
;
19552 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
19554 struct community_entry
*entry
;
19556 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19557 if (entry
== list
->head
) {
19558 if (all_digit(list
->name
))
19559 vty_out(vty
, "Community %s list %s\n",
19560 entry
->style
== COMMUNITY_LIST_STANDARD
19562 : "(expanded) access",
19565 vty_out(vty
, "Named Community %s list %s\n",
19566 entry
->style
== COMMUNITY_LIST_STANDARD
19572 vty_out(vty
, " %s\n",
19573 community_direct_str(entry
->direct
));
19575 vty_out(vty
, " %s %s\n",
19576 community_direct_str(entry
->direct
),
19577 community_list_config_str(entry
));
19581 DEFUN (show_community_list
,
19582 show_bgp_community_list_cmd
,
19583 "show bgp community-list",
19586 "List community-list\n")
19588 struct community_list
*list
;
19589 struct community_list_master
*cm
;
19591 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19593 return CMD_SUCCESS
;
19595 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19596 community_list_show(vty
, list
);
19598 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19599 community_list_show(vty
, list
);
19601 return CMD_SUCCESS
;
19604 DEFUN (show_community_list_arg
,
19605 show_bgp_community_list_arg_cmd
,
19606 "show bgp community-list <(1-500)|WORD> detail",
19609 "List community-list\n"
19610 "Community-list number\n"
19611 "Community-list name\n"
19612 "Detailed information on community-list\n")
19614 int idx_comm_list
= 3;
19615 struct community_list
*list
;
19617 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
19618 COMMUNITY_LIST_MASTER
);
19620 vty_out(vty
, "%% Can't find community-list\n");
19621 return CMD_WARNING
;
19624 community_list_show(vty
, list
);
19626 return CMD_SUCCESS
;
19630 * Large Community code.
19632 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
19633 struct cmd_token
**argv
, int style
,
19634 int reject_all_digit_name
)
19643 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19644 seq
= argv
[idx
]->arg
;
19647 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19650 /* All digit name check. */
19652 argv_find(argv
, argc
, "WORD", &idx
);
19653 argv_find(argv
, argc
, "(1-99)", &idx
);
19654 argv_find(argv
, argc
, "(100-500)", &idx
);
19655 cl_name
= argv
[idx
]->arg
;
19656 if (reject_all_digit_name
&& all_digit(cl_name
)) {
19657 vty_out(vty
, "%% Community name cannot have all digits\n");
19658 return CMD_WARNING_CONFIG_FAILED
;
19662 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
19663 argv_find(argv
, argc
, "LINE", &idx
);
19664 /* Concat community string argument. */
19666 str
= argv_concat(argv
, argc
, idx
);
19670 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
19672 /* Free temporary community list string allocated by
19674 XFREE(MTYPE_TMP
, str
);
19677 community_list_perror(vty
, ret
);
19678 return CMD_WARNING_CONFIG_FAILED
;
19680 return CMD_SUCCESS
;
19683 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
19684 struct cmd_token
**argv
, int style
)
19692 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19693 seq
= argv
[idx
]->arg
;
19696 argv_find(argv
, argc
, "permit", &idx
);
19697 argv_find(argv
, argc
, "deny", &idx
);
19700 /* Check the list direct. */
19701 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
19702 direct
= COMMUNITY_PERMIT
;
19704 direct
= COMMUNITY_DENY
;
19707 argv_find(argv
, argc
, "LINE", &idx
);
19708 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
19709 /* Concat community string argument. */
19710 str
= argv_concat(argv
, argc
, idx
);
19714 argv_find(argv
, argc
, "(1-99)", &idx
);
19715 argv_find(argv
, argc
, "(100-500)", &idx
);
19716 argv_find(argv
, argc
, "WORD", &idx
);
19718 /* Unset community list. */
19719 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
19722 /* Free temporary community list string allocated by
19724 XFREE(MTYPE_TMP
, str
);
19727 community_list_perror(vty
, ret
);
19728 return CMD_WARNING_CONFIG_FAILED
;
19731 return CMD_SUCCESS
;
19734 /* "large-community-list" keyword help string. */
19735 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
19736 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
19738 DEFUN (lcommunity_list_standard
,
19739 bgp_lcommunity_list_standard_cmd
,
19740 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
19742 LCOMMUNITY_LIST_STR
19743 "Large Community list number (standard)\n"
19744 "Sequence number of an entry\n"
19745 "Sequence number\n"
19746 "Specify large community to reject\n"
19747 "Specify large community to accept\n"
19748 LCOMMUNITY_VAL_STR
)
19750 return lcommunity_list_set_vty(vty
, argc
, argv
,
19751 LARGE_COMMUNITY_LIST_STANDARD
, 0);
19754 DEFUN (lcommunity_list_expanded
,
19755 bgp_lcommunity_list_expanded_cmd
,
19756 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
19758 LCOMMUNITY_LIST_STR
19759 "Large Community list number (expanded)\n"
19760 "Sequence number of an entry\n"
19761 "Sequence number\n"
19762 "Specify large community to reject\n"
19763 "Specify large community to accept\n"
19764 "An ordered list as a regular-expression\n")
19766 return lcommunity_list_set_vty(vty
, argc
, argv
,
19767 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
19770 DEFUN (lcommunity_list_name_standard
,
19771 bgp_lcommunity_list_name_standard_cmd
,
19772 "bgp large-community-list standard WORD [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
19774 LCOMMUNITY_LIST_STR
19775 "Specify standard large-community-list\n"
19776 "Large Community list name\n"
19777 "Sequence number of an entry\n"
19778 "Sequence number\n"
19779 "Specify large community to reject\n"
19780 "Specify large community to accept\n"
19781 LCOMMUNITY_VAL_STR
)
19783 return lcommunity_list_set_vty(vty
, argc
, argv
,
19784 LARGE_COMMUNITY_LIST_STANDARD
, 1);
19787 DEFUN (lcommunity_list_name_expanded
,
19788 bgp_lcommunity_list_name_expanded_cmd
,
19789 "bgp large-community-list expanded WORD [seq (0-4294967295)] <deny|permit> LINE...",
19791 LCOMMUNITY_LIST_STR
19792 "Specify expanded large-community-list\n"
19793 "Large Community list name\n"
19794 "Sequence number of an entry\n"
19795 "Sequence number\n"
19796 "Specify large community to reject\n"
19797 "Specify large community to accept\n"
19798 "An ordered list as a regular-expression\n")
19800 return lcommunity_list_set_vty(vty
, argc
, argv
,
19801 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
19804 DEFUN (no_lcommunity_list_all
,
19805 no_bgp_lcommunity_list_all_cmd
,
19806 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
19809 LCOMMUNITY_LIST_STR
19810 "Large Community list number (standard)\n"
19811 "Large Community list number (expanded)\n"
19812 "Large Community list name\n")
19814 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19815 LARGE_COMMUNITY_LIST_STANDARD
);
19818 DEFUN (no_lcommunity_list_name_standard_all
,
19819 no_bgp_lcommunity_list_name_standard_all_cmd
,
19820 "no bgp large-community-list standard WORD",
19823 LCOMMUNITY_LIST_STR
19824 "Specify standard large-community-list\n"
19825 "Large Community list name\n")
19827 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19828 LARGE_COMMUNITY_LIST_STANDARD
);
19831 DEFUN (no_lcommunity_list_name_expanded_all
,
19832 no_bgp_lcommunity_list_name_expanded_all_cmd
,
19833 "no bgp large-community-list expanded WORD",
19836 LCOMMUNITY_LIST_STR
19837 "Specify expanded large-community-list\n"
19838 "Large Community list name\n")
19840 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19841 LARGE_COMMUNITY_LIST_EXPANDED
);
19844 DEFUN (no_lcommunity_list_standard
,
19845 no_bgp_lcommunity_list_standard_cmd
,
19846 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
19849 LCOMMUNITY_LIST_STR
19850 "Large Community list number (standard)\n"
19851 "Sequence number of an entry\n"
19852 "Sequence number\n"
19853 "Specify large community to reject\n"
19854 "Specify large community to accept\n"
19855 LCOMMUNITY_VAL_STR
)
19857 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19858 LARGE_COMMUNITY_LIST_STANDARD
);
19861 DEFUN (no_lcommunity_list_expanded
,
19862 no_bgp_lcommunity_list_expanded_cmd
,
19863 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
19866 LCOMMUNITY_LIST_STR
19867 "Large Community list number (expanded)\n"
19868 "Sequence number of an entry\n"
19869 "Sequence number\n"
19870 "Specify large community to reject\n"
19871 "Specify large community to accept\n"
19872 "An ordered list as a regular-expression\n")
19874 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19875 LARGE_COMMUNITY_LIST_EXPANDED
);
19878 DEFUN (no_lcommunity_list_name_standard
,
19879 no_bgp_lcommunity_list_name_standard_cmd
,
19880 "no bgp large-community-list standard WORD [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
19883 LCOMMUNITY_LIST_STR
19884 "Specify standard large-community-list\n"
19885 "Large Community list name\n"
19886 "Sequence number of an entry\n"
19887 "Sequence number\n"
19888 "Specify large community to reject\n"
19889 "Specify large community to accept\n"
19890 LCOMMUNITY_VAL_STR
)
19892 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19893 LARGE_COMMUNITY_LIST_STANDARD
);
19896 DEFUN (no_lcommunity_list_name_expanded
,
19897 no_bgp_lcommunity_list_name_expanded_cmd
,
19898 "no bgp large-community-list expanded WORD [seq (0-4294967295)] <deny|permit> LINE...",
19901 LCOMMUNITY_LIST_STR
19902 "Specify expanded large-community-list\n"
19903 "Large community list name\n"
19904 "Sequence number of an entry\n"
19905 "Sequence number\n"
19906 "Specify large community to reject\n"
19907 "Specify large community to accept\n"
19908 "An ordered list as a regular-expression\n")
19910 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19911 LARGE_COMMUNITY_LIST_EXPANDED
);
19914 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
19916 struct community_entry
*entry
;
19918 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19919 if (entry
== list
->head
) {
19920 if (all_digit(list
->name
))
19921 vty_out(vty
, "Large community %s list %s\n",
19923 LARGE_COMMUNITY_LIST_STANDARD
19925 : "(expanded) access",
19929 "Named large community %s list %s\n",
19931 LARGE_COMMUNITY_LIST_STANDARD
19937 vty_out(vty
, " %s\n",
19938 community_direct_str(entry
->direct
));
19940 vty_out(vty
, " %s %s\n",
19941 community_direct_str(entry
->direct
),
19942 community_list_config_str(entry
));
19946 DEFUN (show_lcommunity_list
,
19947 show_bgp_lcommunity_list_cmd
,
19948 "show bgp large-community-list",
19951 "List large-community list\n")
19953 struct community_list
*list
;
19954 struct community_list_master
*cm
;
19956 cm
= community_list_master_lookup(bgp_clist
,
19957 LARGE_COMMUNITY_LIST_MASTER
);
19959 return CMD_SUCCESS
;
19961 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19962 lcommunity_list_show(vty
, list
);
19964 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19965 lcommunity_list_show(vty
, list
);
19967 return CMD_SUCCESS
;
19970 DEFUN (show_lcommunity_list_arg
,
19971 show_bgp_lcommunity_list_arg_cmd
,
19972 "show bgp large-community-list <(1-500)|WORD> detail",
19975 "List large-community list\n"
19976 "Large-community-list number\n"
19977 "Large-community-list name\n"
19978 "Detailed information on large-community-list\n")
19980 struct community_list
*list
;
19982 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
19983 LARGE_COMMUNITY_LIST_MASTER
);
19985 vty_out(vty
, "%% Can't find large-community-list\n");
19986 return CMD_WARNING
;
19989 lcommunity_list_show(vty
, list
);
19991 return CMD_SUCCESS
;
19994 /* "extcommunity-list" keyword help string. */
19995 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
19996 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
19998 DEFUN (extcommunity_list_standard
,
19999 bgp_extcommunity_list_standard_cmd
,
20000 "bgp extcommunity-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
20002 EXTCOMMUNITY_LIST_STR
20003 "Extended Community list number (standard)\n"
20004 "Specify standard extcommunity-list\n"
20005 "Community list name\n"
20006 "Sequence number of an entry\n"
20007 "Sequence number\n"
20008 "Specify community to reject\n"
20009 "Specify community to accept\n"
20010 EXTCOMMUNITY_VAL_STR
)
20012 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20014 char *cl_number_or_name
= NULL
;
20019 argv_find(argv
, argc
, "(1-99)", &idx
);
20020 argv_find(argv
, argc
, "WORD", &idx
);
20021 cl_number_or_name
= argv
[idx
]->arg
;
20023 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20024 seq
= argv
[idx
]->arg
;
20026 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20028 argv_find(argv
, argc
, "AA:NN", &idx
);
20029 char *str
= argv_concat(argv
, argc
, idx
);
20031 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20034 XFREE(MTYPE_TMP
, str
);
20037 community_list_perror(vty
, ret
);
20038 return CMD_WARNING_CONFIG_FAILED
;
20041 return CMD_SUCCESS
;
20044 DEFUN (extcommunity_list_name_expanded
,
20045 bgp_extcommunity_list_name_expanded_cmd
,
20046 "bgp extcommunity-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> LINE...",
20048 EXTCOMMUNITY_LIST_STR
20049 "Extended Community list number (expanded)\n"
20050 "Specify expanded extcommunity-list\n"
20051 "Extended Community list name\n"
20052 "Sequence number of an entry\n"
20053 "Sequence number\n"
20054 "Specify community to reject\n"
20055 "Specify community to accept\n"
20056 "An ordered list as a regular-expression\n")
20058 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20060 char *cl_number_or_name
= NULL
;
20064 argv_find(argv
, argc
, "(100-500)", &idx
);
20065 argv_find(argv
, argc
, "WORD", &idx
);
20066 cl_number_or_name
= argv
[idx
]->arg
;
20068 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20069 seq
= argv
[idx
]->arg
;
20071 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
20073 argv_find(argv
, argc
, "LINE", &idx
);
20074 char *str
= argv_concat(argv
, argc
, idx
);
20076 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
20079 XFREE(MTYPE_TMP
, str
);
20082 community_list_perror(vty
, ret
);
20083 return CMD_WARNING_CONFIG_FAILED
;
20086 return CMD_SUCCESS
;
20089 DEFUN (no_extcommunity_list_standard_all
,
20090 no_bgp_extcommunity_list_standard_all_cmd
,
20091 "no bgp extcommunity-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
20094 EXTCOMMUNITY_LIST_STR
20095 "Extended Community list number (standard)\n"
20096 "Specify standard extcommunity-list\n"
20097 "Community list name\n"
20098 "Sequence number of an entry\n"
20099 "Sequence number\n"
20100 "Specify community to reject\n"
20101 "Specify community to accept\n"
20102 EXTCOMMUNITY_VAL_STR
)
20104 int style
= EXTCOMMUNITY_LIST_STANDARD
;
20106 char *cl_number_or_name
= NULL
;
20111 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20112 seq
= argv
[idx
]->arg
;
20115 argv_find(argv
, argc
, "permit", &idx
);
20116 argv_find(argv
, argc
, "deny", &idx
);
20118 direct
= argv_find(argv
, argc
, "permit", &idx
)
20123 argv_find(argv
, argc
, "AA:NN", &idx
);
20124 str
= argv_concat(argv
, argc
, idx
);
20128 argv_find(argv
, argc
, "(1-99)", &idx
);
20129 argv_find(argv
, argc
, "WORD", &idx
);
20130 cl_number_or_name
= argv
[idx
]->arg
;
20132 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20133 seq
, direct
, style
);
20135 XFREE(MTYPE_TMP
, str
);
20138 community_list_perror(vty
, ret
);
20139 return CMD_WARNING_CONFIG_FAILED
;
20142 return CMD_SUCCESS
;
20145 ALIAS(no_extcommunity_list_standard_all
,
20146 no_bgp_extcommunity_list_standard_all_list_cmd
,
20147 "no bgp extcommunity-list <(1-99)|standard WORD>",
20148 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20149 "Extended Community list number (standard)\n"
20150 "Specify standard extcommunity-list\n"
20151 "Community list name\n")
20153 DEFUN (no_extcommunity_list_expanded_all
,
20154 no_bgp_extcommunity_list_expanded_all_cmd
,
20155 "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> LINE...",
20158 EXTCOMMUNITY_LIST_STR
20159 "Extended Community list number (expanded)\n"
20160 "Specify expanded extcommunity-list\n"
20161 "Extended Community list name\n"
20162 "Sequence number of an entry\n"
20163 "Sequence number\n"
20164 "Specify community to reject\n"
20165 "Specify community to accept\n"
20166 "An ordered list as a regular-expression\n")
20168 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
20170 char *cl_number_or_name
= NULL
;
20175 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
20176 seq
= argv
[idx
]->arg
;
20179 argv_find(argv
, argc
, "permit", &idx
);
20180 argv_find(argv
, argc
, "deny", &idx
);
20183 direct
= argv_find(argv
, argc
, "permit", &idx
)
20188 argv_find(argv
, argc
, "LINE", &idx
);
20189 str
= argv_concat(argv
, argc
, idx
);
20193 argv_find(argv
, argc
, "(100-500)", &idx
);
20194 argv_find(argv
, argc
, "WORD", &idx
);
20195 cl_number_or_name
= argv
[idx
]->arg
;
20197 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
20198 seq
, direct
, style
);
20200 XFREE(MTYPE_TMP
, str
);
20203 community_list_perror(vty
, ret
);
20204 return CMD_WARNING_CONFIG_FAILED
;
20207 return CMD_SUCCESS
;
20210 ALIAS(no_extcommunity_list_expanded_all
,
20211 no_bgp_extcommunity_list_expanded_all_list_cmd
,
20212 "no bgp extcommunity-list <(100-500)|expanded WORD>",
20213 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20214 "Extended Community list number (expanded)\n"
20215 "Specify expanded extcommunity-list\n"
20216 "Extended Community list name\n")
20218 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20220 struct community_entry
*entry
;
20222 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20223 if (entry
== list
->head
) {
20224 if (all_digit(list
->name
))
20225 vty_out(vty
, "Extended community %s list %s\n",
20226 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20228 : "(expanded) access",
20232 "Named extended community %s list %s\n",
20233 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20239 vty_out(vty
, " %s\n",
20240 community_direct_str(entry
->direct
));
20242 vty_out(vty
, " %s %s\n",
20243 community_direct_str(entry
->direct
),
20244 community_list_config_str(entry
));
20248 DEFUN (show_extcommunity_list
,
20249 show_bgp_extcommunity_list_cmd
,
20250 "show bgp extcommunity-list",
20253 "List extended-community list\n")
20255 struct community_list
*list
;
20256 struct community_list_master
*cm
;
20258 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20260 return CMD_SUCCESS
;
20262 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20263 extcommunity_list_show(vty
, list
);
20265 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20266 extcommunity_list_show(vty
, list
);
20268 return CMD_SUCCESS
;
20271 DEFUN (show_extcommunity_list_arg
,
20272 show_bgp_extcommunity_list_arg_cmd
,
20273 "show bgp extcommunity-list <(1-500)|WORD> detail",
20276 "List extended-community list\n"
20277 "Extcommunity-list number\n"
20278 "Extcommunity-list name\n"
20279 "Detailed information on extcommunity-list\n")
20281 int idx_comm_list
= 3;
20282 struct community_list
*list
;
20284 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20285 EXTCOMMUNITY_LIST_MASTER
);
20287 vty_out(vty
, "%% Can't find extcommunity-list\n");
20288 return CMD_WARNING
;
20291 extcommunity_list_show(vty
, list
);
20293 return CMD_SUCCESS
;
20296 /* Display community-list and extcommunity-list configuration. */
20297 static int community_list_config_write(struct vty
*vty
)
20299 struct community_list
*list
;
20300 struct community_entry
*entry
;
20301 struct community_list_master
*cm
;
20304 /* Community-list. */
20305 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20307 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20308 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20310 "bgp community-list %s seq %" PRId64
" %s %s\n",
20311 list
->name
, entry
->seq
,
20312 community_direct_str(entry
->direct
),
20313 community_list_config_str(entry
));
20316 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20317 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20319 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
20320 entry
->style
== COMMUNITY_LIST_STANDARD
20323 list
->name
, entry
->seq
,
20324 community_direct_str(entry
->direct
),
20325 community_list_config_str(entry
));
20329 /* Extcommunity-list. */
20330 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20332 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20333 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20335 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
20336 list
->name
, entry
->seq
,
20337 community_direct_str(entry
->direct
),
20338 community_list_config_str(entry
));
20341 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20342 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20344 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
20345 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20348 list
->name
, entry
->seq
,
20349 community_direct_str(entry
->direct
),
20350 community_list_config_str(entry
));
20355 /* lcommunity-list. */
20356 cm
= community_list_master_lookup(bgp_clist
,
20357 LARGE_COMMUNITY_LIST_MASTER
);
20359 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20360 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20362 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
20363 list
->name
, entry
->seq
,
20364 community_direct_str(entry
->direct
),
20365 community_list_config_str(entry
));
20368 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20369 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20371 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
20373 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
20376 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
20377 community_list_config_str(entry
));
20384 static int community_list_config_write(struct vty
*vty
);
20385 static struct cmd_node community_list_node
= {
20386 .name
= "community list",
20387 .node
= COMMUNITY_LIST_NODE
,
20389 .config_write
= community_list_config_write
,
20392 static void community_list_vty(void)
20394 install_node(&community_list_node
);
20396 /* Community-list. */
20397 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
20398 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
20399 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
20400 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
20401 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
20402 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
20403 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
20404 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
20406 /* Extcommunity-list. */
20407 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
20408 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
20409 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
20410 install_element(CONFIG_NODE
,
20411 &no_bgp_extcommunity_list_standard_all_list_cmd
);
20412 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
20413 install_element(CONFIG_NODE
,
20414 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
20415 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
20416 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
20418 /* Large Community List */
20419 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
20420 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
20421 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
20422 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
20423 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
20424 install_element(CONFIG_NODE
,
20425 &no_bgp_lcommunity_list_name_standard_all_cmd
);
20426 install_element(CONFIG_NODE
,
20427 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
20428 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
20429 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
20430 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
20431 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
20432 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
20433 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);