2 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "lib_errors.h"
26 #include "lib/zclient.h"
41 #include "bgpd/bgpd.h"
42 #include "bgpd/bgp_attr_evpn.h"
43 #include "bgpd/bgp_advertise.h"
44 #include "bgpd/bgp_attr.h"
45 #include "bgpd/bgp_aspath.h"
46 #include "bgpd/bgp_community.h"
47 #include "bgpd/bgp_ecommunity.h"
48 #include "bgpd/bgp_lcommunity.h"
49 #include "bgpd/bgp_damp.h"
50 #include "bgpd/bgp_debug.h"
51 #include "bgpd/bgp_errors.h"
52 #include "bgpd/bgp_fsm.h"
53 #include "bgpd/bgp_nexthop.h"
54 #include "bgpd/bgp_open.h"
55 #include "bgpd/bgp_regex.h"
56 #include "bgpd/bgp_route.h"
57 #include "bgpd/bgp_mplsvpn.h"
58 #include "bgpd/bgp_zebra.h"
59 #include "bgpd/bgp_table.h"
60 #include "bgpd/bgp_vty.h"
61 #include "bgpd/bgp_mpath.h"
62 #include "bgpd/bgp_packet.h"
63 #include "bgpd/bgp_updgrp.h"
64 #include "bgpd/bgp_bfd.h"
65 #include "bgpd/bgp_io.h"
66 #include "bgpd/bgp_evpn.h"
67 #include "bgpd/bgp_evpn_vty.h"
68 #include "bgpd/bgp_evpn_mh.h"
69 #include "bgpd/bgp_addpath.h"
70 #include "bgpd/bgp_mac.h"
71 #include "bgpd/bgp_flowspec.h"
73 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
76 #include "northbound.h"
77 #include "northbound_cli.h"
78 #include "bgpd/bgp_nb.h"
81 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
84 .match_profile
= "traditional",
85 .match_version
= "< 7.4",
89 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
90 { .val_bool
= true, .match_profile
= "datacenter", },
91 { .val_bool
= false },
93 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
94 { .val_bool
= true, .match_profile
= "datacenter", },
95 { .val_bool
= false },
97 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
98 { .val_bool
= true, .match_profile
= "datacenter", },
99 { .val_bool
= false },
101 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
102 { .val_bool
= true, .match_profile
= "datacenter", },
103 { .val_bool
= false },
105 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
106 { .val_ulong
= 10, .match_profile
= "datacenter", },
107 { .val_ulong
= 120 },
109 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
110 { .val_ulong
= 9, .match_profile
= "datacenter", },
111 { .val_ulong
= 180 },
113 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
114 { .val_ulong
= 3, .match_profile
= "datacenter", },
117 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
118 { .val_bool
= false, .match_profile
= "datacenter", },
119 { .val_bool
= false, .match_version
= "< 7.4", },
120 { .val_bool
= true },
122 FRR_CFG_DEFAULT_BOOL(BGP_SUPPRESS_DUPLICATES
,
123 { .val_bool
= false, .match_version
= "< 7.6", },
124 { .val_bool
= true },
127 DEFINE_HOOK(bgp_inst_config_write
,
128 (struct bgp
*bgp
, struct vty
*vty
),
130 DEFINE_HOOK(bgp_snmp_update_last_changed
, (struct bgp
*bgp
), (bgp
));
133 "The Graceful Restart No Operation was executed as cmd same as previous one."
135 "The Graceful Restart command used is not valid at this moment."
136 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
137 struct prefix
*range
, int exact
);
139 /* Show BGP peer's information. */
149 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
150 struct prefix
*range
, int exact
);
152 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
157 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
160 afi_t afi
, bool use_json
);
162 static int peer_and_group_lookup_nb(struct vty
*vty
, const char *peer_str
,
163 char *base_xpath
, int xpath_len
,
166 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
172 return BGP_IPV4_NODE
;
174 return BGP_IPV4M_NODE
;
175 case SAFI_LABELED_UNICAST
:
176 return BGP_IPV4L_NODE
;
178 return BGP_VPNV4_NODE
;
180 return BGP_FLOWSPECV4_NODE
;
183 return BGP_IPV4_NODE
;
189 return BGP_IPV6_NODE
;
191 return BGP_IPV6M_NODE
;
192 case SAFI_LABELED_UNICAST
:
193 return BGP_IPV6L_NODE
;
195 return BGP_VPNV6_NODE
;
197 return BGP_FLOWSPECV6_NODE
;
200 return BGP_IPV4_NODE
;
204 return BGP_EVPN_NODE
;
207 // We should never be here but to clarify the switch statement..
208 return BGP_IPV4_NODE
;
211 // Impossible to happen
212 return BGP_IPV4_NODE
;
215 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
218 if (safi
== SAFI_UNICAST
)
219 return "IPv4 Unicast";
220 if (safi
== SAFI_MULTICAST
)
221 return "IPv4 Multicast";
222 if (safi
== SAFI_LABELED_UNICAST
)
223 return "IPv4 Labeled Unicast";
224 if (safi
== SAFI_MPLS_VPN
)
226 if (safi
== SAFI_ENCAP
)
228 if (safi
== SAFI_FLOWSPEC
)
229 return "IPv4 Flowspec";
230 } else if (afi
== AFI_IP6
) {
231 if (safi
== SAFI_UNICAST
)
232 return "IPv6 Unicast";
233 if (safi
== SAFI_MULTICAST
)
234 return "IPv6 Multicast";
235 if (safi
== SAFI_LABELED_UNICAST
)
236 return "IPv6 Labeled Unicast";
237 if (safi
== SAFI_MPLS_VPN
)
239 if (safi
== SAFI_ENCAP
)
241 if (safi
== SAFI_FLOWSPEC
)
242 return "IPv6 Flowspec";
243 } else if (afi
== AFI_L2VPN
) {
244 if (safi
== SAFI_EVPN
)
252 * Please note that we have intentionally camelCased
253 * the return strings here. So if you want
254 * to use this function, please ensure you
255 * are doing this within json output
257 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
260 if (safi
== SAFI_UNICAST
)
261 return "ipv4Unicast";
262 if (safi
== SAFI_MULTICAST
)
263 return "ipv4Multicast";
264 if (safi
== SAFI_LABELED_UNICAST
)
265 return "ipv4LabeledUnicast";
266 if (safi
== SAFI_MPLS_VPN
)
268 if (safi
== SAFI_ENCAP
)
270 if (safi
== SAFI_FLOWSPEC
)
271 return "ipv4Flowspec";
272 } else if (afi
== AFI_IP6
) {
273 if (safi
== SAFI_UNICAST
)
274 return "ipv6Unicast";
275 if (safi
== SAFI_MULTICAST
)
276 return "ipv6Multicast";
277 if (safi
== SAFI_LABELED_UNICAST
)
278 return "ipv6LabeledUnicast";
279 if (safi
== SAFI_MPLS_VPN
)
281 if (safi
== SAFI_ENCAP
)
283 if (safi
== SAFI_FLOWSPEC
)
284 return "ipv6Flowspec";
285 } else if (afi
== AFI_L2VPN
) {
286 if (safi
== SAFI_EVPN
)
293 /* return string maps to afi-safi specific container names
294 * defined in bgp yang file.
296 const char *bgp_afi_safi_get_container_str(afi_t afi
, safi_t safi
)
299 if (safi
== SAFI_UNICAST
)
300 return "ipv4-unicast";
301 if (safi
== SAFI_MULTICAST
)
302 return "ipv4-multicast";
303 if (safi
== SAFI_LABELED_UNICAST
)
304 return "ipv4-labeled-unicast";
305 if (safi
== SAFI_MPLS_VPN
)
306 return "l3vpn-ipv4-unicast";
307 if (safi
== SAFI_FLOWSPEC
)
308 return "ipv4-flowspec";
309 } else if (afi
== AFI_IP6
) {
310 if (safi
== SAFI_UNICAST
)
311 return "ipv6-unicast";
312 if (safi
== SAFI_MULTICAST
)
313 return "ipv6-multicast";
314 if (safi
== SAFI_LABELED_UNICAST
)
315 return "ipv6-labeled-unicast";
316 if (safi
== SAFI_MPLS_VPN
)
317 return "l3vpn-ipv6-unicast";
318 if (safi
== SAFI_FLOWSPEC
)
319 return "ipv6-flowspec";
320 } else if (afi
== AFI_L2VPN
) {
321 if (safi
== SAFI_EVPN
)
328 /* Utility function to get address family from current node. */
329 afi_t
bgp_node_afi(struct vty
*vty
)
337 case BGP_FLOWSPECV6_NODE
:
350 /* Utility function to get subsequent address family from current
352 safi_t
bgp_node_safi(struct vty
*vty
)
358 safi
= SAFI_MPLS_VPN
;
362 safi
= SAFI_MULTICAST
;
369 safi
= SAFI_LABELED_UNICAST
;
371 case BGP_FLOWSPECV4_NODE
:
372 case BGP_FLOWSPECV6_NODE
:
373 safi
= SAFI_FLOWSPEC
;
383 * Converts an AFI in string form to afi_t
385 * @param afi string, one of
389 * @return the corresponding afi_t
391 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
393 afi_t afi
= AFI_MAX
; /* unknown */
394 if (strmatch(afi_str
, "ipv4"))
396 else if (strmatch(afi_str
, "ipv6"))
398 else if (strmatch(afi_str
, "l2vpn"))
403 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
407 if (argv_find(argv
, argc
, "ipv4", index
)) {
411 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
415 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
423 /* supports <unicast|multicast|vpn|labeled-unicast> */
424 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
426 safi_t safi
= SAFI_MAX
; /* unknown */
427 if (strmatch(safi_str
, "multicast"))
428 safi
= SAFI_MULTICAST
;
429 else if (strmatch(safi_str
, "unicast"))
431 else if (strmatch(safi_str
, "vpn"))
432 safi
= SAFI_MPLS_VPN
;
433 else if (strmatch(safi_str
, "evpn"))
435 else if (strmatch(safi_str
, "labeled-unicast"))
436 safi
= SAFI_LABELED_UNICAST
;
437 else if (strmatch(safi_str
, "flowspec"))
438 safi
= SAFI_FLOWSPEC
;
442 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
446 if (argv_find(argv
, argc
, "unicast", index
)) {
449 *safi
= SAFI_UNICAST
;
450 } else if (argv_find(argv
, argc
, "multicast", index
)) {
453 *safi
= SAFI_MULTICAST
;
454 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
457 *safi
= SAFI_LABELED_UNICAST
;
458 } else if (argv_find(argv
, argc
, "vpn", index
)) {
461 *safi
= SAFI_MPLS_VPN
;
462 } else if (argv_find(argv
, argc
, "evpn", index
)) {
466 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
469 *safi
= SAFI_FLOWSPEC
;
474 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
475 enum bgp_instance_type inst_type
)
477 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
479 if (ret
== BGP_CREATED
) {
480 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
481 DFLT_BGP_CONNECT_RETRY
, BGP_DEFAULT_DELAYOPEN
);
483 if (DFLT_BGP_IMPORT_CHECK
)
484 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
485 if (DFLT_BGP_SHOW_HOSTNAME
)
486 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
487 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
488 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
489 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
490 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
491 if (DFLT_BGP_DETERMINISTIC_MED
)
492 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
493 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
494 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
495 if (DFLT_BGP_SUPPRESS_DUPLICATES
)
496 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
);
504 * bgp_vty_find_and_parse_afi_safi_bgp
506 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
507 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
508 * to appropriate values for the calling function. This is to allow the
509 * calling function to make decisions appropriate for the show command
510 * that is being parsed.
512 * The show commands are generally of the form:
513 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
514 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
516 * Since we use argv_find if the show command in particular doesn't have:
518 * [<view|vrf> VIEWVRFNAME]
519 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
520 * The command parsing should still be ok.
522 * vty -> The vty for the command so we can output some useful data in
523 * the event of a parse error in the vrf.
524 * argv -> The command tokens
525 * argc -> How many command tokens we have
526 * idx -> The current place in the command, generally should be 0 for this
528 * afi -> The parsed afi if it was included in the show command, returned here
529 * safi -> The parsed safi if it was included in the show command, returned here
530 * bgp -> Pointer to the bgp data structure we need to fill in.
531 * use_json -> json is configured or not
533 * The function returns the correct location in the parse tree for the
536 * Returns 0 for failure to parse correctly, else the idx position of where
537 * it found the last token.
539 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
540 struct cmd_token
**argv
, int argc
,
541 int *idx
, afi_t
*afi
, safi_t
*safi
,
542 struct bgp
**bgp
, bool use_json
)
544 char *vrf_name
= NULL
;
550 if (argv_find(argv
, argc
, "ip", idx
))
553 if (argv_find(argv
, argc
, "view", idx
))
554 vrf_name
= argv
[*idx
+ 1]->arg
;
555 else if (argv_find(argv
, argc
, "vrf", idx
)) {
556 vrf_name
= argv
[*idx
+ 1]->arg
;
557 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
561 if (strmatch(vrf_name
, "all"))
564 *bgp
= bgp_lookup_by_name(vrf_name
);
567 json_object
*json
= NULL
;
568 json
= json_object_new_object();
569 json_object_string_add(
571 "View/Vrf is unknown");
573 json_object_to_json_string_ext(json
,
574 JSON_C_TO_STRING_PRETTY
));
575 json_object_free(json
);
578 vty_out(vty
, "View/Vrf %s is unknown\n",
585 *bgp
= bgp_get_default();
588 json_object
*json
= NULL
;
589 json
= json_object_new_object();
590 json_object_string_add(
592 "Default BGP instance not found");
594 json_object_to_json_string_ext(json
,
595 JSON_C_TO_STRING_PRETTY
));
596 json_object_free(json
);
600 "Default BGP instance not found\n");
606 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
607 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
613 bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
615 struct interface
*ifp
= NULL
;
617 if (su
->sa
.sa_family
== AF_INET
)
618 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
619 else if (su
->sa
.sa_family
== AF_INET6
)
620 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
621 su
->sin6
.sin6_scope_id
,
630 /* Utility function for looking up peer or peer group. */
631 /* This is used only for configuration, so disallow if attempted on
632 * a dynamic neighbor.
634 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
636 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
639 struct peer
*peer
= NULL
;
640 struct peer_group
*group
= NULL
;
646 ret
= str2sockunion(peer_str
, &su
);
648 /* IP address, locate peer. */
649 peer
= peer_lookup(bgp
, &su
);
651 /* Not IP, could match either peer configured on interface or a
653 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
655 group
= peer_group_lookup(bgp
, peer_str
);
659 if (peer_dynamic_neighbor(peer
)) {
661 "%% Operation not allowed on a dynamic neighbor\n");
671 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
676 int bgp_nb_errmsg_return(char *errmsg
, size_t errmsg_len
, int ret
)
678 const char *str
= NULL
;
681 case BGP_ERR_INVALID_VALUE
:
682 str
= "Invalid value";
684 case BGP_ERR_INVALID_FLAG
:
685 str
= "Invalid flag";
687 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
688 str
= "Peer-group has been shutdown. Activate the peer-group first";
690 case BGP_ERR_PEER_FLAG_CONFLICT
:
691 str
= "Can't set override-capability and strict-capability-match at the same time";
693 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
694 str
= "Specify remote-as or peer-group remote AS first";
696 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
697 str
= "Cannot change the peer-group. Deconfigure first";
699 case BGP_ERR_PEER_GROUP_MISMATCH
:
700 str
= "Peer is not a member of this peer-group";
702 case BGP_ERR_PEER_FILTER_CONFLICT
:
703 str
= "Prefix/distribute list can not co-exist";
705 case BGP_ERR_NOT_INTERNAL_PEER
:
706 str
= "Invalid command. Not an internal neighbor";
708 case BGP_ERR_REMOVE_PRIVATE_AS
:
709 str
= "remove-private-AS cannot be configured for IBGP peers";
711 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
712 str
= "Local-AS allowed only for EBGP peers";
714 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
715 str
= "Cannot have local-as same as BGP AS number";
717 case BGP_ERR_TCPSIG_FAILED
:
718 str
= "Error while applying TCP-Sig to session(s)";
720 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
721 str
= "ebgp-multihop and ttl-security cannot be configured together";
723 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
724 str
= "ttl-security only allowed for EBGP peers";
726 case BGP_ERR_AS_OVERRIDE
:
727 str
= "as-override cannot be configured for IBGP peers";
729 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
730 str
= "Invalid limit for number of dynamic neighbors";
732 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
733 str
= "Dynamic neighbor listen range already exists";
735 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
736 str
= "Operation not allowed on a dynamic neighbor";
738 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
739 str
= "Operation not allowed on a directly connected neighbor";
741 case BGP_ERR_PEER_SAFI_CONFLICT
:
744 case BGP_ERR_GR_INVALID_CMD
:
745 str
= "The Graceful Restart command used is not valid at this moment.";
747 case BGP_ERR_GR_OPERATION_FAILED
:
748 str
= "The Graceful Restart Operation failed due to an err.";
750 case BGP_GR_NO_OPERATION
:
753 case BGP_ERR_PEER_GROUP_MEMBER
:
754 str
= "Peer-group member cannot override remote-as of peer-group";
756 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
757 str
= "Peer-group members must be all internal or all external";
761 snprintf(errmsg
, errmsg_len
, "%s", str
);
768 int bgp_vty_return(struct vty
*vty
, int ret
)
770 const char *str
= NULL
;
773 case BGP_ERR_INVALID_VALUE
:
774 str
= "Invalid value";
776 case BGP_ERR_INVALID_FLAG
:
777 str
= "Invalid flag";
779 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
780 str
= "Peer-group has been shutdown. Activate the peer-group first";
782 case BGP_ERR_PEER_FLAG_CONFLICT
:
783 str
= "Can't set override-capability and strict-capability-match at the same time";
785 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
786 str
= "Specify remote-as or peer-group remote AS first";
788 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
789 str
= "Cannot change the peer-group. Deconfigure first";
791 case BGP_ERR_PEER_GROUP_MISMATCH
:
792 str
= "Peer is not a member of this peer-group";
794 case BGP_ERR_PEER_FILTER_CONFLICT
:
795 str
= "Prefix/distribute list can not co-exist";
797 case BGP_ERR_NOT_INTERNAL_PEER
:
798 str
= "Invalid command. Not an internal neighbor";
800 case BGP_ERR_REMOVE_PRIVATE_AS
:
801 str
= "remove-private-AS cannot be configured for IBGP peers";
803 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
804 str
= "Local-AS allowed only for EBGP peers";
806 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
807 str
= "Cannot have local-as same as BGP AS number";
809 case BGP_ERR_TCPSIG_FAILED
:
810 str
= "Error while applying TCP-Sig to session(s)";
812 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
813 str
= "ebgp-multihop and ttl-security cannot be configured together";
815 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
816 str
= "ttl-security only allowed for EBGP peers";
818 case BGP_ERR_AS_OVERRIDE
:
819 str
= "as-override cannot be configured for IBGP peers";
821 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
822 str
= "Invalid limit for number of dynamic neighbors";
824 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
825 str
= "Dynamic neighbor listen range already exists";
827 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
828 str
= "Operation not allowed on a dynamic neighbor";
830 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
831 str
= "Operation not allowed on a directly connected neighbor";
833 case BGP_ERR_PEER_SAFI_CONFLICT
:
836 case BGP_ERR_GR_INVALID_CMD
:
837 str
= "The Graceful Restart command used is not valid at this moment.";
839 case BGP_ERR_GR_OPERATION_FAILED
:
840 str
= "The Graceful Restart Operation failed due to an err.";
842 case BGP_GR_NO_OPERATION
:
847 vty_out(vty
, "%% %s\n", str
);
848 return CMD_WARNING_CONFIG_FAILED
;
853 /* BGP clear sort. */
862 static void bgp_clear_vty_error(struct peer
*peer
, afi_t afi
, safi_t safi
,
863 int error
, char *errmsg
, size_t errmsg_len
)
866 case BGP_ERR_AF_UNCONFIGURED
:
867 snprintf(errmsg
, errmsg_len
,
868 "%%BGP: Enable %s address family for the neighbor %s",
869 get_afi_safi_str(afi
, safi
, false), peer
->host
);
871 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
874 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig",
882 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
883 struct listnode
**nnode
, enum bgp_clear_type stype
)
888 /* if afi/.safi not specified, spin thru all of them */
889 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
893 FOREACH_AFI_SAFI (tmp_afi
, tmp_safi
) {
894 paf
= peer_af_find(peer
, tmp_afi
, tmp_safi
);
895 if (paf
&& paf
->subgroup
)
896 SET_FLAG(paf
->subgroup
->sflags
,
897 SUBGRP_STATUS_FORCE_UPDATES
);
899 if (!peer
->afc
[tmp_afi
][tmp_safi
])
902 if (stype
== BGP_CLEAR_SOFT_NONE
)
903 ret
= peer_clear(peer
, nnode
);
905 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
908 /* if afi specified and safi not, spin thru safis on this afi */
909 } else if (safi
== SAFI_UNSPEC
) {
912 for (tmp_safi
= SAFI_UNICAST
;
913 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
914 if (!peer
->afc
[afi
][tmp_safi
])
917 paf
= peer_af_find(peer
, afi
, tmp_safi
);
918 if (paf
&& paf
->subgroup
)
919 SET_FLAG(paf
->subgroup
->sflags
,
920 SUBGRP_STATUS_FORCE_UPDATES
);
922 if (stype
== BGP_CLEAR_SOFT_NONE
)
923 ret
= peer_clear(peer
, nnode
);
925 ret
= peer_clear_soft(peer
, afi
,
928 /* both afi/safi specified, let the caller know if not defined */
930 if (!peer
->afc
[afi
][safi
])
933 paf
= peer_af_find(peer
, afi
, safi
);
934 if (paf
&& paf
->subgroup
)
935 SET_FLAG(paf
->subgroup
->sflags
,
936 SUBGRP_STATUS_FORCE_UPDATES
);
938 if (stype
== BGP_CLEAR_SOFT_NONE
)
939 ret
= peer_clear(peer
, nnode
);
941 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
947 /* `clear ip bgp' functions. */
948 static int bgp_clear(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
949 enum clear_sort sort
, enum bgp_clear_type stype
,
950 const char *arg
, char *errmsg
, size_t errmsg_len
)
956 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
958 /* Clear all neighbors. */
960 * Pass along pointer to next node to peer_clear() when walking all
961 * nodes on the BGP instance as that may get freed if it is a
964 if (sort
== clear_all
) {
965 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
967 bgp_peer_gr_flags_update(peer
);
969 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
970 gr_router_detected
= true;
972 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
976 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
980 if (gr_router_detected
981 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
982 bgp_zebra_send_capabilities(bgp
, false);
983 } else if (!gr_router_detected
984 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
985 bgp_zebra_send_capabilities(bgp
, true);
988 /* This is to apply read-only mode on this clear. */
989 if (stype
== BGP_CLEAR_SOFT_NONE
)
990 bgp
->update_delay_over
= 0;
995 /* Clear specified neighbor. */
996 if (sort
== clear_peer
) {
999 /* Make sockunion for lookup. */
1000 ret
= str2sockunion(arg
, &su
);
1002 peer
= peer_lookup_by_conf_if(bgp
, arg
);
1004 peer
= peer_lookup_by_hostname(bgp
, arg
);
1008 "Malformed address or name: %s",
1014 peer
= peer_lookup(bgp
, &su
);
1016 snprintf(errmsg
, errmsg_len
,
1017 "%%BGP: Unknown neighbor - \"%s\"",
1023 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
1024 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
1026 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
1028 /* if afi/safi not defined for this peer, let caller know */
1030 ret
= BGP_ERR_AF_UNCONFIGURED
;
1033 bgp_clear_vty_error(peer
, afi
, safi
, ret
, errmsg
,
1039 /* Clear all neighbors belonging to a specific peer-group. */
1040 if (sort
== clear_group
) {
1041 struct peer_group
*group
;
1043 group
= peer_group_lookup(bgp
, arg
);
1045 snprintf(errmsg
, errmsg_len
,
1046 "%%BGP: No such peer-group %s", arg
);
1050 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
1051 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1054 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1055 errmsg
, errmsg_len
);
1063 "%%BGP: No %s peer belonging to peer-group %s is configured",
1064 get_afi_safi_str(afi
, safi
, false), arg
);
1069 /* Clear all external (eBGP) neighbors. */
1070 if (sort
== clear_external
) {
1071 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1072 if (peer
->sort
== BGP_PEER_IBGP
)
1075 bgp_peer_gr_flags_update(peer
);
1077 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1078 gr_router_detected
= true;
1080 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1083 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1084 errmsg
, errmsg_len
);
1089 if (gr_router_detected
1090 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1091 bgp_zebra_send_capabilities(bgp
, false);
1092 } else if (!gr_router_detected
1093 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1094 bgp_zebra_send_capabilities(bgp
, true);
1098 snprintf(errmsg
, errmsg_len
,
1099 "%%BGP: No external %s peer is configured",
1100 get_afi_safi_str(afi
, safi
, false));
1105 /* Clear all neighbors belonging to a specific AS. */
1106 if (sort
== clear_as
) {
1107 as_t as
= strtoul(arg
, NULL
, 10);
1109 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1113 bgp_peer_gr_flags_update(peer
);
1115 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
1116 gr_router_detected
= true;
1118 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1121 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1122 errmsg
, errmsg_len
);
1127 if (gr_router_detected
1128 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1129 bgp_zebra_send_capabilities(bgp
, false);
1130 } else if (!gr_router_detected
1131 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1132 bgp_zebra_send_capabilities(bgp
, true);
1136 snprintf(errmsg
, errmsg_len
,
1137 "%%BGP: No %s peer is configured with AS %s",
1138 get_afi_safi_str(afi
, safi
, false), arg
);
1146 static int bgp_clear_vty(const char *name
, afi_t afi
, safi_t safi
,
1147 enum clear_sort sort
, enum bgp_clear_type stype
,
1148 const char *arg
, char *errmsg
, size_t errmsg_len
)
1152 /* BGP structure lookup. */
1154 bgp
= bgp_lookup_by_name(name
);
1156 snprintf(errmsg
, errmsg_len
,
1157 "Can't find BGP instance %s", name
);
1161 bgp
= bgp_get_default();
1163 snprintf(errmsg
, errmsg_len
,
1164 "No BGP process is configured");
1169 return bgp_clear(bgp
, afi
, safi
, sort
, stype
, arg
, errmsg
, errmsg_len
);
1172 /* clear soft inbound */
1173 int bgp_clear_star_soft_in(const char *name
, char *errmsg
, size_t errmsg_len
)
1179 FOREACH_AFI_SAFI (afi
, safi
) {
1180 ret
= bgp_clear_vty(name
, afi
, safi
, clear_all
,
1181 BGP_CLEAR_SOFT_IN
, NULL
, errmsg
,
1183 if (ret
!= CMD_SUCCESS
)
1190 /* clear soft outbound */
1191 int bgp_clear_star_soft_out(const char *name
, char *errmsg
, size_t errmsg_len
)
1197 FOREACH_AFI_SAFI (afi
, safi
) {
1198 ret
= bgp_clear_vty(name
, afi
, safi
, clear_all
,
1199 BGP_CLEAR_SOFT_OUT
, NULL
, errmsg
,
1201 if (ret
!= CMD_SUCCESS
)
1209 #ifndef VTYSH_EXTRACT_PL
1210 #include "bgpd/bgp_vty_clippy.c"
1213 DEFUN_HIDDEN (bgp_local_mac
,
1215 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1217 "Local MAC config\n"
1218 "VxLAN Network Identifier\n"
1222 "mac-mobility sequence\n"
1232 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1233 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1234 vty_out(vty
, "%% Malformed MAC address\n");
1237 memset(&ip
, 0, sizeof(ip
));
1238 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1240 bgp
= bgp_get_default();
1242 vty_out(vty
, "Default BGP instance is not there\n");
1246 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1249 vty_out(vty
, "Internal error\n");
1256 DEFUN_HIDDEN (no_bgp_local_mac
,
1257 no_bgp_local_mac_cmd
,
1258 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1261 "Local MAC config\n"
1262 "VxLAN Network Identifier\n"
1273 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1274 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1275 vty_out(vty
, "%% Malformed MAC address\n");
1278 memset(&ip
, 0, sizeof(ip
));
1280 bgp
= bgp_get_default();
1282 vty_out(vty
, "Default BGP instance is not there\n");
1286 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1288 vty_out(vty
, "Internal error\n");
1295 DEFUN (no_synchronization
,
1296 no_synchronization_cmd
,
1297 "no synchronization",
1299 "Perform IGP synchronization\n")
1304 DEFUN (no_auto_summary
,
1305 no_auto_summary_cmd
,
1308 "Enable automatic network number summarization\n")
1313 /* "router bgp" commands. */
1314 DEFUN_YANG_NOSH(router_bgp
,
1316 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1317 ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR
)
1320 int idx_view_vrf
= 3;
1322 int ret
= CMD_SUCCESS
;
1325 const char *name
= NULL
;
1326 char as_str
[12] = {'\0'};
1327 enum bgp_instance_type inst_type
;
1328 char base_xpath
[XPATH_MAXLEN
];
1330 // "router bgp" without an ASN
1332 // Pending: Make VRF option available for ASN less config
1333 bgp
= bgp_get_default();
1336 vty_out(vty
, "%% No BGP process is configured\n");
1337 return CMD_WARNING_CONFIG_FAILED
;
1340 if (listcount(bm
->bgp
) > 1) {
1341 vty_out(vty
, "%% Please specify ASN and VRF\n");
1342 return CMD_WARNING_CONFIG_FAILED
;
1345 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1346 "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME
);
1348 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
1349 snprintf(as_str
, 12, "%d", bgp
->as
);
1350 nb_cli_enqueue_change(vty
, "./global/local-as", NB_OP_MODIFY
,
1352 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
) {
1353 nb_cli_enqueue_change(vty
,
1354 "./global/instance-type-view",
1355 NB_OP_MODIFY
, "true");
1358 nb_cli_pending_commit_check(vty
);
1359 ret
= nb_cli_apply_changes(vty
, base_xpath
);
1360 if (ret
== CMD_SUCCESS
) {
1361 VTY_PUSH_XPATH(BGP_NODE
, base_xpath
);
1364 * For backward compatibility with old commands we still
1365 * need to use the qobj infrastructure.
1367 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1375 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1376 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1378 name
= argv
[idx_vrf
]->arg
;
1380 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1381 if (strmatch(name
, VRF_DEFAULT_NAME
))
1384 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1385 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view")) {
1386 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1389 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1390 "frr-bgp:bgp", "bgp", name
? name
: VRF_DEFAULT_NAME
);
1392 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
1393 nb_cli_enqueue_change(vty
, "./global/local-as", NB_OP_MODIFY
,
1394 argv
[idx_asn
]->arg
);
1395 if (inst_type
== BGP_INSTANCE_TYPE_VIEW
) {
1396 nb_cli_enqueue_change(vty
,
1397 "./global/instance-type-view",
1398 NB_OP_MODIFY
, "true");
1401 nb_cli_pending_commit_check(vty
);
1402 ret
= nb_cli_apply_changes(vty
, base_xpath
);
1403 if (ret
== CMD_SUCCESS
) {
1404 VTY_PUSH_XPATH(BGP_NODE
, base_xpath
);
1407 * For backward compatibility with old commands we still
1408 * need to use the qobj infrastructure.
1410 bgp
= bgp_lookup(as
, name
);
1412 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1419 /* "no router bgp" commands. */
1420 DEFUN_YANG(no_router_bgp
,
1422 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1423 NO_STR ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR
)
1429 const char *name
= NULL
;
1430 char base_xpath
[XPATH_MAXLEN
];
1431 const struct lyd_node
*bgp_glb_dnode
;
1433 // "no router bgp" without an ASN
1435 // Pending: Make VRF option available for ASN less config
1436 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1437 "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME
);
1439 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
1441 if (!bgp_glb_dnode
) {
1442 vty_out(vty
, "%% No BGP process is configured\n");
1443 return CMD_WARNING_CONFIG_FAILED
;
1446 if (listcount(bm
->bgp
) > 1) {
1447 vty_out(vty
, "%% Please specify ASN and VRF\n");
1448 return CMD_WARNING_CONFIG_FAILED
;
1451 /* tcli mode bgp would not be set until apply stage. */
1452 bgp
= nb_running_get_entry(bgp_glb_dnode
, NULL
, false);
1457 vty_out(vty
, "%% Please unconfigure l3vni %u",
1459 return CMD_WARNING_CONFIG_FAILED
;
1462 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1465 name
= argv
[idx_vrf
]->arg
;
1467 /* Lookup bgp structure. */
1468 bgp
= bgp_lookup(as
, name
);
1470 vty_out(vty
, "%% Can't find BGP instance\n");
1471 return CMD_WARNING_CONFIG_FAILED
;
1475 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1477 return CMD_WARNING_CONFIG_FAILED
;
1480 /* Cannot delete default instance if vrf instances exist */
1481 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1482 struct listnode
*node
;
1483 struct bgp
*tmp_bgp
;
1485 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1486 if (tmp_bgp
->inst_type
!= BGP_INSTANCE_TYPE_VRF
)
1488 if (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1489 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1490 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1491 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
) ||
1492 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1493 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1494 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1495 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
) ||
1496 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP
][SAFI_UNICAST
],
1497 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1498 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_IP6
][SAFI_UNICAST
],
1499 BGP_CONFIG_VRF_TO_VRF_EXPORT
) ||
1500 (bgp
== bgp_get_evpn() &&
1501 (CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1502 BGP_L2VPN_EVPN_ADVERTISE_IPV4_UNICAST
) ||
1503 CHECK_FLAG(tmp_bgp
->af_flags
[AFI_L2VPN
][SAFI_EVPN
],
1504 BGP_L2VPN_EVPN_ADVERTISE_IPV6_UNICAST
))) ||
1505 (tmp_bgp
->vnihash
&& hashcount(tmp_bgp
->vnihash
))) {
1507 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1508 return CMD_WARNING_CONFIG_FAILED
;
1513 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1514 "frr-bgp:bgp", "bgp",
1515 bgp
->name
? bgp
->name
: VRF_DEFAULT_NAME
);
1517 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
1519 return nb_cli_apply_changes(vty
, base_xpath
);
1522 void cli_show_router_bgp(struct vty
*vty
, struct lyd_node
*dnode
,
1525 const struct lyd_node
*vrf_dnode
;
1526 const char *vrf_name
;
1529 vrf_dnode
= yang_dnode_get_parent(dnode
, "control-plane-protocol");
1530 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
1531 as
= yang_dnode_get_uint32(dnode
, "./global/local-as");
1533 vty_out(vty
, "!\n");
1534 vty_out(vty
, "router bgp %u", as
);
1535 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
))
1536 vty_out(vty
, " vrf %s", vrf_name
);
1540 /* BGP router-id. */
1542 DEFPY_YANG(bgp_router_id
, bgp_router_id_cmd
, "bgp router-id A.B.C.D",
1544 "Override configured router identifier\n"
1545 "Manually configured router identifier\n")
1547 nb_cli_enqueue_change(vty
, "./global/router-id", NB_OP_MODIFY
,
1550 return nb_cli_apply_changes(vty
, NULL
);
1553 DEFPY_YANG(no_bgp_router_id
, no_bgp_router_id_cmd
, "no bgp router-id [A.B.C.D]",
1555 "Override configured router identifier\n"
1556 "Manually configured router identifier\n")
1558 nb_cli_enqueue_change(vty
, "./global/router-id", NB_OP_DESTROY
,
1559 router_id_str
? router_id_str
: NULL
);
1561 return nb_cli_apply_changes(vty
, NULL
);
1564 void cli_show_router_bgp_router_id(struct vty
*vty
, struct lyd_node
*dnode
,
1567 vty_out(vty
, " bgp router-id %s\n", yang_dnode_get_string(dnode
, NULL
));
1570 DEFPY (bgp_global_suppress_fib_pending
,
1571 bgp_global_suppress_fib_pending_cmd
,
1572 "[no] bgp suppress-fib-pending",
1575 "Advertise only routes that are programmed in kernel to peers globally\n")
1577 bm_wait_for_fib_set(!no
);
1582 DEFPY (bgp_suppress_fib_pending
,
1583 bgp_suppress_fib_pending_cmd
,
1584 "[no] bgp suppress-fib-pending",
1587 "Advertise only routes that are programmed in kernel to peers\n")
1589 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1591 bgp_suppress_fib_pending_set(bgp
, !no
);
1596 /* BGP Cluster ID. */
1597 DEFUN_YANG(bgp_cluster_id
,
1599 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1601 "Configure Route-Reflector Cluster-id\n"
1602 "Route-Reflector Cluster-id in IP address format\n"
1603 "Route-Reflector Cluster-id as 32 bit quantity\n")
1607 nb_cli_enqueue_change(
1608 vty
, "./global/route-reflector/route-reflector-cluster-id",
1609 NB_OP_MODIFY
, argv
[idx_ipv4
]->arg
);
1611 return nb_cli_apply_changes(vty
, NULL
);
1614 DEFUN_YANG(no_bgp_cluster_id
,
1615 no_bgp_cluster_id_cmd
,
1616 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1618 "Configure Route-Reflector Cluster-id\n"
1619 "Route-Reflector Cluster-id in IP address format\n"
1620 "Route-Reflector Cluster-id as 32 bit quantity\n")
1622 nb_cli_enqueue_change(
1623 vty
, "./global/route-reflector/route-reflector-cluster-id",
1624 NB_OP_DESTROY
, NULL
);
1626 return nb_cli_apply_changes(vty
, NULL
);
1633 "Disable BGP route installation to RIB (Zebra)\n")
1635 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1637 "%% No-RIB option is already set, nothing to do here.\n");
1641 bgp_option_norib_set_runtime();
1646 DEFPY (no_bgp_norib
,
1651 "Disable BGP route installation to RIB (Zebra)\n")
1653 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1655 "%% No-RIB option is not set, nothing to do here.\n");
1659 bgp_option_norib_unset_runtime();
1664 DEFPY (no_bgp_send_extra_data
,
1665 no_bgp_send_extra_data_cmd
,
1666 "[no] bgp send-extra-data zebra",
1669 "Extra data to Zebra for display/use\n"
1673 UNSET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1675 SET_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
);
1680 DEFUN_YANG(bgp_confederation_identifier
,
1681 bgp_confederation_identifier_cmd
,
1682 "bgp confederation identifier (1-4294967295)",
1683 "BGP specific commands\n"
1684 "AS confederation parameters\n"
1686 "Set routing domain confederation AS\n")
1690 nb_cli_enqueue_change(vty
, "./global/confederation/identifier",
1691 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
1693 return nb_cli_apply_changes(vty
, NULL
);
1696 DEFUN_YANG(no_bgp_confederation_identifier
,
1697 no_bgp_confederation_identifier_cmd
,
1698 "no bgp confederation identifier [(1-4294967295)]",
1700 "BGP specific commands\n"
1701 "AS confederation parameters\n"
1703 "Set routing domain confederation AS\n")
1705 nb_cli_enqueue_change(vty
, "./global/confederation/identifier",
1706 NB_OP_DESTROY
, NULL
);
1708 return nb_cli_apply_changes(vty
, NULL
);
1711 void cli_show_router_bgp_confederation_identifier(struct vty
*vty
,
1712 struct lyd_node
*dnode
,
1715 vty_out(vty
, " bgp confederation identifier %u\n",
1716 yang_dnode_get_uint32(dnode
, NULL
));
1719 DEFUN_YANG(bgp_confederation_peers
,
1720 bgp_confederation_peers_cmd
,
1721 "bgp confederation peers (1-4294967295)...",
1722 "BGP specific commands\n"
1723 "AS confederation parameters\n"
1724 "Peer ASs in BGP confederation\n" AS_STR
)
1729 for (i
= idx_asn
; i
< argc
; i
++)
1730 nb_cli_enqueue_change(vty
, "./global/confederation/member-as",
1731 NB_OP_CREATE
, argv
[i
]->arg
);
1733 return nb_cli_apply_changes(vty
, NULL
);
1736 DEFUN_YANG(no_bgp_confederation_peers
,
1737 no_bgp_confederation_peers_cmd
,
1738 "no bgp confederation peers (1-4294967295)...",
1740 "BGP specific commands\n"
1741 "AS confederation parameters\n"
1742 "Peer ASs in BGP confederation\n" AS_STR
)
1747 for (i
= idx_asn
; i
< argc
; i
++)
1748 nb_cli_enqueue_change(vty
, "./global/confederation/member-as",
1749 NB_OP_DESTROY
, argv
[i
]->arg
);
1751 return nb_cli_apply_changes(vty
, NULL
);
1754 void cli_show_router_bgp_confederation_member_as(struct vty
*vty
,
1755 struct lyd_node
*dnode
,
1758 vty_out(vty
, " bgp confederation peers %u \n",
1759 yang_dnode_get_uint32(dnode
, NULL
));
1763 * Central routine for maximum-paths configuration.
1764 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1765 * @set: 1 for setting values, 0 for removing the max-paths config.
1767 int bgp_maxpaths_config_vty(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
1768 int peer_type
, uint16_t maxpaths
, uint16_t options
,
1769 int set
, char *errmsg
, size_t errmsg_len
)
1774 if (maxpaths
> multipath_num
) {
1777 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1778 maxpaths
, multipath_num
);
1779 return CMD_WARNING_CONFIG_FAILED
;
1781 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1784 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1789 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1790 (set
== 1) ? "" : "un",
1791 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1792 maxpaths
, afi
, safi
);
1793 return CMD_WARNING_CONFIG_FAILED
;
1796 bgp_recalculate_all_bestpaths(bgp
);
1801 void cli_show_router_bgp_med_config(struct vty
*vty
, struct lyd_node
*dnode
,
1804 if (yang_dnode_get_bool(dnode
, "./enable-med-admin")) {
1805 uint32_t med_admin_val
;
1807 vty_out(vty
, " bgp max-med administrative");
1808 if ((med_admin_val
=
1809 yang_dnode_get_uint32(dnode
, "./max-med-admin"))
1810 != BGP_MAXMED_VALUE_DEFAULT
)
1811 vty_out(vty
, " %u", med_admin_val
);
1815 if (yang_dnode_exists(dnode
, "./max-med-onstart-up-time")) {
1816 uint32_t onstartup_val
;
1818 vty_out(vty
, " bgp max-med on-startup %u",
1819 yang_dnode_get_uint32(dnode
,
1820 "./max-med-onstart-up-time"));
1821 onstartup_val
= yang_dnode_get_uint32(
1822 dnode
, "./max-med-onstart-up-value");
1823 if (onstartup_val
!= BGP_MAXMED_VALUE_DEFAULT
)
1824 vty_out(vty
, " %u", onstartup_val
);
1830 DEFUN_YANG(bgp_maxmed_admin
,
1831 bgp_maxmed_admin_cmd
,
1832 "bgp max-med administrative ",
1834 "Advertise routes with max-med\n"
1835 "Administratively applied, for an indefinite period\n")
1837 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1838 NB_OP_MODIFY
, "true");
1840 return nb_cli_apply_changes(vty
, NULL
);
1843 DEFUN_YANG(bgp_maxmed_admin_medv
,
1844 bgp_maxmed_admin_medv_cmd
,
1845 "bgp max-med administrative (0-4294967295)",
1847 "Advertise routes with max-med\n"
1848 "Administratively applied, for an indefinite period\n"
1849 "Max MED value to be used\n")
1853 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1854 NB_OP_MODIFY
, "true");
1856 nb_cli_enqueue_change(vty
, "./global/med-config/max-med-admin",
1857 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
1859 return nb_cli_apply_changes(vty
, NULL
);
1862 DEFUN_YANG(no_bgp_maxmed_admin
,
1863 no_bgp_maxmed_admin_cmd
,
1864 "no bgp max-med administrative [(0-4294967295)]",
1866 "Advertise routes with max-med\n"
1867 "Administratively applied, for an indefinite period\n"
1868 "Max MED value to be used\n")
1870 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1871 NB_OP_MODIFY
, "false");
1873 nb_cli_enqueue_change(vty
, "./global/med-config/max-med-admin",
1874 NB_OP_MODIFY
, NULL
);
1876 return nb_cli_apply_changes(vty
, NULL
);
1879 DEFUN_YANG (bgp_maxmed_onstartup
,
1880 bgp_maxmed_onstartup_cmd
,
1881 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1883 "Advertise routes with max-med\n"
1884 "Effective on a startup\n"
1885 "Time (seconds) period for max-med\n"
1886 "Max MED value to be used\n")
1890 argv_find(argv
, argc
, "(5-86400)", &idx
);
1891 nb_cli_enqueue_change(vty
,
1892 "./global/med-config/max-med-onstart-up-time",
1893 NB_OP_MODIFY
, argv
[idx
]->arg
);
1895 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1896 nb_cli_enqueue_change(
1897 vty
, "./global/med-config/max-med-onstart-up-value",
1898 NB_OP_MODIFY
, argv
[idx
]->arg
);
1900 nb_cli_enqueue_change(
1901 vty
, "./global/med-config/max-med-onstart-up-value",
1902 NB_OP_MODIFY
, NULL
);
1904 return nb_cli_apply_changes(vty
, NULL
);
1907 DEFUN_YANG (no_bgp_maxmed_onstartup
,
1908 no_bgp_maxmed_onstartup_cmd
,
1909 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1911 "Advertise routes with max-med\n"
1912 "Effective on a startup\n"
1913 "Time (seconds) period for max-med\n"
1914 "Max MED value to be used\n")
1916 nb_cli_enqueue_change(vty
,
1917 "./global/med-config/max-med-onstart-up-time",
1918 NB_OP_DESTROY
, NULL
);
1920 nb_cli_enqueue_change(vty
,
1921 "./global/med-config/max-med-onstart-up-value",
1922 NB_OP_MODIFY
, NULL
);
1924 return nb_cli_apply_changes(vty
, NULL
);
1927 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
1928 uint16_t update_delay
,
1929 uint16_t establish_wait
)
1931 struct listnode
*node
, *nnode
;
1933 bool vrf_cfg
= false;
1936 * See if update-delay is set per-vrf and warn user to delete it
1937 * Note that we only need to check this if this is the first time
1938 * setting the global config.
1940 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
1941 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1942 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1944 "%% update-delay configuration found in vrf %s\n",
1945 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
1955 "%%Failed: global update-delay config not permitted\n");
1959 if (!establish_wait
) { /* update-delay <delay> */
1960 bm
->v_update_delay
= update_delay
;
1961 bm
->v_establish_wait
= bm
->v_update_delay
;
1963 /* update-delay <delay> <establish-wait> */
1964 if (update_delay
< establish_wait
) {
1966 "%%Failed: update-delay less than the establish-wait!\n");
1967 return CMD_WARNING_CONFIG_FAILED
;
1970 bm
->v_update_delay
= update_delay
;
1971 bm
->v_establish_wait
= establish_wait
;
1974 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1975 bgp
->v_update_delay
= bm
->v_update_delay
;
1976 bgp
->v_establish_wait
= bm
->v_establish_wait
;
1982 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
1984 struct listnode
*node
, *nnode
;
1987 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1988 bm
->v_establish_wait
= bm
->v_update_delay
;
1990 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1991 bgp
->v_update_delay
= bm
->v_update_delay
;
1992 bgp
->v_establish_wait
= bm
->v_establish_wait
;
1998 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
1999 uint16_t establish_wait
)
2001 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2003 /* if configured globally, per-instance config is not allowed */
2004 if (bm
->v_update_delay
) {
2006 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
2007 return CMD_WARNING_CONFIG_FAILED
;
2011 if (!establish_wait
) /* update-delay <delay> */
2013 bgp
->v_update_delay
= update_delay
;
2014 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2018 /* update-delay <delay> <establish-wait> */
2019 if (update_delay
< establish_wait
) {
2021 "%%Failed: update-delay less than the establish-wait!\n");
2022 return CMD_WARNING_CONFIG_FAILED
;
2025 bgp
->v_update_delay
= update_delay
;
2026 bgp
->v_establish_wait
= establish_wait
;
2031 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
2033 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2035 /* If configured globally, cannot remove from one bgp instance */
2036 if (bm
->v_update_delay
) {
2038 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
2039 return CMD_WARNING_CONFIG_FAILED
;
2041 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
2042 bgp
->v_establish_wait
= bgp
->v_update_delay
;
2047 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
2049 /* If configured globally, no need to display per-instance value */
2050 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
2051 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
2052 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
2053 vty_out(vty
, " %d", bgp
->v_establish_wait
);
2058 /* Global update-delay configuration */
2059 DEFPY (bgp_global_update_delay
,
2060 bgp_global_update_delay_cmd
,
2061 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
2063 "Force initial delay for best-path and updates for all bgp instances\n"
2064 "Max delay in seconds\n"
2065 "Establish wait in seconds\n")
2067 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
2070 /* Global update-delay deconfiguration */
2071 DEFPY (no_bgp_global_update_delay
,
2072 no_bgp_global_update_delay_cmd
,
2073 "no bgp update-delay [(0-3600) [(1-3600)]]",
2076 "Force initial delay for best-path and updates\n"
2077 "Max delay in seconds\n"
2078 "Establish wait in seconds\n")
2080 return bgp_global_update_delay_deconfig_vty(vty
);
2083 /* Update-delay configuration */
2085 DEFPY (bgp_update_delay
,
2086 bgp_update_delay_cmd
,
2087 "update-delay (0-3600)$delay [(1-3600)$wait]",
2088 "Force initial delay for best-path and updates\n"
2089 "Max delay in seconds\n"
2090 "Establish wait in seconds\n")
2092 return bgp_update_delay_config_vty(vty
, delay
, wait
);
2095 /* Update-delay deconfiguration */
2096 DEFPY (no_bgp_update_delay
,
2097 no_bgp_update_delay_cmd
,
2098 "no update-delay [(0-3600) [(1-3600)]]",
2100 "Force initial delay for best-path and updates\n"
2101 "Max delay in seconds\n"
2102 "Establish wait in seconds\n")
2104 return bgp_update_delay_deconfig_vty(vty
);
2108 int bgp_wpkt_quanta_config_vty(struct bgp
*bgp
, uint32_t quanta
, bool set
)
2110 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
2111 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
2116 int bgp_rpkt_quanta_config_vty(struct bgp
*bgp
, uint32_t quanta
, bool set
)
2118 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
2119 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
2124 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2127 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
2128 if (quanta
!= BGP_WRITE_PACKET_MAX
)
2129 vty_out(vty
, " write-quanta %d\n", quanta
);
2132 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
2135 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
2136 if (quanta
!= BGP_READ_PACKET_MAX
)
2137 vty_out(vty
, " read-quanta %d\n", quanta
);
2140 /* Packet quanta configuration
2142 * XXX: The value set here controls the size of a stack buffer in the IO
2143 * thread. When changing these limits be careful to prevent stack overflow.
2145 * Furthermore, the maximums used here should correspond to
2146 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
2148 DEFPY_YANG (bgp_wpkt_quanta
,
2149 bgp_wpkt_quanta_cmd
,
2150 "[no] write-quanta (1-64)$quanta",
2152 "How many packets to write to peer socket per run\n"
2153 "Number of packets\n")
2156 nb_cli_enqueue_change(
2158 "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta",
2159 NB_OP_MODIFY
, quanta_str
);
2161 nb_cli_enqueue_change(
2163 "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta",
2164 NB_OP_MODIFY
, NULL
);
2166 return nb_cli_apply_changes(vty
, NULL
);
2169 DEFPY_YANG (bgp_rpkt_quanta
,
2170 bgp_rpkt_quanta_cmd
,
2171 "[no] read-quanta (1-10)$quanta",
2173 "How many packets to read from peer socket per I/O cycle\n"
2174 "Number of packets\n")
2177 nb_cli_enqueue_change(
2179 "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta",
2180 NB_OP_MODIFY
, quanta_str
);
2182 nb_cli_enqueue_change(
2184 "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta",
2185 NB_OP_MODIFY
, NULL
);
2187 return nb_cli_apply_changes(vty
, NULL
);
2190 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2192 if (!bgp
->heuristic_coalesce
)
2193 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2196 void cli_show_router_global_update_group_config_coalesce_time(
2197 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2199 vty_out(vty
, " coalesce-time %u\n", yang_dnode_get_uint32(dnode
, NULL
));
2203 DEFUN_YANG (bgp_coalesce_time
,
2204 bgp_coalesce_time_cmd
,
2205 "coalesce-time (0-4294967295)",
2206 "Subgroup coalesce timer\n"
2207 "Subgroup coalesce timer value (in ms)\n")
2211 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
2212 nb_cli_enqueue_change(
2213 vty
, "./global/global-update-group-config/coalesce-time",
2214 NB_OP_MODIFY
, argv
[idx
]->arg
);
2216 return nb_cli_apply_changes(vty
, NULL
);
2219 DEFUN_YANG(no_bgp_coalesce_time
,
2220 no_bgp_coalesce_time_cmd
,
2221 "no coalesce-time (0-4294967295)",
2223 "Subgroup coalesce timer\n"
2224 "Subgroup coalesce timer value (in ms)\n")
2226 nb_cli_enqueue_change(
2227 vty
, "./global/global-update-group-config/coalesce-time",
2228 NB_OP_MODIFY
, NULL
);
2230 return nb_cli_apply_changes(vty
, NULL
);
2233 /* Maximum-paths configuration */
2234 DEFUN_YANG (bgp_maxpaths
,
2236 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2237 "Forward packets over multiple paths\n"
2238 "Number of paths\n")
2241 char base_xpath
[XPATH_MAXLEN
];
2245 afi
= bgp_node_afi(vty
);
2246 safi
= bgp_node_safi(vty
);
2249 base_xpath
, sizeof(base_xpath
),
2250 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ebgp/maximum-paths",
2251 yang_afi_safi_value2identity(afi
, safi
),
2252 bgp_afi_safi_get_container_str(afi
, safi
));
2254 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2255 argv
[idx_number
]->arg
);
2257 return nb_cli_apply_changes(vty
, NULL
);
2260 void cli_show_bgp_global_afi_safi_unicast_use_multiple_paths_ebgp_maximum_paths(
2261 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2263 vty_out(vty
, " maximum-paths %d\n",
2264 yang_dnode_get_uint16(dnode
, NULL
));
2267 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2268 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2269 "Forward packets over multiple paths\n"
2270 "Number of paths\n")
2272 DEFUN_YANG (bgp_maxpaths_ibgp
,
2273 bgp_maxpaths_ibgp_cmd
,
2274 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2275 "Forward packets over multiple paths\n"
2277 "Number of paths\n")
2280 char base_xpath
[XPATH_MAXLEN
];
2284 afi
= bgp_node_afi(vty
);
2285 safi
= bgp_node_safi(vty
);
2288 base_xpath
, sizeof(base_xpath
),
2289 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2290 yang_afi_safi_value2identity(afi
, safi
),
2291 bgp_afi_safi_get_container_str(afi
, safi
));
2293 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2294 argv
[idx_number
]->arg
);
2296 return nb_cli_apply_changes(vty
, NULL
);
2299 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2300 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2301 "Forward packets over multiple paths\n"
2303 "Number of paths\n")
2305 DEFUN_YANG (bgp_maxpaths_ibgp_cluster
,
2306 bgp_maxpaths_ibgp_cluster_cmd
,
2307 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2308 "Forward packets over multiple paths\n"
2311 "Match the cluster length\n")
2314 char base_xpath
[XPATH_MAXLEN
];
2318 afi
= bgp_node_afi(vty
);
2319 safi
= bgp_node_safi(vty
);
2322 base_xpath
, sizeof(base_xpath
),
2323 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2324 yang_afi_safi_value2identity(afi
, safi
),
2325 bgp_afi_safi_get_container_str(afi
, safi
));
2327 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
,
2328 argv
[idx_number
]->arg
);
2331 base_xpath
, sizeof(base_xpath
),
2332 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/cluster-length-list",
2333 yang_afi_safi_value2identity(afi
, safi
),
2334 bgp_afi_safi_get_container_str(afi
, safi
));
2336 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, "true");
2338 return nb_cli_apply_changes(vty
, NULL
);
2341 void cli_show_bgp_global_afi_safi_ip_unicast_use_multiple_paths_ibgp_maximum_paths(
2342 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2344 vty_out(vty
, " maximum-paths ibgp %d",
2345 yang_dnode_get_uint16(dnode
, "./maximum-paths"));
2346 if (yang_dnode_get_bool(dnode
, "./cluster-length-list"))
2347 vty_out(vty
, " equal-cluster-length");
2351 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2352 "maximum-paths ibgp " CMD_RANGE_STR(
2353 1, MULTIPATH_NUM
) " equal-cluster-length",
2354 "Forward packets over multiple paths\n"
2357 "Match the cluster length\n")
2359 DEFUN_YANG (no_bgp_maxpaths
,
2360 no_bgp_maxpaths_cmd
,
2361 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2363 "Forward packets over multiple paths\n"
2364 "Number of paths\n")
2366 char base_xpath
[XPATH_MAXLEN
];
2370 afi
= bgp_node_afi(vty
);
2371 safi
= bgp_node_safi(vty
);
2374 base_xpath
, sizeof(base_xpath
),
2375 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ebgp/maximum-paths",
2376 yang_afi_safi_value2identity(afi
, safi
),
2377 bgp_afi_safi_get_container_str(afi
, safi
));
2379 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, NULL
);
2381 return nb_cli_apply_changes(vty
, NULL
);
2384 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2385 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2386 "Forward packets over multiple paths\n"
2387 "Number of paths\n")
2389 DEFUN_YANG (no_bgp_maxpaths_ibgp
,
2390 no_bgp_maxpaths_ibgp_cmd
,
2391 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2393 "Forward packets over multiple paths\n"
2396 "Match the cluster length\n")
2398 char base_xpath
[XPATH_MAXLEN
];
2402 afi
= bgp_node_afi(vty
);
2403 safi
= bgp_node_safi(vty
);
2406 base_xpath
, sizeof(base_xpath
),
2407 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/maximum-paths",
2408 yang_afi_safi_value2identity(afi
, safi
),
2409 bgp_afi_safi_get_container_str(afi
, safi
));
2411 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, NULL
);
2414 base_xpath
, sizeof(base_xpath
),
2415 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/use-multiple-paths/ibgp/cluster-length-list",
2416 yang_afi_safi_value2identity(afi
, safi
),
2417 bgp_afi_safi_get_container_str(afi
, safi
));
2419 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_MODIFY
, "false");
2421 return nb_cli_apply_changes(vty
, NULL
);
2424 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2425 "no maximum-paths ibgp [" CMD_RANGE_STR(
2426 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2428 "Forward packets over multiple paths\n"
2431 "Match the cluster length\n")
2433 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2434 afi_t afi
, safi_t safi
)
2436 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= multipath_num
) {
2437 vty_out(vty
, " maximum-paths %d\n",
2438 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2441 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= multipath_num
) {
2442 vty_out(vty
, " maximum-paths ibgp %d",
2443 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2444 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
2445 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
2446 vty_out(vty
, " equal-cluster-length");
2453 DEFUN_YANG (bgp_timers
,
2455 "timers bgp (0-65535) (0-65535)",
2456 "Adjust routing timers\n"
2458 "Keepalive interval\n"
2462 int idx_number_2
= 3;
2464 nb_cli_enqueue_change(vty
, "./global/global-config-timers/keepalive",
2465 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
2466 nb_cli_enqueue_change(vty
, "./global/global-config-timers/hold-time",
2467 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
2469 return nb_cli_apply_changes(vty
, NULL
);
2472 DEFUN_YANG (no_bgp_timers
,
2474 "no timers bgp [(0-65535) (0-65535)]",
2476 "Adjust routing timers\n"
2478 "Keepalive interval\n"
2481 nb_cli_enqueue_change(vty
, "./global/global-config-timers/keepalive",
2482 NB_OP_DESTROY
, NULL
);
2483 nb_cli_enqueue_change(vty
, "./global/global-config-timers/hold-time",
2484 NB_OP_DESTROY
, NULL
);
2486 return nb_cli_apply_changes(vty
, NULL
);
2489 void cli_show_router_bgp_route_reflector(struct vty
*vty
,
2490 struct lyd_node
*dnode
,
2493 if (yang_dnode_get_bool(dnode
, "./no-client-reflect"))
2494 vty_out(vty
, " no bgp client-to-client reflection\n");
2496 if (yang_dnode_get_bool(dnode
, "./allow-outbound-policy"))
2497 vty_out(vty
, " bgp route-reflector allow-outbound-policy\n");
2499 if (yang_dnode_exists(dnode
, "./route-reflector-cluster-id"))
2500 vty_out(vty
, " bgp cluster-id %s\n",
2501 yang_dnode_get_string(dnode
,
2502 "./route-reflector-cluster-id"));
2505 DEFUN_YANG(bgp_client_to_client_reflection
,
2506 bgp_client_to_client_reflection_cmd
,
2507 "bgp client-to-client reflection",
2508 "BGP specific commands\n"
2509 "Configure client to client route reflection\n"
2510 "reflection of routes allowed\n")
2512 nb_cli_enqueue_change(vty
, "./global/route-reflector/no-client-reflect",
2513 NB_OP_MODIFY
, "false");
2515 return nb_cli_apply_changes(vty
, NULL
);
2518 DEFUN_YANG(no_bgp_client_to_client_reflection
,
2519 no_bgp_client_to_client_reflection_cmd
,
2520 "no bgp client-to-client reflection",
2522 "BGP specific commands\n"
2523 "Configure client to client route reflection\n"
2524 "reflection of routes allowed\n")
2526 nb_cli_enqueue_change(vty
, "./global/route-reflector/no-client-reflect",
2527 NB_OP_MODIFY
, "true");
2529 return nb_cli_apply_changes(vty
, NULL
);
2532 void cli_show_router_bgp_route_selection(struct vty
*vty
,
2533 struct lyd_node
*dnode
,
2537 if (yang_dnode_get_bool(dnode
, "./always-compare-med"))
2538 vty_out(vty
, " bgp always-compare-med\n");
2540 if (yang_dnode_get_bool(dnode
, "./ignore-as-path-length"))
2541 vty_out(vty
, " bgp bestpath as-path ignore\n");
2543 if (yang_dnode_get_bool(dnode
, "./aspath-confed"))
2544 vty_out(vty
, " bgp bestpath as-path confed\n");
2546 if (yang_dnode_get_bool(dnode
, "./external-compare-router-id"))
2547 vty_out(vty
, " bgp bestpath compare-routerid\n");
2549 if (yang_dnode_get_bool(dnode
, "./allow-multiple-as")) {
2550 if (yang_dnode_get_bool(dnode
, "./multi-path-as-set"))
2552 " bgp bestpath as-path multipath-relax as-set\n");
2554 vty_out(vty
, " bgp bestpath as-path multipath-relax\n");
2557 if (yang_dnode_get_bool(dnode
, "./deterministic-med"))
2558 vty_out(vty
, " bgp deterministic-med\n");
2560 if (yang_dnode_get_bool(dnode
, "./confed-med")
2561 || yang_dnode_get_bool(dnode
, "./missing-as-worst-med")) {
2562 vty_out(vty
, " bgp bestpath med");
2563 if (yang_dnode_get_bool(dnode
, "./confed-med"))
2564 vty_out(vty
, " confed");
2565 if (yang_dnode_get_bool(dnode
, "./missing-as-worst-med"))
2566 vty_out(vty
, " missing-as-worst");
2571 /* "bgp always-compare-med" configuration. */
2572 DEFUN_YANG(bgp_always_compare_med
,
2573 bgp_always_compare_med_cmd
,
2574 "bgp always-compare-med",
2575 "BGP specific commands\n"
2576 "Allow comparing MED from different neighbors\n")
2578 nb_cli_enqueue_change(
2579 vty
, "./global/route-selection-options/always-compare-med",
2580 NB_OP_MODIFY
, "true");
2582 return nb_cli_apply_changes(vty
, NULL
);
2585 DEFUN_YANG(no_bgp_always_compare_med
,
2586 no_bgp_always_compare_med_cmd
,
2587 "no bgp always-compare-med",
2589 "BGP specific commands\n"
2590 "Allow comparing MED from different neighbors\n")
2592 nb_cli_enqueue_change(
2593 vty
, "./global/route-selection-options/always-compare-med",
2594 NB_OP_MODIFY
, "false");
2596 return nb_cli_apply_changes(vty
, NULL
);
2599 DEFUN_YANG(bgp_suppress_duplicates
,
2600 bgp_suppress_duplicates_cmd
,
2601 "bgp suppress-duplicates",
2602 "BGP specific commands\n"
2603 "Suppress duplicate updates if the route actually not changed\n")
2605 nb_cli_enqueue_change(vty
, "./global/suppress-duplicates",
2606 NB_OP_MODIFY
, "true");
2607 return nb_cli_apply_changes(vty
, NULL
);
2610 DEFUN_YANG(no_bgp_suppress_duplicates
,
2611 no_bgp_suppress_duplicates_cmd
,
2612 "no bgp suppress-duplicates",
2614 "BGP specific commands\n"
2615 "Suppress duplicate updates if the route actually not changed\n")
2617 nb_cli_enqueue_change(vty
, "./global/suppress-duplicates",
2618 NB_OP_MODIFY
, "false");
2619 return nb_cli_apply_changes(vty
, NULL
);
2622 void cli_show_router_bgp_suppress_duplicates(struct vty
*vty
,
2623 struct lyd_node
*dnode
,
2626 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SUPPRESS_DUPLICATES
)
2627 vty_out(vty
, " bgp suppress-duplicates\n");
2630 DEFUN_YANG(bgp_ebgp_requires_policy
,
2631 bgp_ebgp_requires_policy_cmd
,
2632 "bgp ebgp-requires-policy",
2633 "BGP specific commands\n"
2634 "Require in and out policy for eBGP peers (RFC8212)\n")
2636 nb_cli_enqueue_change(vty
, "./global/ebgp-requires-policy",
2637 NB_OP_MODIFY
, "true");
2638 return nb_cli_apply_changes(vty
, NULL
);
2641 DEFUN_YANG(no_bgp_ebgp_requires_policy
,
2642 no_bgp_ebgp_requires_policy_cmd
,
2643 "no bgp ebgp-requires-policy",
2645 "BGP specific commands\n"
2646 "Require in and out policy for eBGP peers (RFC8212)\n")
2648 nb_cli_enqueue_change(vty
, "./global/ebgp-requires-policy",
2649 NB_OP_MODIFY
, "false");
2650 return nb_cli_apply_changes(vty
, NULL
);
2653 void cli_show_router_bgp_ebgp_requires_policy(struct vty
*vty
,
2654 struct lyd_node
*dnode
,
2657 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_EBGP_REQUIRES_POLICY
)
2658 vty_out(vty
, " bgp ebgp-requires-policy\n");
2661 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2662 "bgp reject-as-sets",
2663 "BGP specific commands\n"
2664 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2666 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2667 struct listnode
*node
, *nnode
;
2670 bgp
->reject_as_sets
= true;
2672 /* Reset existing BGP sessions to reject routes
2673 * with aspath containing AS_SET or AS_CONFED_SET.
2675 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2676 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2677 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2678 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2679 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2686 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2687 "no bgp reject-as-sets",
2689 "BGP specific commands\n"
2690 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2692 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2693 struct listnode
*node
, *nnode
;
2696 bgp
->reject_as_sets
= false;
2698 /* Reset existing BGP sessions to reject routes
2699 * with aspath containing AS_SET or AS_CONFED_SET.
2701 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2702 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2703 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2704 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2705 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2712 /* "bgp deterministic-med" configuration. */
2713 DEFUN_YANG (bgp_deterministic_med
,
2714 bgp_deterministic_med_cmd
,
2715 "bgp deterministic-med",
2716 "BGP specific commands\n"
2717 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2719 nb_cli_enqueue_change(
2720 vty
, "./global/route-selection-options/deterministic-med",
2721 NB_OP_MODIFY
, "true");
2723 return nb_cli_apply_changes(vty
, NULL
);
2726 DEFUN_YANG (no_bgp_deterministic_med
,
2727 no_bgp_deterministic_med_cmd
,
2728 "no bgp deterministic-med",
2730 "BGP specific commands\n"
2731 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2733 nb_cli_enqueue_change(
2734 vty
, "./global/route-selection-options/deterministic-med",
2735 NB_OP_MODIFY
, "false");
2737 return nb_cli_apply_changes(vty
, NULL
);
2740 /* "bgp graceful-restart mode" configuration. */
2741 DEFUN (bgp_graceful_restart
,
2742 bgp_graceful_restart_cmd
,
2743 "bgp graceful-restart",
2744 "BGP specific commands\n"
2748 int ret
= BGP_GR_FAILURE
;
2750 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2751 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2753 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2755 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2757 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2760 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2761 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2763 "Graceful restart configuration changed, reset all peers to take effect\n");
2764 return bgp_vty_return(vty
, ret
);
2767 DEFUN (no_bgp_graceful_restart
,
2768 no_bgp_graceful_restart_cmd
,
2769 "no bgp graceful-restart",
2771 "BGP specific commands\n"
2775 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2777 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2778 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2780 int ret
= BGP_GR_FAILURE
;
2782 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2784 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2787 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2788 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2790 "Graceful restart configuration changed, reset all peers to take effect\n");
2792 return bgp_vty_return(vty
, ret
);
2795 DEFUN (bgp_graceful_restart_stalepath_time
,
2796 bgp_graceful_restart_stalepath_time_cmd
,
2797 "bgp graceful-restart stalepath-time (1-4095)",
2798 "BGP specific commands\n"
2799 "Graceful restart capability parameters\n"
2800 "Set the max time to hold onto restarting peer's stale paths\n"
2801 "Delay value (seconds)\n")
2803 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2807 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2808 bgp
->stalepath_time
= stalepath
;
2812 DEFUN (bgp_graceful_restart_restart_time
,
2813 bgp_graceful_restart_restart_time_cmd
,
2814 "bgp graceful-restart restart-time (1-4095)",
2815 "BGP specific commands\n"
2816 "Graceful restart capability parameters\n"
2817 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2818 "Delay value (seconds)\n")
2820 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2824 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2825 bgp
->restart_time
= restart
;
2829 DEFUN (bgp_graceful_restart_select_defer_time
,
2830 bgp_graceful_restart_select_defer_time_cmd
,
2831 "bgp graceful-restart select-defer-time (0-3600)",
2832 "BGP specific commands\n"
2833 "Graceful restart capability parameters\n"
2834 "Set the time to defer the BGP route selection after restart\n"
2835 "Delay value (seconds, 0 - disable)\n")
2837 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2839 uint32_t defer_time
;
2841 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2842 bgp
->select_defer_time
= defer_time
;
2843 if (defer_time
== 0)
2844 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2846 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2851 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2852 no_bgp_graceful_restart_stalepath_time_cmd
,
2853 "no bgp graceful-restart stalepath-time [(1-4095)]",
2855 "BGP specific commands\n"
2856 "Graceful restart capability parameters\n"
2857 "Set the max time to hold onto restarting peer's stale paths\n"
2858 "Delay value (seconds)\n")
2860 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2862 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2866 DEFUN (no_bgp_graceful_restart_restart_time
,
2867 no_bgp_graceful_restart_restart_time_cmd
,
2868 "no bgp graceful-restart restart-time [(1-4095)]",
2870 "BGP specific commands\n"
2871 "Graceful restart capability parameters\n"
2872 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2873 "Delay value (seconds)\n")
2875 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2877 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2881 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2882 no_bgp_graceful_restart_select_defer_time_cmd
,
2883 "no bgp graceful-restart select-defer-time [(0-3600)]",
2885 "BGP specific commands\n"
2886 "Graceful restart capability parameters\n"
2887 "Set the time to defer the BGP route selection after restart\n"
2888 "Delay value (seconds)\n")
2890 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2892 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2893 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2898 DEFUN (bgp_graceful_restart_preserve_fw
,
2899 bgp_graceful_restart_preserve_fw_cmd
,
2900 "bgp graceful-restart preserve-fw-state",
2901 "BGP specific commands\n"
2902 "Graceful restart capability parameters\n"
2903 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2905 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2906 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2910 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2911 no_bgp_graceful_restart_preserve_fw_cmd
,
2912 "no bgp graceful-restart preserve-fw-state",
2914 "BGP specific commands\n"
2915 "Graceful restart capability parameters\n"
2916 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2918 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2919 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2923 DEFUN (bgp_graceful_restart_disable
,
2924 bgp_graceful_restart_disable_cmd
,
2925 "bgp graceful-restart-disable",
2926 "BGP specific commands\n"
2929 int ret
= BGP_GR_FAILURE
;
2931 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2933 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
2935 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2937 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
2939 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
2942 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2944 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
2946 "Graceful restart configuration changed, reset all peers to take effect\n");
2948 return bgp_vty_return(vty
, ret
);
2951 DEFUN (no_bgp_graceful_restart_disable
,
2952 no_bgp_graceful_restart_disable_cmd
,
2953 "no bgp graceful-restart-disable",
2955 "BGP specific commands\n"
2959 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2961 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2963 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
2965 int ret
= BGP_GR_FAILURE
;
2967 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
2969 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2972 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2974 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
2976 "Graceful restart configuration changed, reset all peers to take effect\n");
2978 return bgp_vty_return(vty
, ret
);
2981 DEFUN (bgp_neighbor_graceful_restart_set
,
2982 bgp_neighbor_graceful_restart_set_cmd
,
2983 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
2991 int ret
= BGP_GR_FAILURE
;
2993 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2995 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2997 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
2999 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3001 return CMD_WARNING_CONFIG_FAILED
;
3003 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
3005 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3006 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3008 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3010 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
3012 "Graceful restart configuration changed, reset this peer to take effect\n");
3014 return bgp_vty_return(vty
, ret
);
3017 DEFUN (no_bgp_neighbor_graceful_restart
,
3018 no_bgp_neighbor_graceful_restart_set_cmd
,
3019 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
3027 int ret
= BGP_GR_FAILURE
;
3030 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3032 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3034 return CMD_WARNING_CONFIG_FAILED
;
3036 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3038 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
3040 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
3042 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3043 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3045 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3047 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
3049 "Graceful restart configuration changed, reset this peer to take effect\n");
3051 return bgp_vty_return(vty
, ret
);
3054 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
3055 bgp_neighbor_graceful_restart_helper_set_cmd
,
3056 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3059 GR_NEIGHBOR_HELPER_CMD
3064 int ret
= BGP_GR_FAILURE
;
3066 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3068 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3070 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3072 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3075 return CMD_WARNING_CONFIG_FAILED
;
3078 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
3080 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3081 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3083 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3085 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3087 "Graceful restart configuration changed, reset this peer to take effect\n");
3089 return bgp_vty_return(vty
, ret
);
3092 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
3093 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
3094 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
3098 NO_GR_NEIGHBOR_HELPER_CMD
3102 int ret
= BGP_GR_FAILURE
;
3105 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3107 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3109 return CMD_WARNING_CONFIG_FAILED
;
3111 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3113 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
3115 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
3117 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3118 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3120 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3122 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
3124 "Graceful restart configuration changed, reset this peer to take effect\n");
3126 return bgp_vty_return(vty
, ret
);
3129 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
3130 bgp_neighbor_graceful_restart_disable_set_cmd
,
3131 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3134 GR_NEIGHBOR_DISABLE_CMD
3139 int ret
= BGP_GR_FAILURE
;
3141 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3143 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3145 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3147 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3149 return CMD_WARNING_CONFIG_FAILED
;
3151 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
3153 if (peer
->bgp
->t_startup
)
3154 bgp_peer_gr_flags_update(peer
);
3156 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3157 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3159 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3161 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3163 "Graceful restart configuration changed, reset this peer to take effect\n");
3165 return bgp_vty_return(vty
, ret
);
3168 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
3169 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
3170 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
3174 NO_GR_NEIGHBOR_DISABLE_CMD
3178 int ret
= BGP_GR_FAILURE
;
3181 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
3183 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3185 return CMD_WARNING_CONFIG_FAILED
;
3187 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3189 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
3191 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
3193 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
3194 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
3196 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
3198 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
3200 "Graceful restart configuration changed, reset this peer to take effect\n");
3202 return bgp_vty_return(vty
, ret
);
3205 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
3206 bgp_graceful_restart_disable_eor_cmd
,
3207 "bgp graceful-restart disable-eor",
3208 "BGP specific commands\n"
3209 "Graceful restart configuration parameters\n"
3210 "Disable EOR Check\n")
3212 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3213 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3218 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
3219 no_bgp_graceful_restart_disable_eor_cmd
,
3220 "no bgp graceful-restart disable-eor",
3222 "BGP specific commands\n"
3223 "Graceful restart configuration parameters\n"
3224 "Disable EOR Check\n")
3226 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3227 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
3232 DEFUN (bgp_graceful_restart_rib_stale_time
,
3233 bgp_graceful_restart_rib_stale_time_cmd
,
3234 "bgp graceful-restart rib-stale-time (1-3600)",
3235 "BGP specific commands\n"
3236 "Graceful restart configuration parameters\n"
3237 "Specify the stale route removal timer in rib\n"
3238 "Delay value (seconds)\n")
3240 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3242 uint32_t stale_time
;
3244 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3245 bgp
->rib_stale_time
= stale_time
;
3246 /* Send the stale timer update message to RIB */
3247 if (bgp_zebra_stale_timer_update(bgp
))
3253 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
3254 no_bgp_graceful_restart_rib_stale_time_cmd
,
3255 "no bgp graceful-restart rib-stale-time [(1-3600)]",
3257 "BGP specific commands\n"
3258 "Graceful restart configuration parameters\n"
3259 "Specify the stale route removal timer in rib\n"
3260 "Delay value (seconds)\n")
3262 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3264 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
3265 /* Send the stale timer update message to RIB */
3266 if (bgp_zebra_stale_timer_update(bgp
))
3272 static inline int bgp_initiate_graceful_shut_unshut(struct bgp
*bgp
,
3276 bgp_static_redo_import_check(bgp
);
3277 bgp_redistribute_redo(bgp
);
3278 if (bgp_clear_star_soft_out(bgp
->name
, errmsg
, errmsg_len
) < 0)
3280 if (bgp_clear_star_soft_in(bgp
->name
, errmsg
, errmsg_len
) < 0)
3286 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
3288 struct listnode
*node
, *nnode
;
3290 bool vrf_cfg
= false;
3291 char errmsg
[BUFSIZ
] = {'\0'};
3293 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3296 /* See if graceful-shutdown is set per-vrf and warn user to delete */
3297 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3298 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
3300 "%% graceful-shutdown configuration found in vrf %s\n",
3301 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
3302 VRF_DEFAULT_NAME
: bgp
->name
);
3309 "%%Failed: global graceful-shutdown not permitted\n");
3313 /* Set flag globally */
3314 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3316 /* Initiate processing for all BGP instances. */
3317 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3318 if (bgp_initiate_graceful_shut_unshut(bgp
, errmsg
,
3322 vty_out(vty
, "%s\n", errmsg
);
3328 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3330 struct listnode
*node
, *nnode
;
3332 char errmsg
[BUFSIZ
] = {'\0'};
3334 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3337 /* Unset flag globally */
3338 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3340 /* Initiate processing for all BGP instances. */
3341 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3342 if (bgp_initiate_graceful_shut_unshut(bgp
, errmsg
,
3346 vty_out(vty
, "%s\n", errmsg
);
3352 /* "bgp graceful-shutdown" configuration */
3353 DEFUN (bgp_graceful_shutdown
,
3354 bgp_graceful_shutdown_cmd
,
3355 "bgp graceful-shutdown",
3357 "Graceful shutdown parameters\n")
3359 if (vty
->node
== CONFIG_NODE
)
3360 return bgp_global_graceful_shutdown_config_vty(vty
);
3362 nb_cli_enqueue_change(vty
, "./global/graceful-shutdown/enable",
3363 NB_OP_MODIFY
, "true");
3365 return nb_cli_apply_changes(vty
, NULL
);
3368 DEFUN_YANG (no_bgp_graceful_shutdown
,
3369 no_bgp_graceful_shutdown_cmd
,
3370 "no bgp graceful-shutdown",
3373 "Graceful shutdown parameters\n")
3375 if (vty
->node
== CONFIG_NODE
)
3376 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3378 nb_cli_enqueue_change(vty
, "./global/graceful-shutdown/enable",
3379 NB_OP_MODIFY
, "false");
3381 return nb_cli_apply_changes(vty
, NULL
);
3384 void cli_show_router_bgp_graceful_shutdown(struct vty
*vty
,
3385 struct lyd_node
*dnode
,
3388 if (yang_dnode_get_bool(dnode
, NULL
))
3389 vty_out(vty
, " bgp graceful-shutdown\n");
3392 /* "bgp fast-external-failover" configuration. */
3393 DEFUN_YANG (bgp_fast_external_failover
,
3394 bgp_fast_external_failover_cmd
,
3395 "bgp fast-external-failover",
3397 "Immediately reset session if a link to a directly connected external peer goes down\n")
3399 nb_cli_enqueue_change(vty
, "./global/fast-external-failover",
3400 NB_OP_MODIFY
, "false");
3402 return nb_cli_apply_changes(vty
, NULL
);
3405 DEFUN_YANG (no_bgp_fast_external_failover
,
3406 no_bgp_fast_external_failover_cmd
,
3407 "no bgp fast-external-failover",
3410 "Immediately reset session if a link to a directly connected external peer goes down\n")
3412 nb_cli_enqueue_change(vty
, "./global/fast-external-failover",
3413 NB_OP_MODIFY
, "true");
3415 return nb_cli_apply_changes(vty
, NULL
);
3418 void cli_show_router_bgp_fast_external_failover(struct vty
*vty
,
3419 struct lyd_node
*dnode
,
3422 if (!yang_dnode_get_bool(dnode
, NULL
))
3423 vty_out(vty
, " no bgp fast-external-failover\n");
3426 /* "bgp bestpath compare-routerid" configuration. */
3427 DEFUN_YANG(bgp_bestpath_compare_router_id
,
3428 bgp_bestpath_compare_router_id_cmd
,
3429 "bgp bestpath compare-routerid",
3430 "BGP specific commands\n"
3431 "Change the default bestpath selection\n"
3432 "Compare router-id for identical EBGP paths\n")
3434 nb_cli_enqueue_change(
3436 "./global/route-selection-options/external-compare-router-id",
3437 NB_OP_MODIFY
, "true");
3439 return nb_cli_apply_changes(vty
, NULL
);
3442 DEFUN_YANG(no_bgp_bestpath_compare_router_id
,
3443 no_bgp_bestpath_compare_router_id_cmd
,
3444 "no bgp bestpath compare-routerid",
3446 "BGP specific commands\n"
3447 "Change the default bestpath selection\n"
3448 "Compare router-id for identical EBGP paths\n")
3450 nb_cli_enqueue_change(
3452 "./global/route-selection-options/external-compare-router-id",
3453 NB_OP_MODIFY
, "false");
3455 return nb_cli_apply_changes(vty
, NULL
);
3458 /* "bgp bestpath as-path ignore" configuration. */
3459 DEFUN_YANG(bgp_bestpath_aspath_ignore
,
3460 bgp_bestpath_aspath_ignore_cmd
,
3461 "bgp bestpath as-path ignore",
3462 "BGP specific commands\n"
3463 "Change the default bestpath selection\n"
3464 "AS-path attribute\n"
3465 "Ignore as-path length in selecting a route\n")
3467 nb_cli_enqueue_change(
3468 vty
, "./global/route-selection-options/ignore-as-path-length",
3469 NB_OP_MODIFY
, "true");
3471 return nb_cli_apply_changes(vty
, NULL
);
3474 DEFUN_YANG(no_bgp_bestpath_aspath_ignore
,
3475 no_bgp_bestpath_aspath_ignore_cmd
,
3476 "no bgp bestpath as-path ignore",
3478 "BGP specific commands\n"
3479 "Change the default bestpath selection\n"
3480 "AS-path attribute\n"
3481 "Ignore as-path length in selecting a route\n")
3483 nb_cli_enqueue_change(
3484 vty
, "./global/route-selection-options/ignore-as-path-length",
3485 NB_OP_MODIFY
, "false");
3487 return nb_cli_apply_changes(vty
, NULL
);
3490 /* "bgp bestpath as-path confed" configuration. */
3491 DEFUN_YANG (bgp_bestpath_aspath_confed
,
3492 bgp_bestpath_aspath_confed_cmd
,
3493 "bgp bestpath as-path confed",
3494 "BGP specific commands\n"
3495 "Change the default bestpath selection\n"
3496 "AS-path attribute\n"
3497 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3499 nb_cli_enqueue_change(vty
,
3500 "./global/route-selection-options/aspath-confed",
3501 NB_OP_MODIFY
, "true");
3503 return nb_cli_apply_changes(vty
, NULL
);
3506 DEFUN_YANG (no_bgp_bestpath_aspath_confed
,
3507 no_bgp_bestpath_aspath_confed_cmd
,
3508 "no bgp bestpath as-path confed",
3510 "BGP specific commands\n"
3511 "Change the default bestpath selection\n"
3512 "AS-path attribute\n"
3513 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3515 nb_cli_enqueue_change(vty
,
3516 "./global/route-selection-options/aspath-confed",
3517 NB_OP_MODIFY
, "false");
3519 return nb_cli_apply_changes(vty
, NULL
);
3522 /* "bgp bestpath as-path multipath-relax" configuration. */
3523 DEFUN_YANG (bgp_bestpath_aspath_multipath_relax
,
3524 bgp_bestpath_aspath_multipath_relax_cmd
,
3525 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3526 "BGP specific commands\n"
3527 "Change the default bestpath selection\n"
3528 "AS-path attribute\n"
3529 "Allow load sharing across routes that have different AS paths (but same length)\n"
3530 "Generate an AS_SET\n"
3531 "Do not generate an AS_SET\n")
3535 nb_cli_enqueue_change(
3536 vty
, "./global/route-selection-options/allow-multiple-as",
3537 NB_OP_MODIFY
, "true");
3538 if (argv_find(argv
, argc
, "as-set", &idx
))
3539 nb_cli_enqueue_change(
3541 "./global/route-selection-options/multi-path-as-set",
3542 NB_OP_MODIFY
, "true");
3544 nb_cli_enqueue_change(
3546 "./global/route-selection-options/multi-path-as-set",
3547 NB_OP_MODIFY
, "false");
3549 return nb_cli_apply_changes(vty
, NULL
);
3552 DEFUN_YANG (no_bgp_bestpath_aspath_multipath_relax
,
3553 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3554 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3556 "BGP specific commands\n"
3557 "Change the default bestpath selection\n"
3558 "AS-path attribute\n"
3559 "Allow load sharing across routes that have different AS paths (but same length)\n"
3560 "Generate an AS_SET\n"
3561 "Do not generate an AS_SET\n")
3563 nb_cli_enqueue_change(
3564 vty
, "./global/route-selection-options/allow-multiple-as",
3565 NB_OP_MODIFY
, "false");
3566 nb_cli_enqueue_change(
3567 vty
, "./global/route-selection-options/multi-path-as-set",
3568 NB_OP_MODIFY
, "false");
3570 return nb_cli_apply_changes(vty
, NULL
);
3573 /* "bgp log-neighbor-changes" configuration. */
3574 DEFUN_YANG(bgp_log_neighbor_changes
,
3575 bgp_log_neighbor_changes_cmd
,
3576 "bgp log-neighbor-changes",
3577 "BGP specific commands\n"
3578 "Log neighbor up/down and reset reason\n")
3580 nb_cli_enqueue_change(
3581 vty
, "./global/global-neighbor-config/log-neighbor-changes",
3582 NB_OP_MODIFY
, "true");
3584 return nb_cli_apply_changes(vty
, NULL
);
3587 DEFUN_YANG(no_bgp_log_neighbor_changes
,
3588 no_bgp_log_neighbor_changes_cmd
,
3589 "no bgp log-neighbor-changes",
3591 "BGP specific commands\n"
3592 "Log neighbor up/down and reset reason\n")
3594 nb_cli_enqueue_change(
3595 vty
, "./global/global-neighbor-config/log-neighbor-changes",
3596 NB_OP_MODIFY
, "false");
3598 return nb_cli_apply_changes(vty
, NULL
);
3601 /* "bgp bestpath med" configuration. */
3602 DEFUN_YANG (bgp_bestpath_med
,
3603 bgp_bestpath_med_cmd
,
3604 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3605 "BGP specific commands\n"
3606 "Change the default bestpath selection\n"
3608 "Compare MED among confederation paths\n"
3609 "Treat missing MED as the least preferred one\n"
3610 "Treat missing MED as the least preferred one\n"
3611 "Compare MED among confederation paths\n")
3614 bool confed
= false;
3615 bool worst_med
= false;
3618 if (argv_find(argv
, argc
, "confed", &idx
))
3621 nb_cli_enqueue_change(vty
,
3622 "./global/route-selection-options/confed-med",
3623 NB_OP_MODIFY
, confed
? "true" : "false");
3626 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3629 nb_cli_enqueue_change(
3630 vty
, "./global/route-selection-options/missing-as-worst-med",
3631 NB_OP_MODIFY
, worst_med
? "true" : "false");
3633 return nb_cli_apply_changes(vty
, NULL
);
3636 DEFUN_YANG (no_bgp_bestpath_med
,
3637 no_bgp_bestpath_med_cmd
,
3638 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3640 "BGP specific commands\n"
3641 "Change the default bestpath selection\n"
3643 "Compare MED among confederation paths\n"
3644 "Treat missing MED as the least preferred one\n"
3645 "Treat missing MED as the least preferred one\n"
3646 "Compare MED among confederation paths\n")
3650 if (argv_find(argv
, argc
, "confed", &idx
))
3651 nb_cli_enqueue_change(
3652 vty
, "./global/route-selection-options/confed-med",
3653 NB_OP_MODIFY
, "false");
3656 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3657 nb_cli_enqueue_change(
3659 "./global/route-selection-options/missing-as-worst-med",
3660 NB_OP_MODIFY
, "false");
3662 return nb_cli_apply_changes(vty
, NULL
);
3665 /* "bgp bestpath bandwidth" configuration. */
3666 DEFPY (bgp_bestpath_bw
,
3667 bgp_bestpath_bw_cmd
,
3668 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3669 "BGP specific commands\n"
3670 "Change the default bestpath selection\n"
3671 "Link Bandwidth attribute\n"
3672 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3673 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3674 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3676 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3681 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3682 return CMD_ERR_INCOMPLETE
;
3684 if (!strcmp(bw_cfg
, "ignore"))
3685 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3686 else if (!strcmp(bw_cfg
, "skip-missing"))
3687 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3688 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3689 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3691 return CMD_ERR_NO_MATCH
;
3693 /* This config is used in route install, so redo that. */
3694 FOREACH_AFI_SAFI (afi
, safi
) {
3695 if (!bgp_fibupd_safi(safi
))
3697 bgp_zebra_announce_table(bgp
, afi
, safi
);
3703 DEFPY (no_bgp_bestpath_bw
,
3704 no_bgp_bestpath_bw_cmd
,
3705 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3707 "BGP specific commands\n"
3708 "Change the default bestpath selection\n"
3709 "Link Bandwidth attribute\n"
3710 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3711 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3712 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3714 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3718 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3720 /* This config is used in route install, so redo that. */
3721 FOREACH_AFI_SAFI (afi
, safi
) {
3722 if (!bgp_fibupd_safi(safi
))
3724 bgp_zebra_announce_table(bgp
, afi
, safi
);
3729 /* "no bgp default ipv4-unicast". */
3730 DEFUN (no_bgp_default_ipv4_unicast
,
3731 no_bgp_default_ipv4_unicast_cmd
,
3732 "no bgp default ipv4-unicast",
3734 "BGP specific commands\n"
3735 "Configure BGP defaults\n"
3736 "Activate ipv4-unicast for a peer by default\n")
3738 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3739 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
);
3743 DEFUN (bgp_default_ipv4_unicast
,
3744 bgp_default_ipv4_unicast_cmd
,
3745 "bgp default ipv4-unicast",
3746 "BGP specific commands\n"
3747 "Configure BGP defaults\n"
3748 "Activate ipv4-unicast for a peer by default\n")
3750 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3751 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
);
3755 /* Display hostname in certain command outputs */
3756 DEFUN_YANG (bgp_default_show_hostname
,
3757 bgp_default_show_hostname_cmd
,
3758 "bgp default show-hostname",
3759 "BGP specific commands\n"
3760 "Configure BGP defaults\n"
3761 "Show hostname in certain command outputs\n")
3763 nb_cli_enqueue_change(vty
, "./global/show-hostname", NB_OP_MODIFY
,
3766 return nb_cli_apply_changes(vty
, NULL
);
3769 DEFUN_YANG(no_bgp_default_show_hostname
,
3770 no_bgp_default_show_hostname_cmd
,
3771 "no bgp default show-hostname",
3773 "BGP specific commands\n"
3774 "Configure BGP defaults\n"
3775 "Show hostname in certain command outputs\n")
3777 nb_cli_enqueue_change(vty
, "./global/show-hostname", NB_OP_MODIFY
,
3780 return nb_cli_apply_changes(vty
, NULL
);
3783 void cli_show_router_bgp_show_hostname(struct vty
*vty
, struct lyd_node
*dnode
,
3786 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SHOW_HOSTNAME
)
3787 vty_out(vty
, " bgp default show-hostname\n");
3790 /* Display hostname in certain command outputs */
3791 DEFUN_YANG(bgp_default_show_nexthop_hostname
,
3792 bgp_default_show_nexthop_hostname_cmd
,
3793 "bgp default show-nexthop-hostname",
3794 "BGP specific commands\n"
3795 "Configure BGP defaults\n"
3796 "Show hostname for nexthop in certain command outputs\n")
3798 nb_cli_enqueue_change(vty
, "./global/show-nexthop-hostname",
3799 NB_OP_MODIFY
, "true");
3801 return nb_cli_apply_changes(vty
, NULL
);
3804 DEFUN (no_bgp_default_show_nexthop_hostname
,
3805 no_bgp_default_show_nexthop_hostname_cmd
,
3806 "no bgp default show-nexthop-hostname",
3808 "BGP specific commands\n"
3809 "Configure BGP defaults\n"
3810 "Show hostname for nexthop in certain command outputs\n")
3812 nb_cli_enqueue_change(vty
, "./global/show-nexthop-hostname",
3813 NB_OP_MODIFY
, "false");
3815 return nb_cli_apply_changes(vty
, NULL
);
3818 void cli_show_router_bgp_show_nexthop_hostname(struct vty
*vty
,
3819 struct lyd_node
*dnode
,
3822 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SHOW_HOSTNAME
)
3823 vty_out(vty
, " bgp default show-nexthop-hostname\n");
3826 /* "bgp network import-check" configuration. */
3827 DEFUN_YANG(bgp_network_import_check
,
3828 bgp_network_import_check_cmd
,
3829 "bgp network import-check",
3830 "BGP specific commands\n"
3831 "BGP network command\n"
3832 "Check BGP network route exists in IGP\n")
3834 nb_cli_enqueue_change(vty
, "./global/import-check", NB_OP_MODIFY
,
3837 return nb_cli_apply_changes(vty
, NULL
);
3840 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
3841 "bgp network import-check exact",
3842 "BGP specific commands\n"
3843 "BGP network command\n"
3844 "Check BGP network route exists in IGP\n"
3845 "Match route precisely\n")
3847 DEFUN_YANG(no_bgp_network_import_check
,
3848 no_bgp_network_import_check_cmd
,
3849 "no bgp network import-check",
3851 "BGP specific commands\n"
3852 "BGP network command\n"
3853 "Check BGP network route exists in IGP\n")
3855 nb_cli_enqueue_change(vty
, "./global/import-check", NB_OP_MODIFY
,
3858 return nb_cli_apply_changes(vty
, NULL
);
3861 void cli_show_router_bgp_import_check(struct vty
*vty
, struct lyd_node
*dnode
,
3864 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_IMPORT_CHECK
)
3865 vty_out(vty
, " bgp network import-check\n");
3868 DEFUN_YANG(bgp_default_local_preference
,
3869 bgp_default_local_preference_cmd
,
3870 "bgp default local-preference (0-4294967295)",
3871 "BGP specific commands\n"
3872 "Configure BGP defaults\n"
3873 "local preference (higher=more preferred)\n"
3874 "Configure default local preference value\n")
3878 nb_cli_enqueue_change(vty
, "./global/local-pref", NB_OP_MODIFY
,
3879 argv
[idx_number
]->arg
);
3881 return nb_cli_apply_changes(vty
, NULL
);
3884 DEFUN_YANG(no_bgp_default_local_preference
,
3885 no_bgp_default_local_preference_cmd
,
3886 "no bgp default local-preference [(0-4294967295)]",
3888 "BGP specific commands\n"
3889 "Configure BGP defaults\n"
3890 "local preference (higher=more preferred)\n"
3891 "Configure default local preference value\n")
3893 nb_cli_enqueue_change(vty
, "./global/local-pref", NB_OP_MODIFY
, NULL
);
3895 return nb_cli_apply_changes(vty
, NULL
);
3898 void cli_show_router_bgp_local_pref(struct vty
*vty
, struct lyd_node
*dnode
,
3901 vty_out(vty
, " bgp default local-preference %u\n",
3902 yang_dnode_get_uint32(dnode
, NULL
));
3906 DEFUN_YANG(bgp_default_subgroup_pkt_queue_max
,
3907 bgp_default_subgroup_pkt_queue_max_cmd
,
3908 "bgp default subgroup-pkt-queue-max (20-100)",
3909 "BGP specific commands\n"
3910 "Configure BGP defaults\n"
3911 "subgroup-pkt-queue-max\n"
3912 "Configure subgroup packet queue max\n")
3916 nb_cli_enqueue_change(
3918 "./global/global-update-group-config/subgroup-pkt-queue-size",
3919 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
3921 return nb_cli_apply_changes(vty
, NULL
);
3924 DEFUN_YANG(no_bgp_default_subgroup_pkt_queue_max
,
3925 no_bgp_default_subgroup_pkt_queue_max_cmd
,
3926 "no bgp default subgroup-pkt-queue-max [(20-100)]",
3928 "BGP specific commands\n"
3929 "Configure BGP defaults\n"
3930 "subgroup-pkt-queue-max\n"
3931 "Configure subgroup packet queue max\n")
3933 nb_cli_enqueue_change(
3935 "./global/global-update-group-config/subgroup-pkt-queue-size",
3936 NB_OP_MODIFY
, NULL
);
3938 return nb_cli_apply_changes(vty
, NULL
);
3941 void cli_show_router_global_update_group_config_subgroup_pkt_queue_size(
3942 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
3944 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
3945 yang_dnode_get_uint32(dnode
, NULL
));
3948 DEFUN_YANG(bgp_rr_allow_outbound_policy
,
3949 bgp_rr_allow_outbound_policy_cmd
,
3950 "bgp route-reflector allow-outbound-policy",
3951 "BGP specific commands\n"
3952 "Allow modifications made by out route-map\n"
3953 "on ibgp neighbors\n")
3955 nb_cli_enqueue_change(vty
,
3956 "./global/route-reflector/allow-outbound-policy",
3957 NB_OP_MODIFY
, "true");
3959 return nb_cli_apply_changes(vty
, NULL
);
3962 DEFUN_YANG(no_bgp_rr_allow_outbound_policy
,
3963 no_bgp_rr_allow_outbound_policy_cmd
,
3964 "no bgp route-reflector allow-outbound-policy",
3966 "BGP specific commands\n"
3967 "Allow modifications made by out route-map\n"
3968 "on ibgp neighbors\n")
3970 nb_cli_enqueue_change(vty
,
3971 "./global/route-reflector/allow-outbound-policy",
3972 NB_OP_MODIFY
, "false");
3974 return nb_cli_apply_changes(vty
, NULL
);
3978 void cli_show_router_global_neighbor_config(struct vty
*vty
,
3979 struct lyd_node
*dnode
,
3982 uint32_t write_quanta
, read_quanta
;
3984 if (yang_dnode_get_bool(dnode
, "./log-neighbor-changes"))
3985 vty_out(vty
, " bgp log-neighbor-changes\n");
3987 if (yang_dnode_exists(dnode
, "./dynamic-neighbors-limit")) {
3988 uint32_t listen_limit
= yang_dnode_get_uint32(
3989 dnode
, "./dynamic-neighbors-limit");
3990 vty_out(vty
, " bgp listen limit %u\n", listen_limit
);
3993 write_quanta
= yang_dnode_get_uint32(
3994 dnode
, "./packet-quanta-config/wpkt-quanta");
3995 if (write_quanta
!= BGP_WRITE_PACKET_MAX
)
3996 vty_out(vty
, " write-quanta %d\n", write_quanta
);
3998 read_quanta
= yang_dnode_get_uint32(
3999 dnode
, "./packet-quanta-config/rpkt-quanta");
4001 if (read_quanta
!= BGP_READ_PACKET_MAX
)
4002 vty_out(vty
, " read-quanta %d\n", read_quanta
);
4005 DEFUN_YANG(bgp_listen_limit
,
4006 bgp_listen_limit_cmd
,
4007 "bgp listen limit (1-5000)",
4008 "BGP specific commands\n"
4009 "BGP Dynamic Neighbors listen commands\n"
4010 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4011 "Configure Dynamic Neighbors listen limit value\n")
4015 nb_cli_enqueue_change(
4016 vty
, "./global/global-neighbor-config/dynamic-neighbors-limit",
4017 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
4019 return nb_cli_apply_changes(vty
, NULL
);
4022 DEFUN_YANG(no_bgp_listen_limit
,
4023 no_bgp_listen_limit_cmd
,
4024 "no bgp listen limit [(1-5000)]",
4026 "BGP specific commands\n"
4027 "BGP Dynamic Neighbors listen commands\n"
4028 "Maximum number of BGP Dynamic Neighbors that can be created\n"
4029 "Configure Dynamic Neighbors listen limit value\n")
4031 nb_cli_enqueue_change(
4032 vty
, "./global/global-neighbor-config/dynamic-neighbors-limit",
4033 NB_OP_DESTROY
, NULL
);
4035 return nb_cli_apply_changes(vty
, NULL
);
4040 * Check if this listen range is already configured. Check for exact
4041 * match or overlap based on input.
4043 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
4044 struct prefix
*range
, int exact
)
4046 struct listnode
*node
, *nnode
;
4047 struct listnode
*node1
, *nnode1
;
4048 struct peer_group
*group
;
4053 afi
= family2afi(range
->family
);
4054 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4055 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
4058 match
= prefix_same(range
, lr
);
4060 match
= (prefix_match(range
, lr
)
4061 || prefix_match(lr
, range
));
4070 DEFUN (bgp_listen_range
,
4071 bgp_listen_range_cmd
,
4072 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4073 "BGP specific commands\n"
4074 "Configure BGP dynamic neighbors listen range\n"
4075 "Configure BGP dynamic neighbors listen range\n"
4077 "Member of the peer-group\n"
4078 "Peer-group name\n")
4080 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4081 struct prefix range
;
4082 struct peer_group
*group
, *existing_group
;
4087 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4088 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4089 char *prefix
= argv
[idx
]->arg
;
4090 argv_find(argv
, argc
, "PGNAME", &idx
);
4091 char *peergroup
= argv
[idx
]->arg
;
4093 /* Convert IP prefix string to struct prefix. */
4094 ret
= str2prefix(prefix
, &range
);
4096 vty_out(vty
, "%% Malformed listen range\n");
4097 return CMD_WARNING_CONFIG_FAILED
;
4100 afi
= family2afi(range
.family
);
4102 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4104 "%% Malformed listen range (link-local address)\n");
4105 return CMD_WARNING_CONFIG_FAILED
;
4110 /* Check if same listen range is already configured. */
4111 existing_group
= listen_range_exists(bgp
, &range
, 1);
4112 if (existing_group
) {
4113 if (strcmp(existing_group
->name
, peergroup
) == 0)
4117 "%% Same listen range is attached to peer-group %s\n",
4118 existing_group
->name
);
4119 return CMD_WARNING_CONFIG_FAILED
;
4123 /* Check if an overlapping listen range exists. */
4124 if (listen_range_exists(bgp
, &range
, 0)) {
4126 "%% Listen range overlaps with existing listen range\n");
4127 return CMD_WARNING_CONFIG_FAILED
;
4130 group
= peer_group_lookup(bgp
, peergroup
);
4132 vty_out(vty
, "%% Configure the peer-group first\n");
4133 return CMD_WARNING_CONFIG_FAILED
;
4136 ret
= peer_group_listen_range_add(group
, &range
);
4137 return bgp_vty_return(vty
, ret
);
4140 DEFUN (no_bgp_listen_range
,
4141 no_bgp_listen_range_cmd
,
4142 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
4144 "BGP specific commands\n"
4145 "Unconfigure BGP dynamic neighbors listen range\n"
4146 "Unconfigure BGP dynamic neighbors listen range\n"
4148 "Member of the peer-group\n"
4149 "Peer-group name\n")
4151 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4152 struct prefix range
;
4153 struct peer_group
*group
;
4158 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
4159 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
4160 char *prefix
= argv
[idx
]->arg
;
4161 argv_find(argv
, argc
, "PGNAME", &idx
);
4162 char *peergroup
= argv
[idx
]->arg
;
4164 /* Convert IP prefix string to struct prefix. */
4165 ret
= str2prefix(prefix
, &range
);
4167 vty_out(vty
, "%% Malformed listen range\n");
4168 return CMD_WARNING_CONFIG_FAILED
;
4171 afi
= family2afi(range
.family
);
4173 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
4175 "%% Malformed listen range (link-local address)\n");
4176 return CMD_WARNING_CONFIG_FAILED
;
4181 group
= peer_group_lookup(bgp
, peergroup
);
4183 vty_out(vty
, "%% Peer-group does not exist\n");
4184 return CMD_WARNING_CONFIG_FAILED
;
4187 ret
= peer_group_listen_range_del(group
, &range
);
4188 return bgp_vty_return(vty
, ret
);
4191 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
4193 struct peer_group
*group
;
4194 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
4195 struct prefix
*range
;
4198 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
4199 vty_out(vty
, " bgp listen limit %d\n",
4200 bgp
->dynamic_neighbors_limit
);
4202 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
4203 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
4204 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
4207 " bgp listen range %pFX peer-group %s\n",
4208 range
, group
->name
);
4215 DEFUN_YANG(bgp_disable_connected_route_check
,
4216 bgp_disable_connected_route_check_cmd
,
4217 "bgp disable-ebgp-connected-route-check",
4218 "BGP specific commands\n"
4219 "Disable checking if nexthop is connected on ebgp sessions\n")
4221 nb_cli_enqueue_change(vty
,
4222 "./global/ebgp-multihop-connected-route-check",
4223 NB_OP_MODIFY
, "true");
4225 return nb_cli_apply_changes(vty
, NULL
);
4228 DEFUN_YANG(no_bgp_disable_connected_route_check
,
4229 no_bgp_disable_connected_route_check_cmd
,
4230 "no bgp disable-ebgp-connected-route-check",
4232 "BGP specific commands\n"
4233 "Disable checking if nexthop is connected on ebgp sessions\n")
4235 nb_cli_enqueue_change(vty
,
4236 "./global/ebgp-multihop-connected-route-check",
4237 NB_OP_MODIFY
, "false");
4239 return nb_cli_apply_changes(vty
, NULL
);
4242 void cli_show_router_global_ebgp_multihop_connected_route_check(
4243 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
4245 if (yang_dnode_get_bool(dnode
, NULL
))
4246 vty_out(vty
, " bgp disable-ebgp-connected-route-check\n");
4249 DEFUN_YANG(bgp_default_shutdown
,
4250 bgp_default_shutdown_cmd
,
4251 "[no] bgp default shutdown",
4253 "Configure BGP defaults\n"
4254 "Apply administrative shutdown to newly configured peers\n")
4256 nb_cli_enqueue_change(vty
, "./global/default-shutdown", NB_OP_MODIFY
,
4257 strmatch(argv
[0]->text
, "no") ? "false" : "true");
4259 return nb_cli_apply_changes(vty
, NULL
);
4262 void cli_show_router_bgp_default_shutdown(struct vty
*vty
,
4263 struct lyd_node
*dnode
,
4266 if (yang_dnode_get_bool(dnode
, NULL
))
4267 vty_out(vty
, " bgp default shutdown\n");
4270 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4272 "Administrative shutdown of the BGP instance\n"
4273 "Add a shutdown message (RFC 8203)\n"
4274 "Shutdown message\n")
4276 char *msgstr
= NULL
;
4278 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4281 msgstr
= argv_concat(argv
, argc
, 3);
4283 bgp_shutdown_enable(bgp
, msgstr
);
4284 XFREE(MTYPE_TMP
, msgstr
);
4289 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4290 BGP_STR
"Administrative shutdown of the BGP instance\n")
4292 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4294 bgp_shutdown_enable(bgp
, NULL
);
4299 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4300 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4302 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4304 bgp_shutdown_disable(bgp
);
4309 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4310 "no bgp shutdown message MSG...", NO_STR BGP_STR
4311 "Administrative shutdown of the BGP instance\n"
4312 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4314 DEFUN_YANG(neighbor_remote_as
,
4315 neighbor_remote_as_cmd
,
4316 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4317 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4318 "Specify a BGP neighbor\n" AS_STR
4319 "Internal BGP peer\n"
4320 "External BGP peer\n")
4323 int idx_remote_as
= 3;
4324 char base_xpath
[XPATH_MAXLEN
];
4325 char unnbr_xpath
[XPATH_MAXLEN
];
4326 char prgrp_xpath
[XPATH_MAXLEN
];
4328 const char *as_type_str
= "as-specified";
4330 if (str2sockunion(argv
[idx_peer
]->arg
, &su
) < 0) {
4331 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
4332 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, argv
[idx_peer
]->arg
, "");
4334 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
4335 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
, "");
4337 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4338 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4339 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4340 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
,
4341 "%s%s", VTY_CURR_XPATH
,
4343 snprintf(base_xpath
, sizeof(base_xpath
),
4344 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
,
4348 "%% Create the peer-group or interface first\n");
4349 return CMD_WARNING_CONFIG_FAILED
;
4352 snprintf(base_xpath
, sizeof(base_xpath
),
4353 FRR_BGP_NEIGHBOR_NUM_XPATH
, argv
[idx_peer
]->arg
, "");
4356 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4357 as_type_str
= "internal";
4358 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4359 as_type_str
= "external";
4361 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4362 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4364 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4365 NB_OP_MODIFY
, as_type_str
);
4367 return nb_cli_apply_changes(vty
, base_xpath
);
4370 int peer_conf_interface_create(struct bgp
*bgp
, const char *conf_if
, afi_t afi
,
4371 safi_t safi
, bool v6only
,
4372 const char *peer_group_name
, int as_type
,
4373 as_t as
, char *errmsg
, size_t errmsg_len
)
4376 struct peer_group
*group
;
4379 group
= peer_group_lookup(bgp
, conf_if
);
4382 snprintf(errmsg
, errmsg_len
,
4383 "Name conflict with peer-group \n");
4387 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4389 if (as_type
!= AS_UNSPECIFIED
)
4390 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
4393 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
)
4394 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
4395 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
4396 as_type
, 0, 0, NULL
);
4398 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
4399 as_type
, afi
, safi
, NULL
);
4402 snprintf(errmsg
, errmsg_len
,
4403 "BGP failed to create peer\n");
4408 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4410 /* Request zebra to initiate IPv6 RAs on this interface. We do
4412 * any unnumbered peer in order to not worry about run-time
4414 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4416 * gets deleted later etc.)
4419 bgp_zebra_initiate_radv(bgp
, peer
);
4422 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4423 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4425 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4427 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4429 /* v6only flag changed. Reset bgp seesion */
4430 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4431 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4432 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4433 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4435 bgp_session_reset(peer
);
4438 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4439 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4440 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4441 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4444 if (peer_group_name
) {
4445 group
= peer_group_lookup(bgp
, peer_group_name
);
4447 snprintf(errmsg
, errmsg_len
,
4448 "Configure the peer-group first\n");
4452 ret
= peer_group_bind(bgp
, NULL
, peer
, group
, &as
);
4455 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
4458 DEFUN_YANG(neighbor_interface_config
,
4459 neighbor_interface_config_cmd
,
4460 "neighbor WORD interface [peer-group PGNAME]",
4462 "Interface name or neighbor tag\n"
4463 "Enable BGP on interface\n"
4464 "Member of the peer-group\n"
4465 "Peer-group name\n")
4468 int idx_peer_group_word
= 4;
4469 char base_xpath
[XPATH_MAXLEN
];
4471 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4472 argv
[idx_word
]->arg
, "");
4474 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4475 if (argc
> idx_peer_group_word
)
4476 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_MODIFY
,
4477 argv
[idx_peer_group_word
]->arg
);
4479 return nb_cli_apply_changes(vty
, base_xpath
);
4482 DEFUN_YANG(neighbor_interface_config_v6only
,
4483 neighbor_interface_config_v6only_cmd
,
4484 "neighbor WORD interface v6only [peer-group PGNAME]",
4486 "Interface name or neighbor tag\n"
4487 "Enable BGP on interface\n"
4488 "Enable BGP with v6 link-local only\n"
4489 "Member of the peer-group\n"
4490 "Peer-group name\n")
4493 int idx_peer_group_word
= 5;
4494 char base_xpath
[XPATH_MAXLEN
];
4496 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4497 argv
[idx_word
]->arg
, "");
4499 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4500 if (argc
> idx_peer_group_word
)
4501 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_MODIFY
,
4502 argv
[idx_peer_group_word
]->arg
);
4504 nb_cli_enqueue_change(vty
, "./v6only", NB_OP_MODIFY
, "true");
4506 return nb_cli_apply_changes(vty
, base_xpath
);
4511 neighbor_interface_config_remote_as
,
4512 neighbor_interface_config_remote_as_cmd
,
4513 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4515 "Interface name or neighbor tag\n"
4516 "Enable BGP on interface\n"
4517 "Specify a BGP neighbor\n" AS_STR
4518 "Internal BGP peer\n"
4519 "External BGP peer\n")
4522 int idx_remote_as
= 4;
4523 char base_xpath
[XPATH_MAXLEN
];
4524 const char *as_type_str
= "as-specified";
4526 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4527 argv
[idx_word
]->arg
, "");
4529 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4531 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4532 as_type_str
= "internal";
4533 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4534 as_type_str
= "external";
4536 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4537 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4539 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4540 NB_OP_MODIFY
, as_type_str
);
4542 return nb_cli_apply_changes(vty
, base_xpath
);
4546 neighbor_interface_v6only_config_remote_as
,
4547 neighbor_interface_v6only_config_remote_as_cmd
,
4548 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4550 "Interface name or neighbor tag\n"
4551 "Enable BGP with v6 link-local only\n"
4552 "Enable BGP on interface\n"
4553 "Specify a BGP neighbor\n" AS_STR
4554 "Internal BGP peer\n"
4555 "External BGP peer\n")
4558 int idx_remote_as
= 5;
4559 char base_xpath
[XPATH_MAXLEN
];
4560 const char *as_type_str
= "as-specified";
4562 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4563 argv
[idx_word
]->arg
, "");
4565 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4567 nb_cli_enqueue_change(vty
, "./v6only", NB_OP_MODIFY
, "true");
4569 if (argv
[idx_remote_as
]->arg
[0] == 'i') {
4570 as_type_str
= "internal";
4571 } else if (argv
[idx_remote_as
]->arg
[0] == 'e') {
4572 as_type_str
= "external";
4574 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as",
4575 NB_OP_MODIFY
, argv
[idx_remote_as
]->arg
);
4577 nb_cli_enqueue_change(vty
, "./neighbor-remote-as/remote-as-type",
4578 NB_OP_MODIFY
, as_type_str
);
4580 return nb_cli_apply_changes(vty
, base_xpath
);
4583 DEFUN_YANG(neighbor_peer_group
, neighbor_peer_group_cmd
,
4584 "neighbor WORD peer-group",
4586 "Interface name or neighbor tag\n"
4587 "Configure peer-group\n")
4589 char base_xpath
[XPATH_MAXLEN
];
4592 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4593 argv
[idx_word
]->arg
, "");
4595 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
4597 return nb_cli_apply_changes(vty
, base_xpath
);
4600 DEFUN_YANG(no_neighbor
,
4602 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4605 "Specify a BGP neighbor\n" AS_STR
4606 "Internal BGP peer\n"
4607 "External BGP peer\n")
4610 char base_xpath
[XPATH_MAXLEN
];
4611 char num_xpath
[XPATH_MAXLEN
];
4612 char unnbr_xpath
[XPATH_MAXLEN
];
4613 char prgrp_xpath
[XPATH_MAXLEN
];
4616 if (str2sockunion(argv
[idx_peer
]->arg
, &su
) == 0) {
4617 snprintf(num_xpath
, sizeof(num_xpath
),
4618 FRR_BGP_NEIGHBOR_NUM_XPATH
, argv
[idx_peer
]->arg
, "");
4619 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4620 VTY_CURR_XPATH
, num_xpath
+ 1)) {
4621 strlcpy(base_xpath
, num_xpath
, sizeof(base_xpath
));
4624 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
4625 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, argv
[idx_peer
]->arg
, "");
4627 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
4628 FRR_BGP_PEER_GROUP_XPATH
, argv
[idx_peer
]->arg
, "");
4630 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4631 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4632 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4633 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
,
4634 "%s%s", VTY_CURR_XPATH
,
4636 strlcpy(base_xpath
, prgrp_xpath
, sizeof(base_xpath
));
4639 "%% Create the peer-group or interface first\n");
4640 return CMD_WARNING_CONFIG_FAILED
;
4644 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_DESTROY
, NULL
);
4646 return nb_cli_apply_changes(vty
, NULL
);
4649 DEFUN_YANG(no_neighbor_interface_config
,
4650 no_neighbor_interface_config_cmd
,
4651 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4654 "Configure BGP on interface\n"
4655 "Enable BGP with v6 link-local only\n"
4656 "Member of the peer-group\n"
4658 "Specify a BGP neighbor\n" AS_STR
4659 "Internal BGP peer\n"
4660 "External BGP peer\n")
4663 char base_xpath
[XPATH_MAXLEN
];
4665 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4666 argv
[idx_word
]->arg
, "");
4668 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
4670 return nb_cli_apply_changes(vty
, base_xpath
);
4673 DEFUN_YANG(no_neighbor_peer_group
,
4674 no_neighbor_peer_group_cmd
,
4675 "no neighbor WORD peer-group",
4678 "Configure peer-group\n")
4680 char base_xpath
[XPATH_MAXLEN
];
4683 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_PEER_GROUP_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_interface_peer_group_remote_as
,
4692 no_neighbor_interface_peer_group_remote_as_cmd
,
4693 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4695 "Interface name or neighbor tag\n"
4696 "Specify a BGP neighbor\n" AS_STR
4697 "Internal BGP peer\n"
4698 "External BGP peer\n")
4701 char base_xpath
[XPATH_MAXLEN
];
4702 char unnbr_xpath
[XPATH_MAXLEN
];
4703 char prgrp_xpath
[XPATH_MAXLEN
];
4705 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
), FRR_BGP_NEIGHBOR_UNNUM_XPATH
,
4706 argv
[idx_peer
]->arg
, "");
4708 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
), FRR_BGP_PEER_GROUP_XPATH
,
4709 argv
[idx_peer
]->arg
, "");
4711 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4712 VTY_CURR_XPATH
, unnbr_xpath
+ 1)) {
4713 strlcpy(base_xpath
, unnbr_xpath
, sizeof(base_xpath
));
4714 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
4715 VTY_CURR_XPATH
, prgrp_xpath
+ 1)) {
4716 strlcpy(base_xpath
, prgrp_xpath
, sizeof(base_xpath
));
4718 vty_out(vty
, "%% Create the peer-group or interface first\n");
4719 return CMD_WARNING_CONFIG_FAILED
;
4722 strlcat(base_xpath
, "/neighbor-remote-as/remote-as-type",
4723 sizeof(base_xpath
));
4725 nb_cli_enqueue_change(vty
, base_xpath
, NB_OP_DESTROY
, NULL
);
4727 return nb_cli_apply_changes(vty
, NULL
);
4730 DEFUN_YANG(neighbor_local_as
,
4731 neighbor_local_as_cmd
,
4732 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4733 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4734 "Specify a local-as number\n"
4735 "AS number used as local AS\n")
4739 char base_xpath
[XPATH_MAXLEN
];
4741 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4742 sizeof(base_xpath
), NULL
)
4744 return CMD_WARNING_CONFIG_FAILED
;
4746 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4747 argv
[idx_number
]->arg
);
4749 return nb_cli_apply_changes(vty
, base_xpath
);
4753 neighbor_local_as_no_prepend
, neighbor_local_as_no_prepend_cmd
,
4754 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4755 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4756 "Specify a local-as number\n"
4757 "AS number used as local AS\n"
4758 "Do not prepend local-as to updates from ebgp peers\n")
4762 char base_xpath
[XPATH_MAXLEN
];
4764 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4765 sizeof(base_xpath
), NULL
)
4767 return CMD_WARNING_CONFIG_FAILED
;
4769 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4770 argv
[idx_number
]->arg
);
4771 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4774 return nb_cli_apply_changes(vty
, base_xpath
);
4778 neighbor_local_as_no_prepend_replace_as
,
4779 neighbor_local_as_no_prepend_replace_as_cmd
,
4780 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4781 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4782 "Specify a local-as number\n"
4783 "AS number used as local AS\n"
4784 "Do not prepend local-as to updates from ebgp peers\n"
4785 "Do not prepend local-as to updates from ibgp peers\n")
4789 char base_xpath
[XPATH_MAXLEN
];
4791 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4792 sizeof(base_xpath
), NULL
)
4794 return CMD_WARNING_CONFIG_FAILED
;
4796 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_MODIFY
,
4797 argv
[idx_number
]->arg
);
4798 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4800 nb_cli_enqueue_change(vty
, "./local-as/no-replace-as", NB_OP_MODIFY
,
4803 return nb_cli_apply_changes(vty
, base_xpath
);
4806 DEFUN_YANG(no_neighbor_local_as
,
4807 no_neighbor_local_as_cmd
,
4808 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4809 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4810 "Specify a local-as number\n"
4811 "AS number used as local AS\n"
4812 "Do not prepend local-as to updates from ebgp peers\n"
4813 "Do not prepend local-as to updates from ibgp peers\n")
4816 char base_xpath
[XPATH_MAXLEN
];
4818 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4819 sizeof(base_xpath
), NULL
)
4821 return CMD_WARNING_CONFIG_FAILED
;
4823 nb_cli_enqueue_change(vty
, "./local-as/local-as", NB_OP_DESTROY
, NULL
);
4824 nb_cli_enqueue_change(vty
, "./local-as/no-prepend", NB_OP_MODIFY
,
4826 nb_cli_enqueue_change(vty
, "./local-as/no-replace-as", NB_OP_MODIFY
,
4829 return nb_cli_apply_changes(vty
, base_xpath
);
4833 DEFUN (neighbor_solo
,
4835 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4838 "Solo peer - part of its own update group\n")
4844 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4846 return CMD_WARNING_CONFIG_FAILED
;
4848 ret
= update_group_adjust_soloness(peer
, 1);
4849 return bgp_vty_return(vty
, ret
);
4852 DEFUN (no_neighbor_solo
,
4853 no_neighbor_solo_cmd
,
4854 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4858 "Solo peer - part of its own update group\n")
4864 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4866 return CMD_WARNING_CONFIG_FAILED
;
4868 ret
= update_group_adjust_soloness(peer
, 0);
4869 return bgp_vty_return(vty
, ret
);
4872 DEFUN_YANG(neighbor_password
,
4873 neighbor_password_cmd
,
4874 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
4875 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4881 char base_xpath
[XPATH_MAXLEN
];
4883 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4884 sizeof(base_xpath
), NULL
)
4886 return CMD_WARNING_CONFIG_FAILED
;
4888 nb_cli_enqueue_change(vty
, "./password", NB_OP_MODIFY
,
4889 argv
[idx_line
]->arg
);
4891 return nb_cli_apply_changes(vty
, base_xpath
);
4894 DEFUN_YANG(no_neighbor_password
,
4895 no_neighbor_password_cmd
,
4896 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
4897 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4902 char base_xpath
[XPATH_MAXLEN
];
4904 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4905 sizeof(base_xpath
), NULL
)
4907 return CMD_WARNING_CONFIG_FAILED
;
4909 nb_cli_enqueue_change(vty
, "./password", NB_OP_DESTROY
, NULL
);
4911 return nb_cli_apply_changes(vty
, base_xpath
);
4914 DEFUN_YANG(neighbor_activate
,
4915 neighbor_activate_cmd
,
4916 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4917 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4918 "Enable the Address Family for this Neighbor\n")
4921 char base_xpath
[XPATH_MAXLEN
];
4922 char af_xpath
[XPATH_MAXLEN
];
4923 afi_t afi
= bgp_node_afi(vty
);
4924 safi_t safi
= bgp_node_safi(vty
);
4926 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
4927 yang_afi_safi_value2identity(afi
, safi
));
4928 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4929 sizeof(base_xpath
), af_xpath
)
4931 return CMD_WARNING_CONFIG_FAILED
;
4933 nb_cli_enqueue_change(vty
, "./enabled", NB_OP_MODIFY
, "true");
4935 return nb_cli_apply_changes(vty
, base_xpath
);
4938 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
4939 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4940 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4941 "Enable the Address Family for this Neighbor\n")
4943 DEFUN_YANG(no_neighbor_activate
,
4944 no_neighbor_activate_cmd
,
4945 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4948 "Enable the Address Family for this Neighbor\n")
4951 char base_xpath
[XPATH_MAXLEN
];
4952 char af_xpath
[XPATH_MAXLEN
];
4953 afi_t afi
= bgp_node_afi(vty
);
4954 safi_t safi
= bgp_node_safi(vty
);
4956 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
4957 yang_afi_safi_value2identity(afi
, safi
));
4959 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
4960 sizeof(base_xpath
), af_xpath
)
4962 return CMD_WARNING_CONFIG_FAILED
;
4964 nb_cli_enqueue_change(vty
, "./enabled", NB_OP_MODIFY
, "false");
4966 return nb_cli_apply_changes(vty
, base_xpath
);
4969 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
4970 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4971 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4972 "Enable the Address Family for this Neighbor\n")
4974 DEFUN (neighbor_set_peer_group
,
4975 neighbor_set_peer_group_cmd
,
4976 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4979 "Member of the peer-group\n"
4980 "Peer-group name\n")
4982 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4989 struct peer_group
*group
;
4991 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4993 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4995 vty_out(vty
, "%% Malformed address or name: %s\n",
4996 argv
[idx_peer
]->arg
);
4997 return CMD_WARNING_CONFIG_FAILED
;
5000 if (peer_address_self_check(bgp
, &su
)) {
5002 "%% Can not configure the local system as neighbor\n");
5003 return CMD_WARNING_CONFIG_FAILED
;
5006 /* Disallow for dynamic neighbor. */
5007 peer
= peer_lookup(bgp
, &su
);
5008 if (peer
&& peer_dynamic_neighbor(peer
)) {
5010 "%% Operation not allowed on a dynamic neighbor\n");
5011 return CMD_WARNING_CONFIG_FAILED
;
5015 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
5017 vty_out(vty
, "%% Configure the peer-group first\n");
5018 return CMD_WARNING_CONFIG_FAILED
;
5021 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
5023 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
5025 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
5027 return CMD_WARNING_CONFIG_FAILED
;
5030 return bgp_vty_return(vty
, ret
);
5033 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
5034 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
5035 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5036 "Member of the peer-group\n"
5037 "Peer-group name\n")
5039 DEFUN_YANG (no_neighbor_set_peer_group
,
5040 no_neighbor_set_peer_group_cmd
,
5041 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group [PGNAME]",
5045 "Member of the peer-group\n"
5046 "Peer-group name\n")
5049 char base_xpath
[XPATH_MAXLEN
];
5051 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5052 sizeof(base_xpath
), NULL
)
5054 return CMD_WARNING_CONFIG_FAILED
;
5056 nb_cli_enqueue_change(vty
, "./peer-group", NB_OP_DESTROY
, NULL
);
5058 return nb_cli_apply_changes(vty
, base_xpath
);
5061 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
5062 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group [PGNAME]",
5063 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5064 "Member of the peer-group\n"
5065 "Peer-group name\n")
5067 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
5068 uint32_t flag
, int set
)
5073 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5075 return CMD_WARNING_CONFIG_FAILED
;
5078 * If 'neighbor <interface>', then this is for directly connected peers,
5079 * we should not accept disable-connected-check.
5081 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5083 "%s is directly connected peer, cannot accept disable-connected-check\n",
5085 return CMD_WARNING_CONFIG_FAILED
;
5088 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5089 peer_tx_shutdown_message_unset(peer
);
5092 ret
= peer_flag_set(peer
, flag
);
5094 ret
= peer_flag_unset(peer
, flag
);
5096 return bgp_vty_return(vty
, ret
);
5099 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
5101 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
5104 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
5107 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
5110 int peer_flag_modify_nb(struct bgp
*bgp
, const char *ip_str
, struct peer
*peer
,
5111 uint32_t flag
, bool set
, char *errmsg
,
5117 * If 'neighbor <interface>', then this is for directly connected peers,
5118 * we should not accept disable-connected-check.
5120 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
5123 "%s is directly connected peer, cannot accept disable-connected-check\n",
5128 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
5129 peer_tx_shutdown_message_unset(peer
);
5132 ret
= peer_flag_set(peer
, flag
);
5134 ret
= peer_flag_unset(peer
, flag
);
5136 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
5139 /* neighbor passive. */
5140 DEFUN_YANG(neighbor_passive
,
5141 neighbor_passive_cmd
,
5142 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5145 "Don't send open messages to this neighbor\n")
5148 char base_xpath
[XPATH_MAXLEN
];
5150 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5151 sizeof(base_xpath
), NULL
)
5153 return CMD_WARNING_CONFIG_FAILED
;
5155 nb_cli_enqueue_change(vty
, "./passive-mode", NB_OP_MODIFY
, "true");
5157 return nb_cli_apply_changes(vty
, base_xpath
);
5160 DEFUN_YANG(no_neighbor_passive
,
5161 no_neighbor_passive_cmd
,
5162 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
5165 "Don't send open messages to this neighbor\n")
5168 char base_xpath
[XPATH_MAXLEN
];
5170 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5171 sizeof(base_xpath
), NULL
)
5173 return CMD_WARNING_CONFIG_FAILED
;
5175 nb_cli_enqueue_change(vty
, "./passive-mode", NB_OP_MODIFY
, "false");
5177 return nb_cli_apply_changes(vty
, base_xpath
);
5180 /* neighbor shutdown. */
5181 DEFUN_YANG(neighbor_shutdown_msg
,
5182 neighbor_shutdown_msg_cmd
,
5183 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5184 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5185 "Administratively shut down this neighbor\n"
5186 "Add a shutdown message (RFC 8203)\n"
5187 "Shutdown message\n")
5190 char base_xpath
[XPATH_MAXLEN
];
5192 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5193 sizeof(base_xpath
), NULL
)
5195 return CMD_WARNING_CONFIG_FAILED
;
5200 message
= argv_concat(argv
, argc
, 4);
5201 nb_cli_enqueue_change(vty
, "./admin-shutdown/message",
5202 NB_OP_MODIFY
, message
);
5205 nb_cli_enqueue_change(vty
, "./admin-shutdown/enable", NB_OP_MODIFY
,
5208 return nb_cli_apply_changes(vty
, base_xpath
);
5211 ALIAS_YANG(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
5212 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5213 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5214 "Administratively shut down this neighbor\n")
5216 DEFUN_YANG(no_neighbor_shutdown_msg
,
5217 no_neighbor_shutdown_msg_cmd
,
5218 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
5221 "Administratively shut down this neighbor\n"
5222 "Remove a shutdown message (RFC 8203)\n"
5223 "Shutdown message\n")
5226 char base_xpath
[XPATH_MAXLEN
];
5228 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5229 sizeof(base_xpath
), NULL
)
5231 return CMD_WARNING_CONFIG_FAILED
;
5233 nb_cli_enqueue_change(vty
, "./admin-shutdown/enable", NB_OP_MODIFY
,
5236 return nb_cli_apply_changes(vty
, base_xpath
);
5239 ALIAS_YANG(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
5240 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
5241 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5242 "Administratively shut down this neighbor\n")
5244 DEFUN(neighbor_shutdown_rtt
,
5245 neighbor_shutdown_rtt_cmd
,
5246 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
5249 "Administratively shut down this neighbor\n"
5250 "Shutdown if round-trip-time is higher than expected\n"
5251 "Round-trip-time in milliseconds\n"
5252 "Specify the number of keepalives before shutdown\n"
5253 "The number of keepalives with higher RTT to shutdown\n")
5260 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5263 return CMD_WARNING_CONFIG_FAILED
;
5265 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
5267 if (argv_find(argv
, argc
, "count", &idx_count
))
5268 peer
->rtt_keepalive_conf
=
5269 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
5271 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5272 PEER_FLAG_RTT_SHUTDOWN
);
5275 DEFUN(no_neighbor_shutdown_rtt
,
5276 no_neighbor_shutdown_rtt_cmd
,
5277 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
5281 "Administratively shut down this neighbor\n"
5282 "Shutdown if round-trip-time is higher than expected\n"
5283 "Round-trip-time in milliseconds\n"
5284 "Specify the number of keepalives before shutdown\n"
5285 "The number of keepalives with higher RTT to shutdown\n")
5290 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5293 return CMD_WARNING_CONFIG_FAILED
;
5295 peer
->rtt_expected
= 0;
5296 peer
->rtt_keepalive_conf
= 1;
5298 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5299 PEER_FLAG_RTT_SHUTDOWN
);
5302 /* neighbor capability dynamic. */
5303 DEFUN_YANG (neighbor_capability_dynamic
,
5304 neighbor_capability_dynamic_cmd
,
5305 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5308 "Advertise capability to the peer\n"
5309 "Advertise dynamic capability to this neighbor\n")
5312 char base_xpath
[XPATH_MAXLEN
];
5314 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5315 sizeof(base_xpath
), NULL
)
5317 return CMD_WARNING_CONFIG_FAILED
;
5319 nb_cli_enqueue_change(vty
, "./capability-options/dynamic-capability",
5320 NB_OP_MODIFY
, "true");
5322 return nb_cli_apply_changes(vty
, base_xpath
);
5325 DEFUN_YANG (no_neighbor_capability_dynamic
,
5326 no_neighbor_capability_dynamic_cmd
,
5327 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
5331 "Advertise capability to the peer\n"
5332 "Advertise dynamic capability to this neighbor\n")
5335 char base_xpath
[XPATH_MAXLEN
];
5337 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5338 sizeof(base_xpath
), NULL
)
5340 return CMD_WARNING_CONFIG_FAILED
;
5342 nb_cli_enqueue_change(vty
, "./capability-options/dynamic-capability",
5343 NB_OP_MODIFY
, "false");
5345 return nb_cli_apply_changes(vty
, base_xpath
);
5348 /* neighbor dont-capability-negotiate */
5349 DEFUN (neighbor_dont_capability_negotiate
,
5350 neighbor_dont_capability_negotiate_cmd
,
5351 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5354 "Do not perform capability negotiation\n")
5357 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5358 PEER_FLAG_DONT_CAPABILITY
);
5361 DEFUN (no_neighbor_dont_capability_negotiate
,
5362 no_neighbor_dont_capability_negotiate_cmd
,
5363 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5367 "Do not perform capability negotiation\n")
5370 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5371 PEER_FLAG_DONT_CAPABILITY
);
5374 /* neighbor capability extended next hop encoding */
5375 DEFUN_YANG (neighbor_capability_enhe
,
5376 neighbor_capability_enhe_cmd
,
5377 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5380 "Advertise capability to the peer\n"
5381 "Advertise extended next-hop capability to the peer\n")
5384 char base_xpath
[XPATH_MAXLEN
];
5386 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5387 sizeof(base_xpath
), NULL
)
5389 return CMD_WARNING_CONFIG_FAILED
;
5391 nb_cli_enqueue_change(
5392 vty
, "./capability-options/extended-nexthop-capability",
5393 NB_OP_MODIFY
, "true");
5395 return nb_cli_apply_changes(vty
, base_xpath
);
5398 DEFUN_YANG (no_neighbor_capability_enhe
,
5399 no_neighbor_capability_enhe_cmd
,
5400 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5404 "Advertise capability to the peer\n"
5405 "Advertise extended next-hop capability to the peer\n")
5408 char base_xpath
[XPATH_MAXLEN
];
5410 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5411 sizeof(base_xpath
), NULL
)
5413 return CMD_WARNING_CONFIG_FAILED
;
5415 nb_cli_enqueue_change(
5416 vty
, "./capability-options/extended-nexthop-capability",
5417 NB_OP_MODIFY
, "false");
5419 return nb_cli_apply_changes(vty
, base_xpath
);
5422 int peer_af_flag_modify_nb(struct peer
*peer
, afi_t afi
, safi_t safi
,
5423 uint32_t flag
, int set
, char *errmsg
,
5429 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5431 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5433 return bgp_nb_errmsg_return(errmsg
, errmsg_len
, ret
);
5436 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5437 afi_t afi
, safi_t safi
, uint32_t flag
,
5443 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5445 return CMD_WARNING_CONFIG_FAILED
;
5448 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5450 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5452 return bgp_vty_return(vty
, ret
);
5455 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5456 afi_t afi
, safi_t safi
, uint32_t flag
)
5458 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5461 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5462 afi_t afi
, safi_t safi
, uint32_t flag
)
5464 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5467 /* neighbor capability orf prefix-list. */
5468 DEFUN (neighbor_capability_orf_prefix
,
5469 neighbor_capability_orf_prefix_cmd
,
5470 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5473 "Advertise capability to the peer\n"
5474 "Advertise ORF capability to the peer\n"
5475 "Advertise prefixlist ORF capability to this neighbor\n"
5476 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5477 "Capability to RECEIVE the ORF from this neighbor\n"
5478 "Capability to SEND the ORF to this neighbor\n")
5480 int idx_send_recv
= 5;
5481 char *peer_str
= argv
[1]->arg
;
5483 afi_t afi
= bgp_node_afi(vty
);
5484 safi_t safi
= bgp_node_safi(vty
);
5486 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5488 return CMD_WARNING_CONFIG_FAILED
;
5490 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5491 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5492 PEER_FLAG_ORF_PREFIX_SM
);
5494 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5495 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5496 PEER_FLAG_ORF_PREFIX_RM
);
5498 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5499 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5500 PEER_FLAG_ORF_PREFIX_SM
)
5501 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5502 PEER_FLAG_ORF_PREFIX_RM
);
5504 return CMD_WARNING_CONFIG_FAILED
;
5508 neighbor_capability_orf_prefix
,
5509 neighbor_capability_orf_prefix_hidden_cmd
,
5510 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5511 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5512 "Advertise capability to the peer\n"
5513 "Advertise ORF capability to the peer\n"
5514 "Advertise prefixlist ORF capability to this neighbor\n"
5515 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5516 "Capability to RECEIVE the ORF from this neighbor\n"
5517 "Capability to SEND the ORF to this neighbor\n")
5519 DEFUN (no_neighbor_capability_orf_prefix
,
5520 no_neighbor_capability_orf_prefix_cmd
,
5521 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5525 "Advertise capability to the peer\n"
5526 "Advertise ORF capability to the peer\n"
5527 "Advertise prefixlist ORF capability to this neighbor\n"
5528 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5529 "Capability to RECEIVE the ORF from this neighbor\n"
5530 "Capability to SEND the ORF to this neighbor\n")
5532 int idx_send_recv
= 6;
5533 char *peer_str
= argv
[2]->arg
;
5535 afi_t afi
= bgp_node_afi(vty
);
5536 safi_t safi
= bgp_node_safi(vty
);
5538 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5540 return CMD_WARNING_CONFIG_FAILED
;
5542 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5543 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5544 PEER_FLAG_ORF_PREFIX_SM
);
5546 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5547 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5548 PEER_FLAG_ORF_PREFIX_RM
);
5550 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5551 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5552 PEER_FLAG_ORF_PREFIX_SM
)
5553 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5554 PEER_FLAG_ORF_PREFIX_RM
);
5556 return CMD_WARNING_CONFIG_FAILED
;
5560 no_neighbor_capability_orf_prefix
,
5561 no_neighbor_capability_orf_prefix_hidden_cmd
,
5562 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5563 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5564 "Advertise capability to the peer\n"
5565 "Advertise ORF capability to the peer\n"
5566 "Advertise prefixlist ORF capability to this neighbor\n"
5567 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5568 "Capability to RECEIVE the ORF from this neighbor\n"
5569 "Capability to SEND the ORF to this neighbor\n")
5571 /* neighbor next-hop-self. */
5572 DEFUN_YANG (neighbor_nexthop_self
,
5573 neighbor_nexthop_self_cmd
,
5574 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5577 "Disable the next hop calculation for this neighbor\n")
5580 char base_xpath
[XPATH_MAXLEN
];
5581 char af_xpath
[XPATH_MAXLEN
];
5582 char attr_xpath
[XPATH_MAXLEN
];
5583 afi_t afi
= bgp_node_afi(vty
);
5584 safi_t safi
= bgp_node_safi(vty
);
5586 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5587 yang_afi_safi_value2identity(afi
, safi
));
5589 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5590 sizeof(base_xpath
), af_xpath
)
5592 return CMD_WARNING_CONFIG_FAILED
;
5594 snprintf(attr_xpath
, sizeof(attr_xpath
),
5595 "./%s/nexthop-self/next-hop-self",
5596 bgp_afi_safi_get_container_str(afi
, safi
));
5598 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5600 return nb_cli_apply_changes(vty
, base_xpath
);
5603 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5604 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5605 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5606 "Disable the next hop calculation for this neighbor\n")
5608 /* neighbor next-hop-self. */
5609 DEFUN_YANG(neighbor_nexthop_self_force
,
5610 neighbor_nexthop_self_force_cmd
,
5611 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5614 "Disable the next hop calculation for this neighbor\n"
5615 "Set the next hop to self for reflected routes\n")
5618 char base_xpath
[XPATH_MAXLEN
];
5619 char af_xpath
[XPATH_MAXLEN
];
5620 char attr_xpath
[XPATH_MAXLEN
];
5621 afi_t afi
= bgp_node_afi(vty
);
5622 safi_t safi
= bgp_node_safi(vty
);
5624 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5625 yang_afi_safi_value2identity(afi
, safi
));
5627 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5628 sizeof(base_xpath
), af_xpath
)
5630 return CMD_WARNING_CONFIG_FAILED
;
5632 snprintf(attr_xpath
, sizeof(attr_xpath
),
5633 "./%s/nexthop-self/next-hop-self-force",
5634 bgp_afi_safi_get_container_str(afi
, safi
));
5636 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5638 return nb_cli_apply_changes(vty
, base_xpath
);
5641 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5642 neighbor_nexthop_self_force_hidden_cmd
,
5643 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5644 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5645 "Disable the next hop calculation for this neighbor\n"
5646 "Set the next hop to self for reflected routes\n")
5648 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5649 neighbor_nexthop_self_all_hidden_cmd
,
5650 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5651 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5652 "Disable the next hop calculation for this neighbor\n"
5653 "Set the next hop to self for reflected routes\n")
5655 DEFUN_YANG (no_neighbor_nexthop_self
,
5656 no_neighbor_nexthop_self_cmd
,
5657 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5661 "Disable the next hop calculation for this neighbor\n")
5664 char base_xpath
[XPATH_MAXLEN
];
5665 char af_xpath
[XPATH_MAXLEN
];
5666 char attr_xpath
[XPATH_MAXLEN
];
5667 afi_t afi
= bgp_node_afi(vty
);
5668 safi_t safi
= bgp_node_safi(vty
);
5670 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5671 yang_afi_safi_value2identity(afi
, safi
));
5673 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5674 sizeof(base_xpath
), af_xpath
)
5676 return CMD_WARNING_CONFIG_FAILED
;
5678 snprintf(attr_xpath
, sizeof(attr_xpath
),
5679 "./%s/nexthop-self/next-hop-self",
5680 bgp_afi_safi_get_container_str(afi
, safi
));
5682 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5684 return nb_cli_apply_changes(vty
, base_xpath
);
5687 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5688 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5689 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5690 "Disable the next hop calculation for this neighbor\n")
5692 DEFUN_YANG (no_neighbor_nexthop_self_force
,
5693 no_neighbor_nexthop_self_force_cmd
,
5694 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5698 "Disable the next hop calculation for this neighbor\n"
5699 "Set the next hop to self for reflected routes\n")
5702 char base_xpath
[XPATH_MAXLEN
];
5703 char af_xpath
[XPATH_MAXLEN
];
5704 char attr_xpath
[XPATH_MAXLEN
];
5705 afi_t afi
= bgp_node_afi(vty
);
5706 safi_t safi
= bgp_node_safi(vty
);
5708 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5709 yang_afi_safi_value2identity(afi
, safi
));
5711 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5712 sizeof(base_xpath
), af_xpath
)
5714 return CMD_WARNING_CONFIG_FAILED
;
5716 snprintf(attr_xpath
, sizeof(attr_xpath
),
5717 "./%s/nexthop-self/next-hop-self-force",
5718 bgp_afi_safi_get_container_str(afi
, safi
));
5720 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5722 return nb_cli_apply_changes(vty
, base_xpath
);
5725 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5726 no_neighbor_nexthop_self_force_hidden_cmd
,
5727 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5728 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5729 "Disable the next hop calculation for this neighbor\n"
5730 "Set the next hop to self for reflected routes\n")
5732 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5733 no_neighbor_nexthop_self_all_hidden_cmd
,
5734 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5735 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5736 "Disable the next hop calculation for this neighbor\n"
5737 "Set the next hop to self for reflected routes\n")
5739 /* neighbor as-override */
5740 DEFUN_YANG (neighbor_as_override
,
5741 neighbor_as_override_cmd
,
5742 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5745 "Override ASNs in outbound updates if aspath equals remote-as\n")
5748 char base_xpath
[XPATH_MAXLEN
];
5749 char af_xpath
[XPATH_MAXLEN
];
5750 char attr_xpath
[XPATH_MAXLEN
];
5751 afi_t afi
= bgp_node_afi(vty
);
5752 safi_t safi
= bgp_node_safi(vty
);
5754 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5755 yang_afi_safi_value2identity(afi
, safi
));
5757 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5758 sizeof(base_xpath
), af_xpath
)
5760 return CMD_WARNING_CONFIG_FAILED
;
5762 snprintf(attr_xpath
, sizeof(attr_xpath
),
5763 "./%s/as-path-options/replace-peer-as",
5764 bgp_afi_safi_get_container_str(afi
, safi
));
5766 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5768 return nb_cli_apply_changes(vty
, base_xpath
);
5771 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5772 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5773 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5774 "Override ASNs in outbound updates if aspath equals remote-as\n")
5776 DEFUN_YANG (no_neighbor_as_override
,
5777 no_neighbor_as_override_cmd
,
5778 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5782 "Override ASNs in outbound updates if aspath equals remote-as\n")
5785 char base_xpath
[XPATH_MAXLEN
];
5786 char af_xpath
[XPATH_MAXLEN
];
5787 char attr_xpath
[XPATH_MAXLEN
];
5788 afi_t afi
= bgp_node_afi(vty
);
5789 safi_t safi
= bgp_node_safi(vty
);
5791 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5792 yang_afi_safi_value2identity(afi
, safi
));
5794 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5795 sizeof(base_xpath
), af_xpath
)
5797 return CMD_WARNING_CONFIG_FAILED
;
5799 snprintf(attr_xpath
, sizeof(attr_xpath
),
5800 "./%s/as-path-options/replace-peer-as",
5801 bgp_afi_safi_get_container_str(afi
, safi
));
5803 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5805 return nb_cli_apply_changes(vty
, base_xpath
);
5808 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5809 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5810 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5811 "Override ASNs in outbound updates if aspath equals remote-as\n")
5813 /* neighbor remove-private-AS. */
5814 DEFUN_YANG (neighbor_remove_private_as
,
5815 neighbor_remove_private_as_cmd
,
5816 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5819 "Remove private ASNs in outbound updates\n")
5822 char base_xpath
[XPATH_MAXLEN
];
5823 char af_xpath
[XPATH_MAXLEN
];
5824 char attr_xpath
[XPATH_MAXLEN
];
5825 afi_t afi
= bgp_node_afi(vty
);
5826 safi_t safi
= bgp_node_safi(vty
);
5828 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5829 yang_afi_safi_value2identity(afi
, safi
));
5831 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5832 sizeof(base_xpath
), af_xpath
)
5834 return CMD_WARNING_CONFIG_FAILED
;
5836 snprintf(attr_xpath
, sizeof(attr_xpath
),
5837 "./%s/private-as/remove-private-as",
5838 bgp_afi_safi_get_container_str(afi
, safi
));
5840 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5842 return nb_cli_apply_changes(vty
, base_xpath
);
5845 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5846 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5847 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5848 "Remove private ASNs in outbound updates\n")
5850 DEFUN_YANG (neighbor_remove_private_as_all
,
5851 neighbor_remove_private_as_all_cmd
,
5852 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5855 "Remove private ASNs in outbound updates\n"
5856 "Apply to all AS numbers\n")
5859 char base_xpath
[XPATH_MAXLEN
];
5860 char af_xpath
[XPATH_MAXLEN
];
5861 char attr_xpath
[XPATH_MAXLEN
];
5862 afi_t afi
= bgp_node_afi(vty
);
5863 safi_t safi
= bgp_node_safi(vty
);
5865 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5866 yang_afi_safi_value2identity(afi
, safi
));
5868 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5869 sizeof(base_xpath
), af_xpath
)
5871 return CMD_WARNING_CONFIG_FAILED
;
5873 snprintf(attr_xpath
, sizeof(attr_xpath
),
5874 "./%s/private-as/remove-private-as-all",
5875 bgp_afi_safi_get_container_str(afi
, safi
));
5877 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5879 return nb_cli_apply_changes(vty
, base_xpath
);
5882 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5883 neighbor_remove_private_as_all_hidden_cmd
,
5884 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5885 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5886 "Remove private ASNs in outbound updates\n"
5887 "Apply to all AS numbers")
5889 DEFUN_YANG (neighbor_remove_private_as_replace_as
,
5890 neighbor_remove_private_as_replace_as_cmd
,
5891 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5894 "Remove private ASNs in outbound updates\n"
5895 "Replace private ASNs with our ASN in outbound updates\n")
5898 char base_xpath
[XPATH_MAXLEN
];
5899 char af_xpath
[XPATH_MAXLEN
];
5900 char attr_xpath
[XPATH_MAXLEN
];
5901 afi_t afi
= bgp_node_afi(vty
);
5902 safi_t safi
= bgp_node_safi(vty
);
5904 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5905 yang_afi_safi_value2identity(afi
, safi
));
5907 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5908 sizeof(base_xpath
), af_xpath
)
5910 return CMD_WARNING_CONFIG_FAILED
;
5912 snprintf(attr_xpath
, sizeof(attr_xpath
),
5913 "./%s/private-as/remove-private-as-replace",
5914 bgp_afi_safi_get_container_str(afi
, safi
));
5916 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5918 return nb_cli_apply_changes(vty
, base_xpath
);
5921 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5922 neighbor_remove_private_as_replace_as_hidden_cmd
,
5923 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5924 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5925 "Remove private ASNs in outbound updates\n"
5926 "Replace private ASNs with our ASN in outbound updates\n")
5928 DEFUN_YANG (neighbor_remove_private_as_all_replace_as
,
5929 neighbor_remove_private_as_all_replace_as_cmd
,
5930 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5933 "Remove private ASNs in outbound updates\n"
5934 "Apply to all AS numbers\n"
5935 "Replace private ASNs with our ASN in outbound updates\n")
5938 char base_xpath
[XPATH_MAXLEN
];
5939 char af_xpath
[XPATH_MAXLEN
];
5940 char attr_xpath
[XPATH_MAXLEN
];
5941 afi_t afi
= bgp_node_afi(vty
);
5942 safi_t safi
= bgp_node_safi(vty
);
5944 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5945 yang_afi_safi_value2identity(afi
, safi
));
5947 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5948 sizeof(base_xpath
), af_xpath
)
5950 return CMD_WARNING_CONFIG_FAILED
;
5952 snprintf(attr_xpath
, sizeof(attr_xpath
),
5953 "./%s/private-as/remove-private-as-all-replace",
5954 bgp_afi_safi_get_container_str(afi
, safi
));
5956 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
5958 return nb_cli_apply_changes(vty
, base_xpath
);
5962 neighbor_remove_private_as_all_replace_as
,
5963 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5964 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5965 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5966 "Remove private ASNs in outbound updates\n"
5967 "Apply to all AS numbers\n"
5968 "Replace private ASNs with our ASN in outbound updates\n")
5970 DEFUN_YANG (no_neighbor_remove_private_as
,
5971 no_neighbor_remove_private_as_cmd
,
5972 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5976 "Remove private ASNs in outbound updates\n")
5979 char base_xpath
[XPATH_MAXLEN
];
5980 char af_xpath
[XPATH_MAXLEN
];
5981 char attr_xpath
[XPATH_MAXLEN
];
5982 afi_t afi
= bgp_node_afi(vty
);
5983 safi_t safi
= bgp_node_safi(vty
);
5985 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
5986 yang_afi_safi_value2identity(afi
, safi
));
5988 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
5989 sizeof(base_xpath
), af_xpath
)
5991 return CMD_WARNING_CONFIG_FAILED
;
5993 snprintf(attr_xpath
, sizeof(attr_xpath
),
5994 "./%s/private-as/remove-private-as",
5995 bgp_afi_safi_get_container_str(afi
, safi
));
5997 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
5999 return nb_cli_apply_changes(vty
, base_xpath
);
6002 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
6003 no_neighbor_remove_private_as_hidden_cmd
,
6004 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
6005 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6006 "Remove private ASNs in outbound updates\n")
6008 DEFUN_YANG (no_neighbor_remove_private_as_all
,
6009 no_neighbor_remove_private_as_all_cmd
,
6010 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
6014 "Remove private ASNs in outbound updates\n"
6015 "Apply to all AS numbers\n")
6018 char base_xpath
[XPATH_MAXLEN
];
6019 char af_xpath
[XPATH_MAXLEN
];
6020 char attr_xpath
[XPATH_MAXLEN
];
6021 afi_t afi
= bgp_node_afi(vty
);
6022 safi_t safi
= bgp_node_safi(vty
);
6024 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6025 yang_afi_safi_value2identity(afi
, safi
));
6027 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6028 sizeof(base_xpath
), af_xpath
)
6030 return CMD_WARNING_CONFIG_FAILED
;
6032 snprintf(attr_xpath
, sizeof(attr_xpath
),
6033 "./%s/private-as/remove-private-as-all",
6034 bgp_afi_safi_get_container_str(afi
, safi
));
6036 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6038 return nb_cli_apply_changes(vty
, base_xpath
);
6041 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
6042 no_neighbor_remove_private_as_all_hidden_cmd
,
6043 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
6044 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6045 "Remove private ASNs in outbound updates\n"
6046 "Apply to all AS numbers\n")
6048 DEFUN_YANG (no_neighbor_remove_private_as_replace_as
,
6049 no_neighbor_remove_private_as_replace_as_cmd
,
6050 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
6054 "Remove private ASNs in outbound updates\n"
6055 "Replace private ASNs with our ASN in outbound updates\n")
6058 char base_xpath
[XPATH_MAXLEN
];
6059 char af_xpath
[XPATH_MAXLEN
];
6060 char attr_xpath
[XPATH_MAXLEN
];
6061 afi_t afi
= bgp_node_afi(vty
);
6062 safi_t safi
= bgp_node_safi(vty
);
6064 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6065 yang_afi_safi_value2identity(afi
, safi
));
6067 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6068 sizeof(base_xpath
), af_xpath
)
6070 return CMD_WARNING_CONFIG_FAILED
;
6072 snprintf(attr_xpath
, sizeof(attr_xpath
),
6073 "./%s/private-as/remove-private-as-replace",
6074 bgp_afi_safi_get_container_str(afi
, safi
));
6076 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6078 return nb_cli_apply_changes(vty
, base_xpath
);
6081 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
6082 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
6083 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
6084 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6085 "Remove private ASNs in outbound updates\n"
6086 "Replace private ASNs with our ASN in outbound updates\n")
6088 DEFUN_YANG (no_neighbor_remove_private_as_all_replace_as
,
6089 no_neighbor_remove_private_as_all_replace_as_cmd
,
6090 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6094 "Remove private ASNs in outbound updates\n"
6095 "Apply to all AS numbers\n"
6096 "Replace private ASNs with our ASN in outbound updates\n")
6099 char base_xpath
[XPATH_MAXLEN
];
6100 char af_xpath
[XPATH_MAXLEN
];
6101 char attr_xpath
[XPATH_MAXLEN
];
6102 afi_t afi
= bgp_node_afi(vty
);
6103 safi_t safi
= bgp_node_safi(vty
);
6105 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6106 yang_afi_safi_value2identity(afi
, safi
));
6108 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6109 sizeof(base_xpath
), af_xpath
)
6111 return CMD_WARNING_CONFIG_FAILED
;
6113 snprintf(attr_xpath
, sizeof(attr_xpath
),
6114 "./%s/private-as/remove-private-as-all-replace",
6115 bgp_afi_safi_get_container_str(afi
, safi
));
6117 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6119 return nb_cli_apply_changes(vty
, base_xpath
);
6123 no_neighbor_remove_private_as_all_replace_as
,
6124 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
6125 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
6126 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6127 "Remove private ASNs in outbound updates\n"
6128 "Apply to all AS numbers\n"
6129 "Replace private ASNs with our ASN in outbound updates\n")
6132 /* neighbor send-community. */
6133 DEFUN_YANG (neighbor_send_community
,
6134 neighbor_send_community_cmd
,
6135 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6138 "Send Community attribute to this neighbor\n")
6142 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6144 PEER_FLAG_SEND_COMMUNITY
);
6147 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
6148 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6149 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6150 "Send Community attribute to this neighbor\n")
6152 DEFUN_YANG (no_neighbor_send_community
,
6153 no_neighbor_send_community_cmd
,
6154 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6158 "Send Community attribute to this neighbor\n")
6162 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6163 bgp_node_afi(vty
), bgp_node_safi(vty
),
6164 PEER_FLAG_SEND_COMMUNITY
);
6167 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
6168 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
6169 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6170 "Send Community attribute to this neighbor\n")
6172 /* neighbor send-community extended. */
6173 DEFUN_YANG (neighbor_send_community_type
,
6174 neighbor_send_community_type_cmd
,
6175 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6178 "Send Community attribute to this neighbor\n"
6179 "Send Standard and Extended Community attributes\n"
6180 "Send Standard, Large and Extended Community attributes\n"
6181 "Send Extended Community attributes\n"
6182 "Send Standard Community attributes\n"
6183 "Send Large Community attributes\n")
6185 const char *type
= argv
[argc
- 1]->text
;
6186 char *peer_str
= argv
[1]->arg
;
6187 char base_xpath
[XPATH_MAXLEN
];
6188 char af_xpath
[XPATH_MAXLEN
];
6189 char std_xpath
[XPATH_MAXLEN
];
6190 char ext_xpath
[XPATH_MAXLEN
];
6191 char lrg_xpath
[XPATH_MAXLEN
];
6192 afi_t afi
= bgp_node_afi(vty
);
6193 safi_t safi
= bgp_node_safi(vty
);
6195 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6196 yang_afi_safi_value2identity(afi
, safi
));
6198 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6199 sizeof(base_xpath
), af_xpath
)
6201 return CMD_WARNING_CONFIG_FAILED
;
6203 if (strmatch(type
, "standard")) {
6204 snprintf(std_xpath
, sizeof(std_xpath
),
6205 "./%s/send-community/send-community",
6206 bgp_afi_safi_get_container_str(afi
, safi
));
6208 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6211 if (strmatch(type
, "extended")) {
6212 snprintf(ext_xpath
, sizeof(ext_xpath
),
6213 "./%s/send-community/send-ext-community",
6214 bgp_afi_safi_get_container_str(afi
, safi
));
6216 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6219 if (strmatch(type
, "large")) {
6220 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6221 "./%s/send-community/send-large-community",
6222 bgp_afi_safi_get_container_str(afi
, safi
));
6224 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "true");
6227 if (strmatch(type
, "both")) {
6228 snprintf(std_xpath
, sizeof(std_xpath
),
6229 "./%s/send-community/send-community",
6230 bgp_afi_safi_get_container_str(afi
, safi
));
6232 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6234 snprintf(ext_xpath
, sizeof(ext_xpath
),
6235 "./%s/send-community/send-ext-community",
6236 bgp_afi_safi_get_container_str(afi
, safi
));
6238 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6241 if (strmatch(type
, "all")) {
6242 snprintf(std_xpath
, sizeof(std_xpath
),
6243 "./%s/send-community/send-community",
6244 bgp_afi_safi_get_container_str(afi
, safi
));
6246 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "true");
6248 snprintf(ext_xpath
, sizeof(ext_xpath
),
6249 "./%s/send-community/send-ext-community",
6250 bgp_afi_safi_get_container_str(afi
, safi
));
6252 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "true");
6254 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6255 "./%s/send-community/send-large-community",
6256 bgp_afi_safi_get_container_str(afi
, safi
));
6258 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "true");
6261 return nb_cli_apply_changes(vty
, base_xpath
);
6265 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
6266 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6267 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6268 "Send Community attribute to this neighbor\n"
6269 "Send Standard and Extended Community attributes\n"
6270 "Send Standard, Large and Extended Community attributes\n"
6271 "Send Extended Community attributes\n"
6272 "Send Standard Community attributes\n"
6273 "Send Large Community attributes\n")
6275 DEFUN_YANG (no_neighbor_send_community_type
,
6276 no_neighbor_send_community_type_cmd
,
6277 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6281 "Send Community attribute to this neighbor\n"
6282 "Send Standard and Extended Community attributes\n"
6283 "Send Standard, Large and Extended Community attributes\n"
6284 "Send Extended Community attributes\n"
6285 "Send Standard Community attributes\n"
6286 "Send Large Community attributes\n")
6288 const char *type
= argv
[argc
- 1]->text
;
6289 char *peer_str
= argv
[2]->arg
;
6290 char base_xpath
[XPATH_MAXLEN
];
6291 char af_xpath
[XPATH_MAXLEN
];
6292 char std_xpath
[XPATH_MAXLEN
];
6293 char ext_xpath
[XPATH_MAXLEN
];
6294 char lrg_xpath
[XPATH_MAXLEN
];
6295 afi_t afi
= bgp_node_afi(vty
);
6296 safi_t safi
= bgp_node_safi(vty
);
6298 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6299 yang_afi_safi_value2identity(afi
, safi
));
6301 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6302 sizeof(base_xpath
), af_xpath
)
6304 return CMD_WARNING_CONFIG_FAILED
;
6306 if (strmatch(type
, "standard")) {
6307 snprintf(std_xpath
, sizeof(std_xpath
),
6308 "./%s/send-community/send-community",
6309 bgp_afi_safi_get_container_str(afi
, safi
));
6311 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6314 if (strmatch(type
, "extended")) {
6315 snprintf(ext_xpath
, sizeof(ext_xpath
),
6316 "./%s/send-community/send-ext-community",
6317 bgp_afi_safi_get_container_str(afi
, safi
));
6319 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6322 if (strmatch(type
, "large")) {
6323 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6324 "./%s/send-community/send-large-community",
6325 bgp_afi_safi_get_container_str(afi
, safi
));
6327 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "false");
6330 if (strmatch(type
, "both")) {
6331 snprintf(std_xpath
, sizeof(std_xpath
),
6332 "./%s/send-community/send-community",
6333 bgp_afi_safi_get_container_str(afi
, safi
));
6335 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6337 snprintf(ext_xpath
, sizeof(ext_xpath
),
6338 "./%s/send-community/send-ext-community",
6339 bgp_afi_safi_get_container_str(afi
, safi
));
6341 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6344 if (strmatch(type
, "all")) {
6345 snprintf(std_xpath
, sizeof(std_xpath
),
6346 "./%s/send-community/send-community",
6347 bgp_afi_safi_get_container_str(afi
, safi
));
6349 nb_cli_enqueue_change(vty
, std_xpath
, NB_OP_MODIFY
, "false");
6351 snprintf(ext_xpath
, sizeof(ext_xpath
),
6352 "./%s/send-community/send-ext-community",
6353 bgp_afi_safi_get_container_str(afi
, safi
));
6355 nb_cli_enqueue_change(vty
, ext_xpath
, NB_OP_MODIFY
, "false");
6357 snprintf(lrg_xpath
, sizeof(lrg_xpath
),
6358 "./%s/send-community/send-large-community",
6359 bgp_afi_safi_get_container_str(afi
, safi
));
6361 nb_cli_enqueue_change(vty
, lrg_xpath
, NB_OP_MODIFY
, "false");
6364 return nb_cli_apply_changes(vty
, base_xpath
);
6368 no_neighbor_send_community_type
,
6369 no_neighbor_send_community_type_hidden_cmd
,
6370 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
6371 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6372 "Send Community attribute to this neighbor\n"
6373 "Send Standard and Extended Community attributes\n"
6374 "Send Standard, Large and Extended Community attributes\n"
6375 "Send Extended Community attributes\n"
6376 "Send Standard Community attributes\n"
6377 "Send Large Community attributes\n")
6379 /* neighbor soft-reconfig. */
6380 DEFUN_YANG (neighbor_soft_reconfiguration
,
6381 neighbor_soft_reconfiguration_cmd
,
6382 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6383 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6384 "Per neighbor soft reconfiguration\n"
6385 "Allow inbound soft reconfiguration for this neighbor\n")
6388 char base_xpath
[XPATH_MAXLEN
];
6389 char af_xpath
[XPATH_MAXLEN
];
6390 char soft_xpath
[XPATH_MAXLEN
];
6391 afi_t afi
= bgp_node_afi(vty
);
6392 safi_t safi
= bgp_node_safi(vty
);
6394 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6395 yang_afi_safi_value2identity(afi
, safi
));
6397 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6398 sizeof(base_xpath
), af_xpath
)
6400 return CMD_WARNING_CONFIG_FAILED
;
6402 snprintf(soft_xpath
, sizeof(soft_xpath
), "./%s/soft-reconfiguration",
6403 bgp_afi_safi_get_container_str(afi
, safi
));
6405 nb_cli_enqueue_change(vty
, soft_xpath
, NB_OP_MODIFY
, "true");
6407 return nb_cli_apply_changes(vty
, base_xpath
);
6410 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
6411 neighbor_soft_reconfiguration_hidden_cmd
,
6412 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6413 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6414 "Per neighbor soft reconfiguration\n"
6415 "Allow inbound soft reconfiguration for this neighbor\n")
6417 DEFUN_YANG (no_neighbor_soft_reconfiguration
,
6418 no_neighbor_soft_reconfiguration_cmd
,
6419 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6420 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6421 "Per neighbor soft reconfiguration\n"
6422 "Allow inbound soft reconfiguration for this neighbor\n")
6425 char base_xpath
[XPATH_MAXLEN
];
6426 char af_xpath
[XPATH_MAXLEN
];
6427 char soft_xpath
[XPATH_MAXLEN
];
6428 afi_t afi
= bgp_node_afi(vty
);
6429 safi_t safi
= bgp_node_safi(vty
);
6431 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6432 yang_afi_safi_value2identity(afi
, safi
));
6434 snprintf(soft_xpath
, sizeof(soft_xpath
), "./%s/soft-reconfiguration",
6435 bgp_afi_safi_get_container_str(afi
, safi
));
6437 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6438 sizeof(base_xpath
), af_xpath
)
6440 return CMD_WARNING_CONFIG_FAILED
;
6442 nb_cli_enqueue_change(vty
, soft_xpath
, NB_OP_MODIFY
, "false");
6444 return nb_cli_apply_changes(vty
, base_xpath
);
6447 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
6448 no_neighbor_soft_reconfiguration_hidden_cmd
,
6449 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
6450 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6451 "Per neighbor soft reconfiguration\n"
6452 "Allow inbound soft reconfiguration for this neighbor\n")
6454 DEFUN_YANG (neighbor_route_reflector_client
,
6455 neighbor_route_reflector_client_cmd
,
6456 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6459 "Configure a neighbor as Route Reflector client\n")
6462 char base_xpath
[XPATH_MAXLEN
];
6463 char af_xpath
[XPATH_MAXLEN
];
6464 char attr_xpath
[XPATH_MAXLEN
];
6465 afi_t afi
= bgp_node_afi(vty
);
6466 safi_t safi
= bgp_node_safi(vty
);
6468 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6469 yang_afi_safi_value2identity(afi
, safi
));
6471 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6472 sizeof(base_xpath
), af_xpath
)
6474 return CMD_WARNING_CONFIG_FAILED
;
6476 snprintf(attr_xpath
, sizeof(attr_xpath
),
6477 "./%s/route-reflector/route-reflector-client",
6478 bgp_afi_safi_get_container_str(afi
, safi
));
6480 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6482 return nb_cli_apply_changes(vty
, base_xpath
);
6485 ALIAS_HIDDEN(neighbor_route_reflector_client
,
6486 neighbor_route_reflector_client_hidden_cmd
,
6487 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6488 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6489 "Configure a neighbor as Route Reflector client\n")
6491 DEFUN_YANG (no_neighbor_route_reflector_client
,
6492 no_neighbor_route_reflector_client_cmd
,
6493 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6497 "Configure a neighbor as Route Reflector client\n")
6500 char base_xpath
[XPATH_MAXLEN
];
6501 char af_xpath
[XPATH_MAXLEN
];
6502 char attr_xpath
[XPATH_MAXLEN
];
6503 afi_t afi
= bgp_node_afi(vty
);
6504 safi_t safi
= bgp_node_safi(vty
);
6506 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6507 yang_afi_safi_value2identity(afi
, safi
));
6509 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6510 sizeof(base_xpath
), af_xpath
)
6512 return CMD_WARNING_CONFIG_FAILED
;
6514 snprintf(attr_xpath
, sizeof(attr_xpath
),
6515 "./%s/route-reflector/route-reflector-client",
6516 bgp_afi_safi_get_container_str(afi
, safi
));
6518 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6520 return nb_cli_apply_changes(vty
, base_xpath
);
6523 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
6524 no_neighbor_route_reflector_client_hidden_cmd
,
6525 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
6526 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6527 "Configure a neighbor as Route Reflector client\n")
6529 /* neighbor route-server-client. */
6530 DEFUN_YANG (neighbor_route_server_client
,
6531 neighbor_route_server_client_cmd
,
6532 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6535 "Configure a neighbor as Route Server client\n")
6538 char base_xpath
[XPATH_MAXLEN
];
6539 char af_xpath
[XPATH_MAXLEN
];
6540 char attr_xpath
[XPATH_MAXLEN
];
6541 afi_t afi
= bgp_node_afi(vty
);
6542 safi_t safi
= bgp_node_safi(vty
);
6544 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6545 yang_afi_safi_value2identity(afi
, safi
));
6547 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6548 sizeof(base_xpath
), af_xpath
)
6550 return CMD_WARNING_CONFIG_FAILED
;
6552 snprintf(attr_xpath
, sizeof(attr_xpath
),
6553 "./%s/route-server/route-server-client",
6554 bgp_afi_safi_get_container_str(afi
, safi
));
6556 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "true");
6558 return nb_cli_apply_changes(vty
, base_xpath
);
6561 ALIAS_HIDDEN(neighbor_route_server_client
,
6562 neighbor_route_server_client_hidden_cmd
,
6563 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6564 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6565 "Configure a neighbor as Route Server client\n")
6567 DEFUN_YANG (no_neighbor_route_server_client
,
6568 no_neighbor_route_server_client_cmd
,
6569 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6573 "Configure a neighbor as Route Server client\n")
6576 char base_xpath
[XPATH_MAXLEN
];
6577 char af_xpath
[XPATH_MAXLEN
];
6578 char attr_xpath
[XPATH_MAXLEN
];
6579 afi_t afi
= bgp_node_afi(vty
);
6580 safi_t safi
= bgp_node_safi(vty
);
6582 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6583 yang_afi_safi_value2identity(afi
, safi
));
6585 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6586 sizeof(base_xpath
), af_xpath
)
6588 return CMD_WARNING_CONFIG_FAILED
;
6590 snprintf(attr_xpath
, sizeof(attr_xpath
),
6591 "./%s/route-server/route-server-client",
6592 bgp_afi_safi_get_container_str(afi
, safi
));
6594 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
, "false");
6596 return nb_cli_apply_changes(vty
, base_xpath
);
6599 ALIAS_HIDDEN(no_neighbor_route_server_client
,
6600 no_neighbor_route_server_client_hidden_cmd
,
6601 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
6602 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6603 "Configure a neighbor as Route Server client\n")
6605 DEFUN (neighbor_nexthop_local_unchanged
,
6606 neighbor_nexthop_local_unchanged_cmd
,
6607 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6610 "Configure treatment of outgoing link-local nexthop attribute\n"
6611 "Leave link-local nexthop unchanged for this peer\n")
6614 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6616 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6619 DEFUN (no_neighbor_nexthop_local_unchanged
,
6620 no_neighbor_nexthop_local_unchanged_cmd
,
6621 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
6625 "Configure treatment of outgoing link-local-nexthop attribute\n"
6626 "Leave link-local nexthop unchanged for this peer\n")
6629 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6630 bgp_node_afi(vty
), bgp_node_safi(vty
),
6631 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
6634 DEFUN_YANG (neighbor_attr_unchanged
,
6635 neighbor_attr_unchanged_cmd
,
6636 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6639 "BGP attribute is propagated unchanged to this neighbor\n"
6640 "As-path attribute\n"
6641 "Nexthop attribute\n"
6645 char *peer_str
= argv
[1]->arg
;
6646 bool aspath
= false;
6647 bool nexthop
= false;
6649 afi_t afi
= bgp_node_afi(vty
);
6650 safi_t safi
= bgp_node_safi(vty
);
6651 char base_xpath
[XPATH_MAXLEN
];
6652 char af_xpath
[XPATH_MAXLEN
];
6653 char as_xpath
[XPATH_MAXLEN
];
6654 char nxthop_xpath
[XPATH_MAXLEN
];
6655 char med_xpath
[XPATH_MAXLEN
];
6657 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6658 yang_afi_safi_value2identity(afi
, safi
));
6660 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6661 sizeof(base_xpath
), af_xpath
)
6663 return CMD_WARNING_CONFIG_FAILED
;
6665 if (argv_find(argv
, argc
, "as-path", &idx
))
6669 if (argv_find(argv
, argc
, "next-hop", &idx
))
6673 if (argv_find(argv
, argc
, "med", &idx
))
6676 snprintf(as_xpath
, sizeof(as_xpath
),
6677 "./%s/attr-unchanged/as-path-unchanged",
6678 bgp_afi_safi_get_container_str(afi
, safi
));
6679 snprintf(nxthop_xpath
, sizeof(nxthop_xpath
),
6680 "./%s/attr-unchanged/next-hop-unchanged",
6681 bgp_afi_safi_get_container_str(afi
, safi
));
6682 snprintf(med_xpath
, sizeof(med_xpath
),
6683 "./%s/attr-unchanged/med-unchanged",
6684 bgp_afi_safi_get_container_str(afi
, safi
));
6686 /* no flags means all of them! */
6687 if (!aspath
&& !nexthop
&& !med
) {
6688 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "true");
6689 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "true");
6690 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "true");
6693 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
,
6696 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
,
6700 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
,
6703 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
,
6707 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
,
6710 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
,
6714 return nb_cli_apply_changes(vty
, base_xpath
);
6718 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
6719 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6720 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6721 "BGP attribute is propagated unchanged to this neighbor\n"
6722 "As-path attribute\n"
6723 "Nexthop attribute\n"
6726 DEFUN_YANG (no_neighbor_attr_unchanged
,
6727 no_neighbor_attr_unchanged_cmd
,
6728 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6732 "BGP attribute is propagated unchanged to this neighbor\n"
6733 "As-path attribute\n"
6734 "Nexthop attribute\n"
6738 char *peer_str
= argv
[2]->arg
;
6739 bool aspath
= false;
6740 bool nexthop
= false;
6742 afi_t afi
= bgp_node_afi(vty
);
6743 safi_t safi
= bgp_node_safi(vty
);
6744 char base_xpath
[XPATH_MAXLEN
];
6745 char af_xpath
[XPATH_MAXLEN
];
6746 char as_xpath
[XPATH_MAXLEN
];
6747 char nxthop_xpath
[XPATH_MAXLEN
];
6748 char med_xpath
[XPATH_MAXLEN
];
6750 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
6751 yang_afi_safi_value2identity(afi
, safi
));
6753 if (peer_and_group_lookup_nb(vty
, peer_str
, base_xpath
,
6754 sizeof(base_xpath
), af_xpath
)
6756 return CMD_WARNING_CONFIG_FAILED
;
6758 if (argv_find(argv
, argc
, "as-path", &idx
))
6762 if (argv_find(argv
, argc
, "next-hop", &idx
))
6766 if (argv_find(argv
, argc
, "med", &idx
))
6769 snprintf(as_xpath
, sizeof(as_xpath
),
6770 "./%s/attr-unchanged/as-path-unchanged",
6771 bgp_afi_safi_get_container_str(afi
, safi
));
6772 snprintf(nxthop_xpath
, sizeof(nxthop_xpath
),
6773 "./%s/attr-unchanged/next-hop-unchanged",
6774 bgp_afi_safi_get_container_str(afi
, safi
));
6775 snprintf(med_xpath
, sizeof(med_xpath
),
6776 "./%s/attr-unchanged/med-unchanged",
6777 bgp_afi_safi_get_container_str(afi
, safi
));
6779 /* no flags means all of them! */
6780 if (!aspath
&& !nexthop
&& !med
) {
6781 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "false");
6782 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "false");
6783 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "false");
6787 nb_cli_enqueue_change(vty
, as_xpath
, NB_OP_MODIFY
, "false");
6790 nb_cli_enqueue_change(vty
, nxthop_xpath
, NB_OP_MODIFY
, "false");
6793 nb_cli_enqueue_change(vty
, med_xpath
, NB_OP_MODIFY
, "false");
6795 return nb_cli_apply_changes(vty
, base_xpath
);
6799 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
6800 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
6801 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6802 "BGP attribute is propagated unchanged to this neighbor\n"
6803 "As-path attribute\n"
6804 "Nexthop attribute\n"
6807 /* neighbor ebgp-multihop. */
6808 DEFUN_YANG (neighbor_ebgp_multihop
,
6809 neighbor_ebgp_multihop_cmd
,
6810 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6811 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6812 "Allow EBGP neighbors not on directly connected networks\n")
6815 char base_xpath
[XPATH_MAXLEN
];
6817 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6818 sizeof(base_xpath
), NULL
)
6820 return CMD_WARNING_CONFIG_FAILED
;
6822 nb_cli_enqueue_change(vty
, "./ebgp-multihop/enabled", NB_OP_MODIFY
,
6825 return nb_cli_apply_changes(vty
, base_xpath
);
6828 DEFUN_YANG (neighbor_ebgp_multihop_ttl
,
6829 neighbor_ebgp_multihop_ttl_cmd
,
6830 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6831 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6832 "Allow EBGP neighbors not on directly connected networks\n"
6833 "maximum hop count\n")
6837 char base_xpath
[XPATH_MAXLEN
];
6839 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6840 sizeof(base_xpath
), NULL
)
6842 return CMD_WARNING_CONFIG_FAILED
;
6844 nb_cli_enqueue_change(vty
, "./ebgp-multihop/multihop-ttl", NB_OP_MODIFY
,
6845 argv
[idx_number
]->arg
);
6847 return nb_cli_apply_changes(vty
, base_xpath
);
6850 DEFUN_YANG (no_neighbor_ebgp_multihop
,
6851 no_neighbor_ebgp_multihop_cmd
,
6852 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6853 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6854 "Allow EBGP neighbors not on directly connected networks\n"
6855 "maximum hop count\n")
6858 char base_xpath
[XPATH_MAXLEN
];
6860 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6861 sizeof(base_xpath
), NULL
)
6863 return CMD_WARNING_CONFIG_FAILED
;
6866 nb_cli_enqueue_change(vty
, "./ebgp-multihop/multihop-ttl",
6867 NB_OP_DESTROY
, NULL
);
6869 nb_cli_enqueue_change(vty
, "./ebgp-multihop/enabled",
6870 NB_OP_MODIFY
, "false");
6872 return nb_cli_apply_changes(vty
, base_xpath
);
6876 /* disable-connected-check */
6877 DEFUN_YANG (neighbor_disable_connected_check
,
6878 neighbor_disable_connected_check_cmd
,
6879 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6880 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6881 "one-hop away EBGP peer using loopback address\n"
6882 "Enforce EBGP neighbors perform multihop\n")
6885 char base_xpath
[XPATH_MAXLEN
];
6887 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6888 sizeof(base_xpath
), NULL
)
6890 return CMD_WARNING_CONFIG_FAILED
;
6892 nb_cli_enqueue_change(vty
, "./ebgp-multihop/disable-connected-check",
6893 NB_OP_MODIFY
, "true");
6895 return nb_cli_apply_changes(vty
, base_xpath
);
6898 DEFUN_YANG (no_neighbor_disable_connected_check
,
6899 no_neighbor_disable_connected_check_cmd
,
6900 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6901 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6902 "one-hop away EBGP peer using loopback address\n"
6903 "Enforce EBGP neighbors perform multihop\n")
6906 char base_xpath
[XPATH_MAXLEN
];
6908 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6909 sizeof(base_xpath
), NULL
)
6911 return CMD_WARNING_CONFIG_FAILED
;
6913 nb_cli_enqueue_change(vty
, "./ebgp-multihop/disable-connected-check",
6914 NB_OP_MODIFY
, "false");
6916 return nb_cli_apply_changes(vty
, base_xpath
);
6920 /* enforce-first-as */
6921 DEFUN_YANG (neighbor_enforce_first_as
,
6922 neighbor_enforce_first_as_cmd
,
6923 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6924 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6925 "Enforce the first AS for EBGP routes\n")
6928 char base_xpath
[XPATH_MAXLEN
];
6930 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6931 sizeof(base_xpath
), NULL
)
6933 return CMD_WARNING_CONFIG_FAILED
;
6935 nb_cli_enqueue_change(vty
, "./enforce-first-as", NB_OP_MODIFY
, "true");
6937 return nb_cli_apply_changes(vty
, base_xpath
);
6940 DEFUN_YANG (no_neighbor_enforce_first_as
,
6941 no_neighbor_enforce_first_as_cmd
,
6942 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6943 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6944 "Enforce the first AS for EBGP routes\n")
6947 char base_xpath
[XPATH_MAXLEN
];
6949 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
6950 sizeof(base_xpath
), NULL
)
6952 return CMD_WARNING_CONFIG_FAILED
;
6954 nb_cli_enqueue_change(vty
, "./enforce-first-as", NB_OP_MODIFY
, "false");
6956 return nb_cli_apply_changes(vty
, base_xpath
);
6959 static int peer_and_group_lookup_nb(struct vty
*vty
, const char *peer_str
,
6960 char *base_xpath
, int xpath_len
,
6964 char num_xpath
[XPATH_MAXLEN
];
6965 char unnbr_xpath
[XPATH_MAXLEN
];
6966 char prgrp_xpath
[XPATH_MAXLEN
];
6968 if (str2sockunion(peer_str
, &su
) == 0) {
6969 snprintf(num_xpath
, sizeof(num_xpath
),
6970 "/neighbors/neighbor[remote-address='%s']", peer_str
);
6971 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
6972 VTY_CURR_XPATH
, num_xpath
)) {
6973 snprintf(base_xpath
, xpath_len
,
6974 FRR_BGP_NEIGHBOR_NUM_XPATH
, peer_str
,
6975 xpath
? xpath
: "");
6978 "%% Specify remote-as or peer-group commands first\n");
6983 snprintf(unnbr_xpath
, sizeof(unnbr_xpath
),
6984 "/neighbors/unnumbered-neighbor[interface='%s']",
6987 snprintf(prgrp_xpath
, sizeof(prgrp_xpath
),
6988 "/peer-groups/peer-group[peer-group-name='%s']",
6991 if (yang_dnode_exists(vty
->candidate_config
->dnode
, "%s%s",
6992 VTY_CURR_XPATH
, unnbr_xpath
)) {
6993 snprintf(base_xpath
, xpath_len
,
6994 FRR_BGP_NEIGHBOR_UNNUM_XPATH
, peer_str
,
6995 xpath
? xpath
: "");
6996 } else if (yang_dnode_exists(vty
->candidate_config
->dnode
,
6997 "%s%s", VTY_CURR_XPATH
,
6999 snprintf(base_xpath
, xpath_len
,
7000 FRR_BGP_PEER_GROUP_XPATH
, peer_str
,
7001 xpath
? xpath
: "");
7004 "%% Create the peer-group or interface first\n");
7012 DEFUN_YANG (neighbor_description
,
7013 neighbor_description_cmd
,
7014 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
7015 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7016 "Neighbor specific description\n"
7017 "Up to 80 characters describing this neighbor\n")
7022 char base_xpath
[XPATH_MAXLEN
];
7025 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7026 sizeof(base_xpath
), NULL
)
7028 return CMD_WARNING_CONFIG_FAILED
;
7030 str
= argv_concat(argv
, argc
, idx_line
);
7032 nb_cli_enqueue_change(vty
, "./description", NB_OP_MODIFY
, str
);
7034 ret
= nb_cli_apply_changes(vty
, base_xpath
);
7036 XFREE(MTYPE_TMP
, str
);
7041 DEFUN_YANG (no_neighbor_description
,
7042 no_neighbor_description_cmd
,
7043 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
7044 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7045 "Neighbor specific description\n")
7048 char base_xpath
[XPATH_MAXLEN
];
7050 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7051 sizeof(base_xpath
), NULL
)
7053 return CMD_WARNING_CONFIG_FAILED
;
7055 nb_cli_enqueue_change(vty
, "./description", NB_OP_DESTROY
, NULL
);
7057 return nb_cli_apply_changes(vty
, base_xpath
);
7060 ALIAS_YANG(no_neighbor_description
, no_neighbor_description_comment_cmd
,
7061 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
7062 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7063 "Neighbor specific description\n"
7064 "Up to 80 characters describing this neighbor\n")
7066 #define BGP_UPDATE_SOURCE_HELP_STR \
7069 "Interface name (requires zebra to be running)\n"
7071 DEFUN_YANG (neighbor_update_source
,
7072 neighbor_update_source_cmd
,
7073 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
7074 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7075 "Source of routing updates\n"
7076 BGP_UPDATE_SOURCE_HELP_STR
)
7081 char base_xpath
[XPATH_MAXLEN
];
7083 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7084 sizeof(base_xpath
), NULL
)
7086 return CMD_WARNING_CONFIG_FAILED
;
7088 if (str2sockunion(argv
[idx_peer_2
]->arg
, &su
) == 0)
7089 nb_cli_enqueue_change(vty
, "./update-source/ip", NB_OP_MODIFY
,
7090 argv
[idx_peer_2
]->arg
);
7092 nb_cli_enqueue_change(vty
, "./update-source/interface",
7093 NB_OP_MODIFY
, argv
[idx_peer_2
]->arg
);
7095 return nb_cli_apply_changes(vty
, base_xpath
);
7098 DEFUN_YANG (no_neighbor_update_source
,
7099 no_neighbor_update_source_cmd
,
7100 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
7103 "Source of routing updates\n"
7104 BGP_UPDATE_SOURCE_HELP_STR
)
7107 char base_xpath
[XPATH_MAXLEN
];
7109 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7110 sizeof(base_xpath
), NULL
)
7112 return CMD_WARNING_CONFIG_FAILED
;
7114 nb_cli_enqueue_change(vty
, "./update-source/ip", NB_OP_DESTROY
, NULL
);
7115 nb_cli_enqueue_change(vty
, "./update-source/interface", NB_OP_DESTROY
,
7118 return nb_cli_apply_changes(vty
, base_xpath
);
7121 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
7122 afi_t afi
, safi_t safi
,
7123 const char *rmap
, int set
)
7127 struct route_map
*route_map
= NULL
;
7129 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
7131 return CMD_WARNING_CONFIG_FAILED
;
7135 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
7136 ret
= peer_default_originate_set(peer
, afi
, safi
,
7139 ret
= peer_default_originate_unset(peer
, afi
, safi
);
7141 return bgp_vty_return(vty
, ret
);
7144 /* neighbor default-originate. */
7145 DEFUN (neighbor_default_originate
,
7146 neighbor_default_originate_cmd
,
7147 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
7150 "Originate default route to this neighbor\n")
7153 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
7155 bgp_node_safi(vty
), NULL
, 1);
7158 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
7159 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
7160 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7161 "Originate default route to this neighbor\n")
7163 DEFUN (neighbor_default_originate_rmap
,
7164 neighbor_default_originate_rmap_cmd
,
7165 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
7168 "Originate default route to this neighbor\n"
7169 "Route-map to specify criteria to originate default\n"
7174 return peer_default_originate_set_vty(
7175 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7176 argv
[idx_word
]->arg
, 1);
7180 neighbor_default_originate_rmap
,
7181 neighbor_default_originate_rmap_hidden_cmd
,
7182 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
7183 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7184 "Originate default route to this neighbor\n"
7185 "Route-map to specify criteria to originate default\n"
7188 DEFUN (no_neighbor_default_originate
,
7189 no_neighbor_default_originate_cmd
,
7190 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
7194 "Originate default route to this neighbor\n"
7195 "Route-map to specify criteria to originate default\n"
7199 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
7201 bgp_node_safi(vty
), NULL
, 0);
7205 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
7206 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
7207 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7208 "Originate default route to this neighbor\n"
7209 "Route-map to specify criteria to originate default\n"
7213 /* Set specified peer's BGP port. */
7214 DEFUN_YANG (neighbor_port
,
7216 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
7219 "Neighbor's BGP port\n"
7220 "TCP port number\n")
7224 char base_xpath
[XPATH_MAXLEN
];
7226 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7227 argv
[idx_ip
]->arg
, "");
7229 nb_cli_enqueue_change(vty
, "./local-port", NB_OP_MODIFY
,
7230 argv
[idx_number
]->arg
);
7232 return nb_cli_apply_changes(vty
, base_xpath
);
7235 DEFUN_YANG (no_neighbor_port
,
7236 no_neighbor_port_cmd
,
7237 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
7238 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR
7239 "Neighbor's BGP port\n"
7240 "TCP port number\n")
7243 char base_xpath
[XPATH_MAXLEN
];
7245 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7246 argv
[idx_ip
]->arg
, "");
7248 nb_cli_enqueue_change(vty
, "./local-port", NB_OP_DESTROY
, NULL
);
7250 return nb_cli_apply_changes(vty
, base_xpath
);
7253 DEFUN_YANG (neighbor_weight
,
7254 neighbor_weight_cmd
,
7255 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7256 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7257 "Set default weight for routes from this neighbor\n"
7262 char base_xpath
[XPATH_MAXLEN
];
7263 char af_xpath
[XPATH_MAXLEN
];
7264 char attr_xpath
[XPATH_MAXLEN
];
7265 afi_t afi
= bgp_node_afi(vty
);
7266 safi_t safi
= bgp_node_safi(vty
);
7268 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
7269 yang_afi_safi_value2identity(afi
, safi
));
7271 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7272 sizeof(base_xpath
), af_xpath
)
7274 return CMD_WARNING_CONFIG_FAILED
;
7276 snprintf(attr_xpath
, sizeof(attr_xpath
), "./%s/weight/weight-attribute",
7277 bgp_afi_safi_get_container_str(afi
, safi
));
7279 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_MODIFY
,
7280 argv
[idx_number
]->arg
);
7282 return nb_cli_apply_changes(vty
, base_xpath
);
7285 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
7286 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
7287 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7288 "Set default weight for routes from this neighbor\n"
7291 DEFUN_YANG (no_neighbor_weight
,
7292 no_neighbor_weight_cmd
,
7293 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7294 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7295 "Set default weight for routes from this neighbor\n"
7299 char base_xpath
[XPATH_MAXLEN
];
7300 char af_xpath
[XPATH_MAXLEN
];
7301 char attr_xpath
[XPATH_MAXLEN
];
7302 afi_t afi
= bgp_node_afi(vty
);
7303 safi_t safi
= bgp_node_safi(vty
);
7305 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
7306 yang_afi_safi_value2identity(afi
, safi
));
7308 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7309 sizeof(base_xpath
), af_xpath
)
7311 return CMD_WARNING_CONFIG_FAILED
;
7313 snprintf(attr_xpath
, sizeof(attr_xpath
), "./%s/weight/weight-attribute",
7314 bgp_afi_safi_get_container_str(afi
, safi
));
7316 nb_cli_enqueue_change(vty
, attr_xpath
, NB_OP_DESTROY
, NULL
);
7318 return nb_cli_apply_changes(vty
, base_xpath
);
7321 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
7322 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
7323 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7324 "Set default weight for routes from this neighbor\n"
7328 /* Override capability negotiation. */
7329 DEFUN_YANG (neighbor_override_capability
,
7330 neighbor_override_capability_cmd
,
7331 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7334 "Override capability negotiation result\n")
7337 char base_xpath
[XPATH_MAXLEN
];
7339 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7340 sizeof(base_xpath
), NULL
)
7342 return CMD_WARNING_CONFIG_FAILED
;
7344 nb_cli_enqueue_change(
7345 vty
, "./capability-options/override-capability",
7346 NB_OP_MODIFY
, "true");
7348 return nb_cli_apply_changes(vty
, base_xpath
);
7351 DEFUN_YANG (no_neighbor_override_capability
,
7352 no_neighbor_override_capability_cmd
,
7353 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
7357 "Override capability negotiation result\n")
7360 char base_xpath
[XPATH_MAXLEN
];
7362 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7363 sizeof(base_xpath
), NULL
)
7365 return CMD_WARNING_CONFIG_FAILED
;
7367 nb_cli_enqueue_change(
7368 vty
, "./capability-options/override-capability",
7369 NB_OP_MODIFY
, "false");
7371 return nb_cli_apply_changes(vty
, base_xpath
);
7374 DEFUN_YANG (neighbor_strict_capability
,
7375 neighbor_strict_capability_cmd
,
7376 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7379 "Strict capability negotiation match\n")
7382 char base_xpath
[XPATH_MAXLEN
];
7384 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7385 sizeof(base_xpath
), NULL
)
7387 return CMD_WARNING_CONFIG_FAILED
;
7389 nb_cli_enqueue_change(
7390 vty
, "./capability-options/strict-capability",
7391 NB_OP_MODIFY
, "true");
7393 return nb_cli_apply_changes(vty
, base_xpath
);
7396 DEFUN_YANG (no_neighbor_strict_capability
,
7397 no_neighbor_strict_capability_cmd
,
7398 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
7402 "Strict capability negotiation match\n")
7405 char base_xpath
[XPATH_MAXLEN
];
7407 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7408 sizeof(base_xpath
), NULL
)
7410 return CMD_WARNING_CONFIG_FAILED
;
7412 nb_cli_enqueue_change(
7413 vty
, "./capability-options/strict-capability",
7414 NB_OP_MODIFY
, "false");
7416 return nb_cli_apply_changes(vty
, base_xpath
);
7419 DEFUN_YANG (neighbor_timers
,
7420 neighbor_timers_cmd
,
7421 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
7422 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7423 "BGP per neighbor timers\n"
7424 "Keepalive interval\n"
7429 int idx_number_2
= 4;
7430 char base_xpath
[XPATH_MAXLEN
];
7432 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7433 sizeof(base_xpath
), NULL
)
7435 return CMD_WARNING_CONFIG_FAILED
;
7437 nb_cli_enqueue_change(vty
, "./timers/keepalive", NB_OP_MODIFY
,
7438 argv
[idx_number
]->arg
);
7440 nb_cli_enqueue_change(vty
, "./timers/hold-time", NB_OP_MODIFY
,
7441 argv
[idx_number_2
]->arg
);
7443 return nb_cli_apply_changes(vty
, base_xpath
);
7446 DEFUN_YANG (no_neighbor_timers
,
7447 no_neighbor_timers_cmd
,
7448 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
7449 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7450 "BGP per neighbor timers\n"
7451 "Keepalive interval\n"
7455 char base_xpath
[XPATH_MAXLEN
];
7457 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7458 sizeof(base_xpath
), NULL
)
7460 return CMD_WARNING_CONFIG_FAILED
;
7462 nb_cli_enqueue_change(vty
, "./timers/hold-time", NB_OP_DESTROY
, NULL
);
7464 nb_cli_enqueue_change(vty
, "./timers/keepalive", NB_OP_DESTROY
, NULL
);
7466 return nb_cli_apply_changes(vty
, base_xpath
);
7469 DEFUN_YANG (neighbor_timers_connect
,
7470 neighbor_timers_connect_cmd
,
7471 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
7472 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7473 "BGP per neighbor timers\n"
7474 "BGP connect timer\n"
7479 char base_xpath
[XPATH_MAXLEN
];
7481 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7482 sizeof(base_xpath
), NULL
)
7484 return CMD_WARNING_CONFIG_FAILED
;
7486 nb_cli_enqueue_change(vty
, "./timers/connect-time", NB_OP_MODIFY
,
7487 argv
[idx_number
]->arg
);
7489 return nb_cli_apply_changes(vty
, base_xpath
);
7492 DEFUN_YANG (no_neighbor_timers_connect
,
7493 no_neighbor_timers_connect_cmd
,
7494 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
7495 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7496 "BGP per neighbor timers\n"
7497 "BGP connect timer\n"
7501 char base_xpath
[XPATH_MAXLEN
];
7503 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7504 sizeof(base_xpath
), NULL
)
7506 return CMD_WARNING_CONFIG_FAILED
;
7508 nb_cli_enqueue_change(vty
, "./timers/connect-time", NB_OP_DESTROY
,
7511 return nb_cli_apply_changes(vty
, base_xpath
);
7514 DEFPY (neighbor_timers_delayopen
,
7515 neighbor_timers_delayopen_cmd
,
7516 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen (1-240)$interval",
7519 "BGP per neighbor timers\n"
7520 "RFC 4271 DelayOpenTimer\n"
7521 "DelayOpenTime timer interval\n")
7525 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7527 return CMD_WARNING_CONFIG_FAILED
;
7530 if (peer_timers_delayopen_unset(peer
))
7531 return CMD_WARNING_CONFIG_FAILED
;
7533 if (peer_timers_delayopen_set(peer
, interval
))
7534 return CMD_WARNING_CONFIG_FAILED
;
7540 DEFPY (no_neighbor_timers_delayopen
,
7541 no_neighbor_timers_delayopen_cmd
,
7542 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor timers delayopen [(0-65535)]",
7546 "BGP per neighbor timers\n"
7547 "RFC 4271 DelayOpenTimer\n"
7548 "DelayOpenTime timer interval\n")
7552 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7554 return CMD_WARNING_CONFIG_FAILED
;
7556 if (peer_timers_delayopen_unset(peer
))
7557 return CMD_WARNING_CONFIG_FAILED
;
7562 DEFUN_YANG (neighbor_advertise_interval
,
7563 neighbor_advertise_interval_cmd
,
7564 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
7565 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7566 "Minimum interval between sending BGP routing updates\n"
7567 "time in seconds\n")
7571 char base_xpath
[XPATH_MAXLEN
];
7573 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7574 sizeof(base_xpath
), NULL
)
7576 return CMD_WARNING_CONFIG_FAILED
;
7578 nb_cli_enqueue_change(vty
, "./timers/advertise-interval", NB_OP_MODIFY
,
7579 argv
[idx_number
]->arg
);
7581 return nb_cli_apply_changes(vty
, base_xpath
);
7584 DEFUN_YANG (no_neighbor_advertise_interval
,
7585 no_neighbor_advertise_interval_cmd
,
7586 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
7587 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7588 "Minimum interval between sending BGP routing updates\n"
7589 "time in seconds\n")
7592 char base_xpath
[XPATH_MAXLEN
];
7594 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
7595 sizeof(base_xpath
), NULL
)
7597 return CMD_WARNING_CONFIG_FAILED
;
7599 nb_cli_enqueue_change(vty
, "./timers/advertise-interval", NB_OP_DESTROY
,
7602 return nb_cli_apply_changes(vty
, base_xpath
);
7606 /* Time to wait before processing route-map updates */
7607 DEFUN (bgp_set_route_map_delay_timer
,
7608 bgp_set_route_map_delay_timer_cmd
,
7609 "bgp route-map delay-timer (0-600)",
7611 "BGP route-map delay timer\n"
7612 "Time in secs to wait before processing route-map changes\n"
7613 "0 disables the timer, no route updates happen when route-maps change\n")
7616 uint32_t rmap_delay_timer
;
7618 if (argv
[idx_number
]->arg
) {
7619 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7620 bm
->rmap_update_timer
= rmap_delay_timer
;
7622 /* if the dynamic update handling is being disabled, and a timer
7624 * running, stop the timer and act as if the timer has already
7627 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
7628 BGP_TIMER_OFF(bm
->t_rmap_update
);
7629 thread_execute(bm
->master
, bgp_route_map_update_timer
,
7634 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
7635 return CMD_WARNING_CONFIG_FAILED
;
7639 DEFUN (no_bgp_set_route_map_delay_timer
,
7640 no_bgp_set_route_map_delay_timer_cmd
,
7641 "no bgp route-map delay-timer [(0-600)]",
7644 "Default BGP route-map delay timer\n"
7645 "Reset to default time to wait for processing route-map changes\n"
7646 "0 disables the timer, no route updates happen when route-maps change\n")
7649 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
7654 DEFUN_YANG (neighbor_interface
,
7655 neighbor_interface_cmd
,
7656 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
7657 NEIGHBOR_STR NEIGHBOR_ADDR_STR
7663 char base_xpath
[XPATH_MAXLEN
];
7665 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7666 argv
[idx_ip
]->arg
, "");
7668 nb_cli_enqueue_change(vty
, "./local-interface", NB_OP_MODIFY
,
7669 argv
[idx_word
]->arg
);
7671 return nb_cli_apply_changes(vty
, base_xpath
);
7674 DEFUN_YANG (no_neighbor_interface
,
7675 no_neighbor_interface_cmd
,
7676 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
7677 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7682 char base_xpath
[XPATH_MAXLEN
];
7684 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_NEIGHBOR_NUM_XPATH
,
7685 argv
[idx_peer
]->arg
, "");
7687 nb_cli_enqueue_change(vty
, "./local-interface", NB_OP_DESTROY
, NULL
);
7689 return nb_cli_apply_changes(vty
, base_xpath
);
7692 DEFUN (neighbor_distribute_list
,
7693 neighbor_distribute_list_cmd
,
7694 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7697 "Filter updates to/from this neighbor\n"
7698 "IP access-list number\n"
7699 "IP access-list number (expanded range)\n"
7700 "IP Access-list name\n"
7701 "Filter incoming updates\n"
7702 "Filter outgoing updates\n")
7709 const char *pstr
= argv
[idx_peer
]->arg
;
7710 const char *acl
= argv
[idx_acl
]->arg
;
7711 const char *inout
= argv
[argc
- 1]->text
;
7713 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7715 return CMD_WARNING_CONFIG_FAILED
;
7717 /* Check filter direction. */
7718 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7719 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7722 return bgp_vty_return(vty
, ret
);
7726 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
7727 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7728 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7729 "Filter updates to/from this neighbor\n"
7730 "IP access-list number\n"
7731 "IP access-list number (expanded range)\n"
7732 "IP Access-list name\n"
7733 "Filter incoming updates\n"
7734 "Filter outgoing updates\n")
7736 DEFUN (no_neighbor_distribute_list
,
7737 no_neighbor_distribute_list_cmd
,
7738 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7742 "Filter updates to/from this neighbor\n"
7743 "IP access-list number\n"
7744 "IP access-list number (expanded range)\n"
7745 "IP Access-list name\n"
7746 "Filter incoming updates\n"
7747 "Filter outgoing updates\n")
7753 const char *pstr
= argv
[idx_peer
]->arg
;
7754 const char *inout
= argv
[argc
- 1]->text
;
7756 peer
= peer_and_group_lookup_vty(vty
, pstr
);
7758 return CMD_WARNING_CONFIG_FAILED
;
7760 /* Check filter direction. */
7761 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
7762 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7765 return bgp_vty_return(vty
, ret
);
7769 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
7770 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
7771 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7772 "Filter updates to/from this neighbor\n"
7773 "IP access-list number\n"
7774 "IP access-list number (expanded range)\n"
7775 "IP Access-list name\n"
7776 "Filter incoming updates\n"
7777 "Filter outgoing updates\n")
7779 /* Set prefix list to the peer. */
7781 neighbor_prefix_list
, neighbor_prefix_list_cmd
,
7782 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor_str prefix-list WORD$prefix_str <in|out>$direction",
7783 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7784 "Filter updates to/from this neighbor\n"
7785 "Name of a prefix list\n"
7786 "Filter incoming updates\n"
7787 "Filter outgoing updates\n")
7789 char base_xpath
[XPATH_MAXLEN
];
7790 char af_xpath
[XPATH_MAXLEN
];
7791 char plist_xpath
[XPATH_MAXLEN
];
7792 afi_t afi
= bgp_node_afi(vty
);
7793 safi_t safi
= bgp_node_safi(vty
);
7795 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
7796 yang_afi_safi_value2identity(afi
, safi
));
7797 if (peer_and_group_lookup_nb(vty
, neighbor_str
, base_xpath
,
7798 sizeof(base_xpath
), af_xpath
)
7800 return CMD_WARNING_CONFIG_FAILED
;
7802 if (strmatch(direction
, "in"))
7803 snprintf(plist_xpath
, sizeof(plist_xpath
),
7804 "./%s/filter-config/plist-import",
7805 bgp_afi_safi_get_container_str(afi
, safi
));
7806 else if (strmatch(direction
, "out"))
7807 snprintf(plist_xpath
, sizeof(plist_xpath
),
7808 "./%s/filter-config/plist-export",
7809 bgp_afi_safi_get_container_str(afi
, safi
));
7812 nb_cli_enqueue_change(vty
, plist_xpath
, NB_OP_MODIFY
,
7815 nb_cli_enqueue_change(vty
, plist_xpath
, NB_OP_DESTROY
, NULL
);
7817 return nb_cli_apply_changes(vty
, base_xpath
);
7820 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
7821 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
7822 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7823 "Filter updates to/from this neighbor\n"
7824 "Name of a prefix list\n"
7825 "Filter incoming updates\n"
7826 "Filter outgoing updates\n")
7828 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7829 safi_t safi
, const char *name_str
,
7830 const char *direct_str
)
7834 int direct
= FILTER_IN
;
7836 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7838 return CMD_WARNING_CONFIG_FAILED
;
7840 /* Check filter direction. */
7841 if (strncmp(direct_str
, "i", 1) == 0)
7843 else if (strncmp(direct_str
, "o", 1) == 0)
7844 direct
= FILTER_OUT
;
7846 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
7848 return bgp_vty_return(vty
, ret
);
7851 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
7852 safi_t safi
, const char *direct_str
)
7856 int direct
= FILTER_IN
;
7858 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7860 return CMD_WARNING_CONFIG_FAILED
;
7862 /* Check filter direction. */
7863 if (strncmp(direct_str
, "i", 1) == 0)
7865 else if (strncmp(direct_str
, "o", 1) == 0)
7866 direct
= FILTER_OUT
;
7868 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
7870 return bgp_vty_return(vty
, ret
);
7873 DEFUN (neighbor_filter_list
,
7874 neighbor_filter_list_cmd
,
7875 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7878 "Establish BGP filters\n"
7879 "AS path access-list name\n"
7880 "Filter incoming routes\n"
7881 "Filter outgoing routes\n")
7886 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7887 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7888 argv
[idx_in_out
]->arg
);
7891 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7892 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7893 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7894 "Establish BGP filters\n"
7895 "AS path access-list name\n"
7896 "Filter incoming routes\n"
7897 "Filter outgoing routes\n")
7899 DEFUN (no_neighbor_filter_list
,
7900 no_neighbor_filter_list_cmd
,
7901 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7905 "Establish BGP filters\n"
7906 "AS path access-list name\n"
7907 "Filter incoming routes\n"
7908 "Filter outgoing routes\n")
7912 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7913 bgp_node_afi(vty
), bgp_node_safi(vty
),
7914 argv
[idx_in_out
]->arg
);
7917 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7918 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7919 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7920 "Establish BGP filters\n"
7921 "AS path access-list name\n"
7922 "Filter incoming routes\n"
7923 "Filter outgoing routes\n")
7925 /* Set advertise-map to the peer. */
7926 static int peer_advertise_map_set_vty(struct vty
*vty
, const char *ip_str
,
7927 afi_t afi
, safi_t safi
,
7928 const char *advertise_str
,
7929 const char *condition_str
, bool condition
,
7932 int ret
= CMD_WARNING_CONFIG_FAILED
;
7934 struct route_map
*advertise_map
;
7935 struct route_map
*condition_map
;
7937 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7941 condition_map
= route_map_lookup_warn_noexist(vty
, condition_str
);
7942 advertise_map
= route_map_lookup_warn_noexist(vty
, advertise_str
);
7945 ret
= peer_advertise_map_set(peer
, afi
, safi
, advertise_str
,
7946 advertise_map
, condition_str
,
7947 condition_map
, condition
);
7949 ret
= peer_advertise_map_unset(peer
, afi
, safi
, advertise_str
,
7950 advertise_map
, condition_str
,
7951 condition_map
, condition
);
7953 return bgp_vty_return(vty
, ret
);
7956 DEFPY (neighbor_advertise_map
,
7957 neighbor_advertise_map_cmd
,
7958 "[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",
7962 "Route-map to conditionally advertise routes\n"
7963 "Name of advertise map\n"
7964 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7965 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7966 "Name of the exist or non exist map\n")
7968 bool condition
= CONDITION_EXIST
;
7970 if (!strcmp(exist
, "non-exist-map"))
7971 condition
= CONDITION_NON_EXIST
;
7973 return peer_advertise_map_set_vty(vty
, neighbor
, bgp_node_afi(vty
),
7974 bgp_node_safi(vty
), advertise_str
,
7975 condition_str
, condition
, !no
);
7978 ALIAS_HIDDEN(neighbor_advertise_map
, neighbor_advertise_map_hidden_cmd
,
7979 "[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",
7980 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7981 "Route-map to conditionally advertise routes\n"
7982 "Name of advertise map\n"
7983 "Advertise routes only if prefixes in exist-map are installed in BGP table\n"
7984 "Advertise routes only if prefixes in non-exist-map are not installed in BGP table\n"
7985 "Name of the exist or non exist map\n")
7987 /* Set route-map to the peer. */
7989 neighbor_route_map
, neighbor_route_map_cmd
,
7990 "[no$no] neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor_str route-map WORD$rmap_str <in|out>$direction",
7991 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7992 "Apply route map to neighbor\n"
7993 "Name of route map\n"
7994 "Apply map to incoming routes\n"
7995 "Apply map to outbound routes\n")
7997 char base_xpath
[XPATH_MAXLEN
];
7998 char af_xpath
[XPATH_MAXLEN
];
7999 char rmap_xpath
[XPATH_MAXLEN
];
8000 afi_t afi
= bgp_node_afi(vty
);
8001 safi_t safi
= bgp_node_safi(vty
);
8003 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8004 yang_afi_safi_value2identity(afi
, safi
));
8005 if (peer_and_group_lookup_nb(vty
, neighbor_str
, base_xpath
,
8006 sizeof(base_xpath
), af_xpath
)
8008 return CMD_WARNING_CONFIG_FAILED
;
8010 if (strmatch(direction
, "in"))
8011 snprintf(rmap_xpath
, sizeof(rmap_xpath
),
8012 "./%s/filter-config/rmap-import",
8013 bgp_afi_safi_get_container_str(afi
, safi
));
8014 else if (strmatch(direction
, "out"))
8015 snprintf(rmap_xpath
, sizeof(rmap_xpath
),
8016 "./%s/filter-config/rmap-export",
8017 bgp_afi_safi_get_container_str(afi
, safi
));
8020 if (!yang_dnode_exists(
8021 vty
->candidate_config
->dnode
,
8022 "/frr-route-map:lib/route-map[name='%s']",
8024 if (vty_shell_serv(vty
))
8026 "The route-map '%s' does not exist.\n",
8029 nb_cli_enqueue_change(vty
, rmap_xpath
, NB_OP_MODIFY
, rmap_str
);
8031 nb_cli_enqueue_change(vty
, rmap_xpath
, NB_OP_DESTROY
, NULL
);
8033 return nb_cli_apply_changes(vty
, base_xpath
);
8036 /* Set unsuppress-map to the peer. */
8037 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
8038 afi_t afi
, safi_t safi
,
8039 const char *name_str
)
8043 struct route_map
*route_map
;
8045 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8047 return CMD_WARNING_CONFIG_FAILED
;
8049 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
8050 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
8052 return bgp_vty_return(vty
, ret
);
8055 /* Unset route-map from the peer. */
8056 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
8057 afi_t afi
, safi_t safi
)
8062 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
8064 return CMD_WARNING_CONFIG_FAILED
;
8066 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
8068 return bgp_vty_return(vty
, ret
);
8071 DEFUN (neighbor_unsuppress_map
,
8072 neighbor_unsuppress_map_cmd
,
8073 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8076 "Route-map to selectively unsuppress suppressed routes\n"
8077 "Name of route map\n")
8081 return peer_unsuppress_map_set_vty(
8082 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8083 argv
[idx_word
]->arg
);
8086 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
8087 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8088 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8089 "Route-map to selectively unsuppress suppressed routes\n"
8090 "Name of route map\n")
8092 DEFUN (no_neighbor_unsuppress_map
,
8093 no_neighbor_unsuppress_map_cmd
,
8094 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8098 "Route-map to selectively unsuppress suppressed routes\n"
8099 "Name of route map\n")
8102 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
8104 bgp_node_safi(vty
));
8107 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
8108 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
8109 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8110 "Route-map to selectively unsuppress suppressed routes\n"
8111 "Name of route map\n")
8113 /* Maximum number of prefix to be sent to the neighbor. */
8114 DEFUN_YANG(neighbor_maximum_prefix_out
,
8115 neighbor_maximum_prefix_out_cmd
,
8116 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
8117 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8118 "Maximum number of prefixes to be sent to this peer\n"
8119 "Maximum no. of prefix limit\n")
8121 char base_xpath
[XPATH_MAXLEN
];
8122 char af_xpath
[XPATH_MAXLEN
];
8123 char attr_xpath
[XPATH_MAXLEN
];
8126 afi_t afi
= bgp_node_afi(vty
);
8127 safi_t safi
= bgp_node_safi(vty
);
8129 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8130 yang_afi_safi_value2identity(afi
, safi
));
8131 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8132 sizeof(base_xpath
), af_xpath
)
8134 return CMD_WARNING_CONFIG_FAILED
;
8136 snprintf(attr_xpath
, sizeof(attr_xpath
),
8137 "/%s/prefix-limit/direction-list[direction='out']",
8138 bgp_afi_safi_get_container_str(afi
, safi
));
8139 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8141 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8143 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8144 argv
[idx_number
]->arg
);
8146 return nb_cli_apply_changes(vty
, base_xpath
);
8149 DEFUN_YANG(no_neighbor_maximum_prefix_out
,
8150 no_neighbor_maximum_prefix_out_cmd
,
8151 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out",
8152 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8153 "Maximum number of prefixes to be sent to this peer\n")
8155 char base_xpath
[XPATH_MAXLEN
];
8156 char af_xpath
[XPATH_MAXLEN
];
8157 char attr_xpath
[XPATH_MAXLEN
];
8159 afi_t afi
= bgp_node_afi(vty
);
8160 safi_t safi
= bgp_node_safi(vty
);
8162 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8163 yang_afi_safi_value2identity(afi
, safi
));
8164 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8165 sizeof(base_xpath
), af_xpath
)
8167 return CMD_WARNING_CONFIG_FAILED
;
8169 snprintf(attr_xpath
, sizeof(attr_xpath
),
8170 "/%s/prefix-limit/direction-list[direction='out']",
8171 bgp_afi_safi_get_container_str(afi
, safi
));
8172 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8174 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
8176 return nb_cli_apply_changes(vty
, base_xpath
);
8179 /* Maximum number of prefix configuration. Prefix count is different
8180 for each peer configuration. So this configuration can be set for
8181 each peer configuration. */
8182 DEFUN_YANG(neighbor_maximum_prefix
,
8183 neighbor_maximum_prefix_cmd
,
8184 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8185 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8186 "Maximum number of prefix accept from this peer\n"
8187 "maximum no. of prefix limit\n"
8188 "Force checking all received routes not only accepted\n")
8193 char base_xpath
[XPATH_MAXLEN
];
8194 char af_xpath
[XPATH_MAXLEN
];
8195 char attr_xpath
[XPATH_MAXLEN
];
8196 afi_t afi
= bgp_node_afi(vty
);
8197 safi_t safi
= bgp_node_safi(vty
);
8199 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8200 yang_afi_safi_value2identity(afi
, safi
));
8201 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8202 sizeof(base_xpath
), af_xpath
)
8204 return CMD_WARNING_CONFIG_FAILED
;
8206 snprintf(attr_xpath
, sizeof(attr_xpath
),
8207 "/%s/prefix-limit/direction-list[direction='in']",
8208 bgp_afi_safi_get_container_str(afi
, safi
));
8209 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8211 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8213 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8214 argv
[idx_number
]->arg
);
8215 if (argv_find(argv
, argc
, "force", &idx_force
))
8216 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8219 return nb_cli_apply_changes(vty
, base_xpath
);
8222 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
8223 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
8224 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8225 "Maximum number of prefix accept from this peer\n"
8226 "maximum no. of prefix limit\n"
8227 "Force checking all received routes not only accepted\n")
8229 DEFUN_YANG(neighbor_maximum_prefix_threshold
,
8230 neighbor_maximum_prefix_threshold_cmd
,
8231 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8232 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8233 "Maximum number of prefix accept from this peer\n"
8234 "maximum no. of prefix limit\n"
8235 "Threshold value (%) at which to generate a warning msg\n"
8236 "Force checking all received routes not only accepted\n")
8240 int idx_number_2
= 4;
8242 char base_xpath
[XPATH_MAXLEN
];
8243 char af_xpath
[XPATH_MAXLEN
];
8244 char attr_xpath
[XPATH_MAXLEN
];
8245 afi_t afi
= bgp_node_afi(vty
);
8246 safi_t safi
= bgp_node_safi(vty
);
8248 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8249 yang_afi_safi_value2identity(afi
, safi
));
8250 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8251 sizeof(base_xpath
), af_xpath
)
8253 return CMD_WARNING_CONFIG_FAILED
;
8255 snprintf(attr_xpath
, sizeof(attr_xpath
),
8256 "/%s/prefix-limit/direction-list[direction='in']",
8257 bgp_afi_safi_get_container_str(afi
, safi
));
8258 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8260 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8262 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8263 argv
[idx_number
]->arg
);
8265 nb_cli_enqueue_change(vty
, "./options/shutdown-threshold-pct",
8266 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8268 if (argv_find(argv
, argc
, "force", &idx_force
))
8269 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8272 return nb_cli_apply_changes(vty
, base_xpath
);
8276 neighbor_maximum_prefix_threshold
,
8277 neighbor_maximum_prefix_threshold_hidden_cmd
,
8278 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
8279 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8280 "Maximum number of prefix accept from this peer\n"
8281 "maximum no. of prefix limit\n"
8282 "Threshold value (%) at which to generate a warning msg\n"
8283 "Force checking all received routes not only accepted\n")
8285 DEFUN_YANG(neighbor_maximum_prefix_warning
,
8286 neighbor_maximum_prefix_warning_cmd
,
8287 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
8288 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8289 "Maximum number of prefix accept from this peer\n"
8290 "maximum no. of prefix limit\n"
8291 "Only give warning message when limit is exceeded\n"
8292 "Force checking all received routes not only accepted\n")
8297 char base_xpath
[XPATH_MAXLEN
];
8298 char af_xpath
[XPATH_MAXLEN
];
8299 char attr_xpath
[XPATH_MAXLEN
];
8300 afi_t afi
= bgp_node_afi(vty
);
8301 safi_t safi
= bgp_node_safi(vty
);
8303 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8304 yang_afi_safi_value2identity(afi
, safi
));
8305 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8306 sizeof(base_xpath
), af_xpath
)
8308 return CMD_WARNING_CONFIG_FAILED
;
8310 snprintf(attr_xpath
, sizeof(attr_xpath
),
8311 "/%s/prefix-limit/direction-list[direction='in']",
8312 bgp_afi_safi_get_container_str(afi
, safi
));
8313 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8315 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8317 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8318 argv
[idx_number
]->arg
);
8320 nb_cli_enqueue_change(vty
, "./options/warning-only", NB_OP_MODIFY
,
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_warning
,
8331 neighbor_maximum_prefix_warning_hidden_cmd
,
8332 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [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 "Only give warning message when limit is exceeded\n"
8337 "Force checking all received routes not only accepted\n")
8339 DEFUN_YANG(neighbor_maximum_prefix_threshold_warning
,
8340 neighbor_maximum_prefix_threshold_warning_cmd
,
8341 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) 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 "Threshold value (%) at which to generate a warning msg\n"
8346 "Only give warning message when limit is exceeded\n"
8347 "Force checking all received routes not only accepted\n")
8351 int idx_number_2
= 4;
8353 char base_xpath
[XPATH_MAXLEN
];
8354 char af_xpath
[XPATH_MAXLEN
];
8355 char attr_xpath
[XPATH_MAXLEN
];
8356 afi_t afi
= bgp_node_afi(vty
);
8357 safi_t safi
= bgp_node_safi(vty
);
8359 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8360 yang_afi_safi_value2identity(afi
, safi
));
8361 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8362 sizeof(base_xpath
), af_xpath
)
8364 return CMD_WARNING_CONFIG_FAILED
;
8366 snprintf(attr_xpath
, sizeof(attr_xpath
),
8367 "/%s/prefix-limit/direction-list[direction='in']",
8368 bgp_afi_safi_get_container_str(afi
, safi
));
8369 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8371 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8373 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8374 argv
[idx_number
]->arg
);
8375 nb_cli_enqueue_change(vty
, "./options/tw-shutdown-threshold-pct",
8376 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8377 nb_cli_enqueue_change(vty
, "./options/tw-warning-only", NB_OP_MODIFY
,
8379 if (argv_find(argv
, argc
, "force", &idx_force
))
8380 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8383 return nb_cli_apply_changes(vty
, base_xpath
);
8387 neighbor_maximum_prefix_threshold_warning
,
8388 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
8389 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
8390 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8391 "Maximum number of prefix accept from this peer\n"
8392 "maximum no. of prefix limit\n"
8393 "Threshold value (%) at which to generate a warning msg\n"
8394 "Only give warning message when limit is exceeded\n"
8395 "Force checking all received routes not only accepted\n")
8397 DEFUN_YANG(neighbor_maximum_prefix_restart
,
8398 neighbor_maximum_prefix_restart_cmd
,
8399 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8400 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8401 "Maximum number of prefix accept from this peer\n"
8402 "maximum no. of prefix limit\n"
8403 "Restart bgp connection after limit is exceeded\n"
8404 "Restart interval in minutes\n"
8405 "Force checking all received routes not only accepted\n")
8409 int idx_number_2
= 5;
8411 char base_xpath
[XPATH_MAXLEN
];
8412 char af_xpath
[XPATH_MAXLEN
];
8413 char attr_xpath
[XPATH_MAXLEN
];
8414 afi_t afi
= bgp_node_afi(vty
);
8415 safi_t safi
= bgp_node_safi(vty
);
8417 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8418 yang_afi_safi_value2identity(afi
, safi
));
8419 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8420 sizeof(base_xpath
), af_xpath
)
8422 return CMD_WARNING_CONFIG_FAILED
;
8424 snprintf(attr_xpath
, sizeof(attr_xpath
),
8425 "/%s/prefix-limit/direction-list[direction='in']",
8426 bgp_afi_safi_get_container_str(afi
, safi
));
8427 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8429 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8431 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8432 argv
[idx_number
]->arg
);
8433 nb_cli_enqueue_change(vty
, "./options/restart-timer", NB_OP_MODIFY
,
8434 argv
[idx_number_2
]->arg
);
8435 if (argv_find(argv
, argc
, "force", &idx_force
))
8436 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8439 return nb_cli_apply_changes(vty
, base_xpath
);
8443 neighbor_maximum_prefix_restart
,
8444 neighbor_maximum_prefix_restart_hidden_cmd
,
8445 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
8446 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8447 "Maximum number of prefix accept from this peer\n"
8448 "maximum no. of prefix limit\n"
8449 "Restart bgp connection after limit is exceeded\n"
8450 "Restart interval in minutes\n"
8451 "Force checking all received routes not only accepted\n")
8453 DEFUN_YANG(neighbor_maximum_prefix_threshold_restart
,
8454 neighbor_maximum_prefix_threshold_restart_cmd
,
8455 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8456 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8457 "Maximum number of prefixes to accept from this peer\n"
8458 "maximum no. of prefix limit\n"
8459 "Threshold value (%) at which to generate a warning msg\n"
8460 "Restart bgp connection after limit is exceeded\n"
8461 "Restart interval in minutes\n"
8462 "Force checking all received routes not only accepted\n")
8466 int idx_number_2
= 4;
8467 int idx_number_3
= 6;
8469 char base_xpath
[XPATH_MAXLEN
];
8470 char af_xpath
[XPATH_MAXLEN
];
8471 char attr_xpath
[XPATH_MAXLEN
];
8472 afi_t afi
= bgp_node_afi(vty
);
8473 safi_t safi
= bgp_node_safi(vty
);
8475 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8476 yang_afi_safi_value2identity(afi
, safi
));
8477 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8478 sizeof(base_xpath
), af_xpath
)
8480 return CMD_WARNING_CONFIG_FAILED
;
8482 snprintf(attr_xpath
, sizeof(attr_xpath
),
8483 "/%s/prefix-limit/direction-list[direction='in']",
8484 bgp_afi_safi_get_container_str(afi
, safi
));
8485 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8487 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
8489 nb_cli_enqueue_change(vty
, "./max-prefixes", NB_OP_MODIFY
,
8490 argv
[idx_number
]->arg
);
8491 nb_cli_enqueue_change(vty
, "./options/tr-shutdown-threshold-pct",
8492 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
8493 nb_cli_enqueue_change(vty
, "./options/tr-restart-timer", NB_OP_MODIFY
,
8494 argv
[idx_number_3
]->arg
);
8495 if (argv_find(argv
, argc
, "force", &idx_force
))
8496 nb_cli_enqueue_change(vty
, "./force-check", NB_OP_MODIFY
,
8499 return nb_cli_apply_changes(vty
, base_xpath
);
8503 neighbor_maximum_prefix_threshold_restart
,
8504 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
8505 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
8506 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8507 "Maximum number of prefixes to accept from this peer\n"
8508 "maximum no. of prefix limit\n"
8509 "Threshold value (%) at which to generate a warning msg\n"
8510 "Restart bgp connection after limit is exceeded\n"
8511 "Restart interval in minutes\n"
8512 "Force checking all received routes not only accepted\n")
8514 DEFUN_YANG(no_neighbor_maximum_prefix
,
8515 no_neighbor_maximum_prefix_cmd
,
8516 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8517 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8518 "Maximum number of prefixes to accept from this peer\n"
8519 "maximum no. of prefix limit\n"
8520 "Threshold value (%) at which to generate a warning msg\n"
8521 "Restart bgp connection after limit is exceeded\n"
8522 "Restart interval in minutes\n"
8523 "Only give warning message when limit is exceeded\n"
8524 "Force checking all received routes not only accepted\n")
8527 char base_xpath
[XPATH_MAXLEN
];
8528 char af_xpath
[XPATH_MAXLEN
];
8529 char attr_xpath
[XPATH_MAXLEN
];
8530 afi_t afi
= bgp_node_afi(vty
);
8531 safi_t safi
= bgp_node_safi(vty
);
8533 snprintf(af_xpath
, sizeof(af_xpath
), FRR_BGP_AF_XPATH
,
8534 yang_afi_safi_value2identity(afi
, safi
));
8535 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8536 sizeof(base_xpath
), af_xpath
)
8538 return CMD_WARNING_CONFIG_FAILED
;
8540 snprintf(attr_xpath
, sizeof(attr_xpath
),
8541 "/%s/prefix-limit/direction-list[direction='in']",
8542 bgp_afi_safi_get_container_str(afi
, safi
));
8543 strlcat(base_xpath
, attr_xpath
, sizeof(base_xpath
));
8545 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
8547 return nb_cli_apply_changes(vty
, base_xpath
);
8551 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
8552 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
8553 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8554 "Maximum number of prefixes to accept from this peer\n"
8555 "maximum no. of prefix limit\n"
8556 "Threshold value (%) at which to generate a warning msg\n"
8557 "Restart bgp connection after limit is exceeded\n"
8558 "Restart interval in minutes\n"
8559 "Only give warning message when limit is exceeded\n"
8560 "Force checking all received routes not only accepted\n")
8563 /* "neighbor allowas-in" */
8564 DEFUN (neighbor_allowas_in
,
8565 neighbor_allowas_in_cmd
,
8566 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8569 "Accept as-path with my AS present in it\n"
8570 "Number of occurrences of AS number\n"
8571 "Only accept my AS in the as-path if the route was originated in my AS\n")
8574 int idx_number_origin
= 3;
8580 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8582 return CMD_WARNING_CONFIG_FAILED
;
8584 if (argc
<= idx_number_origin
)
8587 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
8590 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
8593 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8596 return bgp_vty_return(vty
, ret
);
8600 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
8601 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8602 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8603 "Accept as-path with my AS present in it\n"
8604 "Number of occurrences of AS number\n"
8605 "Only accept my AS in the as-path if the route was originated in my AS\n")
8607 DEFUN (no_neighbor_allowas_in
,
8608 no_neighbor_allowas_in_cmd
,
8609 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8613 "allow local ASN appears in aspath attribute\n"
8614 "Number of occurrences of AS number\n"
8615 "Only accept my AS in the as-path if the route was originated in my AS\n")
8621 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8623 return CMD_WARNING_CONFIG_FAILED
;
8625 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
8626 bgp_node_safi(vty
));
8628 return bgp_vty_return(vty
, ret
);
8632 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
8633 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
8634 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8635 "allow local ASN appears in aspath attribute\n"
8636 "Number of occurrences of AS number\n"
8637 "Only accept my AS in the as-path if the route was originated in my AS\n")
8639 DEFUN_YANG (neighbor_ttl_security
,
8640 neighbor_ttl_security_cmd
,
8641 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8644 "BGP ttl-security parameters\n"
8645 "Specify the maximum number of hops to the BGP peer\n"
8646 "Number of hops to BGP peer\n")
8650 char base_xpath
[XPATH_MAXLEN
];
8652 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8653 sizeof(base_xpath
), NULL
)
8655 return CMD_WARNING_CONFIG_FAILED
;
8657 nb_cli_enqueue_change(vty
, "./ttl-security", NB_OP_MODIFY
,
8658 argv
[idx_number
]->arg
);
8660 return nb_cli_apply_changes(vty
, base_xpath
);
8663 DEFUN_YANG(no_neighbor_ttl_security
,
8664 no_neighbor_ttl_security_cmd
,
8665 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
8666 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8667 "BGP ttl-security parameters\n"
8668 "Specify the maximum number of hops to the BGP peer\n"
8669 "Number of hops to BGP peer\n")
8672 char base_xpath
[XPATH_MAXLEN
];
8674 if (peer_and_group_lookup_nb(vty
, argv
[idx_peer
]->arg
, base_xpath
,
8675 sizeof(base_xpath
), NULL
)
8677 return CMD_WARNING_CONFIG_FAILED
;
8679 nb_cli_enqueue_change(vty
, "./ttl-security", NB_OP_DESTROY
, NULL
);
8681 return nb_cli_apply_changes(vty
, base_xpath
);
8684 DEFUN (neighbor_addpath_tx_all_paths
,
8685 neighbor_addpath_tx_all_paths_cmd
,
8686 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8689 "Use addpath to advertise all paths to a neighbor\n")
8694 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8696 return CMD_WARNING_CONFIG_FAILED
;
8698 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8703 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
8704 neighbor_addpath_tx_all_paths_hidden_cmd
,
8705 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8706 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8707 "Use addpath to advertise all paths to a neighbor\n")
8709 DEFUN (no_neighbor_addpath_tx_all_paths
,
8710 no_neighbor_addpath_tx_all_paths_cmd
,
8711 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8715 "Use addpath to advertise all paths to a neighbor\n")
8720 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8722 return CMD_WARNING_CONFIG_FAILED
;
8724 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8725 != BGP_ADDPATH_ALL
) {
8727 "%% Peer not currently configured to transmit all paths.");
8728 return CMD_WARNING_CONFIG_FAILED
;
8731 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8737 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
8738 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
8739 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
8740 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8741 "Use addpath to advertise all paths to a neighbor\n")
8743 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
8744 neighbor_addpath_tx_bestpath_per_as_cmd
,
8745 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8748 "Use addpath to advertise the bestpath per each neighboring AS\n")
8753 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8755 return CMD_WARNING_CONFIG_FAILED
;
8757 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8758 BGP_ADDPATH_BEST_PER_AS
);
8763 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
8764 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8765 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8766 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8767 "Use addpath to advertise the bestpath per each neighboring AS\n")
8769 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
8770 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
8771 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8775 "Use addpath to advertise the bestpath per each neighboring AS\n")
8780 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
8782 return CMD_WARNING_CONFIG_FAILED
;
8784 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
8785 != BGP_ADDPATH_BEST_PER_AS
) {
8787 "%% Peer not currently configured to transmit all best path per as.");
8788 return CMD_WARNING_CONFIG_FAILED
;
8791 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8797 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
8798 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
8799 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
8800 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
8801 "Use addpath to advertise the bestpath per each neighboring AS\n")
8804 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
8805 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8808 "Detect AS loops before sending to neighbor\n")
8812 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8814 return CMD_WARNING_CONFIG_FAILED
;
8816 peer
->as_path_loop_detection
= true;
8822 no_neighbor_aspath_loop_detection
,
8823 no_neighbor_aspath_loop_detection_cmd
,
8824 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
8828 "Detect AS loops before sending to neighbor\n")
8832 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8834 return CMD_WARNING_CONFIG_FAILED
;
8836 peer
->as_path_loop_detection
= false;
8841 DEFPY(neighbor_damp
,
8843 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor dampening [(1-45)$half [(1-20000)$reuse (1-20000)$suppress (1-255)$max]]",
8846 "Enable neighbor route-flap dampening\n"
8847 "Half-life time for the penalty\n"
8848 "Value to start reusing a route\n"
8849 "Value to start suppressing a route\n"
8850 "Maximum duration to suppress a stable route\n")
8852 struct peer
*peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8855 return CMD_WARNING_CONFIG_FAILED
;
8857 half
= DEFAULT_HALF_LIFE
;
8859 reuse
= DEFAULT_REUSE
;
8860 suppress
= DEFAULT_SUPPRESS
;
8863 if (suppress
< reuse
) {
8865 "Suppress value cannot be less than reuse value\n");
8866 return CMD_WARNING_CONFIG_FAILED
;
8868 bgp_peer_damp_enable(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
8869 half
* 60, reuse
, suppress
, max
* 60);
8873 DEFPY(no_neighbor_damp
,
8874 no_neighbor_damp_cmd
,
8875 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor dampening [HALF [REUSE SUPPRESS MAX]]",
8879 "Enable neighbor route-flap dampening\n"
8880 "Half-life time for the penalty\n"
8881 "Value to start reusing a route\n"
8882 "Value to start suppressing a route\n"
8883 "Maximum duration to suppress a stable route\n")
8885 struct peer
*peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8888 return CMD_WARNING_CONFIG_FAILED
;
8889 bgp_peer_damp_disable(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
8893 DEFPY (show_ip_bgp_neighbor_damp_param
,
8894 show_ip_bgp_neighbor_damp_param_cmd
,
8895 "show [ip] bgp [<ipv4|ipv6> [unicast]] neighbors <A.B.C.D|X:X::X:X|WORD>$neighbor dampening parameters [json]$json",
8900 "Address Family modifier\n"
8903 "Neighbor route-flap dampening information\n"
8904 "Display detail of configured dampening parameters\n"
8907 bool use_json
= false;
8910 safi_t safi
= SAFI_UNICAST
;
8913 if (argv_find(argv
, argc
, "ip", &idx
))
8915 if (argv_find(argv
, argc
, "ipv4", &idx
))
8917 if (argv_find(argv
, argc
, "ipv6", &idx
))
8919 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
8924 bgp_show_peer_dampening_parameters(vty
, peer
, afi
, safi
, use_json
);
8928 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
8929 struct ecommunity
**list
, bool is_rt6
)
8931 struct ecommunity
*ecom
= NULL
;
8932 struct ecommunity
*ecomadd
;
8934 for (; argc
; --argc
, ++argv
) {
8936 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
8937 ECOMMUNITY_ROUTE_TARGET
,
8940 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
8941 ECOMMUNITY_ROUTE_TARGET
,
8944 vty_out(vty
, "Malformed community-list value\n");
8946 ecommunity_free(&ecom
);
8947 return CMD_WARNING_CONFIG_FAILED
;
8951 ecommunity_merge(ecom
, ecomadd
);
8952 ecommunity_free(&ecomadd
);
8959 ecommunity_free(&*list
);
8966 bool vpn_policy_check_import(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
8967 bool v2vimport
, char *errmsg
, size_t errmsg_len
)
8970 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8971 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
8972 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8973 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
8975 errmsg
, errmsg_len
, "%s",
8976 "%% error: Please unconfigure import vrf commands before using vpn commands");
8980 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8981 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
8982 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8983 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
8985 errmsg
, errmsg_len
, "%s",
8986 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands");
8994 * v2vimport is true if we are handling a `import vrf ...` command
8996 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
9000 switch (vty
->node
) {
9009 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
9014 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9015 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
9016 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9017 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
9019 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
9023 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9024 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
9025 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9026 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
9028 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
9037 af_rd_vpn_export_cmd
,
9038 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
9040 "Specify route distinguisher\n"
9041 "Between current address-family and vpn\n"
9042 "For routes leaked from current address-family to vpn\n"
9043 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
9045 char base_xpath
[XPATH_MAXLEN
];
9050 afi
= bgp_node_afi(vty
);
9051 safi
= bgp_node_safi(vty
);
9054 base_xpath
, sizeof(base_xpath
),
9055 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9056 yang_afi_safi_value2identity(afi
, safi
),
9057 bgp_afi_safi_get_container_str(afi
, safi
));
9059 if (argv_find(argv
, argc
, "no", &idx
))
9060 nb_cli_enqueue_change(vty
, "./rd", NB_OP_DESTROY
, NULL
);
9062 nb_cli_enqueue_change(vty
, "./rd", NB_OP_MODIFY
, rd_str
);
9064 return nb_cli_apply_changes(vty
, base_xpath
);
9067 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rd(
9068 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9072 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
9073 yang_dnode_get_string(dnode
, NULL
));
9076 ALIAS (af_rd_vpn_export
,
9077 af_no_rd_vpn_export_cmd
,
9080 "Specify route distinguisher\n"
9081 "Between current address-family and vpn\n"
9082 "For routes leaked from current address-family to vpn\n")
9084 DEFPY (af_label_vpn_export
,
9085 af_label_vpn_export_cmd
,
9086 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
9088 "label value for VRF\n"
9089 "Between current address-family and vpn\n"
9090 "For routes leaked from current address-family to vpn\n"
9091 "Label Value <0-1048575>\n"
9092 "Automatically assign a label\n")
9094 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9095 mpls_label_t label
= MPLS_LABEL_NONE
;
9100 if (argv_find(argv
, argc
, "no", &idx
))
9103 /* If "no ...", squash trailing parameter */
9109 label
= label_val
; /* parser should force unsigned */
9112 afi
= vpn_policy_getafi(vty
, bgp
, false);
9114 return CMD_WARNING_CONFIG_FAILED
;
9117 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9118 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
9123 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
9125 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9126 bgp_get_default(), bgp
);
9128 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
9129 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
9131 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
9134 * label has previously been automatically
9135 * assigned by labelpool: release it
9137 * NB if tovpn_label == MPLS_LABEL_NONE it
9138 * means the automatic assignment is in flight
9139 * and therefore the labelpool callback must
9140 * detect that the auto label is not needed.
9143 bgp_lp_release(LP_TYPE_VRF
,
9144 &bgp
->vpn_policy
[afi
],
9145 bgp
->vpn_policy
[afi
].tovpn_label
);
9147 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9148 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9151 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
9153 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
9154 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
9155 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
9156 vpn_leak_label_callback
);
9159 /* post-change: re-export vpn routes */
9160 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
9161 bgp_get_default(), bgp
);
9163 hook_call(bgp_snmp_update_last_changed
, bgp
);
9167 ALIAS (af_label_vpn_export
,
9168 af_no_label_vpn_export_cmd
,
9169 "no label vpn export",
9171 "label value for VRF\n"
9172 "Between current address-family and vpn\n"
9173 "For routes leaked from current address-family to vpn\n")
9175 DEFPY_YANG (af_nexthop_vpn_export
,
9176 af_nexthop_vpn_export_cmd
,
9177 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
9179 "Specify next hop to use for VRF advertised prefixes\n"
9180 "Between current address-family and vpn\n"
9181 "For routes leaked from current address-family to vpn\n"
9185 char base_xpath
[XPATH_MAXLEN
];
9193 vty_out(vty
, "%% Nexthop required\n");
9194 return CMD_WARNING_CONFIG_FAILED
;
9196 if (!sockunion2hostprefix(nexthop_su
, &p
))
9197 return CMD_WARNING_CONFIG_FAILED
;
9200 afi
= bgp_node_afi(vty
);
9201 safi
= bgp_node_safi(vty
);
9204 base_xpath
, sizeof(base_xpath
),
9205 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9206 yang_afi_safi_value2identity(afi
, safi
),
9207 bgp_afi_safi_get_container_str(afi
, safi
));
9209 if (argv_find(argv
, argc
, "no", &idx
))
9210 nb_cli_enqueue_change(vty
, "./nexthop", NB_OP_DESTROY
, NULL
);
9212 nb_cli_enqueue_change(vty
, "./nexthop", NB_OP_MODIFY
,
9215 return nb_cli_apply_changes(vty
, base_xpath
);
9218 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_nexthop(
9219 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9223 vty_out(vty
, "%*snexthop vpn export %s\n", indent
, "",
9224 yang_dnode_get_string(dnode
, NULL
));
9227 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
9229 if (!strcmp(dstr
, "import")) {
9230 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9231 } else if (!strcmp(dstr
, "export")) {
9232 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9233 } else if (!strcmp(dstr
, "both")) {
9234 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
9235 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
9237 vty_out(vty
, "%% direction parse error\n");
9238 return CMD_WARNING_CONFIG_FAILED
;
9243 DEFPY (af_rt_vpn_imexport
,
9244 af_rt_vpn_imexport_cmd
,
9245 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
9247 "Specify route target list\n"
9248 "Specify route target list\n"
9249 "Between current address-family and vpn\n"
9250 "For routes leaked from vpn to current address-family: match any\n"
9251 "For routes leaked from current address-family to vpn: set\n"
9252 "both import: match any and export: set\n"
9253 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
9255 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9257 struct ecommunity
*ecom
= NULL
;
9258 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
9259 vpn_policy_direction_t dir
;
9264 if (argv_find(argv
, argc
, "no", &idx
))
9267 afi
= vpn_policy_getafi(vty
, bgp
, false);
9269 return CMD_WARNING_CONFIG_FAILED
;
9271 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
9272 if (ret
!= CMD_SUCCESS
)
9276 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9277 vty_out(vty
, "%% Missing RTLIST\n");
9278 return CMD_WARNING_CONFIG_FAILED
;
9280 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
9281 if (ret
!= CMD_SUCCESS
) {
9286 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
9290 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9293 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9295 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9296 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
9297 ecommunity_dup(ecom
);
9299 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
9301 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
9302 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
9305 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9309 ecommunity_free(&ecom
);
9314 ALIAS (af_rt_vpn_imexport
,
9315 af_no_rt_vpn_imexport_cmd
,
9316 "no <rt|route-target> vpn <import|export|both>$direction_str",
9318 "Specify route target list\n"
9319 "Specify route target list\n"
9320 "Between current address-family and vpn\n"
9321 "For routes leaked from vpn to current address-family\n"
9322 "For routes leaked from current address-family to vpn\n"
9323 "both import and export\n")
9325 DEFPY_YANG (af_route_map_vpn_imexport
,
9326 af_route_map_vpn_imexport_cmd
,
9327 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
9328 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
9330 "Specify route map\n"
9331 "Between current address-family and vpn\n"
9332 "For routes leaked from vpn to current address-family\n"
9333 "For routes leaked from current address-family to vpn\n"
9334 "name of route-map\n")
9336 char base_xpath
[XPATH_MAXLEN
];
9341 afi
= bgp_node_afi(vty
);
9342 safi
= bgp_node_safi(vty
);
9345 base_xpath
, sizeof(base_xpath
),
9346 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config",
9347 yang_afi_safi_value2identity(afi
, safi
),
9348 bgp_afi_safi_get_container_str(afi
, safi
));
9350 if (argv_find(argv
, argc
, "no", &idx
)) {
9351 if (!strcmp(direction_str
, "import"))
9352 nb_cli_enqueue_change(vty
, "./rmap-import",
9353 NB_OP_DESTROY
, NULL
);
9354 else if (!strcmp(direction_str
, "export"))
9355 nb_cli_enqueue_change(vty
, "./rmap-export",
9356 NB_OP_DESTROY
, NULL
);
9358 if (!strcmp(direction_str
, "import"))
9359 nb_cli_enqueue_change(vty
, "./rmap-import",
9360 NB_OP_MODIFY
, rmap_str
);
9361 if (!strcmp(direction_str
, "export"))
9362 nb_cli_enqueue_change(vty
, "./rmap-export",
9363 NB_OP_MODIFY
, rmap_str
);
9365 return nb_cli_apply_changes(vty
, base_xpath
);
9368 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_import(
9369 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9373 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
9374 yang_dnode_get_string(dnode
, NULL
));
9377 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_rmap_export(
9378 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9382 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
9383 yang_dnode_get_string(dnode
, NULL
));
9386 ALIAS (af_route_map_vpn_imexport
,
9387 af_no_route_map_vpn_imexport_cmd
,
9388 "no route-map vpn <import|export>$direction_str",
9390 "Specify route map\n"
9391 "Between current address-family and vpn\n"
9392 "For routes leaked from vpn to current address-family\n"
9393 "For routes leaked from current address-family to vpn\n")
9395 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
9396 "import vrf route-map RMAP$rmap_str",
9397 "Import routes from another VRF\n"
9398 "Vrf routes being filtered\n"
9399 "Specify route map\n"
9400 "name of route-map\n")
9402 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9403 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9405 struct bgp
*bgp_default
;
9407 afi
= vpn_policy_getafi(vty
, bgp
, true);
9409 return CMD_WARNING_CONFIG_FAILED
;
9411 bgp_default
= bgp_get_default();
9416 /* Auto-create assuming the same AS */
9417 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
9418 BGP_INSTANCE_TYPE_DEFAULT
);
9422 "VRF default is not configured as a bgp instance\n");
9427 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9429 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9430 XFREE(MTYPE_ROUTE_MAP_NAME
,
9431 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9432 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
9433 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
9434 bgp
->vpn_policy
[afi
].rmap
[dir
] =
9435 route_map_lookup_warn_noexist(vty
, rmap_str
);
9436 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
9439 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9440 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9442 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9447 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
9448 "no import vrf route-map [RMAP$rmap_str]",
9450 "Import routes from another VRF\n"
9451 "Vrf routes being filtered\n"
9452 "Specify route map\n"
9453 "name of route-map\n")
9455 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9456 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
9459 afi
= vpn_policy_getafi(vty
, bgp
, true);
9461 return CMD_WARNING_CONFIG_FAILED
;
9463 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
9465 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
9466 XFREE(MTYPE_ROUTE_MAP_NAME
,
9467 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
9468 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
9469 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
9471 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
9472 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
9473 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
9475 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
9480 DEFPY_YANG(bgp_imexport_vrf
,
9481 bgp_imexport_vrf_cmd
,
9482 "[no] import vrf VIEWVRFNAME$import_name",
9484 "Import routes from another VRF\n"
9485 "VRF to import from\n"
9486 "The name of the VRF\n")
9488 char base_xpath
[XPATH_MAXLEN
];
9493 if (import_name
== NULL
) {
9494 vty_out(vty
, "%% Missing import name\n");
9498 if (strcmp(import_name
, "route-map") == 0) {
9499 vty_out(vty
, "%% Must include route-map name\n");
9503 afi
= bgp_node_afi(vty
);
9504 safi
= bgp_node_safi(vty
);
9507 base_xpath
, sizeof(base_xpath
),
9508 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vrf-list[vrf='%s']",
9509 yang_afi_safi_value2identity(afi
, safi
),
9510 bgp_afi_safi_get_container_str(afi
, safi
), import_name
);
9512 if (argv_find(argv
, argc
, "no", &idx
))
9513 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
9515 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
9517 return nb_cli_apply_changes(vty
, base_xpath
);
9520 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vrfs(
9521 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9523 vty_out(vty
, " import vrf %s\n",
9524 yang_dnode_get_string(dnode
, "./vrf"));
9527 /* This command is valid only in a bgp vrf instance or the default instance */
9528 DEFPY_YANG (bgp_imexport_vpn
,
9529 bgp_imexport_vpn_cmd
,
9530 "[no] <import|export>$direction_str vpn",
9532 "Import routes to this address-family\n"
9533 "Export routes from this address-family\n"
9534 "to/from default instance VPN RIB\n")
9536 char base_xpath
[XPATH_MAXLEN
];
9541 afi
= bgp_node_afi(vty
);
9542 safi
= bgp_node_safi(vty
);
9544 if (!strcmp(direction_str
, "import")) {
9546 base_xpath
, sizeof(base_xpath
),
9547 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/import-vpn",
9548 yang_afi_safi_value2identity(afi
, safi
),
9549 bgp_afi_safi_get_container_str(afi
, safi
));
9550 } else if (!strcmp(direction_str
, "export")) {
9552 base_xpath
, sizeof(base_xpath
),
9553 "./global/afi-safis/afi-safi[afi-safi-name='%s']/%s/vpn-config/export-vpn",
9554 yang_afi_safi_value2identity(afi
, safi
),
9555 bgp_afi_safi_get_container_str(afi
, safi
));
9557 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
9558 return CMD_WARNING_CONFIG_FAILED
;
9561 if (argv_find(argv
, argc
, "no", &idx
))
9562 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
9564 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, "true");
9566 return nb_cli_apply_changes(vty
, base_xpath
);
9569 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_import_vpn(
9570 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9572 if (yang_dnode_get_bool(dnode
, NULL
))
9573 vty_out(vty
, " import vpn\n");
9576 void cli_show_bgp_global_afi_safi_ip_unicast_vpn_config_export_vpn(
9577 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
9579 if (yang_dnode_get_bool(dnode
, NULL
))
9580 vty_out(vty
, " export vpn\n");
9583 DEFPY (af_routetarget_import
,
9584 af_routetarget_import_cmd
,
9585 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
9587 "Specify route target list\n"
9588 "Specify route target list\n"
9589 "Specify route target list\n"
9590 "Specify route target list\n"
9591 "Flow-spec redirect type route target\n"
9592 "Import routes to this address-family\n"
9593 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
9595 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9597 struct ecommunity
*ecom
= NULL
;
9599 int idx
= 0, idx_unused
= 0;
9603 if (argv_find(argv
, argc
, "no", &idx
))
9606 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
9607 argv_find(argv
, argc
, "route-target6", &idx_unused
))
9610 afi
= vpn_policy_getafi(vty
, bgp
, false);
9612 return CMD_WARNING_CONFIG_FAILED
;
9614 if (rt6
&& afi
!= AFI_IP6
)
9615 return CMD_WARNING_CONFIG_FAILED
;
9618 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
9619 vty_out(vty
, "%% Missing RTLIST\n");
9620 return CMD_WARNING_CONFIG_FAILED
;
9622 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
9623 if (ret
!= CMD_SUCCESS
)
9628 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9629 ecommunity_free(&bgp
->vpn_policy
[afi
]
9630 .import_redirect_rtlist
);
9631 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
9632 ecommunity_dup(ecom
);
9634 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
9635 ecommunity_free(&bgp
->vpn_policy
[afi
]
9636 .import_redirect_rtlist
);
9637 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
9641 ecommunity_free(&ecom
);
9646 void cli_show_bgp_global_afi_safi_header(struct vty
*vty
,
9647 struct lyd_node
*dnode
,
9650 const char *af_name
;
9654 af_name
= yang_dnode_get_string(dnode
, "./afi-safi-name");
9655 yang_afi_safi_identity2value(af_name
, &afi
, &safi
);
9657 vty_out(vty
, " !\n address-family ");
9658 if (afi
== AFI_IP
) {
9659 if (safi
== SAFI_UNICAST
)
9660 vty_out(vty
, "ipv4 unicast");
9661 else if (safi
== SAFI_LABELED_UNICAST
)
9662 vty_out(vty
, "ipv4 labeled-unicast");
9663 else if (safi
== SAFI_MULTICAST
)
9664 vty_out(vty
, "ipv4 multicast");
9665 else if (safi
== SAFI_MPLS_VPN
)
9666 vty_out(vty
, "ipv4 vpn");
9667 else if (safi
== SAFI_ENCAP
)
9668 vty_out(vty
, "ipv4 encap");
9669 else if (safi
== SAFI_FLOWSPEC
)
9670 vty_out(vty
, "ipv4 flowspec");
9671 } else if (afi
== AFI_IP6
) {
9672 if (safi
== SAFI_UNICAST
)
9673 vty_out(vty
, "ipv6 unicast");
9674 else if (safi
== SAFI_LABELED_UNICAST
)
9675 vty_out(vty
, "ipv6 labeled-unicast");
9676 else if (safi
== SAFI_MULTICAST
)
9677 vty_out(vty
, "ipv6 multicast");
9678 else if (safi
== SAFI_MPLS_VPN
)
9679 vty_out(vty
, "ipv6 vpn");
9680 else if (safi
== SAFI_ENCAP
)
9681 vty_out(vty
, "ipv6 encap");
9682 else if (safi
== SAFI_FLOWSPEC
)
9683 vty_out(vty
, "ipv6 flowspec");
9684 } else if (afi
== AFI_L2VPN
) {
9685 if (safi
== SAFI_EVPN
)
9686 vty_out(vty
, "l2vpn evpn");
9691 DEFUN_NOSH (address_family_ipv4_safi
,
9692 address_family_ipv4_safi_cmd
,
9693 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9694 "Enter Address Family command mode\n"
9696 BGP_SAFI_WITH_LABEL_HELP_STR
)
9699 safi_t safi
= SAFI_UNICAST
;
9700 const struct lyd_node
*vrf_dnode
, *bgp_glb_dnode
;
9701 const char *vrf_name
= NULL
;
9704 safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9706 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
9708 vrf_dnode
= yang_dnode_get_parent(bgp_glb_dnode
,
9709 "control-plane-protocol");
9710 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
9712 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
)
9713 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9714 && safi
!= SAFI_EVPN
) {
9716 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9717 return CMD_WARNING_CONFIG_FAILED
;
9720 vty
->node
= bgp_node_type(AFI_IP
, safi
);
9725 DEFUN_NOSH (address_family_ipv6_safi
,
9726 address_family_ipv6_safi_cmd
,
9727 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
9728 "Enter Address Family command mode\n"
9730 BGP_SAFI_WITH_LABEL_HELP_STR
)
9732 safi_t safi
= SAFI_UNICAST
;
9733 const struct lyd_node
*vrf_dnode
, *bgp_glb_dnode
;
9734 const char *vrf_name
= NULL
;
9737 safi
= bgp_vty_safi_from_str(argv
[2]->text
);
9738 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
9740 vrf_dnode
= yang_dnode_get_parent(bgp_glb_dnode
,
9741 "control-plane-protocol");
9742 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
9744 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
)
9745 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
9746 && safi
!= SAFI_EVPN
) {
9748 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
9749 return CMD_WARNING_CONFIG_FAILED
;
9752 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
9757 #ifdef KEEP_OLD_VPN_COMMANDS
9758 DEFUN_NOSH (address_family_vpnv4
,
9759 address_family_vpnv4_cmd
,
9760 "address-family vpnv4 [unicast]",
9761 "Enter Address Family command mode\n"
9763 "Address Family modifier\n")
9765 vty
->node
= BGP_VPNV4_NODE
;
9769 DEFUN_NOSH (address_family_vpnv6
,
9770 address_family_vpnv6_cmd
,
9771 "address-family vpnv6 [unicast]",
9772 "Enter Address Family command mode\n"
9774 "Address Family modifier\n")
9776 vty
->node
= BGP_VPNV6_NODE
;
9779 #endif /* KEEP_OLD_VPN_COMMANDS */
9781 DEFUN_NOSH (address_family_evpn
,
9782 address_family_evpn_cmd
,
9783 "address-family l2vpn evpn",
9784 "Enter Address Family command mode\n"
9786 "Address Family modifier\n")
9788 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
9789 vty
->node
= BGP_EVPN_NODE
;
9793 DEFUN_NOSH (exit_address_family
,
9794 exit_address_family_cmd
,
9795 "exit-address-family",
9796 "Exit from Address Family configuration mode\n")
9798 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
9799 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
9800 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
9801 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
9802 || vty
->node
== BGP_EVPN_NODE
9803 || vty
->node
== BGP_FLOWSPECV4_NODE
9804 || vty
->node
== BGP_FLOWSPECV6_NODE
)
9805 vty
->node
= BGP_NODE
;
9809 void cli_show_bgp_global_afi_safi_header_end(struct vty
*vty
,
9810 struct lyd_node
*dnode
9811 __attribute__((__unused__
)))
9813 vty_out(vty
, " exit-address-family\n");
9816 /* Recalculate bestpath and re-advertise a prefix */
9817 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
9818 const char *ip_str
, afi_t afi
, safi_t safi
,
9819 struct prefix_rd
*prd
)
9822 struct prefix match
;
9823 struct bgp_dest
*dest
;
9824 struct bgp_dest
*rm
;
9826 struct bgp_table
*table
;
9827 struct bgp_table
*rib
;
9829 /* BGP structure lookup. */
9831 bgp
= bgp_lookup_by_name(view_name
);
9833 vty_out(vty
, "%% Can't find BGP instance %s\n",
9838 bgp
= bgp_get_default();
9840 vty_out(vty
, "%% No BGP process is configured\n");
9845 /* Check IP address argument. */
9846 ret
= str2prefix(ip_str
, &match
);
9848 vty_out(vty
, "%% address is malformed\n");
9852 match
.family
= afi2family(afi
);
9853 rib
= bgp
->rib
[afi
][safi
];
9855 if (safi
== SAFI_MPLS_VPN
) {
9856 for (dest
= bgp_table_top(rib
); dest
;
9857 dest
= bgp_route_next(dest
)) {
9858 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9860 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
9863 table
= bgp_dest_get_bgp_table_info(dest
);
9867 if ((rm
= bgp_node_match(table
, &match
)) != NULL
) {
9868 const struct prefix
*rm_p
=
9869 bgp_dest_get_prefix(rm
);
9871 if (rm_p
->prefixlen
== match
.prefixlen
) {
9873 BGP_NODE_USER_CLEAR
);
9874 bgp_process(bgp
, rm
, afi
, safi
);
9876 bgp_dest_unlock_node(rm
);
9880 if ((dest
= bgp_node_match(rib
, &match
)) != NULL
) {
9881 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
9883 if (dest_p
->prefixlen
== match
.prefixlen
) {
9884 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
9885 bgp_process(bgp
, dest
, afi
, safi
);
9887 bgp_dest_unlock_node(dest
);
9894 /* one clear bgp command to rule them all */
9895 DEFUN (clear_ip_bgp_all
,
9896 clear_ip_bgp_all_cmd
,
9897 "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>]",
9901 BGP_INSTANCE_HELP_STR
9904 BGP_SAFI_WITH_LABEL_HELP_STR
9905 "Address Family modifier\n"
9907 "BGP IPv4 neighbor to clear\n"
9908 "BGP IPv6 neighbor to clear\n"
9909 "BGP neighbor on interface to clear\n"
9910 "Clear peers with the AS number\n"
9911 "Clear all external peers\n"
9912 "Clear all members of peer-group\n"
9913 "BGP peer-group name\n"
9918 "Push out prefix-list ORF and do inbound soft reconfig\n"
9923 afi_t afi
= AFI_UNSPEC
;
9924 safi_t safi
= SAFI_UNSPEC
;
9925 enum clear_sort clr_sort
= clear_peer
;
9926 enum bgp_clear_type clr_type
;
9927 char *clr_arg
= NULL
;
9930 char errmsg
[BUFSIZ
] = {'\0'};
9933 /* clear [ip] bgp */
9934 if (argv_find(argv
, argc
, "ip", &idx
))
9937 /* [<vrf> VIEWVRFNAME] */
9938 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9939 vrf
= argv
[idx
+ 1]->arg
;
9941 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9943 } else if (argv_find(argv
, argc
, "view", &idx
)) {
9944 /* [<view> VIEWVRFNAME] */
9945 vrf
= argv
[idx
+ 1]->arg
;
9948 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9949 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
9950 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
9952 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
9953 if (argv_find(argv
, argc
, "*", &idx
)) {
9954 clr_sort
= clear_all
;
9955 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
9956 clr_sort
= clear_peer
;
9957 clr_arg
= argv
[idx
]->arg
;
9958 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
9959 clr_sort
= clear_peer
;
9960 clr_arg
= argv
[idx
]->arg
;
9961 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
9962 clr_sort
= clear_group
;
9964 clr_arg
= argv
[idx
]->arg
;
9965 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
9966 clr_sort
= clear_peer
;
9967 clr_arg
= argv
[idx
]->arg
;
9968 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
9969 clr_sort
= clear_peer
;
9970 clr_arg
= argv
[idx
]->arg
;
9971 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
9972 clr_sort
= clear_as
;
9973 clr_arg
= argv
[idx
]->arg
;
9974 } else if (argv_find(argv
, argc
, "external", &idx
)) {
9975 clr_sort
= clear_external
;
9978 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
9979 if (argv_find(argv
, argc
, "soft", &idx
)) {
9980 if (argv_find(argv
, argc
, "in", &idx
)
9981 || argv_find(argv
, argc
, "out", &idx
))
9982 clr_type
= strmatch(argv
[idx
]->text
, "in")
9984 : BGP_CLEAR_SOFT_OUT
;
9986 clr_type
= BGP_CLEAR_SOFT_BOTH
;
9987 } else if (argv_find(argv
, argc
, "in", &idx
)) {
9988 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
9989 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
9990 : BGP_CLEAR_SOFT_IN
;
9991 } else if (argv_find(argv
, argc
, "out", &idx
)) {
9992 clr_type
= BGP_CLEAR_SOFT_OUT
;
9994 clr_type
= BGP_CLEAR_SOFT_NONE
;
9996 ret
= bgp_clear_vty(vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
, errmsg
,
9999 vty_out(vty
, "Error description: %s\n", errmsg
);
10004 DEFUN (clear_ip_bgp_prefix
,
10005 clear_ip_bgp_prefix_cmd
,
10006 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
10010 BGP_INSTANCE_HELP_STR
10011 "Clear bestpath and re-advertise\n"
10015 char *prefix
= NULL
;
10019 /* [<view|vrf> VIEWVRFNAME] */
10020 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10021 vrf
= argv
[idx
+ 1]->arg
;
10023 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10025 } else if (argv_find(argv
, argc
, "view", &idx
)) {
10026 /* [<view> VIEWVRFNAME] */
10027 vrf
= argv
[idx
+ 1]->arg
;
10031 prefix
= argv
[argc
- 1]->arg
;
10033 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
10036 DEFUN (clear_bgp_ipv6_safi_prefix
,
10037 clear_bgp_ipv6_safi_prefix_cmd
,
10038 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10044 "Clear bestpath and re-advertise\n"
10048 int idx_ipv6_prefix
= 0;
10049 safi_t safi
= SAFI_UNICAST
;
10050 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10051 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10053 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10054 return bgp_clear_prefix(
10055 vty
, NULL
, prefix
, AFI_IP6
,
10059 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
10060 clear_bgp_instance_ipv6_safi_prefix_cmd
,
10061 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
10065 BGP_INSTANCE_HELP_STR
10068 "Clear bestpath and re-advertise\n"
10072 int idx_vrfview
= 0;
10073 int idx_ipv6_prefix
= 0;
10074 safi_t safi
= SAFI_UNICAST
;
10075 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
10076 argv
[idx_ipv6_prefix
]->arg
: NULL
;
10077 char *vrfview
= NULL
;
10079 /* [<view|vrf> VIEWVRFNAME] */
10080 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
10081 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10082 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
10084 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
10085 /* [<view> VIEWVRFNAME] */
10086 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
10088 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
10090 return bgp_clear_prefix(
10091 vty
, vrfview
, prefix
,
10092 AFI_IP6
, safi
, NULL
);
10095 DEFUN (show_bgp_views
,
10096 show_bgp_views_cmd
,
10097 "show [ip] bgp views",
10101 "Show the defined BGP views\n")
10103 struct list
*inst
= bm
->bgp
;
10104 struct listnode
*node
;
10107 vty_out(vty
, "Defined BGP views:\n");
10108 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10110 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
10112 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
10116 return CMD_SUCCESS
;
10119 DEFUN (show_bgp_vrfs
,
10121 "show [ip] bgp vrfs [json]",
10128 char buf
[ETHER_ADDR_STRLEN
];
10129 struct list
*inst
= bm
->bgp
;
10130 struct listnode
*node
;
10132 bool uj
= use_json(argc
, argv
);
10133 json_object
*json
= NULL
;
10134 json_object
*json_vrfs
= NULL
;
10138 json
= json_object_new_object();
10139 json_vrfs
= json_object_new_object();
10142 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
10143 const char *name
, *type
;
10145 struct listnode
*node2
, *nnode2
;
10146 int peers_cfg
, peers_estb
;
10147 json_object
*json_vrf
= NULL
;
10150 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
10154 if (!uj
&& count
== 1) {
10156 "%4s %-5s %-16s %9s %10s %-37s\n",
10157 "Type", "Id", "routerId", "#PeersCfg",
10158 "#PeersEstb", "Name");
10159 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
10160 "L3-VNI", "RouterMAC", "Interface");
10163 peers_cfg
= peers_estb
= 0;
10165 json_vrf
= json_object_new_object();
10168 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
10169 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10172 if (peer
->status
== Established
)
10176 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
10177 name
= VRF_DEFAULT_NAME
;
10186 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10188 : (int64_t)bgp
->vrf_id
;
10189 char buf
[BUFSIZ
] = {0};
10191 json_object_string_add(json_vrf
, "type", type
);
10192 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
10193 json_object_string_add(json_vrf
, "routerId",
10195 &bgp
->router_id
, buf
,
10197 json_object_int_add(json_vrf
, "numConfiguredPeers",
10199 json_object_int_add(json_vrf
, "numEstablishedPeers",
10202 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
10203 json_object_string_add(
10205 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
10206 json_object_string_add(json_vrf
, "interface",
10207 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10209 json_object_object_add(json_vrfs
, name
, json_vrf
);
10211 vty_out(vty
, "%4s %-5d %-16pI4 %-9u %-10u %-37s\n",
10213 bgp
->vrf_id
== VRF_UNKNOWN
? -1
10214 : (int)bgp
->vrf_id
,
10215 &bgp
->router_id
, peers_cfg
, peers_estb
, name
);
10216 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
10218 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
10219 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
10225 json_object_object_add(json
, "vrfs", json_vrfs
);
10227 json_object_int_add(json
, "totalVrfs", count
);
10229 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10230 json
, JSON_C_TO_STRING_PRETTY
));
10231 json_object_free(json
);
10235 "\nTotal number of VRFs (including default): %d\n",
10239 return CMD_SUCCESS
;
10242 DEFUN (show_bgp_mac_hash
,
10243 show_bgp_mac_hash_cmd
,
10244 "show bgp mac hash",
10248 "Mac Address database\n")
10250 bgp_mac_dump_table(vty
);
10252 return CMD_SUCCESS
;
10255 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
10257 struct vty
*vty
= (struct vty
*)args
;
10258 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
10260 vty_out(vty
, "addr: %pI4, count: %d\n", &tip
->addr
, tip
->refcnt
);
10263 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
10265 vty_out(vty
, "self nexthop database:\n");
10266 bgp_nexthop_show_address_hash(vty
, bgp
);
10268 vty_out(vty
, "Tunnel-ip database:\n");
10269 hash_iterate(bgp
->tip_hash
,
10270 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
10274 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
10275 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
10276 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
10277 "martian next-hops\n"
10278 "martian next-hop database\n")
10280 struct bgp
*bgp
= NULL
;
10284 /* [<vrf> VIEWVRFNAME] */
10285 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10286 name
= argv
[idx
+ 1]->arg
;
10287 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
10289 } else if (argv_find(argv
, argc
, "view", &idx
))
10290 /* [<view> VIEWVRFNAME] */
10291 name
= argv
[idx
+ 1]->arg
;
10293 bgp
= bgp_lookup_by_name(name
);
10295 bgp
= bgp_get_default();
10298 vty_out(vty
, "%% No BGP process is configured\n");
10299 return CMD_WARNING
;
10301 bgp_show_martian_nexthops(vty
, bgp
);
10303 return CMD_SUCCESS
;
10306 DEFUN (show_bgp_memory
,
10307 show_bgp_memory_cmd
,
10308 "show [ip] bgp memory",
10312 "Global BGP memory statistics\n")
10314 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10315 unsigned long count
;
10317 /* RIB related usage stats */
10318 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
10319 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
10320 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10321 count
* sizeof(struct bgp_dest
)));
10323 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
10324 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
10325 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10326 count
* sizeof(struct bgp_path_info
)));
10327 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
10328 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
10331 memstrbuf
, sizeof(memstrbuf
),
10332 count
* sizeof(struct bgp_path_info_extra
)));
10334 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
10335 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
10336 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10337 count
* sizeof(struct bgp_static
)));
10339 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
10340 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
10341 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10342 count
* sizeof(struct bpacket
)));
10345 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
10346 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
10347 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10348 count
* sizeof(struct bgp_adj_in
)));
10349 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
10350 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
10351 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10352 count
* sizeof(struct bgp_adj_out
)));
10354 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
10355 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
10357 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10358 count
* sizeof(struct bgp_nexthop_cache
)));
10360 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
10361 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
10363 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10364 count
* sizeof(struct bgp_damp_info
)));
10367 count
= attr_count();
10368 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
10369 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10370 count
* sizeof(struct attr
)));
10372 if ((count
= attr_unknown_count()))
10373 vty_out(vty
, "%ld unknown attributes\n", count
);
10375 /* AS_PATH attributes */
10376 count
= aspath_count();
10377 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
10378 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10379 count
* sizeof(struct aspath
)));
10381 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
10382 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
10383 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10384 count
* sizeof(struct assegment
)));
10386 /* Other attributes */
10387 if ((count
= community_count()))
10388 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10389 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10390 count
* sizeof(struct community
)));
10391 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
10392 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
10393 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10394 count
* sizeof(struct ecommunity
)));
10395 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
10397 "%ld BGP large-community entries, using %s of memory\n",
10398 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10399 count
* sizeof(struct lcommunity
)));
10401 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
10402 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
10403 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10404 count
* sizeof(struct cluster_list
)));
10406 /* Peer related usage */
10407 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
10408 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
10409 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10410 count
* sizeof(struct peer
)));
10412 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
10413 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
10414 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10415 count
* sizeof(struct peer_group
)));
10418 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
10419 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
10420 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
10421 count
* sizeof(regex_t
)));
10422 return CMD_SUCCESS
;
10425 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
10427 json_object
*bestpath
= json_object_new_object();
10429 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
10430 json_object_string_add(bestpath
, "asPath", "ignore");
10432 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
10433 json_object_string_add(bestpath
, "asPath", "confed");
10435 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
10436 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
10437 json_object_string_add(bestpath
, "multiPathRelax",
10440 json_object_string_add(bestpath
, "multiPathRelax",
10443 json_object_string_add(bestpath
, "multiPathRelax", "false");
10445 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
10446 json_object_string_add(bestpath
, "compareRouterId", "true");
10447 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
10448 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
10449 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
10450 json_object_string_add(bestpath
, "med", "confed");
10451 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
10452 json_object_string_add(bestpath
, "med",
10453 "missing-as-worst");
10455 json_object_string_add(bestpath
, "med", "true");
10458 json_object_object_add(json
, "bestPath", bestpath
);
10461 /* Print the error code/subcode for why the peer is down */
10462 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
10463 json_object
*json_peer
, bool use_json
)
10465 const char *code_str
;
10466 const char *subcode_str
;
10469 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10470 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10471 char errorcodesubcode_hexstr
[5];
10472 char errorcodesubcode_str
[256];
10474 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10475 subcode_str
= bgp_notify_subcode_str(
10477 peer
->notify
.subcode
);
10479 snprintf(errorcodesubcode_hexstr
,
10480 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
10481 peer
->notify
.code
, peer
->notify
.subcode
);
10482 json_object_string_add(json_peer
,
10483 "lastErrorCodeSubcode",
10484 errorcodesubcode_hexstr
);
10485 snprintf(errorcodesubcode_str
, 255, "%s%s",
10486 code_str
, subcode_str
);
10487 json_object_string_add(json_peer
,
10488 "lastNotificationReason",
10489 errorcodesubcode_str
);
10490 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10491 && peer
->notify
.code
== BGP_NOTIFY_CEASE
10492 && (peer
->notify
.subcode
10493 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10494 || peer
->notify
.subcode
10495 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10496 && peer
->notify
.length
) {
10498 const char *msg_str
;
10500 msg_str
= bgp_notify_admin_message(
10501 msgbuf
, sizeof(msgbuf
),
10502 (uint8_t *)peer
->notify
.data
,
10503 peer
->notify
.length
);
10505 json_object_string_add(
10507 "lastShutdownDescription",
10512 json_object_string_add(json_peer
, "lastResetDueTo",
10513 peer_down_str
[(int)peer
->last_reset
]);
10514 json_object_int_add(json_peer
, "lastResetCode",
10517 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10518 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10519 code_str
= bgp_notify_code_str(peer
->notify
.code
);
10521 bgp_notify_subcode_str(peer
->notify
.code
,
10522 peer
->notify
.subcode
);
10523 vty_out(vty
, " Notification %s (%s%s)\n",
10524 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
10527 code_str
, subcode_str
);
10529 vty_out(vty
, " %s\n",
10530 peer_down_str
[(int)peer
->last_reset
]);
10535 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
10538 return ((peer
->status
!= Established
) ||
10539 !peer
->afc_recv
[afi
][safi
]);
10542 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
10543 struct peer
*peer
, json_object
*json_peer
,
10544 int max_neighbor_width
, bool use_json
)
10546 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10550 if (peer_dynamic_neighbor(peer
))
10551 json_object_boolean_true_add(json_peer
,
10553 if (peer
->hostname
)
10554 json_object_string_add(json_peer
, "hostname",
10557 if (peer
->domainname
)
10558 json_object_string_add(json_peer
, "domainname",
10560 json_object_int_add(json_peer
, "connectionsEstablished",
10561 peer
->established
);
10562 json_object_int_add(json_peer
, "connectionsDropped",
10564 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
10565 use_json
, json_peer
);
10566 if (peer
->status
== Established
)
10567 json_object_string_add(json_peer
, "lastResetDueTo",
10568 "AFI/SAFI Not Negotiated");
10570 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
10573 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
10575 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
10576 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
10577 peer
->hostname
, peer
->host
);
10579 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
10581 /* pad the neighbor column with spaces */
10582 if (len
< max_neighbor_width
)
10583 vty_out(vty
, "%*s", max_neighbor_width
- len
,
10585 vty_out(vty
, "%7d %7d %9s", peer
->established
,
10587 peer_uptime(peer
->uptime
, timebuf
,
10588 BGP_UPTIME_LEN
, 0, NULL
));
10589 if (peer
->status
== Established
)
10590 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
10592 bgp_show_peer_reset(vty
, peer
, NULL
,
10597 /* If the peer's description includes whitespaces
10598 * then return the first occurrence. Also strip description
10599 * to the given size if needed.
10601 static char *bgp_peer_description_stripped(char *desc
, uint32_t size
)
10603 static char stripped
[BUFSIZ
];
10605 uint32_t len
= size
> strlen(desc
) ? strlen(desc
) : size
;
10607 pnt
= strchr(desc
, ' ');
10609 len
= size
> (uint32_t)(pnt
- desc
) ? (uint32_t)(pnt
- desc
)
10612 strlcpy(stripped
, desc
, len
+ 1);
10617 /* Show BGP peer's summary information. */
10618 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
10619 uint8_t show_flags
)
10622 struct listnode
*node
, *nnode
;
10623 unsigned int count
= 0, dn_count
= 0;
10624 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
10625 char neighbor_buf
[VTY_BUFSIZ
];
10626 int neighbor_col_default_width
= 16;
10627 int len
, failed_count
= 0;
10628 int max_neighbor_width
= 0;
10630 json_object
*json
= NULL
;
10631 json_object
*json_peer
= NULL
;
10632 json_object
*json_peers
= NULL
;
10633 struct peer_af
*paf
;
10634 struct bgp_filter
*filter
;
10635 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
10636 bool show_failed
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
10637 bool show_established
=
10638 CHECK_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
10639 bool show_wide
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
10641 /* labeled-unicast routes are installed in the unicast table so in order
10643 * display the correct PfxRcd value we must look at SAFI_UNICAST
10646 if (safi
== SAFI_LABELED_UNICAST
)
10647 pfx_rcd_safi
= SAFI_UNICAST
;
10649 pfx_rcd_safi
= safi
;
10652 json
= json_object_new_object();
10653 json_peers
= json_object_new_object();
10654 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10655 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10658 if (peer
->afc
[afi
][safi
]) {
10659 /* See if we have at least a single failed peer */
10660 if (bgp_has_peer_failed(peer
, afi
, safi
))
10664 if (peer_dynamic_neighbor(peer
))
10669 /* Loop over all neighbors that will be displayed to determine
10671 * characters are needed for the Neighbor column
10673 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10674 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10677 if (peer
->afc
[afi
][safi
]) {
10678 memset(dn_flag
, '\0', sizeof(dn_flag
));
10679 if (peer_dynamic_neighbor(peer
))
10683 && CHECK_FLAG(bgp
->flags
,
10684 BGP_FLAG_SHOW_HOSTNAME
))
10685 snprintf(neighbor_buf
,
10686 sizeof(neighbor_buf
),
10687 "%s%s(%s) ", dn_flag
,
10688 peer
->hostname
, peer
->host
);
10690 snprintf(neighbor_buf
,
10691 sizeof(neighbor_buf
), "%s%s ",
10692 dn_flag
, peer
->host
);
10694 len
= strlen(neighbor_buf
);
10696 if (len
> max_neighbor_width
)
10697 max_neighbor_width
= len
;
10699 /* See if we have at least a single failed peer */
10700 if (bgp_has_peer_failed(peer
, afi
, safi
))
10706 /* Originally we displayed the Neighbor column as 16
10707 * characters wide so make that the default
10709 if (max_neighbor_width
< neighbor_col_default_width
)
10710 max_neighbor_width
= neighbor_col_default_width
;
10713 if (show_failed
&& !failed_count
) {
10715 json_object_int_add(json
, "failedPeersCount", 0);
10716 json_object_int_add(json
, "dynamicPeers", dn_count
);
10717 json_object_int_add(json
, "totalPeers", count
);
10719 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10720 json
, JSON_C_TO_STRING_PRETTY
));
10721 json_object_free(json
);
10723 vty_out(vty
, "%% No failed BGP neighbors found\n");
10724 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
10726 return CMD_SUCCESS
;
10729 count
= 0; /* Reset the value as its used again */
10730 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10731 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10734 if (!peer
->afc
[afi
][safi
])
10738 unsigned long ents
;
10739 char memstrbuf
[MTYPE_MEMSTR_LEN
];
10742 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
10744 : (int64_t)bgp
->vrf_id
;
10746 /* Usage summary and header */
10748 char buf
[BUFSIZ
] = {0};
10750 json_object_string_add(
10752 inet_ntop(AF_INET
, &bgp
->router_id
, buf
,
10754 json_object_int_add(json
, "as", bgp
->as
);
10755 json_object_int_add(json
, "vrfId", vrf_id_ui
);
10756 json_object_string_add(
10759 == BGP_INSTANCE_TYPE_DEFAULT
)
10764 "BGP router identifier %pI4, local AS number %u vrf-id %d",
10765 &bgp
->router_id
, bgp
->as
,
10766 bgp
->vrf_id
== VRF_UNKNOWN
10768 : (int)bgp
->vrf_id
);
10769 vty_out(vty
, "\n");
10772 if (bgp_update_delay_configured(bgp
)) {
10774 json_object_int_add(
10775 json
, "updateDelayLimit",
10776 bgp
->v_update_delay
);
10778 if (bgp
->v_update_delay
10779 != bgp
->v_establish_wait
)
10780 json_object_int_add(
10782 "updateDelayEstablishWait",
10783 bgp
->v_establish_wait
);
10785 if (bgp_update_delay_active(bgp
)) {
10786 json_object_string_add(
10788 "updateDelayFirstNeighbor",
10789 bgp
->update_delay_begin_time
);
10790 json_object_boolean_true_add(
10792 "updateDelayInProgress");
10794 if (bgp
->update_delay_over
) {
10795 json_object_string_add(
10797 "updateDelayFirstNeighbor",
10798 bgp
->update_delay_begin_time
);
10799 json_object_string_add(
10801 "updateDelayBestpathResumed",
10802 bgp
->update_delay_end_time
);
10803 json_object_string_add(
10805 "updateDelayZebraUpdateResume",
10806 bgp
->update_delay_zebra_resume_time
);
10807 json_object_string_add(
10809 "updateDelayPeerUpdateResume",
10810 bgp
->update_delay_peers_resume_time
);
10815 "Read-only mode update-delay limit: %d seconds\n",
10816 bgp
->v_update_delay
);
10817 if (bgp
->v_update_delay
10818 != bgp
->v_establish_wait
)
10820 " Establish wait: %d seconds\n",
10821 bgp
->v_establish_wait
);
10823 if (bgp_update_delay_active(bgp
)) {
10825 " First neighbor established: %s\n",
10826 bgp
->update_delay_begin_time
);
10828 " Delay in progress\n");
10830 if (bgp
->update_delay_over
) {
10832 " First neighbor established: %s\n",
10833 bgp
->update_delay_begin_time
);
10835 " Best-paths resumed: %s\n",
10836 bgp
->update_delay_end_time
);
10838 " zebra update resumed: %s\n",
10839 bgp
->update_delay_zebra_resume_time
);
10841 " peers update resumed: %s\n",
10842 bgp
->update_delay_peers_resume_time
);
10849 if (bgp_maxmed_onstartup_configured(bgp
)
10850 && bgp
->maxmed_active
)
10851 json_object_boolean_true_add(
10852 json
, "maxMedOnStartup");
10853 if (bgp
->v_maxmed_admin
)
10854 json_object_boolean_true_add(
10855 json
, "maxMedAdministrative");
10857 json_object_int_add(
10858 json
, "tableVersion",
10859 bgp_table_version(bgp
->rib
[afi
][safi
]));
10861 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10862 json_object_int_add(json
, "ribCount", ents
);
10863 json_object_int_add(
10865 ents
* sizeof(struct bgp_dest
));
10867 ents
= bgp
->af_peer_count
[afi
][safi
];
10868 json_object_int_add(json
, "peerCount", ents
);
10869 json_object_int_add(json
, "peerMemory",
10870 ents
* sizeof(struct peer
));
10872 if ((ents
= listcount(bgp
->group
))) {
10873 json_object_int_add(
10874 json
, "peerGroupCount", ents
);
10875 json_object_int_add(
10876 json
, "peerGroupMemory",
10877 ents
* sizeof(struct
10881 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10882 BGP_CONFIG_DAMPENING
))
10883 json_object_boolean_true_add(
10884 json
, "dampeningEnabled");
10886 if (bgp_maxmed_onstartup_configured(bgp
)
10887 && bgp
->maxmed_active
)
10889 "Max-med on-startup active\n");
10890 if (bgp
->v_maxmed_admin
)
10892 "Max-med administrative active\n");
10894 vty_out(vty
, "BGP table version %" PRIu64
"\n",
10895 bgp_table_version(bgp
->rib
[afi
][safi
]));
10897 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
10899 "RIB entries %ld, using %s of memory\n",
10902 memstrbuf
, sizeof(memstrbuf
),
10907 /* Peer related usage */
10908 ents
= bgp
->af_peer_count
[afi
][safi
];
10909 vty_out(vty
, "Peers %ld, using %s of memory\n",
10912 memstrbuf
, sizeof(memstrbuf
),
10913 ents
* sizeof(struct peer
)));
10915 if ((ents
= listcount(bgp
->group
)))
10917 "Peer groups %ld, using %s of memory\n",
10922 ents
* sizeof(struct
10925 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10926 BGP_CONFIG_DAMPENING
))
10927 vty_out(vty
, "Dampening enabled.\n");
10928 vty_out(vty
, "\n");
10930 /* Subtract 8 here because 'Neighbor' is
10932 vty_out(vty
, "Neighbor");
10933 vty_out(vty
, "%*s", max_neighbor_width
- 8,
10937 BGP_SHOW_SUMMARY_HEADER_FAILED
);
10941 ? BGP_SHOW_SUMMARY_HEADER_ALL_WIDE
10942 : BGP_SHOW_SUMMARY_HEADER_ALL
);
10946 paf
= peer_af_find(peer
, afi
, safi
);
10947 filter
= &peer
->filter
[afi
][safi
];
10950 /* Works for both failed & successful cases */
10951 if (peer_dynamic_neighbor(peer
))
10958 bgp_has_peer_failed(peer
, afi
, safi
)) {
10959 json_peer
= json_object_new_object();
10960 bgp_show_failed_summary(vty
, bgp
, peer
,
10961 json_peer
, 0, use_json
);
10962 } else if (!show_failed
) {
10963 if (show_established
10964 && bgp_has_peer_failed(peer
, afi
, safi
))
10967 json_peer
= json_object_new_object();
10968 if (peer_dynamic_neighbor(peer
)) {
10969 json_object_boolean_true_add(json_peer
,
10973 if (peer
->hostname
)
10974 json_object_string_add(json_peer
, "hostname",
10977 if (peer
->domainname
)
10978 json_object_string_add(json_peer
, "domainname",
10981 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
10982 json_object_int_add(
10983 json_peer
, "localAs",
10984 peer
->change_local_as
10985 ? peer
->change_local_as
10987 json_object_int_add(json_peer
, "version", 4);
10988 json_object_int_add(json_peer
, "msgRcvd",
10989 PEER_TOTAL_RX(peer
));
10990 json_object_int_add(json_peer
, "msgSent",
10991 PEER_TOTAL_TX(peer
));
10993 atomic_size_t outq_count
, inq_count
;
10994 outq_count
= atomic_load_explicit(
10995 &peer
->obuf
->count
,
10996 memory_order_relaxed
);
10997 inq_count
= atomic_load_explicit(
10998 &peer
->ibuf
->count
,
10999 memory_order_relaxed
);
11001 json_object_int_add(json_peer
, "tableVersion",
11002 peer
->version
[afi
][safi
]);
11003 json_object_int_add(json_peer
, "outq",
11005 json_object_int_add(json_peer
, "inq",
11007 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
11008 use_json
, json_peer
);
11010 json_object_int_add(json_peer
, "pfxRcd",
11011 peer
->pcount
[afi
][pfx_rcd_safi
]);
11013 if (paf
&& PAF_SUBGRP(paf
))
11014 json_object_int_add(
11015 json_peer
, "pfxSnt",
11016 (PAF_SUBGRP(paf
))->scount
);
11018 json_object_int_add(json_peer
, "pfxSnt",
11021 /* BGP FSM state */
11022 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11023 || CHECK_FLAG(peer
->bgp
->flags
,
11024 BGP_FLAG_SHUTDOWN
))
11025 json_object_string_add(json_peer
,
11028 else if (peer
->afc_recv
[afi
][safi
])
11029 json_object_string_add(
11030 json_peer
, "state",
11031 lookup_msg(bgp_status_msg
,
11032 peer
->status
, NULL
));
11033 else if (CHECK_FLAG(
11035 PEER_STATUS_PREFIX_OVERFLOW
))
11036 json_object_string_add(json_peer
,
11040 json_object_string_add(
11041 json_peer
, "state",
11042 lookup_msg(bgp_status_msg
,
11043 peer
->status
, NULL
));
11045 /* BGP peer state */
11046 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
11047 || CHECK_FLAG(peer
->bgp
->flags
,
11048 BGP_FLAG_SHUTDOWN
))
11049 json_object_string_add(json_peer
,
11052 else if (CHECK_FLAG(
11054 PEER_STATUS_PREFIX_OVERFLOW
))
11055 json_object_string_add(json_peer
,
11058 else if (CHECK_FLAG(peer
->flags
,
11059 PEER_FLAG_PASSIVE
))
11060 json_object_string_add(json_peer
,
11063 else if (CHECK_FLAG(peer
->sflags
,
11064 PEER_STATUS_NSF_WAIT
))
11065 json_object_string_add(json_peer
,
11068 else if (CHECK_FLAG(
11070 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11071 && (!bgp_inbound_policy_exists(peer
,
11073 || !bgp_outbound_policy_exists(
11075 json_object_string_add(json_peer
,
11079 json_object_string_add(
11080 json_peer
, "peerState", "OK");
11082 json_object_int_add(json_peer
, "connectionsEstablished",
11083 peer
->established
);
11084 json_object_int_add(json_peer
, "connectionsDropped",
11087 json_object_string_add(
11088 json_peer
, "desc", peer
->desc
);
11090 /* Avoid creating empty peer dicts in JSON */
11091 if (json_peer
== NULL
)
11095 json_object_string_add(json_peer
, "idType",
11097 else if (peer
->su
.sa
.sa_family
== AF_INET
)
11098 json_object_string_add(json_peer
, "idType",
11100 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
11101 json_object_string_add(json_peer
, "idType",
11103 json_object_object_add(json_peers
, peer
->host
,
11107 bgp_has_peer_failed(peer
, afi
, safi
)) {
11108 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
11109 max_neighbor_width
,
11111 } else if (!show_failed
) {
11112 if (show_established
11113 && bgp_has_peer_failed(peer
, afi
, safi
))
11116 memset(dn_flag
, '\0', sizeof(dn_flag
));
11117 if (peer_dynamic_neighbor(peer
)) {
11122 && CHECK_FLAG(bgp
->flags
,
11123 BGP_FLAG_SHOW_HOSTNAME
))
11124 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
11128 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
11130 /* pad the neighbor column with spaces */
11131 if (len
< max_neighbor_width
)
11132 vty_out(vty
, "%*s", max_neighbor_width
- len
,
11135 atomic_size_t outq_count
, inq_count
;
11136 outq_count
= atomic_load_explicit(
11137 &peer
->obuf
->count
,
11138 memory_order_relaxed
);
11139 inq_count
= atomic_load_explicit(
11140 &peer
->ibuf
->count
,
11141 memory_order_relaxed
);
11145 "4 %10u %10u %9u %9u %8" PRIu64
11148 peer
->change_local_as
11149 ? peer
->change_local_as
11151 PEER_TOTAL_RX(peer
),
11152 PEER_TOTAL_TX(peer
),
11153 peer
->version
[afi
][safi
],
11154 inq_count
, outq_count
,
11155 peer_uptime(peer
->uptime
,
11160 vty_out(vty
, "4 %10u %9u %9u %8" PRIu64
11162 peer
->as
, PEER_TOTAL_RX(peer
),
11163 PEER_TOTAL_TX(peer
),
11164 peer
->version
[afi
][safi
],
11165 inq_count
, outq_count
,
11166 peer_uptime(peer
->uptime
,
11171 if (peer
->status
== Established
) {
11172 if (peer
->afc_recv
[afi
][safi
]) {
11175 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11176 && !bgp_inbound_policy_exists(
11178 vty_out(vty
, " %12s",
11187 vty_out(vty
, " NoNeg");
11190 if (paf
&& PAF_SUBGRP(paf
)) {
11193 BGP_FLAG_EBGP_REQUIRES_POLICY
)
11194 && !bgp_outbound_policy_exists(
11196 vty_out(vty
, " %8s",
11205 vty_out(vty
, " NoNeg");
11208 if (CHECK_FLAG(peer
->flags
,
11209 PEER_FLAG_SHUTDOWN
)
11210 || CHECK_FLAG(peer
->bgp
->flags
,
11211 BGP_FLAG_SHUTDOWN
))
11212 vty_out(vty
, " Idle (Admin)");
11213 else if (CHECK_FLAG(
11215 PEER_STATUS_PREFIX_OVERFLOW
))
11216 vty_out(vty
, " Idle (PfxCt)");
11218 vty_out(vty
, " %12s",
11219 lookup_msg(bgp_status_msg
,
11220 peer
->status
, NULL
));
11222 vty_out(vty
, " %8u", 0);
11225 vty_out(vty
, " %s",
11226 bgp_peer_description_stripped(
11228 show_wide
? 64 : 20));
11230 vty_out(vty
, " N/A");
11231 vty_out(vty
, "\n");
11238 json_object_object_add(json
, "peers", json_peers
);
11239 json_object_int_add(json
, "failedPeers", failed_count
);
11240 json_object_int_add(json
, "totalPeers", count
);
11241 json_object_int_add(json
, "dynamicPeers", dn_count
);
11244 bgp_show_bestpath_json(bgp
, json
);
11246 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11247 json
, JSON_C_TO_STRING_PRETTY
));
11248 json_object_free(json
);
11251 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
11253 vty_out(vty
, "No %s neighbor is configured\n",
11254 get_afi_safi_str(afi
, safi
, false));
11258 vty_out(vty
, "* - dynamic neighbor\n");
11259 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
11260 dn_count
, bgp
->dynamic_neighbors_limit
);
11264 return CMD_SUCCESS
;
11267 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
11268 int safi
, uint8_t show_flags
)
11271 int afi_wildcard
= (afi
== AFI_MAX
);
11272 int safi_wildcard
= (safi
== SAFI_MAX
);
11273 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
11274 bool nbr_output
= false;
11275 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11277 if (use_json
&& is_wildcard
)
11278 vty_out(vty
, "{\n");
11280 afi
= 1; /* AFI_IP */
11281 while (afi
< AFI_MAX
) {
11283 safi
= 1; /* SAFI_UNICAST */
11284 while (safi
< SAFI_MAX
) {
11285 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
11290 * So limit output to those afi/safi
11292 * actualy have something interesting in
11297 vty_out(vty
, ",\n");
11301 vty_out(vty
, "\"%s\":",
11302 get_afi_safi_str(afi
,
11306 vty_out(vty
, "\n%s Summary:\n",
11307 get_afi_safi_str(afi
,
11312 bgp_show_summary(vty
, bgp
, afi
, safi
,
11316 if (!safi_wildcard
)
11324 if (use_json
&& is_wildcard
)
11325 vty_out(vty
, "}\n");
11326 else if (!nbr_output
) {
11328 vty_out(vty
, "{}\n");
11330 vty_out(vty
, "%% No BGP neighbors found\n");
11334 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
11335 safi_t safi
, uint8_t show_flags
)
11337 struct listnode
*node
, *nnode
;
11340 bool nbr_output
= false;
11341 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11344 vty_out(vty
, "{\n");
11346 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11350 vty_out(vty
, ",\n");
11354 vty_out(vty
, "\"%s\":",
11355 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11359 vty_out(vty
, "\nInstance %s:\n",
11360 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11364 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_flags
);
11368 vty_out(vty
, "}\n");
11369 else if (!nbr_output
)
11370 vty_out(vty
, "%% BGP instance not found\n");
11373 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
11374 safi_t safi
, uint8_t show_flags
)
11377 bool use_json
= CHECK_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11380 if (strmatch(name
, "all")) {
11381 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
11383 return CMD_SUCCESS
;
11385 bgp
= bgp_lookup_by_name(name
);
11389 vty_out(vty
, "{}\n");
11392 "%% BGP instance not found\n");
11393 return CMD_WARNING
;
11396 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
,
11398 return CMD_SUCCESS
;
11402 bgp
= bgp_get_default();
11405 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_flags
);
11408 vty_out(vty
, "{}\n");
11410 vty_out(vty
, "%% BGP instance not found\n");
11411 return CMD_WARNING
;
11414 return CMD_SUCCESS
;
11417 /* `show [ip] bgp summary' commands. */
11418 DEFPY (show_ip_bgp_summary
,
11419 show_ip_bgp_summary_cmd
,
11420 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] [all$all] summary [established|failed] [wide] [json$uj]",
11424 BGP_INSTANCE_HELP_STR
11426 BGP_SAFI_WITH_LABEL_HELP_STR
11427 "Display the entries for all address families\n"
11428 "Summary of BGP neighbor status\n"
11429 "Show only sessions in Established state\n"
11430 "Show only sessions not in Established state\n"
11431 "Increase table width for longer output\n"
11435 afi_t afi
= AFI_MAX
;
11436 safi_t safi
= SAFI_MAX
;
11437 uint8_t show_flags
= 0;
11441 /* show [ip] bgp */
11442 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
11444 /* [<vrf> VIEWVRFNAME] */
11445 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11446 vrf
= argv
[idx
+ 1]->arg
;
11447 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11449 } else if (argv_find(argv
, argc
, "view", &idx
))
11450 /* [<view> VIEWVRFNAME] */
11451 vrf
= argv
[idx
+ 1]->arg
;
11452 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11453 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11454 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11457 if (argv_find(argv
, argc
, "failed", &idx
))
11458 SET_FLAG(show_flags
, BGP_SHOW_OPT_FAILED
);
11460 if (argv_find(argv
, argc
, "established", &idx
))
11461 SET_FLAG(show_flags
, BGP_SHOW_OPT_ESTABLISHED
);
11463 if (argv_find(argv
, argc
, "wide", &idx
))
11464 SET_FLAG(show_flags
, BGP_SHOW_OPT_WIDE
);
11466 if (argv_find(argv
, argc
, "json", &idx
))
11467 SET_FLAG(show_flags
, BGP_SHOW_OPT_JSON
);
11469 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, show_flags
);
11472 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
11475 return get_afi_safi_json_str(afi
, safi
);
11477 return get_afi_safi_vty_str(afi
, safi
);
11481 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
11482 afi_t afi
, safi_t safi
,
11483 uint16_t adv_smcap
, uint16_t adv_rmcap
,
11484 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
11485 bool use_json
, json_object
*json_pref
)
11488 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11489 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
11491 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
11492 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11493 json_object_string_add(json_pref
, "sendMode",
11494 "advertisedAndReceived");
11495 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11496 json_object_string_add(json_pref
, "sendMode",
11498 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11499 json_object_string_add(json_pref
, "sendMode",
11502 vty_out(vty
, " Send-mode: ");
11503 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
11504 vty_out(vty
, "advertised");
11505 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
11506 vty_out(vty
, "%sreceived",
11507 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11511 vty_out(vty
, "\n");
11516 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11517 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
11519 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
11520 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11521 json_object_string_add(json_pref
, "recvMode",
11522 "advertisedAndReceived");
11523 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11524 json_object_string_add(json_pref
, "recvMode",
11526 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11527 json_object_string_add(json_pref
, "recvMode",
11530 vty_out(vty
, " Receive-mode: ");
11531 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
11532 vty_out(vty
, "advertised");
11533 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
11534 vty_out(vty
, "%sreceived",
11535 CHECK_FLAG(p
->af_cap
[afi
][safi
],
11539 vty_out(vty
, "\n");
11544 static void bgp_show_neighnor_graceful_restart_rbit(struct vty
*vty
,
11549 bool rbit_status
= false;
11552 vty_out(vty
, "\n R bit: ");
11554 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
11555 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
11556 && (p
->status
== Established
)) {
11558 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_BIT_RCV
))
11559 rbit_status
= true;
11561 rbit_status
= false;
11566 json_object_boolean_true_add(json
, "rBit");
11568 vty_out(vty
, "True\n");
11571 json_object_boolean_false_add(json
, "rBit");
11573 vty_out(vty
, "False\n");
11577 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
11582 const char *mode
= "NotApplicable";
11585 vty_out(vty
, "\n Remote GR Mode: ");
11587 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11588 && (peer
->status
== Established
)) {
11590 if ((peer
->nsf_af_count
== 0)
11591 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11595 } else if (peer
->nsf_af_count
== 0
11596 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11600 } else if (peer
->nsf_af_count
!= 0
11601 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
11608 json_object_string_add(json
, "remoteGrMode", mode
);
11610 vty_out(vty
, mode
, "\n");
11613 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
11618 const char *mode
= "Invalid";
11621 vty_out(vty
, " Local GR Mode: ");
11623 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
11625 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
11627 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
11629 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
11630 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
11632 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
11634 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
11641 json_object_string_add(json
, "localGrMode", mode
);
11643 vty_out(vty
, mode
, "\n");
11647 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
11648 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
11652 json_object
*json_afi_safi
= NULL
;
11653 json_object
*json_timer
= NULL
;
11654 json_object
*json_endofrib_status
= NULL
;
11655 bool eor_flag
= false;
11657 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11658 for (safi
= SAFI_UNICAST
; safi
<= SAFI_MPLS_VPN
; safi
++) {
11659 if (!peer
->afc
[afi
][safi
])
11662 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
11663 || !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
11667 json_afi_safi
= json_object_new_object();
11668 json_endofrib_status
= json_object_new_object();
11669 json_timer
= json_object_new_object();
11672 if (peer
->eor_stime
[afi
][safi
]
11673 >= peer
->pkt_stime
[afi
][safi
])
11679 vty_out(vty
, " %s:\n",
11680 get_afi_safi_str(afi
, safi
, false));
11682 vty_out(vty
, " F bit: ");
11685 if (peer
->nsf
[afi
][safi
]
11686 && CHECK_FLAG(peer
->af_cap
[afi
][safi
],
11687 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
11690 json_object_boolean_true_add(
11691 json_afi_safi
, "fBit");
11693 vty_out(vty
, "True\n");
11696 json_object_boolean_false_add(
11697 json_afi_safi
, "fBit");
11699 vty_out(vty
, "False\n");
11703 vty_out(vty
, " End-of-RIB sent: ");
11705 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11706 PEER_STATUS_EOR_SEND
)) {
11708 json_object_boolean_true_add(
11709 json_endofrib_status
,
11712 PRINT_EOR_JSON(eor_flag
);
11714 vty_out(vty
, "Yes\n");
11716 " End-of-RIB sent after update: ");
11718 PRINT_EOR(eor_flag
);
11722 json_object_boolean_false_add(
11723 json_endofrib_status
,
11725 json_object_boolean_false_add(
11726 json_endofrib_status
,
11727 "endOfRibSentAfterUpdate");
11729 vty_out(vty
, "No\n");
11731 " End-of-RIB sent after update: ");
11732 vty_out(vty
, "No\n");
11737 vty_out(vty
, " End-of-RIB received: ");
11739 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
11740 PEER_STATUS_EOR_RECEIVED
)) {
11742 json_object_boolean_true_add(
11743 json_endofrib_status
,
11746 vty_out(vty
, "Yes\n");
11749 json_object_boolean_false_add(
11750 json_endofrib_status
,
11753 vty_out(vty
, "No\n");
11757 json_object_int_add(json_timer
,
11759 peer
->bgp
->stalepath_time
);
11761 if (peer
->t_gr_stale
!= NULL
) {
11762 json_object_int_add(
11764 "stalePathTimerRemaining",
11765 thread_timer_remain_second(
11766 peer
->t_gr_stale
));
11769 /* Display Configured Selection
11770 * Deferral only when when
11771 * Gr mode is enabled.
11773 if (CHECK_FLAG(peer
->flags
,
11774 PEER_FLAG_GRACEFUL_RESTART
)) {
11775 json_object_int_add(
11777 "selectionDeferralTimer",
11778 peer
->bgp
->stalepath_time
);
11781 if (peer
->bgp
->gr_info
[afi
][safi
]
11785 json_object_int_add(
11787 "selectionDeferralTimerRemaining",
11788 thread_timer_remain_second(
11792 .t_select_deferral
));
11795 vty_out(vty
, " Timers:\n");
11797 " Configured Stale Path Time(sec): %u\n",
11798 peer
->bgp
->stalepath_time
);
11800 if (peer
->t_gr_stale
!= NULL
)
11802 " Stale Path Remaining(sec): %ld\n",
11803 thread_timer_remain_second(
11804 peer
->t_gr_stale
));
11805 /* Display Configured Selection
11806 * Deferral only when when
11807 * Gr mode is enabled.
11809 if (CHECK_FLAG(peer
->flags
,
11810 PEER_FLAG_GRACEFUL_RESTART
))
11812 " Configured Selection Deferral Time(sec): %u\n",
11813 peer
->bgp
->select_defer_time
);
11815 if (peer
->bgp
->gr_info
[afi
][safi
]
11819 " Selection Deferral Time Remaining(sec): %ld\n",
11820 thread_timer_remain_second(
11824 .t_select_deferral
));
11827 json_object_object_add(json_afi_safi
,
11829 json_endofrib_status
);
11830 json_object_object_add(json_afi_safi
, "timers",
11832 json_object_object_add(
11833 json
, get_afi_safi_str(afi
, safi
, true),
11840 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
11846 json_object
*json_timer
= NULL
;
11848 json_timer
= json_object_new_object();
11850 json_object_int_add(json_timer
, "configuredRestartTimer",
11851 p
->bgp
->restart_time
);
11853 json_object_int_add(json_timer
, "receivedRestartTimer",
11856 if (p
->t_gr_restart
!= NULL
)
11857 json_object_int_add(
11858 json_timer
, "restartTimerRemaining",
11859 thread_timer_remain_second(p
->t_gr_restart
));
11861 json_object_object_add(json
, "timers", json_timer
);
11864 vty_out(vty
, " Timers:\n");
11865 vty_out(vty
, " Configured Restart Time(sec): %u\n",
11866 p
->bgp
->restart_time
);
11868 vty_out(vty
, " Received Restart Time(sec): %u\n",
11870 if (p
->t_gr_restart
!= NULL
)
11871 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11872 thread_timer_remain_second(p
->t_gr_restart
));
11873 if (p
->t_gr_restart
!= NULL
) {
11874 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
11875 thread_timer_remain_second(p
->t_gr_restart
));
11880 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
11881 bool use_json
, json_object
*json
)
11883 char buf
[SU_ADDRSTRLEN
] = {0};
11884 char dn_flag
[2] = {0};
11885 /* '*' + v6 address of neighbor */
11886 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
11888 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11893 json_object_string_add(
11894 json
, "neighborAddr",
11895 BGP_PEER_SU_UNSPEC(p
)
11897 : sockunion2str(&p
->su
, buf
,
11900 vty_out(vty
, "BGP neighbor on %s: %s\n", p
->conf_if
,
11901 BGP_PEER_SU_UNSPEC(p
)
11903 : sockunion2str(&p
->su
, buf
,
11906 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
11910 json_object_string_add(json
, "neighborAddr",
11913 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
11916 /* more gr info in new format */
11917 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
11920 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
11921 safi_t safi
, bool use_json
,
11922 json_object
*json_neigh
)
11924 struct bgp_filter
*filter
;
11925 struct peer_af
*paf
;
11926 char orf_pfx_name
[BUFSIZ
];
11928 json_object
*json_af
= NULL
;
11929 json_object
*json_prefA
= NULL
;
11930 json_object
*json_prefB
= NULL
;
11931 json_object
*json_addr
= NULL
;
11932 json_object
*json_advmap
= NULL
;
11935 json_addr
= json_object_new_object();
11936 json_af
= json_object_new_object();
11937 filter
= &p
->filter
[afi
][safi
];
11939 if (peer_group_active(p
))
11940 json_object_string_add(json_addr
, "peerGroupMember",
11943 paf
= peer_af_find(p
, afi
, safi
);
11944 if (paf
&& PAF_SUBGRP(paf
)) {
11945 json_object_int_add(json_addr
, "updateGroupId",
11946 PAF_UPDGRP(paf
)->id
);
11947 json_object_int_add(json_addr
, "subGroupId",
11948 PAF_SUBGRP(paf
)->id
);
11949 json_object_int_add(json_addr
, "packetQueueLength",
11950 bpacket_queue_virtual_length(paf
));
11953 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11954 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11955 PEER_CAP_ORF_PREFIX_SM_RCV
)
11956 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11957 PEER_CAP_ORF_PREFIX_RM_ADV
)
11958 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11959 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11960 json_object_int_add(json_af
, "orfType",
11962 json_prefA
= json_object_new_object();
11963 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
11964 PEER_CAP_ORF_PREFIX_SM_ADV
,
11965 PEER_CAP_ORF_PREFIX_RM_ADV
,
11966 PEER_CAP_ORF_PREFIX_SM_RCV
,
11967 PEER_CAP_ORF_PREFIX_RM_RCV
,
11968 use_json
, json_prefA
);
11969 json_object_object_add(json_af
, "orfPrefixList",
11973 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11974 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11975 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11976 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11977 PEER_CAP_ORF_PREFIX_RM_ADV
)
11978 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11979 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
11980 json_object_int_add(json_af
, "orfOldType",
11981 ORF_TYPE_PREFIX_OLD
);
11982 json_prefB
= json_object_new_object();
11983 bgp_show_peer_afi_orf_cap(
11984 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
11985 PEER_CAP_ORF_PREFIX_RM_ADV
,
11986 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
11987 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
11989 json_object_object_add(json_af
, "orfOldPrefixList",
11993 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11994 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11995 PEER_CAP_ORF_PREFIX_SM_RCV
)
11996 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11997 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11998 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11999 PEER_CAP_ORF_PREFIX_RM_ADV
)
12000 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12001 PEER_CAP_ORF_PREFIX_RM_RCV
)
12002 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12003 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12004 json_object_object_add(json_addr
, "afDependentCap",
12007 json_object_free(json_af
);
12009 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12010 p
->host
, afi
, safi
);
12011 orf_pfx_count
= prefix_bgp_show_prefix_list(
12012 NULL
, afi
, orf_pfx_name
, use_json
);
12014 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12015 PEER_STATUS_ORF_PREFIX_SEND
)
12016 || orf_pfx_count
) {
12017 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12018 PEER_STATUS_ORF_PREFIX_SEND
))
12019 json_object_boolean_true_add(json_neigh
,
12022 json_object_int_add(json_addr
, "orfRecvCounter",
12025 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12026 PEER_STATUS_ORF_WAIT_REFRESH
))
12027 json_object_string_add(
12028 json_addr
, "orfFirstUpdate",
12029 "deferredUntilORFOrRouteRefreshRecvd");
12031 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12032 PEER_FLAG_REFLECTOR_CLIENT
))
12033 json_object_boolean_true_add(json_addr
,
12034 "routeReflectorClient");
12035 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12036 PEER_FLAG_RSERVER_CLIENT
))
12037 json_object_boolean_true_add(json_addr
,
12038 "routeServerClient");
12039 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12040 json_object_boolean_true_add(json_addr
,
12041 "inboundSoftConfigPermit");
12043 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12044 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12045 json_object_boolean_true_add(
12047 "privateAsNumsAllReplacedInUpdatesToNbr");
12048 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12049 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12050 json_object_boolean_true_add(
12052 "privateAsNumsReplacedInUpdatesToNbr");
12053 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12054 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12055 json_object_boolean_true_add(
12057 "privateAsNumsAllRemovedInUpdatesToNbr");
12058 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12059 PEER_FLAG_REMOVE_PRIVATE_AS
))
12060 json_object_boolean_true_add(
12062 "privateAsNumsRemovedInUpdatesToNbr");
12064 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12065 json_object_boolean_true_add(
12067 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12070 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12071 json_object_string_add(json_addr
,
12072 "overrideASNsInOutboundUpdates",
12073 "ifAspathEqualRemoteAs");
12075 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12076 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12077 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12078 json_object_boolean_true_add(json_addr
,
12079 "routerAlwaysNextHop");
12080 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12081 PEER_FLAG_AS_PATH_UNCHANGED
))
12082 json_object_boolean_true_add(
12083 json_addr
, "unchangedAsPathPropogatedToNbr");
12084 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12085 PEER_FLAG_NEXTHOP_UNCHANGED
))
12086 json_object_boolean_true_add(
12087 json_addr
, "unchangedNextHopPropogatedToNbr");
12088 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12089 json_object_boolean_true_add(
12090 json_addr
, "unchangedMedPropogatedToNbr");
12091 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12092 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12093 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
12094 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12095 PEER_FLAG_SEND_COMMUNITY
)
12096 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12097 PEER_FLAG_SEND_EXT_COMMUNITY
))
12098 json_object_string_add(json_addr
,
12099 "commAttriSentToNbr",
12100 "extendedAndStandard");
12101 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12102 PEER_FLAG_SEND_EXT_COMMUNITY
))
12103 json_object_string_add(json_addr
,
12104 "commAttriSentToNbr",
12107 json_object_string_add(json_addr
,
12108 "commAttriSentToNbr",
12111 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12112 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12113 if (p
->default_rmap
[afi
][safi
].name
)
12114 json_object_string_add(
12115 json_addr
, "defaultRouteMap",
12116 p
->default_rmap
[afi
][safi
].name
);
12118 if (paf
&& PAF_SUBGRP(paf
)
12119 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12120 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12121 json_object_boolean_true_add(json_addr
,
12124 json_object_boolean_true_add(json_addr
,
12128 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12129 if (is_evpn_enabled())
12130 json_object_boolean_true_add(
12131 json_addr
, "advertiseAllVnis");
12134 if (filter
->plist
[FILTER_IN
].name
12135 || filter
->dlist
[FILTER_IN
].name
12136 || filter
->aslist
[FILTER_IN
].name
12137 || filter
->map
[RMAP_IN
].name
)
12138 json_object_boolean_true_add(json_addr
,
12139 "inboundPathPolicyConfig");
12140 if (filter
->plist
[FILTER_OUT
].name
12141 || filter
->dlist
[FILTER_OUT
].name
12142 || filter
->aslist
[FILTER_OUT
].name
12143 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12144 json_object_boolean_true_add(
12145 json_addr
, "outboundPathPolicyConfig");
12148 if (filter
->plist
[FILTER_IN
].name
)
12149 json_object_string_add(json_addr
,
12150 "incomingUpdatePrefixFilterList",
12151 filter
->plist
[FILTER_IN
].name
);
12152 if (filter
->plist
[FILTER_OUT
].name
)
12153 json_object_string_add(json_addr
,
12154 "outgoingUpdatePrefixFilterList",
12155 filter
->plist
[FILTER_OUT
].name
);
12157 /* distribute-list */
12158 if (filter
->dlist
[FILTER_IN
].name
)
12159 json_object_string_add(
12160 json_addr
, "incomingUpdateNetworkFilterList",
12161 filter
->dlist
[FILTER_IN
].name
);
12162 if (filter
->dlist
[FILTER_OUT
].name
)
12163 json_object_string_add(
12164 json_addr
, "outgoingUpdateNetworkFilterList",
12165 filter
->dlist
[FILTER_OUT
].name
);
12168 if (filter
->aslist
[FILTER_IN
].name
)
12169 json_object_string_add(json_addr
,
12170 "incomingUpdateAsPathFilterList",
12171 filter
->aslist
[FILTER_IN
].name
);
12172 if (filter
->aslist
[FILTER_OUT
].name
)
12173 json_object_string_add(json_addr
,
12174 "outgoingUpdateAsPathFilterList",
12175 filter
->aslist
[FILTER_OUT
].name
);
12178 if (filter
->map
[RMAP_IN
].name
)
12179 json_object_string_add(
12180 json_addr
, "routeMapForIncomingAdvertisements",
12181 filter
->map
[RMAP_IN
].name
);
12182 if (filter
->map
[RMAP_OUT
].name
)
12183 json_object_string_add(
12184 json_addr
, "routeMapForOutgoingAdvertisements",
12185 filter
->map
[RMAP_OUT
].name
);
12187 /* ebgp-requires-policy (inbound) */
12188 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12189 && !bgp_inbound_policy_exists(p
, filter
))
12190 json_object_string_add(
12191 json_addr
, "inboundEbgpRequiresPolicy",
12192 "Inbound updates discarded due to missing policy");
12194 /* ebgp-requires-policy (outbound) */
12195 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12196 && (!bgp_outbound_policy_exists(p
, filter
)))
12197 json_object_string_add(
12198 json_addr
, "outboundEbgpRequiresPolicy",
12199 "Outbound updates discarded due to missing policy");
12201 /* unsuppress-map */
12202 if (filter
->usmap
.name
)
12203 json_object_string_add(json_addr
,
12204 "selectiveUnsuppressRouteMap",
12205 filter
->usmap
.name
);
12207 /* advertise-map */
12208 if (filter
->advmap
.aname
) {
12209 json_advmap
= json_object_new_object();
12210 json_object_string_add(json_advmap
, "condition",
12211 filter
->advmap
.condition
12214 json_object_string_add(json_advmap
, "conditionMap",
12215 filter
->advmap
.cname
);
12216 json_object_string_add(json_advmap
, "advertiseMap",
12217 filter
->advmap
.aname
);
12218 json_object_string_add(json_advmap
, "advertiseStatus",
12219 filter
->advmap
.update_type
12223 json_object_object_add(json_addr
, "advertiseMap",
12227 /* Receive prefix count */
12228 json_object_int_add(json_addr
, "acceptedPrefixCounter",
12229 p
->pcount
[afi
][safi
]);
12230 if (paf
&& PAF_SUBGRP(paf
))
12231 json_object_int_add(json_addr
, "sentPrefixCounter",
12232 (PAF_SUBGRP(paf
))->scount
);
12234 /* Maximum prefix */
12235 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
12236 json_object_int_add(json_addr
, "prefixOutAllowedMax",
12237 p
->pmax_out
[afi
][safi
]);
12239 /* Maximum prefix */
12240 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12241 json_object_int_add(json_addr
, "prefixAllowedMax",
12242 p
->pmax
[afi
][safi
]);
12243 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12244 PEER_FLAG_MAX_PREFIX_WARNING
))
12245 json_object_boolean_true_add(
12246 json_addr
, "prefixAllowedMaxWarning");
12247 json_object_int_add(json_addr
,
12248 "prefixAllowedWarningThresh",
12249 p
->pmax_threshold
[afi
][safi
]);
12250 if (p
->pmax_restart
[afi
][safi
])
12251 json_object_int_add(
12253 "prefixAllowedRestartIntervalMsecs",
12254 p
->pmax_restart
[afi
][safi
] * 60000);
12256 json_object_object_add(json_neigh
,
12257 get_afi_safi_str(afi
, safi
, true),
12261 filter
= &p
->filter
[afi
][safi
];
12263 vty_out(vty
, " For address family: %s\n",
12264 get_afi_safi_str(afi
, safi
, false));
12266 if (peer_group_active(p
))
12267 vty_out(vty
, " %s peer-group member\n",
12270 paf
= peer_af_find(p
, afi
, safi
);
12271 if (paf
&& PAF_SUBGRP(paf
)) {
12272 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
12273 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
12274 vty_out(vty
, " Packet Queue length %d\n",
12275 bpacket_queue_virtual_length(paf
));
12277 vty_out(vty
, " Not part of any update group\n");
12279 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12280 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12281 PEER_CAP_ORF_PREFIX_SM_RCV
)
12282 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12283 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12284 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12285 PEER_CAP_ORF_PREFIX_RM_ADV
)
12286 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12287 PEER_CAP_ORF_PREFIX_RM_RCV
)
12288 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12289 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
12290 vty_out(vty
, " AF-dependant capabilities:\n");
12292 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12293 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12294 PEER_CAP_ORF_PREFIX_SM_RCV
)
12295 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12296 PEER_CAP_ORF_PREFIX_RM_ADV
)
12297 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12298 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
12300 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12302 bgp_show_peer_afi_orf_cap(
12303 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12304 PEER_CAP_ORF_PREFIX_RM_ADV
,
12305 PEER_CAP_ORF_PREFIX_SM_RCV
,
12306 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
12308 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
12309 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12310 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
12311 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12312 PEER_CAP_ORF_PREFIX_RM_ADV
)
12313 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
12314 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
12316 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
12317 ORF_TYPE_PREFIX_OLD
);
12318 bgp_show_peer_afi_orf_cap(
12319 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
12320 PEER_CAP_ORF_PREFIX_RM_ADV
,
12321 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
12322 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
12325 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
12326 p
->host
, afi
, safi
);
12327 orf_pfx_count
= prefix_bgp_show_prefix_list(
12328 NULL
, afi
, orf_pfx_name
, use_json
);
12330 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12331 PEER_STATUS_ORF_PREFIX_SEND
)
12332 || orf_pfx_count
) {
12333 vty_out(vty
, " Outbound Route Filter (ORF):");
12334 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12335 PEER_STATUS_ORF_PREFIX_SEND
))
12336 vty_out(vty
, " sent;");
12338 vty_out(vty
, " received (%d entries)",
12340 vty_out(vty
, "\n");
12342 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12343 PEER_STATUS_ORF_WAIT_REFRESH
))
12345 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
12347 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12348 PEER_FLAG_REFLECTOR_CLIENT
))
12349 vty_out(vty
, " Route-Reflector Client\n");
12350 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12351 PEER_FLAG_RSERVER_CLIENT
))
12352 vty_out(vty
, " Route-Server Client\n");
12353 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
12355 " Inbound soft reconfiguration allowed\n");
12357 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12358 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
12360 " Private AS numbers (all) replaced in updates to this neighbor\n");
12361 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12362 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
12364 " Private AS numbers replaced in updates to this neighbor\n");
12365 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12366 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
12368 " Private AS numbers (all) removed in updates to this neighbor\n");
12369 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12370 PEER_FLAG_REMOVE_PRIVATE_AS
))
12372 " Private AS numbers removed in updates to this neighbor\n");
12374 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
12375 vty_out(vty
, " %s\n",
12376 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
12377 ->human_description
);
12379 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
12381 " Override ASNs in outbound updates if aspath equals remote-as\n");
12383 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
12384 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12385 PEER_FLAG_FORCE_NEXTHOP_SELF
))
12386 vty_out(vty
, " NEXT_HOP is always this router\n");
12387 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12388 PEER_FLAG_AS_PATH_UNCHANGED
))
12390 " AS_PATH is propagated unchanged to this neighbor\n");
12391 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12392 PEER_FLAG_NEXTHOP_UNCHANGED
))
12394 " NEXT_HOP is propagated unchanged to this neighbor\n");
12395 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
12397 " MED is propagated unchanged to this neighbor\n");
12398 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
12399 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12400 PEER_FLAG_SEND_EXT_COMMUNITY
)
12401 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
12402 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
12404 " Community attribute sent to this neighbor");
12405 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12406 PEER_FLAG_SEND_COMMUNITY
)
12407 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12408 PEER_FLAG_SEND_EXT_COMMUNITY
)
12409 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
12410 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12411 vty_out(vty
, "(all)\n");
12412 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12413 PEER_FLAG_SEND_LARGE_COMMUNITY
))
12414 vty_out(vty
, "(large)\n");
12415 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12416 PEER_FLAG_SEND_EXT_COMMUNITY
))
12417 vty_out(vty
, "(extended)\n");
12419 vty_out(vty
, "(standard)\n");
12421 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12422 PEER_FLAG_DEFAULT_ORIGINATE
)) {
12423 vty_out(vty
, " Default information originate,");
12425 if (p
->default_rmap
[afi
][safi
].name
)
12426 vty_out(vty
, " default route-map %s%s,",
12427 p
->default_rmap
[afi
][safi
].map
? "*"
12429 p
->default_rmap
[afi
][safi
].name
);
12430 if (paf
&& PAF_SUBGRP(paf
)
12431 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
12432 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
12433 vty_out(vty
, " default sent\n");
12435 vty_out(vty
, " default not sent\n");
12438 /* advertise-vni-all */
12439 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
12440 if (is_evpn_enabled())
12441 vty_out(vty
, " advertise-all-vni\n");
12444 if (filter
->plist
[FILTER_IN
].name
12445 || filter
->dlist
[FILTER_IN
].name
12446 || filter
->aslist
[FILTER_IN
].name
12447 || filter
->map
[RMAP_IN
].name
)
12448 vty_out(vty
, " Inbound path policy configured\n");
12449 if (filter
->plist
[FILTER_OUT
].name
12450 || filter
->dlist
[FILTER_OUT
].name
12451 || filter
->aslist
[FILTER_OUT
].name
12452 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
12453 vty_out(vty
, " Outbound path policy configured\n");
12456 if (filter
->plist
[FILTER_IN
].name
)
12458 " Incoming update prefix filter list is %s%s\n",
12459 filter
->plist
[FILTER_IN
].plist
? "*" : "",
12460 filter
->plist
[FILTER_IN
].name
);
12461 if (filter
->plist
[FILTER_OUT
].name
)
12463 " Outgoing update prefix filter list is %s%s\n",
12464 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
12465 filter
->plist
[FILTER_OUT
].name
);
12467 /* distribute-list */
12468 if (filter
->dlist
[FILTER_IN
].name
)
12470 " Incoming update network filter list is %s%s\n",
12471 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
12472 filter
->dlist
[FILTER_IN
].name
);
12473 if (filter
->dlist
[FILTER_OUT
].name
)
12475 " Outgoing update network filter list is %s%s\n",
12476 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
12477 filter
->dlist
[FILTER_OUT
].name
);
12480 if (filter
->aslist
[FILTER_IN
].name
)
12482 " Incoming update AS path filter list is %s%s\n",
12483 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
12484 filter
->aslist
[FILTER_IN
].name
);
12485 if (filter
->aslist
[FILTER_OUT
].name
)
12487 " Outgoing update AS path filter list is %s%s\n",
12488 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
12489 filter
->aslist
[FILTER_OUT
].name
);
12492 if (filter
->map
[RMAP_IN
].name
)
12494 " Route map for incoming advertisements is %s%s\n",
12495 filter
->map
[RMAP_IN
].map
? "*" : "",
12496 filter
->map
[RMAP_IN
].name
);
12497 if (filter
->map
[RMAP_OUT
].name
)
12499 " Route map for outgoing advertisements is %s%s\n",
12500 filter
->map
[RMAP_OUT
].map
? "*" : "",
12501 filter
->map
[RMAP_OUT
].name
);
12503 /* ebgp-requires-policy (inbound) */
12504 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12505 && !bgp_inbound_policy_exists(p
, filter
))
12507 " Inbound updates discarded due to missing policy\n");
12509 /* ebgp-requires-policy (outbound) */
12510 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
12511 && !bgp_outbound_policy_exists(p
, filter
))
12513 " Outbound updates discarded due to missing policy\n");
12515 /* unsuppress-map */
12516 if (filter
->usmap
.name
)
12518 " Route map for selective unsuppress is %s%s\n",
12519 filter
->usmap
.map
? "*" : "",
12520 filter
->usmap
.name
);
12522 /* advertise-map */
12523 if (filter
->advmap
.aname
&& filter
->advmap
.cname
)
12525 " Condition %s, Condition-map %s%s, Advertise-map %s%s, status: %s\n",
12526 filter
->advmap
.condition
? "EXIST"
12528 filter
->advmap
.cmap
? "*" : "",
12529 filter
->advmap
.cname
,
12530 filter
->advmap
.amap
? "*" : "",
12531 filter
->advmap
.aname
,
12532 filter
->advmap
.update_type
== ADVERTISE
12536 /* Receive prefix count */
12537 vty_out(vty
, " %u accepted prefixes\n",
12538 p
->pcount
[afi
][safi
]);
12540 /* maximum-prefix-out */
12541 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
12542 PEER_FLAG_MAX_PREFIX_OUT
))
12544 " Maximum allowed prefixes sent %u\n",
12545 p
->pmax_out
[afi
][safi
]);
12547 /* Maximum prefix */
12548 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
12550 " Maximum prefixes allowed %u%s\n",
12551 p
->pmax
[afi
][safi
],
12552 CHECK_FLAG(p
->af_flags
[afi
][safi
],
12553 PEER_FLAG_MAX_PREFIX_WARNING
)
12554 ? " (warning-only)"
12556 vty_out(vty
, " Threshold for warning message %d%%",
12557 p
->pmax_threshold
[afi
][safi
]);
12558 if (p
->pmax_restart
[afi
][safi
])
12559 vty_out(vty
, ", restart interval %d min",
12560 p
->pmax_restart
[afi
][safi
]);
12561 vty_out(vty
, "\n");
12564 vty_out(vty
, "\n");
12568 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
12572 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
12573 char timebuf
[BGP_UPTIME_LEN
];
12579 json_object
*json_neigh
= NULL
;
12585 json_neigh
= json_object_new_object();
12587 memset(dn_flag
, '\0', sizeof(dn_flag
));
12588 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
12592 if (p
->conf_if
) /* Configured interface name. */
12593 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
12594 BGP_PEER_SU_UNSPEC(p
)
12596 : sockunion2str(&p
->su
, buf
,
12598 else /* Configured IP address. */
12599 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
12604 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
12605 json_object_string_add(json_neigh
, "bgpNeighborAddr",
12607 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
12608 json_object_string_add(
12609 json_neigh
, "bgpNeighborAddr",
12610 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
12612 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
12614 if (p
->change_local_as
)
12615 json_object_int_add(json_neigh
, "localAs",
12616 p
->change_local_as
);
12618 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
12620 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
12621 json_object_boolean_true_add(json_neigh
,
12622 "localAsNoPrepend");
12624 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
12625 json_object_boolean_true_add(json_neigh
,
12626 "localAsReplaceAs");
12628 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
12629 || (p
->as_type
== AS_INTERNAL
))
12630 vty_out(vty
, "remote AS %u, ", p
->as
);
12632 vty_out(vty
, "remote AS Unspecified, ");
12633 vty_out(vty
, "local AS %u%s%s, ",
12634 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
12635 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
12638 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
12642 /* peer type internal or confed-internal */
12643 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
12645 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12646 json_object_boolean_true_add(
12647 json_neigh
, "nbrConfedInternalLink");
12649 json_object_boolean_true_add(json_neigh
,
12650 "nbrInternalLink");
12652 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12653 vty_out(vty
, "confed-internal link\n");
12655 vty_out(vty
, "internal link\n");
12657 /* peer type external or confed-external */
12658 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
12660 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
12661 json_object_boolean_true_add(
12662 json_neigh
, "nbrConfedExternalLink");
12664 json_object_boolean_true_add(json_neigh
,
12665 "nbrExternalLink");
12667 if (bgp_confederation_peers_check(bgp
, p
->as
))
12668 vty_out(vty
, "confed-external link\n");
12670 vty_out(vty
, "external link\n");
12674 json_object_boolean_true_add(json_neigh
,
12675 "nbrUnspecifiedLink");
12677 vty_out(vty
, "unspecified link\n");
12683 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
12685 vty_out(vty
, " Description: %s\n", p
->desc
);
12691 json_object_string_add(json_neigh
, "hostname",
12695 json_object_string_add(json_neigh
, "domainname",
12698 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
12699 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
12702 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
12709 json_object_string_add(json_neigh
, "peerGroup",
12713 struct prefix prefix
, *range
= NULL
;
12715 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12716 range
= peer_group_lookup_dynamic_neighbor_range(
12717 p
->group
, &prefix
);
12720 prefix2str(range
, buf1
, sizeof(buf1
));
12721 json_object_string_add(
12723 "peerSubnetRangeGroup", buf1
);
12728 " Member of peer-group %s for session parameters\n",
12732 struct prefix prefix
, *range
= NULL
;
12734 if (sockunion2hostprefix(&(p
->su
), &prefix
))
12735 range
= peer_group_lookup_dynamic_neighbor_range(
12736 p
->group
, &prefix
);
12740 " Belongs to the subnet range group: %pFX\n",
12748 /* Administrative shutdown. */
12749 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12750 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12751 json_object_boolean_true_add(json_neigh
,
12755 json_object_int_add(json_neigh
, "bgpVersion", 4);
12756 json_object_string_add(
12757 json_neigh
, "remoteRouterId",
12758 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12759 json_object_string_add(
12760 json_neigh
, "localRouterId",
12761 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12764 /* Confederation */
12765 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12766 && bgp_confederation_peers_check(bgp
, p
->as
))
12767 json_object_boolean_true_add(json_neigh
,
12771 json_object_string_add(
12772 json_neigh
, "bgpState",
12773 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12775 if (p
->status
== Established
) {
12778 uptime
= bgp_clock();
12779 uptime
-= p
->uptime
;
12780 epoch_tbuf
= time(NULL
) - uptime
;
12782 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
12784 json_object_string_add(json_neigh
, "bgpTimerUpString",
12785 peer_uptime(p
->uptime
, timebuf
,
12788 json_object_int_add(json_neigh
,
12789 "bgpTimerUpEstablishedEpoch",
12793 else if (p
->status
== Active
) {
12794 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12795 json_object_string_add(json_neigh
, "bgpStateIs",
12797 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12798 json_object_string_add(json_neigh
, "bgpStateIs",
12806 uptime
= bgp_clock();
12807 uptime
-= p
->readtime
;
12808 gmtime_r(&uptime
, &tm
);
12810 json_object_int_add(json_neigh
, "bgpTimerLastRead",
12811 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12812 + (tm
.tm_hour
* 3600000));
12814 uptime
= bgp_clock();
12815 uptime
-= p
->last_write
;
12816 gmtime_r(&uptime
, &tm
);
12818 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
12819 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12820 + (tm
.tm_hour
* 3600000));
12822 uptime
= bgp_clock();
12823 uptime
-= p
->update_time
;
12824 gmtime_r(&uptime
, &tm
);
12826 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
12827 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
12828 + (tm
.tm_hour
* 3600000));
12830 /* Configured timer values. */
12831 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
12832 p
->v_holdtime
* 1000);
12833 json_object_int_add(json_neigh
,
12834 "bgpTimerKeepAliveIntervalMsecs",
12835 p
->v_keepalive
* 1000);
12836 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
)) {
12837 json_object_int_add(json_neigh
,
12838 "bgpTimerDelayOpenTimeMsecs",
12839 p
->v_delayopen
* 1000);
12842 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12843 json_object_int_add(json_neigh
,
12844 "bgpTimerConfiguredHoldTimeMsecs",
12845 p
->holdtime
* 1000);
12846 json_object_int_add(
12848 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12849 p
->keepalive
* 1000);
12850 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12851 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12852 json_object_int_add(json_neigh
,
12853 "bgpTimerConfiguredHoldTimeMsecs",
12854 bgp
->default_holdtime
);
12855 json_object_int_add(
12857 "bgpTimerConfiguredKeepAliveIntervalMsecs",
12858 bgp
->default_keepalive
);
12861 /* Administrative shutdown. */
12862 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
12863 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
12864 vty_out(vty
, " Administratively shut down\n");
12867 vty_out(vty
, " BGP version 4");
12868 vty_out(vty
, ", remote router ID %s",
12869 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
12870 vty_out(vty
, ", local router ID %s\n",
12871 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
12874 /* Confederation */
12875 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
12876 && bgp_confederation_peers_check(bgp
, p
->as
))
12878 " Neighbor under common administration\n");
12881 vty_out(vty
, " BGP state = %s",
12882 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
12884 if (p
->status
== Established
)
12885 vty_out(vty
, ", up for %8s",
12886 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
12889 else if (p
->status
== Active
) {
12890 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
12891 vty_out(vty
, " (passive)");
12892 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
12893 vty_out(vty
, " (NSF passive)");
12895 vty_out(vty
, "\n");
12898 vty_out(vty
, " Last read %s",
12899 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
12901 vty_out(vty
, ", Last write %s\n",
12902 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
12905 /* Configured timer values. */
12907 " Hold time is %d, keepalive interval is %d seconds\n",
12908 p
->v_holdtime
, p
->v_keepalive
);
12909 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
12910 vty_out(vty
, " Configured hold time is %d",
12912 vty_out(vty
, ", keepalive interval is %d seconds\n",
12914 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
12915 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
12916 vty_out(vty
, " Configured hold time is %d",
12917 bgp
->default_holdtime
);
12918 vty_out(vty
, ", keepalive interval is %d seconds\n",
12919 bgp
->default_keepalive
);
12921 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER_DELAYOPEN
))
12923 " Configured DelayOpenTime is %d seconds\n",
12927 if (p
->status
== Established
) {
12928 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
12929 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
12930 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
12931 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
12932 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
12933 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
12934 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
12935 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
12936 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
12937 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
12938 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
12939 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
12940 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
12941 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
12942 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
12943 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
12944 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
12945 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
12946 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
12947 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
12949 json_object
*json_cap
= NULL
;
12951 json_cap
= json_object_new_object();
12954 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
12955 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
12956 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
12957 && CHECK_FLAG(p
->cap
,
12959 json_object_string_add(
12960 json_cap
, "4byteAs",
12961 "advertisedAndReceived");
12962 else if (CHECK_FLAG(p
->cap
,
12964 json_object_string_add(
12965 json_cap
, "4byteAs",
12967 else if (CHECK_FLAG(p
->cap
,
12969 json_object_string_add(
12970 json_cap
, "4byteAs",
12974 /* Extended Message Support */
12975 if (CHECK_FLAG(p
->cap
,
12976 PEER_CAP_EXTENDED_MESSAGE_ADV
)
12979 PEER_CAP_EXTENDED_MESSAGE_RCV
))
12980 json_object_string_add(
12981 json_cap
, "extendedMessage",
12982 "advertisedAndReceived");
12983 else if (CHECK_FLAG(
12985 PEER_CAP_EXTENDED_MESSAGE_ADV
))
12986 json_object_string_add(
12987 json_cap
, "extendedMessage",
12989 else if (CHECK_FLAG(
12991 PEER_CAP_EXTENDED_MESSAGE_RCV
))
12992 json_object_string_add(
12993 json_cap
, "extendedMessage",
12997 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
12998 || CHECK_FLAG(p
->cap
,
12999 PEER_CAP_ADDPATH_ADV
)) {
13000 json_object
*json_add
= NULL
;
13001 const char *print_store
;
13003 json_add
= json_object_new_object();
13005 FOREACH_AFI_SAFI (afi
, safi
) {
13006 json_object
*json_sub
= NULL
;
13008 json_object_new_object();
13009 print_store
= get_afi_safi_str(
13015 PEER_CAP_ADDPATH_AF_TX_ADV
)
13019 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13024 PEER_CAP_ADDPATH_AF_TX_ADV
)
13029 PEER_CAP_ADDPATH_AF_TX_RCV
))
13030 json_object_boolean_true_add(
13032 "txAdvertisedAndReceived");
13038 PEER_CAP_ADDPATH_AF_TX_ADV
))
13039 json_object_boolean_true_add(
13047 PEER_CAP_ADDPATH_AF_TX_RCV
))
13048 json_object_boolean_true_add(
13056 PEER_CAP_ADDPATH_AF_RX_ADV
)
13060 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13065 PEER_CAP_ADDPATH_AF_RX_ADV
)
13070 PEER_CAP_ADDPATH_AF_RX_RCV
))
13071 json_object_boolean_true_add(
13073 "rxAdvertisedAndReceived");
13079 PEER_CAP_ADDPATH_AF_RX_ADV
))
13080 json_object_boolean_true_add(
13088 PEER_CAP_ADDPATH_AF_RX_RCV
))
13089 json_object_boolean_true_add(
13097 PEER_CAP_ADDPATH_AF_TX_ADV
)
13101 PEER_CAP_ADDPATH_AF_TX_RCV
)
13105 PEER_CAP_ADDPATH_AF_RX_ADV
)
13109 PEER_CAP_ADDPATH_AF_RX_RCV
))
13110 json_object_object_add(
13119 json_object_object_add(
13120 json_cap
, "addPath", json_add
);
13124 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
13125 || CHECK_FLAG(p
->cap
,
13126 PEER_CAP_DYNAMIC_ADV
)) {
13127 if (CHECK_FLAG(p
->cap
,
13128 PEER_CAP_DYNAMIC_ADV
)
13129 && CHECK_FLAG(p
->cap
,
13130 PEER_CAP_DYNAMIC_RCV
))
13131 json_object_string_add(
13132 json_cap
, "dynamic",
13133 "advertisedAndReceived");
13134 else if (CHECK_FLAG(
13136 PEER_CAP_DYNAMIC_ADV
))
13137 json_object_string_add(
13138 json_cap
, "dynamic",
13140 else if (CHECK_FLAG(
13142 PEER_CAP_DYNAMIC_RCV
))
13143 json_object_string_add(
13144 json_cap
, "dynamic",
13148 /* Extended nexthop */
13149 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
13150 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13151 json_object
*json_nxt
= NULL
;
13152 const char *print_store
;
13155 if (CHECK_FLAG(p
->cap
,
13157 && CHECK_FLAG(p
->cap
,
13158 PEER_CAP_ENHE_RCV
))
13159 json_object_string_add(
13162 "advertisedAndReceived");
13163 else if (CHECK_FLAG(p
->cap
,
13164 PEER_CAP_ENHE_ADV
))
13165 json_object_string_add(
13169 else if (CHECK_FLAG(p
->cap
,
13170 PEER_CAP_ENHE_RCV
))
13171 json_object_string_add(
13176 if (CHECK_FLAG(p
->cap
,
13177 PEER_CAP_ENHE_RCV
)) {
13179 json_object_new_object();
13181 for (safi
= SAFI_UNICAST
;
13182 safi
< SAFI_MAX
; safi
++) {
13187 PEER_CAP_ENHE_AF_RCV
)) {
13188 print_store
= get_afi_safi_str(
13191 json_object_string_add(
13194 "recieved"); /* misspelled for compatibility */
13197 json_object_object_add(
13199 "extendedNexthopFamililesByPeer",
13204 /* Route Refresh */
13205 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
13206 || CHECK_FLAG(p
->cap
,
13207 PEER_CAP_REFRESH_NEW_RCV
)
13208 || CHECK_FLAG(p
->cap
,
13209 PEER_CAP_REFRESH_OLD_RCV
)) {
13210 if (CHECK_FLAG(p
->cap
,
13211 PEER_CAP_REFRESH_ADV
)
13214 PEER_CAP_REFRESH_NEW_RCV
)
13217 PEER_CAP_REFRESH_OLD_RCV
))) {
13220 PEER_CAP_REFRESH_OLD_RCV
)
13223 PEER_CAP_REFRESH_NEW_RCV
))
13224 json_object_string_add(
13227 "advertisedAndReceivedOldNew");
13231 PEER_CAP_REFRESH_OLD_RCV
))
13232 json_object_string_add(
13235 "advertisedAndReceivedOld");
13237 json_object_string_add(
13240 "advertisedAndReceivedNew");
13245 PEER_CAP_REFRESH_ADV
))
13246 json_object_string_add(
13253 PEER_CAP_REFRESH_NEW_RCV
)
13256 PEER_CAP_REFRESH_OLD_RCV
))
13257 json_object_string_add(
13263 /* Enhanced Route Refresh */
13264 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
)
13265 || CHECK_FLAG(p
->cap
,
13266 PEER_CAP_ENHANCED_RR_RCV
)) {
13267 if (CHECK_FLAG(p
->cap
,
13268 PEER_CAP_ENHANCED_RR_ADV
)
13271 PEER_CAP_ENHANCED_RR_RCV
))
13272 json_object_string_add(
13274 "enhancedRouteRefresh",
13275 "advertisedAndReceived");
13279 PEER_CAP_ENHANCED_RR_ADV
))
13280 json_object_string_add(
13282 "enhancedRouteRefresh",
13287 PEER_CAP_ENHANCED_RR_RCV
))
13288 json_object_string_add(
13290 "enhancedRouteRefresh",
13294 /* Multiprotocol Extensions */
13295 json_object
*json_multi
= NULL
;
13296 json_multi
= json_object_new_object();
13298 FOREACH_AFI_SAFI (afi
, safi
) {
13299 if (p
->afc_adv
[afi
][safi
]
13300 || p
->afc_recv
[afi
][safi
]) {
13301 json_object
*json_exten
= NULL
;
13303 json_object_new_object();
13305 if (p
->afc_adv
[afi
][safi
]
13306 && p
->afc_recv
[afi
][safi
])
13307 json_object_boolean_true_add(
13309 "advertisedAndReceived");
13310 else if (p
->afc_adv
[afi
][safi
])
13311 json_object_boolean_true_add(
13314 else if (p
->afc_recv
[afi
][safi
])
13315 json_object_boolean_true_add(
13319 json_object_object_add(
13321 get_afi_safi_str(afi
,
13327 json_object_object_add(
13328 json_cap
, "multiprotocolExtensions",
13331 /* Hostname capabilities */
13332 json_object
*json_hname
= NULL
;
13334 json_hname
= json_object_new_object();
13336 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13337 json_object_string_add(
13338 json_hname
, "advHostName",
13339 bgp
->peer_self
->hostname
13343 json_object_string_add(
13344 json_hname
, "advDomainName",
13345 bgp
->peer_self
->domainname
13352 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13353 json_object_string_add(
13354 json_hname
, "rcvHostName",
13355 p
->hostname
? p
->hostname
13357 json_object_string_add(
13358 json_hname
, "rcvDomainName",
13359 p
->domainname
? p
->domainname
13363 json_object_object_add(json_cap
, "hostName",
13366 /* Gracefull Restart */
13367 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
13368 || CHECK_FLAG(p
->cap
,
13369 PEER_CAP_RESTART_ADV
)) {
13370 if (CHECK_FLAG(p
->cap
,
13371 PEER_CAP_RESTART_ADV
)
13372 && CHECK_FLAG(p
->cap
,
13373 PEER_CAP_RESTART_RCV
))
13374 json_object_string_add(
13377 "advertisedAndReceived");
13378 else if (CHECK_FLAG(
13380 PEER_CAP_RESTART_ADV
))
13381 json_object_string_add(
13383 "gracefulRestartCapability",
13385 else if (CHECK_FLAG(
13387 PEER_CAP_RESTART_RCV
))
13388 json_object_string_add(
13390 "gracefulRestartCapability",
13393 if (CHECK_FLAG(p
->cap
,
13394 PEER_CAP_RESTART_RCV
)) {
13395 int restart_af_count
= 0;
13396 json_object
*json_restart
=
13399 json_object_new_object();
13401 json_object_int_add(
13403 "gracefulRestartRemoteTimerMsecs",
13404 p
->v_gr_restart
* 1000);
13406 FOREACH_AFI_SAFI (afi
, safi
) {
13411 PEER_CAP_RESTART_AF_RCV
)) {
13416 json_object_new_object();
13422 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
13423 json_object_boolean_true_add(
13426 restart_af_count
++;
13427 json_object_object_add(
13436 if (!restart_af_count
) {
13437 json_object_string_add(
13439 "addressFamiliesByPeer",
13444 json_object_object_add(
13446 "addressFamiliesByPeer",
13450 json_object_object_add(json_neigh
,
13451 "neighborCapabilities",
13454 vty_out(vty
, " Neighbor capabilities:\n");
13457 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
13458 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
13459 vty_out(vty
, " 4 Byte AS:");
13460 if (CHECK_FLAG(p
->cap
,
13462 vty_out(vty
, " advertised");
13463 if (CHECK_FLAG(p
->cap
,
13465 vty_out(vty
, " %sreceived",
13471 vty_out(vty
, "\n");
13474 /* Extended Message Support */
13475 if (CHECK_FLAG(p
->cap
,
13476 PEER_CAP_EXTENDED_MESSAGE_RCV
)
13479 PEER_CAP_EXTENDED_MESSAGE_ADV
)) {
13480 vty_out(vty
, " Extended Message:");
13483 PEER_CAP_EXTENDED_MESSAGE_ADV
))
13484 vty_out(vty
, " advertised");
13487 PEER_CAP_EXTENDED_MESSAGE_RCV
))
13488 vty_out(vty
, " %sreceived",
13491 PEER_CAP_EXTENDED_MESSAGE_ADV
)
13494 vty_out(vty
, "\n");
13498 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
13499 || CHECK_FLAG(p
->cap
,
13500 PEER_CAP_ADDPATH_ADV
)) {
13501 vty_out(vty
, " AddPath:\n");
13503 FOREACH_AFI_SAFI (afi
, safi
) {
13507 PEER_CAP_ADDPATH_AF_TX_ADV
)
13511 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
13523 PEER_CAP_ADDPATH_AF_TX_ADV
))
13535 PEER_CAP_ADDPATH_AF_TX_RCV
))
13542 PEER_CAP_ADDPATH_AF_TX_ADV
)
13546 vty_out(vty
, "\n");
13552 PEER_CAP_ADDPATH_AF_RX_ADV
)
13556 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
13568 PEER_CAP_ADDPATH_AF_RX_ADV
))
13580 PEER_CAP_ADDPATH_AF_RX_RCV
))
13587 PEER_CAP_ADDPATH_AF_RX_ADV
)
13591 vty_out(vty
, "\n");
13597 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
13598 || CHECK_FLAG(p
->cap
,
13599 PEER_CAP_DYNAMIC_ADV
)) {
13600 vty_out(vty
, " Dynamic:");
13601 if (CHECK_FLAG(p
->cap
,
13602 PEER_CAP_DYNAMIC_ADV
))
13603 vty_out(vty
, " advertised");
13604 if (CHECK_FLAG(p
->cap
,
13605 PEER_CAP_DYNAMIC_RCV
))
13606 vty_out(vty
, " %sreceived",
13609 PEER_CAP_DYNAMIC_ADV
)
13612 vty_out(vty
, "\n");
13615 /* Extended nexthop */
13616 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
13617 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
13618 vty_out(vty
, " Extended nexthop:");
13619 if (CHECK_FLAG(p
->cap
,
13620 PEER_CAP_ENHE_ADV
))
13621 vty_out(vty
, " advertised");
13622 if (CHECK_FLAG(p
->cap
,
13623 PEER_CAP_ENHE_RCV
))
13624 vty_out(vty
, " %sreceived",
13630 vty_out(vty
, "\n");
13632 if (CHECK_FLAG(p
->cap
,
13633 PEER_CAP_ENHE_RCV
)) {
13635 " Address families by peer:\n ");
13636 for (safi
= SAFI_UNICAST
;
13637 safi
< SAFI_MAX
; safi
++)
13642 PEER_CAP_ENHE_AF_RCV
))
13652 /* Route Refresh */
13653 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
13654 || CHECK_FLAG(p
->cap
,
13655 PEER_CAP_REFRESH_NEW_RCV
)
13656 || CHECK_FLAG(p
->cap
,
13657 PEER_CAP_REFRESH_OLD_RCV
)) {
13658 vty_out(vty
, " Route refresh:");
13659 if (CHECK_FLAG(p
->cap
,
13660 PEER_CAP_REFRESH_ADV
))
13661 vty_out(vty
, " advertised");
13662 if (CHECK_FLAG(p
->cap
,
13663 PEER_CAP_REFRESH_NEW_RCV
)
13666 PEER_CAP_REFRESH_OLD_RCV
))
13667 vty_out(vty
, " %sreceived(%s)",
13670 PEER_CAP_REFRESH_ADV
)
13675 PEER_CAP_REFRESH_OLD_RCV
)
13678 PEER_CAP_REFRESH_NEW_RCV
))
13682 PEER_CAP_REFRESH_OLD_RCV
)
13686 vty_out(vty
, "\n");
13689 /* Enhanced Route Refresh */
13690 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHANCED_RR_ADV
)
13691 || CHECK_FLAG(p
->cap
,
13692 PEER_CAP_ENHANCED_RR_RCV
)) {
13694 " Enhanced Route Refresh:");
13697 PEER_CAP_ENHANCED_RR_ADV
))
13698 vty_out(vty
, " advertised");
13701 PEER_CAP_ENHANCED_RR_RCV
))
13702 vty_out(vty
, " %sreceived",
13705 PEER_CAP_REFRESH_ADV
)
13708 vty_out(vty
, "\n");
13711 /* Multiprotocol Extensions */
13712 FOREACH_AFI_SAFI (afi
, safi
)
13713 if (p
->afc_adv
[afi
][safi
]
13714 || p
->afc_recv
[afi
][safi
]) {
13716 " Address Family %s:",
13721 if (p
->afc_adv
[afi
][safi
])
13724 if (p
->afc_recv
[afi
][safi
])
13731 vty_out(vty
, "\n");
13734 /* Hostname capability */
13735 vty_out(vty
, " Hostname Capability:");
13737 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
13739 " advertised (name: %s,domain name: %s)",
13740 bgp
->peer_self
->hostname
13744 bgp
->peer_self
->domainname
13749 vty_out(vty
, " not advertised");
13752 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
13754 " received (name: %s,domain name: %s)",
13755 p
->hostname
? p
->hostname
13757 p
->domainname
? p
->domainname
13760 vty_out(vty
, " not received");
13763 vty_out(vty
, "\n");
13765 /* Graceful Restart */
13766 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
13767 || CHECK_FLAG(p
->cap
,
13768 PEER_CAP_RESTART_ADV
)) {
13770 " Graceful Restart Capability:");
13771 if (CHECK_FLAG(p
->cap
,
13772 PEER_CAP_RESTART_ADV
))
13773 vty_out(vty
, " advertised");
13774 if (CHECK_FLAG(p
->cap
,
13775 PEER_CAP_RESTART_RCV
))
13776 vty_out(vty
, " %sreceived",
13779 PEER_CAP_RESTART_ADV
)
13782 vty_out(vty
, "\n");
13784 if (CHECK_FLAG(p
->cap
,
13785 PEER_CAP_RESTART_RCV
)) {
13786 int restart_af_count
= 0;
13789 " Remote Restart timer is %d seconds\n",
13792 " Address families by peer:\n ");
13794 FOREACH_AFI_SAFI (afi
, safi
)
13799 PEER_CAP_RESTART_AF_RCV
)) {
13813 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
13815 : "not preserved");
13816 restart_af_count
++;
13818 if (!restart_af_count
)
13819 vty_out(vty
, "none");
13820 vty_out(vty
, "\n");
13822 } /* Gracefull Restart */
13827 /* graceful restart information */
13828 json_object
*json_grace
= NULL
;
13829 json_object
*json_grace_send
= NULL
;
13830 json_object
*json_grace_recv
= NULL
;
13831 int eor_send_af_count
= 0;
13832 int eor_receive_af_count
= 0;
13835 json_grace
= json_object_new_object();
13836 json_grace_send
= json_object_new_object();
13837 json_grace_recv
= json_object_new_object();
13839 if ((p
->status
== Established
)
13840 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13841 FOREACH_AFI_SAFI (afi
, safi
) {
13842 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13843 PEER_STATUS_EOR_SEND
)) {
13844 json_object_boolean_true_add(
13846 get_afi_safi_str(afi
,
13849 eor_send_af_count
++;
13852 FOREACH_AFI_SAFI (afi
, safi
) {
13854 p
->af_sflags
[afi
][safi
],
13855 PEER_STATUS_EOR_RECEIVED
)) {
13856 json_object_boolean_true_add(
13858 get_afi_safi_str(afi
,
13861 eor_receive_af_count
++;
13865 json_object_object_add(json_grace
, "endOfRibSend",
13867 json_object_object_add(json_grace
, "endOfRibRecv",
13871 if (p
->t_gr_restart
)
13872 json_object_int_add(json_grace
,
13873 "gracefulRestartTimerMsecs",
13874 thread_timer_remain_second(
13879 json_object_int_add(
13881 "gracefulStalepathTimerMsecs",
13882 thread_timer_remain_second(
13885 /* more gr info in new format */
13886 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
,
13888 json_object_object_add(
13889 json_neigh
, "gracefulRestartInfo", json_grace
);
13891 vty_out(vty
, " Graceful restart information:\n");
13892 if ((p
->status
== Established
)
13893 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
13895 vty_out(vty
, " End-of-RIB send: ");
13896 FOREACH_AFI_SAFI (afi
, safi
) {
13897 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
13898 PEER_STATUS_EOR_SEND
)) {
13899 vty_out(vty
, "%s%s",
13900 eor_send_af_count
? ", "
13905 eor_send_af_count
++;
13908 vty_out(vty
, "\n");
13909 vty_out(vty
, " End-of-RIB received: ");
13910 FOREACH_AFI_SAFI (afi
, safi
) {
13912 p
->af_sflags
[afi
][safi
],
13913 PEER_STATUS_EOR_RECEIVED
)) {
13914 vty_out(vty
, "%s%s",
13915 eor_receive_af_count
13918 get_afi_safi_str(afi
,
13921 eor_receive_af_count
++;
13924 vty_out(vty
, "\n");
13927 if (p
->t_gr_restart
)
13929 " The remaining time of restart timer is %ld\n",
13930 thread_timer_remain_second(
13935 " The remaining time of stalepath timer is %ld\n",
13936 thread_timer_remain_second(
13939 /* more gr info in new format */
13940 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
13944 json_object
*json_stat
= NULL
;
13945 json_stat
= json_object_new_object();
13946 /* Packet counts. */
13948 atomic_size_t outq_count
, inq_count
;
13949 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
13950 memory_order_relaxed
);
13951 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
13952 memory_order_relaxed
);
13954 json_object_int_add(json_stat
, "depthInq",
13955 (unsigned long)inq_count
);
13956 json_object_int_add(json_stat
, "depthOutq",
13957 (unsigned long)outq_count
);
13958 json_object_int_add(json_stat
, "opensSent",
13959 atomic_load_explicit(&p
->open_out
,
13960 memory_order_relaxed
));
13961 json_object_int_add(json_stat
, "opensRecv",
13962 atomic_load_explicit(&p
->open_in
,
13963 memory_order_relaxed
));
13964 json_object_int_add(json_stat
, "notificationsSent",
13965 atomic_load_explicit(&p
->notify_out
,
13966 memory_order_relaxed
));
13967 json_object_int_add(json_stat
, "notificationsRecv",
13968 atomic_load_explicit(&p
->notify_in
,
13969 memory_order_relaxed
));
13970 json_object_int_add(json_stat
, "updatesSent",
13971 atomic_load_explicit(&p
->update_out
,
13972 memory_order_relaxed
));
13973 json_object_int_add(json_stat
, "updatesRecv",
13974 atomic_load_explicit(&p
->update_in
,
13975 memory_order_relaxed
));
13976 json_object_int_add(json_stat
, "keepalivesSent",
13977 atomic_load_explicit(&p
->keepalive_out
,
13978 memory_order_relaxed
));
13979 json_object_int_add(json_stat
, "keepalivesRecv",
13980 atomic_load_explicit(&p
->keepalive_in
,
13981 memory_order_relaxed
));
13982 json_object_int_add(json_stat
, "routeRefreshSent",
13983 atomic_load_explicit(&p
->refresh_out
,
13984 memory_order_relaxed
));
13985 json_object_int_add(json_stat
, "routeRefreshRecv",
13986 atomic_load_explicit(&p
->refresh_in
,
13987 memory_order_relaxed
));
13988 json_object_int_add(json_stat
, "capabilitySent",
13989 atomic_load_explicit(&p
->dynamic_cap_out
,
13990 memory_order_relaxed
));
13991 json_object_int_add(json_stat
, "capabilityRecv",
13992 atomic_load_explicit(&p
->dynamic_cap_in
,
13993 memory_order_relaxed
));
13994 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
13995 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
13996 json_object_object_add(json_neigh
, "messageStats", json_stat
);
13998 atomic_size_t outq_count
, inq_count
;
13999 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
14000 memory_order_relaxed
);
14001 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
14002 memory_order_relaxed
);
14004 /* Packet counts. */
14005 vty_out(vty
, " Message statistics:\n");
14006 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
14007 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
14008 vty_out(vty
, " Sent Rcvd\n");
14009 vty_out(vty
, " Opens: %10d %10d\n",
14010 atomic_load_explicit(&p
->open_out
,
14011 memory_order_relaxed
),
14012 atomic_load_explicit(&p
->open_in
,
14013 memory_order_relaxed
));
14014 vty_out(vty
, " Notifications: %10d %10d\n",
14015 atomic_load_explicit(&p
->notify_out
,
14016 memory_order_relaxed
),
14017 atomic_load_explicit(&p
->notify_in
,
14018 memory_order_relaxed
));
14019 vty_out(vty
, " Updates: %10d %10d\n",
14020 atomic_load_explicit(&p
->update_out
,
14021 memory_order_relaxed
),
14022 atomic_load_explicit(&p
->update_in
,
14023 memory_order_relaxed
));
14024 vty_out(vty
, " Keepalives: %10d %10d\n",
14025 atomic_load_explicit(&p
->keepalive_out
,
14026 memory_order_relaxed
),
14027 atomic_load_explicit(&p
->keepalive_in
,
14028 memory_order_relaxed
));
14029 vty_out(vty
, " Route Refresh: %10d %10d\n",
14030 atomic_load_explicit(&p
->refresh_out
,
14031 memory_order_relaxed
),
14032 atomic_load_explicit(&p
->refresh_in
,
14033 memory_order_relaxed
));
14034 vty_out(vty
, " Capability: %10d %10d\n",
14035 atomic_load_explicit(&p
->dynamic_cap_out
,
14036 memory_order_relaxed
),
14037 atomic_load_explicit(&p
->dynamic_cap_in
,
14038 memory_order_relaxed
));
14039 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
14044 /* advertisement-interval */
14045 json_object_int_add(json_neigh
,
14046 "minBtwnAdvertisementRunsTimerMsecs",
14047 p
->v_routeadv
* 1000);
14049 /* Update-source. */
14050 if (p
->update_if
|| p
->update_source
) {
14052 json_object_string_add(json_neigh
,
14055 else if (p
->update_source
)
14056 json_object_string_add(
14057 json_neigh
, "updateSource",
14058 sockunion2str(p
->update_source
, buf1
,
14062 /* advertisement-interval */
14064 " Minimum time between advertisement runs is %d seconds\n",
14067 /* Update-source. */
14068 if (p
->update_if
|| p
->update_source
) {
14069 vty_out(vty
, " Update source is ");
14071 vty_out(vty
, "%s", p
->update_if
);
14072 else if (p
->update_source
)
14074 sockunion2str(p
->update_source
, buf1
,
14076 vty_out(vty
, "\n");
14079 vty_out(vty
, "\n");
14082 /* Address Family Information */
14083 json_object
*json_hold
= NULL
;
14086 json_hold
= json_object_new_object();
14088 FOREACH_AFI_SAFI (afi
, safi
)
14089 if (p
->afc
[afi
][safi
])
14090 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
14094 json_object_object_add(json_neigh
, "addressFamilyInfo",
14096 json_object_int_add(json_neigh
, "connectionsEstablished",
14098 json_object_int_add(json_neigh
, "connectionsDropped",
14101 vty_out(vty
, " Connections established %d; dropped %d\n",
14102 p
->established
, p
->dropped
);
14104 if (!p
->last_reset
) {
14106 json_object_string_add(json_neigh
, "lastReset",
14109 vty_out(vty
, " Last reset never\n");
14115 uptime
= bgp_clock();
14116 uptime
-= p
->resettime
;
14117 gmtime_r(&uptime
, &tm
);
14119 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
14121 + (tm
.tm_min
* 60000)
14122 + (tm
.tm_hour
* 3600000));
14123 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
14125 vty_out(vty
, " Last reset %s, ",
14126 peer_uptime(p
->resettime
, timebuf
,
14127 BGP_UPTIME_LEN
, 0, NULL
));
14129 bgp_show_peer_reset(vty
, p
, NULL
, false);
14130 if (p
->last_reset_cause_size
) {
14131 msg
= p
->last_reset_cause
;
14133 " Message received that caused BGP to send a NOTIFICATION:\n ");
14134 for (i
= 1; i
<= p
->last_reset_cause_size
;
14136 vty_out(vty
, "%02X", *msg
++);
14138 if (i
!= p
->last_reset_cause_size
) {
14140 vty_out(vty
, "\n ");
14141 } else if (i
% 4 == 0) {
14146 vty_out(vty
, "\n");
14151 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
14153 json_object_boolean_true_add(json_neigh
,
14154 "prefixesConfigExceedMax");
14157 " Peer had exceeded the max. no. of prefixes configured.\n");
14159 if (p
->t_pmax_restart
) {
14161 json_object_boolean_true_add(
14162 json_neigh
, "reducePrefixNumFrom");
14163 json_object_int_add(json_neigh
,
14164 "restartInTimerMsec",
14165 thread_timer_remain_second(
14170 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
14171 p
->host
, thread_timer_remain_second(
14172 p
->t_pmax_restart
));
14175 json_object_boolean_true_add(
14177 "reducePrefixNumAndClearIpBgp");
14180 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
14185 /* EBGP Multihop and GTSM */
14186 if (p
->sort
!= BGP_PEER_IBGP
) {
14188 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14189 json_object_int_add(json_neigh
,
14190 "externalBgpNbrMaxHopsAway",
14192 else if (p
->ttl
> BGP_DEFAULT_TTL
)
14193 json_object_int_add(json_neigh
,
14194 "externalBgpNbrMaxHopsAway",
14197 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
14199 " External BGP neighbor may be up to %d hops away.\n",
14201 else if (p
->ttl
> BGP_DEFAULT_TTL
)
14203 " External BGP neighbor may be up to %d hops away.\n",
14207 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
) {
14209 json_object_int_add(json_neigh
,
14210 "internalBgpNbrMaxHopsAway",
14214 " Internal BGP neighbor may be up to %d hops away.\n",
14219 /* Local address. */
14222 json_object_string_add(json_neigh
, "hostLocal",
14223 sockunion2str(p
->su_local
, buf1
,
14225 json_object_int_add(json_neigh
, "portLocal",
14226 ntohs(p
->su_local
->sin
.sin_port
));
14228 vty_out(vty
, "Local host: %s, Local port: %d\n",
14229 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
14230 ntohs(p
->su_local
->sin
.sin_port
));
14233 /* Remote address. */
14234 if (p
->su_remote
) {
14236 json_object_string_add(json_neigh
, "hostForeign",
14237 sockunion2str(p
->su_remote
, buf1
,
14239 json_object_int_add(json_neigh
, "portForeign",
14240 ntohs(p
->su_remote
->sin
.sin_port
));
14242 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
14243 sockunion2str(p
->su_remote
, buf1
,
14245 ntohs(p
->su_remote
->sin
.sin_port
));
14248 /* Nexthop display. */
14251 json_object_string_add(json_neigh
, "nexthop",
14253 &p
->nexthop
.v4
, buf1
,
14255 json_object_string_add(json_neigh
, "nexthopGlobal",
14256 inet_ntop(AF_INET6
,
14257 &p
->nexthop
.v6_global
,
14258 buf1
, sizeof(buf1
)));
14259 json_object_string_add(json_neigh
, "nexthopLocal",
14260 inet_ntop(AF_INET6
,
14261 &p
->nexthop
.v6_local
,
14262 buf1
, sizeof(buf1
)));
14263 if (p
->shared_network
)
14264 json_object_string_add(json_neigh
,
14268 json_object_string_add(json_neigh
,
14270 "nonSharedNetwork");
14272 vty_out(vty
, "Nexthop: %s\n",
14273 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
14275 vty_out(vty
, "Nexthop global: %s\n",
14276 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
14278 vty_out(vty
, "Nexthop local: %s\n",
14279 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
14281 vty_out(vty
, "BGP connection: %s\n",
14282 p
->shared_network
? "shared network"
14283 : "non shared network");
14287 /* Timer information. */
14289 json_object_int_add(json_neigh
, "connectRetryTimer",
14291 if (p
->status
== Established
&& p
->rtt
)
14292 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
14295 json_object_int_add(
14296 json_neigh
, "nextStartTimerDueInMsecs",
14297 thread_timer_remain_second(p
->t_start
) * 1000);
14299 json_object_int_add(
14300 json_neigh
, "nextConnectTimerDueInMsecs",
14301 thread_timer_remain_second(p
->t_connect
)
14303 if (p
->t_routeadv
) {
14304 json_object_int_add(json_neigh
, "mraiInterval",
14306 json_object_int_add(
14307 json_neigh
, "mraiTimerExpireInMsecs",
14308 thread_timer_remain_second(p
->t_routeadv
)
14312 json_object_int_add(json_neigh
, "authenticationEnabled",
14316 json_object_string_add(json_neigh
, "readThread", "on");
14318 json_object_string_add(json_neigh
, "readThread", "off");
14320 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
14321 json_object_string_add(json_neigh
, "writeThread", "on");
14323 json_object_string_add(json_neigh
, "writeThread",
14326 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
14328 if (p
->status
== Established
&& p
->rtt
)
14329 vty_out(vty
, "Estimated round trip time: %d ms\n",
14332 vty_out(vty
, "Next start timer due in %ld seconds\n",
14333 thread_timer_remain_second(p
->t_start
));
14335 vty_out(vty
, "Next connect timer due in %ld seconds\n",
14336 thread_timer_remain_second(p
->t_connect
));
14339 "MRAI (interval %u) timer expires in %ld seconds\n",
14341 thread_timer_remain_second(p
->t_routeadv
));
14343 vty_out(vty
, "Peer Authentication Enabled\n");
14345 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
14346 p
->t_read
? "on" : "off",
14347 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
14352 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
14353 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
14354 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
14357 vty_out(vty
, "\n");
14359 /* BFD information. */
14360 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
14363 if (p
->conf_if
) /* Configured interface name. */
14364 json_object_object_add(json
, p
->conf_if
, json_neigh
);
14365 else /* Configured IP address. */
14366 json_object_object_add(json
, p
->host
, json_neigh
);
14370 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
14371 enum show_type type
,
14372 union sockunion
*su
,
14373 const char *conf_if
, afi_t afi
,
14376 struct listnode
*node
, *nnode
;
14379 safi_t safi
= SAFI_UNICAST
;
14380 json_object
*json
= NULL
;
14381 json_object
*json_neighbor
= NULL
;
14384 json
= json_object_new_object();
14385 json_neighbor
= json_object_new_object();
14388 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14390 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14393 if ((peer
->afc
[afi
][safi
]) == 0)
14396 if (type
== show_all
) {
14397 bgp_show_peer_gr_status(vty
, peer
, use_json
,
14401 json_object_object_add(json
, peer
->host
,
14403 json_neighbor
= NULL
;
14406 } else if (type
== show_peer
) {
14409 && !strcmp(peer
->conf_if
, conf_if
))
14411 && !strcmp(peer
->hostname
, conf_if
))) {
14413 bgp_show_peer_gr_status(vty
, peer
,
14418 if (sockunion_same(&peer
->su
, su
)) {
14420 bgp_show_peer_gr_status(vty
, peer
,
14425 if (use_json
&& find
)
14426 json_object_object_add(json
, peer
->host
,
14431 json_neighbor
= NULL
;
14436 if (type
== show_peer
&& !find
) {
14438 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14440 vty_out(vty
, "%% No such neighbor\n");
14443 vty_out(vty
, "%s\n",
14444 json_object_to_json_string_ext(
14445 json
, JSON_C_TO_STRING_PRETTY
));
14448 json_object_free(json_neighbor
);
14449 json_object_free(json
);
14451 vty_out(vty
, "\n");
14454 return CMD_SUCCESS
;
14457 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
14458 enum show_type type
, union sockunion
*su
,
14459 const char *conf_if
, bool use_json
,
14462 struct listnode
*node
, *nnode
;
14465 bool nbr_output
= false;
14466 afi_t afi
= AFI_MAX
;
14467 safi_t safi
= SAFI_MAX
;
14469 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
14471 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
14475 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
14476 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
14481 bgp_show_peer(vty
, peer
, use_json
, json
);
14487 && !strcmp(peer
->conf_if
, conf_if
))
14489 && !strcmp(peer
->hostname
, conf_if
))) {
14491 bgp_show_peer(vty
, peer
, use_json
,
14495 if (sockunion_same(&peer
->su
, su
)) {
14497 bgp_show_peer(vty
, peer
, use_json
,
14502 case show_ipv4_peer
:
14503 case show_ipv6_peer
:
14504 FOREACH_SAFI (safi
) {
14505 if (peer
->afc
[afi
][safi
]) {
14508 && !strcmp(peer
->conf_if
, conf_if
))
14510 && !strcmp(peer
->hostname
, conf_if
))) {
14512 bgp_show_peer(vty
, peer
, use_json
,
14517 if (sockunion_same(&peer
->su
, su
)) {
14519 bgp_show_peer(vty
, peer
, use_json
,
14527 case show_ipv4_all
:
14528 case show_ipv6_all
:
14529 FOREACH_SAFI (safi
) {
14530 if (peer
->afc
[afi
][safi
]) {
14531 bgp_show_peer(vty
, peer
, use_json
, json
);
14540 if ((type
== show_peer
|| type
== show_ipv4_peer
||
14541 type
== show_ipv6_peer
) && !find
) {
14543 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
14545 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
14548 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
14549 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
14550 vty_out(vty
, "%% No BGP neighbors found\n");
14553 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
14554 json
, JSON_C_TO_STRING_PRETTY
));
14556 vty_out(vty
, "\n");
14559 return CMD_SUCCESS
;
14562 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
14563 enum show_type type
,
14564 const char *ip_str
,
14565 afi_t afi
, bool use_json
)
14570 union sockunion su
;
14572 bgp
= bgp_get_default();
14578 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
14582 ret
= str2sockunion(ip_str
, &su
);
14584 bgp_show_neighbor_graceful_restart(
14585 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
14587 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
14588 NULL
, afi
, use_json
);
14590 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
14594 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
14595 enum show_type type
,
14596 const char *ip_str
,
14599 struct listnode
*node
, *nnode
;
14601 union sockunion su
;
14602 json_object
*json
= NULL
;
14603 int ret
, is_first
= 1;
14604 bool nbr_output
= false;
14607 vty_out(vty
, "{\n");
14609 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
14612 if (!(json
= json_object_new_object())) {
14614 EC_BGP_JSON_MEM_ERROR
,
14615 "Unable to allocate memory for JSON object");
14617 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
14621 json_object_int_add(json
, "vrfId",
14622 (bgp
->vrf_id
== VRF_UNKNOWN
)
14624 : (int64_t)bgp
->vrf_id
);
14625 json_object_string_add(
14627 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14632 vty_out(vty
, ",\n");
14636 vty_out(vty
, "\"%s\":",
14637 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14641 vty_out(vty
, "\nInstance %s:\n",
14642 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
14647 if (type
== show_peer
|| type
== show_ipv4_peer
||
14648 type
== show_ipv6_peer
) {
14649 ret
= str2sockunion(ip_str
, &su
);
14651 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14654 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14657 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
14660 json_object_free(json
);
14665 vty_out(vty
, "}\n");
14666 else if (!nbr_output
)
14667 vty_out(vty
, "%% BGP instance not found\n");
14670 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
14671 enum show_type type
, const char *ip_str
,
14676 union sockunion su
;
14677 json_object
*json
= NULL
;
14680 if (strmatch(name
, "all")) {
14681 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
14683 return CMD_SUCCESS
;
14685 bgp
= bgp_lookup_by_name(name
);
14688 json
= json_object_new_object();
14689 vty_out(vty
, "%s\n",
14690 json_object_to_json_string_ext(
14692 JSON_C_TO_STRING_PRETTY
));
14693 json_object_free(json
);
14696 "%% BGP instance not found\n");
14698 return CMD_WARNING
;
14702 bgp
= bgp_get_default();
14706 json
= json_object_new_object();
14708 ret
= str2sockunion(ip_str
, &su
);
14710 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
14713 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
14716 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
14719 json_object_free(json
);
14722 vty_out(vty
, "{}\n");
14724 vty_out(vty
, "%% BGP instance not found\n");
14727 return CMD_SUCCESS
;
14732 /* "show [ip] bgp neighbors graceful-restart" commands. */
14733 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
14734 show_ip_bgp_neighbors_graceful_restart_cmd
,
14735 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
14741 "Neighbor to display information about\n"
14742 "Neighbor to display information about\n"
14743 "Neighbor on BGP configured interface\n"
14747 char *sh_arg
= NULL
;
14748 enum show_type sh_type
;
14750 afi_t afi
= AFI_MAX
;
14751 bool uj
= use_json(argc
, argv
);
14753 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
14758 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14759 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14760 || argv_find(argv
, argc
, "WORD", &idx
)) {
14761 sh_type
= show_peer
;
14762 sh_arg
= argv
[idx
]->arg
;
14764 sh_type
= show_all
;
14766 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
14767 return CMD_SUCCESS
;
14770 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
14774 /* "show [ip] bgp neighbors" commands. */
14775 DEFUN (show_ip_bgp_neighbors
,
14776 show_ip_bgp_neighbors_cmd
,
14777 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
14781 BGP_INSTANCE_HELP_STR
14784 "Detailed information on TCP and BGP neighbor connections\n"
14785 "Neighbor to display information about\n"
14786 "Neighbor to display information about\n"
14787 "Neighbor on BGP configured interface\n"
14791 char *sh_arg
= NULL
;
14792 enum show_type sh_type
;
14793 afi_t afi
= AFI_MAX
;
14795 bool uj
= use_json(argc
, argv
);
14799 /* [<vrf> VIEWVRFNAME] */
14800 if (argv_find(argv
, argc
, "vrf", &idx
)) {
14801 vrf
= argv
[idx
+ 1]->arg
;
14802 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
14804 } else if (argv_find(argv
, argc
, "view", &idx
))
14805 /* [<view> VIEWVRFNAME] */
14806 vrf
= argv
[idx
+ 1]->arg
;
14810 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
14811 sh_type
= show_ipv4_all
;
14813 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
14814 sh_type
= show_ipv6_all
;
14817 sh_type
= show_all
;
14820 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
14821 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
14822 || argv_find(argv
, argc
, "WORD", &idx
)) {
14823 sh_type
= show_peer
;
14824 sh_arg
= argv
[idx
]->arg
;
14827 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
14828 sh_type
= show_ipv4_peer
;
14829 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
14830 sh_type
= show_ipv6_peer
;
14833 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
14836 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
14837 paths' and `show ip mbgp paths'. Those functions results are the
14839 DEFUN (show_ip_bgp_paths
,
14840 show_ip_bgp_paths_cmd
,
14841 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
14846 "Path information\n")
14848 vty_out(vty
, "Address Refcnt Path\n");
14849 aspath_print_all_vty(vty
);
14850 return CMD_SUCCESS
;
14855 static void community_show_all_iterator(struct hash_bucket
*bucket
,
14858 struct community
*com
;
14860 com
= (struct community
*)bucket
->data
;
14861 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
14862 community_str(com
, false));
14865 /* Show BGP's community internal data. */
14866 DEFUN (show_ip_bgp_community_info
,
14867 show_ip_bgp_community_info_cmd
,
14868 "show [ip] bgp community-info",
14872 "List all bgp community information\n")
14874 vty_out(vty
, "Address Refcnt Community\n");
14876 hash_iterate(community_hash(),
14877 (void (*)(struct hash_bucket
*,
14878 void *))community_show_all_iterator
,
14881 return CMD_SUCCESS
;
14884 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
14887 struct lcommunity
*lcom
;
14889 lcom
= (struct lcommunity
*)bucket
->data
;
14890 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
14891 lcommunity_str(lcom
, false));
14894 /* Show BGP's community internal data. */
14895 DEFUN (show_ip_bgp_lcommunity_info
,
14896 show_ip_bgp_lcommunity_info_cmd
,
14897 "show ip bgp large-community-info",
14901 "List all bgp large-community information\n")
14903 vty_out(vty
, "Address Refcnt Large-community\n");
14905 hash_iterate(lcommunity_hash(),
14906 (void (*)(struct hash_bucket
*,
14907 void *))lcommunity_show_all_iterator
,
14910 return CMD_SUCCESS
;
14912 /* Graceful Restart */
14914 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
14921 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
14923 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
14925 switch (bgp_global_gr_mode
) {
14927 case GLOBAL_HELPER
:
14928 vty_out(vty
, "Global BGP GR Mode : Helper\n");
14932 vty_out(vty
, "Global BGP GR Mode : Restart\n");
14935 case GLOBAL_DISABLE
:
14936 vty_out(vty
, "Global BGP GR Mode : Disable\n");
14939 case GLOBAL_INVALID
:
14941 "Global BGP GR Mode Invalid\n");
14944 vty_out(vty
, "\n");
14947 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
14948 enum show_type type
,
14949 const char *ip_str
,
14950 afi_t afi
, bool use_json
)
14952 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
14955 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
14957 bgp_show_neighbor_graceful_restart_vty(
14958 vty
, type
, ip_str
, afi
, use_json
);
14961 } else if (afi
!= AFI_MAX
) {
14962 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
14965 return CMD_ERR_INCOMPLETE
;
14968 return CMD_SUCCESS
;
14970 /* Graceful Restart */
14972 DEFUN (show_ip_bgp_attr_info
,
14973 show_ip_bgp_attr_info_cmd
,
14974 "show [ip] bgp attribute-info",
14978 "List all bgp attribute information\n")
14980 attr_show_all(vty
);
14981 return CMD_SUCCESS
;
14984 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
14985 afi_t afi
, safi_t safi
,
14986 bool use_json
, json_object
*json
)
14989 struct listnode
*node
;
14991 char buf1
[INET6_ADDRSTRLEN
];
14993 vpn_policy_direction_t dir
;
14996 json_object
*json_import_vrfs
= NULL
;
14997 json_object
*json_export_vrfs
= NULL
;
14999 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15002 vty_out(vty
, "%s\n",
15003 json_object_to_json_string_ext(
15005 JSON_C_TO_STRING_PRETTY
));
15006 json_object_free(json
);
15008 return CMD_WARNING
;
15011 /* Provide context for the block */
15012 json_object_string_add(json
, "vrf", name
? name
: "default");
15013 json_object_string_add(json
, "afiSafi",
15014 get_afi_safi_str(afi
, safi
, true));
15016 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15017 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15018 json_object_string_add(json
, "importFromVrfs", "none");
15019 json_object_string_add(json
, "importRts", "none");
15021 json_import_vrfs
= json_object_new_array();
15023 for (ALL_LIST_ELEMENTS_RO(
15024 bgp
->vpn_policy
[afi
].import_vrf
,
15026 json_object_array_add(json_import_vrfs
,
15027 json_object_new_string(vname
));
15029 json_object_object_add(json
, "importFromVrfs",
15031 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15032 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15033 ecom_str
= ecommunity_ecom2str(
15034 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15035 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15036 json_object_string_add(json
, "importRts",
15038 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15040 json_object_string_add(json
, "importRts",
15044 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15045 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
15046 json_object_string_add(json
, "exportToVrfs", "none");
15047 json_object_string_add(json
, "routeDistinguisher",
15049 json_object_string_add(json
, "exportRts", "none");
15051 json_export_vrfs
= json_object_new_array();
15053 for (ALL_LIST_ELEMENTS_RO(
15054 bgp
->vpn_policy
[afi
].export_vrf
,
15056 json_object_array_add(json_export_vrfs
,
15057 json_object_new_string(vname
));
15058 json_object_object_add(json
, "exportToVrfs",
15060 json_object_string_add(json
, "routeDistinguisher",
15061 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
15062 buf1
, RD_ADDRSTRLEN
));
15064 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15065 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15066 ecom_str
= ecommunity_ecom2str(
15067 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15068 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15069 json_object_string_add(json
, "exportRts",
15071 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15073 json_object_string_add(json
, "exportRts",
15078 vty_out(vty
, "%s\n",
15079 json_object_to_json_string_ext(json
,
15080 JSON_C_TO_STRING_PRETTY
));
15081 json_object_free(json
);
15084 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15087 vty_out(vty
, "%% No such BGP instance exist\n");
15088 return CMD_WARNING
;
15091 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15092 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15094 "This VRF is not importing %s routes from any other VRF\n",
15095 get_afi_safi_str(afi
, safi
, false));
15098 "This VRF is importing %s routes from the following VRFs:\n",
15099 get_afi_safi_str(afi
, safi
, false));
15101 for (ALL_LIST_ELEMENTS_RO(
15102 bgp
->vpn_policy
[afi
].import_vrf
,
15104 vty_out(vty
, " %s\n", vname
);
15106 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
15108 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15109 ecom_str
= ecommunity_ecom2str(
15110 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15111 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15112 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
15114 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15116 vty_out(vty
, "Import RT(s):\n");
15119 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15120 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15122 "This VRF is not exporting %s routes to any other VRF\n",
15123 get_afi_safi_str(afi
, safi
, false));
15126 "This VRF is exporting %s routes to the following VRFs:\n",
15127 get_afi_safi_str(afi
, safi
, false));
15129 for (ALL_LIST_ELEMENTS_RO(
15130 bgp
->vpn_policy
[afi
].export_vrf
,
15132 vty_out(vty
, " %s\n", vname
);
15134 vty_out(vty
, "RD: %s\n",
15135 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
15136 buf1
, RD_ADDRSTRLEN
));
15138 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
15139 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
15140 ecom_str
= ecommunity_ecom2str(
15141 bgp
->vpn_policy
[afi
].rtlist
[dir
],
15142 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
15143 vty_out(vty
, "Export RT: %s\n", ecom_str
);
15144 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
15146 vty_out(vty
, "Import RT(s):\n");
15150 return CMD_SUCCESS
;
15153 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
15154 safi_t safi
, bool use_json
)
15156 struct listnode
*node
, *nnode
;
15158 char *vrf_name
= NULL
;
15159 json_object
*json
= NULL
;
15160 json_object
*json_vrf
= NULL
;
15161 json_object
*json_vrfs
= NULL
;
15164 json
= json_object_new_object();
15165 json_vrfs
= json_object_new_object();
15168 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15170 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
15171 vrf_name
= bgp
->name
;
15174 json_vrf
= json_object_new_object();
15176 vty_out(vty
, "\nInstance %s:\n",
15177 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15178 ? VRF_DEFAULT_NAME
: bgp
->name
);
15180 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
15182 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15183 json_object_object_add(json_vrfs
,
15184 VRF_DEFAULT_NAME
, json_vrf
);
15186 json_object_object_add(json_vrfs
, vrf_name
,
15192 json_object_object_add(json
, "vrfs", json_vrfs
);
15193 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
15194 JSON_C_TO_STRING_PRETTY
));
15195 json_object_free(json
);
15198 return CMD_SUCCESS
;
15201 /* "show [ip] bgp route-leak" command. */
15202 DEFUN (show_ip_bgp_route_leak
,
15203 show_ip_bgp_route_leak_cmd
,
15204 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
15208 BGP_INSTANCE_HELP_STR
15211 "Route leaking information\n"
15215 afi_t afi
= AFI_MAX
;
15216 safi_t safi
= SAFI_MAX
;
15218 bool uj
= use_json(argc
, argv
);
15220 json_object
*json
= NULL
;
15222 /* show [ip] bgp */
15223 if (argv_find(argv
, argc
, "ip", &idx
)) {
15225 safi
= SAFI_UNICAST
;
15227 /* [vrf VIEWVRFNAME] */
15228 if (argv_find(argv
, argc
, "view", &idx
)) {
15230 "%% This command is not applicable to BGP views\n");
15231 return CMD_WARNING
;
15234 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15235 vrf
= argv
[idx
+ 1]->arg
;
15236 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15239 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15240 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15241 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15244 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
15246 "%% This command is applicable only for unicast ipv4|ipv6\n");
15247 return CMD_WARNING
;
15250 if (vrf
&& strmatch(vrf
, "all"))
15251 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
15254 json
= json_object_new_object();
15256 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
15259 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
15262 struct listnode
*node
, *nnode
;
15265 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
15266 vty_out(vty
, "\nInstance %s:\n",
15267 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
15270 update_group_show(bgp
, afi
, safi
, vty
, 0);
15274 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
15275 int safi
, uint64_t subgrp_id
)
15280 if (strmatch(name
, "all")) {
15281 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
15282 return CMD_SUCCESS
;
15284 bgp
= bgp_lookup_by_name(name
);
15287 bgp
= bgp_get_default();
15291 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
15292 return CMD_SUCCESS
;
15295 DEFUN (show_ip_bgp_updgrps
,
15296 show_ip_bgp_updgrps_cmd
,
15297 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
15301 BGP_INSTANCE_HELP_STR
15303 BGP_SAFI_WITH_LABEL_HELP_STR
15304 "Detailed info about dynamic update groups\n"
15305 "Specific subgroup to display detailed info for\n")
15308 afi_t afi
= AFI_IP6
;
15309 safi_t safi
= SAFI_UNICAST
;
15310 uint64_t subgrp_id
= 0;
15314 /* show [ip] bgp */
15315 if (argv_find(argv
, argc
, "ip", &idx
))
15317 /* [<vrf> VIEWVRFNAME] */
15318 if (argv_find(argv
, argc
, "vrf", &idx
)) {
15319 vrf
= argv
[idx
+ 1]->arg
;
15320 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
15322 } else if (argv_find(argv
, argc
, "view", &idx
))
15323 /* [<view> VIEWVRFNAME] */
15324 vrf
= argv
[idx
+ 1]->arg
;
15325 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
15326 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
15327 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
15330 /* get subgroup id, if provided */
15332 if (argv
[idx
]->type
== VARIABLE_TKN
)
15333 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
15335 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
15338 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
15339 show_bgp_instance_all_ipv6_updgrps_cmd
,
15340 "show [ip] bgp <view|vrf> all update-groups",
15344 BGP_INSTANCE_ALL_HELP_STR
15345 "Detailed info about dynamic update groups\n")
15347 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
15348 return CMD_SUCCESS
;
15351 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
15352 show_bgp_l2vpn_evpn_updgrps_cmd
,
15353 "show [ip] bgp l2vpn evpn update-groups",
15357 "l2vpn address family\n"
15358 "evpn sub-address family\n"
15359 "Detailed info about dynamic update groups\n")
15362 uint64_t subgrp_id
= 0;
15364 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
15365 return CMD_SUCCESS
;
15368 DEFUN (show_bgp_updgrps_stats
,
15369 show_bgp_updgrps_stats_cmd
,
15370 "show [ip] bgp update-groups statistics",
15374 "Detailed info about dynamic update groups\n"
15379 bgp
= bgp_get_default();
15381 update_group_show_stats(bgp
, vty
);
15383 return CMD_SUCCESS
;
15386 DEFUN (show_bgp_instance_updgrps_stats
,
15387 show_bgp_instance_updgrps_stats_cmd
,
15388 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
15392 BGP_INSTANCE_HELP_STR
15393 "Detailed info about dynamic update groups\n"
15399 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
15401 update_group_show_stats(bgp
, vty
);
15403 return CMD_SUCCESS
;
15406 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
15407 afi_t afi
, safi_t safi
,
15408 const char *what
, uint64_t subgrp_id
)
15413 bgp
= bgp_lookup_by_name(name
);
15415 bgp
= bgp_get_default();
15418 if (!strcmp(what
, "advertise-queue"))
15419 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
15421 else if (!strcmp(what
, "advertised-routes"))
15422 update_group_show_advertised(bgp
, afi
, safi
, vty
,
15424 else if (!strcmp(what
, "packet-queue"))
15425 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
15430 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
15431 show_ip_bgp_instance_updgrps_adj_s_cmd
,
15432 "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",
15433 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
15435 "Detailed info about dynamic update groups\n"
15436 "Specific subgroup to display info for\n"
15437 "Advertisement queue\n"
15438 "Announced routes\n"
15441 uint64_t subgrp_id
= 0;
15445 subgrp_id
= strtoull(sgid
, NULL
, 10);
15450 afiz
= bgp_vty_afi_from_str(afi
);
15454 afiz
= bgp_vty_afi_from_str(afi
);
15455 if (afiz
!= AFI_IP
)
15457 "%% Cannot specify both 'ip' and 'ipv6'\n");
15458 return CMD_WARNING
;
15461 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
15463 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
15464 return CMD_SUCCESS
;
15467 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
15469 struct listnode
*node
, *nnode
;
15470 struct prefix
*range
;
15475 const char *peer_status
;
15476 const char *af_str
;
15481 conf
= group
->conf
;
15483 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
15484 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15485 group
->name
, conf
->as
);
15486 } else if (conf
->as_type
== AS_INTERNAL
) {
15487 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
15488 group
->name
, group
->bgp
->as
);
15490 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
15493 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
15494 vty_out(vty
, " Peer-group type is internal\n");
15496 vty_out(vty
, " Peer-group type is external\n");
15498 /* Display AFs configured. */
15499 vty_out(vty
, " Configured address-families:");
15500 FOREACH_AFI_SAFI (afi
, safi
) {
15501 if (conf
->afc
[afi
][safi
]) {
15503 vty_out(vty
, " %s;", get_afi_safi_str(afi
, safi
, false));
15507 vty_out(vty
, " none\n");
15509 vty_out(vty
, "\n");
15511 /* Display listen ranges (for dynamic neighbors), if any */
15512 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
15515 else if (afi
== AFI_IP6
)
15519 lr_count
= listcount(group
->listen_range
[afi
]);
15521 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
15525 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
15527 vty_out(vty
, " %pFX\n", range
);
15531 /* Display group members and their status */
15532 if (listcount(group
->peer
)) {
15533 vty_out(vty
, " Peer-group members:\n");
15534 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
15535 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
15536 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15537 peer_status
= "Idle (Admin)";
15538 else if (CHECK_FLAG(peer
->sflags
,
15539 PEER_STATUS_PREFIX_OVERFLOW
))
15540 peer_status
= "Idle (PfxCt)";
15542 peer_status
= lookup_msg(bgp_status_msg
,
15543 peer
->status
, NULL
);
15545 dynamic
= peer_dynamic_neighbor(peer
);
15546 vty_out(vty
, " %s %s %s \n", peer
->host
,
15547 dynamic
? "(dynamic)" : "", peer_status
);
15551 return CMD_SUCCESS
;
15554 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
15555 const char *group_name
)
15558 struct listnode
*node
, *nnode
;
15559 struct peer_group
*group
;
15560 bool found
= false;
15562 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
15565 vty_out(vty
, "%% BGP instance not found\n");
15566 return CMD_WARNING
;
15569 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15571 if (strmatch(group
->name
, group_name
)) {
15572 bgp_show_one_peer_group(vty
, group
);
15577 bgp_show_one_peer_group(vty
, group
);
15581 if (group_name
&& !found
)
15582 vty_out(vty
, "%% No such peer-group\n");
15584 return CMD_SUCCESS
;
15587 DEFUN (show_ip_bgp_peer_groups
,
15588 show_ip_bgp_peer_groups_cmd
,
15589 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
15593 BGP_INSTANCE_HELP_STR
15594 "Detailed information on BGP peer groups\n"
15595 "Peer group name\n")
15600 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
15602 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
15604 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
15608 /* Redistribute VTY commands. */
15610 DEFUN_YANG (bgp_redistribute_ipv4
,
15611 bgp_redistribute_ipv4_cmd
,
15612 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15613 "Redistribute information from another routing protocol\n"
15614 FRR_IP_REDIST_HELP_STR_BGPD
)
15616 int idx_protocol
= 1;
15617 char base_xpath
[XPATH_MAXLEN
];
15619 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15620 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15621 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15622 argv
[idx_protocol
]->text
, "0");
15624 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15626 return nb_cli_apply_changes(vty
, base_xpath
);
15630 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
15631 "redistribute " FRR_IP_REDIST_STR_BGPD
,
15632 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
15634 DEFUN_YANG (bgp_redistribute_ipv4_rmap
,
15635 bgp_redistribute_ipv4_rmap_cmd
,
15636 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15637 "Redistribute information from another routing protocol\n"
15638 FRR_IP_REDIST_HELP_STR_BGPD
15639 "Route map reference\n"
15640 "Pointer to route-map entries\n")
15642 int idx_protocol
= 1;
15644 char base_xpath
[XPATH_MAXLEN
];
15646 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15647 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15648 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15649 argv
[idx_protocol
]->text
, "0");
15651 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15652 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15653 argv
[idx_word
]->arg
);
15655 return nb_cli_apply_changes(vty
, base_xpath
);
15659 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
15660 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
15661 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15662 "Route map reference\n"
15663 "Pointer to route-map entries\n")
15665 DEFUN_YANG (bgp_redistribute_ipv4_metric
,
15666 bgp_redistribute_ipv4_metric_cmd
,
15667 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15668 "Redistribute information from another routing protocol\n"
15669 FRR_IP_REDIST_HELP_STR_BGPD
15670 "Metric for redistributed routes\n"
15671 "Default metric\n")
15673 int idx_protocol
= 1;
15674 int idx_number
= 3;
15675 char base_xpath
[XPATH_MAXLEN
];
15677 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15678 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15679 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15680 argv
[idx_protocol
]->text
, "0");
15682 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15683 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15684 argv
[idx_number
]->arg
);
15686 return nb_cli_apply_changes(vty
, base_xpath
);
15690 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
15691 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
15692 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15693 "Metric for redistributed routes\n"
15694 "Default metric\n")
15697 bgp_redistribute_ipv4_rmap_metric
,
15698 bgp_redistribute_ipv4_rmap_metric_cmd
,
15699 "redistribute " FRR_IP_REDIST_STR_BGPD
15700 " route-map WORD metric (0-4294967295)",
15701 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15702 "Route map reference\n"
15703 "Pointer to route-map entries\n"
15704 "Metric for redistributed routes\n"
15705 "Default metric\n")
15707 int idx_protocol
= 1;
15709 int idx_number
= 5;
15710 char base_xpath
[XPATH_MAXLEN
];
15712 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15713 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15714 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15715 argv
[idx_protocol
]->text
, "0");
15717 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15718 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15719 argv
[idx_word
]->arg
);
15720 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15721 argv
[idx_number
]->arg
);
15723 return nb_cli_apply_changes(vty
, base_xpath
);
15727 bgp_redistribute_ipv4_rmap_metric
,
15728 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
15729 "redistribute " FRR_IP_REDIST_STR_BGPD
15730 " route-map WORD metric (0-4294967295)",
15731 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15732 "Route map reference\n"
15733 "Pointer to route-map entries\n"
15734 "Metric for redistributed routes\n"
15735 "Default metric\n")
15738 bgp_redistribute_ipv4_metric_rmap
,
15739 bgp_redistribute_ipv4_metric_rmap_cmd
,
15740 "redistribute " FRR_IP_REDIST_STR_BGPD
15741 " metric (0-4294967295) route-map WORD",
15742 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15743 "Metric for redistributed routes\n"
15745 "Route map reference\n"
15746 "Pointer to route-map entries\n")
15748 int idx_protocol
= 1;
15750 int idx_number
= 3;
15751 char base_xpath
[XPATH_MAXLEN
];
15753 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15754 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15755 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15756 argv
[idx_protocol
]->text
, "0");
15758 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15759 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15760 argv
[idx_number
]->arg
);
15761 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15762 argv
[idx_word
]->arg
);
15764 return nb_cli_apply_changes(vty
, base_xpath
);
15768 bgp_redistribute_ipv4_metric_rmap
,
15769 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
15770 "redistribute " FRR_IP_REDIST_STR_BGPD
15771 " metric (0-4294967295) route-map WORD",
15772 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
15773 "Metric for redistributed routes\n"
15775 "Route map reference\n"
15776 "Pointer to route-map entries\n")
15778 DEFUN_YANG (bgp_redistribute_ipv4_ospf
,
15779 bgp_redistribute_ipv4_ospf_cmd
,
15780 "redistribute <ospf|table> (1-65535)",
15781 "Redistribute information from another routing protocol\n"
15782 "Open Shortest Path First (OSPFv2)\n"
15783 "Non-main Kernel Routing Table\n"
15784 "Instance ID/Table ID\n")
15786 int idx_protocol
= 1;
15787 int idx_number
= 2;
15788 char base_xpath
[XPATH_MAXLEN
];
15790 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15791 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15792 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15793 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15795 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15797 return nb_cli_apply_changes(vty
, base_xpath
);
15800 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
15801 "redistribute <ospf|table> (1-65535)",
15802 "Redistribute information from another routing protocol\n"
15803 "Open Shortest Path First (OSPFv2)\n"
15804 "Non-main Kernel Routing Table\n"
15805 "Instance ID/Table ID\n")
15807 DEFUN_YANG (bgp_redistribute_ipv4_ospf_rmap
,
15808 bgp_redistribute_ipv4_ospf_rmap_cmd
,
15809 "redistribute <ospf|table> (1-65535) route-map WORD",
15810 "Redistribute information from another routing protocol\n"
15811 "Open Shortest Path First (OSPFv2)\n"
15812 "Non-main Kernel Routing Table\n"
15813 "Instance ID/Table ID\n"
15814 "Route map reference\n"
15815 "Pointer to route-map entries\n")
15817 int idx_protocol
= 1;
15818 int idx_number
= 2;
15820 char base_xpath
[XPATH_MAXLEN
];
15822 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15823 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15824 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15825 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15827 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15829 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15830 argv
[idx_word
]->arg
);
15832 return nb_cli_apply_changes(vty
, base_xpath
);
15835 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
15836 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
15837 "redistribute <ospf|table> (1-65535) route-map WORD",
15838 "Redistribute information from another routing protocol\n"
15839 "Open Shortest Path First (OSPFv2)\n"
15840 "Non-main Kernel Routing Table\n"
15841 "Instance ID/Table ID\n"
15842 "Route map reference\n"
15843 "Pointer to route-map entries\n")
15845 DEFUN_YANG(bgp_redistribute_ipv4_ospf_metric
,
15846 bgp_redistribute_ipv4_ospf_metric_cmd
,
15847 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15848 "Redistribute information from another routing protocol\n"
15849 "Open Shortest Path First (OSPFv2)\n"
15850 "Non-main Kernel Routing Table\n"
15851 "Instance ID/Table ID\n"
15852 "Metric for redistributed routes\n"
15853 "Default metric\n")
15855 int idx_protocol
= 1;
15856 int idx_number
= 2;
15857 int idx_number_2
= 4;
15858 char base_xpath
[XPATH_MAXLEN
];
15860 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15861 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15862 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15863 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15865 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15867 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15868 argv
[idx_number_2
]->arg
);
15870 return nb_cli_apply_changes(vty
, base_xpath
);
15873 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
15874 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
15875 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
15876 "Redistribute information from another routing protocol\n"
15877 "Open Shortest Path First (OSPFv2)\n"
15878 "Non-main Kernel Routing Table\n"
15879 "Instance ID/Table ID\n"
15880 "Metric for redistributed routes\n"
15881 "Default metric\n")
15884 bgp_redistribute_ipv4_ospf_rmap_metric
,
15885 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
15886 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15887 "Redistribute information from another routing protocol\n"
15888 "Open Shortest Path First (OSPFv2)\n"
15889 "Non-main Kernel Routing Table\n"
15890 "Instance ID/Table ID\n"
15891 "Route map reference\n"
15892 "Pointer to route-map entries\n"
15893 "Metric for redistributed routes\n"
15894 "Default metric\n")
15896 int idx_protocol
= 1;
15897 int idx_number
= 2;
15899 int idx_number_2
= 6;
15900 char base_xpath
[XPATH_MAXLEN
];
15902 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15903 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15904 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15905 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15907 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15909 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15910 argv
[idx_word
]->arg
);
15911 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15912 argv
[idx_number_2
]->arg
);
15914 return nb_cli_apply_changes(vty
, base_xpath
);
15918 bgp_redistribute_ipv4_ospf_rmap_metric
,
15919 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
15920 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
15921 "Redistribute information from another routing protocol\n"
15922 "Open Shortest Path First (OSPFv2)\n"
15923 "Non-main Kernel Routing Table\n"
15924 "Instance ID/Table ID\n"
15925 "Route map reference\n"
15926 "Pointer to route-map entries\n"
15927 "Metric for redistributed routes\n"
15928 "Default metric\n")
15931 bgp_redistribute_ipv4_ospf_metric_rmap
,
15932 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
15933 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15934 "Redistribute information from another routing protocol\n"
15935 "Open Shortest Path First (OSPFv2)\n"
15936 "Non-main Kernel Routing Table\n"
15937 "Instance ID/Table ID\n"
15938 "Metric for redistributed routes\n"
15940 "Route map reference\n"
15941 "Pointer to route-map entries\n")
15943 int idx_protocol
= 1;
15944 int idx_number
= 2;
15945 int idx_number_2
= 4;
15947 char base_xpath
[XPATH_MAXLEN
];
15949 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15950 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15951 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15952 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15954 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
15956 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
15957 argv
[idx_number_2
]->arg
);
15958 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
15959 argv
[idx_word
]->arg
);
15961 return nb_cli_apply_changes(vty
, base_xpath
);
15965 bgp_redistribute_ipv4_ospf_metric_rmap
,
15966 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
15967 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
15968 "Redistribute information from another routing protocol\n"
15969 "Open Shortest Path First (OSPFv2)\n"
15970 "Non-main Kernel Routing Table\n"
15971 "Instance ID/Table ID\n"
15972 "Metric for redistributed routes\n"
15974 "Route map reference\n"
15975 "Pointer to route-map entries\n")
15977 DEFUN_YANG (no_bgp_redistribute_ipv4_ospf
,
15978 no_bgp_redistribute_ipv4_ospf_cmd
,
15979 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
15981 "Redistribute information from another routing protocol\n"
15982 "Open Shortest Path First (OSPFv2)\n"
15983 "Non-main Kernel Routing Table\n"
15984 "Instance ID/Table ID\n"
15985 "Metric for redistributed routes\n"
15987 "Route map reference\n"
15988 "Pointer to route-map entries\n")
15990 int idx_protocol
= 2;
15991 int idx_number
= 3;
15992 char base_xpath
[XPATH_MAXLEN
];
15994 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
15995 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
15996 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
15997 argv
[idx_protocol
]->text
, argv
[idx_number
]->arg
);
15999 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
16001 return nb_cli_apply_changes(vty
, base_xpath
);
16005 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
16006 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
16008 "Redistribute information from another routing protocol\n"
16009 "Open Shortest Path First (OSPFv2)\n"
16010 "Non-main Kernel Routing Table\n"
16011 "Instance ID/Table ID\n"
16012 "Metric for redistributed routes\n"
16014 "Route map reference\n"
16015 "Pointer to route-map entries\n")
16017 DEFUN_YANG (no_bgp_redistribute_ipv4
,
16018 no_bgp_redistribute_ipv4_cmd
,
16019 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
16021 "Redistribute information from another routing protocol\n"
16022 FRR_IP_REDIST_HELP_STR_BGPD
16023 "Metric for redistributed routes\n"
16025 "Route map reference\n"
16026 "Pointer to route-map entries\n")
16028 int idx_protocol
= 2;
16029 char base_xpath
[XPATH_MAXLEN
];
16031 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16032 yang_afi_safi_value2identity(AFI_IP
, SAFI_UNICAST
),
16033 bgp_afi_safi_get_container_str(AFI_IP
, SAFI_UNICAST
),
16034 argv
[idx_protocol
]->text
, "0");
16036 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
16038 return nb_cli_apply_changes(vty
, base_xpath
);
16042 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
16043 "no redistribute " FRR_IP_REDIST_STR_BGPD
16044 " [{metric (0-4294967295)|route-map WORD}]",
16046 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
16047 "Metric for redistributed routes\n"
16049 "Route map reference\n"
16050 "Pointer to route-map entries\n")
16052 DEFUN_YANG (bgp_redistribute_ipv6
,
16053 bgp_redistribute_ipv6_cmd
,
16054 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
16055 "Redistribute information from another routing protocol\n"
16056 FRR_IP6_REDIST_HELP_STR_BGPD
)
16058 int idx_protocol
= 1;
16059 char base_xpath
[XPATH_MAXLEN
];
16061 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16062 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16063 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16064 argv
[idx_protocol
]->text
, "0");
16066 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16068 return nb_cli_apply_changes(vty
, base_xpath
);
16071 DEFUN_YANG (bgp_redistribute_ipv6_rmap
,
16072 bgp_redistribute_ipv6_rmap_cmd
,
16073 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
16074 "Redistribute information from another routing protocol\n"
16075 FRR_IP6_REDIST_HELP_STR_BGPD
16076 "Route map reference\n"
16077 "Pointer to route-map entries\n")
16079 int idx_protocol
= 1;
16081 char base_xpath
[XPATH_MAXLEN
];
16083 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16084 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16085 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16086 argv
[idx_protocol
]->text
, "0");
16088 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16089 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16090 argv
[idx_word
]->arg
);
16092 return nb_cli_apply_changes(vty
, base_xpath
);
16095 DEFUN_YANG (bgp_redistribute_ipv6_metric
,
16096 bgp_redistribute_ipv6_metric_cmd
,
16097 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
16098 "Redistribute information from another routing protocol\n"
16099 FRR_IP6_REDIST_HELP_STR_BGPD
16100 "Metric for redistributed routes\n"
16101 "Default metric\n")
16103 int idx_protocol
= 1;
16104 int idx_number
= 3;
16105 char base_xpath
[XPATH_MAXLEN
];
16107 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16108 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16109 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16110 argv
[idx_protocol
]->text
, "0");
16112 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16113 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16114 argv
[idx_number
]->arg
);
16116 return nb_cli_apply_changes(vty
, base_xpath
);
16120 bgp_redistribute_ipv6_rmap_metric
,
16121 bgp_redistribute_ipv6_rmap_metric_cmd
,
16122 "redistribute " FRR_IP6_REDIST_STR_BGPD
16123 " route-map WORD metric (0-4294967295)",
16124 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
16125 "Route map reference\n"
16126 "Pointer to route-map entries\n"
16127 "Metric for redistributed routes\n"
16128 "Default metric\n")
16130 int idx_protocol
= 1;
16132 int idx_number
= 5;
16133 char base_xpath
[XPATH_MAXLEN
];
16135 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16136 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16137 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16138 argv
[idx_protocol
]->text
, "0");
16140 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16141 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16142 argv
[idx_word
]->arg
);
16143 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16144 argv
[idx_number
]->arg
);
16146 return nb_cli_apply_changes(vty
, base_xpath
);
16150 bgp_redistribute_ipv6_metric_rmap
,
16151 bgp_redistribute_ipv6_metric_rmap_cmd
,
16152 "redistribute " FRR_IP6_REDIST_STR_BGPD
16153 " metric (0-4294967295) route-map WORD",
16154 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
16155 "Metric for redistributed routes\n"
16157 "Route map reference\n"
16158 "Pointer to route-map entries\n")
16160 int idx_protocol
= 1;
16162 int idx_number
= 3;
16163 char base_xpath
[XPATH_MAXLEN
];
16165 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16166 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16167 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16168 argv
[idx_protocol
]->text
, "0");
16170 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
16171 nb_cli_enqueue_change(vty
, "./metric", NB_OP_CREATE
,
16172 argv
[idx_number
]->arg
);
16173 nb_cli_enqueue_change(vty
, "./rmap-policy-import", NB_OP_CREATE
,
16174 argv
[idx_word
]->arg
);
16176 return nb_cli_apply_changes(vty
, base_xpath
);
16180 no_bgp_redistribute_ipv6
,
16181 no_bgp_redistribute_ipv6_cmd
,
16182 "no redistribute " FRR_IP6_REDIST_STR_BGPD
16183 " [{metric (0-4294967295)|route-map WORD}]",
16185 "Redistribute information from another routing protocol\n" FRR_IP6_REDIST_HELP_STR_BGPD
16186 "Metric for redistributed routes\n"
16188 "Route map reference\n"
16189 "Pointer to route-map entries\n")
16191 int idx_protocol
= 2;
16192 char base_xpath
[XPATH_MAXLEN
];
16194 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_AFI_SAFI_REDIST_XPATH
,
16195 yang_afi_safi_value2identity(AFI_IP6
, SAFI_UNICAST
),
16196 bgp_afi_safi_get_container_str(AFI_IP6
, SAFI_UNICAST
),
16197 argv
[idx_protocol
]->text
, "0");
16199 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
16201 return nb_cli_apply_changes(vty
, base_xpath
);
16204 void cli_show_bgp_global_afi_safi_ip_unicast_redistribution_list(
16205 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
16207 uint32_t instance
= 0;
16209 vty_out(vty
, " redistribute %s",
16210 yang_dnode_get_string(dnode
, "./route-type"));
16211 if ((instance
= yang_dnode_get_uint16(dnode
, "./route-instance")))
16212 vty_out(vty
, " %d", instance
);
16213 if (yang_dnode_exists(dnode
, "./metric"))
16214 vty_out(vty
, " metric %u",
16215 yang_dnode_get_uint32(dnode
, "./metric"));
16216 if (yang_dnode_exists(dnode
, "./rmap-policy-import"))
16217 vty_out(vty
, " route-map %s",
16218 yang_dnode_get_string(dnode
, "./rmap-policy-import"));
16219 vty_out(vty
, "\n");
16222 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
16223 afi_t afi
, safi_t safi
)
16227 /* Unicast redistribution only. */
16228 if (safi
!= SAFI_UNICAST
)
16231 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
16232 /* Redistribute BGP does not make sense. */
16233 if (i
!= ZEBRA_ROUTE_BGP
) {
16234 struct list
*red_list
;
16235 struct listnode
*node
;
16236 struct bgp_redist
*red
;
16238 red_list
= bgp
->redist
[afi
][i
];
16242 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
16243 /* "redistribute" configuration. */
16244 vty_out(vty
, " redistribute %s",
16245 zebra_route_string(i
));
16247 vty_out(vty
, " %d", red
->instance
);
16248 if (red
->redist_metric_flag
)
16249 vty_out(vty
, " metric %u",
16250 red
->redist_metric
);
16251 if (red
->rmap
.name
)
16252 vty_out(vty
, " route-map %s",
16254 vty_out(vty
, "\n");
16260 /* peer-group helpers for config-write */
16262 static bool peergroup_flag_check(struct peer
*peer
, uint32_t flag
)
16264 if (!peer_group_active(peer
)) {
16265 if (CHECK_FLAG(peer
->flags_invert
, flag
))
16266 return !CHECK_FLAG(peer
->flags
, flag
);
16268 return !!CHECK_FLAG(peer
->flags
, flag
);
16271 return !!CHECK_FLAG(peer
->flags_override
, flag
);
16274 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16277 if (!peer_group_active(peer
)) {
16278 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
16279 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
16281 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
16284 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
16287 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
16288 uint8_t type
, int direct
)
16290 struct bgp_filter
*filter
;
16292 if (peer_group_active(peer
))
16293 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
16296 filter
= &peer
->filter
[afi
][safi
];
16298 case PEER_FT_DISTRIBUTE_LIST
:
16299 return !!(filter
->dlist
[direct
].name
);
16300 case PEER_FT_FILTER_LIST
:
16301 return !!(filter
->aslist
[direct
].name
);
16302 case PEER_FT_PREFIX_LIST
:
16303 return !!(filter
->plist
[direct
].name
);
16304 case PEER_FT_ROUTE_MAP
:
16305 return !!(filter
->map
[direct
].name
);
16306 case PEER_FT_UNSUPPRESS_MAP
:
16307 return !!(filter
->usmap
.name
);
16308 case PEER_FT_ADVERTISE_MAP
:
16309 return !!(filter
->advmap
.aname
16310 && ((filter
->advmap
.condition
== direct
)
16311 && filter
->advmap
.cname
));
16317 /* Return true if the addpath type is set for peer and different from
16320 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
16323 enum bgp_addpath_strat type
, g_type
;
16325 type
= peer
->addpath_type
[afi
][safi
];
16327 if (type
!= BGP_ADDPATH_NONE
) {
16328 if (peer_group_active(peer
)) {
16329 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
16331 if (type
!= g_type
)
16343 /* This is part of the address-family block (unicast only) */
16344 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
16349 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16350 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16351 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
16352 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
16353 bgp
->vpn_policy
[afi
]
16354 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16356 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
16357 bgp
->vpn_policy
[afi
]
16358 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
16360 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16361 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
16362 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
16363 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
16366 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16367 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
16369 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
16372 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
16373 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
16374 bgp
->vpn_policy
[afi
].tovpn_label
);
16377 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16378 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
16379 char buf
[RD_ADDRSTRLEN
];
16380 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
16381 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
16384 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
16385 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
16387 char buf
[PREFIX_STRLEN
];
16388 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
16389 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
16392 vty_out(vty
, "%*snexthop vpn export %s\n",
16396 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
16397 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
16399 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16400 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
16402 char *b
= ecommunity_ecom2str(
16403 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16404 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
16405 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
16406 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16408 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
16409 char *b
= ecommunity_ecom2str(
16410 bgp
->vpn_policy
[afi
]
16411 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
16412 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16413 ECOMMUNITY_ROUTE_TARGET
);
16414 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
16415 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16417 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
16418 char *b
= ecommunity_ecom2str(
16419 bgp
->vpn_policy
[afi
]
16420 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
16421 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16422 ECOMMUNITY_ROUTE_TARGET
);
16423 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
16424 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16428 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
16429 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
16430 bgp
->vpn_policy
[afi
]
16431 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
16433 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
16434 char *b
= ecommunity_ecom2str(
16435 bgp
->vpn_policy
[afi
]
16436 .import_redirect_rtlist
,
16437 ECOMMUNITY_FORMAT_ROUTE_MAP
,
16438 ECOMMUNITY_ROUTE_TARGET
);
16440 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
16441 != ECOMMUNITY_SIZE
)
16442 vty_out(vty
, "%*srt6 redirect import %s\n",
16445 vty_out(vty
, "%*srt redirect import %s\n",
16447 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
16451 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
16452 afi_t afi
, safi_t safi
)
16454 struct bgp_filter
*filter
;
16458 filter
= &peer
->filter
[afi
][safi
];
16460 /* distribute-list. */
16461 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16463 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
16464 filter
->dlist
[FILTER_IN
].name
);
16466 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
16468 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
16469 filter
->dlist
[FILTER_OUT
].name
);
16472 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16474 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
16475 filter
->plist
[FILTER_IN
].name
);
16477 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
16479 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
16480 filter
->plist
[FILTER_OUT
].name
);
16483 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
16484 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
16485 filter
->map
[RMAP_IN
].name
);
16487 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
16489 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
16490 filter
->map
[RMAP_OUT
].name
);
16492 /* unsuppress-map */
16493 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
16494 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
16495 filter
->usmap
.name
);
16497 /* advertise-map : always applied in OUT direction*/
16498 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16499 CONDITION_NON_EXIST
))
16501 " neighbor %s advertise-map %s non-exist-map %s\n",
16502 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16504 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ADVERTISE_MAP
,
16506 vty_out(vty
, " neighbor %s advertise-map %s exist-map %s\n",
16507 addr
, filter
->advmap
.aname
, filter
->advmap
.cname
);
16510 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16512 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
16513 filter
->aslist
[FILTER_IN
].name
);
16515 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
16517 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
16518 filter
->aslist
[FILTER_OUT
].name
);
16521 /* BGP peer configuration display function. */
16522 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
16525 struct peer
*g_peer
= NULL
;
16526 char buf
[SU_ADDRSTRLEN
];
16528 int if_pg_printed
= false;
16529 int if_ras_printed
= false;
16531 /* Skip dynamic neighbors. */
16532 if (peer_dynamic_neighbor(peer
))
16536 addr
= peer
->conf_if
;
16540 /************************************
16541 ****** Global to the neighbor ******
16542 ************************************/
16543 if (peer
->conf_if
) {
16544 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
16545 vty_out(vty
, " neighbor %s interface v6only", addr
);
16547 vty_out(vty
, " neighbor %s interface", addr
);
16549 if (peer_group_active(peer
)) {
16550 vty_out(vty
, " peer-group %s", peer
->group
->name
);
16551 if_pg_printed
= true;
16552 } else if (peer
->as_type
== AS_SPECIFIED
) {
16553 vty_out(vty
, " remote-as %u", peer
->as
);
16554 if_ras_printed
= true;
16555 } else if (peer
->as_type
== AS_INTERNAL
) {
16556 vty_out(vty
, " remote-as internal");
16557 if_ras_printed
= true;
16558 } else if (peer
->as_type
== AS_EXTERNAL
) {
16559 vty_out(vty
, " remote-as external");
16560 if_ras_printed
= true;
16563 vty_out(vty
, "\n");
16566 /* remote-as and peer-group */
16567 /* peer is a member of a peer-group */
16568 if (peer_group_active(peer
)) {
16569 g_peer
= peer
->group
->conf
;
16571 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
16572 if (peer
->as_type
== AS_SPECIFIED
) {
16573 vty_out(vty
, " neighbor %s remote-as %u\n",
16575 } else if (peer
->as_type
== AS_INTERNAL
) {
16577 " neighbor %s remote-as internal\n",
16579 } else if (peer
->as_type
== AS_EXTERNAL
) {
16581 " neighbor %s remote-as external\n",
16586 /* For swpX peers we displayed the peer-group
16587 * via 'neighbor swpX interface peer-group PGNAME' */
16588 if (!if_pg_printed
)
16589 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
16590 peer
->group
->name
);
16593 /* peer is NOT a member of a peer-group */
16595 /* peer is a peer-group, declare the peer-group */
16596 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
16597 vty_out(vty
, " neighbor %s peer-group\n", addr
);
16600 if (!if_ras_printed
) {
16601 if (peer
->as_type
== AS_SPECIFIED
) {
16602 vty_out(vty
, " neighbor %s remote-as %u\n",
16604 } else if (peer
->as_type
== AS_INTERNAL
) {
16606 " neighbor %s remote-as internal\n",
16608 } else if (peer
->as_type
== AS_EXTERNAL
) {
16610 " neighbor %s remote-as external\n",
16617 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
16618 vty_out(vty
, " neighbor %s local-as %u", addr
,
16619 peer
->change_local_as
);
16620 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
16621 vty_out(vty
, " no-prepend");
16622 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
16623 vty_out(vty
, " replace-as");
16624 vty_out(vty
, "\n");
16629 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
16633 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
16634 if (peer
->tx_shutdown_message
)
16635 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
16636 peer
->tx_shutdown_message
);
16638 vty_out(vty
, " neighbor %s shutdown\n", addr
);
16641 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
16642 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
16643 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
16646 if (peer
->bfd_info
) {
16647 if (!peer_group_active(peer
) || !g_peer
->bfd_info
) {
16648 bgp_bfd_peer_config_write(vty
, peer
, addr
);
16653 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
16654 vty_out(vty
, " neighbor %s password %s\n", addr
,
16657 /* neighbor solo */
16658 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
16659 if (!peer_group_active(peer
)) {
16660 vty_out(vty
, " neighbor %s solo\n", addr
);
16665 if (peer
->port
!= BGP_PORT_DEFAULT
) {
16666 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
16669 /* Local interface name */
16670 if (peer
->ifname
) {
16671 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
16675 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
16676 vty_out(vty
, " neighbor %s passive\n", addr
);
16678 /* ebgp-multihop */
16679 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
16680 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
16681 && peer
->ttl
== MAXTTL
)) {
16682 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
16683 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
16688 /* ttl-security hops */
16689 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
16690 if (!peer_group_active(peer
)
16691 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
16692 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
16693 addr
, peer
->gtsm_hops
);
16697 /* disable-connected-check */
16698 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
16699 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
16701 /* enforce-first-as */
16702 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
16703 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
16705 /* update-source */
16706 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
16707 if (peer
->update_source
)
16708 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16709 sockunion2str(peer
->update_source
, buf
,
16711 else if (peer
->update_if
)
16712 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
16716 /* advertisement-interval */
16717 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
16718 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
16722 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
16723 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
16724 peer
->keepalive
, peer
->holdtime
);
16726 /* timers connect */
16727 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
16728 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16730 /* need special-case handling for changed default values due to
16731 * config profile / version (because there is no "timers bgp connect"
16732 * command, we need to save this per-peer :/)
16734 else if (!peer_group_active(peer
) && !peer
->connect
&&
16735 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
16736 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
16737 peer
->bgp
->default_connect_retry
);
16739 /* timers delayopen */
16740 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_DELAYOPEN
))
16741 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16743 /* Save config even though flag is not set if default values have been
16746 else if (!peer_group_active(peer
) && !peer
->delayopen
16747 && peer
->bgp
->default_delayopen
!= BGP_DEFAULT_DELAYOPEN
)
16748 vty_out(vty
, " neighbor %s timers delayopen %u\n", addr
,
16749 peer
->bgp
->default_delayopen
);
16751 /* capability dynamic */
16752 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
16753 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
16755 /* capability extended-nexthop */
16756 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
16757 if (!peer
->conf_if
) {
16758 if (CHECK_FLAG(peer
->flags_invert
,
16759 PEER_FLAG_CAPABILITY_ENHE
))
16761 " no neighbor %s capability extended-nexthop\n",
16765 " neighbor %s capability extended-nexthop\n",
16770 /* dont-capability-negotiation */
16771 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
16772 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
16774 /* override-capability */
16775 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
16776 vty_out(vty
, " neighbor %s override-capability\n", addr
);
16778 /* strict-capability-match */
16779 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
16780 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
16782 /* Sender side AS path loop detection. */
16783 if (peer
->as_path_loop_detection
)
16784 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
16787 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16788 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
16790 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16791 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
16793 " neighbor %s graceful-restart-helper\n", addr
);
16794 } else if (CHECK_FLAG(
16795 peer
->peer_gr_new_status_flag
,
16796 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
16798 " neighbor %s graceful-restart\n", addr
);
16800 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
16801 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
16803 peer
->peer_gr_new_status_flag
,
16804 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
16805 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
16811 /* BGP peer configuration display function. */
16812 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
16813 struct peer
*peer
, afi_t afi
, safi_t safi
)
16815 struct peer
*g_peer
= NULL
;
16817 bool flag_scomm
, flag_secomm
, flag_slcomm
;
16819 /* Skip dynamic neighbors. */
16820 if (peer_dynamic_neighbor(peer
))
16824 addr
= peer
->conf_if
;
16828 /************************************
16829 ****** Per AF to the neighbor ******
16830 ************************************/
16831 if (peer_group_active(peer
)) {
16832 g_peer
= peer
->group
->conf
;
16834 /* If the peer-group is active but peer is not, print a 'no
16836 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
16837 vty_out(vty
, " no neighbor %s activate\n", addr
);
16840 /* If the peer-group is not active but peer is, print an
16842 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
16843 vty_out(vty
, " neighbor %s activate\n", addr
);
16846 if (peer
->afc
[afi
][safi
]) {
16847 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
16848 if (CHECK_FLAG(bgp
->flags
,
16849 BGP_FLAG_NO_DEFAULT_IPV4
)) {
16850 vty_out(vty
, " neighbor %s activate\n",
16854 vty_out(vty
, " neighbor %s activate\n", addr
);
16856 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
16857 if (!CHECK_FLAG(bgp
->flags
,
16858 BGP_FLAG_NO_DEFAULT_IPV4
)) {
16860 " no neighbor %s activate\n",
16867 /* addpath TX knobs */
16868 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
16869 switch (peer
->addpath_type
[afi
][safi
]) {
16870 case BGP_ADDPATH_ALL
:
16871 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
16874 case BGP_ADDPATH_BEST_PER_AS
:
16876 " neighbor %s addpath-tx-bestpath-per-AS\n",
16879 case BGP_ADDPATH_MAX
:
16880 case BGP_ADDPATH_NONE
:
16885 /* ORF capability. */
16886 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
16887 || peergroup_af_flag_check(peer
, afi
, safi
,
16888 PEER_FLAG_ORF_PREFIX_RM
)) {
16889 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
16891 if (peergroup_af_flag_check(peer
, afi
, safi
,
16892 PEER_FLAG_ORF_PREFIX_SM
)
16893 && peergroup_af_flag_check(peer
, afi
, safi
,
16894 PEER_FLAG_ORF_PREFIX_RM
))
16895 vty_out(vty
, " both");
16896 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16897 PEER_FLAG_ORF_PREFIX_SM
))
16898 vty_out(vty
, " send");
16900 vty_out(vty
, " receive");
16901 vty_out(vty
, "\n");
16904 /* Route reflector client. */
16905 if (peergroup_af_flag_check(peer
, afi
, safi
,
16906 PEER_FLAG_REFLECTOR_CLIENT
)) {
16907 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
16910 /* next-hop-self force */
16911 if (peergroup_af_flag_check(peer
, afi
, safi
,
16912 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
16913 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
16916 /* next-hop-self */
16917 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
16918 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
16921 /* remove-private-AS */
16922 if (peergroup_af_flag_check(peer
, afi
, safi
,
16923 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
16924 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
16928 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16929 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
16930 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
16934 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16935 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
16936 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
16939 else if (peergroup_af_flag_check(peer
, afi
, safi
,
16940 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
16941 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
16945 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
16946 vty_out(vty
, " neighbor %s as-override\n", addr
);
16949 /* send-community print. */
16950 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16951 PEER_FLAG_SEND_COMMUNITY
);
16952 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16953 PEER_FLAG_SEND_EXT_COMMUNITY
);
16954 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
16955 PEER_FLAG_SEND_LARGE_COMMUNITY
);
16957 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
16958 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
16961 vty_out(vty
, " no neighbor %s send-community\n", addr
);
16964 " no neighbor %s send-community extended\n",
16968 vty_out(vty
, " no neighbor %s send-community large\n",
16972 /* Default information */
16973 if (peergroup_af_flag_check(peer
, afi
, safi
,
16974 PEER_FLAG_DEFAULT_ORIGINATE
)) {
16975 vty_out(vty
, " neighbor %s default-originate", addr
);
16977 if (peer
->default_rmap
[afi
][safi
].name
)
16978 vty_out(vty
, " route-map %s",
16979 peer
->default_rmap
[afi
][safi
].name
);
16981 vty_out(vty
, "\n");
16984 /* Soft reconfiguration inbound. */
16985 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
16986 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
16990 /* maximum-prefix. */
16991 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
16992 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
16993 peer
->pmax
[afi
][safi
]);
16995 if (peer
->pmax_threshold
[afi
][safi
]
16996 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
16997 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
16998 if (peer_af_flag_check(peer
, afi
, safi
,
16999 PEER_FLAG_MAX_PREFIX_WARNING
))
17000 vty_out(vty
, " warning-only");
17001 if (peer
->pmax_restart
[afi
][safi
])
17002 vty_out(vty
, " restart %u",
17003 peer
->pmax_restart
[afi
][safi
]);
17004 if (peer_af_flag_check(peer
, afi
, safi
,
17005 PEER_FLAG_MAX_PREFIX_FORCE
))
17006 vty_out(vty
, " force");
17008 vty_out(vty
, "\n");
17011 /* maximum-prefix-out */
17012 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
17013 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
17014 addr
, peer
->pmax_out
[afi
][safi
]);
17016 /* Route server client. */
17017 if (peergroup_af_flag_check(peer
, afi
, safi
,
17018 PEER_FLAG_RSERVER_CLIENT
)) {
17019 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
17022 /* Nexthop-local unchanged. */
17023 if (peergroup_af_flag_check(peer
, afi
, safi
,
17024 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
17025 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
17028 /* allowas-in <1-10> */
17029 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
17030 if (peer_af_flag_check(peer
, afi
, safi
,
17031 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
17032 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
17033 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
17034 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
17036 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
17037 peer
->allowas_in
[afi
][safi
]);
17042 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
17043 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
17044 peer
->weight
[afi
][safi
]);
17047 bgp_config_write_filter(vty
, peer
, afi
, safi
);
17049 /* atribute-unchanged. */
17050 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
17051 || (safi
!= SAFI_EVPN
17052 && peer_af_flag_check(peer
, afi
, safi
,
17053 PEER_FLAG_NEXTHOP_UNCHANGED
))
17054 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
17056 if (!peer_group_active(peer
)
17057 || peergroup_af_flag_check(peer
, afi
, safi
,
17058 PEER_FLAG_AS_PATH_UNCHANGED
)
17059 || peergroup_af_flag_check(peer
, afi
, safi
,
17060 PEER_FLAG_NEXTHOP_UNCHANGED
)
17061 || peergroup_af_flag_check(peer
, afi
, safi
,
17062 PEER_FLAG_MED_UNCHANGED
)) {
17065 " neighbor %s attribute-unchanged%s%s%s\n",
17067 peer_af_flag_check(peer
, afi
, safi
,
17068 PEER_FLAG_AS_PATH_UNCHANGED
)
17071 peer_af_flag_check(peer
, afi
, safi
,
17072 PEER_FLAG_NEXTHOP_UNCHANGED
)
17075 peer_af_flag_check(peer
, afi
, safi
,
17076 PEER_FLAG_MED_UNCHANGED
)
17083 /* Address family based peer configuration display. */
17084 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
17088 struct peer_group
*group
;
17089 struct listnode
*node
, *nnode
;
17092 vty_frame(vty
, " !\n address-family ");
17093 if (afi
== AFI_IP
) {
17094 if (safi
== SAFI_UNICAST
)
17095 vty_frame(vty
, "ipv4 unicast");
17096 else if (safi
== SAFI_LABELED_UNICAST
)
17097 vty_frame(vty
, "ipv4 labeled-unicast");
17098 else if (safi
== SAFI_MULTICAST
)
17099 vty_frame(vty
, "ipv4 multicast");
17100 else if (safi
== SAFI_MPLS_VPN
)
17101 vty_frame(vty
, "ipv4 vpn");
17102 else if (safi
== SAFI_ENCAP
)
17103 vty_frame(vty
, "ipv4 encap");
17104 else if (safi
== SAFI_FLOWSPEC
)
17105 vty_frame(vty
, "ipv4 flowspec");
17106 } else if (afi
== AFI_IP6
) {
17107 if (safi
== SAFI_UNICAST
)
17108 vty_frame(vty
, "ipv6 unicast");
17109 else if (safi
== SAFI_LABELED_UNICAST
)
17110 vty_frame(vty
, "ipv6 labeled-unicast");
17111 else if (safi
== SAFI_MULTICAST
)
17112 vty_frame(vty
, "ipv6 multicast");
17113 else if (safi
== SAFI_MPLS_VPN
)
17114 vty_frame(vty
, "ipv6 vpn");
17115 else if (safi
== SAFI_ENCAP
)
17116 vty_frame(vty
, "ipv6 encap");
17117 else if (safi
== SAFI_FLOWSPEC
)
17118 vty_frame(vty
, "ipv6 flowspec");
17119 } else if (afi
== AFI_L2VPN
) {
17120 if (safi
== SAFI_EVPN
)
17121 vty_frame(vty
, "l2vpn evpn");
17123 vty_frame(vty
, "\n");
17125 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
17127 bgp_config_write_network(vty
, bgp
, afi
, safi
);
17129 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
17131 /* BGP flag dampening. */
17132 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
17133 bgp_config_write_damp(vty
, bgp
, afi
, safi
);
17134 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, node
, group
))
17135 if (peer_af_flag_check(group
->conf
, afi
, safi
,
17136 PEER_FLAG_CONFIG_DAMPENING
))
17137 bgp_config_write_peer_damp(vty
, group
->conf
, afi
, safi
);
17138 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, node
, peer
))
17139 if (peer_af_flag_check(peer
, afi
, safi
,
17140 PEER_FLAG_CONFIG_DAMPENING
))
17141 bgp_config_write_peer_damp(vty
, peer
, afi
, safi
);
17143 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
17144 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
17146 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17147 /* Skip dynamic neighbors. */
17148 if (peer_dynamic_neighbor(peer
))
17151 /* Do not display doppelganger peers */
17152 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17153 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
17156 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
17157 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
17159 if (safi
== SAFI_EVPN
)
17160 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
17162 if (safi
== SAFI_FLOWSPEC
)
17163 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
17165 if (safi
== SAFI_UNICAST
) {
17166 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
17167 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17168 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
17170 vty_out(vty
, " export vpn\n");
17172 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17173 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
17175 vty_out(vty
, " import vpn\n");
17177 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
17178 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
17181 for (ALL_LIST_ELEMENTS_RO(
17182 bgp
->vpn_policy
[afi
].import_vrf
, node
,
17184 vty_out(vty
, " import vrf %s\n", name
);
17188 vty_endframe(vty
, " exit-address-family\n");
17191 int bgp_config_write(struct vty
*vty
)
17194 struct peer_group
*group
;
17196 struct listnode
*node
, *nnode
;
17197 struct listnode
*mnode
, *mnnode
;
17199 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
17200 vty_out(vty
, "bgp route-map delay-timer %u\n",
17201 bm
->rmap_update_timer
);
17203 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
17204 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
17205 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
17206 vty_out(vty
, " %d", bm
->v_establish_wait
);
17207 vty_out(vty
, "\n");
17210 if (bm
->wait_for_fib
)
17211 vty_out(vty
, "bgp suppress-fib-pending\n");
17213 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17214 vty_out(vty
, "bgp graceful-shutdown\n");
17216 /* No-RIB (Zebra) option flag configuration */
17217 if (bgp_option_check(BGP_OPT_NO_FIB
))
17218 vty_out(vty
, "bgp no-rib\n");
17220 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA
))
17221 vty_out(vty
, "no bgp send-extra-data zebra\n");
17223 /* BGP configuration. */
17224 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
17226 /* skip all auto created vrf as they dont have user config */
17227 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
17230 /* Router bgp ASN */
17231 vty_out(vty
, "router bgp %u", bgp
->as
);
17234 vty_out(vty
, " %s %s",
17235 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
17236 ? "view" : "vrf", bgp
->name
);
17237 vty_out(vty
, "\n");
17239 /* BGP fast-external-failover. */
17240 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
17241 vty_out(vty
, " no bgp fast-external-failover\n");
17243 /* BGP router ID. */
17244 if (bgp
->router_id_static
.s_addr
!= INADDR_ANY
)
17245 vty_out(vty
, " bgp router-id %pI4\n",
17246 &bgp
->router_id_static
);
17248 /* Suppress fib pending */
17249 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_FIB_PENDING
))
17250 vty_out(vty
, " bgp suppress-fib-pending\n");
17252 /* BGP log-neighbor-changes. */
17253 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17254 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
17255 vty_out(vty
, " %sbgp log-neighbor-changes\n",
17256 CHECK_FLAG(bgp
->flags
,
17257 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
17261 /* BGP configuration. */
17262 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
17263 vty_out(vty
, " bgp always-compare-med\n");
17265 /* RFC8212 default eBGP policy. */
17266 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
17267 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
17268 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
17269 CHECK_FLAG(bgp
->flags
,
17270 BGP_FLAG_EBGP_REQUIRES_POLICY
)
17274 /* draft-ietf-idr-deprecate-as-set-confed-set */
17275 if (bgp
->reject_as_sets
)
17276 vty_out(vty
, " bgp reject-as-sets\n");
17278 /* Suppress duplicate updates if the route actually not changed
17280 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SUPPRESS_DUPLICATES
)
17281 != SAVE_BGP_SUPPRESS_DUPLICATES
)
17282 vty_out(vty
, " %sbgp suppress-duplicates\n",
17283 CHECK_FLAG(bgp
->flags
,
17284 BGP_FLAG_SUPPRESS_DUPLICATES
)
17288 /* BGP default ipv4-unicast. */
17289 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
))
17290 vty_out(vty
, " no bgp default ipv4-unicast\n");
17292 /* BGP default local-preference. */
17293 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
17294 vty_out(vty
, " bgp default local-preference %u\n",
17295 bgp
->default_local_pref
);
17297 /* BGP default show-hostname */
17298 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17299 != SAVE_BGP_SHOW_HOSTNAME
)
17300 vty_out(vty
, " %sbgp default show-hostname\n",
17301 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
17305 /* BGP default show-nexthop-hostname */
17306 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17307 != SAVE_BGP_SHOW_HOSTNAME
)
17308 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
17309 CHECK_FLAG(bgp
->flags
,
17310 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
17314 /* BGP default subgroup-pkt-queue-max. */
17315 if (bgp
->default_subgroup_pkt_queue_max
17316 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
17317 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
17318 bgp
->default_subgroup_pkt_queue_max
);
17320 /* BGP client-to-client reflection. */
17321 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
17322 vty_out(vty
, " no bgp client-to-client reflection\n");
17324 /* BGP cluster ID. */
17325 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
17326 vty_out(vty
, " bgp cluster-id %pI4\n",
17329 /* Disable ebgp connected nexthop check */
17330 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
17332 " bgp disable-ebgp-connected-route-check\n");
17334 /* Confederation identifier*/
17335 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
17336 vty_out(vty
, " bgp confederation identifier %u\n",
17339 /* Confederation peer */
17340 if (bgp
->confed_peers_cnt
> 0) {
17343 vty_out(vty
, " bgp confederation peers");
17345 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
17346 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
17348 vty_out(vty
, "\n");
17351 /* BGP deterministic-med. */
17352 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
17353 != SAVE_BGP_DETERMINISTIC_MED
)
17354 vty_out(vty
, " %sbgp deterministic-med\n",
17355 CHECK_FLAG(bgp
->flags
,
17356 BGP_FLAG_DETERMINISTIC_MED
)
17360 /* BGP update-delay. */
17361 bgp_config_write_update_delay(vty
, bgp
);
17363 if (bgp
->v_maxmed_onstartup
17364 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
17365 vty_out(vty
, " bgp max-med on-startup %u",
17366 bgp
->v_maxmed_onstartup
);
17367 if (bgp
->maxmed_onstartup_value
17368 != BGP_MAXMED_VALUE_DEFAULT
)
17369 vty_out(vty
, " %u",
17370 bgp
->maxmed_onstartup_value
);
17371 vty_out(vty
, "\n");
17373 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
17374 vty_out(vty
, " bgp max-med administrative");
17375 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
17376 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
17377 vty_out(vty
, "\n");
17381 bgp_config_write_wpkt_quanta(vty
, bgp
);
17383 bgp_config_write_rpkt_quanta(vty
, bgp
);
17385 /* coalesce time */
17386 bgp_config_write_coalesce_time(vty
, bgp
);
17388 /* BGP per-instance graceful-shutdown */
17389 /* BGP-wide settings and per-instance settings are mutually
17392 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
17393 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
17394 vty_out(vty
, " bgp graceful-shutdown\n");
17396 /* BGP graceful-restart. */
17397 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
17399 " bgp graceful-restart stalepath-time %u\n",
17400 bgp
->stalepath_time
);
17402 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
17403 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
17404 bgp
->restart_time
);
17406 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
17408 " bgp graceful-restart select-defer-time %u\n",
17409 bgp
->select_defer_time
);
17411 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
17412 vty_out(vty
, " bgp graceful-restart\n");
17414 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
17415 vty_out(vty
, " bgp graceful-restart-disable\n");
17417 /* BGP graceful-restart Preserve State F bit. */
17418 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
17420 " bgp graceful-restart preserve-fw-state\n");
17422 /* Stale timer for RIB */
17423 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
17425 " bgp graceful-restart rib-stale-time %u\n",
17426 bgp
->rib_stale_time
);
17428 /* BGP bestpath method. */
17429 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
17430 vty_out(vty
, " bgp bestpath as-path ignore\n");
17431 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
17432 vty_out(vty
, " bgp bestpath as-path confed\n");
17434 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
17435 if (CHECK_FLAG(bgp
->flags
,
17436 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
17438 " bgp bestpath as-path multipath-relax as-set\n");
17441 " bgp bestpath as-path multipath-relax\n");
17445 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
17447 " bgp route-reflector allow-outbound-policy\n");
17449 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
17450 vty_out(vty
, " bgp bestpath compare-routerid\n");
17451 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
17452 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
17453 vty_out(vty
, " bgp bestpath med");
17454 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
17455 vty_out(vty
, " confed");
17456 if (CHECK_FLAG(bgp
->flags
,
17457 BGP_FLAG_MED_MISSING_AS_WORST
))
17458 vty_out(vty
, " missing-as-worst");
17459 vty_out(vty
, "\n");
17462 /* Link bandwidth handling. */
17463 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
17464 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
17465 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
17466 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
17467 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
17468 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
17470 /* BGP network import check. */
17471 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17472 != SAVE_BGP_IMPORT_CHECK
)
17473 vty_out(vty
, " %sbgp network import-check\n",
17474 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
17478 /* BGP timers configuration. */
17479 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
17480 && bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
17481 vty_out(vty
, " timers bgp %u %u\n",
17482 bgp
->default_keepalive
, bgp
->default_holdtime
);
17485 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
17486 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
17489 /* Normal neighbor configuration. */
17490 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
17491 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
17492 bgp_config_write_peer_global(vty
, bgp
, peer
);
17495 /* listen range and limit for dynamic BGP neighbors */
17496 bgp_config_write_listen(vty
, bgp
);
17499 * BGP default autoshutdown neighbors
17501 * This must be placed after any peer and peer-group
17502 * configuration, to avoid setting all peers to shutdown after
17503 * a daemon restart, which is undesired behavior. (see #2286)
17505 if (bgp
->autoshutdown
)
17506 vty_out(vty
, " bgp default shutdown\n");
17508 /* BGP instance administrative shutdown */
17509 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
17510 vty_out(vty
, " bgp shutdown\n");
17512 /* IPv4 unicast configuration. */
17513 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
17515 /* IPv4 multicast configuration. */
17516 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
17518 /* IPv4 labeled-unicast configuration. */
17519 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
17521 /* IPv4 VPN configuration. */
17522 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
17524 /* ENCAPv4 configuration. */
17525 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
17527 /* FLOWSPEC v4 configuration. */
17528 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
17530 /* IPv6 unicast configuration. */
17531 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
17533 /* IPv6 multicast configuration. */
17534 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
17536 /* IPv6 labeled-unicast configuration. */
17537 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
17538 SAFI_LABELED_UNICAST
);
17540 /* IPv6 VPN configuration. */
17541 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
17543 /* ENCAPv6 configuration. */
17544 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
17546 /* FLOWSPEC v6 configuration. */
17547 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
17549 /* EVPN configuration. */
17550 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
17552 hook_call(bgp_inst_config_write
, bgp
, vty
);
17554 #ifdef ENABLE_BGP_VNC
17555 bgp_rfapi_cfg_write(vty
, bgp
);
17558 vty_out(vty
, "!\n");
17564 /* BGP node structure. */
17565 static struct cmd_node bgp_node
= {
17568 .parent_node
= CONFIG_NODE
,
17569 .prompt
= "%s(config-router)# ",
17570 .config_write
= bgp_config_write
,
17573 static struct cmd_node bgp_ipv4_unicast_node
= {
17574 .name
= "bgp ipv4 unicast",
17575 .node
= BGP_IPV4_NODE
,
17576 .parent_node
= BGP_NODE
,
17577 .prompt
= "%s(config-router-af)# ",
17580 static struct cmd_node bgp_ipv4_multicast_node
= {
17581 .name
= "bgp ipv4 multicast",
17582 .node
= BGP_IPV4M_NODE
,
17583 .parent_node
= BGP_NODE
,
17584 .prompt
= "%s(config-router-af)# ",
17587 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
17588 .name
= "bgp ipv4 labeled unicast",
17589 .node
= BGP_IPV4L_NODE
,
17590 .parent_node
= BGP_NODE
,
17591 .prompt
= "%s(config-router-af)# ",
17594 static struct cmd_node bgp_ipv6_unicast_node
= {
17595 .name
= "bgp ipv6",
17596 .node
= BGP_IPV6_NODE
,
17597 .parent_node
= BGP_NODE
,
17598 .prompt
= "%s(config-router-af)# ",
17601 static struct cmd_node bgp_ipv6_multicast_node
= {
17602 .name
= "bgp ipv6 multicast",
17603 .node
= BGP_IPV6M_NODE
,
17604 .parent_node
= BGP_NODE
,
17605 .prompt
= "%s(config-router-af)# ",
17608 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
17609 .name
= "bgp ipv6 labeled unicast",
17610 .node
= BGP_IPV6L_NODE
,
17611 .parent_node
= BGP_NODE
,
17612 .prompt
= "%s(config-router-af)# ",
17615 static struct cmd_node bgp_vpnv4_node
= {
17616 .name
= "bgp vpnv4",
17617 .node
= BGP_VPNV4_NODE
,
17618 .parent_node
= BGP_NODE
,
17619 .prompt
= "%s(config-router-af)# ",
17622 static struct cmd_node bgp_vpnv6_node
= {
17623 .name
= "bgp vpnv6",
17624 .node
= BGP_VPNV6_NODE
,
17625 .parent_node
= BGP_NODE
,
17626 .prompt
= "%s(config-router-af-vpnv6)# ",
17629 static struct cmd_node bgp_evpn_node
= {
17630 .name
= "bgp evpn",
17631 .node
= BGP_EVPN_NODE
,
17632 .parent_node
= BGP_NODE
,
17633 .prompt
= "%s(config-router-evpn)# ",
17636 static struct cmd_node bgp_evpn_vni_node
= {
17637 .name
= "bgp evpn vni",
17638 .node
= BGP_EVPN_VNI_NODE
,
17639 .parent_node
= BGP_EVPN_NODE
,
17640 .prompt
= "%s(config-router-af-vni)# ",
17643 static struct cmd_node bgp_flowspecv4_node
= {
17644 .name
= "bgp ipv4 flowspec",
17645 .node
= BGP_FLOWSPECV4_NODE
,
17646 .parent_node
= BGP_NODE
,
17647 .prompt
= "%s(config-router-af)# ",
17650 static struct cmd_node bgp_flowspecv6_node
= {
17651 .name
= "bgp ipv6 flowspec",
17652 .node
= BGP_FLOWSPECV6_NODE
,
17653 .parent_node
= BGP_NODE
,
17654 .prompt
= "%s(config-router-af-vpnv6)# ",
17657 static void community_list_vty(void);
17659 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
17663 struct listnode
*lnbgp
, *lnpeer
;
17665 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17666 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
17667 /* only provide suggestions on the appropriate input
17669 * they'll otherwise show up multiple times */
17670 enum cmd_token_type match_type
;
17671 char *name
= peer
->host
;
17673 if (peer
->conf_if
) {
17674 match_type
= VARIABLE_TKN
;
17675 name
= peer
->conf_if
;
17676 } else if (strchr(peer
->host
, ':'))
17677 match_type
= IPV6_TKN
;
17679 match_type
= IPV4_TKN
;
17681 if (token
->type
!= match_type
)
17684 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
17689 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
17690 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
17691 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
17692 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
17693 {.completions
= NULL
}};
17695 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
17698 struct peer_group
*group
;
17699 struct listnode
*lnbgp
, *lnpeer
;
17701 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
17702 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
17703 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
17708 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
17709 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
17710 {.completions
= NULL
} };
17712 void bgp_vty_init(void)
17714 cmd_variable_handler_register(bgp_var_neighbor
);
17715 cmd_variable_handler_register(bgp_var_peergroup
);
17717 /* Install bgp top node. */
17718 install_node(&bgp_node
);
17719 install_node(&bgp_ipv4_unicast_node
);
17720 install_node(&bgp_ipv4_multicast_node
);
17721 install_node(&bgp_ipv4_labeled_unicast_node
);
17722 install_node(&bgp_ipv6_unicast_node
);
17723 install_node(&bgp_ipv6_multicast_node
);
17724 install_node(&bgp_ipv6_labeled_unicast_node
);
17725 install_node(&bgp_vpnv4_node
);
17726 install_node(&bgp_vpnv6_node
);
17727 install_node(&bgp_evpn_node
);
17728 install_node(&bgp_evpn_vni_node
);
17729 install_node(&bgp_flowspecv4_node
);
17730 install_node(&bgp_flowspecv6_node
);
17732 /* Install default VTY commands to new nodes. */
17733 install_default(BGP_NODE
);
17734 install_default(BGP_IPV4_NODE
);
17735 install_default(BGP_IPV4M_NODE
);
17736 install_default(BGP_IPV4L_NODE
);
17737 install_default(BGP_IPV6_NODE
);
17738 install_default(BGP_IPV6M_NODE
);
17739 install_default(BGP_IPV6L_NODE
);
17740 install_default(BGP_VPNV4_NODE
);
17741 install_default(BGP_VPNV6_NODE
);
17742 install_default(BGP_FLOWSPECV4_NODE
);
17743 install_default(BGP_FLOWSPECV6_NODE
);
17744 install_default(BGP_EVPN_NODE
);
17745 install_default(BGP_EVPN_VNI_NODE
);
17747 /* "bgp local-mac" hidden commands. */
17748 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
17749 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
17751 /* "bgp suppress-fib-pending" global */
17752 install_element(CONFIG_NODE
, &bgp_global_suppress_fib_pending_cmd
);
17754 /* bgp route-map delay-timer commands. */
17755 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17756 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17758 /* global bgp update-delay command */
17759 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
17760 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
17762 /* global bgp graceful-shutdown command */
17763 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
17764 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
17766 /* Dummy commands (Currently not supported) */
17767 install_element(BGP_NODE
, &no_synchronization_cmd
);
17768 install_element(BGP_NODE
, &no_auto_summary_cmd
);
17770 /* "router bgp" commands. */
17771 install_element(CONFIG_NODE
, &router_bgp_cmd
);
17773 /* "no router bgp" commands. */
17774 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
17776 /* "bgp router-id" commands. */
17777 install_element(BGP_NODE
, &bgp_router_id_cmd
);
17778 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
17780 /* "bgp suppress-fib-pending" command */
17781 install_element(BGP_NODE
, &bgp_suppress_fib_pending_cmd
);
17783 /* "bgp cluster-id" commands. */
17784 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
17785 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
17787 /* "bgp no-rib" commands. */
17788 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
17789 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
17791 install_element(CONFIG_NODE
, &no_bgp_send_extra_data_cmd
);
17793 /* "bgp confederation" commands. */
17794 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
17795 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
17797 /* "bgp confederation peers" commands. */
17798 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
17799 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
17801 /* bgp max-med command */
17802 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
17803 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
17804 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
17805 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
17806 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
17808 /* bgp disable-ebgp-connected-nh-check */
17809 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
17810 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
17812 /* bgp update-delay command */
17813 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
17814 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
17816 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
17817 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
17819 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
17820 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
17822 /* "maximum-paths" commands. */
17823 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
17824 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
17825 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
17826 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
17827 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
17828 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
17829 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
17830 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
17831 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
17832 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
17833 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17834 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17835 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
17836 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17837 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17839 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
17840 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
17841 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17842 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17843 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17844 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
17845 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
17846 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
17847 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
17848 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
17850 /* "timers bgp" commands. */
17851 install_element(BGP_NODE
, &bgp_timers_cmd
);
17852 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
17854 /* route-map delay-timer commands - per instance for backwards compat.
17856 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
17857 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
17859 /* "bgp client-to-client reflection" commands */
17860 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
17861 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
17863 /* "bgp always-compare-med" commands */
17864 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
17865 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
17867 /* bgp ebgp-requires-policy */
17868 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
17869 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
17871 /* bgp suppress-duplicates */
17872 install_element(BGP_NODE
, &bgp_suppress_duplicates_cmd
);
17873 install_element(BGP_NODE
, &no_bgp_suppress_duplicates_cmd
);
17875 /* bgp reject-as-sets */
17876 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
17877 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
17879 /* "bgp deterministic-med" commands */
17880 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
17881 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
17883 /* "bgp graceful-restart" command */
17884 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
17885 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
17887 /* "bgp graceful-restart-disable" command */
17888 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
17889 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
17891 /* "neighbor a:b:c:d graceful-restart" command */
17892 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
17893 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
17895 /* "neighbor a:b:c:d graceful-restart-disable" command */
17896 install_element(BGP_NODE
,
17897 &bgp_neighbor_graceful_restart_disable_set_cmd
);
17898 install_element(BGP_NODE
,
17899 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
17901 /* "neighbor a:b:c:d graceful-restart-helper" command */
17902 install_element(BGP_NODE
,
17903 &bgp_neighbor_graceful_restart_helper_set_cmd
);
17904 install_element(BGP_NODE
,
17905 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
17907 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
17908 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
17909 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
17910 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
17911 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
17912 install_element(BGP_NODE
,
17913 &no_bgp_graceful_restart_select_defer_time_cmd
);
17914 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
17915 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
17917 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
17918 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
17919 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
17920 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
17922 /* "bgp graceful-shutdown" commands */
17923 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
17924 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
17926 /* "bgp fast-external-failover" commands */
17927 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
17928 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
17930 /* "bgp bestpath compare-routerid" commands */
17931 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
17932 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
17934 /* "bgp bestpath as-path ignore" commands */
17935 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
17936 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
17938 /* "bgp bestpath as-path confed" commands */
17939 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
17940 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
17942 /* "bgp bestpath as-path multipath-relax" commands */
17943 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
17944 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
17946 /* "bgp log-neighbor-changes" commands */
17947 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
17948 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
17950 /* "bgp bestpath med" commands */
17951 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
17952 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
17954 /* "bgp bestpath bandwidth" commands */
17955 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
17956 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
17958 /* "no bgp default ipv4-unicast" commands. */
17959 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
17960 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
17962 /* "bgp network import-check" commands. */
17963 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
17964 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
17965 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
17967 /* "bgp default local-preference" commands. */
17968 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
17969 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
17971 /* bgp default show-hostname */
17972 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
17973 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
17975 /* bgp default show-nexthop-hostname */
17976 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
17977 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
17979 /* "bgp default subgroup-pkt-queue-max" commands. */
17980 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
17981 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
17983 /* bgp ibgp-allow-policy-mods command */
17984 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
17985 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
17987 /* "bgp listen limit" commands. */
17988 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
17989 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
17991 /* "bgp listen range" commands. */
17992 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
17993 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
17995 /* "bgp default shutdown" command */
17996 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
17998 /* "bgp shutdown" commands */
17999 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
18000 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
18001 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
18002 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
18004 /* "neighbor remote-as" commands. */
18005 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
18006 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
18007 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
18008 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
18009 install_element(BGP_NODE
,
18010 &neighbor_interface_v6only_config_remote_as_cmd
);
18011 install_element(BGP_NODE
, &no_neighbor_cmd
);
18012 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
18014 /* "neighbor peer-group" commands. */
18015 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
18016 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
18017 install_element(BGP_NODE
,
18018 &no_neighbor_interface_peer_group_remote_as_cmd
);
18020 /* "neighbor local-as" commands. */
18021 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
18022 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
18023 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
18024 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
18026 /* "neighbor solo" commands. */
18027 install_element(BGP_NODE
, &neighbor_solo_cmd
);
18028 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
18030 /* "neighbor password" commands. */
18031 install_element(BGP_NODE
, &neighbor_password_cmd
);
18032 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
18034 /* "neighbor activate" commands. */
18035 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
18036 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
18037 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
18038 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
18039 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
18040 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
18041 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
18042 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
18043 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
18044 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
18045 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
18046 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
18048 /* "no neighbor activate" commands. */
18049 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
18050 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
18051 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
18052 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
18053 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
18054 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
18055 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
18056 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
18057 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
18058 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
18059 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
18060 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
18062 /* "neighbor peer-group" set commands. */
18063 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
18064 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18065 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18066 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18067 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18068 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18069 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18070 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
18071 install_element(BGP_FLOWSPECV4_NODE
,
18072 &neighbor_set_peer_group_hidden_cmd
);
18073 install_element(BGP_FLOWSPECV6_NODE
,
18074 &neighbor_set_peer_group_hidden_cmd
);
18076 /* "no neighbor peer-group unset" commands. */
18077 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
18078 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18079 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18080 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18081 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18082 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18083 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18084 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
18085 install_element(BGP_FLOWSPECV4_NODE
,
18086 &no_neighbor_set_peer_group_hidden_cmd
);
18087 install_element(BGP_FLOWSPECV6_NODE
,
18088 &no_neighbor_set_peer_group_hidden_cmd
);
18090 /* "neighbor softreconfiguration inbound" commands.*/
18091 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
18092 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
18093 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18094 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18095 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18096 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18097 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18098 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18099 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18100 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18101 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
18102 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18103 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
18104 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18105 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
18106 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18107 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
18108 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18109 install_element(BGP_FLOWSPECV4_NODE
,
18110 &neighbor_soft_reconfiguration_cmd
);
18111 install_element(BGP_FLOWSPECV4_NODE
,
18112 &no_neighbor_soft_reconfiguration_cmd
);
18113 install_element(BGP_FLOWSPECV6_NODE
,
18114 &neighbor_soft_reconfiguration_cmd
);
18115 install_element(BGP_FLOWSPECV6_NODE
,
18116 &no_neighbor_soft_reconfiguration_cmd
);
18117 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
18118 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
18120 /* "neighbor attribute-unchanged" commands. */
18121 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
18122 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
18123 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
18124 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18125 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
18126 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18127 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
18128 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18129 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
18130 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18131 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
18132 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
18133 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
18134 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
18135 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
18136 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18137 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
18138 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18140 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
18141 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
18143 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_attr_unchanged_cmd
);
18144 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
18145 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_attr_unchanged_cmd
);
18146 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
18148 /* "nexthop-local unchanged" commands */
18149 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
18150 install_element(BGP_IPV6_NODE
,
18151 &no_neighbor_nexthop_local_unchanged_cmd
);
18153 /* "neighbor next-hop-self" commands. */
18154 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
18155 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
18156 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
18157 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18158 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
18159 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
18160 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
18161 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
18162 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
18163 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18164 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
18165 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
18166 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
18167 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
18168 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
18169 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
18170 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
18171 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
18172 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
18173 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
18175 /* "neighbor next-hop-self force" commands. */
18176 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
18177 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
18178 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18179 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
18180 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18181 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18182 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18183 install_element(BGP_IPV4_NODE
,
18184 &no_neighbor_nexthop_self_all_hidden_cmd
);
18185 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
18186 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18187 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18188 install_element(BGP_IPV4M_NODE
,
18189 &no_neighbor_nexthop_self_all_hidden_cmd
);
18190 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
18191 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18192 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18193 install_element(BGP_IPV4L_NODE
,
18194 &no_neighbor_nexthop_self_all_hidden_cmd
);
18195 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18196 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18197 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18198 install_element(BGP_IPV6_NODE
,
18199 &no_neighbor_nexthop_self_all_hidden_cmd
);
18200 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
18201 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18202 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18203 install_element(BGP_IPV6M_NODE
,
18204 &no_neighbor_nexthop_self_all_hidden_cmd
);
18205 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
18206 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18207 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18208 install_element(BGP_IPV6L_NODE
,
18209 &no_neighbor_nexthop_self_all_hidden_cmd
);
18210 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
18211 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18212 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18213 install_element(BGP_VPNV4_NODE
,
18214 &no_neighbor_nexthop_self_all_hidden_cmd
);
18215 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
18216 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18217 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
18218 install_element(BGP_VPNV6_NODE
,
18219 &no_neighbor_nexthop_self_all_hidden_cmd
);
18220 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
18221 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
18223 /* "neighbor as-override" commands. */
18224 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
18225 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
18226 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
18227 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
18228 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
18229 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
18230 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
18231 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
18232 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
18233 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
18234 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
18235 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
18236 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
18237 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
18238 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
18239 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
18240 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
18241 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
18243 /* "neighbor remove-private-AS" commands. */
18244 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
18245 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
18246 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
18247 install_element(BGP_NODE
,
18248 &no_neighbor_remove_private_as_all_hidden_cmd
);
18249 install_element(BGP_NODE
,
18250 &neighbor_remove_private_as_replace_as_hidden_cmd
);
18251 install_element(BGP_NODE
,
18252 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
18253 install_element(BGP_NODE
,
18254 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18257 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
18258 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
18259 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18260 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18261 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18262 install_element(BGP_IPV4_NODE
,
18263 &neighbor_remove_private_as_replace_as_cmd
);
18264 install_element(BGP_IPV4_NODE
,
18265 &no_neighbor_remove_private_as_replace_as_cmd
);
18266 install_element(BGP_IPV4_NODE
,
18267 &neighbor_remove_private_as_all_replace_as_cmd
);
18268 install_element(BGP_IPV4_NODE
,
18269 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18270 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
18271 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
18272 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
18273 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18274 install_element(BGP_IPV4M_NODE
,
18275 &neighbor_remove_private_as_replace_as_cmd
);
18276 install_element(BGP_IPV4M_NODE
,
18277 &no_neighbor_remove_private_as_replace_as_cmd
);
18278 install_element(BGP_IPV4M_NODE
,
18279 &neighbor_remove_private_as_all_replace_as_cmd
);
18280 install_element(BGP_IPV4M_NODE
,
18281 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18282 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
18283 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
18284 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
18285 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18286 install_element(BGP_IPV4L_NODE
,
18287 &neighbor_remove_private_as_replace_as_cmd
);
18288 install_element(BGP_IPV4L_NODE
,
18289 &no_neighbor_remove_private_as_replace_as_cmd
);
18290 install_element(BGP_IPV4L_NODE
,
18291 &neighbor_remove_private_as_all_replace_as_cmd
);
18292 install_element(BGP_IPV4L_NODE
,
18293 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18294 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
18295 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18296 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18297 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18298 install_element(BGP_IPV6_NODE
,
18299 &neighbor_remove_private_as_replace_as_cmd
);
18300 install_element(BGP_IPV6_NODE
,
18301 &no_neighbor_remove_private_as_replace_as_cmd
);
18302 install_element(BGP_IPV6_NODE
,
18303 &neighbor_remove_private_as_all_replace_as_cmd
);
18304 install_element(BGP_IPV6_NODE
,
18305 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18306 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
18307 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
18308 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
18309 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18310 install_element(BGP_IPV6M_NODE
,
18311 &neighbor_remove_private_as_replace_as_cmd
);
18312 install_element(BGP_IPV6M_NODE
,
18313 &no_neighbor_remove_private_as_replace_as_cmd
);
18314 install_element(BGP_IPV6M_NODE
,
18315 &neighbor_remove_private_as_all_replace_as_cmd
);
18316 install_element(BGP_IPV6M_NODE
,
18317 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18318 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
18319 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
18320 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
18321 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18322 install_element(BGP_IPV6L_NODE
,
18323 &neighbor_remove_private_as_replace_as_cmd
);
18324 install_element(BGP_IPV6L_NODE
,
18325 &no_neighbor_remove_private_as_replace_as_cmd
);
18326 install_element(BGP_IPV6L_NODE
,
18327 &neighbor_remove_private_as_all_replace_as_cmd
);
18328 install_element(BGP_IPV6L_NODE
,
18329 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18330 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
18331 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
18332 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
18333 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18334 install_element(BGP_VPNV4_NODE
,
18335 &neighbor_remove_private_as_replace_as_cmd
);
18336 install_element(BGP_VPNV4_NODE
,
18337 &no_neighbor_remove_private_as_replace_as_cmd
);
18338 install_element(BGP_VPNV4_NODE
,
18339 &neighbor_remove_private_as_all_replace_as_cmd
);
18340 install_element(BGP_VPNV4_NODE
,
18341 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18342 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
18343 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
18344 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
18345 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
18346 install_element(BGP_VPNV6_NODE
,
18347 &neighbor_remove_private_as_replace_as_cmd
);
18348 install_element(BGP_VPNV6_NODE
,
18349 &no_neighbor_remove_private_as_replace_as_cmd
);
18350 install_element(BGP_VPNV6_NODE
,
18351 &neighbor_remove_private_as_all_replace_as_cmd
);
18352 install_element(BGP_VPNV6_NODE
,
18353 &no_neighbor_remove_private_as_all_replace_as_cmd
);
18355 /* "neighbor send-community" commands.*/
18356 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
18357 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
18358 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
18359 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
18360 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
18361 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
18362 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
18363 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
18364 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
18365 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
18366 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
18367 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
18368 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
18369 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
18370 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
18371 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
18372 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
18373 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
18374 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
18375 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
18376 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
18377 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
18378 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
18379 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
18380 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
18381 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
18382 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
18383 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
18384 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
18385 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
18386 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
18387 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
18388 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
18389 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
18390 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
18391 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
18393 /* "neighbor route-reflector" commands.*/
18394 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
18395 install_element(BGP_NODE
,
18396 &no_neighbor_route_reflector_client_hidden_cmd
);
18397 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
18398 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
18399 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
18400 install_element(BGP_IPV4M_NODE
,
18401 &no_neighbor_route_reflector_client_cmd
);
18402 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
18403 install_element(BGP_IPV4L_NODE
,
18404 &no_neighbor_route_reflector_client_cmd
);
18405 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
18406 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
18407 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
18408 install_element(BGP_IPV6M_NODE
,
18409 &no_neighbor_route_reflector_client_cmd
);
18410 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
18411 install_element(BGP_IPV6L_NODE
,
18412 &no_neighbor_route_reflector_client_cmd
);
18413 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
18414 install_element(BGP_VPNV4_NODE
,
18415 &no_neighbor_route_reflector_client_cmd
);
18416 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
18417 install_element(BGP_VPNV6_NODE
,
18418 &no_neighbor_route_reflector_client_cmd
);
18419 install_element(BGP_FLOWSPECV4_NODE
,
18420 &neighbor_route_reflector_client_cmd
);
18421 install_element(BGP_FLOWSPECV4_NODE
,
18422 &no_neighbor_route_reflector_client_cmd
);
18423 install_element(BGP_FLOWSPECV6_NODE
,
18424 &neighbor_route_reflector_client_cmd
);
18425 install_element(BGP_FLOWSPECV6_NODE
,
18426 &no_neighbor_route_reflector_client_cmd
);
18427 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
18428 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
18430 /* "neighbor route-server" commands.*/
18431 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
18432 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
18433 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
18434 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
18435 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
18436 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
18437 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
18438 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
18439 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
18440 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
18441 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
18442 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
18443 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
18444 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
18445 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
18446 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
18447 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
18448 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
18449 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
18450 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
18451 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
18452 install_element(BGP_FLOWSPECV4_NODE
,
18453 &no_neighbor_route_server_client_cmd
);
18454 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
18455 install_element(BGP_FLOWSPECV6_NODE
,
18456 &no_neighbor_route_server_client_cmd
);
18458 /* "neighbor addpath-tx-all-paths" commands.*/
18459 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
18460 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
18461 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18462 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18463 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18464 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18465 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18466 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18467 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18468 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18469 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18470 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18471 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18472 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18473 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18474 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18475 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
18476 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
18478 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
18479 install_element(BGP_NODE
,
18480 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18481 install_element(BGP_NODE
,
18482 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
18483 install_element(BGP_IPV4_NODE
,
18484 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18485 install_element(BGP_IPV4_NODE
,
18486 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18487 install_element(BGP_IPV4M_NODE
,
18488 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18489 install_element(BGP_IPV4M_NODE
,
18490 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18491 install_element(BGP_IPV4L_NODE
,
18492 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18493 install_element(BGP_IPV4L_NODE
,
18494 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18495 install_element(BGP_IPV6_NODE
,
18496 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18497 install_element(BGP_IPV6_NODE
,
18498 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18499 install_element(BGP_IPV6M_NODE
,
18500 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18501 install_element(BGP_IPV6M_NODE
,
18502 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18503 install_element(BGP_IPV6L_NODE
,
18504 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18505 install_element(BGP_IPV6L_NODE
,
18506 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18507 install_element(BGP_VPNV4_NODE
,
18508 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18509 install_element(BGP_VPNV4_NODE
,
18510 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18511 install_element(BGP_VPNV6_NODE
,
18512 &neighbor_addpath_tx_bestpath_per_as_cmd
);
18513 install_element(BGP_VPNV6_NODE
,
18514 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
18516 /* "neighbor sender-as-path-loop-detection" commands. */
18517 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
18518 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
18520 /* "neighbor passive" commands. */
18521 install_element(BGP_NODE
, &neighbor_passive_cmd
);
18522 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
18525 /* "neighbor shutdown" commands. */
18526 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
18527 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
18528 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
18529 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
18530 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
18531 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
18533 /* "neighbor capability extended-nexthop" commands.*/
18534 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
18535 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
18537 /* "neighbor capability orf prefix-list" commands.*/
18538 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
18539 install_element(BGP_NODE
,
18540 &no_neighbor_capability_orf_prefix_hidden_cmd
);
18541 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
18542 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18543 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18544 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18545 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18546 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18547 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
18548 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18549 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
18550 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18551 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
18552 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
18554 /* "neighbor capability dynamic" commands.*/
18555 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
18556 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
18558 /* "neighbor dont-capability-negotiate" commands. */
18559 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
18560 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
18562 /* "neighbor ebgp-multihop" commands. */
18563 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
18564 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
18565 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
18567 /* "neighbor disable-connected-check" commands. */
18568 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
18569 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
18571 /* "neighbor enforce-first-as" commands. */
18572 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
18573 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
18575 /* "neighbor description" commands. */
18576 install_element(BGP_NODE
, &neighbor_description_cmd
);
18577 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
18578 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
18580 /* "neighbor update-source" commands. "*/
18581 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
18582 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
18584 /* "neighbor default-originate" commands. */
18585 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
18586 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
18587 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
18588 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
18589 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
18590 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
18591 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
18592 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
18593 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
18594 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
18595 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
18596 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
18597 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
18598 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
18599 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
18600 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
18601 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
18602 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
18603 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
18604 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
18605 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
18607 /* "neighbor port" commands. */
18608 install_element(BGP_NODE
, &neighbor_port_cmd
);
18609 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
18611 /* "neighbor weight" commands. */
18612 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
18613 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
18615 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
18616 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
18617 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
18618 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
18619 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
18620 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
18621 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
18622 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
18623 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
18624 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
18625 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
18626 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
18627 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
18628 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
18629 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
18630 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
18632 /* "neighbor override-capability" commands. */
18633 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
18634 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
18636 /* "neighbor strict-capability-match" commands. */
18637 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
18638 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
18640 /* "neighbor timers" commands. */
18641 install_element(BGP_NODE
, &neighbor_timers_cmd
);
18642 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
18644 /* "neighbor timers connect" commands. */
18645 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
18646 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
18648 /* "neighbor timers delayopen" commands. */
18649 install_element(BGP_NODE
, &neighbor_timers_delayopen_cmd
);
18650 install_element(BGP_NODE
, &no_neighbor_timers_delayopen_cmd
);
18652 /* "neighbor advertisement-interval" commands. */
18653 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
18654 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
18656 /* "neighbor interface" commands. */
18657 install_element(BGP_NODE
, &neighbor_interface_cmd
);
18658 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
18660 /* "neighbor distribute" commands. */
18661 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
18662 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
18663 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
18664 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
18665 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
18666 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
18667 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
18668 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
18669 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
18670 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
18671 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
18672 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
18673 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
18674 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
18675 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
18676 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
18677 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
18678 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
18680 /* "neighbor prefix-list" commands. */
18681 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
18682 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
18683 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
18684 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
18685 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
18686 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
18687 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
18688 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
18689 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
18690 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
18691 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
18693 /* "neighbor filter-list" commands. */
18694 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
18695 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
18696 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
18697 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
18698 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
18699 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
18700 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
18701 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
18702 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
18703 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
18704 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
18705 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
18706 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
18707 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
18708 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
18709 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
18710 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
18711 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
18712 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
18713 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
18714 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
18715 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
18717 /* "neighbor route-map" commands. */
18718 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
18719 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
18720 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
18721 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
18722 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
18723 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
18724 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
18725 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
18726 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
18727 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
18728 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
18730 /* "neighbor unsuppress-map" commands. */
18731 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
18732 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
18733 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
18734 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18735 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
18736 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18737 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
18738 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18739 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
18740 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18741 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
18742 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
18743 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
18744 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
18745 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
18746 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
18747 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
18748 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
18750 /* "neighbor advertise-map" commands. */
18751 install_element(BGP_NODE
, &neighbor_advertise_map_hidden_cmd
);
18752 install_element(BGP_IPV4_NODE
, &neighbor_advertise_map_cmd
);
18753 install_element(BGP_IPV4M_NODE
, &neighbor_advertise_map_cmd
);
18754 install_element(BGP_IPV4L_NODE
, &neighbor_advertise_map_cmd
);
18755 install_element(BGP_IPV6_NODE
, &neighbor_advertise_map_cmd
);
18756 install_element(BGP_IPV6M_NODE
, &neighbor_advertise_map_cmd
);
18757 install_element(BGP_IPV6L_NODE
, &neighbor_advertise_map_cmd
);
18758 install_element(BGP_VPNV4_NODE
, &neighbor_advertise_map_cmd
);
18759 install_element(BGP_VPNV6_NODE
, &neighbor_advertise_map_cmd
);
18761 /* neighbor maximum-prefix-out commands. */
18762 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
18763 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18764 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18765 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18766 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18767 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18768 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18769 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18770 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18771 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18772 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
18773 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18774 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
18775 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18776 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
18777 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18778 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
18779 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
18781 /* "neighbor maximum-prefix" commands. */
18782 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
18783 install_element(BGP_NODE
,
18784 &neighbor_maximum_prefix_threshold_hidden_cmd
);
18785 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
18786 install_element(BGP_NODE
,
18787 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
18788 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
18789 install_element(BGP_NODE
,
18790 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
18791 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
18792 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
18793 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18794 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18795 install_element(BGP_IPV4_NODE
,
18796 &neighbor_maximum_prefix_threshold_warning_cmd
);
18797 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18798 install_element(BGP_IPV4_NODE
,
18799 &neighbor_maximum_prefix_threshold_restart_cmd
);
18800 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18801 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
18802 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18803 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18804 install_element(BGP_IPV4M_NODE
,
18805 &neighbor_maximum_prefix_threshold_warning_cmd
);
18806 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18807 install_element(BGP_IPV4M_NODE
,
18808 &neighbor_maximum_prefix_threshold_restart_cmd
);
18809 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18810 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
18811 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18812 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18813 install_element(BGP_IPV4L_NODE
,
18814 &neighbor_maximum_prefix_threshold_warning_cmd
);
18815 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18816 install_element(BGP_IPV4L_NODE
,
18817 &neighbor_maximum_prefix_threshold_restart_cmd
);
18818 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18819 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
18820 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18821 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18822 install_element(BGP_IPV6_NODE
,
18823 &neighbor_maximum_prefix_threshold_warning_cmd
);
18824 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18825 install_element(BGP_IPV6_NODE
,
18826 &neighbor_maximum_prefix_threshold_restart_cmd
);
18827 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18828 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
18829 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18830 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18831 install_element(BGP_IPV6M_NODE
,
18832 &neighbor_maximum_prefix_threshold_warning_cmd
);
18833 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18834 install_element(BGP_IPV6M_NODE
,
18835 &neighbor_maximum_prefix_threshold_restart_cmd
);
18836 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
18837 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
18838 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18839 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18840 install_element(BGP_IPV6L_NODE
,
18841 &neighbor_maximum_prefix_threshold_warning_cmd
);
18842 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18843 install_element(BGP_IPV6L_NODE
,
18844 &neighbor_maximum_prefix_threshold_restart_cmd
);
18845 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
18846 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
18847 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18848 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18849 install_element(BGP_VPNV4_NODE
,
18850 &neighbor_maximum_prefix_threshold_warning_cmd
);
18851 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18852 install_element(BGP_VPNV4_NODE
,
18853 &neighbor_maximum_prefix_threshold_restart_cmd
);
18854 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
18855 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
18856 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
18857 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
18858 install_element(BGP_VPNV6_NODE
,
18859 &neighbor_maximum_prefix_threshold_warning_cmd
);
18860 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
18861 install_element(BGP_VPNV6_NODE
,
18862 &neighbor_maximum_prefix_threshold_restart_cmd
);
18863 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
18865 /* "neighbor allowas-in" */
18866 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
18867 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
18868 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
18869 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
18870 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
18871 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
18872 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
18873 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
18874 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
18875 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
18876 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
18877 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
18878 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
18879 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
18880 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
18881 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
18882 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
18883 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
18884 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
18885 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
18887 /* "neighbor dampening" commands. */
18888 install_element(BGP_NODE
, &neighbor_damp_cmd
);
18889 install_element(BGP_NODE
, &no_neighbor_damp_cmd
);
18890 install_element(BGP_IPV4_NODE
, &neighbor_damp_cmd
);
18891 install_element(BGP_IPV4_NODE
, &no_neighbor_damp_cmd
);
18892 install_element(BGP_IPV4M_NODE
, &neighbor_damp_cmd
);
18893 install_element(BGP_IPV4M_NODE
, &no_neighbor_damp_cmd
);
18894 install_element(BGP_IPV4L_NODE
, &neighbor_damp_cmd
);
18895 install_element(BGP_IPV4L_NODE
, &no_neighbor_damp_cmd
);
18896 install_element(BGP_IPV6_NODE
, &neighbor_damp_cmd
);
18897 install_element(BGP_IPV6_NODE
, &no_neighbor_damp_cmd
);
18898 install_element(BGP_IPV6M_NODE
, &neighbor_damp_cmd
);
18899 install_element(BGP_IPV6M_NODE
, &no_neighbor_damp_cmd
);
18900 install_element(BGP_IPV6L_NODE
, &neighbor_damp_cmd
);
18901 install_element(BGP_IPV6L_NODE
, &no_neighbor_damp_cmd
);
18902 install_element(VIEW_NODE
, &show_ip_bgp_neighbor_damp_param_cmd
);
18904 /* address-family commands. */
18905 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
18906 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
18907 #ifdef KEEP_OLD_VPN_COMMANDS
18908 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
18909 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
18910 #endif /* KEEP_OLD_VPN_COMMANDS */
18912 install_element(BGP_NODE
, &address_family_evpn_cmd
);
18914 /* "exit-address-family" command. */
18915 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
18916 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
18917 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
18918 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
18919 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
18920 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
18921 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
18922 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
18923 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
18924 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
18925 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
18927 /* "clear ip bgp commands" */
18928 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
18930 /* clear ip bgp prefix */
18931 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
18932 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
18933 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
18935 /* "show [ip] bgp summary" commands. */
18936 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
18937 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
18938 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
18939 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
18940 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
18941 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
18942 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
18944 /* "show [ip] bgp neighbors" commands. */
18945 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
18947 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
18949 /* "show [ip] bgp peer-group" commands. */
18950 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
18952 /* "show [ip] bgp paths" commands. */
18953 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
18955 /* "show [ip] bgp community" commands. */
18956 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
18958 /* "show ip bgp large-community" commands. */
18959 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
18960 /* "show [ip] bgp attribute-info" commands. */
18961 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
18962 /* "show [ip] bgp route-leak" command */
18963 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
18965 /* "redistribute" commands. */
18966 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
18967 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
18968 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
18969 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
18970 install_element(BGP_NODE
,
18971 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
18972 install_element(BGP_NODE
,
18973 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
18974 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
18975 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
18976 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
18977 install_element(BGP_NODE
,
18978 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
18979 install_element(BGP_NODE
,
18980 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
18981 install_element(BGP_NODE
,
18982 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
18983 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
18984 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
18985 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
18986 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
18987 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
18988 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
18989 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
18990 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
18991 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
18992 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
18993 install_element(BGP_IPV4_NODE
,
18994 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
18995 install_element(BGP_IPV4_NODE
,
18996 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
18997 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
18998 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
18999 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
19000 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
19001 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
19002 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
19004 /* import|export vpn [route-map WORD] */
19005 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
19006 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
19008 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
19009 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
19011 /* ttl_security commands */
19012 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
19013 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
19015 /* "show [ip] bgp memory" commands. */
19016 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
19018 /* "show bgp martian next-hop" */
19019 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
19021 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
19023 /* "show [ip] bgp views" commands. */
19024 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
19026 /* "show [ip] bgp vrfs" commands. */
19027 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
19029 /* Community-list. */
19030 community_list_vty();
19032 /* vpn-policy commands */
19033 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
19034 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
19035 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
19036 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
19037 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
19038 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
19039 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
19040 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
19041 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
19042 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
19043 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
19044 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
19046 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
19047 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
19049 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
19050 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
19051 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
19052 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
19053 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
19054 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
19055 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19056 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
19057 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
19058 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
19061 #include "memory.h"
19062 #include "bgp_regex.h"
19063 #include "bgp_clist.h"
19064 #include "bgp_ecommunity.h"
19066 /* VTY functions. */
19068 /* Direction value to string conversion. */
19069 static const char *community_direct_str(int direct
)
19072 case COMMUNITY_DENY
:
19074 case COMMUNITY_PERMIT
:
19081 /* Display error string. */
19082 static void community_list_perror(struct vty
*vty
, int ret
)
19085 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
19086 vty_out(vty
, "%% Can't find community-list\n");
19088 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
19089 vty_out(vty
, "%% Malformed community-list value\n");
19091 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
19093 "%% Community name conflict, previously defined as standard community\n");
19095 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
19097 "%% Community name conflict, previously defined as expanded community\n");
19102 /* "community-list" keyword help string. */
19103 #define COMMUNITY_LIST_STR "Add a community list entry\n"
19105 /*community-list standard */
19106 DEFUN (community_list_standard
,
19107 bgp_community_list_standard_cmd
,
19108 "bgp community-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
19111 "Community list number (standard)\n"
19112 "Add an standard community-list entry\n"
19113 "Community list name\n"
19114 "Sequence number of an entry\n"
19115 "Sequence number\n"
19116 "Specify community to reject\n"
19117 "Specify community to accept\n"
19120 char *cl_name_or_number
= NULL
;
19123 int style
= COMMUNITY_LIST_STANDARD
;
19126 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19128 seq
= argv
[idx
]->arg
;
19131 argv_find(argv
, argc
, "(1-99)", &idx
);
19132 argv_find(argv
, argc
, "WORD", &idx
);
19133 cl_name_or_number
= argv
[idx
]->arg
;
19134 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19136 argv_find(argv
, argc
, "AA:NN", &idx
);
19137 char *str
= argv_concat(argv
, argc
, idx
);
19139 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19142 XFREE(MTYPE_TMP
, str
);
19145 /* Display error string. */
19146 community_list_perror(vty
, ret
);
19147 return CMD_WARNING_CONFIG_FAILED
;
19150 return CMD_SUCCESS
;
19153 DEFUN (no_community_list_standard_all
,
19154 no_bgp_community_list_standard_all_cmd
,
19155 "no bgp community-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
19159 "Community list number (standard)\n"
19160 "Add an standard community-list entry\n"
19161 "Community list name\n"
19162 "Sequence number of an entry\n"
19163 "Sequence number\n"
19164 "Specify community to reject\n"
19165 "Specify community to accept\n"
19168 char *cl_name_or_number
= NULL
;
19171 int style
= COMMUNITY_LIST_STANDARD
;
19175 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19177 seq
= argv
[idx
]->arg
;
19180 argv_find(argv
, argc
, "permit", &idx
);
19181 argv_find(argv
, argc
, "deny", &idx
);
19184 direct
= argv_find(argv
, argc
, "permit", &idx
)
19189 argv_find(argv
, argc
, "AA:NN", &idx
);
19190 str
= argv_concat(argv
, argc
, idx
);
19194 argv_find(argv
, argc
, "(1-99)", &idx
);
19195 argv_find(argv
, argc
, "WORD", &idx
);
19196 cl_name_or_number
= argv
[idx
]->arg
;
19198 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19201 XFREE(MTYPE_TMP
, str
);
19204 community_list_perror(vty
, ret
);
19205 return CMD_WARNING_CONFIG_FAILED
;
19208 return CMD_SUCCESS
;
19211 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
19212 "no bgp community-list <(1-99)|standard WORD>",
19213 NO_STR BGP_STR COMMUNITY_LIST_STR
19214 "Community list number (standard)\n"
19215 "Add an standard community-list entry\n"
19216 "Community list name\n")
19218 /*community-list expanded */
19219 DEFUN (community_list_expanded_all
,
19220 bgp_community_list_expanded_all_cmd
,
19221 "bgp community-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
19224 "Community list number (expanded)\n"
19225 "Add an expanded community-list entry\n"
19226 "Community list name\n"
19227 "Sequence number of an entry\n"
19228 "Sequence number\n"
19229 "Specify community to reject\n"
19230 "Specify community to accept\n"
19233 char *cl_name_or_number
= NULL
;
19236 int style
= COMMUNITY_LIST_EXPANDED
;
19239 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19241 seq
= argv
[idx
]->arg
;
19245 argv_find(argv
, argc
, "(100-500)", &idx
);
19246 argv_find(argv
, argc
, "WORD", &idx
);
19247 cl_name_or_number
= argv
[idx
]->arg
;
19248 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19250 argv_find(argv
, argc
, "AA:NN", &idx
);
19251 char *str
= argv_concat(argv
, argc
, idx
);
19253 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
19256 XFREE(MTYPE_TMP
, str
);
19259 /* Display error string. */
19260 community_list_perror(vty
, ret
);
19261 return CMD_WARNING_CONFIG_FAILED
;
19264 return CMD_SUCCESS
;
19267 DEFUN (no_community_list_expanded_all
,
19268 no_bgp_community_list_expanded_all_cmd
,
19269 "no bgp community-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
19273 "Community list number (expanded)\n"
19274 "Add an expanded community-list entry\n"
19275 "Community list name\n"
19276 "Sequence number of an entry\n"
19277 "Sequence number\n"
19278 "Specify community to reject\n"
19279 "Specify community to accept\n"
19282 char *cl_name_or_number
= NULL
;
19286 int style
= COMMUNITY_LIST_EXPANDED
;
19289 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
19291 seq
= argv
[idx
]->arg
;
19294 argv_find(argv
, argc
, "permit", &idx
);
19295 argv_find(argv
, argc
, "deny", &idx
);
19298 direct
= argv_find(argv
, argc
, "permit", &idx
)
19303 argv_find(argv
, argc
, "AA:NN", &idx
);
19304 str
= argv_concat(argv
, argc
, idx
);
19308 argv_find(argv
, argc
, "(100-500)", &idx
);
19309 argv_find(argv
, argc
, "WORD", &idx
);
19310 cl_name_or_number
= argv
[idx
]->arg
;
19312 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
19315 XFREE(MTYPE_TMP
, str
);
19318 community_list_perror(vty
, ret
);
19319 return CMD_WARNING_CONFIG_FAILED
;
19322 return CMD_SUCCESS
;
19325 ALIAS(no_community_list_expanded_all
,
19326 no_bgp_community_list_expanded_all_list_cmd
,
19327 "no bgp community-list <(100-500)|expanded WORD>",
19328 NO_STR BGP_STR COMMUNITY_LIST_STR
19329 "Community list number (expanded)\n"
19330 "Add an expanded community-list entry\n"
19331 "Community list name\n")
19333 /* Return configuration string of community-list entry. */
19334 static const char *community_list_config_str(struct community_entry
*entry
)
19341 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
19342 str
= community_str(entry
->u
.com
, false);
19343 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
19344 str
= lcommunity_str(entry
->u
.lcom
, false);
19346 str
= entry
->config
;
19351 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
19353 struct community_entry
*entry
;
19355 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19356 if (entry
== list
->head
) {
19357 if (all_digit(list
->name
))
19358 vty_out(vty
, "Community %s list %s\n",
19359 entry
->style
== COMMUNITY_LIST_STANDARD
19361 : "(expanded) access",
19364 vty_out(vty
, "Named Community %s list %s\n",
19365 entry
->style
== COMMUNITY_LIST_STANDARD
19371 vty_out(vty
, " %s\n",
19372 community_direct_str(entry
->direct
));
19374 vty_out(vty
, " %s %s\n",
19375 community_direct_str(entry
->direct
),
19376 community_list_config_str(entry
));
19380 DEFUN (show_community_list
,
19381 show_bgp_community_list_cmd
,
19382 "show bgp community-list",
19385 "List community-list\n")
19387 struct community_list
*list
;
19388 struct community_list_master
*cm
;
19390 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
19392 return CMD_SUCCESS
;
19394 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19395 community_list_show(vty
, list
);
19397 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19398 community_list_show(vty
, list
);
19400 return CMD_SUCCESS
;
19403 DEFUN (show_community_list_arg
,
19404 show_bgp_community_list_arg_cmd
,
19405 "show bgp community-list <(1-500)|WORD> detail",
19408 "List community-list\n"
19409 "Community-list number\n"
19410 "Community-list name\n"
19411 "Detailed information on community-list\n")
19413 int idx_comm_list
= 3;
19414 struct community_list
*list
;
19416 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
19417 COMMUNITY_LIST_MASTER
);
19419 vty_out(vty
, "%% Can't find community-list\n");
19420 return CMD_WARNING
;
19423 community_list_show(vty
, list
);
19425 return CMD_SUCCESS
;
19429 * Large Community code.
19431 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
19432 struct cmd_token
**argv
, int style
,
19433 int reject_all_digit_name
)
19442 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19443 seq
= argv
[idx
]->arg
;
19446 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19449 /* All digit name check. */
19451 argv_find(argv
, argc
, "WORD", &idx
);
19452 argv_find(argv
, argc
, "(1-99)", &idx
);
19453 argv_find(argv
, argc
, "(100-500)", &idx
);
19454 cl_name
= argv
[idx
]->arg
;
19455 if (reject_all_digit_name
&& all_digit(cl_name
)) {
19456 vty_out(vty
, "%% Community name cannot have all digits\n");
19457 return CMD_WARNING_CONFIG_FAILED
;
19461 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
19462 argv_find(argv
, argc
, "LINE", &idx
);
19463 /* Concat community string argument. */
19465 str
= argv_concat(argv
, argc
, idx
);
19469 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
19471 /* Free temporary community list string allocated by
19473 XFREE(MTYPE_TMP
, str
);
19476 community_list_perror(vty
, ret
);
19477 return CMD_WARNING_CONFIG_FAILED
;
19479 return CMD_SUCCESS
;
19482 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
19483 struct cmd_token
**argv
, int style
)
19491 if (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 /* Check the list direct. */
19500 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
19501 direct
= COMMUNITY_PERMIT
;
19503 direct
= COMMUNITY_DENY
;
19506 argv_find(argv
, argc
, "LINE", &idx
);
19507 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
19508 /* Concat community string argument. */
19509 str
= argv_concat(argv
, argc
, idx
);
19513 argv_find(argv
, argc
, "(1-99)", &idx
);
19514 argv_find(argv
, argc
, "(100-500)", &idx
);
19515 argv_find(argv
, argc
, "WORD", &idx
);
19517 /* Unset community list. */
19518 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
19521 /* Free temporary community list string allocated by
19523 XFREE(MTYPE_TMP
, str
);
19526 community_list_perror(vty
, ret
);
19527 return CMD_WARNING_CONFIG_FAILED
;
19530 return CMD_SUCCESS
;
19533 /* "large-community-list" keyword help string. */
19534 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
19535 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
19537 DEFUN (lcommunity_list_standard
,
19538 bgp_lcommunity_list_standard_cmd
,
19539 "bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
19541 LCOMMUNITY_LIST_STR
19542 "Large Community list number (standard)\n"
19543 "Sequence number of an entry\n"
19544 "Sequence number\n"
19545 "Specify large community to reject\n"
19546 "Specify large community to accept\n"
19547 LCOMMUNITY_VAL_STR
)
19549 return lcommunity_list_set_vty(vty
, argc
, argv
,
19550 LARGE_COMMUNITY_LIST_STANDARD
, 0);
19553 DEFUN (lcommunity_list_expanded
,
19554 bgp_lcommunity_list_expanded_cmd
,
19555 "bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
19557 LCOMMUNITY_LIST_STR
19558 "Large Community list number (expanded)\n"
19559 "Sequence number of an entry\n"
19560 "Sequence number\n"
19561 "Specify large community to reject\n"
19562 "Specify large community to accept\n"
19563 "An ordered list as a regular-expression\n")
19565 return lcommunity_list_set_vty(vty
, argc
, argv
,
19566 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
19569 DEFUN (lcommunity_list_name_standard
,
19570 bgp_lcommunity_list_name_standard_cmd
,
19571 "bgp large-community-list standard WORD [seq (0-4294967295)] <deny|permit> AA:BB:CC...",
19573 LCOMMUNITY_LIST_STR
19574 "Specify standard large-community-list\n"
19575 "Large Community list name\n"
19576 "Sequence number of an entry\n"
19577 "Sequence number\n"
19578 "Specify large community to reject\n"
19579 "Specify large community to accept\n"
19580 LCOMMUNITY_VAL_STR
)
19582 return lcommunity_list_set_vty(vty
, argc
, argv
,
19583 LARGE_COMMUNITY_LIST_STANDARD
, 1);
19586 DEFUN (lcommunity_list_name_expanded
,
19587 bgp_lcommunity_list_name_expanded_cmd
,
19588 "bgp large-community-list expanded WORD [seq (0-4294967295)] <deny|permit> LINE...",
19590 LCOMMUNITY_LIST_STR
19591 "Specify expanded large-community-list\n"
19592 "Large Community list name\n"
19593 "Sequence number of an entry\n"
19594 "Sequence number\n"
19595 "Specify large community to reject\n"
19596 "Specify large community to accept\n"
19597 "An ordered list as a regular-expression\n")
19599 return lcommunity_list_set_vty(vty
, argc
, argv
,
19600 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
19603 DEFUN (no_lcommunity_list_all
,
19604 no_bgp_lcommunity_list_all_cmd
,
19605 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
19608 LCOMMUNITY_LIST_STR
19609 "Large Community list number (standard)\n"
19610 "Large Community list number (expanded)\n"
19611 "Large Community list name\n")
19613 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19614 LARGE_COMMUNITY_LIST_STANDARD
);
19617 DEFUN (no_lcommunity_list_name_standard_all
,
19618 no_bgp_lcommunity_list_name_standard_all_cmd
,
19619 "no bgp large-community-list standard WORD",
19622 LCOMMUNITY_LIST_STR
19623 "Specify standard large-community-list\n"
19624 "Large Community list name\n")
19626 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19627 LARGE_COMMUNITY_LIST_STANDARD
);
19630 DEFUN (no_lcommunity_list_name_expanded_all
,
19631 no_bgp_lcommunity_list_name_expanded_all_cmd
,
19632 "no bgp large-community-list expanded WORD",
19635 LCOMMUNITY_LIST_STR
19636 "Specify expanded large-community-list\n"
19637 "Large Community list name\n")
19639 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19640 LARGE_COMMUNITY_LIST_EXPANDED
);
19643 DEFUN (no_lcommunity_list_standard
,
19644 no_bgp_lcommunity_list_standard_cmd
,
19645 "no bgp large-community-list (1-99) [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
19648 LCOMMUNITY_LIST_STR
19649 "Large Community list number (standard)\n"
19650 "Sequence number of an entry\n"
19651 "Sequence number\n"
19652 "Specify large community to reject\n"
19653 "Specify large community to accept\n"
19654 LCOMMUNITY_VAL_STR
)
19656 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19657 LARGE_COMMUNITY_LIST_STANDARD
);
19660 DEFUN (no_lcommunity_list_expanded
,
19661 no_bgp_lcommunity_list_expanded_cmd
,
19662 "no bgp large-community-list (100-500) [seq (0-4294967295)] <deny|permit> LINE...",
19665 LCOMMUNITY_LIST_STR
19666 "Large Community list number (expanded)\n"
19667 "Sequence number of an entry\n"
19668 "Sequence number\n"
19669 "Specify large community to reject\n"
19670 "Specify large community to accept\n"
19671 "An ordered list as a regular-expression\n")
19673 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19674 LARGE_COMMUNITY_LIST_EXPANDED
);
19677 DEFUN (no_lcommunity_list_name_standard
,
19678 no_bgp_lcommunity_list_name_standard_cmd
,
19679 "no bgp large-community-list standard WORD [seq (0-4294967295)] <deny|permit> AA:AA:NN...",
19682 LCOMMUNITY_LIST_STR
19683 "Specify standard large-community-list\n"
19684 "Large Community list name\n"
19685 "Sequence number of an entry\n"
19686 "Sequence number\n"
19687 "Specify large community to reject\n"
19688 "Specify large community to accept\n"
19689 LCOMMUNITY_VAL_STR
)
19691 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19692 LARGE_COMMUNITY_LIST_STANDARD
);
19695 DEFUN (no_lcommunity_list_name_expanded
,
19696 no_bgp_lcommunity_list_name_expanded_cmd
,
19697 "no bgp large-community-list expanded WORD [seq (0-4294967295)] <deny|permit> LINE...",
19700 LCOMMUNITY_LIST_STR
19701 "Specify expanded large-community-list\n"
19702 "Large community list name\n"
19703 "Sequence number of an entry\n"
19704 "Sequence number\n"
19705 "Specify large community to reject\n"
19706 "Specify large community to accept\n"
19707 "An ordered list as a regular-expression\n")
19709 return lcommunity_list_unset_vty(vty
, argc
, argv
,
19710 LARGE_COMMUNITY_LIST_EXPANDED
);
19713 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
19715 struct community_entry
*entry
;
19717 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
19718 if (entry
== list
->head
) {
19719 if (all_digit(list
->name
))
19720 vty_out(vty
, "Large community %s list %s\n",
19722 LARGE_COMMUNITY_LIST_STANDARD
19724 : "(expanded) access",
19728 "Named large community %s list %s\n",
19730 LARGE_COMMUNITY_LIST_STANDARD
19736 vty_out(vty
, " %s\n",
19737 community_direct_str(entry
->direct
));
19739 vty_out(vty
, " %s %s\n",
19740 community_direct_str(entry
->direct
),
19741 community_list_config_str(entry
));
19745 DEFUN (show_lcommunity_list
,
19746 show_bgp_lcommunity_list_cmd
,
19747 "show bgp large-community-list",
19750 "List large-community list\n")
19752 struct community_list
*list
;
19753 struct community_list_master
*cm
;
19755 cm
= community_list_master_lookup(bgp_clist
,
19756 LARGE_COMMUNITY_LIST_MASTER
);
19758 return CMD_SUCCESS
;
19760 for (list
= cm
->num
.head
; list
; list
= list
->next
)
19761 lcommunity_list_show(vty
, list
);
19763 for (list
= cm
->str
.head
; list
; list
= list
->next
)
19764 lcommunity_list_show(vty
, list
);
19766 return CMD_SUCCESS
;
19769 DEFUN (show_lcommunity_list_arg
,
19770 show_bgp_lcommunity_list_arg_cmd
,
19771 "show bgp large-community-list <(1-500)|WORD> detail",
19774 "List large-community list\n"
19775 "Large-community-list number\n"
19776 "Large-community-list name\n"
19777 "Detailed information on large-community-list\n")
19779 struct community_list
*list
;
19781 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
19782 LARGE_COMMUNITY_LIST_MASTER
);
19784 vty_out(vty
, "%% Can't find large-community-list\n");
19785 return CMD_WARNING
;
19788 lcommunity_list_show(vty
, list
);
19790 return CMD_SUCCESS
;
19793 /* "extcommunity-list" keyword help string. */
19794 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
19795 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
19797 DEFUN (extcommunity_list_standard
,
19798 bgp_extcommunity_list_standard_cmd
,
19799 "bgp extcommunity-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
19801 EXTCOMMUNITY_LIST_STR
19802 "Extended Community list number (standard)\n"
19803 "Specify standard extcommunity-list\n"
19804 "Community list name\n"
19805 "Sequence number of an entry\n"
19806 "Sequence number\n"
19807 "Specify community to reject\n"
19808 "Specify community to accept\n"
19809 EXTCOMMUNITY_VAL_STR
)
19811 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19813 char *cl_number_or_name
= NULL
;
19818 argv_find(argv
, argc
, "(1-99)", &idx
);
19819 argv_find(argv
, argc
, "WORD", &idx
);
19820 cl_number_or_name
= argv
[idx
]->arg
;
19822 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19823 seq
= argv
[idx
]->arg
;
19825 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19827 argv_find(argv
, argc
, "AA:NN", &idx
);
19828 char *str
= argv_concat(argv
, argc
, idx
);
19830 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19833 XFREE(MTYPE_TMP
, str
);
19836 community_list_perror(vty
, ret
);
19837 return CMD_WARNING_CONFIG_FAILED
;
19840 return CMD_SUCCESS
;
19843 DEFUN (extcommunity_list_name_expanded
,
19844 bgp_extcommunity_list_name_expanded_cmd
,
19845 "bgp extcommunity-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> LINE...",
19847 EXTCOMMUNITY_LIST_STR
19848 "Extended Community list number (expanded)\n"
19849 "Specify expanded extcommunity-list\n"
19850 "Extended Community list name\n"
19851 "Sequence number of an entry\n"
19852 "Sequence number\n"
19853 "Specify community to reject\n"
19854 "Specify community to accept\n"
19855 "An ordered list as a regular-expression\n")
19857 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
19859 char *cl_number_or_name
= NULL
;
19863 argv_find(argv
, argc
, "(100-500)", &idx
);
19864 argv_find(argv
, argc
, "WORD", &idx
);
19865 cl_number_or_name
= argv
[idx
]->arg
;
19867 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19868 seq
= argv
[idx
]->arg
;
19870 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
19872 argv_find(argv
, argc
, "LINE", &idx
);
19873 char *str
= argv_concat(argv
, argc
, idx
);
19875 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
19878 XFREE(MTYPE_TMP
, str
);
19881 community_list_perror(vty
, ret
);
19882 return CMD_WARNING_CONFIG_FAILED
;
19885 return CMD_SUCCESS
;
19888 DEFUN (no_extcommunity_list_standard_all
,
19889 no_bgp_extcommunity_list_standard_all_cmd
,
19890 "no bgp extcommunity-list <(1-99)|standard WORD> [seq (0-4294967295)] <deny|permit> AA:NN...",
19893 EXTCOMMUNITY_LIST_STR
19894 "Extended Community list number (standard)\n"
19895 "Specify standard extcommunity-list\n"
19896 "Community list name\n"
19897 "Sequence number of an entry\n"
19898 "Sequence number\n"
19899 "Specify community to reject\n"
19900 "Specify community to accept\n"
19901 EXTCOMMUNITY_VAL_STR
)
19903 int style
= EXTCOMMUNITY_LIST_STANDARD
;
19905 char *cl_number_or_name
= NULL
;
19910 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19911 seq
= argv
[idx
]->arg
;
19914 argv_find(argv
, argc
, "permit", &idx
);
19915 argv_find(argv
, argc
, "deny", &idx
);
19917 direct
= argv_find(argv
, argc
, "permit", &idx
)
19922 argv_find(argv
, argc
, "AA:NN", &idx
);
19923 str
= argv_concat(argv
, argc
, idx
);
19927 argv_find(argv
, argc
, "(1-99)", &idx
);
19928 argv_find(argv
, argc
, "WORD", &idx
);
19929 cl_number_or_name
= argv
[idx
]->arg
;
19931 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
19932 seq
, direct
, style
);
19934 XFREE(MTYPE_TMP
, str
);
19937 community_list_perror(vty
, ret
);
19938 return CMD_WARNING_CONFIG_FAILED
;
19941 return CMD_SUCCESS
;
19944 ALIAS(no_extcommunity_list_standard_all
,
19945 no_bgp_extcommunity_list_standard_all_list_cmd
,
19946 "no bgp extcommunity-list <(1-99)|standard WORD>",
19947 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
19948 "Extended Community list number (standard)\n"
19949 "Specify standard extcommunity-list\n"
19950 "Community list name\n")
19952 DEFUN (no_extcommunity_list_expanded_all
,
19953 no_bgp_extcommunity_list_expanded_all_cmd
,
19954 "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (0-4294967295)] <deny|permit> LINE...",
19957 EXTCOMMUNITY_LIST_STR
19958 "Extended Community list number (expanded)\n"
19959 "Specify expanded extcommunity-list\n"
19960 "Extended Community list name\n"
19961 "Sequence number of an entry\n"
19962 "Sequence number\n"
19963 "Specify community to reject\n"
19964 "Specify community to accept\n"
19965 "An ordered list as a regular-expression\n")
19967 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
19969 char *cl_number_or_name
= NULL
;
19974 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
19975 seq
= argv
[idx
]->arg
;
19978 argv_find(argv
, argc
, "permit", &idx
);
19979 argv_find(argv
, argc
, "deny", &idx
);
19982 direct
= argv_find(argv
, argc
, "permit", &idx
)
19987 argv_find(argv
, argc
, "LINE", &idx
);
19988 str
= argv_concat(argv
, argc
, idx
);
19992 argv_find(argv
, argc
, "(100-500)", &idx
);
19993 argv_find(argv
, argc
, "WORD", &idx
);
19994 cl_number_or_name
= argv
[idx
]->arg
;
19996 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
19997 seq
, direct
, style
);
19999 XFREE(MTYPE_TMP
, str
);
20002 community_list_perror(vty
, ret
);
20003 return CMD_WARNING_CONFIG_FAILED
;
20006 return CMD_SUCCESS
;
20009 ALIAS(no_extcommunity_list_expanded_all
,
20010 no_bgp_extcommunity_list_expanded_all_list_cmd
,
20011 "no bgp extcommunity-list <(100-500)|expanded WORD>",
20012 NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
20013 "Extended Community list number (expanded)\n"
20014 "Specify expanded extcommunity-list\n"
20015 "Extended Community list name\n")
20017 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
20019 struct community_entry
*entry
;
20021 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20022 if (entry
== list
->head
) {
20023 if (all_digit(list
->name
))
20024 vty_out(vty
, "Extended community %s list %s\n",
20025 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20027 : "(expanded) access",
20031 "Named extended community %s list %s\n",
20032 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20038 vty_out(vty
, " %s\n",
20039 community_direct_str(entry
->direct
));
20041 vty_out(vty
, " %s %s\n",
20042 community_direct_str(entry
->direct
),
20043 community_list_config_str(entry
));
20047 DEFUN (show_extcommunity_list
,
20048 show_bgp_extcommunity_list_cmd
,
20049 "show bgp extcommunity-list",
20052 "List extended-community list\n")
20054 struct community_list
*list
;
20055 struct community_list_master
*cm
;
20057 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20059 return CMD_SUCCESS
;
20061 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20062 extcommunity_list_show(vty
, list
);
20064 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20065 extcommunity_list_show(vty
, list
);
20067 return CMD_SUCCESS
;
20070 DEFUN (show_extcommunity_list_arg
,
20071 show_bgp_extcommunity_list_arg_cmd
,
20072 "show bgp extcommunity-list <(1-500)|WORD> detail",
20075 "List extended-community list\n"
20076 "Extcommunity-list number\n"
20077 "Extcommunity-list name\n"
20078 "Detailed information on extcommunity-list\n")
20080 int idx_comm_list
= 3;
20081 struct community_list
*list
;
20083 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
20084 EXTCOMMUNITY_LIST_MASTER
);
20086 vty_out(vty
, "%% Can't find extcommunity-list\n");
20087 return CMD_WARNING
;
20090 extcommunity_list_show(vty
, list
);
20092 return CMD_SUCCESS
;
20095 /* Display community-list and extcommunity-list configuration. */
20096 static int community_list_config_write(struct vty
*vty
)
20098 struct community_list
*list
;
20099 struct community_entry
*entry
;
20100 struct community_list_master
*cm
;
20103 /* Community-list. */
20104 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
20106 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20107 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20109 "bgp community-list %s seq %" PRId64
" %s %s\n",
20110 list
->name
, entry
->seq
,
20111 community_direct_str(entry
->direct
),
20112 community_list_config_str(entry
));
20115 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20116 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20118 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
20119 entry
->style
== COMMUNITY_LIST_STANDARD
20122 list
->name
, entry
->seq
,
20123 community_direct_str(entry
->direct
),
20124 community_list_config_str(entry
));
20128 /* Extcommunity-list. */
20129 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
20131 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20132 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20134 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
20135 list
->name
, entry
->seq
,
20136 community_direct_str(entry
->direct
),
20137 community_list_config_str(entry
));
20140 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20141 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20143 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
20144 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
20147 list
->name
, entry
->seq
,
20148 community_direct_str(entry
->direct
),
20149 community_list_config_str(entry
));
20154 /* lcommunity-list. */
20155 cm
= community_list_master_lookup(bgp_clist
,
20156 LARGE_COMMUNITY_LIST_MASTER
);
20158 for (list
= cm
->num
.head
; list
; list
= list
->next
)
20159 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20161 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
20162 list
->name
, entry
->seq
,
20163 community_direct_str(entry
->direct
),
20164 community_list_config_str(entry
));
20167 for (list
= cm
->str
.head
; list
; list
= list
->next
)
20168 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
20170 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
20172 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
20175 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
20176 community_list_config_str(entry
));
20183 static int community_list_config_write(struct vty
*vty
);
20184 static struct cmd_node community_list_node
= {
20185 .name
= "community list",
20186 .node
= COMMUNITY_LIST_NODE
,
20188 .config_write
= community_list_config_write
,
20191 static void community_list_vty(void)
20193 install_node(&community_list_node
);
20195 /* Community-list. */
20196 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
20197 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
20198 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
20199 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
20200 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
20201 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
20202 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
20203 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
20205 /* Extcommunity-list. */
20206 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
20207 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
20208 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
20209 install_element(CONFIG_NODE
,
20210 &no_bgp_extcommunity_list_standard_all_list_cmd
);
20211 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
20212 install_element(CONFIG_NODE
,
20213 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
20214 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
20215 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
20217 /* Large Community List */
20218 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
20219 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
20220 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
20221 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
20222 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
20223 install_element(CONFIG_NODE
,
20224 &no_bgp_lcommunity_list_name_standard_all_cmd
);
20225 install_element(CONFIG_NODE
,
20226 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
20227 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
20228 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
20229 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
20230 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
20231 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
20232 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);