2 * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "lib_errors.h"
26 #include "lib/zclient.h"
41 #include "bgpd/bgpd.h"
42 #include "bgpd/bgp_attr_evpn.h"
43 #include "bgpd/bgp_advertise.h"
44 #include "bgpd/bgp_attr.h"
45 #include "bgpd/bgp_aspath.h"
46 #include "bgpd/bgp_community.h"
47 #include "bgpd/bgp_ecommunity.h"
48 #include "bgpd/bgp_lcommunity.h"
49 #include "bgpd/bgp_damp.h"
50 #include "bgpd/bgp_debug.h"
51 #include "bgpd/bgp_errors.h"
52 #include "bgpd/bgp_fsm.h"
53 #include "bgpd/bgp_nexthop.h"
54 #include "bgpd/bgp_open.h"
55 #include "bgpd/bgp_regex.h"
56 #include "bgpd/bgp_route.h"
57 #include "bgpd/bgp_mplsvpn.h"
58 #include "bgpd/bgp_zebra.h"
59 #include "bgpd/bgp_table.h"
60 #include "bgpd/bgp_vty.h"
61 #include "bgpd/bgp_mpath.h"
62 #include "bgpd/bgp_packet.h"
63 #include "bgpd/bgp_updgrp.h"
64 #include "bgpd/bgp_bfd.h"
65 #include "bgpd/bgp_io.h"
66 #include "bgpd/bgp_evpn.h"
67 #include "bgpd/bgp_evpn_vty.h"
68 #include "bgpd/bgp_evpn_mh.h"
69 #include "bgpd/bgp_addpath.h"
70 #include "bgpd/bgp_mac.h"
71 #include "bgpd/bgp_flowspec.h"
73 #include "bgpd/rfapi/bgp_rfapi_cfg.h"
76 #include "northbound.h"
77 #include "northbound_cli.h"
78 #include "bgpd/bgp_nb.h"
81 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
84 .match_profile
= "traditional",
85 .match_version
= "< 7.4",
89 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
90 { .val_bool
= true, .match_profile
= "datacenter", },
91 { .val_bool
= false },
93 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
94 { .val_bool
= true, .match_profile
= "datacenter", },
95 { .val_bool
= false },
97 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
98 { .val_bool
= true, .match_profile
= "datacenter", },
99 { .val_bool
= false },
101 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
102 { .val_bool
= true, .match_profile
= "datacenter", },
103 { .val_bool
= false },
105 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
106 { .val_ulong
= 10, .match_profile
= "datacenter", },
107 { .val_ulong
= 120 },
109 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
110 { .val_ulong
= 9, .match_profile
= "datacenter", },
111 { .val_ulong
= 180 },
113 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
114 { .val_ulong
= 3, .match_profile
= "datacenter", },
117 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
118 { .val_bool
= false, .match_profile
= "datacenter", },
119 { .val_bool
= false, .match_version
= "< 7.4", },
120 { .val_bool
= true },
123 DEFINE_HOOK(bgp_inst_config_write
,
124 (struct bgp
*bgp
, struct vty
*vty
),
128 "The Graceful Restart No Operation was executed as cmd same as previous one."
130 "The Graceful Restart command used is not valid at this moment."
131 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
132 struct prefix
*range
, int exact
);
134 /* Show BGP peer's information. */
144 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
145 struct prefix
*range
, int exact
);
147 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
152 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
155 afi_t afi
, bool use_json
);
157 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
163 return BGP_IPV4_NODE
;
165 return BGP_IPV4M_NODE
;
166 case SAFI_LABELED_UNICAST
:
167 return BGP_IPV4L_NODE
;
169 return BGP_VPNV4_NODE
;
171 return BGP_FLOWSPECV4_NODE
;
174 return BGP_IPV4_NODE
;
180 return BGP_IPV6_NODE
;
182 return BGP_IPV6M_NODE
;
183 case SAFI_LABELED_UNICAST
:
184 return BGP_IPV6L_NODE
;
186 return BGP_VPNV6_NODE
;
188 return BGP_FLOWSPECV6_NODE
;
191 return BGP_IPV4_NODE
;
195 return BGP_EVPN_NODE
;
198 // We should never be here but to clarify the switch statement..
199 return BGP_IPV4_NODE
;
202 // Impossible to happen
203 return BGP_IPV4_NODE
;
206 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
208 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
209 return "IPv4 Unicast";
210 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
211 return "IPv4 Multicast";
212 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
213 return "IPv4 Labeled Unicast";
214 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
216 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
218 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
219 return "IPv4 Flowspec";
220 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
221 return "IPv6 Unicast";
222 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
223 return "IPv6 Multicast";
224 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
225 return "IPv6 Labeled Unicast";
226 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
228 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
230 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
231 return "IPv6 Flowspec";
232 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
239 * Please note that we have intentionally camelCased
240 * the return strings here. So if you want
241 * to use this function, please ensure you
242 * are doing this within json output
244 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
246 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
247 return "ipv4Unicast";
248 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
249 return "ipv4Multicast";
250 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
251 return "ipv4LabeledUnicast";
252 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
254 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
256 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
257 return "ipv4Flowspec";
258 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
259 return "ipv6Unicast";
260 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
261 return "ipv6Multicast";
262 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
263 return "ipv6LabeledUnicast";
264 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
266 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
268 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
269 return "ipv6Flowspec";
270 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
276 /* Utility function to get address family from current node. */
277 afi_t
bgp_node_afi(struct vty
*vty
)
285 case BGP_FLOWSPECV6_NODE
:
298 /* Utility function to get subsequent address family from current
300 safi_t
bgp_node_safi(struct vty
*vty
)
306 safi
= SAFI_MPLS_VPN
;
310 safi
= SAFI_MULTICAST
;
317 safi
= SAFI_LABELED_UNICAST
;
319 case BGP_FLOWSPECV4_NODE
:
320 case BGP_FLOWSPECV6_NODE
:
321 safi
= SAFI_FLOWSPEC
;
331 * Converts an AFI in string form to afi_t
333 * @param afi string, one of
337 * @return the corresponding afi_t
339 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
341 afi_t afi
= AFI_MAX
; /* unknown */
342 if (strmatch(afi_str
, "ipv4"))
344 else if (strmatch(afi_str
, "ipv6"))
346 else if (strmatch(afi_str
, "l2vpn"))
351 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
355 if (argv_find(argv
, argc
, "ipv4", index
)) {
359 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
363 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
371 /* supports <unicast|multicast|vpn|labeled-unicast> */
372 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
374 safi_t safi
= SAFI_MAX
; /* unknown */
375 if (strmatch(safi_str
, "multicast"))
376 safi
= SAFI_MULTICAST
;
377 else if (strmatch(safi_str
, "unicast"))
379 else if (strmatch(safi_str
, "vpn"))
380 safi
= SAFI_MPLS_VPN
;
381 else if (strmatch(safi_str
, "evpn"))
383 else if (strmatch(safi_str
, "labeled-unicast"))
384 safi
= SAFI_LABELED_UNICAST
;
385 else if (strmatch(safi_str
, "flowspec"))
386 safi
= SAFI_FLOWSPEC
;
390 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
394 if (argv_find(argv
, argc
, "unicast", index
)) {
397 *safi
= SAFI_UNICAST
;
398 } else if (argv_find(argv
, argc
, "multicast", index
)) {
401 *safi
= SAFI_MULTICAST
;
402 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
405 *safi
= SAFI_LABELED_UNICAST
;
406 } else if (argv_find(argv
, argc
, "vpn", index
)) {
409 *safi
= SAFI_MPLS_VPN
;
410 } else if (argv_find(argv
, argc
, "evpn", index
)) {
414 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
417 *safi
= SAFI_FLOWSPEC
;
422 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
423 enum bgp_instance_type inst_type
)
425 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
427 if (ret
== BGP_CREATED
) {
428 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
429 DFLT_BGP_CONNECT_RETRY
);
431 if (DFLT_BGP_IMPORT_CHECK
)
432 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
433 if (DFLT_BGP_SHOW_HOSTNAME
)
434 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
435 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
436 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
437 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
438 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
439 if (DFLT_BGP_DETERMINISTIC_MED
)
440 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
441 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
442 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
450 * bgp_vty_find_and_parse_afi_safi_bgp
452 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
453 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
454 * to appropriate values for the calling function. This is to allow the
455 * calling function to make decisions appropriate for the show command
456 * that is being parsed.
458 * The show commands are generally of the form:
459 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
460 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
462 * Since we use argv_find if the show command in particular doesn't have:
464 * [<view|vrf> VIEWVRFNAME]
465 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
466 * The command parsing should still be ok.
468 * vty -> The vty for the command so we can output some useful data in
469 * the event of a parse error in the vrf.
470 * argv -> The command tokens
471 * argc -> How many command tokens we have
472 * idx -> The current place in the command, generally should be 0 for this
474 * afi -> The parsed afi if it was included in the show command, returned here
475 * safi -> The parsed safi if it was included in the show command, returned here
476 * bgp -> Pointer to the bgp data structure we need to fill in.
477 * use_json -> json is configured or not
479 * The function returns the correct location in the parse tree for the
482 * Returns 0 for failure to parse correctly, else the idx position of where
483 * it found the last token.
485 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
486 struct cmd_token
**argv
, int argc
,
487 int *idx
, afi_t
*afi
, safi_t
*safi
,
488 struct bgp
**bgp
, bool use_json
)
490 char *vrf_name
= NULL
;
496 if (argv_find(argv
, argc
, "ip", idx
))
499 if (argv_find(argv
, argc
, "view", idx
))
500 vrf_name
= argv
[*idx
+ 1]->arg
;
501 else if (argv_find(argv
, argc
, "vrf", idx
)) {
502 vrf_name
= argv
[*idx
+ 1]->arg
;
503 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
507 if (strmatch(vrf_name
, "all"))
510 *bgp
= bgp_lookup_by_name(vrf_name
);
513 json_object
*json
= NULL
;
514 json
= json_object_new_object();
515 json_object_string_add(
517 "View/Vrf is unknown");
519 json_object_to_json_string_ext(json
,
520 JSON_C_TO_STRING_PRETTY
));
521 json_object_free(json
);
524 vty_out(vty
, "View/Vrf %s is unknown\n",
531 *bgp
= bgp_get_default();
534 json_object
*json
= NULL
;
535 json
= json_object_new_object();
536 json_object_string_add(
538 "Default BGP instance not found");
540 json_object_to_json_string_ext(json
,
541 JSON_C_TO_STRING_PRETTY
));
542 json_object_free(json
);
546 "Default BGP instance not found\n");
552 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
553 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
559 static bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
561 struct interface
*ifp
= NULL
;
563 if (su
->sa
.sa_family
== AF_INET
)
564 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
565 else if (su
->sa
.sa_family
== AF_INET6
)
566 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
567 su
->sin6
.sin6_scope_id
,
576 /* Utility function for looking up peer from VTY. */
577 /* This is used only for configuration, so disallow if attempted on
578 * a dynamic neighbor.
580 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
582 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
591 ret
= str2sockunion(ip_str
, &su
);
593 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
595 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
598 "%% Malformed address or name: %s\n",
604 peer
= peer_lookup(bgp
, &su
);
607 "%% Specify remote-as or peer-group commands first\n");
610 if (peer_dynamic_neighbor(peer
)) {
612 "%% Operation not allowed on a dynamic neighbor\n");
619 /* Utility function for looking up peer or peer group. */
620 /* This is used only for configuration, so disallow if attempted on
621 * a dynamic neighbor.
623 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
625 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
628 struct peer
*peer
= NULL
;
629 struct peer_group
*group
= NULL
;
635 ret
= str2sockunion(peer_str
, &su
);
637 /* IP address, locate peer. */
638 peer
= peer_lookup(bgp
, &su
);
640 /* Not IP, could match either peer configured on interface or a
642 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
644 group
= peer_group_lookup(bgp
, peer_str
);
648 if (peer_dynamic_neighbor(peer
)) {
650 "%% Operation not allowed on a dynamic neighbor\n");
660 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
665 int bgp_vty_return(struct vty
*vty
, int ret
)
667 const char *str
= NULL
;
670 case BGP_ERR_INVALID_VALUE
:
671 str
= "Invalid value";
673 case BGP_ERR_INVALID_FLAG
:
674 str
= "Invalid flag";
676 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
677 str
= "Peer-group has been shutdown. Activate the peer-group first";
679 case BGP_ERR_PEER_FLAG_CONFLICT
:
680 str
= "Can't set override-capability and strict-capability-match at the same time";
682 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
683 str
= "Specify remote-as or peer-group remote AS first";
685 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
686 str
= "Cannot change the peer-group. Deconfigure first";
688 case BGP_ERR_PEER_GROUP_MISMATCH
:
689 str
= "Peer is not a member of this peer-group";
691 case BGP_ERR_PEER_FILTER_CONFLICT
:
692 str
= "Prefix/distribute list can not co-exist";
694 case BGP_ERR_NOT_INTERNAL_PEER
:
695 str
= "Invalid command. Not an internal neighbor";
697 case BGP_ERR_REMOVE_PRIVATE_AS
:
698 str
= "remove-private-AS cannot be configured for IBGP peers";
700 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
701 str
= "Local-AS allowed only for EBGP peers";
703 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
704 str
= "Cannot have local-as same as BGP AS number";
706 case BGP_ERR_TCPSIG_FAILED
:
707 str
= "Error while applying TCP-Sig to session(s)";
709 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
710 str
= "ebgp-multihop and ttl-security cannot be configured together";
712 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
713 str
= "ttl-security only allowed for EBGP peers";
715 case BGP_ERR_AS_OVERRIDE
:
716 str
= "as-override cannot be configured for IBGP peers";
718 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
719 str
= "Invalid limit for number of dynamic neighbors";
721 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
722 str
= "Dynamic neighbor listen range already exists";
724 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
725 str
= "Operation not allowed on a dynamic neighbor";
727 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
728 str
= "Operation not allowed on a directly connected neighbor";
730 case BGP_ERR_PEER_SAFI_CONFLICT
:
733 case BGP_ERR_GR_INVALID_CMD
:
734 str
= "The Graceful Restart command used is not valid at this moment.";
736 case BGP_ERR_GR_OPERATION_FAILED
:
737 str
= "The Graceful Restart Operation failed due to an err.";
739 case BGP_GR_NO_OPERATION
:
744 vty_out(vty
, "%% %s\n", str
);
745 return CMD_WARNING_CONFIG_FAILED
;
750 /* BGP clear sort. */
759 static void bgp_clear_vty_error(struct peer
*peer
, afi_t afi
, safi_t safi
,
760 int error
, char *errmsg
, size_t errmsg_len
)
763 case BGP_ERR_AF_UNCONFIGURED
:
764 snprintf(errmsg
, errmsg_len
,
765 "%%BGP: Enable %s address family for the neighbor %s",
766 get_afi_safi_str(afi
, safi
, false), peer
->host
);
768 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
771 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig",
779 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
780 struct listnode
**nnode
, enum bgp_clear_type stype
)
784 /* if afi/.safi not specified, spin thru all of them */
785 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
789 FOREACH_AFI_SAFI (tmp_afi
, tmp_safi
) {
790 if (!peer
->afc
[tmp_afi
][tmp_safi
])
793 if (stype
== BGP_CLEAR_SOFT_NONE
)
794 ret
= peer_clear(peer
, nnode
);
796 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
799 /* if afi specified and safi not, spin thru safis on this afi */
800 } else if (safi
== SAFI_UNSPEC
) {
803 for (tmp_safi
= SAFI_UNICAST
;
804 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
805 if (!peer
->afc
[afi
][tmp_safi
])
808 if (stype
== BGP_CLEAR_SOFT_NONE
)
809 ret
= peer_clear(peer
, nnode
);
811 ret
= peer_clear_soft(peer
, afi
,
814 /* both afi/safi specified, let the caller know if not defined */
816 if (!peer
->afc
[afi
][safi
])
819 if (stype
== BGP_CLEAR_SOFT_NONE
)
820 ret
= peer_clear(peer
, nnode
);
822 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
828 /* `clear ip bgp' functions. */
829 static int bgp_clear(struct bgp
*bgp
, afi_t afi
, safi_t safi
,
830 enum clear_sort sort
, enum bgp_clear_type stype
,
831 const char *arg
, char *errmsg
, size_t errmsg_len
)
837 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
839 /* Clear all neighbors. */
841 * Pass along pointer to next node to peer_clear() when walking all
842 * nodes on the BGP instance as that may get freed if it is a
845 if (sort
== clear_all
) {
846 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
848 bgp_peer_gr_flags_update(peer
);
850 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
851 gr_router_detected
= true;
853 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
857 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
861 if (gr_router_detected
862 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
863 bgp_zebra_send_capabilities(bgp
, false);
864 } else if (!gr_router_detected
865 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
866 bgp_zebra_send_capabilities(bgp
, true);
869 /* This is to apply read-only mode on this clear. */
870 if (stype
== BGP_CLEAR_SOFT_NONE
)
871 bgp
->update_delay_over
= 0;
876 /* Clear specified neighbor. */
877 if (sort
== clear_peer
) {
880 /* Make sockunion for lookup. */
881 ret
= str2sockunion(arg
, &su
);
883 peer
= peer_lookup_by_conf_if(bgp
, arg
);
885 peer
= peer_lookup_by_hostname(bgp
, arg
);
889 "Malformed address or name: %s",
895 peer
= peer_lookup(bgp
, &su
);
897 snprintf(errmsg
, errmsg_len
,
898 "%%BGP: Unknown neighbor - \"%s\"",
904 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
905 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
907 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
909 /* if afi/safi not defined for this peer, let caller know */
911 ret
= BGP_ERR_AF_UNCONFIGURED
;
914 bgp_clear_vty_error(peer
, afi
, safi
, ret
, errmsg
,
920 /* Clear all neighbors belonging to a specific peer-group. */
921 if (sort
== clear_group
) {
922 struct peer_group
*group
;
924 group
= peer_group_lookup(bgp
, arg
);
926 snprintf(errmsg
, errmsg_len
,
927 "%%BGP: No such peer-group %s", arg
);
931 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
932 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
935 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
944 "%%BGP: No %s peer belonging to peer-group %s is configured",
945 get_afi_safi_str(afi
, safi
, false), arg
);
950 /* Clear all external (eBGP) neighbors. */
951 if (sort
== clear_external
) {
952 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
953 if (peer
->sort
== BGP_PEER_IBGP
)
956 bgp_peer_gr_flags_update(peer
);
958 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
959 gr_router_detected
= true;
961 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
964 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
970 if (gr_router_detected
971 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
972 bgp_zebra_send_capabilities(bgp
, false);
973 } else if (!gr_router_detected
974 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
975 bgp_zebra_send_capabilities(bgp
, true);
979 snprintf(errmsg
, errmsg_len
,
980 "%%BGP: No external %s peer is configured",
981 get_afi_safi_str(afi
, safi
, false));
986 /* Clear all neighbors belonging to a specific AS. */
987 if (sort
== clear_as
) {
988 as_t as
= strtoul(arg
, NULL
, 10);
990 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
994 bgp_peer_gr_flags_update(peer
);
996 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
997 gr_router_detected
= true;
999 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
1002 bgp_clear_vty_error(peer
, afi
, safi
, ret
,
1003 errmsg
, errmsg_len
);
1008 if (gr_router_detected
1009 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
1010 bgp_zebra_send_capabilities(bgp
, false);
1011 } else if (!gr_router_detected
1012 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
1013 bgp_zebra_send_capabilities(bgp
, true);
1017 snprintf(errmsg
, errmsg_len
,
1018 "%%BGP: No %s peer is configured with AS %s",
1019 get_afi_safi_str(afi
, safi
, false), arg
);
1027 static int bgp_clear_vty(const char *name
, afi_t afi
, safi_t safi
,
1028 enum clear_sort sort
, enum bgp_clear_type stype
,
1029 const char *arg
, char *errmsg
, size_t errmsg_len
)
1033 /* BGP structure lookup. */
1035 bgp
= bgp_lookup_by_name(name
);
1037 snprintf(errmsg
, errmsg_len
,
1038 "Can't find BGP instance %s", name
);
1042 bgp
= bgp_get_default();
1044 snprintf(errmsg
, errmsg_len
,
1045 "No BGP process is configured");
1050 return bgp_clear(bgp
, afi
, safi
, sort
, stype
, arg
, errmsg
, errmsg_len
);
1053 /* clear soft inbound */
1054 int bgp_clear_star_soft_in(const char *name
, char *errmsg
, size_t errmsg_len
)
1060 FOREACH_AFI_SAFI (afi
, safi
) {
1061 ret
= bgp_clear_vty(name
, afi
, safi
, clear_all
,
1062 BGP_CLEAR_SOFT_IN
, NULL
, errmsg
,
1064 if (ret
!= CMD_SUCCESS
)
1071 /* clear soft outbound */
1072 int bgp_clear_star_soft_out(const char *name
, char *errmsg
, size_t errmsg_len
)
1078 FOREACH_AFI_SAFI (afi
, safi
) {
1079 ret
= bgp_clear_vty(name
, afi
, safi
, clear_all
,
1080 BGP_CLEAR_SOFT_OUT
, NULL
, errmsg
,
1082 if (ret
!= CMD_SUCCESS
)
1090 #ifndef VTYSH_EXTRACT_PL
1091 #include "bgpd/bgp_vty_clippy.c"
1094 DEFUN_HIDDEN (bgp_local_mac
,
1096 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1098 "Local MAC config\n"
1099 "VxLAN Network Identifier\n"
1103 "mac-mobility sequence\n"
1113 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1114 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1115 vty_out(vty
, "%% Malformed MAC address\n");
1118 memset(&ip
, 0, sizeof(ip
));
1119 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1121 bgp
= bgp_get_default();
1123 vty_out(vty
, "Default BGP instance is not there\n");
1127 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1130 vty_out(vty
, "Internal error\n");
1137 DEFUN_HIDDEN (no_bgp_local_mac
,
1138 no_bgp_local_mac_cmd
,
1139 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1142 "Local MAC config\n"
1143 "VxLAN Network Identifier\n"
1154 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1155 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1156 vty_out(vty
, "%% Malformed MAC address\n");
1159 memset(&ip
, 0, sizeof(ip
));
1161 bgp
= bgp_get_default();
1163 vty_out(vty
, "Default BGP instance is not there\n");
1167 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1169 vty_out(vty
, "Internal error\n");
1176 DEFUN (no_synchronization
,
1177 no_synchronization_cmd
,
1178 "no synchronization",
1180 "Perform IGP synchronization\n")
1185 DEFUN (no_auto_summary
,
1186 no_auto_summary_cmd
,
1189 "Enable automatic network number summarization\n")
1194 /* "router bgp" commands. */
1195 DEFUN_YANG_NOSH(router_bgp
,
1197 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1198 ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR
)
1201 int idx_view_vrf
= 3;
1203 int ret
= CMD_SUCCESS
;
1206 const char *name
= NULL
;
1207 char as_str
[12] = {'\0'};
1208 enum bgp_instance_type inst_type
;
1209 char base_xpath
[XPATH_MAXLEN
];
1211 // "router bgp" without an ASN
1213 // Pending: Make VRF option available for ASN less config
1214 bgp
= bgp_get_default();
1217 vty_out(vty
, "%% No BGP process is configured\n");
1218 return CMD_WARNING_CONFIG_FAILED
;
1221 if (listcount(bm
->bgp
) > 1) {
1222 vty_out(vty
, "%% Please specify ASN and VRF\n");
1223 return CMD_WARNING_CONFIG_FAILED
;
1226 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1227 "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME
);
1229 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
1230 snprintf(as_str
, 12, "%d", bgp
->as
);
1231 nb_cli_enqueue_change(vty
, "./global/local-as", NB_OP_MODIFY
,
1233 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
) {
1234 nb_cli_enqueue_change(vty
,
1235 "./global/instance-type-view",
1236 NB_OP_MODIFY
, "true");
1239 nb_cli_pending_commit_check(vty
);
1240 ret
= nb_cli_apply_changes(vty
, base_xpath
);
1241 if (ret
== CMD_SUCCESS
) {
1242 VTY_PUSH_XPATH(BGP_NODE
, base_xpath
);
1245 * For backward compatibility with old commands we still
1246 * need to use the qobj infrastructure.
1248 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1256 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1257 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1259 name
= argv
[idx_vrf
]->arg
;
1261 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1262 if (strmatch(name
, VRF_DEFAULT_NAME
))
1265 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1266 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view")) {
1267 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1270 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1271 "frr-bgp:bgp", "bgp", name
? name
: VRF_DEFAULT_NAME
);
1273 nb_cli_enqueue_change(vty
, ".", NB_OP_CREATE
, NULL
);
1274 nb_cli_enqueue_change(vty
, "./global/local-as", NB_OP_MODIFY
,
1275 argv
[idx_asn
]->arg
);
1276 if (inst_type
== BGP_INSTANCE_TYPE_VIEW
) {
1277 nb_cli_enqueue_change(vty
,
1278 "./global/instance-type-view",
1279 NB_OP_MODIFY
, "true");
1282 nb_cli_pending_commit_check(vty
);
1283 ret
= nb_cli_apply_changes(vty
, base_xpath
);
1284 if (ret
== CMD_SUCCESS
) {
1285 VTY_PUSH_XPATH(BGP_NODE
, base_xpath
);
1288 * For backward compatibility with old commands we still
1289 * need to use the qobj infrastructure.
1291 bgp
= bgp_lookup(as
, name
);
1293 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1300 /* "no router bgp" commands. */
1301 DEFUN_YANG(no_router_bgp
,
1303 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1304 NO_STR ROUTER_STR BGP_STR AS_STR BGP_INSTANCE_HELP_STR
)
1310 const char *name
= NULL
;
1311 char base_xpath
[XPATH_MAXLEN
];
1312 const struct lyd_node
*bgp_glb_dnode
;
1314 // "no router bgp" without an ASN
1316 // Pending: Make VRF option available for ASN less config
1317 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1318 "frr-bgp:bgp", "bgp", VRF_DEFAULT_NAME
);
1320 bgp_glb_dnode
= yang_dnode_get(vty
->candidate_config
->dnode
,
1322 if (!bgp_glb_dnode
) {
1323 vty_out(vty
, "%% No BGP process is configured\n");
1324 return CMD_WARNING_CONFIG_FAILED
;
1327 if (listcount(bm
->bgp
) > 1) {
1328 vty_out(vty
, "%% Please specify ASN and VRF\n");
1329 return CMD_WARNING_CONFIG_FAILED
;
1332 /* tcli mode bgp would not be set until apply stage. */
1333 bgp
= nb_running_get_entry(bgp_glb_dnode
, NULL
, false);
1338 vty_out(vty
, "%% Please unconfigure l3vni %u",
1340 return CMD_WARNING_CONFIG_FAILED
;
1343 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1346 name
= argv
[idx_vrf
]->arg
;
1348 /* Lookup bgp structure. */
1349 bgp
= bgp_lookup(as
, name
);
1351 vty_out(vty
, "%% Can't find BGP instance\n");
1352 return CMD_WARNING_CONFIG_FAILED
;
1356 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1358 return CMD_WARNING_CONFIG_FAILED
;
1361 /* Cannot delete default instance if vrf instances exist */
1362 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1363 struct listnode
*node
;
1364 struct bgp
*tmp_bgp
;
1366 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1367 if (tmp_bgp
->inst_type
1368 == BGP_INSTANCE_TYPE_VRF
) {
1370 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1371 return CMD_WARNING_CONFIG_FAILED
;
1376 snprintf(base_xpath
, sizeof(base_xpath
), FRR_BGP_GLOBAL_XPATH
,
1377 "frr-bgp:bgp", "bgp",
1378 bgp
->name
? bgp
->name
: VRF_DEFAULT_NAME
);
1380 nb_cli_enqueue_change(vty
, ".", NB_OP_DESTROY
, NULL
);
1382 return nb_cli_apply_changes(vty
, base_xpath
);
1385 void cli_show_router_bgp(struct vty
*vty
, struct lyd_node
*dnode
,
1388 const struct lyd_node
*vrf_dnode
;
1389 const char *vrf_name
;
1392 vrf_dnode
= yang_dnode_get_parent(dnode
, "control-plane-protocol");
1393 vrf_name
= yang_dnode_get_string(vrf_dnode
, "./vrf");
1394 as
= yang_dnode_get_uint32(dnode
, "./global/local-as");
1396 vty_out(vty
, "!\n");
1397 vty_out(vty
, "router bgp %u", as
);
1398 if (!strmatch(vrf_name
, VRF_DEFAULT_NAME
))
1399 vty_out(vty
, " vrf %s", vrf_name
);
1403 /* BGP router-id. */
1405 DEFPY_YANG(bgp_router_id
, bgp_router_id_cmd
, "bgp router-id A.B.C.D",
1407 "Override configured router identifier\n"
1408 "Manually configured router identifier\n")
1410 nb_cli_enqueue_change(vty
, "./global/router-id", NB_OP_MODIFY
,
1413 return nb_cli_apply_changes(vty
, NULL
);
1416 DEFPY_YANG(no_bgp_router_id
, no_bgp_router_id_cmd
, "no bgp router-id [A.B.C.D]",
1418 "Override configured router identifier\n"
1419 "Manually configured router identifier\n")
1421 nb_cli_enqueue_change(vty
, "./global/router-id", NB_OP_DESTROY
,
1422 router_id_str
? router_id_str
: NULL
);
1424 return nb_cli_apply_changes(vty
, NULL
);
1427 void cli_show_router_bgp_router_id(struct vty
*vty
, struct lyd_node
*dnode
,
1430 vty_out(vty
, " bgp router-id %s\n", yang_dnode_get_string(dnode
, NULL
));
1433 /* BGP Cluster ID. */
1434 DEFUN_YANG(bgp_cluster_id
,
1436 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1438 "Configure Route-Reflector Cluster-id\n"
1439 "Route-Reflector Cluster-id in IP address format\n"
1440 "Route-Reflector Cluster-id as 32 bit quantity\n")
1444 nb_cli_enqueue_change(
1445 vty
, "./global/route-reflector/route-reflector-cluster-id",
1446 NB_OP_MODIFY
, argv
[idx_ipv4
]->arg
);
1448 return nb_cli_apply_changes(vty
, NULL
);
1451 DEFUN_YANG(no_bgp_cluster_id
,
1452 no_bgp_cluster_id_cmd
,
1453 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1455 "Configure Route-Reflector Cluster-id\n"
1456 "Route-Reflector Cluster-id in IP address format\n"
1457 "Route-Reflector Cluster-id as 32 bit quantity\n")
1459 nb_cli_enqueue_change(
1460 vty
, "./global/route-reflector/route-reflector-cluster-id",
1461 NB_OP_DESTROY
, NULL
);
1463 return nb_cli_apply_changes(vty
, NULL
);
1470 "Disable BGP route installation to RIB (Zebra)\n")
1472 if (bgp_option_check(BGP_OPT_NO_FIB
)) {
1474 "%% No-RIB option is already set, nothing to do here.\n");
1478 bgp_option_norib_set_runtime();
1483 DEFPY (no_bgp_norib
,
1488 "Disable BGP route installation to RIB (Zebra)\n")
1490 if (!bgp_option_check(BGP_OPT_NO_FIB
)) {
1492 "%% No-RIB option is not set, nothing to do here.\n");
1496 bgp_option_norib_unset_runtime();
1501 DEFUN_YANG(bgp_confederation_identifier
,
1502 bgp_confederation_identifier_cmd
,
1503 "bgp confederation identifier (1-4294967295)",
1504 "BGP specific commands\n"
1505 "AS confederation parameters\n"
1507 "Set routing domain confederation AS\n")
1511 nb_cli_enqueue_change(vty
, "./global/confederation/identifier",
1512 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
1514 return nb_cli_apply_changes(vty
, NULL
);
1517 DEFUN_YANG(no_bgp_confederation_identifier
,
1518 no_bgp_confederation_identifier_cmd
,
1519 "no bgp confederation identifier [(1-4294967295)]",
1521 "BGP specific commands\n"
1522 "AS confederation parameters\n"
1524 "Set routing domain confederation AS\n")
1526 nb_cli_enqueue_change(vty
, "./global/confederation/identifier",
1527 NB_OP_DESTROY
, NULL
);
1529 return nb_cli_apply_changes(vty
, NULL
);
1532 void cli_show_router_bgp_confederation_identifier(struct vty
*vty
,
1533 struct lyd_node
*dnode
,
1536 vty_out(vty
, " bgp confederation identifier %u\n",
1537 yang_dnode_get_uint32(dnode
, NULL
));
1540 DEFUN_YANG(bgp_confederation_peers
,
1541 bgp_confederation_peers_cmd
,
1542 "bgp confederation peers (1-4294967295)...",
1543 "BGP specific commands\n"
1544 "AS confederation parameters\n"
1545 "Peer ASs in BGP confederation\n" AS_STR
)
1550 for (i
= idx_asn
; i
< argc
; i
++)
1551 nb_cli_enqueue_change(vty
, "./global/confederation/member-as",
1552 NB_OP_CREATE
, argv
[i
]->arg
);
1554 return nb_cli_apply_changes(vty
, NULL
);
1557 DEFUN_YANG(no_bgp_confederation_peers
,
1558 no_bgp_confederation_peers_cmd
,
1559 "no bgp confederation peers (1-4294967295)...",
1561 "BGP specific commands\n"
1562 "AS confederation parameters\n"
1563 "Peer ASs in BGP confederation\n" AS_STR
)
1568 for (i
= idx_asn
; i
< argc
; i
++)
1569 nb_cli_enqueue_change(vty
, "./global/confederation/member-as",
1570 NB_OP_DESTROY
, argv
[i
]->arg
);
1572 return nb_cli_apply_changes(vty
, NULL
);
1575 void cli_show_router_bgp_confederation_member_as(struct vty
*vty
,
1576 struct lyd_node
*dnode
,
1579 vty_out(vty
, " bgp confederation peers %u \n",
1580 yang_dnode_get_uint32(dnode
, NULL
));
1584 * Central routine for maximum-paths configuration.
1585 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1586 * @set: 1 for setting values, 0 for removing the max-paths config.
1588 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1589 const char *mpaths
, uint16_t options
,
1592 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1593 uint16_t maxpaths
= 0;
1598 afi
= bgp_node_afi(vty
);
1599 safi
= bgp_node_safi(vty
);
1602 maxpaths
= strtol(mpaths
, NULL
, 10);
1603 if (maxpaths
> multipath_num
) {
1605 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1606 maxpaths
, multipath_num
);
1607 return CMD_WARNING_CONFIG_FAILED
;
1609 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1612 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1616 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1617 (set
== 1) ? "" : "un",
1618 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1619 maxpaths
, afi
, safi
);
1620 return CMD_WARNING_CONFIG_FAILED
;
1623 bgp_recalculate_all_bestpaths(bgp
);
1628 void cli_show_router_bgp_med_config(struct vty
*vty
, struct lyd_node
*dnode
,
1631 if (yang_dnode_get_bool(dnode
, "./enable-med-admin")) {
1632 uint32_t med_admin_val
;
1634 vty_out(vty
, " bgp max-med administrative");
1635 if ((med_admin_val
=
1636 yang_dnode_get_uint32(dnode
, "./max-med-admin"))
1637 != BGP_MAXMED_VALUE_DEFAULT
)
1638 vty_out(vty
, " %u", med_admin_val
);
1642 if (yang_dnode_exists(dnode
, "./max-med-onstart-up-time")) {
1643 uint32_t onstartup_val
;
1645 vty_out(vty
, " bgp max-med on-startup %u",
1646 yang_dnode_get_uint32(dnode
,
1647 "./max-med-onstart-up-time"));
1648 onstartup_val
= yang_dnode_get_uint32(
1649 dnode
, "./max-med-onstart-up-value");
1650 if (onstartup_val
!= BGP_MAXMED_VALUE_DEFAULT
)
1651 vty_out(vty
, " %u", onstartup_val
);
1657 DEFUN_YANG(bgp_maxmed_admin
,
1658 bgp_maxmed_admin_cmd
,
1659 "bgp max-med administrative ",
1661 "Advertise routes with max-med\n"
1662 "Administratively applied, for an indefinite period\n")
1664 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1665 NB_OP_MODIFY
, "true");
1667 return nb_cli_apply_changes(vty
, NULL
);
1670 DEFUN_YANG(bgp_maxmed_admin_medv
,
1671 bgp_maxmed_admin_medv_cmd
,
1672 "bgp max-med administrative (0-4294967295)",
1674 "Advertise routes with max-med\n"
1675 "Administratively applied, for an indefinite period\n"
1676 "Max MED value to be used\n")
1680 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1681 NB_OP_MODIFY
, "true");
1683 nb_cli_enqueue_change(vty
, "./global/med-config/max-med-admin",
1684 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
1686 return nb_cli_apply_changes(vty
, NULL
);
1689 DEFUN_YANG(no_bgp_maxmed_admin
,
1690 no_bgp_maxmed_admin_cmd
,
1691 "no bgp max-med administrative [(0-4294967295)]",
1693 "Advertise routes with max-med\n"
1694 "Administratively applied, for an indefinite period\n"
1695 "Max MED value to be used\n")
1697 nb_cli_enqueue_change(vty
, "./global/med-config/enable-med-admin",
1698 NB_OP_MODIFY
, "false");
1700 nb_cli_enqueue_change(vty
, "./global/med-config/max-med-admin",
1701 NB_OP_MODIFY
, NULL
);
1703 return nb_cli_apply_changes(vty
, NULL
);
1706 DEFUN_YANG(bgp_maxmed_onstartup
,
1707 bgp_maxmed_onstartup_cmd
,
1708 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1710 "Advertise routes with max-med\n"
1711 "Effective on a startup\n"
1712 "Time (seconds) period for max-med\n"
1713 "Max MED value to be used\n")
1717 argv_find(argv
, argc
, "(5-86400)", &idx
);
1718 nb_cli_enqueue_change(vty
,
1719 "./global/med-config/max-med-onstart-up-time",
1720 NB_OP_MODIFY
, argv
[idx
]->arg
);
1722 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1723 nb_cli_enqueue_change(
1724 vty
, "./global/med-config/max-med-onstart-up-value",
1725 NB_OP_MODIFY
, argv
[idx
]->arg
);
1727 nb_cli_enqueue_change(
1728 vty
, "./global/med-config/max-med-onstart-up-value",
1729 NB_OP_MODIFY
, NULL
);
1731 return nb_cli_apply_changes(vty
, NULL
);
1734 DEFUN_YANG(no_bgp_maxmed_onstartup
,
1735 no_bgp_maxmed_onstartup_cmd
,
1736 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1738 "Advertise routes with max-med\n"
1739 "Effective on a startup\n"
1740 "Time (seconds) period for max-med\n"
1741 "Max MED value to be used\n")
1743 nb_cli_enqueue_change(vty
,
1744 "./global/med-config/max-med-onstart-up-time",
1745 NB_OP_DESTROY
, NULL
);
1747 nb_cli_enqueue_change(vty
,
1748 "./global/med-config/max-med-onstart-up-value",
1749 NB_OP_MODIFY
, NULL
);
1751 return nb_cli_apply_changes(vty
, NULL
);
1754 static int bgp_global_update_delay_config_vty(struct vty
*vty
,
1755 uint16_t update_delay
,
1756 uint16_t establish_wait
)
1758 struct listnode
*node
, *nnode
;
1760 bool vrf_cfg
= false;
1763 * See if update-delay is set per-vrf and warn user to delete it
1764 * Note that we only need to check this if this is the first time
1765 * setting the global config.
1767 if (bm
->v_update_delay
== BGP_UPDATE_DELAY_DEF
) {
1768 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1769 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1771 "%% update-delay configuration found in vrf %s\n",
1772 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
1782 "%%Failed: global update-delay config not permitted\n");
1786 if (!establish_wait
) { /* update-delay <delay> */
1787 bm
->v_update_delay
= update_delay
;
1788 bm
->v_establish_wait
= bm
->v_update_delay
;
1790 /* update-delay <delay> <establish-wait> */
1791 if (update_delay
< establish_wait
) {
1793 "%%Failed: update-delay less than the establish-wait!\n");
1794 return CMD_WARNING_CONFIG_FAILED
;
1797 bm
->v_update_delay
= update_delay
;
1798 bm
->v_establish_wait
= establish_wait
;
1801 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1802 bgp
->v_update_delay
= bm
->v_update_delay
;
1803 bgp
->v_establish_wait
= bm
->v_establish_wait
;
1809 static int bgp_global_update_delay_deconfig_vty(struct vty
*vty
)
1811 struct listnode
*node
, *nnode
;
1814 bm
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1815 bm
->v_establish_wait
= bm
->v_update_delay
;
1817 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
1818 bgp
->v_update_delay
= bm
->v_update_delay
;
1819 bgp
->v_establish_wait
= bm
->v_establish_wait
;
1825 static int bgp_update_delay_config_vty(struct vty
*vty
, uint16_t update_delay
,
1826 uint16_t establish_wait
)
1828 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1830 /* if configured globally, per-instance config is not allowed */
1831 if (bm
->v_update_delay
) {
1833 "%%Failed: per-vrf update-delay config not permitted with global update-delay\n");
1834 return CMD_WARNING_CONFIG_FAILED
;
1838 if (!establish_wait
) /* update-delay <delay> */
1840 bgp
->v_update_delay
= update_delay
;
1841 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1845 /* update-delay <delay> <establish-wait> */
1846 if (update_delay
< establish_wait
) {
1848 "%%Failed: update-delay less than the establish-wait!\n");
1849 return CMD_WARNING_CONFIG_FAILED
;
1852 bgp
->v_update_delay
= update_delay
;
1853 bgp
->v_establish_wait
= establish_wait
;
1858 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1860 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1862 /* If configured globally, cannot remove from one bgp instance */
1863 if (bm
->v_update_delay
) {
1865 "%%Failed: bgp update-delay configured globally. Delete per-vrf not permitted\n");
1866 return CMD_WARNING_CONFIG_FAILED
;
1868 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1869 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1874 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1876 /* If configured globally, no need to display per-instance value */
1877 if (bgp
->v_update_delay
!= bm
->v_update_delay
) {
1878 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1879 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1880 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1885 /* Global update-delay configuration */
1886 DEFPY (bgp_global_update_delay
,
1887 bgp_global_update_delay_cmd
,
1888 "bgp update-delay (0-3600)$delay [(1-3600)$wait]",
1890 "Force initial delay for best-path and updates for all bgp instances\n"
1891 "Max delay in seconds\n"
1892 "Establish wait in seconds\n")
1894 return bgp_global_update_delay_config_vty(vty
, delay
, wait
);
1897 /* Global update-delay deconfiguration */
1898 DEFPY (no_bgp_global_update_delay
,
1899 no_bgp_global_update_delay_cmd
,
1900 "no bgp update-delay [(0-3600) [(1-3600)]]",
1903 "Force initial delay for best-path and updates\n"
1904 "Max delay in seconds\n"
1905 "Establish wait in seconds\n")
1907 return bgp_global_update_delay_deconfig_vty(vty
);
1910 /* Update-delay configuration */
1912 DEFPY (bgp_update_delay
,
1913 bgp_update_delay_cmd
,
1914 "update-delay (0-3600)$delay [(1-3600)$wait]",
1915 "Force initial delay for best-path and updates\n"
1916 "Max delay in seconds\n"
1917 "Establish wait in seconds\n")
1919 return bgp_update_delay_config_vty(vty
, delay
, wait
);
1922 /* Update-delay deconfiguration */
1923 DEFPY (no_bgp_update_delay
,
1924 no_bgp_update_delay_cmd
,
1925 "no update-delay [(0-3600) [(1-3600)]]",
1927 "Force initial delay for best-path and updates\n"
1928 "Max delay in seconds\n"
1929 "Establish wait in seconds\n")
1931 return bgp_update_delay_deconfig_vty(vty
);
1935 int bgp_wpkt_quanta_config_vty(struct bgp
*bgp
, uint32_t quanta
, bool set
)
1937 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
1938 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
1943 int bgp_rpkt_quanta_config_vty(struct bgp
*bgp
, uint32_t quanta
, bool set
)
1945 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
1946 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
1951 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1954 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1955 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1956 vty_out(vty
, " write-quanta %d\n", quanta
);
1959 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1962 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1963 if (quanta
!= BGP_READ_PACKET_MAX
)
1964 vty_out(vty
, " read-quanta %d\n", quanta
);
1967 /* Packet quanta configuration
1969 * XXX: The value set here controls the size of a stack buffer in the IO
1970 * thread. When changing these limits be careful to prevent stack overflow.
1972 * Furthermore, the maximums used here should correspond to
1973 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
1975 DEFPY_YANG(bgp_wpkt_quanta
,
1976 bgp_wpkt_quanta_cmd
,
1977 "[no] write-quanta (1-64)$quanta",
1979 "How many packets to write to peer socket per run\n"
1980 "Number of packets\n")
1983 nb_cli_enqueue_change(
1985 "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta",
1986 NB_OP_MODIFY
, quanta_str
);
1988 nb_cli_enqueue_change(
1990 "./global/global-neighbor-config/packet-quanta-config/wpkt-quanta",
1991 NB_OP_MODIFY
, NULL
);
1993 return nb_cli_apply_changes(vty
, NULL
);
1996 DEFPY_YANG(bgp_rpkt_quanta
,
1997 bgp_rpkt_quanta_cmd
,
1998 "[no] read-quanta (1-10)$quanta",
2000 "How many packets to read from peer socket per I/O cycle\n"
2001 "Number of packets\n")
2004 nb_cli_enqueue_change(
2006 "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta",
2007 NB_OP_MODIFY
, quanta_str
);
2009 nb_cli_enqueue_change(
2011 "./global/global-neighbor-config/packet-quanta-config/rpkt-quanta",
2012 NB_OP_MODIFY
, NULL
);
2014 return nb_cli_apply_changes(vty
, NULL
);
2017 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
2019 if (!bgp
->heuristic_coalesce
)
2020 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
2023 void cli_show_router_global_update_group_config_coalesce_time(
2024 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
2026 vty_out(vty
, " coalesce-time %u\n", yang_dnode_get_uint32(dnode
, NULL
));
2030 DEFUN_YANG(bgp_coalesce_time
,
2031 bgp_coalesce_time_cmd
,
2032 "coalesce-time (0-4294967295)",
2033 "Subgroup coalesce timer\n"
2034 "Subgroup coalesce timer value (in ms)\n")
2038 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
2039 nb_cli_enqueue_change(
2040 vty
, "./global/global-update-group-config/coalesce-time",
2041 NB_OP_MODIFY
, argv
[idx
]->arg
);
2043 return nb_cli_apply_changes(vty
, NULL
);
2046 DEFUN_YANG(no_bgp_coalesce_time
,
2047 no_bgp_coalesce_time_cmd
,
2048 "no coalesce-time (0-4294967295)",
2050 "Subgroup coalesce timer\n"
2051 "Subgroup coalesce timer value (in ms)\n")
2053 nb_cli_enqueue_change(
2054 vty
, "./global/global-update-group-config/coalesce-time",
2055 NB_OP_MODIFY
, NULL
);
2057 return nb_cli_apply_changes(vty
, NULL
);
2060 /* Maximum-paths configuration */
2061 DEFUN (bgp_maxpaths
,
2063 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2064 "Forward packets over multiple paths\n"
2065 "Number of paths\n")
2068 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
2069 argv
[idx_number
]->arg
, 0, 1);
2072 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
2073 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2074 "Forward packets over multiple paths\n"
2075 "Number of paths\n")
2077 DEFUN (bgp_maxpaths_ibgp
,
2078 bgp_maxpaths_ibgp_cmd
,
2079 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2080 "Forward packets over multiple paths\n"
2082 "Number of paths\n")
2085 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
2086 argv
[idx_number
]->arg
, 0, 1);
2089 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
2090 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
2091 "Forward packets over multiple paths\n"
2093 "Number of paths\n")
2095 DEFUN (bgp_maxpaths_ibgp_cluster
,
2096 bgp_maxpaths_ibgp_cluster_cmd
,
2097 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
2098 "Forward packets over multiple paths\n"
2101 "Match the cluster length\n")
2104 return bgp_maxpaths_config_vty(
2105 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
2106 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
2109 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
2110 "maximum-paths ibgp " CMD_RANGE_STR(
2111 1, MULTIPATH_NUM
) " equal-cluster-length",
2112 "Forward packets over multiple paths\n"
2115 "Match the cluster length\n")
2117 DEFUN (no_bgp_maxpaths
,
2118 no_bgp_maxpaths_cmd
,
2119 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
2121 "Forward packets over multiple paths\n"
2122 "Number of paths\n")
2124 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
2127 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
2128 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
2129 "Forward packets over multiple paths\n"
2130 "Number of paths\n")
2132 DEFUN (no_bgp_maxpaths_ibgp
,
2133 no_bgp_maxpaths_ibgp_cmd
,
2134 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2136 "Forward packets over multiple paths\n"
2139 "Match the cluster length\n")
2141 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
2144 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
2145 "no maximum-paths ibgp [" CMD_RANGE_STR(
2146 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
2148 "Forward packets over multiple paths\n"
2151 "Match the cluster length\n")
2153 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
2154 afi_t afi
, safi_t safi
)
2156 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
2157 vty_out(vty
, " maximum-paths %d\n",
2158 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
2161 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
2162 vty_out(vty
, " maximum-paths ibgp %d",
2163 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
2164 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
2165 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
2166 vty_out(vty
, " equal-cluster-length");
2173 DEFUN_YANG(bgp_timers
,
2175 "timers bgp (0-65535) (0-65535)",
2176 "Adjust routing timers\n"
2178 "Keepalive interval\n"
2182 int idx_number_2
= 3;
2184 nb_cli_enqueue_change(vty
, "./global/global-config-timers/keepalive",
2185 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
2186 nb_cli_enqueue_change(vty
, "./global/global-config-timers/hold-time",
2187 NB_OP_MODIFY
, argv
[idx_number_2
]->arg
);
2189 return nb_cli_apply_changes(vty
, NULL
);
2192 DEFUN_YANG(no_bgp_timers
,
2194 "no timers bgp [(0-65535) (0-65535)]",
2196 "Adjust routing timers\n"
2198 "Keepalive interval\n"
2201 nb_cli_enqueue_change(vty
, "./global/global-config-timers/keepalive",
2202 NB_OP_DESTROY
, NULL
);
2203 nb_cli_enqueue_change(vty
, "./global/global-config-timers/hold-time",
2204 NB_OP_DESTROY
, NULL
);
2206 return nb_cli_apply_changes(vty
, NULL
);
2209 void cli_show_router_bgp_route_reflector(struct vty
*vty
,
2210 struct lyd_node
*dnode
,
2213 if (yang_dnode_get_bool(dnode
, "./no-client-reflect"))
2214 vty_out(vty
, " no bgp client-to-client reflection\n");
2216 if (yang_dnode_get_bool(dnode
, "./allow-outbound-policy"))
2217 vty_out(vty
, " bgp route-reflector allow-outbound-policy\n");
2219 if (yang_dnode_exists(dnode
, "./route-reflector-cluster-id"))
2220 vty_out(vty
, " bgp cluster-id %s\n",
2221 yang_dnode_get_string(dnode
,
2222 "./route-reflector-cluster-id"));
2225 DEFUN_YANG(bgp_client_to_client_reflection
,
2226 bgp_client_to_client_reflection_cmd
,
2227 "bgp client-to-client reflection",
2228 "BGP specific commands\n"
2229 "Configure client to client route reflection\n"
2230 "reflection of routes allowed\n")
2232 nb_cli_enqueue_change(vty
, "./global/route-reflector/no-client-reflect",
2233 NB_OP_MODIFY
, "false");
2235 return nb_cli_apply_changes(vty
, NULL
);
2238 DEFUN_YANG(no_bgp_client_to_client_reflection
,
2239 no_bgp_client_to_client_reflection_cmd
,
2240 "no bgp client-to-client reflection",
2242 "BGP specific commands\n"
2243 "Configure client to client route reflection\n"
2244 "reflection of routes allowed\n")
2246 nb_cli_enqueue_change(vty
, "./global/route-reflector/no-client-reflect",
2247 NB_OP_MODIFY
, "true");
2249 return nb_cli_apply_changes(vty
, NULL
);
2252 void cli_show_router_bgp_route_selection(struct vty
*vty
,
2253 struct lyd_node
*dnode
,
2257 if (yang_dnode_get_bool(dnode
, "./always-compare-med"))
2258 vty_out(vty
, " bgp always-compare-med\n");
2260 if (yang_dnode_get_bool(dnode
, "./ignore-as-path-length"))
2261 vty_out(vty
, " bgp bestpath as-path ignore\n");
2263 if (yang_dnode_get_bool(dnode
, "./aspath-confed"))
2264 vty_out(vty
, " bgp bestpath as-path confed\n");
2266 if (yang_dnode_get_bool(dnode
, "./external-compare-router-id"))
2267 vty_out(vty
, " bgp bestpath compare-routerid\n");
2269 if (yang_dnode_get_bool(dnode
, "./allow-multiple-as")) {
2270 if (yang_dnode_get_bool(dnode
, "./multi-path-as-set"))
2272 " bgp bestpath as-path multipath-relax as-set\n");
2274 vty_out(vty
, " bgp bestpath as-path multipath-relax\n");
2277 if (yang_dnode_get_bool(dnode
, "./deterministic-med"))
2278 vty_out(vty
, " bgp deterministic-med\n");
2280 if (yang_dnode_get_bool(dnode
, "./confed-med")
2281 || yang_dnode_get_bool(dnode
, "./missing-as-worst-med")) {
2282 vty_out(vty
, " bgp bestpath med");
2283 if (yang_dnode_get_bool(dnode
, "./confed-med"))
2284 vty_out(vty
, " confed");
2285 if (yang_dnode_get_bool(dnode
, "./missing-as-worst-med"))
2286 vty_out(vty
, " missing-as-worst");
2291 /* "bgp always-compare-med" configuration. */
2292 DEFUN_YANG(bgp_always_compare_med
,
2293 bgp_always_compare_med_cmd
,
2294 "bgp always-compare-med",
2295 "BGP specific commands\n"
2296 "Allow comparing MED from different neighbors\n")
2298 nb_cli_enqueue_change(
2299 vty
, "./global/route-selection-options/always-compare-med",
2300 NB_OP_MODIFY
, "true");
2302 return nb_cli_apply_changes(vty
, NULL
);
2305 DEFUN_YANG(no_bgp_always_compare_med
,
2306 no_bgp_always_compare_med_cmd
,
2307 "no bgp always-compare-med",
2309 "BGP specific commands\n"
2310 "Allow comparing MED from different neighbors\n")
2312 nb_cli_enqueue_change(
2313 vty
, "./global/route-selection-options/always-compare-med",
2314 NB_OP_MODIFY
, "false");
2316 return nb_cli_apply_changes(vty
, NULL
);
2319 DEFUN_YANG(bgp_ebgp_requires_policy
,
2320 bgp_ebgp_requires_policy_cmd
,
2321 "bgp ebgp-requires-policy",
2322 "BGP specific commands\n"
2323 "Require in and out policy for eBGP peers (RFC8212)\n")
2325 nb_cli_enqueue_change(vty
, "./global/ebgp-requires-policy",
2326 NB_OP_MODIFY
, "true");
2327 return nb_cli_apply_changes(vty
, NULL
);
2330 DEFUN_YANG(no_bgp_ebgp_requires_policy
,
2331 no_bgp_ebgp_requires_policy_cmd
,
2332 "no bgp ebgp-requires-policy",
2334 "BGP specific commands\n"
2335 "Require in and out policy for eBGP peers (RFC8212)\n")
2337 nb_cli_enqueue_change(vty
, "./global/ebgp-requires-policy",
2338 NB_OP_MODIFY
, "false");
2339 return nb_cli_apply_changes(vty
, NULL
);
2342 void cli_show_router_bgp_ebgp_requires_policy(struct vty
*vty
,
2343 struct lyd_node
*dnode
,
2346 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_EBGP_REQUIRES_POLICY
)
2347 vty_out(vty
, " bgp ebgp-requires-policy\n");
2350 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2351 "bgp reject-as-sets",
2352 "BGP specific commands\n"
2353 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2355 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2356 struct listnode
*node
, *nnode
;
2359 bgp
->reject_as_sets
= true;
2361 /* Reset existing BGP sessions to reject routes
2362 * with aspath containing AS_SET or AS_CONFED_SET.
2364 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2365 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2366 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2367 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2368 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2375 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2376 "no bgp reject-as-sets",
2378 "BGP specific commands\n"
2379 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2381 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2382 struct listnode
*node
, *nnode
;
2385 bgp
->reject_as_sets
= false;
2387 /* Reset existing BGP sessions to reject routes
2388 * with aspath containing AS_SET or AS_CONFED_SET.
2390 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2391 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2392 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2393 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2394 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2401 /* "bgp deterministic-med" configuration. */
2402 DEFUN_YANG (bgp_deterministic_med
,
2403 bgp_deterministic_med_cmd
,
2404 "bgp deterministic-med",
2405 "BGP specific commands\n"
2406 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2408 nb_cli_enqueue_change(
2409 vty
, "./global/route-selection-options/deterministic-med",
2410 NB_OP_MODIFY
, "true");
2412 return nb_cli_apply_changes(vty
, NULL
);
2415 DEFUN_YANG (no_bgp_deterministic_med
,
2416 no_bgp_deterministic_med_cmd
,
2417 "no bgp deterministic-med",
2419 "BGP specific commands\n"
2420 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2422 nb_cli_enqueue_change(
2423 vty
, "./global/route-selection-options/deterministic-med",
2424 NB_OP_MODIFY
, "false");
2426 return nb_cli_apply_changes(vty
, NULL
);
2429 /* "bgp graceful-restart mode" configuration. */
2430 DEFUN (bgp_graceful_restart
,
2431 bgp_graceful_restart_cmd
,
2432 "bgp graceful-restart",
2433 "BGP specific commands\n"
2437 int ret
= BGP_GR_FAILURE
;
2439 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2440 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2442 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2444 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2446 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2449 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2450 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2452 "Graceful restart configuration changed, reset all peers to take effect\n");
2453 return bgp_vty_return(vty
, ret
);
2456 DEFUN (no_bgp_graceful_restart
,
2457 no_bgp_graceful_restart_cmd
,
2458 "no bgp graceful-restart",
2460 "BGP specific commands\n"
2464 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2466 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2467 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2469 int ret
= BGP_GR_FAILURE
;
2471 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2473 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2476 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2477 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2479 "Graceful restart configuration changed, reset all peers to take effect\n");
2481 return bgp_vty_return(vty
, ret
);
2484 DEFUN (bgp_graceful_restart_stalepath_time
,
2485 bgp_graceful_restart_stalepath_time_cmd
,
2486 "bgp graceful-restart stalepath-time (1-4095)",
2487 "BGP specific commands\n"
2488 "Graceful restart capability parameters\n"
2489 "Set the max time to hold onto restarting peer's stale paths\n"
2490 "Delay value (seconds)\n")
2492 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2496 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2497 bgp
->stalepath_time
= stalepath
;
2501 DEFUN (bgp_graceful_restart_restart_time
,
2502 bgp_graceful_restart_restart_time_cmd
,
2503 "bgp graceful-restart restart-time (1-4095)",
2504 "BGP specific commands\n"
2505 "Graceful restart capability parameters\n"
2506 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2507 "Delay value (seconds)\n")
2509 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2513 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2514 bgp
->restart_time
= restart
;
2518 DEFUN (bgp_graceful_restart_select_defer_time
,
2519 bgp_graceful_restart_select_defer_time_cmd
,
2520 "bgp graceful-restart select-defer-time (0-3600)",
2521 "BGP specific commands\n"
2522 "Graceful restart capability parameters\n"
2523 "Set the time to defer the BGP route selection after restart\n"
2524 "Delay value (seconds, 0 - disable)\n")
2526 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2528 uint32_t defer_time
;
2530 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2531 bgp
->select_defer_time
= defer_time
;
2532 if (defer_time
== 0)
2533 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2535 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2540 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2541 no_bgp_graceful_restart_stalepath_time_cmd
,
2542 "no bgp graceful-restart stalepath-time [(1-4095)]",
2544 "BGP specific commands\n"
2545 "Graceful restart capability parameters\n"
2546 "Set the max time to hold onto restarting peer's stale paths\n"
2547 "Delay value (seconds)\n")
2549 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2551 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2555 DEFUN (no_bgp_graceful_restart_restart_time
,
2556 no_bgp_graceful_restart_restart_time_cmd
,
2557 "no bgp graceful-restart restart-time [(1-4095)]",
2559 "BGP specific commands\n"
2560 "Graceful restart capability parameters\n"
2561 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2562 "Delay value (seconds)\n")
2564 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2566 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2570 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2571 no_bgp_graceful_restart_select_defer_time_cmd
,
2572 "no bgp graceful-restart select-defer-time [(0-3600)]",
2574 "BGP specific commands\n"
2575 "Graceful restart capability parameters\n"
2576 "Set the time to defer the BGP route selection after restart\n"
2577 "Delay value (seconds)\n")
2579 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2581 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2582 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2587 DEFUN (bgp_graceful_restart_preserve_fw
,
2588 bgp_graceful_restart_preserve_fw_cmd
,
2589 "bgp graceful-restart preserve-fw-state",
2590 "BGP specific commands\n"
2591 "Graceful restart capability parameters\n"
2592 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2594 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2595 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2599 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2600 no_bgp_graceful_restart_preserve_fw_cmd
,
2601 "no bgp graceful-restart preserve-fw-state",
2603 "BGP specific commands\n"
2604 "Graceful restart capability parameters\n"
2605 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2607 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2608 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2612 DEFUN (bgp_graceful_restart_disable
,
2613 bgp_graceful_restart_disable_cmd
,
2614 "bgp graceful-restart-disable",
2615 "BGP specific commands\n"
2618 int ret
= BGP_GR_FAILURE
;
2620 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2622 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
2624 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2626 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
2628 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
2631 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2633 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
2635 "Graceful restart configuration changed, reset all peers to take effect\n");
2637 return bgp_vty_return(vty
, ret
);
2640 DEFUN (no_bgp_graceful_restart_disable
,
2641 no_bgp_graceful_restart_disable_cmd
,
2642 "no bgp graceful-restart-disable",
2644 "BGP specific commands\n"
2648 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2650 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2652 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
2654 int ret
= BGP_GR_FAILURE
;
2656 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
2658 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2661 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2663 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
2665 "Graceful restart configuration changed, reset all peers to take effect\n");
2667 return bgp_vty_return(vty
, ret
);
2670 DEFUN (bgp_neighbor_graceful_restart_set
,
2671 bgp_neighbor_graceful_restart_set_cmd
,
2672 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
2680 int ret
= BGP_GR_FAILURE
;
2682 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2684 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2686 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
2688 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2690 return CMD_WARNING_CONFIG_FAILED
;
2692 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
2694 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2695 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2697 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2699 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
2701 "Graceful restart configuration changed, reset this peer to take effect\n");
2703 return bgp_vty_return(vty
, ret
);
2706 DEFUN (no_bgp_neighbor_graceful_restart
,
2707 no_bgp_neighbor_graceful_restart_set_cmd
,
2708 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
2716 int ret
= BGP_GR_FAILURE
;
2719 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2721 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2723 return CMD_WARNING_CONFIG_FAILED
;
2725 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2727 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
2729 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
2731 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2732 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2734 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2736 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
2738 "Graceful restart configuration changed, reset this peer to take effect\n");
2740 return bgp_vty_return(vty
, ret
);
2743 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
2744 bgp_neighbor_graceful_restart_helper_set_cmd
,
2745 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
2748 GR_NEIGHBOR_HELPER_CMD
2753 int ret
= BGP_GR_FAILURE
;
2755 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2757 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2759 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
2761 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2764 return CMD_WARNING_CONFIG_FAILED
;
2767 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
2769 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2770 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2772 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2774 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
2776 "Graceful restart configuration changed, reset this peer to take effect\n");
2778 return bgp_vty_return(vty
, ret
);
2781 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
2782 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
2783 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
2787 NO_GR_NEIGHBOR_HELPER_CMD
2791 int ret
= BGP_GR_FAILURE
;
2794 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2796 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2798 return CMD_WARNING_CONFIG_FAILED
;
2800 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2802 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
2804 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
2806 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2807 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2809 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2811 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
2813 "Graceful restart configuration changed, reset this peer to take effect\n");
2815 return bgp_vty_return(vty
, ret
);
2818 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
2819 bgp_neighbor_graceful_restart_disable_set_cmd
,
2820 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
2823 GR_NEIGHBOR_DISABLE_CMD
2828 int ret
= BGP_GR_FAILURE
;
2830 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2832 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2834 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
2836 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2838 return CMD_WARNING_CONFIG_FAILED
;
2840 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
2842 if (peer
->bgp
->t_startup
)
2843 bgp_peer_gr_flags_update(peer
);
2845 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2846 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2848 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2850 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
2852 "Graceful restart configuration changed, reset this peer to take effect\n");
2854 return bgp_vty_return(vty
, ret
);
2857 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
2858 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
2859 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
2863 NO_GR_NEIGHBOR_DISABLE_CMD
2867 int ret
= BGP_GR_FAILURE
;
2870 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2872 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2874 return CMD_WARNING_CONFIG_FAILED
;
2876 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2878 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
2880 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
2882 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2883 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2885 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2887 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
2889 "Graceful restart configuration changed, reset this peer to take effect\n");
2891 return bgp_vty_return(vty
, ret
);
2894 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
2895 bgp_graceful_restart_disable_eor_cmd
,
2896 "bgp graceful-restart disable-eor",
2897 "BGP specific commands\n"
2898 "Graceful restart configuration parameters\n"
2899 "Disable EOR Check\n")
2901 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2902 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
2907 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
2908 no_bgp_graceful_restart_disable_eor_cmd
,
2909 "no bgp graceful-restart disable-eor",
2911 "BGP specific commands\n"
2912 "Graceful restart configuration parameters\n"
2913 "Disable EOR Check\n")
2915 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2916 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
2921 DEFUN (bgp_graceful_restart_rib_stale_time
,
2922 bgp_graceful_restart_rib_stale_time_cmd
,
2923 "bgp graceful-restart rib-stale-time (1-3600)",
2924 "BGP specific commands\n"
2925 "Graceful restart configuration parameters\n"
2926 "Specify the stale route removal timer in rib\n"
2927 "Delay value (seconds)\n")
2929 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2931 uint32_t stale_time
;
2933 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2934 bgp
->rib_stale_time
= stale_time
;
2935 /* Send the stale timer update message to RIB */
2936 if (bgp_zebra_stale_timer_update(bgp
))
2942 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
2943 no_bgp_graceful_restart_rib_stale_time_cmd
,
2944 "no bgp graceful-restart rib-stale-time [(1-3600)]",
2946 "BGP specific commands\n"
2947 "Graceful restart configuration parameters\n"
2948 "Specify the stale route removal timer in rib\n"
2949 "Delay value (seconds)\n")
2951 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2953 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
2954 /* Send the stale timer update message to RIB */
2955 if (bgp_zebra_stale_timer_update(bgp
))
2961 static inline int bgp_initiate_graceful_shut_unshut(struct bgp
*bgp
,
2965 bgp_static_redo_import_check(bgp
);
2966 bgp_redistribute_redo(bgp
);
2967 if (bgp_clear_star_soft_out(bgp
->name
, errmsg
, errmsg_len
) < 0)
2969 if (bgp_clear_star_soft_in(bgp
->name
, errmsg
, errmsg_len
) < 0)
2975 static int bgp_global_graceful_shutdown_config_vty(struct vty
*vty
)
2977 struct listnode
*node
, *nnode
;
2979 bool vrf_cfg
= false;
2980 char errmsg
[BUFSIZ
] = {'\0'};
2982 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
2985 /* See if graceful-shutdown is set per-vrf and warn user to delete */
2986 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
2987 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2989 "%% graceful-shutdown configuration found in vrf %s\n",
2990 bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
?
2991 VRF_DEFAULT_NAME
: bgp
->name
);
2998 "%%Failed: global graceful-shutdown not permitted\n");
3002 /* Set flag globally */
3003 SET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3005 /* Initiate processing for all BGP instances. */
3006 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3007 if (bgp_initiate_graceful_shut_unshut(bgp
, errmsg
,
3011 vty_out(vty
, "%s\n", errmsg
);
3017 static int bgp_global_graceful_shutdown_deconfig_vty(struct vty
*vty
)
3019 struct listnode
*node
, *nnode
;
3021 char errmsg
[BUFSIZ
] = {'\0'};
3023 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
3026 /* Unset flag globally */
3027 UNSET_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
);
3029 /* Initiate processing for all BGP instances. */
3030 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
3031 if (bgp_initiate_graceful_shut_unshut(bgp
, errmsg
,
3035 vty_out(vty
, "%s\n", errmsg
);
3041 /* "bgp graceful-shutdown" configuration */
3042 DEFUN (bgp_graceful_shutdown
,
3043 bgp_graceful_shutdown_cmd
,
3044 "bgp graceful-shutdown",
3046 "Graceful shutdown parameters\n")
3048 if (vty
->node
== CONFIG_NODE
)
3049 return bgp_global_graceful_shutdown_config_vty(vty
);
3051 nb_cli_enqueue_change(vty
, "./global/graceful-shutdown/enable",
3052 NB_OP_MODIFY
, "true");
3054 return nb_cli_apply_changes(vty
, NULL
);
3057 DEFUN_YANG (no_bgp_graceful_shutdown
,
3058 no_bgp_graceful_shutdown_cmd
,
3059 "no bgp graceful-shutdown",
3062 "Graceful shutdown parameters\n")
3064 if (vty
->node
== CONFIG_NODE
)
3065 return bgp_global_graceful_shutdown_deconfig_vty(vty
);
3067 nb_cli_enqueue_change(vty
, "./global/graceful-shutdown/enable",
3068 NB_OP_MODIFY
, "false");
3070 return nb_cli_apply_changes(vty
, NULL
);
3073 void cli_show_router_bgp_graceful_shutdown(struct vty
*vty
,
3074 struct lyd_node
*dnode
,
3077 if (yang_dnode_get_bool(dnode
, NULL
))
3078 vty_out(vty
, " bgp graceful-shutdown\n");
3081 /* "bgp fast-external-failover" configuration. */
3082 DEFUN_YANG (bgp_fast_external_failover
,
3083 bgp_fast_external_failover_cmd
,
3084 "bgp fast-external-failover",
3086 "Immediately reset session if a link to a directly connected external peer goes down\n")
3088 nb_cli_enqueue_change(vty
, "./global/fast-external-failover",
3089 NB_OP_MODIFY
, "false");
3091 return nb_cli_apply_changes(vty
, NULL
);
3094 DEFUN_YANG (no_bgp_fast_external_failover
,
3095 no_bgp_fast_external_failover_cmd
,
3096 "no bgp fast-external-failover",
3099 "Immediately reset session if a link to a directly connected external peer goes down\n")
3101 nb_cli_enqueue_change(vty
, "./global/fast-external-failover",
3102 NB_OP_MODIFY
, "true");
3104 return nb_cli_apply_changes(vty
, NULL
);
3107 void cli_show_router_bgp_fast_external_failover(struct vty
*vty
,
3108 struct lyd_node
*dnode
,
3111 if (!yang_dnode_get_bool(dnode
, NULL
))
3112 vty_out(vty
, " no bgp fast-external-failover\n");
3115 /* "bgp bestpath compare-routerid" configuration. */
3116 DEFUN_YANG(bgp_bestpath_compare_router_id
,
3117 bgp_bestpath_compare_router_id_cmd
,
3118 "bgp bestpath compare-routerid",
3119 "BGP specific commands\n"
3120 "Change the default bestpath selection\n"
3121 "Compare router-id for identical EBGP paths\n")
3123 nb_cli_enqueue_change(
3125 "./global/route-selection-options/external-compare-router-id",
3126 NB_OP_MODIFY
, "true");
3128 return nb_cli_apply_changes(vty
, NULL
);
3131 DEFUN_YANG(no_bgp_bestpath_compare_router_id
,
3132 no_bgp_bestpath_compare_router_id_cmd
,
3133 "no bgp bestpath compare-routerid",
3135 "BGP specific commands\n"
3136 "Change the default bestpath selection\n"
3137 "Compare router-id for identical EBGP paths\n")
3139 nb_cli_enqueue_change(
3141 "./global/route-selection-options/external-compare-router-id",
3142 NB_OP_MODIFY
, "false");
3144 return nb_cli_apply_changes(vty
, NULL
);
3147 /* "bgp bestpath as-path ignore" configuration. */
3148 DEFUN_YANG(bgp_bestpath_aspath_ignore
,
3149 bgp_bestpath_aspath_ignore_cmd
,
3150 "bgp bestpath as-path ignore",
3151 "BGP specific commands\n"
3152 "Change the default bestpath selection\n"
3153 "AS-path attribute\n"
3154 "Ignore as-path length in selecting a route\n")
3156 nb_cli_enqueue_change(
3157 vty
, "./global/route-selection-options/ignore-as-path-length",
3158 NB_OP_MODIFY
, "true");
3160 return nb_cli_apply_changes(vty
, NULL
);
3163 DEFUN_YANG(no_bgp_bestpath_aspath_ignore
,
3164 no_bgp_bestpath_aspath_ignore_cmd
,
3165 "no bgp bestpath as-path ignore",
3167 "BGP specific commands\n"
3168 "Change the default bestpath selection\n"
3169 "AS-path attribute\n"
3170 "Ignore as-path length in selecting a route\n")
3172 nb_cli_enqueue_change(
3173 vty
, "./global/route-selection-options/ignore-as-path-length",
3174 NB_OP_MODIFY
, "false");
3176 return nb_cli_apply_changes(vty
, NULL
);
3179 /* "bgp bestpath as-path confed" configuration. */
3180 DEFUN_YANG (bgp_bestpath_aspath_confed
,
3181 bgp_bestpath_aspath_confed_cmd
,
3182 "bgp bestpath as-path confed",
3183 "BGP specific commands\n"
3184 "Change the default bestpath selection\n"
3185 "AS-path attribute\n"
3186 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3188 nb_cli_enqueue_change(vty
,
3189 "./global/route-selection-options/aspath-confed",
3190 NB_OP_MODIFY
, "true");
3192 return nb_cli_apply_changes(vty
, NULL
);
3195 DEFUN_YANG (no_bgp_bestpath_aspath_confed
,
3196 no_bgp_bestpath_aspath_confed_cmd
,
3197 "no bgp bestpath as-path confed",
3199 "BGP specific commands\n"
3200 "Change the default bestpath selection\n"
3201 "AS-path attribute\n"
3202 "Compare path lengths including confederation sets & sequences in selecting a route\n")
3204 nb_cli_enqueue_change(vty
,
3205 "./global/route-selection-options/aspath-confed",
3206 NB_OP_MODIFY
, "false");
3208 return nb_cli_apply_changes(vty
, NULL
);
3211 /* "bgp bestpath as-path multipath-relax" configuration. */
3212 DEFUN_YANG (bgp_bestpath_aspath_multipath_relax
,
3213 bgp_bestpath_aspath_multipath_relax_cmd
,
3214 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3215 "BGP specific commands\n"
3216 "Change the default bestpath selection\n"
3217 "AS-path attribute\n"
3218 "Allow load sharing across routes that have different AS paths (but same length)\n"
3219 "Generate an AS_SET\n"
3220 "Do not generate an AS_SET\n")
3224 nb_cli_enqueue_change(
3225 vty
, "./global/route-selection-options/allow-multiple-as",
3226 NB_OP_MODIFY
, "true");
3227 if (argv_find(argv
, argc
, "as-set", &idx
))
3228 nb_cli_enqueue_change(
3230 "./global/route-selection-options/multi-path-as-set",
3231 NB_OP_MODIFY
, "true");
3233 nb_cli_enqueue_change(
3235 "./global/route-selection-options/multi-path-as-set",
3236 NB_OP_MODIFY
, "false");
3238 return nb_cli_apply_changes(vty
, NULL
);
3241 DEFUN_YANG (no_bgp_bestpath_aspath_multipath_relax
,
3242 no_bgp_bestpath_aspath_multipath_relax_cmd
,
3243 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
3245 "BGP specific commands\n"
3246 "Change the default bestpath selection\n"
3247 "AS-path attribute\n"
3248 "Allow load sharing across routes that have different AS paths (but same length)\n"
3249 "Generate an AS_SET\n"
3250 "Do not generate an AS_SET\n")
3252 nb_cli_enqueue_change(
3253 vty
, "./global/route-selection-options/allow-multiple-as",
3254 NB_OP_MODIFY
, "false");
3255 nb_cli_enqueue_change(
3256 vty
, "./global/route-selection-options/multi-path-as-set",
3257 NB_OP_MODIFY
, "false");
3259 return nb_cli_apply_changes(vty
, NULL
);
3262 /* "bgp log-neighbor-changes" configuration. */
3263 DEFUN_YANG(bgp_log_neighbor_changes
,
3264 bgp_log_neighbor_changes_cmd
,
3265 "bgp log-neighbor-changes",
3266 "BGP specific commands\n"
3267 "Log neighbor up/down and reset reason\n")
3269 nb_cli_enqueue_change(
3270 vty
, "./global/global-neighbor-config/log-neighbor-changes",
3271 NB_OP_MODIFY
, "true");
3273 return nb_cli_apply_changes(vty
, NULL
);
3276 DEFUN_YANG(no_bgp_log_neighbor_changes
,
3277 no_bgp_log_neighbor_changes_cmd
,
3278 "no bgp log-neighbor-changes",
3280 "BGP specific commands\n"
3281 "Log neighbor up/down and reset reason\n")
3283 nb_cli_enqueue_change(
3284 vty
, "./global/global-neighbor-config/log-neighbor-changes",
3285 NB_OP_MODIFY
, "false");
3287 return nb_cli_apply_changes(vty
, NULL
);
3290 /* "bgp bestpath med" configuration. */
3291 DEFUN_YANG (bgp_bestpath_med
,
3292 bgp_bestpath_med_cmd
,
3293 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3294 "BGP specific commands\n"
3295 "Change the default bestpath selection\n"
3297 "Compare MED among confederation paths\n"
3298 "Treat missing MED as the least preferred one\n"
3299 "Treat missing MED as the least preferred one\n"
3300 "Compare MED among confederation paths\n")
3303 bool confed
= false;
3304 bool worst_med
= false;
3307 if (argv_find(argv
, argc
, "confed", &idx
))
3310 nb_cli_enqueue_change(vty
,
3311 "./global/route-selection-options/confed-med",
3312 NB_OP_MODIFY
, confed
? "true" : "false");
3315 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3318 nb_cli_enqueue_change(
3319 vty
, "./global/route-selection-options/missing-as-worst-med",
3320 NB_OP_MODIFY
, worst_med
? "true" : "false");
3322 return nb_cli_apply_changes(vty
, NULL
);
3325 DEFUN_YANG (no_bgp_bestpath_med
,
3326 no_bgp_bestpath_med_cmd
,
3327 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
3329 "BGP specific commands\n"
3330 "Change the default bestpath selection\n"
3332 "Compare MED among confederation paths\n"
3333 "Treat missing MED as the least preferred one\n"
3334 "Treat missing MED as the least preferred one\n"
3335 "Compare MED among confederation paths\n")
3339 if (argv_find(argv
, argc
, "confed", &idx
))
3340 nb_cli_enqueue_change(
3341 vty
, "./global/route-selection-options/confed-med",
3342 NB_OP_MODIFY
, "false");
3345 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
3346 nb_cli_enqueue_change(
3348 "./global/route-selection-options/missing-as-worst-med",
3349 NB_OP_MODIFY
, "false");
3351 return nb_cli_apply_changes(vty
, NULL
);
3354 /* "bgp bestpath bandwidth" configuration. */
3355 DEFPY (bgp_bestpath_bw
,
3356 bgp_bestpath_bw_cmd
,
3357 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
3358 "BGP specific commands\n"
3359 "Change the default bestpath selection\n"
3360 "Link Bandwidth attribute\n"
3361 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3362 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3363 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3365 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3370 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3371 return CMD_ERR_INCOMPLETE
;
3373 if (!strcmp(bw_cfg
, "ignore"))
3374 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3375 else if (!strcmp(bw_cfg
, "skip-missing"))
3376 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3377 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3378 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3380 return CMD_ERR_NO_MATCH
;
3382 /* This config is used in route install, so redo that. */
3383 FOREACH_AFI_SAFI (afi
, safi
) {
3384 if (!bgp_fibupd_safi(safi
))
3386 bgp_zebra_announce_table(bgp
, afi
, safi
);
3392 DEFPY (no_bgp_bestpath_bw
,
3393 no_bgp_bestpath_bw_cmd
,
3394 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3396 "BGP specific commands\n"
3397 "Change the default bestpath selection\n"
3398 "Link Bandwidth attribute\n"
3399 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3400 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3401 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3403 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3407 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3409 /* This config is used in route install, so redo that. */
3410 FOREACH_AFI_SAFI (afi
, safi
) {
3411 if (!bgp_fibupd_safi(safi
))
3413 bgp_zebra_announce_table(bgp
, afi
, safi
);
3418 /* "no bgp default ipv4-unicast". */
3419 DEFUN (no_bgp_default_ipv4_unicast
,
3420 no_bgp_default_ipv4_unicast_cmd
,
3421 "no bgp default ipv4-unicast",
3423 "BGP specific commands\n"
3424 "Configure BGP defaults\n"
3425 "Activate ipv4-unicast for a peer by default\n")
3427 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3428 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
);
3432 DEFUN (bgp_default_ipv4_unicast
,
3433 bgp_default_ipv4_unicast_cmd
,
3434 "bgp default ipv4-unicast",
3435 "BGP specific commands\n"
3436 "Configure BGP defaults\n"
3437 "Activate ipv4-unicast for a peer by default\n")
3439 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3440 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
);
3444 /* Display hostname in certain command outputs */
3445 DEFUN_YANG (bgp_default_show_hostname
,
3446 bgp_default_show_hostname_cmd
,
3447 "bgp default show-hostname",
3448 "BGP specific commands\n"
3449 "Configure BGP defaults\n"
3450 "Show hostname in certain command outputs\n")
3452 nb_cli_enqueue_change(vty
, "./global/show-hostname", NB_OP_MODIFY
,
3455 return nb_cli_apply_changes(vty
, NULL
);
3458 DEFUN_YANG(no_bgp_default_show_hostname
,
3459 no_bgp_default_show_hostname_cmd
,
3460 "no bgp default show-hostname",
3462 "BGP specific commands\n"
3463 "Configure BGP defaults\n"
3464 "Show hostname in certain command outputs\n")
3466 nb_cli_enqueue_change(vty
, "./global/show-hostname", NB_OP_MODIFY
,
3469 return nb_cli_apply_changes(vty
, NULL
);
3472 void cli_show_router_bgp_show_hostname(struct vty
*vty
, struct lyd_node
*dnode
,
3475 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SHOW_HOSTNAME
)
3476 vty_out(vty
, " bgp default show-hostname\n");
3479 /* Display hostname in certain command outputs */
3480 DEFUN (bgp_default_show_nexthop_hostname
,
3481 bgp_default_show_nexthop_hostname_cmd
,
3482 "bgp default show-nexthop-hostname",
3483 "BGP specific commands\n"
3484 "Configure BGP defaults\n"
3485 "Show hostname for nexthop in certain command outputs\n")
3487 nb_cli_enqueue_change(vty
, "./global/show-nexthop-hostname",
3488 NB_OP_MODIFY
, "true");
3490 return nb_cli_apply_changes(vty
, NULL
);
3493 DEFUN (no_bgp_default_show_nexthop_hostname
,
3494 no_bgp_default_show_nexthop_hostname_cmd
,
3495 "no bgp default show-nexthop-hostname",
3497 "BGP specific commands\n"
3498 "Configure BGP defaults\n"
3499 "Show hostname for nexthop in certain command outputs\n")
3501 nb_cli_enqueue_change(vty
, "./global/show-nexthop-hostname",
3502 NB_OP_MODIFY
, "false");
3504 return nb_cli_apply_changes(vty
, NULL
);
3507 void cli_show_router_bgp_show_nexthop_hostname(struct vty
*vty
,
3508 struct lyd_node
*dnode
,
3511 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_SHOW_HOSTNAME
)
3512 vty_out(vty
, " bgp default show-nexthop-hostname\n");
3515 /* "bgp network import-check" configuration. */
3516 DEFUN_YANG(bgp_network_import_check
,
3517 bgp_network_import_check_cmd
,
3518 "bgp network import-check",
3519 "BGP specific commands\n"
3520 "BGP network command\n"
3521 "Check BGP network route exists in IGP\n")
3523 nb_cli_enqueue_change(vty
, "./global/import-check", NB_OP_MODIFY
,
3526 return nb_cli_apply_changes(vty
, NULL
);
3529 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
3530 "bgp network import-check exact",
3531 "BGP specific commands\n"
3532 "BGP network command\n"
3533 "Check BGP network route exists in IGP\n"
3534 "Match route precisely\n")
3536 DEFUN_YANG(no_bgp_network_import_check
,
3537 no_bgp_network_import_check_cmd
,
3538 "no bgp network import-check",
3540 "BGP specific commands\n"
3541 "BGP network command\n"
3542 "Check BGP network route exists in IGP\n")
3544 nb_cli_enqueue_change(vty
, "./global/import-check", NB_OP_MODIFY
,
3547 return nb_cli_apply_changes(vty
, NULL
);
3550 void cli_show_router_bgp_import_check(struct vty
*vty
, struct lyd_node
*dnode
,
3553 if (yang_dnode_get_bool(dnode
, NULL
) != SAVE_BGP_IMPORT_CHECK
)
3554 vty_out(vty
, " bgp network import-check\n");
3557 DEFUN_YANG(bgp_default_local_preference
,
3558 bgp_default_local_preference_cmd
,
3559 "bgp default local-preference (0-4294967295)",
3560 "BGP specific commands\n"
3561 "Configure BGP defaults\n"
3562 "local preference (higher=more preferred)\n"
3563 "Configure default local preference value\n")
3567 nb_cli_enqueue_change(vty
, "./global/local-pref", NB_OP_MODIFY
,
3568 argv
[idx_number
]->arg
);
3570 return nb_cli_apply_changes(vty
, NULL
);
3573 DEFUN_YANG(no_bgp_default_local_preference
,
3574 no_bgp_default_local_preference_cmd
,
3575 "no bgp default local-preference [(0-4294967295)]",
3577 "BGP specific commands\n"
3578 "Configure BGP defaults\n"
3579 "local preference (higher=more preferred)\n"
3580 "Configure default local preference value\n")
3582 nb_cli_enqueue_change(vty
, "./global/local-pref", NB_OP_MODIFY
, NULL
);
3584 return nb_cli_apply_changes(vty
, NULL
);
3587 void cli_show_router_bgp_local_pref(struct vty
*vty
, struct lyd_node
*dnode
,
3590 vty_out(vty
, " bgp default local-preference %u\n",
3591 yang_dnode_get_uint32(dnode
, NULL
));
3595 DEFUN_YANG(bgp_default_subgroup_pkt_queue_max
,
3596 bgp_default_subgroup_pkt_queue_max_cmd
,
3597 "bgp default subgroup-pkt-queue-max (20-100)",
3598 "BGP specific commands\n"
3599 "Configure BGP defaults\n"
3600 "subgroup-pkt-queue-max\n"
3601 "Configure subgroup packet queue max\n")
3605 nb_cli_enqueue_change(
3607 "./global/global-update-group-config/subgroup-pkt-queue-size",
3608 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
3610 return nb_cli_apply_changes(vty
, NULL
);
3613 DEFUN_YANG(no_bgp_default_subgroup_pkt_queue_max
,
3614 no_bgp_default_subgroup_pkt_queue_max_cmd
,
3615 "no bgp default subgroup-pkt-queue-max [(20-100)]",
3617 "BGP specific commands\n"
3618 "Configure BGP defaults\n"
3619 "subgroup-pkt-queue-max\n"
3620 "Configure subgroup packet queue max\n")
3622 nb_cli_enqueue_change(
3624 "./global/global-update-group-config/subgroup-pkt-queue-size",
3625 NB_OP_MODIFY
, NULL
);
3627 return nb_cli_apply_changes(vty
, NULL
);
3630 void cli_show_router_global_update_group_config_subgroup_pkt_queue_size(
3631 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
3633 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
3634 yang_dnode_get_uint32(dnode
, NULL
));
3637 DEFUN_YANG(bgp_rr_allow_outbound_policy
,
3638 bgp_rr_allow_outbound_policy_cmd
,
3639 "bgp route-reflector allow-outbound-policy",
3640 "BGP specific commands\n"
3641 "Allow modifications made by out route-map\n"
3642 "on ibgp neighbors\n")
3644 nb_cli_enqueue_change(vty
,
3645 "./global/route-reflector/allow-outbound-policy",
3646 NB_OP_MODIFY
, "true");
3648 return nb_cli_apply_changes(vty
, NULL
);
3651 DEFUN_YANG(no_bgp_rr_allow_outbound_policy
,
3652 no_bgp_rr_allow_outbound_policy_cmd
,
3653 "no bgp route-reflector allow-outbound-policy",
3655 "BGP specific commands\n"
3656 "Allow modifications made by out route-map\n"
3657 "on ibgp neighbors\n")
3659 nb_cli_enqueue_change(vty
,
3660 "./global/route-reflector/allow-outbound-policy",
3661 NB_OP_MODIFY
, "false");
3663 return nb_cli_apply_changes(vty
, NULL
);
3667 void cli_show_router_global_neighbor_config(struct vty
*vty
,
3668 struct lyd_node
*dnode
,
3671 uint32_t write_quanta
, read_quanta
;
3673 if (yang_dnode_get_bool(dnode
, "./log-neighbor-changes"))
3674 vty_out(vty
, " bgp log-neighbor-changes\n");
3676 if (yang_dnode_exists(dnode
, "./dynamic-neighbors-limit")) {
3677 uint32_t listen_limit
= yang_dnode_get_uint32(
3678 dnode
, "./dynamic-neighbors-limit");
3679 vty_out(vty
, " bgp listen limit %u\n", listen_limit
);
3682 write_quanta
= yang_dnode_get_uint32(
3683 dnode
, "./packet-quanta-config/wpkt-quanta");
3684 if (write_quanta
!= BGP_WRITE_PACKET_MAX
)
3685 vty_out(vty
, " write-quanta %d\n", write_quanta
);
3687 read_quanta
= yang_dnode_get_uint32(
3688 dnode
, "./packet-quanta-config/rpkt-quanta");
3690 if (read_quanta
!= BGP_READ_PACKET_MAX
)
3691 vty_out(vty
, " read-quanta %d\n", read_quanta
);
3694 DEFUN_YANG(bgp_listen_limit
,
3695 bgp_listen_limit_cmd
,
3696 "bgp listen limit (1-5000)",
3697 "BGP specific commands\n"
3698 "BGP Dynamic Neighbors listen commands\n"
3699 "Maximum number of BGP Dynamic Neighbors that can be created\n"
3700 "Configure Dynamic Neighbors listen limit value\n")
3704 nb_cli_enqueue_change(
3705 vty
, "./global/global-neighbor-config/dynamic-neighbors-limit",
3706 NB_OP_MODIFY
, argv
[idx_number
]->arg
);
3708 return nb_cli_apply_changes(vty
, NULL
);
3711 DEFUN_YANG(no_bgp_listen_limit
,
3712 no_bgp_listen_limit_cmd
,
3713 "no bgp listen limit [(1-5000)]",
3715 "BGP specific commands\n"
3716 "BGP Dynamic Neighbors listen commands\n"
3717 "Maximum number of BGP Dynamic Neighbors that can be created\n"
3718 "Configure Dynamic Neighbors listen limit value\n")
3720 nb_cli_enqueue_change(
3721 vty
, "./global/global-neighbor-config/dynamic-neighbors-limit",
3722 NB_OP_DESTROY
, NULL
);
3724 return nb_cli_apply_changes(vty
, NULL
);
3729 * Check if this listen range is already configured. Check for exact
3730 * match or overlap based on input.
3732 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
3733 struct prefix
*range
, int exact
)
3735 struct listnode
*node
, *nnode
;
3736 struct listnode
*node1
, *nnode1
;
3737 struct peer_group
*group
;
3742 afi
= family2afi(range
->family
);
3743 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
3744 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
3747 match
= prefix_same(range
, lr
);
3749 match
= (prefix_match(range
, lr
)
3750 || prefix_match(lr
, range
));
3759 DEFUN (bgp_listen_range
,
3760 bgp_listen_range_cmd
,
3761 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
3762 "BGP specific commands\n"
3763 "Configure BGP dynamic neighbors listen range\n"
3764 "Configure BGP dynamic neighbors listen range\n"
3766 "Member of the peer-group\n"
3767 "Peer-group name\n")
3769 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3770 struct prefix range
;
3771 struct peer_group
*group
, *existing_group
;
3776 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
3777 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
3778 char *prefix
= argv
[idx
]->arg
;
3779 argv_find(argv
, argc
, "PGNAME", &idx
);
3780 char *peergroup
= argv
[idx
]->arg
;
3782 /* Convert IP prefix string to struct prefix. */
3783 ret
= str2prefix(prefix
, &range
);
3785 vty_out(vty
, "%% Malformed listen range\n");
3786 return CMD_WARNING_CONFIG_FAILED
;
3789 afi
= family2afi(range
.family
);
3791 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
3793 "%% Malformed listen range (link-local address)\n");
3794 return CMD_WARNING_CONFIG_FAILED
;
3799 /* Check if same listen range is already configured. */
3800 existing_group
= listen_range_exists(bgp
, &range
, 1);
3801 if (existing_group
) {
3802 if (strcmp(existing_group
->name
, peergroup
) == 0)
3806 "%% Same listen range is attached to peer-group %s\n",
3807 existing_group
->name
);
3808 return CMD_WARNING_CONFIG_FAILED
;
3812 /* Check if an overlapping listen range exists. */
3813 if (listen_range_exists(bgp
, &range
, 0)) {
3815 "%% Listen range overlaps with existing listen range\n");
3816 return CMD_WARNING_CONFIG_FAILED
;
3819 group
= peer_group_lookup(bgp
, peergroup
);
3821 vty_out(vty
, "%% Configure the peer-group first\n");
3822 return CMD_WARNING_CONFIG_FAILED
;
3825 ret
= peer_group_listen_range_add(group
, &range
);
3826 return bgp_vty_return(vty
, ret
);
3829 DEFUN (no_bgp_listen_range
,
3830 no_bgp_listen_range_cmd
,
3831 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
3833 "BGP specific commands\n"
3834 "Unconfigure BGP dynamic neighbors listen range\n"
3835 "Unconfigure BGP dynamic neighbors listen range\n"
3837 "Member of the peer-group\n"
3838 "Peer-group name\n")
3840 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3841 struct prefix range
;
3842 struct peer_group
*group
;
3847 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
3848 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
3849 char *prefix
= argv
[idx
]->arg
;
3850 argv_find(argv
, argc
, "PGNAME", &idx
);
3851 char *peergroup
= argv
[idx
]->arg
;
3853 /* Convert IP prefix string to struct prefix. */
3854 ret
= str2prefix(prefix
, &range
);
3856 vty_out(vty
, "%% Malformed listen range\n");
3857 return CMD_WARNING_CONFIG_FAILED
;
3860 afi
= family2afi(range
.family
);
3862 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
3864 "%% Malformed listen range (link-local address)\n");
3865 return CMD_WARNING_CONFIG_FAILED
;
3870 group
= peer_group_lookup(bgp
, peergroup
);
3872 vty_out(vty
, "%% Peer-group does not exist\n");
3873 return CMD_WARNING_CONFIG_FAILED
;
3876 ret
= peer_group_listen_range_del(group
, &range
);
3877 return bgp_vty_return(vty
, ret
);
3880 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
3882 struct peer_group
*group
;
3883 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
3884 struct prefix
*range
;
3886 char buf
[PREFIX2STR_BUFFER
];
3888 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
3889 vty_out(vty
, " bgp listen limit %d\n",
3890 bgp
->dynamic_neighbors_limit
);
3892 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
3893 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
3894 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
3896 prefix2str(range
, buf
, sizeof(buf
));
3898 " bgp listen range %s peer-group %s\n",
3906 DEFUN_YANG(bgp_disable_connected_route_check
,
3907 bgp_disable_connected_route_check_cmd
,
3908 "bgp disable-ebgp-connected-route-check",
3909 "BGP specific commands\n"
3910 "Disable checking if nexthop is connected on ebgp sessions\n")
3912 nb_cli_enqueue_change(vty
,
3913 "./global/ebgp-multihop-connected-route-check",
3914 NB_OP_MODIFY
, "true");
3916 return nb_cli_apply_changes(vty
, NULL
);
3919 DEFUN_YANG(no_bgp_disable_connected_route_check
,
3920 no_bgp_disable_connected_route_check_cmd
,
3921 "no bgp disable-ebgp-connected-route-check",
3923 "BGP specific commands\n"
3924 "Disable checking if nexthop is connected on ebgp sessions\n")
3926 nb_cli_enqueue_change(vty
,
3927 "./global/ebgp-multihop-connected-route-check",
3928 NB_OP_MODIFY
, "false");
3930 return nb_cli_apply_changes(vty
, NULL
);
3933 void cli_show_router_global_ebgp_multihop_connected_route_check(
3934 struct vty
*vty
, struct lyd_node
*dnode
, bool show_defaults
)
3936 if (yang_dnode_get_bool(dnode
, NULL
))
3937 vty_out(vty
, " bgp disable-ebgp-connected-route-check\n");
3940 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
3941 const char *as_str
, afi_t afi
, safi_t safi
)
3943 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3946 int as_type
= AS_SPECIFIED
;
3949 if (as_str
[0] == 'i') {
3951 as_type
= AS_INTERNAL
;
3952 } else if (as_str
[0] == 'e') {
3954 as_type
= AS_EXTERNAL
;
3956 /* Get AS number. */
3957 as
= strtoul(as_str
, NULL
, 10);
3960 /* If peer is peer group or interface peer, call proper function. */
3961 ret
= str2sockunion(peer_str
, &su
);
3965 /* Check if existing interface peer */
3966 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
3968 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
3971 /* if not interface peer, check peer-group settings */
3972 if (ret
< 0 && !peer
) {
3973 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
3976 "%% Create the peer-group or interface first\n");
3977 return CMD_WARNING_CONFIG_FAILED
;
3982 if (peer_address_self_check(bgp
, &su
)) {
3984 "%% Can not configure the local system as neighbor\n");
3985 return CMD_WARNING_CONFIG_FAILED
;
3987 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
3990 /* This peer belongs to peer group. */
3992 case BGP_ERR_PEER_GROUP_MEMBER
:
3994 "%% Peer-group member cannot override remote-as of peer-group\n");
3995 return CMD_WARNING_CONFIG_FAILED
;
3996 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
3998 "%% Peer-group members must be all internal or all external\n");
3999 return CMD_WARNING_CONFIG_FAILED
;
4001 return bgp_vty_return(vty
, ret
);
4004 DEFUN_YANG(bgp_default_shutdown
,
4005 bgp_default_shutdown_cmd
,
4006 "[no] bgp default shutdown",
4008 "Configure BGP defaults\n"
4009 "Apply administrative shutdown to newly configured peers\n")
4011 nb_cli_enqueue_change(vty
, "./global/default-shutdown", NB_OP_MODIFY
,
4012 strmatch(argv
[0]->text
, "no") ? "false" : "true");
4014 return nb_cli_apply_changes(vty
, NULL
);
4017 void cli_show_router_bgp_default_shutdown(struct vty
*vty
,
4018 struct lyd_node
*dnode
,
4021 if (yang_dnode_get_bool(dnode
, NULL
))
4022 vty_out(vty
, " bgp default shutdown\n");
4025 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
4027 "Administrative shutdown of the BGP instance\n"
4028 "Add a shutdown message (RFC 8203)\n"
4029 "Shutdown message\n")
4031 char *msgstr
= NULL
;
4033 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4036 msgstr
= argv_concat(argv
, argc
, 3);
4038 bgp_shutdown_enable(bgp
, msgstr
);
4039 XFREE(MTYPE_TMP
, msgstr
);
4044 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
4045 BGP_STR
"Administrative shutdown of the BGP instance\n")
4047 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4049 bgp_shutdown_enable(bgp
, NULL
);
4054 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
4055 NO_STR BGP_STR
"Administrative shutdown of the BGP instance\n")
4057 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4059 bgp_shutdown_disable(bgp
);
4064 ALIAS(no_bgp_shutdown
, no_bgp_shutdown_msg_cmd
,
4065 "no bgp shutdown message MSG...", NO_STR BGP_STR
4066 "Administrative shutdown of the BGP instance\n"
4067 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
4069 DEFUN (neighbor_remote_as
,
4070 neighbor_remote_as_cmd
,
4071 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
4074 "Specify a BGP neighbor\n"
4076 "Internal BGP peer\n"
4077 "External BGP peer\n")
4080 int idx_remote_as
= 3;
4081 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
4082 argv
[idx_remote_as
]->arg
, AFI_IP
,
4086 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
4087 afi_t afi
, safi_t safi
, int v6only
,
4088 const char *peer_group_name
,
4091 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4093 int as_type
= AS_UNSPECIFIED
;
4095 struct peer_group
*group
;
4099 group
= peer_group_lookup(bgp
, conf_if
);
4102 vty_out(vty
, "%% Name conflict with peer-group \n");
4103 return CMD_WARNING_CONFIG_FAILED
;
4107 if (as_str
[0] == 'i') {
4108 as_type
= AS_INTERNAL
;
4109 } else if (as_str
[0] == 'e') {
4110 as_type
= AS_EXTERNAL
;
4112 /* Get AS number. */
4113 as
= strtoul(as_str
, NULL
, 10);
4114 as_type
= AS_SPECIFIED
;
4118 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
4121 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
4124 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
)
4125 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
4126 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
4127 as_type
, 0, 0, NULL
);
4129 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
4130 as_type
, afi
, safi
, NULL
);
4133 vty_out(vty
, "%% BGP failed to create peer\n");
4134 return CMD_WARNING_CONFIG_FAILED
;
4138 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4140 /* Request zebra to initiate IPv6 RAs on this interface. We do
4142 * any unnumbered peer in order to not worry about run-time
4144 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
4146 * gets deleted later etc.)
4149 bgp_zebra_initiate_radv(bgp
, peer
);
4152 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
4153 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
4155 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4157 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
4159 /* v6only flag changed. Reset bgp seesion */
4160 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
4161 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
4162 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
4163 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
4165 bgp_session_reset(peer
);
4168 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
4169 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
4170 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
4171 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
4174 if (peer_group_name
) {
4175 group
= peer_group_lookup(bgp
, peer_group_name
);
4177 vty_out(vty
, "%% Configure the peer-group first\n");
4178 return CMD_WARNING_CONFIG_FAILED
;
4181 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
4184 return bgp_vty_return(vty
, ret
);
4187 DEFUN (neighbor_interface_config
,
4188 neighbor_interface_config_cmd
,
4189 "neighbor WORD interface [peer-group PGNAME]",
4191 "Interface name or neighbor tag\n"
4192 "Enable BGP on interface\n"
4193 "Member of the peer-group\n"
4194 "Peer-group name\n")
4197 int idx_peer_group_word
= 4;
4199 if (argc
> idx_peer_group_word
)
4200 return peer_conf_interface_get(
4201 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
4202 argv
[idx_peer_group_word
]->arg
, NULL
);
4204 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
4205 SAFI_UNICAST
, 0, NULL
, NULL
);
4208 DEFUN (neighbor_interface_config_v6only
,
4209 neighbor_interface_config_v6only_cmd
,
4210 "neighbor WORD interface v6only [peer-group PGNAME]",
4212 "Interface name or neighbor tag\n"
4213 "Enable BGP on interface\n"
4214 "Enable BGP with v6 link-local only\n"
4215 "Member of the peer-group\n"
4216 "Peer-group name\n")
4219 int idx_peer_group_word
= 5;
4221 if (argc
> idx_peer_group_word
)
4222 return peer_conf_interface_get(
4223 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
4224 argv
[idx_peer_group_word
]->arg
, NULL
);
4226 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
4227 SAFI_UNICAST
, 1, NULL
, NULL
);
4231 DEFUN (neighbor_interface_config_remote_as
,
4232 neighbor_interface_config_remote_as_cmd
,
4233 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
4235 "Interface name or neighbor tag\n"
4236 "Enable BGP on interface\n"
4237 "Specify a BGP neighbor\n"
4239 "Internal BGP peer\n"
4240 "External BGP peer\n")
4243 int idx_remote_as
= 4;
4244 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
4245 SAFI_UNICAST
, 0, NULL
,
4246 argv
[idx_remote_as
]->arg
);
4249 DEFUN (neighbor_interface_v6only_config_remote_as
,
4250 neighbor_interface_v6only_config_remote_as_cmd
,
4251 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
4253 "Interface name or neighbor tag\n"
4254 "Enable BGP with v6 link-local only\n"
4255 "Enable BGP on interface\n"
4256 "Specify a BGP neighbor\n"
4258 "Internal BGP peer\n"
4259 "External BGP peer\n")
4262 int idx_remote_as
= 5;
4263 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
4264 SAFI_UNICAST
, 1, NULL
,
4265 argv
[idx_remote_as
]->arg
);
4268 DEFUN (neighbor_peer_group
,
4269 neighbor_peer_group_cmd
,
4270 "neighbor WORD peer-group",
4272 "Interface name or neighbor tag\n"
4273 "Configure peer-group\n")
4275 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4278 struct peer_group
*group
;
4280 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4282 vty_out(vty
, "%% Name conflict with interface: \n");
4283 return CMD_WARNING_CONFIG_FAILED
;
4286 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
4288 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
4289 return CMD_WARNING_CONFIG_FAILED
;
4297 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
4301 "Specify a BGP neighbor\n"
4303 "Internal BGP peer\n"
4304 "External BGP peer\n")
4306 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4310 struct peer_group
*group
;
4314 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4316 /* look up for neighbor by interface name config. */
4317 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4319 /* Request zebra to terminate IPv6 RAs on this
4322 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4323 peer_notify_unconfig(peer
);
4328 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
4330 peer_group_notify_unconfig(group
);
4331 peer_group_delete(group
);
4333 vty_out(vty
, "%% Create the peer-group first\n");
4334 return CMD_WARNING_CONFIG_FAILED
;
4337 peer
= peer_lookup(bgp
, &su
);
4339 if (peer_dynamic_neighbor(peer
)) {
4341 "%% Operation not allowed on a dynamic neighbor\n");
4342 return CMD_WARNING_CONFIG_FAILED
;
4345 other
= peer
->doppelganger
;
4347 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4348 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4350 peer_notify_unconfig(peer
);
4352 if (other
&& other
->status
!= Deleted
) {
4353 peer_notify_unconfig(other
);
4362 DEFUN (no_neighbor_interface_config
,
4363 no_neighbor_interface_config_cmd
,
4364 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
4368 "Configure BGP on interface\n"
4369 "Enable BGP with v6 link-local only\n"
4370 "Member of the peer-group\n"
4372 "Specify a BGP neighbor\n"
4374 "Internal BGP peer\n"
4375 "External BGP peer\n")
4377 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4381 /* look up for neighbor by interface name config. */
4382 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4384 /* Request zebra to terminate IPv6 RAs on this interface. */
4386 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4387 peer_notify_unconfig(peer
);
4390 vty_out(vty
, "%% Create the bgp interface first\n");
4391 return CMD_WARNING_CONFIG_FAILED
;
4396 DEFUN (no_neighbor_peer_group
,
4397 no_neighbor_peer_group_cmd
,
4398 "no neighbor WORD peer-group",
4402 "Configure peer-group\n")
4404 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4406 struct peer_group
*group
;
4408 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4410 peer_group_notify_unconfig(group
);
4411 peer_group_delete(group
);
4413 vty_out(vty
, "%% Create the peer-group first\n");
4414 return CMD_WARNING_CONFIG_FAILED
;
4419 DEFUN (no_neighbor_interface_peer_group_remote_as
,
4420 no_neighbor_interface_peer_group_remote_as_cmd
,
4421 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4424 "Interface name or neighbor tag\n"
4425 "Specify a BGP neighbor\n"
4427 "Internal BGP peer\n"
4428 "External BGP peer\n")
4430 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4432 struct peer_group
*group
;
4435 /* look up for neighbor by interface name config. */
4436 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4438 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
4442 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4444 peer_group_remote_as_delete(group
);
4446 vty_out(vty
, "%% Create the peer-group or interface first\n");
4447 return CMD_WARNING_CONFIG_FAILED
;
4452 DEFUN (neighbor_local_as
,
4453 neighbor_local_as_cmd
,
4454 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4457 "Specify a local-as number\n"
4458 "AS number used as local AS\n")
4466 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4468 return CMD_WARNING_CONFIG_FAILED
;
4470 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4471 ret
= peer_local_as_set(peer
, as
, 0, 0);
4472 return bgp_vty_return(vty
, ret
);
4475 DEFUN (neighbor_local_as_no_prepend
,
4476 neighbor_local_as_no_prepend_cmd
,
4477 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4480 "Specify a local-as number\n"
4481 "AS number used as local AS\n"
4482 "Do not prepend local-as to updates from ebgp peers\n")
4490 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4492 return CMD_WARNING_CONFIG_FAILED
;
4494 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4495 ret
= peer_local_as_set(peer
, as
, 1, 0);
4496 return bgp_vty_return(vty
, ret
);
4499 DEFUN (neighbor_local_as_no_prepend_replace_as
,
4500 neighbor_local_as_no_prepend_replace_as_cmd
,
4501 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4504 "Specify a local-as number\n"
4505 "AS number used as local AS\n"
4506 "Do not prepend local-as to updates from ebgp peers\n"
4507 "Do not prepend local-as to updates from ibgp peers\n")
4515 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4517 return CMD_WARNING_CONFIG_FAILED
;
4519 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4520 ret
= peer_local_as_set(peer
, as
, 1, 1);
4521 return bgp_vty_return(vty
, ret
);
4524 DEFUN (no_neighbor_local_as
,
4525 no_neighbor_local_as_cmd
,
4526 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4530 "Specify a local-as number\n"
4531 "AS number used as local AS\n"
4532 "Do not prepend local-as to updates from ebgp peers\n"
4533 "Do not prepend local-as to updates from ibgp peers\n")
4539 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4541 return CMD_WARNING_CONFIG_FAILED
;
4543 ret
= peer_local_as_unset(peer
);
4544 return bgp_vty_return(vty
, ret
);
4548 DEFUN (neighbor_solo
,
4550 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4553 "Solo peer - part of its own update group\n")
4559 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4561 return CMD_WARNING_CONFIG_FAILED
;
4563 ret
= update_group_adjust_soloness(peer
, 1);
4564 return bgp_vty_return(vty
, ret
);
4567 DEFUN (no_neighbor_solo
,
4568 no_neighbor_solo_cmd
,
4569 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4573 "Solo peer - part of its own update group\n")
4579 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4581 return CMD_WARNING_CONFIG_FAILED
;
4583 ret
= update_group_adjust_soloness(peer
, 0);
4584 return bgp_vty_return(vty
, ret
);
4587 DEFUN (neighbor_password
,
4588 neighbor_password_cmd
,
4589 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
4600 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4602 return CMD_WARNING_CONFIG_FAILED
;
4604 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
4605 return bgp_vty_return(vty
, ret
);
4608 DEFUN (no_neighbor_password
,
4609 no_neighbor_password_cmd
,
4610 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
4621 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4623 return CMD_WARNING_CONFIG_FAILED
;
4625 ret
= peer_password_unset(peer
);
4626 return bgp_vty_return(vty
, ret
);
4629 DEFUN (neighbor_activate
,
4630 neighbor_activate_cmd
,
4631 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4634 "Enable the Address Family for this Neighbor\n")
4640 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4642 return CMD_WARNING_CONFIG_FAILED
;
4644 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
4645 return bgp_vty_return(vty
, ret
);
4648 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
4649 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4650 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4651 "Enable the Address Family for this Neighbor\n")
4653 DEFUN (no_neighbor_activate
,
4654 no_neighbor_activate_cmd
,
4655 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4659 "Enable the Address Family for this Neighbor\n")
4666 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4668 return CMD_WARNING_CONFIG_FAILED
;
4670 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
4671 return bgp_vty_return(vty
, ret
);
4674 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
4675 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4676 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4677 "Enable the Address Family for this Neighbor\n")
4679 DEFUN (neighbor_set_peer_group
,
4680 neighbor_set_peer_group_cmd
,
4681 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4684 "Member of the peer-group\n"
4685 "Peer-group name\n")
4687 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4694 struct peer_group
*group
;
4696 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4698 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4700 vty_out(vty
, "%% Malformed address or name: %s\n",
4701 argv
[idx_peer
]->arg
);
4702 return CMD_WARNING_CONFIG_FAILED
;
4705 if (peer_address_self_check(bgp
, &su
)) {
4707 "%% Can not configure the local system as neighbor\n");
4708 return CMD_WARNING_CONFIG_FAILED
;
4711 /* Disallow for dynamic neighbor. */
4712 peer
= peer_lookup(bgp
, &su
);
4713 if (peer
&& peer_dynamic_neighbor(peer
)) {
4715 "%% Operation not allowed on a dynamic neighbor\n");
4716 return CMD_WARNING_CONFIG_FAILED
;
4720 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4722 vty_out(vty
, "%% Configure the peer-group first\n");
4723 return CMD_WARNING_CONFIG_FAILED
;
4726 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
4728 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
4730 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
4732 return CMD_WARNING_CONFIG_FAILED
;
4735 return bgp_vty_return(vty
, ret
);
4738 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
4739 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4740 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4741 "Member of the peer-group\n"
4742 "Peer-group name\n")
4744 DEFUN (no_neighbor_set_peer_group
,
4745 no_neighbor_set_peer_group_cmd
,
4746 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4750 "Member of the peer-group\n"
4751 "Peer-group name\n")
4753 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4758 struct peer_group
*group
;
4760 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4762 return CMD_WARNING_CONFIG_FAILED
;
4764 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4766 vty_out(vty
, "%% Configure the peer-group first\n");
4767 return CMD_WARNING_CONFIG_FAILED
;
4770 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4771 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4773 peer_notify_unconfig(peer
);
4774 ret
= peer_delete(peer
);
4776 return bgp_vty_return(vty
, ret
);
4779 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
4780 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4781 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4782 "Member of the peer-group\n"
4783 "Peer-group name\n")
4785 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
4786 uint32_t flag
, int set
)
4791 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4793 return CMD_WARNING_CONFIG_FAILED
;
4796 * If 'neighbor <interface>', then this is for directly connected peers,
4797 * we should not accept disable-connected-check.
4799 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
4801 "%s is directly connected peer, cannot accept disable-connected-check\n",
4803 return CMD_WARNING_CONFIG_FAILED
;
4806 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
4807 peer_tx_shutdown_message_unset(peer
);
4810 ret
= peer_flag_set(peer
, flag
);
4812 ret
= peer_flag_unset(peer
, flag
);
4814 return bgp_vty_return(vty
, ret
);
4817 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
4819 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
4822 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
4825 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
4828 /* neighbor passive. */
4829 DEFUN (neighbor_passive
,
4830 neighbor_passive_cmd
,
4831 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
4834 "Don't send open messages to this neighbor\n")
4837 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
4840 DEFUN (no_neighbor_passive
,
4841 no_neighbor_passive_cmd
,
4842 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
4846 "Don't send open messages to this neighbor\n")
4849 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
4852 /* neighbor shutdown. */
4853 DEFUN (neighbor_shutdown_msg
,
4854 neighbor_shutdown_msg_cmd
,
4855 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
4858 "Administratively shut down this neighbor\n"
4859 "Add a shutdown message (RFC 8203)\n"
4860 "Shutdown message\n")
4866 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4870 return CMD_WARNING_CONFIG_FAILED
;
4871 message
= argv_concat(argv
, argc
, 4);
4872 peer_tx_shutdown_message_set(peer
, message
);
4873 XFREE(MTYPE_TMP
, message
);
4876 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
4879 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
4880 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
4881 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4882 "Administratively shut down this neighbor\n")
4884 DEFUN (no_neighbor_shutdown_msg
,
4885 no_neighbor_shutdown_msg_cmd
,
4886 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
4890 "Administratively shut down this neighbor\n"
4891 "Remove a shutdown message (RFC 8203)\n"
4892 "Shutdown message\n")
4896 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4897 PEER_FLAG_SHUTDOWN
);
4900 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
4901 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
4902 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4903 "Administratively shut down this neighbor\n")
4905 DEFUN(neighbor_shutdown_rtt
,
4906 neighbor_shutdown_rtt_cmd
,
4907 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt (1-65535) [count (1-255)]",
4910 "Administratively shut down this neighbor\n"
4911 "Shutdown if round-trip-time is higher than expected\n"
4912 "Round-trip-time in milliseconds\n"
4913 "Specify the number of keepalives before shutdown\n"
4914 "The number of keepalives with higher RTT to shutdown\n")
4921 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4924 return CMD_WARNING_CONFIG_FAILED
;
4926 peer
->rtt_expected
= strtol(argv
[idx_rtt
]->arg
, NULL
, 10);
4928 if (argv_find(argv
, argc
, "count", &idx_count
))
4929 peer
->rtt_keepalive_conf
=
4930 strtol(argv
[idx_count
+ 1]->arg
, NULL
, 10);
4932 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4933 PEER_FLAG_RTT_SHUTDOWN
);
4936 DEFUN(no_neighbor_shutdown_rtt
,
4937 no_neighbor_shutdown_rtt_cmd
,
4938 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown rtt [(1-65535) [count (1-255)]]",
4942 "Administratively shut down this neighbor\n"
4943 "Shutdown if round-trip-time is higher than expected\n"
4944 "Round-trip-time in milliseconds\n"
4945 "Specify the number of keepalives before shutdown\n"
4946 "The number of keepalives with higher RTT to shutdown\n")
4951 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4954 return CMD_WARNING_CONFIG_FAILED
;
4956 peer
->rtt_expected
= 0;
4957 peer
->rtt_keepalive_conf
= 1;
4959 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4960 PEER_FLAG_RTT_SHUTDOWN
);
4963 /* neighbor capability dynamic. */
4964 DEFUN (neighbor_capability_dynamic
,
4965 neighbor_capability_dynamic_cmd
,
4966 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
4969 "Advertise capability to the peer\n"
4970 "Advertise dynamic capability to this neighbor\n")
4973 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4974 PEER_FLAG_DYNAMIC_CAPABILITY
);
4977 DEFUN (no_neighbor_capability_dynamic
,
4978 no_neighbor_capability_dynamic_cmd
,
4979 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
4983 "Advertise capability to the peer\n"
4984 "Advertise dynamic capability to this neighbor\n")
4987 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4988 PEER_FLAG_DYNAMIC_CAPABILITY
);
4991 /* neighbor dont-capability-negotiate */
4992 DEFUN (neighbor_dont_capability_negotiate
,
4993 neighbor_dont_capability_negotiate_cmd
,
4994 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
4997 "Do not perform capability negotiation\n")
5000 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5001 PEER_FLAG_DONT_CAPABILITY
);
5004 DEFUN (no_neighbor_dont_capability_negotiate
,
5005 no_neighbor_dont_capability_negotiate_cmd
,
5006 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
5010 "Do not perform capability negotiation\n")
5013 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5014 PEER_FLAG_DONT_CAPABILITY
);
5017 /* neighbor capability extended next hop encoding */
5018 DEFUN (neighbor_capability_enhe
,
5019 neighbor_capability_enhe_cmd
,
5020 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5023 "Advertise capability to the peer\n"
5024 "Advertise extended next-hop capability to the peer\n")
5027 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5028 PEER_FLAG_CAPABILITY_ENHE
);
5031 DEFUN (no_neighbor_capability_enhe
,
5032 no_neighbor_capability_enhe_cmd
,
5033 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
5037 "Advertise capability to the peer\n"
5038 "Advertise extended next-hop capability to the peer\n")
5041 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5042 PEER_FLAG_CAPABILITY_ENHE
);
5045 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
5046 afi_t afi
, safi_t safi
, uint32_t flag
,
5052 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5054 return CMD_WARNING_CONFIG_FAILED
;
5057 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
5059 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
5061 return bgp_vty_return(vty
, ret
);
5064 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
5065 afi_t afi
, safi_t safi
, uint32_t flag
)
5067 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
5070 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
5071 afi_t afi
, safi_t safi
, uint32_t flag
)
5073 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
5076 /* neighbor capability orf prefix-list. */
5077 DEFUN (neighbor_capability_orf_prefix
,
5078 neighbor_capability_orf_prefix_cmd
,
5079 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5082 "Advertise capability to the peer\n"
5083 "Advertise ORF capability to the peer\n"
5084 "Advertise prefixlist ORF capability to this neighbor\n"
5085 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5086 "Capability to RECEIVE the ORF from this neighbor\n"
5087 "Capability to SEND the ORF to this neighbor\n")
5089 int idx_send_recv
= 5;
5090 char *peer_str
= argv
[1]->arg
;
5092 afi_t afi
= bgp_node_afi(vty
);
5093 safi_t safi
= bgp_node_safi(vty
);
5095 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5097 return CMD_WARNING_CONFIG_FAILED
;
5099 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5100 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5101 PEER_FLAG_ORF_PREFIX_SM
);
5103 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5104 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5105 PEER_FLAG_ORF_PREFIX_RM
);
5107 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5108 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5109 PEER_FLAG_ORF_PREFIX_SM
)
5110 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5111 PEER_FLAG_ORF_PREFIX_RM
);
5113 return CMD_WARNING_CONFIG_FAILED
;
5117 neighbor_capability_orf_prefix
,
5118 neighbor_capability_orf_prefix_hidden_cmd
,
5119 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5120 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5121 "Advertise capability to the peer\n"
5122 "Advertise ORF capability to the peer\n"
5123 "Advertise prefixlist ORF capability to this neighbor\n"
5124 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5125 "Capability to RECEIVE the ORF from this neighbor\n"
5126 "Capability to SEND the ORF to this neighbor\n")
5128 DEFUN (no_neighbor_capability_orf_prefix
,
5129 no_neighbor_capability_orf_prefix_cmd
,
5130 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5134 "Advertise capability to the peer\n"
5135 "Advertise ORF capability to the peer\n"
5136 "Advertise prefixlist ORF capability to this neighbor\n"
5137 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5138 "Capability to RECEIVE the ORF from this neighbor\n"
5139 "Capability to SEND the ORF to this neighbor\n")
5141 int idx_send_recv
= 6;
5142 char *peer_str
= argv
[2]->arg
;
5144 afi_t afi
= bgp_node_afi(vty
);
5145 safi_t safi
= bgp_node_safi(vty
);
5147 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5149 return CMD_WARNING_CONFIG_FAILED
;
5151 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
5152 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5153 PEER_FLAG_ORF_PREFIX_SM
);
5155 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
5156 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5157 PEER_FLAG_ORF_PREFIX_RM
);
5159 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
5160 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5161 PEER_FLAG_ORF_PREFIX_SM
)
5162 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5163 PEER_FLAG_ORF_PREFIX_RM
);
5165 return CMD_WARNING_CONFIG_FAILED
;
5169 no_neighbor_capability_orf_prefix
,
5170 no_neighbor_capability_orf_prefix_hidden_cmd
,
5171 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
5172 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5173 "Advertise capability to the peer\n"
5174 "Advertise ORF capability to the peer\n"
5175 "Advertise prefixlist ORF capability to this neighbor\n"
5176 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
5177 "Capability to RECEIVE the ORF from this neighbor\n"
5178 "Capability to SEND the ORF to this neighbor\n")
5180 /* neighbor next-hop-self. */
5181 DEFUN (neighbor_nexthop_self
,
5182 neighbor_nexthop_self_cmd
,
5183 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5186 "Disable the next hop calculation for this neighbor\n")
5189 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5190 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
5193 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
5194 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5195 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5196 "Disable the next hop calculation for this neighbor\n")
5198 /* neighbor next-hop-self. */
5199 DEFUN (neighbor_nexthop_self_force
,
5200 neighbor_nexthop_self_force_cmd
,
5201 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5204 "Disable the next hop calculation for this neighbor\n"
5205 "Set the next hop to self for reflected routes\n")
5208 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5210 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5213 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5214 neighbor_nexthop_self_force_hidden_cmd
,
5215 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5216 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5217 "Disable the next hop calculation for this neighbor\n"
5218 "Set the next hop to self for reflected routes\n")
5220 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
5221 neighbor_nexthop_self_all_hidden_cmd
,
5222 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5223 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5224 "Disable the next hop calculation for this neighbor\n"
5225 "Set the next hop to self for reflected routes\n")
5227 DEFUN (no_neighbor_nexthop_self
,
5228 no_neighbor_nexthop_self_cmd
,
5229 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5233 "Disable the next hop calculation for this neighbor\n")
5236 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5237 bgp_node_afi(vty
), bgp_node_safi(vty
),
5238 PEER_FLAG_NEXTHOP_SELF
);
5241 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
5242 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
5243 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5244 "Disable the next hop calculation for this neighbor\n")
5246 DEFUN (no_neighbor_nexthop_self_force
,
5247 no_neighbor_nexthop_self_force_cmd
,
5248 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5252 "Disable the next hop calculation for this neighbor\n"
5253 "Set the next hop to self for reflected routes\n")
5256 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5257 bgp_node_afi(vty
), bgp_node_safi(vty
),
5258 PEER_FLAG_FORCE_NEXTHOP_SELF
);
5261 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5262 no_neighbor_nexthop_self_force_hidden_cmd
,
5263 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
5264 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5265 "Disable the next hop calculation for this neighbor\n"
5266 "Set the next hop to self for reflected routes\n")
5268 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
5269 no_neighbor_nexthop_self_all_hidden_cmd
,
5270 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
5271 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5272 "Disable the next hop calculation for this neighbor\n"
5273 "Set the next hop to self for reflected routes\n")
5275 /* neighbor as-override */
5276 DEFUN (neighbor_as_override
,
5277 neighbor_as_override_cmd
,
5278 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5281 "Override ASNs in outbound updates if aspath equals remote-as\n")
5284 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5285 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
5288 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
5289 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5290 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5291 "Override ASNs in outbound updates if aspath equals remote-as\n")
5293 DEFUN (no_neighbor_as_override
,
5294 no_neighbor_as_override_cmd
,
5295 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5299 "Override ASNs in outbound updates if aspath equals remote-as\n")
5302 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5303 bgp_node_afi(vty
), bgp_node_safi(vty
),
5304 PEER_FLAG_AS_OVERRIDE
);
5307 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
5308 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
5309 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5310 "Override ASNs in outbound updates if aspath equals remote-as\n")
5312 /* neighbor remove-private-AS. */
5313 DEFUN (neighbor_remove_private_as
,
5314 neighbor_remove_private_as_cmd
,
5315 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5318 "Remove private ASNs in outbound updates\n")
5321 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5323 PEER_FLAG_REMOVE_PRIVATE_AS
);
5326 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
5327 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5328 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5329 "Remove private ASNs in outbound updates\n")
5331 DEFUN (neighbor_remove_private_as_all
,
5332 neighbor_remove_private_as_all_cmd
,
5333 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5336 "Remove private ASNs in outbound updates\n"
5337 "Apply to all AS numbers\n")
5340 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5342 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5345 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
5346 neighbor_remove_private_as_all_hidden_cmd
,
5347 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5348 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5349 "Remove private ASNs in outbound updates\n"
5350 "Apply to all AS numbers")
5352 DEFUN (neighbor_remove_private_as_replace_as
,
5353 neighbor_remove_private_as_replace_as_cmd
,
5354 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5357 "Remove private ASNs in outbound updates\n"
5358 "Replace private ASNs with our ASN in outbound updates\n")
5361 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5363 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5366 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
5367 neighbor_remove_private_as_replace_as_hidden_cmd
,
5368 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5369 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5370 "Remove private ASNs in outbound updates\n"
5371 "Replace private ASNs with our ASN in outbound updates\n")
5373 DEFUN (neighbor_remove_private_as_all_replace_as
,
5374 neighbor_remove_private_as_all_replace_as_cmd
,
5375 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5378 "Remove private ASNs in outbound updates\n"
5379 "Apply to all AS numbers\n"
5380 "Replace private ASNs with our ASN in outbound updates\n")
5383 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5385 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5389 neighbor_remove_private_as_all_replace_as
,
5390 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5391 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5392 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5393 "Remove private ASNs in outbound updates\n"
5394 "Apply to all AS numbers\n"
5395 "Replace private ASNs with our ASN in outbound updates\n")
5397 DEFUN (no_neighbor_remove_private_as
,
5398 no_neighbor_remove_private_as_cmd
,
5399 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5403 "Remove private ASNs in outbound updates\n")
5406 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5407 bgp_node_afi(vty
), bgp_node_safi(vty
),
5408 PEER_FLAG_REMOVE_PRIVATE_AS
);
5411 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
5412 no_neighbor_remove_private_as_hidden_cmd
,
5413 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
5414 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5415 "Remove private ASNs in outbound updates\n")
5417 DEFUN (no_neighbor_remove_private_as_all
,
5418 no_neighbor_remove_private_as_all_cmd
,
5419 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5423 "Remove private ASNs in outbound updates\n"
5424 "Apply to all AS numbers\n")
5427 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5428 bgp_node_afi(vty
), bgp_node_safi(vty
),
5429 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
5432 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
5433 no_neighbor_remove_private_as_all_hidden_cmd
,
5434 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
5435 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5436 "Remove private ASNs in outbound updates\n"
5437 "Apply to all AS numbers\n")
5439 DEFUN (no_neighbor_remove_private_as_replace_as
,
5440 no_neighbor_remove_private_as_replace_as_cmd
,
5441 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5445 "Remove private ASNs in outbound updates\n"
5446 "Replace private ASNs with our ASN in outbound updates\n")
5449 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5450 bgp_node_afi(vty
), bgp_node_safi(vty
),
5451 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
5454 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
5455 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
5456 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
5457 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5458 "Remove private ASNs in outbound updates\n"
5459 "Replace private ASNs with our ASN in outbound updates\n")
5461 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
5462 no_neighbor_remove_private_as_all_replace_as_cmd
,
5463 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5467 "Remove private ASNs in outbound updates\n"
5468 "Apply to all AS numbers\n"
5469 "Replace private ASNs with our ASN in outbound updates\n")
5472 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5473 bgp_node_afi(vty
), bgp_node_safi(vty
),
5474 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5478 no_neighbor_remove_private_as_all_replace_as
,
5479 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5480 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5481 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5482 "Remove private ASNs in outbound updates\n"
5483 "Apply to all AS numbers\n"
5484 "Replace private ASNs with our ASN in outbound updates\n")
5487 /* neighbor send-community. */
5488 DEFUN (neighbor_send_community
,
5489 neighbor_send_community_cmd
,
5490 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5493 "Send Community attribute to this neighbor\n")
5497 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5499 PEER_FLAG_SEND_COMMUNITY
);
5502 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
5503 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5504 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5505 "Send Community attribute to this neighbor\n")
5507 DEFUN (no_neighbor_send_community
,
5508 no_neighbor_send_community_cmd
,
5509 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5513 "Send Community attribute to this neighbor\n")
5517 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5518 bgp_node_afi(vty
), bgp_node_safi(vty
),
5519 PEER_FLAG_SEND_COMMUNITY
);
5522 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
5523 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5524 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5525 "Send Community attribute to this neighbor\n")
5527 /* neighbor send-community extended. */
5528 DEFUN (neighbor_send_community_type
,
5529 neighbor_send_community_type_cmd
,
5530 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5533 "Send Community attribute to this neighbor\n"
5534 "Send Standard and Extended Community attributes\n"
5535 "Send Standard, Large and Extended Community attributes\n"
5536 "Send Extended Community attributes\n"
5537 "Send Standard Community attributes\n"
5538 "Send Large Community attributes\n")
5540 const char *type
= argv
[argc
- 1]->text
;
5541 char *peer_str
= argv
[1]->arg
;
5543 afi_t afi
= bgp_node_afi(vty
);
5544 safi_t safi
= bgp_node_safi(vty
);
5546 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5548 return CMD_WARNING_CONFIG_FAILED
;
5550 if (strmatch(type
, "standard"))
5551 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5552 PEER_FLAG_SEND_COMMUNITY
);
5554 if (strmatch(type
, "extended"))
5555 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5556 PEER_FLAG_SEND_EXT_COMMUNITY
);
5558 if (strmatch(type
, "large"))
5559 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5560 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5562 if (strmatch(type
, "both")) {
5563 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5564 PEER_FLAG_SEND_COMMUNITY
)
5565 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5566 PEER_FLAG_SEND_EXT_COMMUNITY
);
5568 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5569 PEER_FLAG_SEND_COMMUNITY
)
5570 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5571 PEER_FLAG_SEND_EXT_COMMUNITY
)
5572 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5573 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5577 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
5578 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5579 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5580 "Send Community attribute to this neighbor\n"
5581 "Send Standard and Extended Community attributes\n"
5582 "Send Standard, Large and Extended Community attributes\n"
5583 "Send Extended Community attributes\n"
5584 "Send Standard Community attributes\n"
5585 "Send Large Community attributes\n")
5587 DEFUN (no_neighbor_send_community_type
,
5588 no_neighbor_send_community_type_cmd
,
5589 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5593 "Send Community attribute to this neighbor\n"
5594 "Send Standard and Extended Community attributes\n"
5595 "Send Standard, Large and Extended Community attributes\n"
5596 "Send Extended Community attributes\n"
5597 "Send Standard Community attributes\n"
5598 "Send Large Community attributes\n")
5600 const char *type
= argv
[argc
- 1]->text
;
5601 char *peer_str
= argv
[2]->arg
;
5603 afi_t afi
= bgp_node_afi(vty
);
5604 safi_t safi
= bgp_node_safi(vty
);
5606 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5608 return CMD_WARNING_CONFIG_FAILED
;
5610 if (strmatch(type
, "standard"))
5611 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5612 PEER_FLAG_SEND_COMMUNITY
);
5614 if (strmatch(type
, "extended"))
5615 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5616 PEER_FLAG_SEND_EXT_COMMUNITY
);
5618 if (strmatch(type
, "large"))
5619 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5620 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5622 if (strmatch(type
, "both")) {
5624 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5625 PEER_FLAG_SEND_COMMUNITY
)
5626 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5627 PEER_FLAG_SEND_EXT_COMMUNITY
);
5630 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5631 PEER_FLAG_SEND_COMMUNITY
)
5632 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5633 PEER_FLAG_SEND_EXT_COMMUNITY
)
5634 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5635 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5639 no_neighbor_send_community_type
,
5640 no_neighbor_send_community_type_hidden_cmd
,
5641 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5642 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5643 "Send Community attribute to this neighbor\n"
5644 "Send Standard and Extended Community attributes\n"
5645 "Send Standard, Large and Extended Community attributes\n"
5646 "Send Extended Community attributes\n"
5647 "Send Standard Community attributes\n"
5648 "Send Large Community attributes\n")
5650 /* neighbor soft-reconfig. */
5651 DEFUN (neighbor_soft_reconfiguration
,
5652 neighbor_soft_reconfiguration_cmd
,
5653 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5656 "Per neighbor soft reconfiguration\n"
5657 "Allow inbound soft reconfiguration for this neighbor\n")
5660 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5662 PEER_FLAG_SOFT_RECONFIG
);
5665 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
5666 neighbor_soft_reconfiguration_hidden_cmd
,
5667 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5668 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5669 "Per neighbor soft reconfiguration\n"
5670 "Allow inbound soft reconfiguration for this neighbor\n")
5672 DEFUN (no_neighbor_soft_reconfiguration
,
5673 no_neighbor_soft_reconfiguration_cmd
,
5674 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5678 "Per neighbor soft reconfiguration\n"
5679 "Allow inbound soft reconfiguration for this neighbor\n")
5682 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5683 bgp_node_afi(vty
), bgp_node_safi(vty
),
5684 PEER_FLAG_SOFT_RECONFIG
);
5687 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
5688 no_neighbor_soft_reconfiguration_hidden_cmd
,
5689 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5690 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5691 "Per neighbor soft reconfiguration\n"
5692 "Allow inbound soft reconfiguration for this neighbor\n")
5694 DEFUN (neighbor_route_reflector_client
,
5695 neighbor_route_reflector_client_cmd
,
5696 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5699 "Configure a neighbor as Route Reflector client\n")
5705 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5707 return CMD_WARNING_CONFIG_FAILED
;
5709 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5711 PEER_FLAG_REFLECTOR_CLIENT
);
5714 ALIAS_HIDDEN(neighbor_route_reflector_client
,
5715 neighbor_route_reflector_client_hidden_cmd
,
5716 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5717 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5718 "Configure a neighbor as Route Reflector client\n")
5720 DEFUN (no_neighbor_route_reflector_client
,
5721 no_neighbor_route_reflector_client_cmd
,
5722 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5726 "Configure a neighbor as Route Reflector client\n")
5729 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5730 bgp_node_afi(vty
), bgp_node_safi(vty
),
5731 PEER_FLAG_REFLECTOR_CLIENT
);
5734 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
5735 no_neighbor_route_reflector_client_hidden_cmd
,
5736 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5737 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5738 "Configure a neighbor as Route Reflector client\n")
5740 /* neighbor route-server-client. */
5741 DEFUN (neighbor_route_server_client
,
5742 neighbor_route_server_client_cmd
,
5743 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5746 "Configure a neighbor as Route Server client\n")
5751 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5753 return CMD_WARNING_CONFIG_FAILED
;
5754 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5756 PEER_FLAG_RSERVER_CLIENT
);
5759 ALIAS_HIDDEN(neighbor_route_server_client
,
5760 neighbor_route_server_client_hidden_cmd
,
5761 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5762 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5763 "Configure a neighbor as Route Server client\n")
5765 DEFUN (no_neighbor_route_server_client
,
5766 no_neighbor_route_server_client_cmd
,
5767 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5771 "Configure a neighbor as Route Server client\n")
5774 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5775 bgp_node_afi(vty
), bgp_node_safi(vty
),
5776 PEER_FLAG_RSERVER_CLIENT
);
5779 ALIAS_HIDDEN(no_neighbor_route_server_client
,
5780 no_neighbor_route_server_client_hidden_cmd
,
5781 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5782 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5783 "Configure a neighbor as Route Server client\n")
5785 DEFUN (neighbor_nexthop_local_unchanged
,
5786 neighbor_nexthop_local_unchanged_cmd
,
5787 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
5790 "Configure treatment of outgoing link-local nexthop attribute\n"
5791 "Leave link-local nexthop unchanged for this peer\n")
5794 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5796 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
5799 DEFUN (no_neighbor_nexthop_local_unchanged
,
5800 no_neighbor_nexthop_local_unchanged_cmd
,
5801 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
5805 "Configure treatment of outgoing link-local-nexthop attribute\n"
5806 "Leave link-local nexthop unchanged for this peer\n")
5809 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5810 bgp_node_afi(vty
), bgp_node_safi(vty
),
5811 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
5814 DEFUN (neighbor_attr_unchanged
,
5815 neighbor_attr_unchanged_cmd
,
5816 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
5819 "BGP attribute is propagated unchanged to this neighbor\n"
5820 "As-path attribute\n"
5821 "Nexthop attribute\n"
5825 char *peer_str
= argv
[1]->arg
;
5827 bool aspath
= false;
5828 bool nexthop
= false;
5830 afi_t afi
= bgp_node_afi(vty
);
5831 safi_t safi
= bgp_node_safi(vty
);
5834 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5836 return CMD_WARNING_CONFIG_FAILED
;
5838 if (argv_find(argv
, argc
, "as-path", &idx
))
5842 if (argv_find(argv
, argc
, "next-hop", &idx
))
5846 if (argv_find(argv
, argc
, "med", &idx
))
5849 /* no flags means all of them! */
5850 if (!aspath
&& !nexthop
&& !med
) {
5851 ret
= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5852 PEER_FLAG_AS_PATH_UNCHANGED
);
5853 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5854 PEER_FLAG_NEXTHOP_UNCHANGED
);
5855 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5856 PEER_FLAG_MED_UNCHANGED
);
5859 if (peer_af_flag_check(peer
, afi
, safi
,
5860 PEER_FLAG_AS_PATH_UNCHANGED
)) {
5861 ret
|= peer_af_flag_unset_vty(
5862 vty
, peer_str
, afi
, safi
,
5863 PEER_FLAG_AS_PATH_UNCHANGED
);
5866 ret
|= peer_af_flag_set_vty(
5867 vty
, peer_str
, afi
, safi
,
5868 PEER_FLAG_AS_PATH_UNCHANGED
);
5871 if (peer_af_flag_check(peer
, afi
, safi
,
5872 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
5873 ret
|= peer_af_flag_unset_vty(
5874 vty
, peer_str
, afi
, safi
,
5875 PEER_FLAG_NEXTHOP_UNCHANGED
);
5878 ret
|= peer_af_flag_set_vty(
5879 vty
, peer_str
, afi
, safi
,
5880 PEER_FLAG_NEXTHOP_UNCHANGED
);
5883 if (peer_af_flag_check(peer
, afi
, safi
,
5884 PEER_FLAG_MED_UNCHANGED
)) {
5885 ret
|= peer_af_flag_unset_vty(
5886 vty
, peer_str
, afi
, safi
,
5887 PEER_FLAG_MED_UNCHANGED
);
5890 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5891 PEER_FLAG_MED_UNCHANGED
);
5898 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
5899 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
5900 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5901 "BGP attribute is propagated unchanged to this neighbor\n"
5902 "As-path attribute\n"
5903 "Nexthop attribute\n"
5906 DEFUN (no_neighbor_attr_unchanged
,
5907 no_neighbor_attr_unchanged_cmd
,
5908 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
5912 "BGP attribute is propagated unchanged to this neighbor\n"
5913 "As-path attribute\n"
5914 "Nexthop attribute\n"
5918 char *peer_str
= argv
[2]->arg
;
5920 bool aspath
= false;
5921 bool nexthop
= false;
5923 afi_t afi
= bgp_node_afi(vty
);
5924 safi_t safi
= bgp_node_safi(vty
);
5927 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5929 return CMD_WARNING_CONFIG_FAILED
;
5931 if (argv_find(argv
, argc
, "as-path", &idx
))
5935 if (argv_find(argv
, argc
, "next-hop", &idx
))
5939 if (argv_find(argv
, argc
, "med", &idx
))
5942 if (!aspath
&& !nexthop
&& !med
) // no flags means all of them!
5943 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5944 PEER_FLAG_AS_PATH_UNCHANGED
)
5945 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5946 PEER_FLAG_NEXTHOP_UNCHANGED
)
5947 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5948 PEER_FLAG_MED_UNCHANGED
);
5951 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5952 PEER_FLAG_AS_PATH_UNCHANGED
);
5955 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5956 PEER_FLAG_NEXTHOP_UNCHANGED
);
5959 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5960 PEER_FLAG_MED_UNCHANGED
);
5966 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
5967 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
5968 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5969 "BGP attribute is propagated unchanged to this neighbor\n"
5970 "As-path attribute\n"
5971 "Nexthop attribute\n"
5974 /* EBGP multihop configuration. */
5975 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
5976 const char *ttl_str
)
5981 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5983 return CMD_WARNING_CONFIG_FAILED
;
5986 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
5991 ttl
= strtoul(ttl_str
, NULL
, 10);
5993 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
5996 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
6000 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6002 return CMD_WARNING_CONFIG_FAILED
;
6004 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
6007 /* neighbor ebgp-multihop. */
6008 DEFUN (neighbor_ebgp_multihop
,
6009 neighbor_ebgp_multihop_cmd
,
6010 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
6013 "Allow EBGP neighbors not on directly connected networks\n")
6016 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6019 DEFUN (neighbor_ebgp_multihop_ttl
,
6020 neighbor_ebgp_multihop_ttl_cmd
,
6021 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
6024 "Allow EBGP neighbors not on directly connected networks\n"
6025 "maximum hop count\n")
6029 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
6030 argv
[idx_number
]->arg
);
6033 DEFUN (no_neighbor_ebgp_multihop
,
6034 no_neighbor_ebgp_multihop_cmd
,
6035 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
6039 "Allow EBGP neighbors not on directly connected networks\n"
6040 "maximum hop count\n")
6043 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
6047 /* disable-connected-check */
6048 DEFUN (neighbor_disable_connected_check
,
6049 neighbor_disable_connected_check_cmd
,
6050 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6053 "one-hop away EBGP peer using loopback address\n"
6054 "Enforce EBGP neighbors perform multihop\n")
6057 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6058 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6061 DEFUN (no_neighbor_disable_connected_check
,
6062 no_neighbor_disable_connected_check_cmd
,
6063 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
6067 "one-hop away EBGP peer using loopback address\n"
6068 "Enforce EBGP neighbors perform multihop\n")
6071 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6072 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
6076 /* enforce-first-as */
6077 DEFUN (neighbor_enforce_first_as
,
6078 neighbor_enforce_first_as_cmd
,
6079 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6082 "Enforce the first AS for EBGP routes\n")
6086 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6087 PEER_FLAG_ENFORCE_FIRST_AS
);
6090 DEFUN (no_neighbor_enforce_first_as
,
6091 no_neighbor_enforce_first_as_cmd
,
6092 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
6096 "Enforce the first AS for EBGP routes\n")
6100 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6101 PEER_FLAG_ENFORCE_FIRST_AS
);
6105 DEFUN (neighbor_description
,
6106 neighbor_description_cmd
,
6107 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6110 "Neighbor specific description\n"
6111 "Up to 80 characters describing this neighbor\n")
6118 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6120 return CMD_WARNING_CONFIG_FAILED
;
6122 str
= argv_concat(argv
, argc
, idx_line
);
6124 peer_description_set(peer
, str
);
6126 XFREE(MTYPE_TMP
, str
);
6131 DEFUN (no_neighbor_description
,
6132 no_neighbor_description_cmd
,
6133 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
6137 "Neighbor specific description\n")
6142 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6144 return CMD_WARNING_CONFIG_FAILED
;
6146 peer_description_unset(peer
);
6151 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
6152 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
6153 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6154 "Neighbor specific description\n"
6155 "Up to 80 characters describing this neighbor\n")
6157 /* Neighbor update-source. */
6158 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
6159 const char *source_str
)
6165 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6167 return CMD_WARNING_CONFIG_FAILED
;
6173 if (str2sockunion(source_str
, &su
) == 0)
6174 peer_update_source_addr_set(peer
, &su
);
6176 if (str2prefix(source_str
, &p
)) {
6178 "%% Invalid update-source, remove prefix length \n");
6179 return CMD_WARNING_CONFIG_FAILED
;
6181 peer_update_source_if_set(peer
, source_str
);
6184 peer_update_source_unset(peer
);
6189 #define BGP_UPDATE_SOURCE_HELP_STR \
6192 "Interface name (requires zebra to be running)\n"
6194 DEFUN (neighbor_update_source
,
6195 neighbor_update_source_cmd
,
6196 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
6199 "Source of routing updates\n"
6200 BGP_UPDATE_SOURCE_HELP_STR
)
6204 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
6205 argv
[idx_peer_2
]->arg
);
6208 DEFUN (no_neighbor_update_source
,
6209 no_neighbor_update_source_cmd
,
6210 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
6214 "Source of routing updates\n"
6215 BGP_UPDATE_SOURCE_HELP_STR
)
6218 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6221 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
6222 afi_t afi
, safi_t safi
,
6223 const char *rmap
, int set
)
6227 struct route_map
*route_map
= NULL
;
6229 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
6231 return CMD_WARNING_CONFIG_FAILED
;
6235 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
6236 ret
= peer_default_originate_set(peer
, afi
, safi
,
6239 ret
= peer_default_originate_unset(peer
, afi
, safi
);
6241 return bgp_vty_return(vty
, ret
);
6244 /* neighbor default-originate. */
6245 DEFUN (neighbor_default_originate
,
6246 neighbor_default_originate_cmd
,
6247 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6250 "Originate default route to this neighbor\n")
6253 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6255 bgp_node_safi(vty
), NULL
, 1);
6258 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
6259 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
6260 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6261 "Originate default route to this neighbor\n")
6263 DEFUN (neighbor_default_originate_rmap
,
6264 neighbor_default_originate_rmap_cmd
,
6265 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
6268 "Originate default route to this neighbor\n"
6269 "Route-map to specify criteria to originate default\n"
6274 return peer_default_originate_set_vty(
6275 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6276 argv
[idx_word
]->arg
, 1);
6280 neighbor_default_originate_rmap
,
6281 neighbor_default_originate_rmap_hidden_cmd
,
6282 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
6283 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6284 "Originate default route to this neighbor\n"
6285 "Route-map to specify criteria to originate default\n"
6288 DEFUN (no_neighbor_default_originate
,
6289 no_neighbor_default_originate_cmd
,
6290 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
6294 "Originate default route to this neighbor\n"
6295 "Route-map to specify criteria to originate default\n"
6299 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
6301 bgp_node_safi(vty
), NULL
, 0);
6305 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
6306 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
6307 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6308 "Originate default route to this neighbor\n"
6309 "Route-map to specify criteria to originate default\n"
6313 /* Set neighbor's BGP port. */
6314 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
6315 const char *port_str
)
6321 peer
= peer_lookup_vty(vty
, ip_str
);
6323 return CMD_WARNING_CONFIG_FAILED
;
6326 sp
= getservbyname("bgp", "tcp");
6327 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
6329 port
= strtoul(port_str
, NULL
, 10);
6332 peer_port_set(peer
, port
);
6337 /* Set specified peer's BGP port. */
6338 DEFUN (neighbor_port
,
6340 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
6343 "Neighbor's BGP port\n"
6344 "TCP port number\n")
6348 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
6349 argv
[idx_number
]->arg
);
6352 DEFUN (no_neighbor_port
,
6353 no_neighbor_port_cmd
,
6354 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
6358 "Neighbor's BGP port\n"
6359 "TCP port number\n")
6362 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
6366 /* neighbor weight. */
6367 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6368 safi_t safi
, const char *weight_str
)
6372 unsigned long weight
;
6374 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6376 return CMD_WARNING_CONFIG_FAILED
;
6378 weight
= strtoul(weight_str
, NULL
, 10);
6380 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
6381 return bgp_vty_return(vty
, ret
);
6384 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6390 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6392 return CMD_WARNING_CONFIG_FAILED
;
6394 ret
= peer_weight_unset(peer
, afi
, safi
);
6395 return bgp_vty_return(vty
, ret
);
6398 DEFUN (neighbor_weight
,
6399 neighbor_weight_cmd
,
6400 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
6403 "Set default weight for routes from this neighbor\n"
6408 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6409 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
6412 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
6413 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
6414 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6415 "Set default weight for routes from this neighbor\n"
6418 DEFUN (no_neighbor_weight
,
6419 no_neighbor_weight_cmd
,
6420 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
6424 "Set default weight for routes from this neighbor\n"
6428 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
6429 bgp_node_afi(vty
), bgp_node_safi(vty
));
6432 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
6433 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
6434 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6435 "Set default weight for routes from this neighbor\n"
6439 /* Override capability negotiation. */
6440 DEFUN (neighbor_override_capability
,
6441 neighbor_override_capability_cmd
,
6442 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
6445 "Override capability negotiation result\n")
6448 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6449 PEER_FLAG_OVERRIDE_CAPABILITY
);
6452 DEFUN (no_neighbor_override_capability
,
6453 no_neighbor_override_capability_cmd
,
6454 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
6458 "Override capability negotiation result\n")
6461 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6462 PEER_FLAG_OVERRIDE_CAPABILITY
);
6465 DEFUN (neighbor_strict_capability
,
6466 neighbor_strict_capability_cmd
,
6467 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
6470 "Strict capability negotiation match\n")
6474 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6475 PEER_FLAG_STRICT_CAP_MATCH
);
6478 DEFUN (no_neighbor_strict_capability
,
6479 no_neighbor_strict_capability_cmd
,
6480 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
6484 "Strict capability negotiation match\n")
6488 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6489 PEER_FLAG_STRICT_CAP_MATCH
);
6492 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
6493 const char *keep_str
, const char *hold_str
)
6500 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6502 return CMD_WARNING_CONFIG_FAILED
;
6504 keepalive
= strtoul(keep_str
, NULL
, 10);
6505 holdtime
= strtoul(hold_str
, NULL
, 10);
6507 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
6509 return bgp_vty_return(vty
, ret
);
6512 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
6517 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6519 return CMD_WARNING_CONFIG_FAILED
;
6521 ret
= peer_timers_unset(peer
);
6523 return bgp_vty_return(vty
, ret
);
6526 DEFUN (neighbor_timers
,
6527 neighbor_timers_cmd
,
6528 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
6531 "BGP per neighbor timers\n"
6532 "Keepalive interval\n"
6537 int idx_number_2
= 4;
6538 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
6539 argv
[idx_number
]->arg
,
6540 argv
[idx_number_2
]->arg
);
6543 DEFUN (no_neighbor_timers
,
6544 no_neighbor_timers_cmd
,
6545 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
6549 "BGP per neighbor timers\n"
6550 "Keepalive interval\n"
6554 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
6558 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
6559 const char *time_str
)
6565 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6567 return CMD_WARNING_CONFIG_FAILED
;
6569 connect
= strtoul(time_str
, NULL
, 10);
6571 ret
= peer_timers_connect_set(peer
, connect
);
6573 return bgp_vty_return(vty
, ret
);
6576 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
6581 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6583 return CMD_WARNING_CONFIG_FAILED
;
6585 ret
= peer_timers_connect_unset(peer
);
6587 return bgp_vty_return(vty
, ret
);
6590 DEFUN (neighbor_timers_connect
,
6591 neighbor_timers_connect_cmd
,
6592 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
6595 "BGP per neighbor timers\n"
6596 "BGP connect timer\n"
6601 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
6602 argv
[idx_number
]->arg
);
6605 DEFUN (no_neighbor_timers_connect
,
6606 no_neighbor_timers_connect_cmd
,
6607 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
6611 "BGP per neighbor timers\n"
6612 "BGP connect timer\n"
6616 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
6620 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
6621 const char *time_str
, int set
)
6625 uint32_t routeadv
= 0;
6627 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6629 return CMD_WARNING_CONFIG_FAILED
;
6632 routeadv
= strtoul(time_str
, NULL
, 10);
6635 ret
= peer_advertise_interval_set(peer
, routeadv
);
6637 ret
= peer_advertise_interval_unset(peer
);
6639 return bgp_vty_return(vty
, ret
);
6642 DEFUN (neighbor_advertise_interval
,
6643 neighbor_advertise_interval_cmd
,
6644 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
6647 "Minimum interval between sending BGP routing updates\n"
6648 "time in seconds\n")
6652 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
6653 argv
[idx_number
]->arg
, 1);
6656 DEFUN (no_neighbor_advertise_interval
,
6657 no_neighbor_advertise_interval_cmd
,
6658 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
6662 "Minimum interval between sending BGP routing updates\n"
6663 "time in seconds\n")
6666 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
6670 /* Time to wait before processing route-map updates */
6671 DEFUN (bgp_set_route_map_delay_timer
,
6672 bgp_set_route_map_delay_timer_cmd
,
6673 "bgp route-map delay-timer (0-600)",
6675 "BGP route-map delay timer\n"
6676 "Time in secs to wait before processing route-map changes\n"
6677 "0 disables the timer, no route updates happen when route-maps change\n")
6680 uint32_t rmap_delay_timer
;
6682 if (argv
[idx_number
]->arg
) {
6683 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6684 bm
->rmap_update_timer
= rmap_delay_timer
;
6686 /* if the dynamic update handling is being disabled, and a timer
6688 * running, stop the timer and act as if the timer has already
6691 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
6692 BGP_TIMER_OFF(bm
->t_rmap_update
);
6693 thread_execute(bm
->master
, bgp_route_map_update_timer
,
6698 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
6699 return CMD_WARNING_CONFIG_FAILED
;
6703 DEFUN (no_bgp_set_route_map_delay_timer
,
6704 no_bgp_set_route_map_delay_timer_cmd
,
6705 "no bgp route-map delay-timer [(0-600)]",
6708 "Default BGP route-map delay timer\n"
6709 "Reset to default time to wait for processing route-map changes\n"
6710 "0 disables the timer, no route updates happen when route-maps change\n")
6713 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
6718 /* neighbor interface */
6719 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
6724 peer
= peer_lookup_vty(vty
, ip_str
);
6725 if (!peer
|| peer
->conf_if
) {
6726 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
6727 return CMD_WARNING_CONFIG_FAILED
;
6731 peer_interface_set(peer
, str
);
6733 peer_interface_unset(peer
);
6738 DEFUN (neighbor_interface
,
6739 neighbor_interface_cmd
,
6740 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
6748 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
6751 DEFUN (no_neighbor_interface
,
6752 no_neighbor_interface_cmd
,
6753 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
6761 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6764 DEFUN (neighbor_distribute_list
,
6765 neighbor_distribute_list_cmd
,
6766 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
6769 "Filter updates to/from this neighbor\n"
6770 "IP access-list number\n"
6771 "IP access-list number (expanded range)\n"
6772 "IP Access-list name\n"
6773 "Filter incoming updates\n"
6774 "Filter outgoing updates\n")
6781 const char *pstr
= argv
[idx_peer
]->arg
;
6782 const char *acl
= argv
[idx_acl
]->arg
;
6783 const char *inout
= argv
[argc
- 1]->text
;
6785 peer
= peer_and_group_lookup_vty(vty
, pstr
);
6787 return CMD_WARNING_CONFIG_FAILED
;
6789 /* Check filter direction. */
6790 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
6791 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6794 return bgp_vty_return(vty
, ret
);
6798 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
6799 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
6800 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6801 "Filter updates to/from this neighbor\n"
6802 "IP access-list number\n"
6803 "IP access-list number (expanded range)\n"
6804 "IP Access-list name\n"
6805 "Filter incoming updates\n"
6806 "Filter outgoing updates\n")
6808 DEFUN (no_neighbor_distribute_list
,
6809 no_neighbor_distribute_list_cmd
,
6810 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
6814 "Filter updates to/from this neighbor\n"
6815 "IP access-list number\n"
6816 "IP access-list number (expanded range)\n"
6817 "IP Access-list name\n"
6818 "Filter incoming updates\n"
6819 "Filter outgoing updates\n")
6825 const char *pstr
= argv
[idx_peer
]->arg
;
6826 const char *inout
= argv
[argc
- 1]->text
;
6828 peer
= peer_and_group_lookup_vty(vty
, pstr
);
6830 return CMD_WARNING_CONFIG_FAILED
;
6832 /* Check filter direction. */
6833 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
6834 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6837 return bgp_vty_return(vty
, ret
);
6841 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
6842 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
6843 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6844 "Filter updates to/from this neighbor\n"
6845 "IP access-list number\n"
6846 "IP access-list number (expanded range)\n"
6847 "IP Access-list name\n"
6848 "Filter incoming updates\n"
6849 "Filter outgoing updates\n")
6851 /* Set prefix list to the peer. */
6852 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
6853 afi_t afi
, safi_t safi
,
6854 const char *name_str
,
6855 const char *direct_str
)
6858 int direct
= FILTER_IN
;
6861 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6863 return CMD_WARNING_CONFIG_FAILED
;
6865 /* Check filter direction. */
6866 if (strncmp(direct_str
, "i", 1) == 0)
6868 else if (strncmp(direct_str
, "o", 1) == 0)
6869 direct
= FILTER_OUT
;
6871 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
6873 return bgp_vty_return(vty
, ret
);
6876 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
6877 afi_t afi
, safi_t safi
,
6878 const char *direct_str
)
6882 int direct
= FILTER_IN
;
6884 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6886 return CMD_WARNING_CONFIG_FAILED
;
6888 /* Check filter direction. */
6889 if (strncmp(direct_str
, "i", 1) == 0)
6891 else if (strncmp(direct_str
, "o", 1) == 0)
6892 direct
= FILTER_OUT
;
6894 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
6896 return bgp_vty_return(vty
, ret
);
6899 DEFUN (neighbor_prefix_list
,
6900 neighbor_prefix_list_cmd
,
6901 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
6904 "Filter updates to/from this neighbor\n"
6905 "Name of a prefix list\n"
6906 "Filter incoming updates\n"
6907 "Filter outgoing updates\n")
6912 return peer_prefix_list_set_vty(
6913 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6914 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
6917 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
6918 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
6919 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6920 "Filter updates to/from this neighbor\n"
6921 "Name of a prefix list\n"
6922 "Filter incoming updates\n"
6923 "Filter outgoing updates\n")
6925 DEFUN (no_neighbor_prefix_list
,
6926 no_neighbor_prefix_list_cmd
,
6927 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
6931 "Filter updates to/from this neighbor\n"
6932 "Name of a prefix list\n"
6933 "Filter incoming updates\n"
6934 "Filter outgoing updates\n")
6938 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
6939 bgp_node_afi(vty
), bgp_node_safi(vty
),
6940 argv
[idx_in_out
]->arg
);
6943 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
6944 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
6945 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6946 "Filter updates to/from this neighbor\n"
6947 "Name of a prefix list\n"
6948 "Filter incoming updates\n"
6949 "Filter outgoing updates\n")
6951 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6952 safi_t safi
, const char *name_str
,
6953 const char *direct_str
)
6957 int direct
= FILTER_IN
;
6959 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6961 return CMD_WARNING_CONFIG_FAILED
;
6963 /* Check filter direction. */
6964 if (strncmp(direct_str
, "i", 1) == 0)
6966 else if (strncmp(direct_str
, "o", 1) == 0)
6967 direct
= FILTER_OUT
;
6969 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
6971 return bgp_vty_return(vty
, ret
);
6974 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6975 safi_t safi
, const char *direct_str
)
6979 int direct
= FILTER_IN
;
6981 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6983 return CMD_WARNING_CONFIG_FAILED
;
6985 /* Check filter direction. */
6986 if (strncmp(direct_str
, "i", 1) == 0)
6988 else if (strncmp(direct_str
, "o", 1) == 0)
6989 direct
= FILTER_OUT
;
6991 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
6993 return bgp_vty_return(vty
, ret
);
6996 DEFUN (neighbor_filter_list
,
6997 neighbor_filter_list_cmd
,
6998 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7001 "Establish BGP filters\n"
7002 "AS path access-list name\n"
7003 "Filter incoming routes\n"
7004 "Filter outgoing routes\n")
7009 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
7010 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
7011 argv
[idx_in_out
]->arg
);
7014 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
7015 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7016 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7017 "Establish BGP filters\n"
7018 "AS path access-list name\n"
7019 "Filter incoming routes\n"
7020 "Filter outgoing routes\n")
7022 DEFUN (no_neighbor_filter_list
,
7023 no_neighbor_filter_list_cmd
,
7024 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7028 "Establish BGP filters\n"
7029 "AS path access-list name\n"
7030 "Filter incoming routes\n"
7031 "Filter outgoing routes\n")
7035 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
7036 bgp_node_afi(vty
), bgp_node_safi(vty
),
7037 argv
[idx_in_out
]->arg
);
7040 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
7041 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
7042 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7043 "Establish BGP filters\n"
7044 "AS path access-list name\n"
7045 "Filter incoming routes\n"
7046 "Filter outgoing routes\n")
7048 /* Set route-map to the peer. */
7049 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
7050 afi_t afi
, safi_t safi
, const char *name_str
,
7051 const char *direct_str
)
7055 int direct
= RMAP_IN
;
7056 struct route_map
*route_map
;
7058 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7060 return CMD_WARNING_CONFIG_FAILED
;
7062 /* Check filter direction. */
7063 if (strncmp(direct_str
, "in", 2) == 0)
7065 else if (strncmp(direct_str
, "o", 1) == 0)
7068 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7069 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
7071 return bgp_vty_return(vty
, ret
);
7074 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7075 afi_t afi
, safi_t safi
,
7076 const char *direct_str
)
7080 int direct
= RMAP_IN
;
7082 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7084 return CMD_WARNING_CONFIG_FAILED
;
7086 /* Check filter direction. */
7087 if (strncmp(direct_str
, "in", 2) == 0)
7089 else if (strncmp(direct_str
, "o", 1) == 0)
7092 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
7094 return bgp_vty_return(vty
, ret
);
7097 DEFUN (neighbor_route_map
,
7098 neighbor_route_map_cmd
,
7099 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7102 "Apply route map to neighbor\n"
7103 "Name of route map\n"
7104 "Apply map to incoming routes\n"
7105 "Apply map to outbound routes\n")
7110 return peer_route_map_set_vty(
7111 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7112 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
7115 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
7116 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7117 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7118 "Apply route map to neighbor\n"
7119 "Name of route map\n"
7120 "Apply map to incoming routes\n"
7121 "Apply map to outbound routes\n")
7123 DEFUN (no_neighbor_route_map
,
7124 no_neighbor_route_map_cmd
,
7125 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7129 "Apply route map to neighbor\n"
7130 "Name of route map\n"
7131 "Apply map to incoming routes\n"
7132 "Apply map to outbound routes\n")
7136 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7137 bgp_node_afi(vty
), bgp_node_safi(vty
),
7138 argv
[idx_in_out
]->arg
);
7141 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
7142 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
7143 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7144 "Apply route map to neighbor\n"
7145 "Name of route map\n"
7146 "Apply map to incoming routes\n"
7147 "Apply map to outbound routes\n")
7149 /* Set unsuppress-map to the peer. */
7150 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
7151 afi_t afi
, safi_t safi
,
7152 const char *name_str
)
7156 struct route_map
*route_map
;
7158 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7160 return CMD_WARNING_CONFIG_FAILED
;
7162 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
7163 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
7165 return bgp_vty_return(vty
, ret
);
7168 /* Unset route-map from the peer. */
7169 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
7170 afi_t afi
, safi_t safi
)
7175 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7177 return CMD_WARNING_CONFIG_FAILED
;
7179 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
7181 return bgp_vty_return(vty
, ret
);
7184 DEFUN (neighbor_unsuppress_map
,
7185 neighbor_unsuppress_map_cmd
,
7186 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7189 "Route-map to selectively unsuppress suppressed routes\n"
7190 "Name of route map\n")
7194 return peer_unsuppress_map_set_vty(
7195 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7196 argv
[idx_word
]->arg
);
7199 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
7200 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7201 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7202 "Route-map to selectively unsuppress suppressed routes\n"
7203 "Name of route map\n")
7205 DEFUN (no_neighbor_unsuppress_map
,
7206 no_neighbor_unsuppress_map_cmd
,
7207 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7211 "Route-map to selectively unsuppress suppressed routes\n"
7212 "Name of route map\n")
7215 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
7217 bgp_node_safi(vty
));
7220 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
7221 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
7222 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7223 "Route-map to selectively unsuppress suppressed routes\n"
7224 "Name of route map\n")
7226 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
7227 afi_t afi
, safi_t safi
,
7228 const char *num_str
,
7229 const char *threshold_str
, int warning
,
7230 const char *restart_str
,
7231 const char *force_str
)
7239 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7241 return CMD_WARNING_CONFIG_FAILED
;
7243 max
= strtoul(num_str
, NULL
, 10);
7245 threshold
= atoi(threshold_str
);
7247 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
7250 restart
= atoi(restart_str
);
7254 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
7255 restart
, force_str
? true : false);
7257 return bgp_vty_return(vty
, ret
);
7260 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
7261 afi_t afi
, safi_t safi
)
7266 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
7268 return CMD_WARNING_CONFIG_FAILED
;
7270 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
7272 return bgp_vty_return(vty
, ret
);
7275 /* Maximum number of prefix to be sent to the neighbor. */
7276 DEFUN(neighbor_maximum_prefix_out
,
7277 neighbor_maximum_prefix_out_cmd
,
7278 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
7281 "Maximum number of prefixes to be sent to this peer\n"
7282 "Maximum no. of prefix limit\n")
7288 afi_t afi
= bgp_node_afi(vty
);
7289 safi_t safi
= bgp_node_safi(vty
);
7291 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7293 return CMD_WARNING_CONFIG_FAILED
;
7295 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7297 SET_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
);
7298 peer
->pmax_out
[afi
][safi
] = max
;
7303 DEFUN(no_neighbor_maximum_prefix_out
,
7304 no_neighbor_maximum_prefix_out_cmd
,
7305 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out",
7309 "Maximum number of prefixes to be sent to this peer\n")
7313 afi_t afi
= bgp_node_afi(vty
);
7314 safi_t safi
= bgp_node_safi(vty
);
7316 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7318 return CMD_WARNING_CONFIG_FAILED
;
7320 UNSET_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
);
7321 peer
->pmax_out
[afi
][safi
] = 0;
7326 /* Maximum number of prefix configuration. Prefix count is different
7327 for each peer configuration. So this configuration can be set for
7328 each peer configuration. */
7329 DEFUN (neighbor_maximum_prefix
,
7330 neighbor_maximum_prefix_cmd
,
7331 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
7334 "Maximum number of prefix accept from this peer\n"
7335 "maximum no. of prefix limit\n"
7336 "Force checking all received routes not only accepted\n")
7343 if (argv_find(argv
, argc
, "force", &idx_force
))
7344 force
= argv
[idx_force
]->arg
;
7346 return peer_maximum_prefix_set_vty(
7347 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7348 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
7351 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
7352 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
7353 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7354 "Maximum number of prefix accept from this peer\n"
7355 "maximum no. of prefix limit\n"
7356 "Force checking all received routes not only accepted\n")
7358 DEFUN (neighbor_maximum_prefix_threshold
,
7359 neighbor_maximum_prefix_threshold_cmd
,
7360 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
7363 "Maximum number of prefix accept from this peer\n"
7364 "maximum no. of prefix limit\n"
7365 "Threshold value (%) at which to generate a warning msg\n"
7366 "Force checking all received routes not only accepted\n")
7370 int idx_number_2
= 4;
7374 if (argv_find(argv
, argc
, "force", &idx_force
))
7375 force
= argv
[idx_force
]->arg
;
7377 return peer_maximum_prefix_set_vty(
7378 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7379 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
7383 neighbor_maximum_prefix_threshold
,
7384 neighbor_maximum_prefix_threshold_hidden_cmd
,
7385 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
7386 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7387 "Maximum number of prefix accept from this peer\n"
7388 "maximum no. of prefix limit\n"
7389 "Threshold value (%) at which to generate a warning msg\n"
7390 "Force checking all received routes not only accepted\n")
7392 DEFUN (neighbor_maximum_prefix_warning
,
7393 neighbor_maximum_prefix_warning_cmd
,
7394 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
7397 "Maximum number of prefix accept from this peer\n"
7398 "maximum no. of prefix limit\n"
7399 "Only give warning message when limit is exceeded\n"
7400 "Force checking all received routes not only accepted\n")
7407 if (argv_find(argv
, argc
, "force", &idx_force
))
7408 force
= argv
[idx_force
]->arg
;
7410 return peer_maximum_prefix_set_vty(
7411 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7412 argv
[idx_number
]->arg
, NULL
, 1, NULL
, force
);
7416 neighbor_maximum_prefix_warning
,
7417 neighbor_maximum_prefix_warning_hidden_cmd
,
7418 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
7419 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7420 "Maximum number of prefix accept from this peer\n"
7421 "maximum no. of prefix limit\n"
7422 "Only give warning message when limit is exceeded\n"
7423 "Force checking all received routes not only accepted\n")
7425 DEFUN (neighbor_maximum_prefix_threshold_warning
,
7426 neighbor_maximum_prefix_threshold_warning_cmd
,
7427 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
7430 "Maximum number of prefix accept from this peer\n"
7431 "maximum no. of prefix limit\n"
7432 "Threshold value (%) at which to generate a warning msg\n"
7433 "Only give warning message when limit is exceeded\n"
7434 "Force checking all received routes not only accepted\n")
7438 int idx_number_2
= 4;
7442 if (argv_find(argv
, argc
, "force", &idx_force
))
7443 force
= argv
[idx_force
]->arg
;
7445 return peer_maximum_prefix_set_vty(
7446 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7447 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
7451 neighbor_maximum_prefix_threshold_warning
,
7452 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
7453 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
7454 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7455 "Maximum number of prefix accept from this peer\n"
7456 "maximum no. of prefix limit\n"
7457 "Threshold value (%) at which to generate a warning msg\n"
7458 "Only give warning message when limit is exceeded\n"
7459 "Force checking all received routes not only accepted\n")
7461 DEFUN (neighbor_maximum_prefix_restart
,
7462 neighbor_maximum_prefix_restart_cmd
,
7463 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
7466 "Maximum number of prefix accept from this peer\n"
7467 "maximum no. of prefix limit\n"
7468 "Restart bgp connection after limit is exceeded\n"
7469 "Restart interval in minutes\n"
7470 "Force checking all received routes not only accepted\n")
7474 int idx_number_2
= 5;
7478 if (argv_find(argv
, argc
, "force", &idx_force
))
7479 force
= argv
[idx_force
]->arg
;
7481 return peer_maximum_prefix_set_vty(
7482 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7483 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
7487 neighbor_maximum_prefix_restart
,
7488 neighbor_maximum_prefix_restart_hidden_cmd
,
7489 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
7490 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7491 "Maximum number of prefix accept from this peer\n"
7492 "maximum no. of prefix limit\n"
7493 "Restart bgp connection after limit is exceeded\n"
7494 "Restart interval in minutes\n"
7495 "Force checking all received routes not only accepted\n")
7497 DEFUN (neighbor_maximum_prefix_threshold_restart
,
7498 neighbor_maximum_prefix_threshold_restart_cmd
,
7499 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
7502 "Maximum number of prefixes to accept from this peer\n"
7503 "maximum no. of prefix limit\n"
7504 "Threshold value (%) at which to generate a warning msg\n"
7505 "Restart bgp connection after limit is exceeded\n"
7506 "Restart interval in minutes\n"
7507 "Force checking all received routes not only accepted\n")
7511 int idx_number_2
= 4;
7512 int idx_number_3
= 6;
7516 if (argv_find(argv
, argc
, "force", &idx_force
))
7517 force
= argv
[idx_force
]->arg
;
7519 return peer_maximum_prefix_set_vty(
7520 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7521 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
7522 argv
[idx_number_3
]->arg
, force
);
7526 neighbor_maximum_prefix_threshold_restart
,
7527 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
7528 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
7529 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7530 "Maximum number of prefixes to accept from this peer\n"
7531 "maximum no. of prefix limit\n"
7532 "Threshold value (%) at which to generate a warning msg\n"
7533 "Restart bgp connection after limit is exceeded\n"
7534 "Restart interval in minutes\n"
7535 "Force checking all received routes not only accepted\n")
7537 DEFUN (no_neighbor_maximum_prefix
,
7538 no_neighbor_maximum_prefix_cmd
,
7539 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
7543 "Maximum number of prefixes to accept from this peer\n"
7544 "maximum no. of prefix limit\n"
7545 "Threshold value (%) at which to generate a warning msg\n"
7546 "Restart bgp connection after limit is exceeded\n"
7547 "Restart interval in minutes\n"
7548 "Only give warning message when limit is exceeded\n"
7549 "Force checking all received routes not only accepted\n")
7552 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
7554 bgp_node_safi(vty
));
7558 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
7559 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
7560 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7561 "Maximum number of prefixes to accept from this peer\n"
7562 "maximum no. of prefix limit\n"
7563 "Threshold value (%) at which to generate a warning msg\n"
7564 "Restart bgp connection after limit is exceeded\n"
7565 "Restart interval in minutes\n"
7566 "Only give warning message when limit is exceeded\n"
7567 "Force checking all received routes not only accepted\n")
7570 /* "neighbor allowas-in" */
7571 DEFUN (neighbor_allowas_in
,
7572 neighbor_allowas_in_cmd
,
7573 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
7576 "Accept as-path with my AS present in it\n"
7577 "Number of occurrences of AS number\n"
7578 "Only accept my AS in the as-path if the route was originated in my AS\n")
7581 int idx_number_origin
= 3;
7587 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7589 return CMD_WARNING_CONFIG_FAILED
;
7591 if (argc
<= idx_number_origin
)
7594 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
7597 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
7600 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7603 return bgp_vty_return(vty
, ret
);
7607 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
7608 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
7609 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7610 "Accept as-path with my AS present in it\n"
7611 "Number of occurrences of AS number\n"
7612 "Only accept my AS in the as-path if the route was originated in my AS\n")
7614 DEFUN (no_neighbor_allowas_in
,
7615 no_neighbor_allowas_in_cmd
,
7616 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
7620 "allow local ASN appears in aspath attribute\n"
7621 "Number of occurrences of AS number\n"
7622 "Only accept my AS in the as-path if the route was originated in my AS\n")
7628 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7630 return CMD_WARNING_CONFIG_FAILED
;
7632 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
7633 bgp_node_safi(vty
));
7635 return bgp_vty_return(vty
, ret
);
7639 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
7640 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
7641 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7642 "allow local ASN appears in aspath attribute\n"
7643 "Number of occurrences of AS number\n"
7644 "Only accept my AS in the as-path if the route was originated in my AS\n")
7646 DEFUN (neighbor_ttl_security
,
7647 neighbor_ttl_security_cmd
,
7648 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
7651 "BGP ttl-security parameters\n"
7652 "Specify the maximum number of hops to the BGP peer\n"
7653 "Number of hops to BGP peer\n")
7660 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7662 return CMD_WARNING_CONFIG_FAILED
;
7664 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7667 * If 'neighbor swpX', then this is for directly connected peers,
7668 * we should not accept a ttl-security hops value greater than 1.
7670 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
7672 "%s is directly connected peer, hops cannot exceed 1\n",
7673 argv
[idx_peer
]->arg
);
7674 return CMD_WARNING_CONFIG_FAILED
;
7677 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
7680 DEFUN (no_neighbor_ttl_security
,
7681 no_neighbor_ttl_security_cmd
,
7682 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
7686 "BGP ttl-security parameters\n"
7687 "Specify the maximum number of hops to the BGP peer\n"
7688 "Number of hops to BGP peer\n")
7693 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7695 return CMD_WARNING_CONFIG_FAILED
;
7697 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
7700 DEFUN (neighbor_addpath_tx_all_paths
,
7701 neighbor_addpath_tx_all_paths_cmd
,
7702 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
7705 "Use addpath to advertise all paths to a neighbor\n")
7710 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7712 return CMD_WARNING_CONFIG_FAILED
;
7714 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7719 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
7720 neighbor_addpath_tx_all_paths_hidden_cmd
,
7721 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
7722 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7723 "Use addpath to advertise all paths to a neighbor\n")
7725 DEFUN (no_neighbor_addpath_tx_all_paths
,
7726 no_neighbor_addpath_tx_all_paths_cmd
,
7727 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
7731 "Use addpath to advertise all paths to a neighbor\n")
7736 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7738 return CMD_WARNING_CONFIG_FAILED
;
7740 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
7741 != BGP_ADDPATH_ALL
) {
7743 "%% Peer not currently configured to transmit all paths.");
7744 return CMD_WARNING_CONFIG_FAILED
;
7747 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7753 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
7754 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
7755 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
7756 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7757 "Use addpath to advertise all paths to a neighbor\n")
7759 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
7760 neighbor_addpath_tx_bestpath_per_as_cmd
,
7761 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
7764 "Use addpath to advertise the bestpath per each neighboring AS\n")
7769 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7771 return CMD_WARNING_CONFIG_FAILED
;
7773 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7774 BGP_ADDPATH_BEST_PER_AS
);
7779 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
7780 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
7781 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
7782 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7783 "Use addpath to advertise the bestpath per each neighboring AS\n")
7785 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
7786 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
7787 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
7791 "Use addpath to advertise the bestpath per each neighboring AS\n")
7796 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7798 return CMD_WARNING_CONFIG_FAILED
;
7800 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
7801 != BGP_ADDPATH_BEST_PER_AS
) {
7803 "%% Peer not currently configured to transmit all best path per as.");
7804 return CMD_WARNING_CONFIG_FAILED
;
7807 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7813 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
7814 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
7815 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
7816 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7817 "Use addpath to advertise the bestpath per each neighboring AS\n")
7820 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
7821 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
7824 "Detect AS loops before sending to neighbor\n")
7828 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7830 return CMD_WARNING_CONFIG_FAILED
;
7832 peer
->as_path_loop_detection
= true;
7838 no_neighbor_aspath_loop_detection
,
7839 no_neighbor_aspath_loop_detection_cmd
,
7840 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
7844 "Detect AS loops before sending to neighbor\n")
7848 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7850 return CMD_WARNING_CONFIG_FAILED
;
7852 peer
->as_path_loop_detection
= false;
7857 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
7858 struct ecommunity
**list
, bool is_rt6
)
7860 struct ecommunity
*ecom
= NULL
;
7861 struct ecommunity
*ecomadd
;
7863 for (; argc
; --argc
, ++argv
) {
7865 ecomadd
= ecommunity_str2com_ipv6(argv
[0]->arg
,
7866 ECOMMUNITY_ROUTE_TARGET
,
7869 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
7870 ECOMMUNITY_ROUTE_TARGET
,
7873 vty_out(vty
, "Malformed community-list value\n");
7875 ecommunity_free(&ecom
);
7876 return CMD_WARNING_CONFIG_FAILED
;
7880 ecommunity_merge(ecom
, ecomadd
);
7881 ecommunity_free(&ecomadd
);
7888 ecommunity_free(&*list
);
7896 * v2vimport is true if we are handling a `import vrf ...` command
7898 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
7902 switch (vty
->node
) {
7911 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
7916 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
7917 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
7918 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
7919 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
7921 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
7925 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
7926 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
7927 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
7928 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
7930 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
7937 DEFPY (af_rd_vpn_export
,
7938 af_rd_vpn_export_cmd
,
7939 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
7941 "Specify route distinguisher\n"
7942 "Between current address-family and vpn\n"
7943 "For routes leaked from current address-family to vpn\n"
7944 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
7946 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7947 struct prefix_rd prd
;
7953 if (argv_find(argv
, argc
, "no", &idx
))
7957 ret
= str2prefix_rd(rd_str
, &prd
);
7959 vty_out(vty
, "%% Malformed rd\n");
7960 return CMD_WARNING_CONFIG_FAILED
;
7964 afi
= vpn_policy_getafi(vty
, bgp
, false);
7966 return CMD_WARNING_CONFIG_FAILED
;
7969 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
7971 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
7972 bgp_get_default(), bgp
);
7975 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
7976 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
7977 BGP_VPN_POLICY_TOVPN_RD_SET
);
7979 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
7980 BGP_VPN_POLICY_TOVPN_RD_SET
);
7983 /* post-change: re-export vpn routes */
7984 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
7985 bgp_get_default(), bgp
);
7990 ALIAS (af_rd_vpn_export
,
7991 af_no_rd_vpn_export_cmd
,
7994 "Specify route distinguisher\n"
7995 "Between current address-family and vpn\n"
7996 "For routes leaked from current address-family to vpn\n")
7998 DEFPY (af_label_vpn_export
,
7999 af_label_vpn_export_cmd
,
8000 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
8002 "label value for VRF\n"
8003 "Between current address-family and vpn\n"
8004 "For routes leaked from current address-family to vpn\n"
8005 "Label Value <0-1048575>\n"
8006 "Automatically assign a label\n")
8008 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8009 mpls_label_t label
= MPLS_LABEL_NONE
;
8014 if (argv_find(argv
, argc
, "no", &idx
))
8017 /* If "no ...", squash trailing parameter */
8023 label
= label_val
; /* parser should force unsigned */
8026 afi
= vpn_policy_getafi(vty
, bgp
, false);
8028 return CMD_WARNING_CONFIG_FAILED
;
8031 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8032 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
8037 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8039 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8040 bgp_get_default(), bgp
);
8042 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
8043 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
8045 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
8048 * label has previously been automatically
8049 * assigned by labelpool: release it
8051 * NB if tovpn_label == MPLS_LABEL_NONE it
8052 * means the automatic assignment is in flight
8053 * and therefore the labelpool callback must
8054 * detect that the auto label is not needed.
8057 bgp_lp_release(LP_TYPE_VRF
,
8058 &bgp
->vpn_policy
[afi
],
8059 bgp
->vpn_policy
[afi
].tovpn_label
);
8061 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8062 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8065 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
8067 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8068 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
8069 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
8070 vpn_leak_label_callback
);
8073 /* post-change: re-export vpn routes */
8074 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8075 bgp_get_default(), bgp
);
8080 ALIAS (af_label_vpn_export
,
8081 af_no_label_vpn_export_cmd
,
8082 "no label vpn export",
8084 "label value for VRF\n"
8085 "Between current address-family and vpn\n"
8086 "For routes leaked from current address-family to vpn\n")
8088 DEFPY (af_nexthop_vpn_export
,
8089 af_nexthop_vpn_export_cmd
,
8090 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
8092 "Specify next hop to use for VRF advertised prefixes\n"
8093 "Between current address-family and vpn\n"
8094 "For routes leaked from current address-family to vpn\n"
8098 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8104 vty_out(vty
, "%% Nexthop required\n");
8105 return CMD_WARNING_CONFIG_FAILED
;
8107 if (!sockunion2hostprefix(nexthop_su
, &p
))
8108 return CMD_WARNING_CONFIG_FAILED
;
8111 afi
= vpn_policy_getafi(vty
, bgp
, false);
8113 return CMD_WARNING_CONFIG_FAILED
;
8116 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
8118 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8119 bgp_get_default(), bgp
);
8122 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
8123 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8124 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
8126 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
8127 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
8130 /* post-change: re-export vpn routes */
8131 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
8132 bgp_get_default(), bgp
);
8137 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
8139 if (!strcmp(dstr
, "import")) {
8140 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
8141 } else if (!strcmp(dstr
, "export")) {
8142 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
8143 } else if (!strcmp(dstr
, "both")) {
8144 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
8145 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
8147 vty_out(vty
, "%% direction parse error\n");
8148 return CMD_WARNING_CONFIG_FAILED
;
8153 DEFPY (af_rt_vpn_imexport
,
8154 af_rt_vpn_imexport_cmd
,
8155 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
8157 "Specify route target list\n"
8158 "Specify route target list\n"
8159 "Between current address-family and vpn\n"
8160 "For routes leaked from vpn to current address-family: match any\n"
8161 "For routes leaked from current address-family to vpn: set\n"
8162 "both import: match any and export: set\n"
8163 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
8165 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8167 struct ecommunity
*ecom
= NULL
;
8168 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
8169 vpn_policy_direction_t dir
;
8174 if (argv_find(argv
, argc
, "no", &idx
))
8177 afi
= vpn_policy_getafi(vty
, bgp
, false);
8179 return CMD_WARNING_CONFIG_FAILED
;
8181 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
8182 if (ret
!= CMD_SUCCESS
)
8186 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
8187 vty_out(vty
, "%% Missing RTLIST\n");
8188 return CMD_WARNING_CONFIG_FAILED
;
8190 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, false);
8191 if (ret
!= CMD_SUCCESS
) {
8196 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
8200 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8203 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
8205 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
8206 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
8207 ecommunity_dup(ecom
);
8209 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
8211 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
8212 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
8215 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8219 ecommunity_free(&ecom
);
8224 ALIAS (af_rt_vpn_imexport
,
8225 af_no_rt_vpn_imexport_cmd
,
8226 "no <rt|route-target> vpn <import|export|both>$direction_str",
8228 "Specify route target list\n"
8229 "Specify route target list\n"
8230 "Between current address-family and vpn\n"
8231 "For routes leaked from vpn to current address-family\n"
8232 "For routes leaked from current address-family to vpn\n"
8233 "both import and export\n")
8235 DEFPY (af_route_map_vpn_imexport
,
8236 af_route_map_vpn_imexport_cmd
,
8237 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
8238 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
8240 "Specify route map\n"
8241 "Between current address-family and vpn\n"
8242 "For routes leaked from vpn to current address-family\n"
8243 "For routes leaked from current address-family to vpn\n"
8244 "name of route-map\n")
8246 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8248 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
8249 vpn_policy_direction_t dir
;
8254 if (argv_find(argv
, argc
, "no", &idx
))
8257 afi
= vpn_policy_getafi(vty
, bgp
, false);
8259 return CMD_WARNING_CONFIG_FAILED
;
8261 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
8262 if (ret
!= CMD_SUCCESS
)
8265 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
8269 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8272 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
8273 XFREE(MTYPE_ROUTE_MAP_NAME
,
8274 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
8275 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
8276 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
8277 bgp
->vpn_policy
[afi
].rmap
[dir
] =
8278 route_map_lookup_warn_noexist(vty
, rmap_str
);
8279 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
8282 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
8283 XFREE(MTYPE_ROUTE_MAP_NAME
,
8284 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
8285 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
8286 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
8289 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8295 ALIAS (af_route_map_vpn_imexport
,
8296 af_no_route_map_vpn_imexport_cmd
,
8297 "no route-map vpn <import|export>$direction_str",
8299 "Specify route map\n"
8300 "Between current address-family and vpn\n"
8301 "For routes leaked from vpn to current address-family\n"
8302 "For routes leaked from current address-family to vpn\n")
8304 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
8305 "import vrf route-map RMAP$rmap_str",
8306 "Import routes from another VRF\n"
8307 "Vrf routes being filtered\n"
8308 "Specify route map\n"
8309 "name of route-map\n")
8311 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8312 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
8314 struct bgp
*bgp_default
;
8316 afi
= vpn_policy_getafi(vty
, bgp
, true);
8318 return CMD_WARNING_CONFIG_FAILED
;
8320 bgp_default
= bgp_get_default();
8325 /* Auto-create assuming the same AS */
8326 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
8327 BGP_INSTANCE_TYPE_DEFAULT
);
8331 "VRF default is not configured as a bgp instance\n");
8336 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8338 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
8339 XFREE(MTYPE_ROUTE_MAP_NAME
,
8340 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
8341 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
8342 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
8343 bgp
->vpn_policy
[afi
].rmap
[dir
] =
8344 route_map_lookup_warn_noexist(vty
, rmap_str
);
8345 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
8348 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8349 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
8351 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8356 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
8357 "no import vrf route-map [RMAP$rmap_str]",
8359 "Import routes from another VRF\n"
8360 "Vrf routes being filtered\n"
8361 "Specify route map\n"
8362 "name of route-map\n")
8364 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8365 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
8368 afi
= vpn_policy_getafi(vty
, bgp
, true);
8370 return CMD_WARNING_CONFIG_FAILED
;
8372 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8374 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
8375 XFREE(MTYPE_ROUTE_MAP_NAME
,
8376 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
8377 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
8378 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
8380 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
8381 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
8382 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
8384 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8389 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
8390 "[no] import vrf VIEWVRFNAME$import_name",
8392 "Import routes from another VRF\n"
8393 "VRF to import from\n"
8394 "The name of the VRF\n")
8396 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8397 struct listnode
*node
;
8398 struct bgp
*vrf_bgp
, *bgp_default
;
8401 bool remove
= false;
8404 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
8408 if (import_name
== NULL
) {
8409 vty_out(vty
, "%% Missing import name\n");
8413 if (strcmp(import_name
, "route-map") == 0) {
8414 vty_out(vty
, "%% Must include route-map name\n");
8418 if (argv_find(argv
, argc
, "no", &idx
))
8421 afi
= vpn_policy_getafi(vty
, bgp
, true);
8423 return CMD_WARNING_CONFIG_FAILED
;
8425 safi
= bgp_node_safi(vty
);
8427 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
8428 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
8429 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
8430 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
8431 remove
? "unimport" : "import", import_name
);
8435 bgp_default
= bgp_get_default();
8437 /* Auto-create assuming the same AS */
8438 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
8439 BGP_INSTANCE_TYPE_DEFAULT
);
8443 "VRF default is not configured as a bgp instance\n");
8448 vrf_bgp
= bgp_lookup_by_name(import_name
);
8450 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
8451 vrf_bgp
= bgp_default
;
8453 /* Auto-create assuming the same AS */
8454 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
8458 "VRF %s is not configured as a bgp instance\n",
8465 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
8467 /* Already importing from "import_vrf"? */
8468 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
8470 if (strcmp(vname
, import_name
) == 0)
8474 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
8480 /* This command is valid only in a bgp vrf instance or the default instance */
8481 DEFPY (bgp_imexport_vpn
,
8482 bgp_imexport_vpn_cmd
,
8483 "[no] <import|export>$direction_str vpn",
8485 "Import routes to this address-family\n"
8486 "Export routes from this address-family\n"
8487 "to/from default instance VPN RIB\n")
8489 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8496 vpn_policy_direction_t dir
;
8498 if (argv_find(argv
, argc
, "no", &idx
))
8501 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
8502 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
8504 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
8505 return CMD_WARNING_CONFIG_FAILED
;
8508 afi
= bgp_node_afi(vty
);
8509 safi
= bgp_node_safi(vty
);
8510 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
8511 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
8512 return CMD_WARNING_CONFIG_FAILED
;
8515 if (!strcmp(direction_str
, "import")) {
8516 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
8517 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
8518 } else if (!strcmp(direction_str
, "export")) {
8519 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
8520 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
8522 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
8523 return CMD_WARNING_CONFIG_FAILED
;
8526 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
8529 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
8530 if (!previous_state
) {
8531 /* trigger export current vrf */
8532 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8535 if (previous_state
) {
8536 /* trigger un-export current vrf */
8537 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8539 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
8545 DEFPY (af_routetarget_import
,
8546 af_routetarget_import_cmd
,
8547 "[no] <rt|route-target|route-target6|rt6> redirect import RTLIST...",
8549 "Specify route target list\n"
8550 "Specify route target list\n"
8551 "Specify route target list\n"
8552 "Specify route target list\n"
8553 "Flow-spec redirect type route target\n"
8554 "Import routes to this address-family\n"
8555 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN|IPV6:MN)\n")
8557 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8559 struct ecommunity
*ecom
= NULL
;
8561 int idx
= 0, idx_unused
= 0;
8565 if (argv_find(argv
, argc
, "no", &idx
))
8568 if (argv_find(argv
, argc
, "rt6", &idx_unused
) ||
8569 argv_find(argv
, argc
, "route-target6", &idx_unused
))
8572 afi
= vpn_policy_getafi(vty
, bgp
, false);
8574 return CMD_WARNING_CONFIG_FAILED
;
8576 if (rt6
&& afi
!= AFI_IP6
)
8577 return CMD_WARNING_CONFIG_FAILED
;
8580 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
8581 vty_out(vty
, "%% Missing RTLIST\n");
8582 return CMD_WARNING_CONFIG_FAILED
;
8584 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
, rt6
);
8585 if (ret
!= CMD_SUCCESS
)
8590 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
8591 ecommunity_free(&bgp
->vpn_policy
[afi
]
8592 .import_redirect_rtlist
);
8593 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
8594 ecommunity_dup(ecom
);
8596 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
8597 ecommunity_free(&bgp
->vpn_policy
[afi
]
8598 .import_redirect_rtlist
);
8599 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
8603 ecommunity_free(&ecom
);
8608 DEFUN_NOSH (address_family_ipv4_safi
,
8609 address_family_ipv4_safi_cmd
,
8610 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
8611 "Enter Address Family command mode\n"
8613 BGP_SAFI_WITH_LABEL_HELP_STR
)
8617 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8618 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
8619 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
8620 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
8621 && safi
!= SAFI_EVPN
) {
8623 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
8624 return CMD_WARNING_CONFIG_FAILED
;
8626 vty
->node
= bgp_node_type(AFI_IP
, safi
);
8628 vty
->node
= BGP_IPV4_NODE
;
8633 DEFUN_NOSH (address_family_ipv6_safi
,
8634 address_family_ipv6_safi_cmd
,
8635 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
8636 "Enter Address Family command mode\n"
8638 BGP_SAFI_WITH_LABEL_HELP_STR
)
8641 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8642 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
8643 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
8644 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
8645 && safi
!= SAFI_EVPN
) {
8647 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
8648 return CMD_WARNING_CONFIG_FAILED
;
8650 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
8652 vty
->node
= BGP_IPV6_NODE
;
8657 #ifdef KEEP_OLD_VPN_COMMANDS
8658 DEFUN_NOSH (address_family_vpnv4
,
8659 address_family_vpnv4_cmd
,
8660 "address-family vpnv4 [unicast]",
8661 "Enter Address Family command mode\n"
8663 "Address Family modifier\n")
8665 vty
->node
= BGP_VPNV4_NODE
;
8669 DEFUN_NOSH (address_family_vpnv6
,
8670 address_family_vpnv6_cmd
,
8671 "address-family vpnv6 [unicast]",
8672 "Enter Address Family command mode\n"
8674 "Address Family modifier\n")
8676 vty
->node
= BGP_VPNV6_NODE
;
8679 #endif /* KEEP_OLD_VPN_COMMANDS */
8681 DEFUN_NOSH (address_family_evpn
,
8682 address_family_evpn_cmd
,
8683 "address-family l2vpn evpn",
8684 "Enter Address Family command mode\n"
8686 "Address Family modifier\n")
8688 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8689 vty
->node
= BGP_EVPN_NODE
;
8693 DEFUN_NOSH (exit_address_family
,
8694 exit_address_family_cmd
,
8695 "exit-address-family",
8696 "Exit from Address Family configuration mode\n")
8698 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
8699 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
8700 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
8701 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
8702 || vty
->node
== BGP_EVPN_NODE
8703 || vty
->node
== BGP_FLOWSPECV4_NODE
8704 || vty
->node
== BGP_FLOWSPECV6_NODE
)
8705 vty
->node
= BGP_NODE
;
8709 /* Recalculate bestpath and re-advertise a prefix */
8710 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
8711 const char *ip_str
, afi_t afi
, safi_t safi
,
8712 struct prefix_rd
*prd
)
8715 struct prefix match
;
8716 struct bgp_dest
*dest
;
8717 struct bgp_dest
*rm
;
8719 struct bgp_table
*table
;
8720 struct bgp_table
*rib
;
8722 /* BGP structure lookup. */
8724 bgp
= bgp_lookup_by_name(view_name
);
8726 vty_out(vty
, "%% Can't find BGP instance %s\n",
8731 bgp
= bgp_get_default();
8733 vty_out(vty
, "%% No BGP process is configured\n");
8738 /* Check IP address argument. */
8739 ret
= str2prefix(ip_str
, &match
);
8741 vty_out(vty
, "%% address is malformed\n");
8745 match
.family
= afi2family(afi
);
8746 rib
= bgp
->rib
[afi
][safi
];
8748 if (safi
== SAFI_MPLS_VPN
) {
8749 for (dest
= bgp_table_top(rib
); dest
;
8750 dest
= bgp_route_next(dest
)) {
8751 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
8753 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
8756 table
= bgp_dest_get_bgp_table_info(dest
);
8760 if ((rm
= bgp_node_match(table
, &match
)) != NULL
) {
8761 const struct prefix
*rm_p
=
8762 bgp_dest_get_prefix(rm
);
8764 if (rm_p
->prefixlen
== match
.prefixlen
) {
8766 BGP_NODE_USER_CLEAR
);
8767 bgp_process(bgp
, rm
, afi
, safi
);
8769 bgp_dest_unlock_node(rm
);
8773 if ((dest
= bgp_node_match(rib
, &match
)) != NULL
) {
8774 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
8776 if (dest_p
->prefixlen
== match
.prefixlen
) {
8777 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
8778 bgp_process(bgp
, dest
, afi
, safi
);
8780 bgp_dest_unlock_node(dest
);
8787 /* one clear bgp command to rule them all */
8788 DEFUN (clear_ip_bgp_all
,
8789 clear_ip_bgp_all_cmd
,
8790 "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>]",
8794 BGP_INSTANCE_HELP_STR
8797 BGP_SAFI_WITH_LABEL_HELP_STR
8798 "Address Family modifier\n"
8800 "BGP IPv4 neighbor to clear\n"
8801 "BGP IPv6 neighbor to clear\n"
8802 "BGP neighbor on interface to clear\n"
8803 "Clear peers with the AS number\n"
8804 "Clear all external peers\n"
8805 "Clear all members of peer-group\n"
8806 "BGP peer-group name\n"
8811 "Push out prefix-list ORF and do inbound soft reconfig\n"
8816 afi_t afi
= AFI_UNSPEC
;
8817 safi_t safi
= SAFI_UNSPEC
;
8818 enum clear_sort clr_sort
= clear_peer
;
8819 enum bgp_clear_type clr_type
;
8820 char *clr_arg
= NULL
;
8823 char errmsg
[BUFSIZ
] = {'\0'};
8826 /* clear [ip] bgp */
8827 if (argv_find(argv
, argc
, "ip", &idx
))
8830 /* [<vrf> VIEWVRFNAME] */
8831 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8832 vrf
= argv
[idx
+ 1]->arg
;
8834 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8836 } else if (argv_find(argv
, argc
, "view", &idx
)) {
8837 /* [<view> VIEWVRFNAME] */
8838 vrf
= argv
[idx
+ 1]->arg
;
8841 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8842 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
8843 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8845 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
8846 if (argv_find(argv
, argc
, "*", &idx
)) {
8847 clr_sort
= clear_all
;
8848 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8849 clr_sort
= clear_peer
;
8850 clr_arg
= argv
[idx
]->arg
;
8851 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
8852 clr_sort
= clear_peer
;
8853 clr_arg
= argv
[idx
]->arg
;
8854 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
8855 clr_sort
= clear_group
;
8857 clr_arg
= argv
[idx
]->arg
;
8858 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
8859 clr_sort
= clear_peer
;
8860 clr_arg
= argv
[idx
]->arg
;
8861 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
8862 clr_sort
= clear_peer
;
8863 clr_arg
= argv
[idx
]->arg
;
8864 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
8865 clr_sort
= clear_as
;
8866 clr_arg
= argv
[idx
]->arg
;
8867 } else if (argv_find(argv
, argc
, "external", &idx
)) {
8868 clr_sort
= clear_external
;
8871 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
8872 if (argv_find(argv
, argc
, "soft", &idx
)) {
8873 if (argv_find(argv
, argc
, "in", &idx
)
8874 || argv_find(argv
, argc
, "out", &idx
))
8875 clr_type
= strmatch(argv
[idx
]->text
, "in")
8877 : BGP_CLEAR_SOFT_OUT
;
8879 clr_type
= BGP_CLEAR_SOFT_BOTH
;
8880 } else if (argv_find(argv
, argc
, "in", &idx
)) {
8881 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
8882 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
8883 : BGP_CLEAR_SOFT_IN
;
8884 } else if (argv_find(argv
, argc
, "out", &idx
)) {
8885 clr_type
= BGP_CLEAR_SOFT_OUT
;
8887 clr_type
= BGP_CLEAR_SOFT_NONE
;
8889 ret
= bgp_clear_vty(vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
, errmsg
,
8892 vty_out(vty
, "Error description: %s\n", errmsg
);
8897 DEFUN (clear_ip_bgp_prefix
,
8898 clear_ip_bgp_prefix_cmd
,
8899 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
8903 BGP_INSTANCE_HELP_STR
8904 "Clear bestpath and re-advertise\n"
8908 char *prefix
= NULL
;
8912 /* [<view|vrf> VIEWVRFNAME] */
8913 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8914 vrf
= argv
[idx
+ 1]->arg
;
8916 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8918 } else if (argv_find(argv
, argc
, "view", &idx
)) {
8919 /* [<view> VIEWVRFNAME] */
8920 vrf
= argv
[idx
+ 1]->arg
;
8924 prefix
= argv
[argc
- 1]->arg
;
8926 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
8929 DEFUN (clear_bgp_ipv6_safi_prefix
,
8930 clear_bgp_ipv6_safi_prefix_cmd
,
8931 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
8937 "Clear bestpath and re-advertise\n"
8941 int idx_ipv6_prefix
= 0;
8942 safi_t safi
= SAFI_UNICAST
;
8943 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
8944 argv
[idx_ipv6_prefix
]->arg
: NULL
;
8946 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
8947 return bgp_clear_prefix(
8948 vty
, NULL
, prefix
, AFI_IP6
,
8952 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
8953 clear_bgp_instance_ipv6_safi_prefix_cmd
,
8954 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
8958 BGP_INSTANCE_HELP_STR
8961 "Clear bestpath and re-advertise\n"
8965 int idx_vrfview
= 0;
8966 int idx_ipv6_prefix
= 0;
8967 safi_t safi
= SAFI_UNICAST
;
8968 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
8969 argv
[idx_ipv6_prefix
]->arg
: NULL
;
8970 char *vrfview
= NULL
;
8972 /* [<view|vrf> VIEWVRFNAME] */
8973 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
8974 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
8975 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
8977 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
8978 /* [<view> VIEWVRFNAME] */
8979 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
8981 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
8983 return bgp_clear_prefix(
8984 vty
, vrfview
, prefix
,
8985 AFI_IP6
, safi
, NULL
);
8988 DEFUN (show_bgp_views
,
8990 "show [ip] bgp views",
8994 "Show the defined BGP views\n")
8996 struct list
*inst
= bm
->bgp
;
8997 struct listnode
*node
;
9000 vty_out(vty
, "Defined BGP views:\n");
9001 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
9003 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
9005 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
9012 DEFUN (show_bgp_vrfs
,
9014 "show [ip] bgp vrfs [json]",
9021 char buf
[ETHER_ADDR_STRLEN
];
9022 struct list
*inst
= bm
->bgp
;
9023 struct listnode
*node
;
9025 bool uj
= use_json(argc
, argv
);
9026 json_object
*json
= NULL
;
9027 json_object
*json_vrfs
= NULL
;
9031 json
= json_object_new_object();
9032 json_vrfs
= json_object_new_object();
9035 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
9036 const char *name
, *type
;
9038 struct listnode
*node2
, *nnode2
;
9039 int peers_cfg
, peers_estb
;
9040 json_object
*json_vrf
= NULL
;
9043 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
9047 if (!uj
&& count
== 1) {
9049 "%4s %-5s %-16s %9s %10s %-37s\n",
9050 "Type", "Id", "routerId", "#PeersCfg",
9051 "#PeersEstb", "Name");
9052 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
9053 "L3-VNI", "RouterMAC", "Interface");
9056 peers_cfg
= peers_estb
= 0;
9058 json_vrf
= json_object_new_object();
9061 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
9062 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
9065 if (peer
->status
== Established
)
9069 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
9070 name
= VRF_DEFAULT_NAME
;
9079 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
9081 : (int64_t)bgp
->vrf_id
;
9082 json_object_string_add(json_vrf
, "type", type
);
9083 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
9084 json_object_string_add(json_vrf
, "routerId",
9085 inet_ntoa(bgp
->router_id
));
9086 json_object_int_add(json_vrf
, "numConfiguredPeers",
9088 json_object_int_add(json_vrf
, "numEstablishedPeers",
9091 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
9092 json_object_string_add(
9094 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
9095 json_object_string_add(json_vrf
, "interface",
9096 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
9098 json_object_object_add(json_vrfs
, name
, json_vrf
);
9101 "%4s %-5d %-16s %-9u %-10u %-37s\n",
9103 bgp
->vrf_id
== VRF_UNKNOWN
? -1
9105 inet_ntoa(bgp
->router_id
), peers_cfg
,
9107 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
9109 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
9110 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
9116 json_object_object_add(json
, "vrfs", json_vrfs
);
9118 json_object_int_add(json
, "totalVrfs", count
);
9120 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
9121 json
, JSON_C_TO_STRING_PRETTY
));
9122 json_object_free(json
);
9126 "\nTotal number of VRFs (including default): %d\n",
9133 DEFUN (show_bgp_mac_hash
,
9134 show_bgp_mac_hash_cmd
,
9135 "show bgp mac hash",
9139 "Mac Address database\n")
9141 bgp_mac_dump_table(vty
);
9146 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
9148 struct vty
*vty
= (struct vty
*)args
;
9149 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
9151 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
9155 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
9157 vty_out(vty
, "self nexthop database:\n");
9158 bgp_nexthop_show_address_hash(vty
, bgp
);
9160 vty_out(vty
, "Tunnel-ip database:\n");
9161 hash_iterate(bgp
->tip_hash
,
9162 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
9166 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
9167 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
9168 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
9169 "martian next-hops\n"
9170 "martian next-hop database\n")
9172 struct bgp
*bgp
= NULL
;
9176 /* [<vrf> VIEWVRFNAME] */
9177 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9178 name
= argv
[idx
+ 1]->arg
;
9179 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
9181 } else if (argv_find(argv
, argc
, "view", &idx
))
9182 /* [<view> VIEWVRFNAME] */
9183 name
= argv
[idx
+ 1]->arg
;
9185 bgp
= bgp_lookup_by_name(name
);
9187 bgp
= bgp_get_default();
9190 vty_out(vty
, "%% No BGP process is configured\n");
9193 bgp_show_martian_nexthops(vty
, bgp
);
9198 DEFUN (show_bgp_memory
,
9199 show_bgp_memory_cmd
,
9200 "show [ip] bgp memory",
9204 "Global BGP memory statistics\n")
9206 char memstrbuf
[MTYPE_MEMSTR_LEN
];
9207 unsigned long count
;
9209 /* RIB related usage stats */
9210 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
9211 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
9212 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9213 count
* sizeof(struct bgp_dest
)));
9215 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
9216 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
9217 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9218 count
* sizeof(struct bgp_path_info
)));
9219 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
9220 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
9223 memstrbuf
, sizeof(memstrbuf
),
9224 count
* sizeof(struct bgp_path_info_extra
)));
9226 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
9227 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
9228 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9229 count
* sizeof(struct bgp_static
)));
9231 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
9232 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
9233 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9234 count
* sizeof(struct bpacket
)));
9237 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
9238 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
9239 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9240 count
* sizeof(struct bgp_adj_in
)));
9241 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
9242 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
9243 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9244 count
* sizeof(struct bgp_adj_out
)));
9246 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
9247 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
9249 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9250 count
* sizeof(struct bgp_nexthop_cache
)));
9252 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
9253 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
9255 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9256 count
* sizeof(struct bgp_damp_info
)));
9259 count
= attr_count();
9260 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
9261 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9262 count
* sizeof(struct attr
)));
9264 if ((count
= attr_unknown_count()))
9265 vty_out(vty
, "%ld unknown attributes\n", count
);
9267 /* AS_PATH attributes */
9268 count
= aspath_count();
9269 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
9270 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9271 count
* sizeof(struct aspath
)));
9273 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
9274 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
9275 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9276 count
* sizeof(struct assegment
)));
9278 /* Other attributes */
9279 if ((count
= community_count()))
9280 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
9281 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9282 count
* sizeof(struct community
)));
9283 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
9284 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
9285 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9286 count
* sizeof(struct ecommunity
)));
9287 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
9289 "%ld BGP large-community entries, using %s of memory\n",
9290 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9291 count
* sizeof(struct lcommunity
)));
9293 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
9294 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
9295 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9296 count
* sizeof(struct cluster_list
)));
9298 /* Peer related usage */
9299 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
9300 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
9301 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9302 count
* sizeof(struct peer
)));
9304 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
9305 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
9306 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9307 count
* sizeof(struct peer_group
)));
9310 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
9311 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
9312 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
9313 count
* sizeof(regex_t
)));
9317 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
9319 json_object
*bestpath
= json_object_new_object();
9321 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
9322 json_object_string_add(bestpath
, "asPath", "ignore");
9324 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
9325 json_object_string_add(bestpath
, "asPath", "confed");
9327 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
9328 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
9329 json_object_string_add(bestpath
, "multiPathRelax",
9332 json_object_string_add(bestpath
, "multiPathRelax",
9335 json_object_string_add(bestpath
, "multiPathRelax", "false");
9337 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
9338 json_object_string_add(bestpath
, "compareRouterId", "true");
9339 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
9340 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
9341 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
9342 json_object_string_add(bestpath
, "med", "confed");
9343 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
9344 json_object_string_add(bestpath
, "med",
9345 "missing-as-worst");
9347 json_object_string_add(bestpath
, "med", "true");
9350 json_object_object_add(json
, "bestPath", bestpath
);
9353 /* Print the error code/subcode for why the peer is down */
9354 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
9355 json_object
*json_peer
, bool use_json
)
9357 const char *code_str
;
9358 const char *subcode_str
;
9361 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
9362 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
9363 char errorcodesubcode_hexstr
[5];
9364 char errorcodesubcode_str
[256];
9366 code_str
= bgp_notify_code_str(peer
->notify
.code
);
9367 subcode_str
= bgp_notify_subcode_str(
9369 peer
->notify
.subcode
);
9371 snprintf(errorcodesubcode_hexstr
,
9372 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
9373 peer
->notify
.code
, peer
->notify
.subcode
);
9374 json_object_string_add(json_peer
,
9375 "lastErrorCodeSubcode",
9376 errorcodesubcode_hexstr
);
9377 snprintf(errorcodesubcode_str
, 255, "%s%s",
9378 code_str
, subcode_str
);
9379 json_object_string_add(json_peer
,
9380 "lastNotificationReason",
9381 errorcodesubcode_str
);
9382 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
9383 && peer
->notify
.code
== BGP_NOTIFY_CEASE
9384 && (peer
->notify
.subcode
9385 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
9386 || peer
->notify
.subcode
9387 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
9388 && peer
->notify
.length
) {
9390 const char *msg_str
;
9392 msg_str
= bgp_notify_admin_message(
9393 msgbuf
, sizeof(msgbuf
),
9394 (uint8_t *)peer
->notify
.data
,
9395 peer
->notify
.length
);
9397 json_object_string_add(
9399 "lastShutdownDescription",
9404 json_object_string_add(json_peer
, "lastResetDueTo",
9405 peer_down_str
[(int)peer
->last_reset
]);
9406 json_object_int_add(json_peer
, "lastResetCode",
9409 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
9410 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
9411 code_str
= bgp_notify_code_str(peer
->notify
.code
);
9413 bgp_notify_subcode_str(peer
->notify
.code
,
9414 peer
->notify
.subcode
);
9415 vty_out(vty
, " Notification %s (%s%s)\n",
9416 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
9419 code_str
, subcode_str
);
9421 vty_out(vty
, " %s\n",
9422 peer_down_str
[(int)peer
->last_reset
]);
9427 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
9430 return ((peer
->status
!= Established
) ||
9431 !peer
->afc_recv
[afi
][safi
]);
9434 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
9435 struct peer
*peer
, json_object
*json_peer
,
9436 int max_neighbor_width
, bool use_json
)
9438 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
9442 if (peer_dynamic_neighbor(peer
))
9443 json_object_boolean_true_add(json_peer
,
9446 json_object_string_add(json_peer
, "hostname",
9449 if (peer
->domainname
)
9450 json_object_string_add(json_peer
, "domainname",
9452 json_object_int_add(json_peer
, "connectionsEstablished",
9454 json_object_int_add(json_peer
, "connectionsDropped",
9456 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9457 use_json
, json_peer
);
9458 if (peer
->status
== Established
)
9459 json_object_string_add(json_peer
, "lastResetDueTo",
9460 "AFI/SAFI Not Negotiated");
9462 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
9465 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
9467 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
9468 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
9469 peer
->hostname
, peer
->host
);
9471 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
9473 /* pad the neighbor column with spaces */
9474 if (len
< max_neighbor_width
)
9475 vty_out(vty
, "%*s", max_neighbor_width
- len
,
9477 vty_out(vty
, "%7d %7d %9s", peer
->established
,
9479 peer_uptime(peer
->uptime
, timebuf
,
9480 BGP_UPTIME_LEN
, 0, NULL
));
9481 if (peer
->status
== Established
)
9482 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
9484 bgp_show_peer_reset(vty
, peer
, NULL
,
9490 /* Show BGP peer's summary information. */
9491 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
9492 bool show_failed
, bool show_established
,
9496 struct listnode
*node
, *nnode
;
9497 unsigned int count
= 0, dn_count
= 0;
9498 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
9499 char neighbor_buf
[VTY_BUFSIZ
];
9500 int neighbor_col_default_width
= 16;
9501 int len
, failed_count
= 0;
9502 int max_neighbor_width
= 0;
9504 json_object
*json
= NULL
;
9505 json_object
*json_peer
= NULL
;
9506 json_object
*json_peers
= NULL
;
9507 struct peer_af
*paf
;
9508 struct bgp_filter
*filter
;
9510 /* labeled-unicast routes are installed in the unicast table so in order
9512 * display the correct PfxRcd value we must look at SAFI_UNICAST
9515 if (safi
== SAFI_LABELED_UNICAST
)
9516 pfx_rcd_safi
= SAFI_UNICAST
;
9518 pfx_rcd_safi
= safi
;
9521 json
= json_object_new_object();
9522 json_peers
= json_object_new_object();
9523 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
9524 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
9527 if (peer
->afc
[afi
][safi
]) {
9528 /* See if we have at least a single failed peer */
9529 if (bgp_has_peer_failed(peer
, afi
, safi
))
9533 if (peer_dynamic_neighbor(peer
))
9538 /* Loop over all neighbors that will be displayed to determine
9540 * characters are needed for the Neighbor column
9542 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
9543 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
9546 if (peer
->afc
[afi
][safi
]) {
9547 memset(dn_flag
, '\0', sizeof(dn_flag
));
9548 if (peer_dynamic_neighbor(peer
))
9552 && CHECK_FLAG(bgp
->flags
,
9553 BGP_FLAG_SHOW_HOSTNAME
))
9554 snprintf(neighbor_buf
,
9555 sizeof(neighbor_buf
),
9556 "%s%s(%s) ", dn_flag
,
9557 peer
->hostname
, peer
->host
);
9559 snprintf(neighbor_buf
,
9560 sizeof(neighbor_buf
), "%s%s ",
9561 dn_flag
, peer
->host
);
9563 len
= strlen(neighbor_buf
);
9565 if (len
> max_neighbor_width
)
9566 max_neighbor_width
= len
;
9568 /* See if we have at least a single failed peer */
9569 if (bgp_has_peer_failed(peer
, afi
, safi
))
9575 /* Originally we displayed the Neighbor column as 16
9576 * characters wide so make that the default
9578 if (max_neighbor_width
< neighbor_col_default_width
)
9579 max_neighbor_width
= neighbor_col_default_width
;
9582 if (show_failed
&& !failed_count
) {
9584 json_object_int_add(json
, "failedPeersCount", 0);
9585 json_object_int_add(json
, "dynamicPeers", dn_count
);
9586 json_object_int_add(json
, "totalPeers", count
);
9588 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
9589 json
, JSON_C_TO_STRING_PRETTY
));
9590 json_object_free(json
);
9592 vty_out(vty
, "%% No failed BGP neighbors found\n");
9593 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
9598 count
= 0; /* Reset the value as its used again */
9599 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
9600 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
9603 if (!peer
->afc
[afi
][safi
])
9608 char memstrbuf
[MTYPE_MEMSTR_LEN
];
9611 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
9613 : (int64_t)bgp
->vrf_id
;
9615 /* Usage summary and header */
9617 json_object_string_add(
9619 inet_ntoa(bgp
->router_id
));
9620 json_object_int_add(json
, "as", bgp
->as
);
9621 json_object_int_add(json
, "vrfId", vrf_id_ui
);
9622 json_object_string_add(
9625 == BGP_INSTANCE_TYPE_DEFAULT
)
9630 "BGP router identifier %s, local AS number %u vrf-id %d",
9631 inet_ntoa(bgp
->router_id
), bgp
->as
,
9632 bgp
->vrf_id
== VRF_UNKNOWN
9634 : (int)bgp
->vrf_id
);
9638 if (bgp_update_delay_configured(bgp
)) {
9640 json_object_int_add(
9641 json
, "updateDelayLimit",
9642 bgp
->v_update_delay
);
9644 if (bgp
->v_update_delay
9645 != bgp
->v_establish_wait
)
9646 json_object_int_add(
9648 "updateDelayEstablishWait",
9649 bgp
->v_establish_wait
);
9651 if (bgp_update_delay_active(bgp
)) {
9652 json_object_string_add(
9654 "updateDelayFirstNeighbor",
9655 bgp
->update_delay_begin_time
);
9656 json_object_boolean_true_add(
9658 "updateDelayInProgress");
9660 if (bgp
->update_delay_over
) {
9661 json_object_string_add(
9663 "updateDelayFirstNeighbor",
9664 bgp
->update_delay_begin_time
);
9665 json_object_string_add(
9667 "updateDelayBestpathResumed",
9668 bgp
->update_delay_end_time
);
9669 json_object_string_add(
9671 "updateDelayZebraUpdateResume",
9672 bgp
->update_delay_zebra_resume_time
);
9673 json_object_string_add(
9675 "updateDelayPeerUpdateResume",
9676 bgp
->update_delay_peers_resume_time
);
9681 "Read-only mode update-delay limit: %d seconds\n",
9682 bgp
->v_update_delay
);
9683 if (bgp
->v_update_delay
9684 != bgp
->v_establish_wait
)
9686 " Establish wait: %d seconds\n",
9687 bgp
->v_establish_wait
);
9689 if (bgp_update_delay_active(bgp
)) {
9691 " First neighbor established: %s\n",
9692 bgp
->update_delay_begin_time
);
9694 " Delay in progress\n");
9696 if (bgp
->update_delay_over
) {
9698 " First neighbor established: %s\n",
9699 bgp
->update_delay_begin_time
);
9701 " Best-paths resumed: %s\n",
9702 bgp
->update_delay_end_time
);
9704 " zebra update resumed: %s\n",
9705 bgp
->update_delay_zebra_resume_time
);
9707 " peers update resumed: %s\n",
9708 bgp
->update_delay_peers_resume_time
);
9715 if (bgp_maxmed_onstartup_configured(bgp
)
9716 && bgp
->maxmed_active
)
9717 json_object_boolean_true_add(
9718 json
, "maxMedOnStartup");
9719 if (bgp
->v_maxmed_admin
)
9720 json_object_boolean_true_add(
9721 json
, "maxMedAdministrative");
9723 json_object_int_add(
9724 json
, "tableVersion",
9725 bgp_table_version(bgp
->rib
[afi
][safi
]));
9727 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
9728 json_object_int_add(json
, "ribCount", ents
);
9729 json_object_int_add(
9731 ents
* sizeof(struct bgp_dest
));
9733 ents
= bgp
->af_peer_count
[afi
][safi
];
9734 json_object_int_add(json
, "peerCount", ents
);
9735 json_object_int_add(json
, "peerMemory",
9736 ents
* sizeof(struct peer
));
9738 if ((ents
= listcount(bgp
->group
))) {
9739 json_object_int_add(
9740 json
, "peerGroupCount", ents
);
9741 json_object_int_add(
9742 json
, "peerGroupMemory",
9743 ents
* sizeof(struct
9747 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
9748 BGP_CONFIG_DAMPENING
))
9749 json_object_boolean_true_add(
9750 json
, "dampeningEnabled");
9752 if (bgp_maxmed_onstartup_configured(bgp
)
9753 && bgp
->maxmed_active
)
9755 "Max-med on-startup active\n");
9756 if (bgp
->v_maxmed_admin
)
9758 "Max-med administrative active\n");
9760 vty_out(vty
, "BGP table version %" PRIu64
"\n",
9761 bgp_table_version(bgp
->rib
[afi
][safi
]));
9763 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
9765 "RIB entries %ld, using %s of memory\n",
9768 memstrbuf
, sizeof(memstrbuf
),
9773 /* Peer related usage */
9774 ents
= bgp
->af_peer_count
[afi
][safi
];
9775 vty_out(vty
, "Peers %ld, using %s of memory\n",
9778 memstrbuf
, sizeof(memstrbuf
),
9779 ents
* sizeof(struct peer
)));
9781 if ((ents
= listcount(bgp
->group
)))
9783 "Peer groups %ld, using %s of memory\n",
9788 ents
* sizeof(struct
9791 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
9792 BGP_CONFIG_DAMPENING
))
9793 vty_out(vty
, "Dampening enabled.\n");
9796 /* Subtract 8 here because 'Neighbor' is
9798 vty_out(vty
, "Neighbor");
9799 vty_out(vty
, "%*s", max_neighbor_width
- 8,
9802 vty_out(vty
, "EstdCnt DropCnt ResetTime Reason\n");
9805 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt\n");
9809 paf
= peer_af_find(peer
, afi
, safi
);
9810 filter
= &peer
->filter
[afi
][safi
];
9813 /* Works for both failed & successful cases */
9814 if (peer_dynamic_neighbor(peer
))
9821 bgp_has_peer_failed(peer
, afi
, safi
)) {
9822 json_peer
= json_object_new_object();
9823 bgp_show_failed_summary(vty
, bgp
, peer
,
9824 json_peer
, 0, use_json
);
9825 } else if (!show_failed
) {
9826 if (show_established
9827 && bgp_has_peer_failed(peer
, afi
, safi
))
9830 json_peer
= json_object_new_object();
9831 if (peer_dynamic_neighbor(peer
)) {
9832 json_object_boolean_true_add(json_peer
,
9837 json_object_string_add(json_peer
, "hostname",
9840 if (peer
->domainname
)
9841 json_object_string_add(json_peer
, "domainname",
9844 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
9845 json_object_int_add(json_peer
, "version", 4);
9846 json_object_int_add(json_peer
, "msgRcvd",
9847 PEER_TOTAL_RX(peer
));
9848 json_object_int_add(json_peer
, "msgSent",
9849 PEER_TOTAL_TX(peer
));
9851 atomic_size_t outq_count
, inq_count
;
9852 outq_count
= atomic_load_explicit(
9854 memory_order_relaxed
);
9855 inq_count
= atomic_load_explicit(
9857 memory_order_relaxed
);
9859 json_object_int_add(json_peer
, "tableVersion",
9860 peer
->version
[afi
][safi
]);
9861 json_object_int_add(json_peer
, "outq",
9863 json_object_int_add(json_peer
, "inq",
9865 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9866 use_json
, json_peer
);
9868 json_object_int_add(json_peer
, "pfxRcd",
9869 peer
->pcount
[afi
][pfx_rcd_safi
]);
9871 if (paf
&& PAF_SUBGRP(paf
))
9872 json_object_int_add(json_peer
,
9874 (PAF_SUBGRP(paf
))->scount
);
9875 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
9876 || CHECK_FLAG(peer
->bgp
->flags
,
9878 json_object_string_add(json_peer
, "state",
9880 else if (peer
->afc_recv
[afi
][safi
])
9881 json_object_string_add(
9883 lookup_msg(bgp_status_msg
, peer
->status
,
9885 else if (CHECK_FLAG(peer
->sflags
,
9886 PEER_STATUS_PREFIX_OVERFLOW
))
9887 json_object_string_add(json_peer
, "state",
9890 json_object_string_add(
9892 lookup_msg(bgp_status_msg
, peer
->status
,
9894 json_object_int_add(json_peer
, "connectionsEstablished",
9896 json_object_int_add(json_peer
, "connectionsDropped",
9899 /* Avoid creating empty peer dicts in JSON */
9900 if (json_peer
== NULL
)
9904 json_object_string_add(json_peer
, "idType",
9906 else if (peer
->su
.sa
.sa_family
== AF_INET
)
9907 json_object_string_add(json_peer
, "idType",
9909 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
9910 json_object_string_add(json_peer
, "idType",
9912 json_object_object_add(json_peers
, peer
->host
,
9916 bgp_has_peer_failed(peer
, afi
, safi
)) {
9917 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
9920 } else if (!show_failed
) {
9921 if (show_established
9922 && bgp_has_peer_failed(peer
, afi
, safi
))
9925 memset(dn_flag
, '\0', sizeof(dn_flag
));
9926 if (peer_dynamic_neighbor(peer
)) {
9931 && CHECK_FLAG(bgp
->flags
,
9932 BGP_FLAG_SHOW_HOSTNAME
))
9933 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
9937 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
9939 /* pad the neighbor column with spaces */
9940 if (len
< max_neighbor_width
)
9941 vty_out(vty
, "%*s", max_neighbor_width
- len
,
9944 atomic_size_t outq_count
, inq_count
;
9945 outq_count
= atomic_load_explicit(
9947 memory_order_relaxed
);
9948 inq_count
= atomic_load_explicit(
9950 memory_order_relaxed
);
9953 "4 %10u %9u %9u %8" PRIu64
" %4zu %4zu %8s",
9954 peer
->as
, PEER_TOTAL_RX(peer
),
9955 PEER_TOTAL_TX(peer
),
9956 peer
->version
[afi
][safi
], inq_count
,
9958 peer_uptime(peer
->uptime
, timebuf
,
9959 BGP_UPTIME_LEN
, 0, NULL
));
9961 if (peer
->status
== Established
) {
9962 if (peer
->afc_recv
[afi
][safi
]) {
9965 BGP_FLAG_EBGP_REQUIRES_POLICY
)
9966 && !bgp_inbound_policy_exists(
9968 vty_out(vty
, " %12s",
9977 vty_out(vty
, " NoNeg");
9980 if (paf
&& PAF_SUBGRP(paf
)) {
9983 BGP_FLAG_EBGP_REQUIRES_POLICY
)
9984 && !bgp_outbound_policy_exists(
9986 vty_out(vty
, " %8s",
9996 if (CHECK_FLAG(peer
->flags
,
9998 || CHECK_FLAG(peer
->bgp
->flags
,
10000 vty_out(vty
, " Idle (Admin)");
10001 else if (CHECK_FLAG(
10003 PEER_STATUS_PREFIX_OVERFLOW
))
10004 vty_out(vty
, " Idle (PfxCt)");
10006 vty_out(vty
, " %12s",
10007 lookup_msg(bgp_status_msg
,
10008 peer
->status
, NULL
));
10010 vty_out(vty
, " %8u", 0);
10012 vty_out(vty
, "\n");
10019 json_object_object_add(json
, "peers", json_peers
);
10020 json_object_int_add(json
, "failedPeers", failed_count
);
10021 json_object_int_add(json
, "totalPeers", count
);
10022 json_object_int_add(json
, "dynamicPeers", dn_count
);
10025 bgp_show_bestpath_json(bgp
, json
);
10027 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10028 json
, JSON_C_TO_STRING_PRETTY
));
10029 json_object_free(json
);
10032 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
10034 vty_out(vty
, "No %s neighbor is configured\n",
10035 get_afi_safi_str(afi
, safi
, false));
10039 vty_out(vty
, "* - dynamic neighbor\n");
10040 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
10041 dn_count
, bgp
->dynamic_neighbors_limit
);
10045 return CMD_SUCCESS
;
10048 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
10049 int safi
, bool show_failed
,
10050 bool show_established
, bool use_json
)
10053 int afi_wildcard
= (afi
== AFI_MAX
);
10054 int safi_wildcard
= (safi
== SAFI_MAX
);
10055 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
10056 bool nbr_output
= false;
10058 if (use_json
&& is_wildcard
)
10059 vty_out(vty
, "{\n");
10061 afi
= 1; /* AFI_IP */
10062 while (afi
< AFI_MAX
) {
10064 safi
= 1; /* SAFI_UNICAST */
10065 while (safi
< SAFI_MAX
) {
10066 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
10071 * So limit output to those afi/safi
10073 * actualy have something interesting in
10078 vty_out(vty
, ",\n");
10082 vty_out(vty
, "\"%s\":",
10083 get_afi_safi_str(afi
,
10087 vty_out(vty
, "\n%s Summary:\n",
10088 get_afi_safi_str(afi
,
10093 bgp_show_summary(vty
, bgp
, afi
, safi
,
10094 show_failed
, show_established
,
10098 if (!safi_wildcard
)
10106 if (use_json
&& is_wildcard
)
10107 vty_out(vty
, "}\n");
10108 else if (!nbr_output
) {
10110 vty_out(vty
, "{}\n");
10112 vty_out(vty
, "%% No BGP neighbors found\n");
10116 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
10117 safi_t safi
, bool show_failed
,
10118 bool show_established
,
10121 struct listnode
*node
, *nnode
;
10124 bool nbr_output
= false;
10127 vty_out(vty
, "{\n");
10129 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
10133 vty_out(vty
, ",\n");
10137 vty_out(vty
, "\"%s\":",
10138 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10142 vty_out(vty
, "\nInstance %s:\n",
10143 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10147 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
10148 show_established
, use_json
);
10152 vty_out(vty
, "}\n");
10153 else if (!nbr_output
)
10154 vty_out(vty
, "%% BGP instance not found\n");
10157 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
10158 safi_t safi
, bool show_failed
, bool show_established
,
10164 if (strmatch(name
, "all")) {
10165 bgp_show_all_instances_summary_vty(
10166 vty
, afi
, safi
, show_failed
, show_established
,
10168 return CMD_SUCCESS
;
10170 bgp
= bgp_lookup_by_name(name
);
10174 vty_out(vty
, "{}\n");
10177 "%% BGP instance not found\n");
10178 return CMD_WARNING
;
10181 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
,
10182 show_failed
, show_established
,
10184 return CMD_SUCCESS
;
10188 bgp
= bgp_get_default();
10191 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
10192 show_established
, use_json
);
10195 vty_out(vty
, "{}\n");
10197 vty_out(vty
, "%% BGP instance not found\n");
10198 return CMD_WARNING
;
10201 return CMD_SUCCESS
;
10204 /* `show [ip] bgp summary' commands. */
10205 DEFPY (show_ip_bgp_summary
,
10206 show_ip_bgp_summary_cmd
,
10207 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] [all$all] summary [established|failed] [json$uj]",
10211 BGP_INSTANCE_HELP_STR
10213 BGP_SAFI_WITH_LABEL_HELP_STR
10214 "Display the entries for all address families\n"
10215 "Summary of BGP neighbor status\n"
10216 "Show only sessions in Established state\n"
10217 "Show only sessions not in Established state\n"
10221 afi_t afi
= AFI_MAX
;
10222 safi_t safi
= SAFI_MAX
;
10223 bool show_failed
= false;
10224 bool show_established
= false;
10228 /* show [ip] bgp */
10229 if (!all
&& argv_find(argv
, argc
, "ip", &idx
))
10231 /* [<vrf> VIEWVRFNAME] */
10232 if (argv_find(argv
, argc
, "vrf", &idx
)) {
10233 vrf
= argv
[idx
+ 1]->arg
;
10234 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
10236 } else if (argv_find(argv
, argc
, "view", &idx
))
10237 /* [<view> VIEWVRFNAME] */
10238 vrf
= argv
[idx
+ 1]->arg
;
10239 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
10240 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
10241 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
10244 if (argv_find(argv
, argc
, "failed", &idx
))
10245 show_failed
= true;
10246 if (argv_find(argv
, argc
, "established", &idx
))
10247 show_established
= true;
10249 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, show_failed
,
10250 show_established
, uj
);
10253 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
10256 return get_afi_safi_json_str(afi
, safi
);
10258 return get_afi_safi_vty_str(afi
, safi
);
10262 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
10263 afi_t afi
, safi_t safi
,
10264 uint16_t adv_smcap
, uint16_t adv_rmcap
,
10265 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
10266 bool use_json
, json_object
*json_pref
)
10269 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
10270 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
10272 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
10273 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
10274 json_object_string_add(json_pref
, "sendMode",
10275 "advertisedAndReceived");
10276 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
10277 json_object_string_add(json_pref
, "sendMode",
10279 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
10280 json_object_string_add(json_pref
, "sendMode",
10283 vty_out(vty
, " Send-mode: ");
10284 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
10285 vty_out(vty
, "advertised");
10286 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
10287 vty_out(vty
, "%sreceived",
10288 CHECK_FLAG(p
->af_cap
[afi
][safi
],
10292 vty_out(vty
, "\n");
10297 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
10298 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
10300 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
10301 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
10302 json_object_string_add(json_pref
, "recvMode",
10303 "advertisedAndReceived");
10304 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
10305 json_object_string_add(json_pref
, "recvMode",
10307 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
10308 json_object_string_add(json_pref
, "recvMode",
10311 vty_out(vty
, " Receive-mode: ");
10312 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
10313 vty_out(vty
, "advertised");
10314 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
10315 vty_out(vty
, "%sreceived",
10316 CHECK_FLAG(p
->af_cap
[afi
][safi
],
10320 vty_out(vty
, "\n");
10325 static void bgp_show_neighnor_graceful_restart_rbit(struct vty
*vty
,
10330 bool rbit_status
= false;
10333 vty_out(vty
, "\n R bit: ");
10335 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
10336 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
10337 && (p
->status
== Established
)) {
10339 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_BIT_RCV
))
10340 rbit_status
= true;
10342 rbit_status
= false;
10347 json_object_boolean_true_add(json
, "rBit");
10349 vty_out(vty
, "True\n");
10352 json_object_boolean_false_add(json
, "rBit");
10354 vty_out(vty
, "False\n");
10358 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
10363 const char *mode
= "NotApplicable";
10366 vty_out(vty
, "\n Remote GR Mode: ");
10368 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
10369 && (peer
->status
== Established
)) {
10371 if ((peer
->nsf_af_count
== 0)
10372 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
10376 } else if (peer
->nsf_af_count
== 0
10377 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
10381 } else if (peer
->nsf_af_count
!= 0
10382 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
10389 json_object_string_add(json
, "remoteGrMode", mode
);
10391 vty_out(vty
, mode
, "\n");
10394 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
10399 const char *mode
= "Invalid";
10402 vty_out(vty
, " Local GR Mode: ");
10404 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
10406 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
10408 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
10410 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
10411 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
10413 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
10415 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
10422 json_object_string_add(json
, "localGrMode", mode
);
10424 vty_out(vty
, mode
, "\n");
10428 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
10429 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
10433 json_object
*json_afi_safi
= NULL
;
10434 json_object
*json_timer
= NULL
;
10435 json_object
*json_endofrib_status
= NULL
;
10436 bool eor_flag
= false;
10438 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
10439 for (safi
= SAFI_UNICAST
; safi
<= SAFI_MPLS_VPN
; safi
++) {
10440 if (!peer
->afc
[afi
][safi
])
10443 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
10444 || !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
10448 json_afi_safi
= json_object_new_object();
10449 json_endofrib_status
= json_object_new_object();
10450 json_timer
= json_object_new_object();
10453 if (peer
->eor_stime
[afi
][safi
]
10454 >= peer
->pkt_stime
[afi
][safi
])
10460 vty_out(vty
, " %s:\n",
10461 get_afi_safi_str(afi
, safi
, false));
10463 vty_out(vty
, " F bit: ");
10466 if (peer
->nsf
[afi
][safi
]
10467 && CHECK_FLAG(peer
->af_cap
[afi
][safi
],
10468 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
10471 json_object_boolean_true_add(
10472 json_afi_safi
, "fBit");
10474 vty_out(vty
, "True\n");
10477 json_object_boolean_false_add(
10478 json_afi_safi
, "fBit");
10480 vty_out(vty
, "False\n");
10484 vty_out(vty
, " End-of-RIB sent: ");
10486 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
10487 PEER_STATUS_EOR_SEND
)) {
10489 json_object_boolean_true_add(
10490 json_endofrib_status
,
10493 PRINT_EOR_JSON(eor_flag
);
10495 vty_out(vty
, "Yes\n");
10497 " End-of-RIB sent after update: ");
10499 PRINT_EOR(eor_flag
);
10503 json_object_boolean_false_add(
10504 json_endofrib_status
,
10506 json_object_boolean_false_add(
10507 json_endofrib_status
,
10508 "endOfRibSentAfterUpdate");
10510 vty_out(vty
, "No\n");
10512 " End-of-RIB sent after update: ");
10513 vty_out(vty
, "No\n");
10518 vty_out(vty
, " End-of-RIB received: ");
10520 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
10521 PEER_STATUS_EOR_RECEIVED
)) {
10523 json_object_boolean_true_add(
10524 json_endofrib_status
,
10527 vty_out(vty
, "Yes\n");
10530 json_object_boolean_false_add(
10531 json_endofrib_status
,
10534 vty_out(vty
, "No\n");
10538 json_object_int_add(json_timer
,
10540 peer
->bgp
->stalepath_time
);
10542 if (peer
->t_gr_stale
!= NULL
) {
10543 json_object_int_add(
10545 "stalePathTimerRemaining",
10546 thread_timer_remain_second(
10547 peer
->t_gr_stale
));
10550 /* Display Configured Selection
10551 * Deferral only when when
10552 * Gr mode is enabled.
10554 if (CHECK_FLAG(peer
->flags
,
10555 PEER_FLAG_GRACEFUL_RESTART
)) {
10556 json_object_int_add(
10558 "selectionDeferralTimer",
10559 peer
->bgp
->stalepath_time
);
10562 if (peer
->bgp
->gr_info
[afi
][safi
]
10566 json_object_int_add(
10568 "selectionDeferralTimerRemaining",
10569 thread_timer_remain_second(
10573 .t_select_deferral
));
10576 vty_out(vty
, " Timers:\n");
10578 " Configured Stale Path Time(sec): %u\n",
10579 peer
->bgp
->stalepath_time
);
10581 if (peer
->t_gr_stale
!= NULL
)
10583 " Stale Path Remaining(sec): %ld\n",
10584 thread_timer_remain_second(
10585 peer
->t_gr_stale
));
10586 /* Display Configured Selection
10587 * Deferral only when when
10588 * Gr mode is enabled.
10590 if (CHECK_FLAG(peer
->flags
,
10591 PEER_FLAG_GRACEFUL_RESTART
))
10593 " Configured Selection Deferral Time(sec): %u\n",
10594 peer
->bgp
->select_defer_time
);
10596 if (peer
->bgp
->gr_info
[afi
][safi
]
10600 " Selection Deferral Time Remaining(sec): %ld\n",
10601 thread_timer_remain_second(
10605 .t_select_deferral
));
10608 json_object_object_add(json_afi_safi
,
10610 json_endofrib_status
);
10611 json_object_object_add(json_afi_safi
, "timers",
10613 json_object_object_add(
10614 json
, get_afi_safi_str(afi
, safi
, true),
10621 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
10627 json_object
*json_timer
= NULL
;
10629 json_timer
= json_object_new_object();
10631 json_object_int_add(json_timer
, "configuredRestartTimer",
10632 p
->bgp
->restart_time
);
10634 json_object_int_add(json_timer
, "receivedRestartTimer",
10637 if (p
->t_gr_restart
!= NULL
)
10638 json_object_int_add(
10639 json_timer
, "restartTimerRemaining",
10640 thread_timer_remain_second(p
->t_gr_restart
));
10642 json_object_object_add(json
, "timers", json_timer
);
10645 vty_out(vty
, " Timers:\n");
10646 vty_out(vty
, " Configured Restart Time(sec): %u\n",
10647 p
->bgp
->restart_time
);
10649 vty_out(vty
, " Received Restart Time(sec): %u\n",
10651 if (p
->t_gr_restart
!= NULL
)
10652 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
10653 thread_timer_remain_second(p
->t_gr_restart
));
10654 if (p
->t_gr_restart
!= NULL
) {
10655 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
10656 thread_timer_remain_second(p
->t_gr_restart
));
10661 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
10662 bool use_json
, json_object
*json
)
10664 char buf
[SU_ADDRSTRLEN
] = {0};
10665 char dn_flag
[2] = {0};
10666 /* '*' + v6 address of neighbor */
10667 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
10669 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
10674 json_object_string_add(
10675 json
, "neighborAddr",
10676 BGP_PEER_SU_UNSPEC(p
)
10678 : sockunion2str(&p
->su
, buf
,
10681 vty_out(vty
, "BGP neighbor on %s: %s\n", p
->conf_if
,
10682 BGP_PEER_SU_UNSPEC(p
)
10684 : sockunion2str(&p
->su
, buf
,
10687 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
10691 json_object_string_add(json
, "neighborAddr",
10694 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
10697 /* more gr info in new format */
10698 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
10701 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
10702 safi_t safi
, bool use_json
,
10703 json_object
*json_neigh
)
10705 struct bgp_filter
*filter
;
10706 struct peer_af
*paf
;
10707 char orf_pfx_name
[BUFSIZ
];
10709 json_object
*json_af
= NULL
;
10710 json_object
*json_prefA
= NULL
;
10711 json_object
*json_prefB
= NULL
;
10712 json_object
*json_addr
= NULL
;
10715 json_addr
= json_object_new_object();
10716 json_af
= json_object_new_object();
10717 filter
= &p
->filter
[afi
][safi
];
10719 if (peer_group_active(p
))
10720 json_object_string_add(json_addr
, "peerGroupMember",
10723 paf
= peer_af_find(p
, afi
, safi
);
10724 if (paf
&& PAF_SUBGRP(paf
)) {
10725 json_object_int_add(json_addr
, "updateGroupId",
10726 PAF_UPDGRP(paf
)->id
);
10727 json_object_int_add(json_addr
, "subGroupId",
10728 PAF_SUBGRP(paf
)->id
);
10729 json_object_int_add(json_addr
, "packetQueueLength",
10730 bpacket_queue_virtual_length(paf
));
10733 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
10734 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10735 PEER_CAP_ORF_PREFIX_SM_RCV
)
10736 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10737 PEER_CAP_ORF_PREFIX_RM_ADV
)
10738 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10739 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
10740 json_object_int_add(json_af
, "orfType",
10742 json_prefA
= json_object_new_object();
10743 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
10744 PEER_CAP_ORF_PREFIX_SM_ADV
,
10745 PEER_CAP_ORF_PREFIX_RM_ADV
,
10746 PEER_CAP_ORF_PREFIX_SM_RCV
,
10747 PEER_CAP_ORF_PREFIX_RM_RCV
,
10748 use_json
, json_prefA
);
10749 json_object_object_add(json_af
, "orfPrefixList",
10753 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
10754 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10755 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
10756 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10757 PEER_CAP_ORF_PREFIX_RM_ADV
)
10758 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10759 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
10760 json_object_int_add(json_af
, "orfOldType",
10761 ORF_TYPE_PREFIX_OLD
);
10762 json_prefB
= json_object_new_object();
10763 bgp_show_peer_afi_orf_cap(
10764 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
10765 PEER_CAP_ORF_PREFIX_RM_ADV
,
10766 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
10767 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
10769 json_object_object_add(json_af
, "orfOldPrefixList",
10773 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
10774 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10775 PEER_CAP_ORF_PREFIX_SM_RCV
)
10776 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10777 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
10778 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10779 PEER_CAP_ORF_PREFIX_RM_ADV
)
10780 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10781 PEER_CAP_ORF_PREFIX_RM_RCV
)
10782 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10783 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
10784 json_object_object_add(json_addr
, "afDependentCap",
10787 json_object_free(json_af
);
10789 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
10790 p
->host
, afi
, safi
);
10791 orf_pfx_count
= prefix_bgp_show_prefix_list(
10792 NULL
, afi
, orf_pfx_name
, use_json
);
10794 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10795 PEER_STATUS_ORF_PREFIX_SEND
)
10796 || orf_pfx_count
) {
10797 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10798 PEER_STATUS_ORF_PREFIX_SEND
))
10799 json_object_boolean_true_add(json_neigh
,
10802 json_object_int_add(json_addr
, "orfRecvCounter",
10805 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10806 PEER_STATUS_ORF_WAIT_REFRESH
))
10807 json_object_string_add(
10808 json_addr
, "orfFirstUpdate",
10809 "deferredUntilORFOrRouteRefreshRecvd");
10811 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10812 PEER_FLAG_REFLECTOR_CLIENT
))
10813 json_object_boolean_true_add(json_addr
,
10814 "routeReflectorClient");
10815 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10816 PEER_FLAG_RSERVER_CLIENT
))
10817 json_object_boolean_true_add(json_addr
,
10818 "routeServerClient");
10819 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
10820 json_object_boolean_true_add(json_addr
,
10821 "inboundSoftConfigPermit");
10823 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10824 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
10825 json_object_boolean_true_add(
10827 "privateAsNumsAllReplacedInUpdatesToNbr");
10828 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10829 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
10830 json_object_boolean_true_add(
10832 "privateAsNumsReplacedInUpdatesToNbr");
10833 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10834 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
10835 json_object_boolean_true_add(
10837 "privateAsNumsAllRemovedInUpdatesToNbr");
10838 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10839 PEER_FLAG_REMOVE_PRIVATE_AS
))
10840 json_object_boolean_true_add(
10842 "privateAsNumsRemovedInUpdatesToNbr");
10844 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
10845 json_object_boolean_true_add(
10847 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
10850 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
10851 json_object_string_add(json_addr
,
10852 "overrideASNsInOutboundUpdates",
10853 "ifAspathEqualRemoteAs");
10855 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
10856 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
10857 PEER_FLAG_FORCE_NEXTHOP_SELF
))
10858 json_object_boolean_true_add(json_addr
,
10859 "routerAlwaysNextHop");
10860 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10861 PEER_FLAG_AS_PATH_UNCHANGED
))
10862 json_object_boolean_true_add(
10863 json_addr
, "unchangedAsPathPropogatedToNbr");
10864 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10865 PEER_FLAG_NEXTHOP_UNCHANGED
))
10866 json_object_boolean_true_add(
10867 json_addr
, "unchangedNextHopPropogatedToNbr");
10868 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
10869 json_object_boolean_true_add(
10870 json_addr
, "unchangedMedPropogatedToNbr");
10871 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
10872 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
10873 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
10874 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10875 PEER_FLAG_SEND_COMMUNITY
)
10876 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
10877 PEER_FLAG_SEND_EXT_COMMUNITY
))
10878 json_object_string_add(json_addr
,
10879 "commAttriSentToNbr",
10880 "extendedAndStandard");
10881 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10882 PEER_FLAG_SEND_EXT_COMMUNITY
))
10883 json_object_string_add(json_addr
,
10884 "commAttriSentToNbr",
10887 json_object_string_add(json_addr
,
10888 "commAttriSentToNbr",
10891 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10892 PEER_FLAG_DEFAULT_ORIGINATE
)) {
10893 if (p
->default_rmap
[afi
][safi
].name
)
10894 json_object_string_add(
10895 json_addr
, "defaultRouteMap",
10896 p
->default_rmap
[afi
][safi
].name
);
10898 if (paf
&& PAF_SUBGRP(paf
)
10899 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
10900 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
10901 json_object_boolean_true_add(json_addr
,
10904 json_object_boolean_true_add(json_addr
,
10908 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
10909 if (is_evpn_enabled())
10910 json_object_boolean_true_add(
10911 json_addr
, "advertiseAllVnis");
10914 if (filter
->plist
[FILTER_IN
].name
10915 || filter
->dlist
[FILTER_IN
].name
10916 || filter
->aslist
[FILTER_IN
].name
10917 || filter
->map
[RMAP_IN
].name
)
10918 json_object_boolean_true_add(json_addr
,
10919 "inboundPathPolicyConfig");
10920 if (filter
->plist
[FILTER_OUT
].name
10921 || filter
->dlist
[FILTER_OUT
].name
10922 || filter
->aslist
[FILTER_OUT
].name
10923 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
10924 json_object_boolean_true_add(
10925 json_addr
, "outboundPathPolicyConfig");
10928 if (filter
->plist
[FILTER_IN
].name
)
10929 json_object_string_add(json_addr
,
10930 "incomingUpdatePrefixFilterList",
10931 filter
->plist
[FILTER_IN
].name
);
10932 if (filter
->plist
[FILTER_OUT
].name
)
10933 json_object_string_add(json_addr
,
10934 "outgoingUpdatePrefixFilterList",
10935 filter
->plist
[FILTER_OUT
].name
);
10937 /* distribute-list */
10938 if (filter
->dlist
[FILTER_IN
].name
)
10939 json_object_string_add(
10940 json_addr
, "incomingUpdateNetworkFilterList",
10941 filter
->dlist
[FILTER_IN
].name
);
10942 if (filter
->dlist
[FILTER_OUT
].name
)
10943 json_object_string_add(
10944 json_addr
, "outgoingUpdateNetworkFilterList",
10945 filter
->dlist
[FILTER_OUT
].name
);
10948 if (filter
->aslist
[FILTER_IN
].name
)
10949 json_object_string_add(json_addr
,
10950 "incomingUpdateAsPathFilterList",
10951 filter
->aslist
[FILTER_IN
].name
);
10952 if (filter
->aslist
[FILTER_OUT
].name
)
10953 json_object_string_add(json_addr
,
10954 "outgoingUpdateAsPathFilterList",
10955 filter
->aslist
[FILTER_OUT
].name
);
10958 if (filter
->map
[RMAP_IN
].name
)
10959 json_object_string_add(
10960 json_addr
, "routeMapForIncomingAdvertisements",
10961 filter
->map
[RMAP_IN
].name
);
10962 if (filter
->map
[RMAP_OUT
].name
)
10963 json_object_string_add(
10964 json_addr
, "routeMapForOutgoingAdvertisements",
10965 filter
->map
[RMAP_OUT
].name
);
10967 /* ebgp-requires-policy (inbound) */
10968 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
10969 && !bgp_inbound_policy_exists(p
, filter
))
10970 json_object_string_add(
10971 json_addr
, "inboundEbgpRequiresPolicy",
10972 "Inbound updates discarded due to missing policy");
10974 /* ebgp-requires-policy (outbound) */
10975 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
10976 && (!bgp_outbound_policy_exists(p
, filter
)))
10977 json_object_string_add(
10978 json_addr
, "outboundEbgpRequiresPolicy",
10979 "Outbound updates discarded due to missing policy");
10981 /* unsuppress-map */
10982 if (filter
->usmap
.name
)
10983 json_object_string_add(json_addr
,
10984 "selectiveUnsuppressRouteMap",
10985 filter
->usmap
.name
);
10987 /* Receive prefix count */
10988 json_object_int_add(json_addr
, "acceptedPrefixCounter",
10989 p
->pcount
[afi
][safi
]);
10990 if (paf
&& PAF_SUBGRP(paf
))
10991 json_object_int_add(json_addr
, "sentPrefixCounter",
10992 (PAF_SUBGRP(paf
))->scount
);
10994 /* Maximum prefix */
10995 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
10996 json_object_int_add(json_addr
, "prefixOutAllowedMax",
10997 p
->pmax_out
[afi
][safi
]);
10999 /* Maximum prefix */
11000 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
11001 json_object_int_add(json_addr
, "prefixAllowedMax",
11002 p
->pmax
[afi
][safi
]);
11003 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11004 PEER_FLAG_MAX_PREFIX_WARNING
))
11005 json_object_boolean_true_add(
11006 json_addr
, "prefixAllowedMaxWarning");
11007 json_object_int_add(json_addr
,
11008 "prefixAllowedWarningThresh",
11009 p
->pmax_threshold
[afi
][safi
]);
11010 if (p
->pmax_restart
[afi
][safi
])
11011 json_object_int_add(
11013 "prefixAllowedRestartIntervalMsecs",
11014 p
->pmax_restart
[afi
][safi
] * 60000);
11016 json_object_object_add(json_neigh
,
11017 get_afi_safi_str(afi
, safi
, true),
11021 filter
= &p
->filter
[afi
][safi
];
11023 vty_out(vty
, " For address family: %s\n",
11024 get_afi_safi_str(afi
, safi
, false));
11026 if (peer_group_active(p
))
11027 vty_out(vty
, " %s peer-group member\n",
11030 paf
= peer_af_find(p
, afi
, safi
);
11031 if (paf
&& PAF_SUBGRP(paf
)) {
11032 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
11033 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
11034 vty_out(vty
, " Packet Queue length %d\n",
11035 bpacket_queue_virtual_length(paf
));
11037 vty_out(vty
, " Not part of any update group\n");
11039 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11040 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11041 PEER_CAP_ORF_PREFIX_SM_RCV
)
11042 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11043 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11044 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11045 PEER_CAP_ORF_PREFIX_RM_ADV
)
11046 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11047 PEER_CAP_ORF_PREFIX_RM_RCV
)
11048 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11049 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
11050 vty_out(vty
, " AF-dependant capabilities:\n");
11052 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11053 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11054 PEER_CAP_ORF_PREFIX_SM_RCV
)
11055 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11056 PEER_CAP_ORF_PREFIX_RM_ADV
)
11057 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11058 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
11060 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
11062 bgp_show_peer_afi_orf_cap(
11063 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
11064 PEER_CAP_ORF_PREFIX_RM_ADV
,
11065 PEER_CAP_ORF_PREFIX_SM_RCV
,
11066 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
11068 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
11069 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11070 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
11071 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11072 PEER_CAP_ORF_PREFIX_RM_ADV
)
11073 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
11074 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
11076 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
11077 ORF_TYPE_PREFIX_OLD
);
11078 bgp_show_peer_afi_orf_cap(
11079 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
11080 PEER_CAP_ORF_PREFIX_RM_ADV
,
11081 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
11082 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
11085 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
11086 p
->host
, afi
, safi
);
11087 orf_pfx_count
= prefix_bgp_show_prefix_list(
11088 NULL
, afi
, orf_pfx_name
, use_json
);
11090 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11091 PEER_STATUS_ORF_PREFIX_SEND
)
11092 || orf_pfx_count
) {
11093 vty_out(vty
, " Outbound Route Filter (ORF):");
11094 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11095 PEER_STATUS_ORF_PREFIX_SEND
))
11096 vty_out(vty
, " sent;");
11098 vty_out(vty
, " received (%d entries)",
11100 vty_out(vty
, "\n");
11102 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11103 PEER_STATUS_ORF_WAIT_REFRESH
))
11105 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
11107 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11108 PEER_FLAG_REFLECTOR_CLIENT
))
11109 vty_out(vty
, " Route-Reflector Client\n");
11110 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11111 PEER_FLAG_RSERVER_CLIENT
))
11112 vty_out(vty
, " Route-Server Client\n");
11113 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
11115 " Inbound soft reconfiguration allowed\n");
11117 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11118 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
11120 " Private AS numbers (all) replaced in updates to this neighbor\n");
11121 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11122 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
11124 " Private AS numbers replaced in updates to this neighbor\n");
11125 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11126 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
11128 " Private AS numbers (all) removed in updates to this neighbor\n");
11129 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11130 PEER_FLAG_REMOVE_PRIVATE_AS
))
11132 " Private AS numbers removed in updates to this neighbor\n");
11134 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
11135 vty_out(vty
, " %s\n",
11136 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
11137 ->human_description
);
11139 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
11141 " Override ASNs in outbound updates if aspath equals remote-as\n");
11143 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
11144 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11145 PEER_FLAG_FORCE_NEXTHOP_SELF
))
11146 vty_out(vty
, " NEXT_HOP is always this router\n");
11147 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11148 PEER_FLAG_AS_PATH_UNCHANGED
))
11150 " AS_PATH is propagated unchanged to this neighbor\n");
11151 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11152 PEER_FLAG_NEXTHOP_UNCHANGED
))
11154 " NEXT_HOP is propagated unchanged to this neighbor\n");
11155 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
11157 " MED is propagated unchanged to this neighbor\n");
11158 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
11159 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11160 PEER_FLAG_SEND_EXT_COMMUNITY
)
11161 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
11162 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
11164 " Community attribute sent to this neighbor");
11165 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11166 PEER_FLAG_SEND_COMMUNITY
)
11167 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
11168 PEER_FLAG_SEND_EXT_COMMUNITY
)
11169 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
11170 PEER_FLAG_SEND_LARGE_COMMUNITY
))
11171 vty_out(vty
, "(all)\n");
11172 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11173 PEER_FLAG_SEND_LARGE_COMMUNITY
))
11174 vty_out(vty
, "(large)\n");
11175 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11176 PEER_FLAG_SEND_EXT_COMMUNITY
))
11177 vty_out(vty
, "(extended)\n");
11179 vty_out(vty
, "(standard)\n");
11181 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11182 PEER_FLAG_DEFAULT_ORIGINATE
)) {
11183 vty_out(vty
, " Default information originate,");
11185 if (p
->default_rmap
[afi
][safi
].name
)
11186 vty_out(vty
, " default route-map %s%s,",
11187 p
->default_rmap
[afi
][safi
].map
? "*"
11189 p
->default_rmap
[afi
][safi
].name
);
11190 if (paf
&& PAF_SUBGRP(paf
)
11191 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
11192 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
11193 vty_out(vty
, " default sent\n");
11195 vty_out(vty
, " default not sent\n");
11198 /* advertise-vni-all */
11199 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
11200 if (is_evpn_enabled())
11201 vty_out(vty
, " advertise-all-vni\n");
11204 if (filter
->plist
[FILTER_IN
].name
11205 || filter
->dlist
[FILTER_IN
].name
11206 || filter
->aslist
[FILTER_IN
].name
11207 || filter
->map
[RMAP_IN
].name
)
11208 vty_out(vty
, " Inbound path policy configured\n");
11209 if (filter
->plist
[FILTER_OUT
].name
11210 || filter
->dlist
[FILTER_OUT
].name
11211 || filter
->aslist
[FILTER_OUT
].name
11212 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
11213 vty_out(vty
, " Outbound path policy configured\n");
11216 if (filter
->plist
[FILTER_IN
].name
)
11218 " Incoming update prefix filter list is %s%s\n",
11219 filter
->plist
[FILTER_IN
].plist
? "*" : "",
11220 filter
->plist
[FILTER_IN
].name
);
11221 if (filter
->plist
[FILTER_OUT
].name
)
11223 " Outgoing update prefix filter list is %s%s\n",
11224 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
11225 filter
->plist
[FILTER_OUT
].name
);
11227 /* distribute-list */
11228 if (filter
->dlist
[FILTER_IN
].name
)
11230 " Incoming update network filter list is %s%s\n",
11231 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
11232 filter
->dlist
[FILTER_IN
].name
);
11233 if (filter
->dlist
[FILTER_OUT
].name
)
11235 " Outgoing update network filter list is %s%s\n",
11236 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
11237 filter
->dlist
[FILTER_OUT
].name
);
11240 if (filter
->aslist
[FILTER_IN
].name
)
11242 " Incoming update AS path filter list is %s%s\n",
11243 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
11244 filter
->aslist
[FILTER_IN
].name
);
11245 if (filter
->aslist
[FILTER_OUT
].name
)
11247 " Outgoing update AS path filter list is %s%s\n",
11248 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
11249 filter
->aslist
[FILTER_OUT
].name
);
11252 if (filter
->map
[RMAP_IN
].name
)
11254 " Route map for incoming advertisements is %s%s\n",
11255 filter
->map
[RMAP_IN
].map
? "*" : "",
11256 filter
->map
[RMAP_IN
].name
);
11257 if (filter
->map
[RMAP_OUT
].name
)
11259 " Route map for outgoing advertisements is %s%s\n",
11260 filter
->map
[RMAP_OUT
].map
? "*" : "",
11261 filter
->map
[RMAP_OUT
].name
);
11263 /* ebgp-requires-policy (inbound) */
11264 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
11265 && !bgp_inbound_policy_exists(p
, filter
))
11267 " Inbound updates discarded due to missing policy\n");
11269 /* ebgp-requires-policy (outbound) */
11270 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
11271 && !bgp_outbound_policy_exists(p
, filter
))
11273 " Outbound updates discarded due to missing policy\n");
11275 /* unsuppress-map */
11276 if (filter
->usmap
.name
)
11278 " Route map for selective unsuppress is %s%s\n",
11279 filter
->usmap
.map
? "*" : "",
11280 filter
->usmap
.name
);
11282 /* Receive prefix count */
11283 vty_out(vty
, " %u accepted prefixes\n",
11284 p
->pcount
[afi
][safi
]);
11286 /* maximum-prefix-out */
11287 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
11288 PEER_FLAG_MAX_PREFIX_OUT
))
11290 " Maximum allowed prefixes sent %u\n",
11291 p
->pmax_out
[afi
][safi
]);
11293 /* Maximum prefix */
11294 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
11296 " Maximum prefixes allowed %u%s\n",
11297 p
->pmax
[afi
][safi
],
11298 CHECK_FLAG(p
->af_flags
[afi
][safi
],
11299 PEER_FLAG_MAX_PREFIX_WARNING
)
11300 ? " (warning-only)"
11302 vty_out(vty
, " Threshold for warning message %d%%",
11303 p
->pmax_threshold
[afi
][safi
]);
11304 if (p
->pmax_restart
[afi
][safi
])
11305 vty_out(vty
, ", restart interval %d min",
11306 p
->pmax_restart
[afi
][safi
]);
11307 vty_out(vty
, "\n");
11310 vty_out(vty
, "\n");
11314 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
11318 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
11319 char timebuf
[BGP_UPTIME_LEN
];
11325 json_object
*json_neigh
= NULL
;
11331 json_neigh
= json_object_new_object();
11333 memset(dn_flag
, '\0', sizeof(dn_flag
));
11334 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
11338 if (p
->conf_if
) /* Configured interface name. */
11339 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
11340 BGP_PEER_SU_UNSPEC(p
)
11342 : sockunion2str(&p
->su
, buf
,
11344 else /* Configured IP address. */
11345 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
11350 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
11351 json_object_string_add(json_neigh
, "bgpNeighborAddr",
11353 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
11354 json_object_string_add(
11355 json_neigh
, "bgpNeighborAddr",
11356 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
11358 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
11360 if (p
->change_local_as
)
11361 json_object_int_add(json_neigh
, "localAs",
11362 p
->change_local_as
);
11364 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
11366 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
11367 json_object_boolean_true_add(json_neigh
,
11368 "localAsNoPrepend");
11370 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
11371 json_object_boolean_true_add(json_neigh
,
11372 "localAsReplaceAs");
11374 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
11375 || (p
->as_type
== AS_INTERNAL
))
11376 vty_out(vty
, "remote AS %u, ", p
->as
);
11378 vty_out(vty
, "remote AS Unspecified, ");
11379 vty_out(vty
, "local AS %u%s%s, ",
11380 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
11381 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
11384 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
11388 /* peer type internal or confed-internal */
11389 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
11391 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
11392 json_object_boolean_true_add(
11393 json_neigh
, "nbrConfedInternalLink");
11395 json_object_boolean_true_add(json_neigh
,
11396 "nbrInternalLink");
11398 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
11399 vty_out(vty
, "confed-internal link\n");
11401 vty_out(vty
, "internal link\n");
11403 /* peer type external or confed-external */
11404 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
11406 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
11407 json_object_boolean_true_add(
11408 json_neigh
, "nbrConfedExternalLink");
11410 json_object_boolean_true_add(json_neigh
,
11411 "nbrExternalLink");
11413 if (bgp_confederation_peers_check(bgp
, p
->as
))
11414 vty_out(vty
, "confed-external link\n");
11416 vty_out(vty
, "external link\n");
11420 json_object_boolean_true_add(json_neigh
,
11421 "nbrUnspecifiedLink");
11423 vty_out(vty
, "unspecified link\n");
11429 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
11431 vty_out(vty
, " Description: %s\n", p
->desc
);
11437 json_object_string_add(json_neigh
, "hostname",
11441 json_object_string_add(json_neigh
, "domainname",
11444 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
11445 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
11448 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
11455 json_object_string_add(json_neigh
, "peerGroup",
11459 struct prefix prefix
, *range
= NULL
;
11461 sockunion2hostprefix(&(p
->su
), &prefix
);
11462 range
= peer_group_lookup_dynamic_neighbor_range(
11463 p
->group
, &prefix
);
11466 prefix2str(range
, buf1
, sizeof(buf1
));
11467 json_object_string_add(
11469 "peerSubnetRangeGroup", buf1
);
11474 " Member of peer-group %s for session parameters\n",
11478 struct prefix prefix
, *range
= NULL
;
11480 sockunion2hostprefix(&(p
->su
), &prefix
);
11481 range
= peer_group_lookup_dynamic_neighbor_range(
11482 p
->group
, &prefix
);
11486 " Belongs to the subnet range group: %pFX\n",
11494 /* Administrative shutdown. */
11495 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
11496 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
11497 json_object_boolean_true_add(json_neigh
,
11501 json_object_int_add(json_neigh
, "bgpVersion", 4);
11502 json_object_string_add(
11503 json_neigh
, "remoteRouterId",
11504 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
11505 json_object_string_add(
11506 json_neigh
, "localRouterId",
11507 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
11510 /* Confederation */
11511 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
11512 && bgp_confederation_peers_check(bgp
, p
->as
))
11513 json_object_boolean_true_add(json_neigh
,
11517 json_object_string_add(
11518 json_neigh
, "bgpState",
11519 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
11521 if (p
->status
== Established
) {
11524 uptime
= bgp_clock();
11525 uptime
-= p
->uptime
;
11526 epoch_tbuf
= time(NULL
) - uptime
;
11528 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
11530 json_object_string_add(json_neigh
, "bgpTimerUpString",
11531 peer_uptime(p
->uptime
, timebuf
,
11534 json_object_int_add(json_neigh
,
11535 "bgpTimerUpEstablishedEpoch",
11539 else if (p
->status
== Active
) {
11540 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
11541 json_object_string_add(json_neigh
, "bgpStateIs",
11543 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
11544 json_object_string_add(json_neigh
, "bgpStateIs",
11552 uptime
= bgp_clock();
11553 uptime
-= p
->readtime
;
11554 gmtime_r(&uptime
, &tm
);
11556 json_object_int_add(json_neigh
, "bgpTimerLastRead",
11557 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
11558 + (tm
.tm_hour
* 3600000));
11560 uptime
= bgp_clock();
11561 uptime
-= p
->last_write
;
11562 gmtime_r(&uptime
, &tm
);
11564 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
11565 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
11566 + (tm
.tm_hour
* 3600000));
11568 uptime
= bgp_clock();
11569 uptime
-= p
->update_time
;
11570 gmtime_r(&uptime
, &tm
);
11572 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
11573 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
11574 + (tm
.tm_hour
* 3600000));
11576 /* Configured timer values. */
11577 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
11578 p
->v_holdtime
* 1000);
11579 json_object_int_add(json_neigh
,
11580 "bgpTimerKeepAliveIntervalMsecs",
11581 p
->v_keepalive
* 1000);
11582 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
11583 json_object_int_add(json_neigh
,
11584 "bgpTimerConfiguredHoldTimeMsecs",
11585 p
->holdtime
* 1000);
11586 json_object_int_add(
11588 "bgpTimerConfiguredKeepAliveIntervalMsecs",
11589 p
->keepalive
* 1000);
11590 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
11591 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
11592 json_object_int_add(json_neigh
,
11593 "bgpTimerConfiguredHoldTimeMsecs",
11594 bgp
->default_holdtime
);
11595 json_object_int_add(
11597 "bgpTimerConfiguredKeepAliveIntervalMsecs",
11598 bgp
->default_keepalive
);
11601 /* Administrative shutdown. */
11602 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
11603 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
11604 vty_out(vty
, " Administratively shut down\n");
11607 vty_out(vty
, " BGP version 4");
11608 vty_out(vty
, ", remote router ID %s",
11609 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
11610 vty_out(vty
, ", local router ID %s\n",
11611 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
11614 /* Confederation */
11615 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
11616 && bgp_confederation_peers_check(bgp
, p
->as
))
11618 " Neighbor under common administration\n");
11621 vty_out(vty
, " BGP state = %s",
11622 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
11624 if (p
->status
== Established
)
11625 vty_out(vty
, ", up for %8s",
11626 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
11629 else if (p
->status
== Active
) {
11630 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
11631 vty_out(vty
, " (passive)");
11632 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
11633 vty_out(vty
, " (NSF passive)");
11635 vty_out(vty
, "\n");
11638 vty_out(vty
, " Last read %s",
11639 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
11641 vty_out(vty
, ", Last write %s\n",
11642 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
11645 /* Configured timer values. */
11647 " Hold time is %d, keepalive interval is %d seconds\n",
11648 p
->v_holdtime
, p
->v_keepalive
);
11649 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
11650 vty_out(vty
, " Configured hold time is %d",
11652 vty_out(vty
, ", keepalive interval is %d seconds\n",
11654 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
11655 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
11656 vty_out(vty
, " Configured hold time is %d",
11657 bgp
->default_holdtime
);
11658 vty_out(vty
, ", keepalive interval is %d seconds\n",
11659 bgp
->default_keepalive
);
11663 if (p
->status
== Established
) {
11664 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
11665 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
11666 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
11667 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
11668 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
11669 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
11670 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
11671 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
11672 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
11673 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
11674 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
11675 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
11676 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
11677 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
11678 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
11679 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
11680 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
11681 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
11682 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
11683 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
11685 json_object
*json_cap
= NULL
;
11687 json_cap
= json_object_new_object();
11690 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
11691 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
11692 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
11693 && CHECK_FLAG(p
->cap
,
11695 json_object_string_add(
11696 json_cap
, "4byteAs",
11697 "advertisedAndReceived");
11698 else if (CHECK_FLAG(p
->cap
,
11700 json_object_string_add(
11701 json_cap
, "4byteAs",
11703 else if (CHECK_FLAG(p
->cap
,
11705 json_object_string_add(
11706 json_cap
, "4byteAs",
11711 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
11712 || CHECK_FLAG(p
->cap
,
11713 PEER_CAP_ADDPATH_ADV
)) {
11714 json_object
*json_add
= NULL
;
11715 const char *print_store
;
11717 json_add
= json_object_new_object();
11719 FOREACH_AFI_SAFI (afi
, safi
) {
11720 json_object
*json_sub
= NULL
;
11722 json_object_new_object();
11723 print_store
= get_afi_safi_str(
11729 PEER_CAP_ADDPATH_AF_TX_ADV
)
11733 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
11738 PEER_CAP_ADDPATH_AF_TX_ADV
)
11743 PEER_CAP_ADDPATH_AF_TX_RCV
))
11744 json_object_boolean_true_add(
11746 "txAdvertisedAndReceived");
11752 PEER_CAP_ADDPATH_AF_TX_ADV
))
11753 json_object_boolean_true_add(
11761 PEER_CAP_ADDPATH_AF_TX_RCV
))
11762 json_object_boolean_true_add(
11770 PEER_CAP_ADDPATH_AF_RX_ADV
)
11774 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
11779 PEER_CAP_ADDPATH_AF_RX_ADV
)
11784 PEER_CAP_ADDPATH_AF_RX_RCV
))
11785 json_object_boolean_true_add(
11787 "rxAdvertisedAndReceived");
11793 PEER_CAP_ADDPATH_AF_RX_ADV
))
11794 json_object_boolean_true_add(
11802 PEER_CAP_ADDPATH_AF_RX_RCV
))
11803 json_object_boolean_true_add(
11811 PEER_CAP_ADDPATH_AF_TX_ADV
)
11815 PEER_CAP_ADDPATH_AF_TX_RCV
)
11819 PEER_CAP_ADDPATH_AF_RX_ADV
)
11823 PEER_CAP_ADDPATH_AF_RX_RCV
))
11824 json_object_object_add(
11833 json_object_object_add(
11834 json_cap
, "addPath", json_add
);
11838 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
11839 || CHECK_FLAG(p
->cap
,
11840 PEER_CAP_DYNAMIC_ADV
)) {
11841 if (CHECK_FLAG(p
->cap
,
11842 PEER_CAP_DYNAMIC_ADV
)
11843 && CHECK_FLAG(p
->cap
,
11844 PEER_CAP_DYNAMIC_RCV
))
11845 json_object_string_add(
11846 json_cap
, "dynamic",
11847 "advertisedAndReceived");
11848 else if (CHECK_FLAG(
11850 PEER_CAP_DYNAMIC_ADV
))
11851 json_object_string_add(
11852 json_cap
, "dynamic",
11854 else if (CHECK_FLAG(
11856 PEER_CAP_DYNAMIC_RCV
))
11857 json_object_string_add(
11858 json_cap
, "dynamic",
11862 /* Extended nexthop */
11863 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
11864 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
11865 json_object
*json_nxt
= NULL
;
11866 const char *print_store
;
11869 if (CHECK_FLAG(p
->cap
,
11871 && CHECK_FLAG(p
->cap
,
11872 PEER_CAP_ENHE_RCV
))
11873 json_object_string_add(
11876 "advertisedAndReceived");
11877 else if (CHECK_FLAG(p
->cap
,
11878 PEER_CAP_ENHE_ADV
))
11879 json_object_string_add(
11883 else if (CHECK_FLAG(p
->cap
,
11884 PEER_CAP_ENHE_RCV
))
11885 json_object_string_add(
11890 if (CHECK_FLAG(p
->cap
,
11891 PEER_CAP_ENHE_RCV
)) {
11893 json_object_new_object();
11895 for (safi
= SAFI_UNICAST
;
11896 safi
< SAFI_MAX
; safi
++) {
11901 PEER_CAP_ENHE_AF_RCV
)) {
11902 print_store
= get_afi_safi_str(
11905 json_object_string_add(
11908 "recieved"); /* misspelled for compatibility */
11911 json_object_object_add(
11913 "extendedNexthopFamililesByPeer",
11918 /* Route Refresh */
11919 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
11920 || CHECK_FLAG(p
->cap
,
11921 PEER_CAP_REFRESH_NEW_RCV
)
11922 || CHECK_FLAG(p
->cap
,
11923 PEER_CAP_REFRESH_OLD_RCV
)) {
11924 if (CHECK_FLAG(p
->cap
,
11925 PEER_CAP_REFRESH_ADV
)
11928 PEER_CAP_REFRESH_NEW_RCV
)
11931 PEER_CAP_REFRESH_OLD_RCV
))) {
11934 PEER_CAP_REFRESH_OLD_RCV
)
11937 PEER_CAP_REFRESH_NEW_RCV
))
11938 json_object_string_add(
11941 "advertisedAndReceivedOldNew");
11945 PEER_CAP_REFRESH_OLD_RCV
))
11946 json_object_string_add(
11949 "advertisedAndReceivedOld");
11951 json_object_string_add(
11954 "advertisedAndReceivedNew");
11959 PEER_CAP_REFRESH_ADV
))
11960 json_object_string_add(
11967 PEER_CAP_REFRESH_NEW_RCV
)
11970 PEER_CAP_REFRESH_OLD_RCV
))
11971 json_object_string_add(
11977 /* Multiprotocol Extensions */
11978 json_object
*json_multi
= NULL
;
11979 json_multi
= json_object_new_object();
11981 FOREACH_AFI_SAFI (afi
, safi
) {
11982 if (p
->afc_adv
[afi
][safi
]
11983 || p
->afc_recv
[afi
][safi
]) {
11984 json_object
*json_exten
= NULL
;
11986 json_object_new_object();
11988 if (p
->afc_adv
[afi
][safi
]
11989 && p
->afc_recv
[afi
][safi
])
11990 json_object_boolean_true_add(
11992 "advertisedAndReceived");
11993 else if (p
->afc_adv
[afi
][safi
])
11994 json_object_boolean_true_add(
11997 else if (p
->afc_recv
[afi
][safi
])
11998 json_object_boolean_true_add(
12002 json_object_object_add(
12004 get_afi_safi_str(afi
,
12010 json_object_object_add(
12011 json_cap
, "multiprotocolExtensions",
12014 /* Hostname capabilities */
12015 json_object
*json_hname
= NULL
;
12017 json_hname
= json_object_new_object();
12019 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
12020 json_object_string_add(
12021 json_hname
, "advHostName",
12022 bgp
->peer_self
->hostname
12026 json_object_string_add(
12027 json_hname
, "advDomainName",
12028 bgp
->peer_self
->domainname
12035 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
12036 json_object_string_add(
12037 json_hname
, "rcvHostName",
12038 p
->hostname
? p
->hostname
12040 json_object_string_add(
12041 json_hname
, "rcvDomainName",
12042 p
->domainname
? p
->domainname
12046 json_object_object_add(json_cap
, "hostName",
12049 /* Gracefull Restart */
12050 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
12051 || CHECK_FLAG(p
->cap
,
12052 PEER_CAP_RESTART_ADV
)) {
12053 if (CHECK_FLAG(p
->cap
,
12054 PEER_CAP_RESTART_ADV
)
12055 && CHECK_FLAG(p
->cap
,
12056 PEER_CAP_RESTART_RCV
))
12057 json_object_string_add(
12060 "advertisedAndReceived");
12061 else if (CHECK_FLAG(
12063 PEER_CAP_RESTART_ADV
))
12064 json_object_string_add(
12066 "gracefulRestartCapability",
12068 else if (CHECK_FLAG(
12070 PEER_CAP_RESTART_RCV
))
12071 json_object_string_add(
12073 "gracefulRestartCapability",
12076 if (CHECK_FLAG(p
->cap
,
12077 PEER_CAP_RESTART_RCV
)) {
12078 int restart_af_count
= 0;
12079 json_object
*json_restart
=
12082 json_object_new_object();
12084 json_object_int_add(
12086 "gracefulRestartRemoteTimerMsecs",
12087 p
->v_gr_restart
* 1000);
12089 FOREACH_AFI_SAFI (afi
, safi
) {
12094 PEER_CAP_RESTART_AF_RCV
)) {
12099 json_object_new_object();
12105 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
12106 json_object_boolean_true_add(
12109 restart_af_count
++;
12110 json_object_object_add(
12119 if (!restart_af_count
) {
12120 json_object_string_add(
12122 "addressFamiliesByPeer",
12127 json_object_object_add(
12129 "addressFamiliesByPeer",
12133 json_object_object_add(json_neigh
,
12134 "neighborCapabilities",
12137 vty_out(vty
, " Neighbor capabilities:\n");
12140 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
12141 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
12142 vty_out(vty
, " 4 Byte AS:");
12143 if (CHECK_FLAG(p
->cap
,
12145 vty_out(vty
, " advertised");
12146 if (CHECK_FLAG(p
->cap
,
12148 vty_out(vty
, " %sreceived",
12154 vty_out(vty
, "\n");
12158 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
12159 || CHECK_FLAG(p
->cap
,
12160 PEER_CAP_ADDPATH_ADV
)) {
12161 vty_out(vty
, " AddPath:\n");
12163 FOREACH_AFI_SAFI (afi
, safi
) {
12167 PEER_CAP_ADDPATH_AF_TX_ADV
)
12171 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
12183 PEER_CAP_ADDPATH_AF_TX_ADV
))
12195 PEER_CAP_ADDPATH_AF_TX_RCV
))
12202 PEER_CAP_ADDPATH_AF_TX_ADV
)
12206 vty_out(vty
, "\n");
12212 PEER_CAP_ADDPATH_AF_RX_ADV
)
12216 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
12228 PEER_CAP_ADDPATH_AF_RX_ADV
))
12240 PEER_CAP_ADDPATH_AF_RX_RCV
))
12247 PEER_CAP_ADDPATH_AF_RX_ADV
)
12251 vty_out(vty
, "\n");
12257 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
12258 || CHECK_FLAG(p
->cap
,
12259 PEER_CAP_DYNAMIC_ADV
)) {
12260 vty_out(vty
, " Dynamic:");
12261 if (CHECK_FLAG(p
->cap
,
12262 PEER_CAP_DYNAMIC_ADV
))
12263 vty_out(vty
, " advertised");
12264 if (CHECK_FLAG(p
->cap
,
12265 PEER_CAP_DYNAMIC_RCV
))
12266 vty_out(vty
, " %sreceived",
12269 PEER_CAP_DYNAMIC_ADV
)
12272 vty_out(vty
, "\n");
12275 /* Extended nexthop */
12276 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
12277 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
12278 vty_out(vty
, " Extended nexthop:");
12279 if (CHECK_FLAG(p
->cap
,
12280 PEER_CAP_ENHE_ADV
))
12281 vty_out(vty
, " advertised");
12282 if (CHECK_FLAG(p
->cap
,
12283 PEER_CAP_ENHE_RCV
))
12284 vty_out(vty
, " %sreceived",
12290 vty_out(vty
, "\n");
12292 if (CHECK_FLAG(p
->cap
,
12293 PEER_CAP_ENHE_RCV
)) {
12295 " Address families by peer:\n ");
12296 for (safi
= SAFI_UNICAST
;
12297 safi
< SAFI_MAX
; safi
++)
12302 PEER_CAP_ENHE_AF_RCV
))
12312 /* Route Refresh */
12313 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
12314 || CHECK_FLAG(p
->cap
,
12315 PEER_CAP_REFRESH_NEW_RCV
)
12316 || CHECK_FLAG(p
->cap
,
12317 PEER_CAP_REFRESH_OLD_RCV
)) {
12318 vty_out(vty
, " Route refresh:");
12319 if (CHECK_FLAG(p
->cap
,
12320 PEER_CAP_REFRESH_ADV
))
12321 vty_out(vty
, " advertised");
12322 if (CHECK_FLAG(p
->cap
,
12323 PEER_CAP_REFRESH_NEW_RCV
)
12326 PEER_CAP_REFRESH_OLD_RCV
))
12327 vty_out(vty
, " %sreceived(%s)",
12330 PEER_CAP_REFRESH_ADV
)
12335 PEER_CAP_REFRESH_OLD_RCV
)
12338 PEER_CAP_REFRESH_NEW_RCV
))
12342 PEER_CAP_REFRESH_OLD_RCV
)
12346 vty_out(vty
, "\n");
12349 /* Multiprotocol Extensions */
12350 FOREACH_AFI_SAFI (afi
, safi
)
12351 if (p
->afc_adv
[afi
][safi
]
12352 || p
->afc_recv
[afi
][safi
]) {
12354 " Address Family %s:",
12359 if (p
->afc_adv
[afi
][safi
])
12362 if (p
->afc_recv
[afi
][safi
])
12369 vty_out(vty
, "\n");
12372 /* Hostname capability */
12373 vty_out(vty
, " Hostname Capability:");
12375 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
12377 " advertised (name: %s,domain name: %s)",
12378 bgp
->peer_self
->hostname
12382 bgp
->peer_self
->domainname
12387 vty_out(vty
, " not advertised");
12390 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
12392 " received (name: %s,domain name: %s)",
12393 p
->hostname
? p
->hostname
12395 p
->domainname
? p
->domainname
12398 vty_out(vty
, " not received");
12401 vty_out(vty
, "\n");
12403 /* Graceful Restart */
12404 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
12405 || CHECK_FLAG(p
->cap
,
12406 PEER_CAP_RESTART_ADV
)) {
12408 " Graceful Restart Capability:");
12409 if (CHECK_FLAG(p
->cap
,
12410 PEER_CAP_RESTART_ADV
))
12411 vty_out(vty
, " advertised");
12412 if (CHECK_FLAG(p
->cap
,
12413 PEER_CAP_RESTART_RCV
))
12414 vty_out(vty
, " %sreceived",
12417 PEER_CAP_RESTART_ADV
)
12420 vty_out(vty
, "\n");
12422 if (CHECK_FLAG(p
->cap
,
12423 PEER_CAP_RESTART_RCV
)) {
12424 int restart_af_count
= 0;
12427 " Remote Restart timer is %d seconds\n",
12430 " Address families by peer:\n ");
12432 FOREACH_AFI_SAFI (afi
, safi
)
12437 PEER_CAP_RESTART_AF_RCV
)) {
12451 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
12453 : "not preserved");
12454 restart_af_count
++;
12456 if (!restart_af_count
)
12457 vty_out(vty
, "none");
12458 vty_out(vty
, "\n");
12460 } /* Gracefull Restart */
12465 /* graceful restart information */
12466 json_object
*json_grace
= NULL
;
12467 json_object
*json_grace_send
= NULL
;
12468 json_object
*json_grace_recv
= NULL
;
12469 int eor_send_af_count
= 0;
12470 int eor_receive_af_count
= 0;
12473 json_grace
= json_object_new_object();
12474 json_grace_send
= json_object_new_object();
12475 json_grace_recv
= json_object_new_object();
12477 if ((p
->status
== Established
)
12478 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
12479 FOREACH_AFI_SAFI (afi
, safi
) {
12480 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12481 PEER_STATUS_EOR_SEND
)) {
12482 json_object_boolean_true_add(
12484 get_afi_safi_str(afi
,
12487 eor_send_af_count
++;
12490 FOREACH_AFI_SAFI (afi
, safi
) {
12492 p
->af_sflags
[afi
][safi
],
12493 PEER_STATUS_EOR_RECEIVED
)) {
12494 json_object_boolean_true_add(
12496 get_afi_safi_str(afi
,
12499 eor_receive_af_count
++;
12503 json_object_object_add(json_grace
, "endOfRibSend",
12505 json_object_object_add(json_grace
, "endOfRibRecv",
12509 if (p
->t_gr_restart
)
12510 json_object_int_add(json_grace
,
12511 "gracefulRestartTimerMsecs",
12512 thread_timer_remain_second(
12517 json_object_int_add(
12519 "gracefulStalepathTimerMsecs",
12520 thread_timer_remain_second(
12523 /* more gr info in new format */
12524 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
,
12526 json_object_object_add(
12527 json_neigh
, "gracefulRestartInfo", json_grace
);
12529 vty_out(vty
, " Graceful restart information:\n");
12530 if ((p
->status
== Established
)
12531 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
12533 vty_out(vty
, " End-of-RIB send: ");
12534 FOREACH_AFI_SAFI (afi
, safi
) {
12535 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12536 PEER_STATUS_EOR_SEND
)) {
12537 vty_out(vty
, "%s%s",
12538 eor_send_af_count
? ", "
12543 eor_send_af_count
++;
12546 vty_out(vty
, "\n");
12547 vty_out(vty
, " End-of-RIB received: ");
12548 FOREACH_AFI_SAFI (afi
, safi
) {
12550 p
->af_sflags
[afi
][safi
],
12551 PEER_STATUS_EOR_RECEIVED
)) {
12552 vty_out(vty
, "%s%s",
12553 eor_receive_af_count
12556 get_afi_safi_str(afi
,
12559 eor_receive_af_count
++;
12562 vty_out(vty
, "\n");
12565 if (p
->t_gr_restart
)
12567 " The remaining time of restart timer is %ld\n",
12568 thread_timer_remain_second(
12573 " The remaining time of stalepath timer is %ld\n",
12574 thread_timer_remain_second(
12577 /* more gr info in new format */
12578 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
12582 json_object
*json_stat
= NULL
;
12583 json_stat
= json_object_new_object();
12584 /* Packet counts. */
12586 atomic_size_t outq_count
, inq_count
;
12587 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
12588 memory_order_relaxed
);
12589 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
12590 memory_order_relaxed
);
12592 json_object_int_add(json_stat
, "depthInq",
12593 (unsigned long)inq_count
);
12594 json_object_int_add(json_stat
, "depthOutq",
12595 (unsigned long)outq_count
);
12596 json_object_int_add(json_stat
, "opensSent",
12597 atomic_load_explicit(&p
->open_out
,
12598 memory_order_relaxed
));
12599 json_object_int_add(json_stat
, "opensRecv",
12600 atomic_load_explicit(&p
->open_in
,
12601 memory_order_relaxed
));
12602 json_object_int_add(json_stat
, "notificationsSent",
12603 atomic_load_explicit(&p
->notify_out
,
12604 memory_order_relaxed
));
12605 json_object_int_add(json_stat
, "notificationsRecv",
12606 atomic_load_explicit(&p
->notify_in
,
12607 memory_order_relaxed
));
12608 json_object_int_add(json_stat
, "updatesSent",
12609 atomic_load_explicit(&p
->update_out
,
12610 memory_order_relaxed
));
12611 json_object_int_add(json_stat
, "updatesRecv",
12612 atomic_load_explicit(&p
->update_in
,
12613 memory_order_relaxed
));
12614 json_object_int_add(json_stat
, "keepalivesSent",
12615 atomic_load_explicit(&p
->keepalive_out
,
12616 memory_order_relaxed
));
12617 json_object_int_add(json_stat
, "keepalivesRecv",
12618 atomic_load_explicit(&p
->keepalive_in
,
12619 memory_order_relaxed
));
12620 json_object_int_add(json_stat
, "routeRefreshSent",
12621 atomic_load_explicit(&p
->refresh_out
,
12622 memory_order_relaxed
));
12623 json_object_int_add(json_stat
, "routeRefreshRecv",
12624 atomic_load_explicit(&p
->refresh_in
,
12625 memory_order_relaxed
));
12626 json_object_int_add(json_stat
, "capabilitySent",
12627 atomic_load_explicit(&p
->dynamic_cap_out
,
12628 memory_order_relaxed
));
12629 json_object_int_add(json_stat
, "capabilityRecv",
12630 atomic_load_explicit(&p
->dynamic_cap_in
,
12631 memory_order_relaxed
));
12632 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
12633 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
12634 json_object_object_add(json_neigh
, "messageStats", json_stat
);
12636 atomic_size_t outq_count
, inq_count
;
12637 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
12638 memory_order_relaxed
);
12639 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
12640 memory_order_relaxed
);
12642 /* Packet counts. */
12643 vty_out(vty
, " Message statistics:\n");
12644 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
12645 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
12646 vty_out(vty
, " Sent Rcvd\n");
12647 vty_out(vty
, " Opens: %10d %10d\n",
12648 atomic_load_explicit(&p
->open_out
,
12649 memory_order_relaxed
),
12650 atomic_load_explicit(&p
->open_in
,
12651 memory_order_relaxed
));
12652 vty_out(vty
, " Notifications: %10d %10d\n",
12653 atomic_load_explicit(&p
->notify_out
,
12654 memory_order_relaxed
),
12655 atomic_load_explicit(&p
->notify_in
,
12656 memory_order_relaxed
));
12657 vty_out(vty
, " Updates: %10d %10d\n",
12658 atomic_load_explicit(&p
->update_out
,
12659 memory_order_relaxed
),
12660 atomic_load_explicit(&p
->update_in
,
12661 memory_order_relaxed
));
12662 vty_out(vty
, " Keepalives: %10d %10d\n",
12663 atomic_load_explicit(&p
->keepalive_out
,
12664 memory_order_relaxed
),
12665 atomic_load_explicit(&p
->keepalive_in
,
12666 memory_order_relaxed
));
12667 vty_out(vty
, " Route Refresh: %10d %10d\n",
12668 atomic_load_explicit(&p
->refresh_out
,
12669 memory_order_relaxed
),
12670 atomic_load_explicit(&p
->refresh_in
,
12671 memory_order_relaxed
));
12672 vty_out(vty
, " Capability: %10d %10d\n",
12673 atomic_load_explicit(&p
->dynamic_cap_out
,
12674 memory_order_relaxed
),
12675 atomic_load_explicit(&p
->dynamic_cap_in
,
12676 memory_order_relaxed
));
12677 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
12682 /* advertisement-interval */
12683 json_object_int_add(json_neigh
,
12684 "minBtwnAdvertisementRunsTimerMsecs",
12685 p
->v_routeadv
* 1000);
12687 /* Update-source. */
12688 if (p
->update_if
|| p
->update_source
) {
12690 json_object_string_add(json_neigh
,
12693 else if (p
->update_source
)
12694 json_object_string_add(
12695 json_neigh
, "updateSource",
12696 sockunion2str(p
->update_source
, buf1
,
12700 /* advertisement-interval */
12702 " Minimum time between advertisement runs is %d seconds\n",
12705 /* Update-source. */
12706 if (p
->update_if
|| p
->update_source
) {
12707 vty_out(vty
, " Update source is ");
12709 vty_out(vty
, "%s", p
->update_if
);
12710 else if (p
->update_source
)
12712 sockunion2str(p
->update_source
, buf1
,
12714 vty_out(vty
, "\n");
12717 vty_out(vty
, "\n");
12720 /* Address Family Information */
12721 json_object
*json_hold
= NULL
;
12724 json_hold
= json_object_new_object();
12726 FOREACH_AFI_SAFI (afi
, safi
)
12727 if (p
->afc
[afi
][safi
])
12728 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
12732 json_object_object_add(json_neigh
, "addressFamilyInfo",
12734 json_object_int_add(json_neigh
, "connectionsEstablished",
12736 json_object_int_add(json_neigh
, "connectionsDropped",
12739 vty_out(vty
, " Connections established %d; dropped %d\n",
12740 p
->established
, p
->dropped
);
12742 if (!p
->last_reset
) {
12744 json_object_string_add(json_neigh
, "lastReset",
12747 vty_out(vty
, " Last reset never\n");
12753 uptime
= bgp_clock();
12754 uptime
-= p
->resettime
;
12755 gmtime_r(&uptime
, &tm
);
12757 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
12759 + (tm
.tm_min
* 60000)
12760 + (tm
.tm_hour
* 3600000));
12761 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
12763 vty_out(vty
, " Last reset %s, ",
12764 peer_uptime(p
->resettime
, timebuf
,
12765 BGP_UPTIME_LEN
, 0, NULL
));
12767 bgp_show_peer_reset(vty
, p
, NULL
, false);
12768 if (p
->last_reset_cause_size
) {
12769 msg
= p
->last_reset_cause
;
12771 " Message received that caused BGP to send a NOTIFICATION:\n ");
12772 for (i
= 1; i
<= p
->last_reset_cause_size
;
12774 vty_out(vty
, "%02X", *msg
++);
12776 if (i
!= p
->last_reset_cause_size
) {
12778 vty_out(vty
, "\n ");
12779 } else if (i
% 4 == 0) {
12784 vty_out(vty
, "\n");
12789 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
12791 json_object_boolean_true_add(json_neigh
,
12792 "prefixesConfigExceedMax");
12795 " Peer had exceeded the max. no. of prefixes configured.\n");
12797 if (p
->t_pmax_restart
) {
12799 json_object_boolean_true_add(
12800 json_neigh
, "reducePrefixNumFrom");
12801 json_object_int_add(json_neigh
,
12802 "restartInTimerMsec",
12803 thread_timer_remain_second(
12808 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
12809 p
->host
, thread_timer_remain_second(
12810 p
->t_pmax_restart
));
12813 json_object_boolean_true_add(
12815 "reducePrefixNumAndClearIpBgp");
12818 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
12823 /* EBGP Multihop and GTSM */
12824 if (p
->sort
!= BGP_PEER_IBGP
) {
12826 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
12827 json_object_int_add(json_neigh
,
12828 "externalBgpNbrMaxHopsAway",
12830 else if (p
->ttl
> BGP_DEFAULT_TTL
)
12831 json_object_int_add(json_neigh
,
12832 "externalBgpNbrMaxHopsAway",
12835 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
12837 " External BGP neighbor may be up to %d hops away.\n",
12839 else if (p
->ttl
> BGP_DEFAULT_TTL
)
12841 " External BGP neighbor may be up to %d hops away.\n",
12845 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
) {
12847 json_object_int_add(json_neigh
,
12848 "internalBgpNbrMaxHopsAway",
12852 " Internal BGP neighbor may be up to %d hops away.\n",
12857 /* Local address. */
12860 json_object_string_add(json_neigh
, "hostLocal",
12861 sockunion2str(p
->su_local
, buf1
,
12863 json_object_int_add(json_neigh
, "portLocal",
12864 ntohs(p
->su_local
->sin
.sin_port
));
12866 vty_out(vty
, "Local host: %s, Local port: %d\n",
12867 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
12868 ntohs(p
->su_local
->sin
.sin_port
));
12871 /* Remote address. */
12872 if (p
->su_remote
) {
12874 json_object_string_add(json_neigh
, "hostForeign",
12875 sockunion2str(p
->su_remote
, buf1
,
12877 json_object_int_add(json_neigh
, "portForeign",
12878 ntohs(p
->su_remote
->sin
.sin_port
));
12880 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
12881 sockunion2str(p
->su_remote
, buf1
,
12883 ntohs(p
->su_remote
->sin
.sin_port
));
12886 /* Nexthop display. */
12889 json_object_string_add(json_neigh
, "nexthop",
12891 &p
->nexthop
.v4
, buf1
,
12893 json_object_string_add(json_neigh
, "nexthopGlobal",
12894 inet_ntop(AF_INET6
,
12895 &p
->nexthop
.v6_global
,
12896 buf1
, sizeof(buf1
)));
12897 json_object_string_add(json_neigh
, "nexthopLocal",
12898 inet_ntop(AF_INET6
,
12899 &p
->nexthop
.v6_local
,
12900 buf1
, sizeof(buf1
)));
12901 if (p
->shared_network
)
12902 json_object_string_add(json_neigh
,
12906 json_object_string_add(json_neigh
,
12908 "nonSharedNetwork");
12910 vty_out(vty
, "Nexthop: %s\n",
12911 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
12913 vty_out(vty
, "Nexthop global: %s\n",
12914 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
12916 vty_out(vty
, "Nexthop local: %s\n",
12917 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
12919 vty_out(vty
, "BGP connection: %s\n",
12920 p
->shared_network
? "shared network"
12921 : "non shared network");
12925 /* Timer information. */
12927 json_object_int_add(json_neigh
, "connectRetryTimer",
12929 if (p
->status
== Established
&& p
->rtt
)
12930 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
12933 json_object_int_add(
12934 json_neigh
, "nextStartTimerDueInMsecs",
12935 thread_timer_remain_second(p
->t_start
) * 1000);
12937 json_object_int_add(
12938 json_neigh
, "nextConnectTimerDueInMsecs",
12939 thread_timer_remain_second(p
->t_connect
)
12941 if (p
->t_routeadv
) {
12942 json_object_int_add(json_neigh
, "mraiInterval",
12944 json_object_int_add(
12945 json_neigh
, "mraiTimerExpireInMsecs",
12946 thread_timer_remain_second(p
->t_routeadv
)
12950 json_object_int_add(json_neigh
, "authenticationEnabled",
12954 json_object_string_add(json_neigh
, "readThread", "on");
12956 json_object_string_add(json_neigh
, "readThread", "off");
12958 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
12959 json_object_string_add(json_neigh
, "writeThread", "on");
12961 json_object_string_add(json_neigh
, "writeThread",
12964 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
12966 if (p
->status
== Established
&& p
->rtt
)
12967 vty_out(vty
, "Estimated round trip time: %d ms\n",
12970 vty_out(vty
, "Next start timer due in %ld seconds\n",
12971 thread_timer_remain_second(p
->t_start
));
12973 vty_out(vty
, "Next connect timer due in %ld seconds\n",
12974 thread_timer_remain_second(p
->t_connect
));
12977 "MRAI (interval %u) timer expires in %ld seconds\n",
12979 thread_timer_remain_second(p
->t_routeadv
));
12981 vty_out(vty
, "Peer Authentication Enabled\n");
12983 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
12984 p
->t_read
? "on" : "off",
12985 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
12990 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
12991 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
12992 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
12995 vty_out(vty
, "\n");
12997 /* BFD information. */
12998 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
13001 if (p
->conf_if
) /* Configured interface name. */
13002 json_object_object_add(json
, p
->conf_if
, json_neigh
);
13003 else /* Configured IP address. */
13004 json_object_object_add(json
, p
->host
, json_neigh
);
13008 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
13009 enum show_type type
,
13010 union sockunion
*su
,
13011 const char *conf_if
, afi_t afi
,
13014 struct listnode
*node
, *nnode
;
13017 safi_t safi
= SAFI_UNICAST
;
13018 json_object
*json
= NULL
;
13019 json_object
*json_neighbor
= NULL
;
13022 json
= json_object_new_object();
13023 json_neighbor
= json_object_new_object();
13026 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
13028 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
13031 if ((peer
->afc
[afi
][safi
]) == 0)
13034 if (type
== show_all
) {
13035 bgp_show_peer_gr_status(vty
, peer
, use_json
,
13039 json_object_object_add(json
, peer
->host
,
13041 json_neighbor
= NULL
;
13044 } else if (type
== show_peer
) {
13047 && !strcmp(peer
->conf_if
, conf_if
))
13049 && !strcmp(peer
->hostname
, conf_if
))) {
13051 bgp_show_peer_gr_status(vty
, peer
,
13056 if (sockunion_same(&peer
->su
, su
)) {
13058 bgp_show_peer_gr_status(vty
, peer
,
13063 if (use_json
&& find
)
13064 json_object_object_add(json
, peer
->host
,
13069 json_neighbor
= NULL
;
13074 if (type
== show_peer
&& !find
) {
13076 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
13078 vty_out(vty
, "%% No such neighbor\n");
13081 vty_out(vty
, "%s\n",
13082 json_object_to_json_string_ext(
13083 json
, JSON_C_TO_STRING_PRETTY
));
13086 json_object_free(json_neighbor
);
13087 json_object_free(json
);
13089 vty_out(vty
, "\n");
13092 return CMD_SUCCESS
;
13095 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
13096 enum show_type type
, union sockunion
*su
,
13097 const char *conf_if
, bool use_json
,
13100 struct listnode
*node
, *nnode
;
13103 bool nbr_output
= false;
13104 afi_t afi
= AFI_MAX
;
13105 safi_t safi
= SAFI_MAX
;
13107 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
13109 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
13113 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
13114 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
13119 bgp_show_peer(vty
, peer
, use_json
, json
);
13125 && !strcmp(peer
->conf_if
, conf_if
))
13127 && !strcmp(peer
->hostname
, conf_if
))) {
13129 bgp_show_peer(vty
, peer
, use_json
,
13133 if (sockunion_same(&peer
->su
, su
)) {
13135 bgp_show_peer(vty
, peer
, use_json
,
13140 case show_ipv4_peer
:
13141 case show_ipv6_peer
:
13142 FOREACH_SAFI (safi
) {
13143 if (peer
->afc
[afi
][safi
]) {
13146 && !strcmp(peer
->conf_if
, conf_if
))
13148 && !strcmp(peer
->hostname
, conf_if
))) {
13150 bgp_show_peer(vty
, peer
, use_json
,
13155 if (sockunion_same(&peer
->su
, su
)) {
13157 bgp_show_peer(vty
, peer
, use_json
,
13165 case show_ipv4_all
:
13166 case show_ipv6_all
:
13167 FOREACH_SAFI (safi
) {
13168 if (peer
->afc
[afi
][safi
]) {
13169 bgp_show_peer(vty
, peer
, use_json
, json
);
13178 if ((type
== show_peer
|| type
== show_ipv4_peer
||
13179 type
== show_ipv6_peer
) && !find
) {
13181 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
13183 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
13186 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
13187 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
13188 vty_out(vty
, "%% No BGP neighbors found\n");
13191 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
13192 json
, JSON_C_TO_STRING_PRETTY
));
13194 vty_out(vty
, "\n");
13197 return CMD_SUCCESS
;
13200 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
13201 enum show_type type
,
13202 const char *ip_str
,
13203 afi_t afi
, bool use_json
)
13208 union sockunion su
;
13210 bgp
= bgp_get_default();
13216 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
13220 ret
= str2sockunion(ip_str
, &su
);
13222 bgp_show_neighbor_graceful_restart(
13223 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
13225 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
13226 NULL
, afi
, use_json
);
13228 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
13232 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
13233 enum show_type type
,
13234 const char *ip_str
,
13237 struct listnode
*node
, *nnode
;
13239 union sockunion su
;
13240 json_object
*json
= NULL
;
13241 int ret
, is_first
= 1;
13242 bool nbr_output
= false;
13245 vty_out(vty
, "{\n");
13247 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
13250 if (!(json
= json_object_new_object())) {
13252 EC_BGP_JSON_MEM_ERROR
,
13253 "Unable to allocate memory for JSON object");
13255 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
13259 json_object_int_add(json
, "vrfId",
13260 (bgp
->vrf_id
== VRF_UNKNOWN
)
13262 : (int64_t)bgp
->vrf_id
);
13263 json_object_string_add(
13265 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
13270 vty_out(vty
, ",\n");
13274 vty_out(vty
, "\"%s\":",
13275 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
13279 vty_out(vty
, "\nInstance %s:\n",
13280 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
13285 if (type
== show_peer
|| type
== show_ipv4_peer
||
13286 type
== show_ipv6_peer
) {
13287 ret
= str2sockunion(ip_str
, &su
);
13289 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
13292 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
13295 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
13298 json_object_free(json
);
13303 vty_out(vty
, "}\n");
13304 else if (!nbr_output
)
13305 vty_out(vty
, "%% BGP instance not found\n");
13308 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
13309 enum show_type type
, const char *ip_str
,
13314 union sockunion su
;
13315 json_object
*json
= NULL
;
13318 if (strmatch(name
, "all")) {
13319 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
13321 return CMD_SUCCESS
;
13323 bgp
= bgp_lookup_by_name(name
);
13326 json
= json_object_new_object();
13327 vty_out(vty
, "%s\n",
13328 json_object_to_json_string_ext(
13330 JSON_C_TO_STRING_PRETTY
));
13331 json_object_free(json
);
13334 "%% BGP instance not found\n");
13336 return CMD_WARNING
;
13340 bgp
= bgp_get_default();
13344 json
= json_object_new_object();
13346 ret
= str2sockunion(ip_str
, &su
);
13348 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
13351 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
13354 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
13357 json_object_free(json
);
13360 vty_out(vty
, "{}\n");
13362 vty_out(vty
, "%% BGP instance not found\n");
13365 return CMD_SUCCESS
;
13370 /* "show [ip] bgp neighbors graceful-restart" commands. */
13371 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
13372 show_ip_bgp_neighbors_graceful_restart_cmd
,
13373 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
13379 "Neighbor to display information about\n"
13380 "Neighbor to display information about\n"
13381 "Neighbor on BGP configured interface\n"
13385 char *sh_arg
= NULL
;
13386 enum show_type sh_type
;
13388 afi_t afi
= AFI_MAX
;
13389 bool uj
= use_json(argc
, argv
);
13391 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
13396 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
13397 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
13398 || argv_find(argv
, argc
, "WORD", &idx
)) {
13399 sh_type
= show_peer
;
13400 sh_arg
= argv
[idx
]->arg
;
13402 sh_type
= show_all
;
13404 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
13405 return CMD_SUCCESS
;
13408 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
13412 /* "show [ip] bgp neighbors" commands. */
13413 DEFUN (show_ip_bgp_neighbors
,
13414 show_ip_bgp_neighbors_cmd
,
13415 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
13419 BGP_INSTANCE_HELP_STR
13422 "Detailed information on TCP and BGP neighbor connections\n"
13423 "Neighbor to display information about\n"
13424 "Neighbor to display information about\n"
13425 "Neighbor on BGP configured interface\n"
13429 char *sh_arg
= NULL
;
13430 enum show_type sh_type
;
13431 afi_t afi
= AFI_MAX
;
13433 bool uj
= use_json(argc
, argv
);
13437 /* [<vrf> VIEWVRFNAME] */
13438 if (argv_find(argv
, argc
, "vrf", &idx
)) {
13439 vrf
= argv
[idx
+ 1]->arg
;
13440 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
13442 } else if (argv_find(argv
, argc
, "view", &idx
))
13443 /* [<view> VIEWVRFNAME] */
13444 vrf
= argv
[idx
+ 1]->arg
;
13448 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
13449 sh_type
= show_ipv4_all
;
13451 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
13452 sh_type
= show_ipv6_all
;
13455 sh_type
= show_all
;
13458 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
13459 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
13460 || argv_find(argv
, argc
, "WORD", &idx
)) {
13461 sh_type
= show_peer
;
13462 sh_arg
= argv
[idx
]->arg
;
13465 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
13466 sh_type
= show_ipv4_peer
;
13467 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
13468 sh_type
= show_ipv6_peer
;
13471 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
13474 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
13475 paths' and `show ip mbgp paths'. Those functions results are the
13477 DEFUN (show_ip_bgp_paths
,
13478 show_ip_bgp_paths_cmd
,
13479 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
13484 "Path information\n")
13486 vty_out(vty
, "Address Refcnt Path\n");
13487 aspath_print_all_vty(vty
);
13488 return CMD_SUCCESS
;
13493 static void community_show_all_iterator(struct hash_bucket
*bucket
,
13496 struct community
*com
;
13498 com
= (struct community
*)bucket
->data
;
13499 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
13500 community_str(com
, false));
13503 /* Show BGP's community internal data. */
13504 DEFUN (show_ip_bgp_community_info
,
13505 show_ip_bgp_community_info_cmd
,
13506 "show [ip] bgp community-info",
13510 "List all bgp community information\n")
13512 vty_out(vty
, "Address Refcnt Community\n");
13514 hash_iterate(community_hash(),
13515 (void (*)(struct hash_bucket
*,
13516 void *))community_show_all_iterator
,
13519 return CMD_SUCCESS
;
13522 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
13525 struct lcommunity
*lcom
;
13527 lcom
= (struct lcommunity
*)bucket
->data
;
13528 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
13529 lcommunity_str(lcom
, false));
13532 /* Show BGP's community internal data. */
13533 DEFUN (show_ip_bgp_lcommunity_info
,
13534 show_ip_bgp_lcommunity_info_cmd
,
13535 "show ip bgp large-community-info",
13539 "List all bgp large-community information\n")
13541 vty_out(vty
, "Address Refcnt Large-community\n");
13543 hash_iterate(lcommunity_hash(),
13544 (void (*)(struct hash_bucket
*,
13545 void *))lcommunity_show_all_iterator
,
13548 return CMD_SUCCESS
;
13550 /* Graceful Restart */
13552 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
13559 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
13561 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
13563 switch (bgp_global_gr_mode
) {
13565 case GLOBAL_HELPER
:
13566 vty_out(vty
, "Global BGP GR Mode : Helper\n");
13570 vty_out(vty
, "Global BGP GR Mode : Restart\n");
13573 case GLOBAL_DISABLE
:
13574 vty_out(vty
, "Global BGP GR Mode : Disable\n");
13577 case GLOBAL_INVALID
:
13579 "Global BGP GR Mode Invalid\n");
13582 vty_out(vty
, "\n");
13585 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
13586 enum show_type type
,
13587 const char *ip_str
,
13588 afi_t afi
, bool use_json
)
13590 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
13593 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
13595 bgp_show_neighbor_graceful_restart_vty(
13596 vty
, type
, ip_str
, afi
, use_json
);
13599 } else if (afi
!= AFI_MAX
) {
13600 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
13603 return CMD_ERR_INCOMPLETE
;
13606 return CMD_SUCCESS
;
13608 /* Graceful Restart */
13610 DEFUN (show_ip_bgp_attr_info
,
13611 show_ip_bgp_attr_info_cmd
,
13612 "show [ip] bgp attribute-info",
13616 "List all bgp attribute information\n")
13618 attr_show_all(vty
);
13619 return CMD_SUCCESS
;
13622 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
13623 afi_t afi
, safi_t safi
,
13624 bool use_json
, json_object
*json
)
13627 struct listnode
*node
;
13629 char buf1
[INET6_ADDRSTRLEN
];
13631 vpn_policy_direction_t dir
;
13634 json_object
*json_import_vrfs
= NULL
;
13635 json_object
*json_export_vrfs
= NULL
;
13637 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
13640 vty_out(vty
, "%s\n",
13641 json_object_to_json_string_ext(
13643 JSON_C_TO_STRING_PRETTY
));
13644 json_object_free(json
);
13646 return CMD_WARNING
;
13649 /* Provide context for the block */
13650 json_object_string_add(json
, "vrf", name
? name
: "default");
13651 json_object_string_add(json
, "afiSafi",
13652 get_afi_safi_str(afi
, safi
, true));
13654 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
13655 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
13656 json_object_string_add(json
, "importFromVrfs", "none");
13657 json_object_string_add(json
, "importRts", "none");
13659 json_import_vrfs
= json_object_new_array();
13661 for (ALL_LIST_ELEMENTS_RO(
13662 bgp
->vpn_policy
[afi
].import_vrf
,
13664 json_object_array_add(json_import_vrfs
,
13665 json_object_new_string(vname
));
13667 json_object_object_add(json
, "importFromVrfs",
13669 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
13670 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
13671 ecom_str
= ecommunity_ecom2str(
13672 bgp
->vpn_policy
[afi
].rtlist
[dir
],
13673 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
13674 json_object_string_add(json
, "importRts",
13676 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
13678 json_object_string_add(json
, "importRts",
13682 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
13683 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
13684 json_object_string_add(json
, "exportToVrfs", "none");
13685 json_object_string_add(json
, "routeDistinguisher",
13687 json_object_string_add(json
, "exportRts", "none");
13689 json_export_vrfs
= json_object_new_array();
13691 for (ALL_LIST_ELEMENTS_RO(
13692 bgp
->vpn_policy
[afi
].export_vrf
,
13694 json_object_array_add(json_export_vrfs
,
13695 json_object_new_string(vname
));
13696 json_object_object_add(json
, "exportToVrfs",
13698 json_object_string_add(json
, "routeDistinguisher",
13699 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
13700 buf1
, RD_ADDRSTRLEN
));
13702 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
13703 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
13704 ecom_str
= ecommunity_ecom2str(
13705 bgp
->vpn_policy
[afi
].rtlist
[dir
],
13706 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
13707 json_object_string_add(json
, "exportRts",
13709 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
13711 json_object_string_add(json
, "exportRts",
13716 vty_out(vty
, "%s\n",
13717 json_object_to_json_string_ext(json
,
13718 JSON_C_TO_STRING_PRETTY
));
13719 json_object_free(json
);
13722 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
13725 vty_out(vty
, "%% No such BGP instance exist\n");
13726 return CMD_WARNING
;
13729 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
13730 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
13732 "This VRF is not importing %s routes from any other VRF\n",
13733 get_afi_safi_str(afi
, safi
, false));
13736 "This VRF is importing %s routes from the following VRFs:\n",
13737 get_afi_safi_str(afi
, safi
, false));
13739 for (ALL_LIST_ELEMENTS_RO(
13740 bgp
->vpn_policy
[afi
].import_vrf
,
13742 vty_out(vty
, " %s\n", vname
);
13744 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
13746 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
13747 ecom_str
= ecommunity_ecom2str(
13748 bgp
->vpn_policy
[afi
].rtlist
[dir
],
13749 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
13750 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
13752 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
13754 vty_out(vty
, "Import RT(s):\n");
13757 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
13758 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
13760 "This VRF is not exporting %s routes to any other VRF\n",
13761 get_afi_safi_str(afi
, safi
, false));
13764 "This VRF is exporting %s routes to the following VRFs:\n",
13765 get_afi_safi_str(afi
, safi
, false));
13767 for (ALL_LIST_ELEMENTS_RO(
13768 bgp
->vpn_policy
[afi
].export_vrf
,
13770 vty_out(vty
, " %s\n", vname
);
13772 vty_out(vty
, "RD: %s\n",
13773 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
13774 buf1
, RD_ADDRSTRLEN
));
13776 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
13777 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
13778 ecom_str
= ecommunity_ecom2str(
13779 bgp
->vpn_policy
[afi
].rtlist
[dir
],
13780 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
13781 vty_out(vty
, "Export RT: %s\n", ecom_str
);
13782 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
13784 vty_out(vty
, "Import RT(s):\n");
13788 return CMD_SUCCESS
;
13791 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
13792 safi_t safi
, bool use_json
)
13794 struct listnode
*node
, *nnode
;
13796 char *vrf_name
= NULL
;
13797 json_object
*json
= NULL
;
13798 json_object
*json_vrf
= NULL
;
13799 json_object
*json_vrfs
= NULL
;
13802 json
= json_object_new_object();
13803 json_vrfs
= json_object_new_object();
13806 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
13808 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
13809 vrf_name
= bgp
->name
;
13812 json_vrf
= json_object_new_object();
13814 vty_out(vty
, "\nInstance %s:\n",
13815 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
13816 ? VRF_DEFAULT_NAME
: bgp
->name
);
13818 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
13820 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
13821 json_object_object_add(json_vrfs
,
13822 VRF_DEFAULT_NAME
, json_vrf
);
13824 json_object_object_add(json_vrfs
, vrf_name
,
13830 json_object_object_add(json
, "vrfs", json_vrfs
);
13831 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
13832 JSON_C_TO_STRING_PRETTY
));
13833 json_object_free(json
);
13836 return CMD_SUCCESS
;
13839 /* "show [ip] bgp route-leak" command. */
13840 DEFUN (show_ip_bgp_route_leak
,
13841 show_ip_bgp_route_leak_cmd
,
13842 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
13846 BGP_INSTANCE_HELP_STR
13849 "Route leaking information\n"
13853 afi_t afi
= AFI_MAX
;
13854 safi_t safi
= SAFI_MAX
;
13856 bool uj
= use_json(argc
, argv
);
13858 json_object
*json
= NULL
;
13860 /* show [ip] bgp */
13861 if (argv_find(argv
, argc
, "ip", &idx
)) {
13863 safi
= SAFI_UNICAST
;
13865 /* [vrf VIEWVRFNAME] */
13866 if (argv_find(argv
, argc
, "view", &idx
)) {
13868 "%% This command is not applicable to BGP views\n");
13869 return CMD_WARNING
;
13872 if (argv_find(argv
, argc
, "vrf", &idx
)) {
13873 vrf
= argv
[idx
+ 1]->arg
;
13874 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
13877 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
13878 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
13879 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
13882 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
13884 "%% This command is applicable only for unicast ipv4|ipv6\n");
13885 return CMD_WARNING
;
13888 if (vrf
&& strmatch(vrf
, "all"))
13889 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
13892 json
= json_object_new_object();
13894 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
13897 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
13900 struct listnode
*node
, *nnode
;
13903 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
13904 vty_out(vty
, "\nInstance %s:\n",
13905 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
13908 update_group_show(bgp
, afi
, safi
, vty
, 0);
13912 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
13913 int safi
, uint64_t subgrp_id
)
13918 if (strmatch(name
, "all")) {
13919 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
13920 return CMD_SUCCESS
;
13922 bgp
= bgp_lookup_by_name(name
);
13925 bgp
= bgp_get_default();
13929 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
13930 return CMD_SUCCESS
;
13933 DEFUN (show_ip_bgp_updgrps
,
13934 show_ip_bgp_updgrps_cmd
,
13935 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
13939 BGP_INSTANCE_HELP_STR
13941 BGP_SAFI_WITH_LABEL_HELP_STR
13942 "Detailed info about dynamic update groups\n"
13943 "Specific subgroup to display detailed info for\n")
13946 afi_t afi
= AFI_IP6
;
13947 safi_t safi
= SAFI_UNICAST
;
13948 uint64_t subgrp_id
= 0;
13952 /* show [ip] bgp */
13953 if (argv_find(argv
, argc
, "ip", &idx
))
13955 /* [<vrf> VIEWVRFNAME] */
13956 if (argv_find(argv
, argc
, "vrf", &idx
)) {
13957 vrf
= argv
[idx
+ 1]->arg
;
13958 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
13960 } else if (argv_find(argv
, argc
, "view", &idx
))
13961 /* [<view> VIEWVRFNAME] */
13962 vrf
= argv
[idx
+ 1]->arg
;
13963 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
13964 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
13965 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
13968 /* get subgroup id, if provided */
13970 if (argv
[idx
]->type
== VARIABLE_TKN
)
13971 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
13973 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
13976 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
13977 show_bgp_instance_all_ipv6_updgrps_cmd
,
13978 "show [ip] bgp <view|vrf> all update-groups",
13982 BGP_INSTANCE_ALL_HELP_STR
13983 "Detailed info about dynamic update groups\n")
13985 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
13986 return CMD_SUCCESS
;
13989 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
13990 show_bgp_l2vpn_evpn_updgrps_cmd
,
13991 "show [ip] bgp l2vpn evpn update-groups",
13995 "l2vpn address family\n"
13996 "evpn sub-address family\n"
13997 "Detailed info about dynamic update groups\n")
14000 uint64_t subgrp_id
= 0;
14002 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
14003 return CMD_SUCCESS
;
14006 DEFUN (show_bgp_updgrps_stats
,
14007 show_bgp_updgrps_stats_cmd
,
14008 "show [ip] bgp update-groups statistics",
14012 "Detailed info about dynamic update groups\n"
14017 bgp
= bgp_get_default();
14019 update_group_show_stats(bgp
, vty
);
14021 return CMD_SUCCESS
;
14024 DEFUN (show_bgp_instance_updgrps_stats
,
14025 show_bgp_instance_updgrps_stats_cmd
,
14026 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
14030 BGP_INSTANCE_HELP_STR
14031 "Detailed info about dynamic update groups\n"
14037 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
14039 update_group_show_stats(bgp
, vty
);
14041 return CMD_SUCCESS
;
14044 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
14045 afi_t afi
, safi_t safi
,
14046 const char *what
, uint64_t subgrp_id
)
14051 bgp
= bgp_lookup_by_name(name
);
14053 bgp
= bgp_get_default();
14056 if (!strcmp(what
, "advertise-queue"))
14057 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
14059 else if (!strcmp(what
, "advertised-routes"))
14060 update_group_show_advertised(bgp
, afi
, safi
, vty
,
14062 else if (!strcmp(what
, "packet-queue"))
14063 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
14068 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
14069 show_ip_bgp_instance_updgrps_adj_s_cmd
,
14070 "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",
14071 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
14073 "Detailed info about dynamic update groups\n"
14074 "Specific subgroup to display info for\n"
14075 "Advertisement queue\n"
14076 "Announced routes\n"
14079 uint64_t subgrp_id
= 0;
14083 subgrp_id
= strtoull(sgid
, NULL
, 10);
14088 afiz
= bgp_vty_afi_from_str(afi
);
14092 afiz
= bgp_vty_afi_from_str(afi
);
14093 if (afiz
!= AFI_IP
)
14095 "%% Cannot specify both 'ip' and 'ipv6'\n");
14096 return CMD_WARNING
;
14099 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
14101 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
14102 return CMD_SUCCESS
;
14105 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
14107 struct listnode
*node
, *nnode
;
14108 struct prefix
*range
;
14111 char buf
[PREFIX2STR_BUFFER
];
14114 const char *peer_status
;
14115 const char *af_str
;
14120 conf
= group
->conf
;
14122 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
14123 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
14124 group
->name
, conf
->as
);
14125 } else if (conf
->as_type
== AS_INTERNAL
) {
14126 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
14127 group
->name
, group
->bgp
->as
);
14129 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
14132 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
14133 vty_out(vty
, " Peer-group type is internal\n");
14135 vty_out(vty
, " Peer-group type is external\n");
14137 /* Display AFs configured. */
14138 vty_out(vty
, " Configured address-families:");
14139 FOREACH_AFI_SAFI (afi
, safi
) {
14140 if (conf
->afc
[afi
][safi
]) {
14142 vty_out(vty
, " %s;", get_afi_safi_str(afi
, safi
, false));
14146 vty_out(vty
, " none\n");
14148 vty_out(vty
, "\n");
14150 /* Display listen ranges (for dynamic neighbors), if any */
14151 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
14154 else if (afi
== AFI_IP6
)
14158 lr_count
= listcount(group
->listen_range
[afi
]);
14160 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
14164 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
14166 prefix2str(range
, buf
, sizeof(buf
));
14167 vty_out(vty
, " %s\n", buf
);
14172 /* Display group members and their status */
14173 if (listcount(group
->peer
)) {
14174 vty_out(vty
, " Peer-group members:\n");
14175 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
14176 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
14177 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
14178 peer_status
= "Idle (Admin)";
14179 else if (CHECK_FLAG(peer
->sflags
,
14180 PEER_STATUS_PREFIX_OVERFLOW
))
14181 peer_status
= "Idle (PfxCt)";
14183 peer_status
= lookup_msg(bgp_status_msg
,
14184 peer
->status
, NULL
);
14186 dynamic
= peer_dynamic_neighbor(peer
);
14187 vty_out(vty
, " %s %s %s \n", peer
->host
,
14188 dynamic
? "(dynamic)" : "", peer_status
);
14192 return CMD_SUCCESS
;
14195 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
14196 const char *group_name
)
14199 struct listnode
*node
, *nnode
;
14200 struct peer_group
*group
;
14201 bool found
= false;
14203 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
14206 vty_out(vty
, "%% BGP instance not found\n");
14207 return CMD_WARNING
;
14210 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
14212 if (strmatch(group
->name
, group_name
)) {
14213 bgp_show_one_peer_group(vty
, group
);
14218 bgp_show_one_peer_group(vty
, group
);
14222 if (group_name
&& !found
)
14223 vty_out(vty
, "%% No such peer-group\n");
14225 return CMD_SUCCESS
;
14228 DEFUN (show_ip_bgp_peer_groups
,
14229 show_ip_bgp_peer_groups_cmd
,
14230 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
14234 BGP_INSTANCE_HELP_STR
14235 "Detailed information on BGP peer groups\n"
14236 "Peer group name\n")
14241 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
14243 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
14245 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
14249 /* Redistribute VTY commands. */
14251 DEFUN (bgp_redistribute_ipv4
,
14252 bgp_redistribute_ipv4_cmd
,
14253 "redistribute " FRR_IP_REDIST_STR_BGPD
,
14254 "Redistribute information from another routing protocol\n"
14255 FRR_IP_REDIST_HELP_STR_BGPD
)
14257 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14258 int idx_protocol
= 1;
14261 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
14263 vty_out(vty
, "%% Invalid route type\n");
14264 return CMD_WARNING_CONFIG_FAILED
;
14267 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
14268 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
14272 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
14273 "redistribute " FRR_IP_REDIST_STR_BGPD
,
14274 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
14276 DEFUN (bgp_redistribute_ipv4_rmap
,
14277 bgp_redistribute_ipv4_rmap_cmd
,
14278 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
14279 "Redistribute information from another routing protocol\n"
14280 FRR_IP_REDIST_HELP_STR_BGPD
14281 "Route map reference\n"
14282 "Pointer to route-map entries\n")
14284 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14285 int idx_protocol
= 1;
14288 struct bgp_redist
*red
;
14290 struct route_map
*route_map
= route_map_lookup_warn_noexist(
14291 vty
, argv
[idx_word
]->arg
);
14293 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
14295 vty_out(vty
, "%% Invalid route type\n");
14296 return CMD_WARNING_CONFIG_FAILED
;
14299 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
14301 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
14302 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
14306 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
14307 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
14308 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
14309 "Route map reference\n"
14310 "Pointer to route-map entries\n")
14312 DEFUN (bgp_redistribute_ipv4_metric
,
14313 bgp_redistribute_ipv4_metric_cmd
,
14314 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
14315 "Redistribute information from another routing protocol\n"
14316 FRR_IP_REDIST_HELP_STR_BGPD
14317 "Metric for redistributed routes\n"
14318 "Default metric\n")
14320 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14321 int idx_protocol
= 1;
14322 int idx_number
= 3;
14325 struct bgp_redist
*red
;
14328 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
14330 vty_out(vty
, "%% Invalid route type\n");
14331 return CMD_WARNING_CONFIG_FAILED
;
14333 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
14335 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
14336 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
14337 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
14341 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
14342 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
14343 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
14344 "Metric for redistributed routes\n"
14345 "Default metric\n")
14347 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
14348 bgp_redistribute_ipv4_rmap_metric_cmd
,
14349 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
14350 "Redistribute information from another routing protocol\n"
14351 FRR_IP_REDIST_HELP_STR_BGPD
14352 "Route map reference\n"
14353 "Pointer to route-map entries\n"
14354 "Metric for redistributed routes\n"
14355 "Default metric\n")
14357 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14358 int idx_protocol
= 1;
14360 int idx_number
= 5;
14363 struct bgp_redist
*red
;
14365 struct route_map
*route_map
=
14366 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
14368 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
14370 vty_out(vty
, "%% Invalid route type\n");
14371 return CMD_WARNING_CONFIG_FAILED
;
14373 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
14375 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
14377 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
14378 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
14379 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
14383 bgp_redistribute_ipv4_rmap_metric
,
14384 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
14385 "redistribute " FRR_IP_REDIST_STR_BGPD
14386 " route-map WORD metric (0-4294967295)",
14387 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
14388 "Route map reference\n"
14389 "Pointer to route-map entries\n"
14390 "Metric for redistributed routes\n"
14391 "Default metric\n")
14393 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
14394 bgp_redistribute_ipv4_metric_rmap_cmd
,
14395 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
14396 "Redistribute information from another routing protocol\n"
14397 FRR_IP_REDIST_HELP_STR_BGPD
14398 "Metric for redistributed routes\n"
14400 "Route map reference\n"
14401 "Pointer to route-map entries\n")
14403 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14404 int idx_protocol
= 1;
14405 int idx_number
= 3;
14409 struct bgp_redist
*red
;
14411 struct route_map
*route_map
=
14412 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
14414 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
14416 vty_out(vty
, "%% Invalid route type\n");
14417 return CMD_WARNING_CONFIG_FAILED
;
14419 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
14421 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
14422 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
14424 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
14425 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
14429 bgp_redistribute_ipv4_metric_rmap
,
14430 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
14431 "redistribute " FRR_IP_REDIST_STR_BGPD
14432 " metric (0-4294967295) route-map WORD",
14433 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
14434 "Metric for redistributed routes\n"
14436 "Route map reference\n"
14437 "Pointer to route-map entries\n")
14439 DEFUN (bgp_redistribute_ipv4_ospf
,
14440 bgp_redistribute_ipv4_ospf_cmd
,
14441 "redistribute <ospf|table> (1-65535)",
14442 "Redistribute information from another routing protocol\n"
14443 "Open Shortest Path First (OSPFv2)\n"
14444 "Non-main Kernel Routing Table\n"
14445 "Instance ID/Table ID\n")
14447 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14448 int idx_ospf_table
= 1;
14449 int idx_number
= 2;
14450 unsigned short instance
;
14451 unsigned short protocol
;
14453 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
14455 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
14456 protocol
= ZEBRA_ROUTE_OSPF
;
14458 protocol
= ZEBRA_ROUTE_TABLE
;
14460 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
14461 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
14464 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
14465 "redistribute <ospf|table> (1-65535)",
14466 "Redistribute information from another routing protocol\n"
14467 "Open Shortest Path First (OSPFv2)\n"
14468 "Non-main Kernel Routing Table\n"
14469 "Instance ID/Table ID\n")
14471 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
14472 bgp_redistribute_ipv4_ospf_rmap_cmd
,
14473 "redistribute <ospf|table> (1-65535) route-map WORD",
14474 "Redistribute information from another routing protocol\n"
14475 "Open Shortest Path First (OSPFv2)\n"
14476 "Non-main Kernel Routing Table\n"
14477 "Instance ID/Table ID\n"
14478 "Route map reference\n"
14479 "Pointer to route-map entries\n")
14481 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14482 int idx_ospf_table
= 1;
14483 int idx_number
= 2;
14485 struct bgp_redist
*red
;
14486 unsigned short instance
;
14489 struct route_map
*route_map
=
14490 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
14492 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
14493 protocol
= ZEBRA_ROUTE_OSPF
;
14495 protocol
= ZEBRA_ROUTE_TABLE
;
14497 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
14498 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
14500 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
14501 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
14504 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
14505 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
14506 "redistribute <ospf|table> (1-65535) route-map WORD",
14507 "Redistribute information from another routing protocol\n"
14508 "Open Shortest Path First (OSPFv2)\n"
14509 "Non-main Kernel Routing Table\n"
14510 "Instance ID/Table ID\n"
14511 "Route map reference\n"
14512 "Pointer to route-map entries\n")
14514 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
14515 bgp_redistribute_ipv4_ospf_metric_cmd
,
14516 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
14517 "Redistribute information from another routing protocol\n"
14518 "Open Shortest Path First (OSPFv2)\n"
14519 "Non-main Kernel Routing Table\n"
14520 "Instance ID/Table ID\n"
14521 "Metric for redistributed routes\n"
14522 "Default metric\n")
14524 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14525 int idx_ospf_table
= 1;
14526 int idx_number
= 2;
14527 int idx_number_2
= 4;
14529 struct bgp_redist
*red
;
14530 unsigned short instance
;
14534 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
14535 protocol
= ZEBRA_ROUTE_OSPF
;
14537 protocol
= ZEBRA_ROUTE_TABLE
;
14539 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
14540 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
14542 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
14543 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
14545 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
14548 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
14549 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
14550 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
14551 "Redistribute information from another routing protocol\n"
14552 "Open Shortest Path First (OSPFv2)\n"
14553 "Non-main Kernel Routing Table\n"
14554 "Instance ID/Table ID\n"
14555 "Metric for redistributed routes\n"
14556 "Default metric\n")
14558 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
14559 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
14560 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
14561 "Redistribute information from another routing protocol\n"
14562 "Open Shortest Path First (OSPFv2)\n"
14563 "Non-main Kernel Routing Table\n"
14564 "Instance ID/Table ID\n"
14565 "Route map reference\n"
14566 "Pointer to route-map entries\n"
14567 "Metric for redistributed routes\n"
14568 "Default metric\n")
14570 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14571 int idx_ospf_table
= 1;
14572 int idx_number
= 2;
14574 int idx_number_2
= 6;
14576 struct bgp_redist
*red
;
14577 unsigned short instance
;
14580 struct route_map
*route_map
=
14581 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
14583 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
14584 protocol
= ZEBRA_ROUTE_OSPF
;
14586 protocol
= ZEBRA_ROUTE_TABLE
;
14588 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
14589 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
14591 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
14593 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
14594 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
14596 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
14600 bgp_redistribute_ipv4_ospf_rmap_metric
,
14601 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
14602 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
14603 "Redistribute information from another routing protocol\n"
14604 "Open Shortest Path First (OSPFv2)\n"
14605 "Non-main Kernel Routing Table\n"
14606 "Instance ID/Table ID\n"
14607 "Route map reference\n"
14608 "Pointer to route-map entries\n"
14609 "Metric for redistributed routes\n"
14610 "Default metric\n")
14612 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
14613 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
14614 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
14615 "Redistribute information from another routing protocol\n"
14616 "Open Shortest Path First (OSPFv2)\n"
14617 "Non-main Kernel Routing Table\n"
14618 "Instance ID/Table ID\n"
14619 "Metric for redistributed routes\n"
14621 "Route map reference\n"
14622 "Pointer to route-map entries\n")
14624 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14625 int idx_ospf_table
= 1;
14626 int idx_number
= 2;
14627 int idx_number_2
= 4;
14630 struct bgp_redist
*red
;
14631 unsigned short instance
;
14634 struct route_map
*route_map
=
14635 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
14637 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
14638 protocol
= ZEBRA_ROUTE_OSPF
;
14640 protocol
= ZEBRA_ROUTE_TABLE
;
14642 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
14643 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
14645 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
14646 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
14649 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
14650 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
14654 bgp_redistribute_ipv4_ospf_metric_rmap
,
14655 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
14656 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
14657 "Redistribute information from another routing protocol\n"
14658 "Open Shortest Path First (OSPFv2)\n"
14659 "Non-main Kernel Routing Table\n"
14660 "Instance ID/Table ID\n"
14661 "Metric for redistributed routes\n"
14663 "Route map reference\n"
14664 "Pointer to route-map entries\n")
14666 DEFUN (no_bgp_redistribute_ipv4_ospf
,
14667 no_bgp_redistribute_ipv4_ospf_cmd
,
14668 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
14670 "Redistribute information from another routing protocol\n"
14671 "Open Shortest Path First (OSPFv2)\n"
14672 "Non-main Kernel Routing Table\n"
14673 "Instance ID/Table ID\n"
14674 "Metric for redistributed routes\n"
14676 "Route map reference\n"
14677 "Pointer to route-map entries\n")
14679 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14680 int idx_ospf_table
= 2;
14681 int idx_number
= 3;
14682 unsigned short instance
;
14685 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
14686 protocol
= ZEBRA_ROUTE_OSPF
;
14688 protocol
= ZEBRA_ROUTE_TABLE
;
14690 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
14691 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
14695 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
14696 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
14698 "Redistribute information from another routing protocol\n"
14699 "Open Shortest Path First (OSPFv2)\n"
14700 "Non-main Kernel Routing Table\n"
14701 "Instance ID/Table ID\n"
14702 "Metric for redistributed routes\n"
14704 "Route map reference\n"
14705 "Pointer to route-map entries\n")
14707 DEFUN (no_bgp_redistribute_ipv4
,
14708 no_bgp_redistribute_ipv4_cmd
,
14709 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
14711 "Redistribute information from another routing protocol\n"
14712 FRR_IP_REDIST_HELP_STR_BGPD
14713 "Metric for redistributed routes\n"
14715 "Route map reference\n"
14716 "Pointer to route-map entries\n")
14718 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14719 int idx_protocol
= 2;
14722 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
14724 vty_out(vty
, "%% Invalid route type\n");
14725 return CMD_WARNING_CONFIG_FAILED
;
14727 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
14731 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
14732 "no redistribute " FRR_IP_REDIST_STR_BGPD
14733 " [{metric (0-4294967295)|route-map WORD}]",
14735 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
14736 "Metric for redistributed routes\n"
14738 "Route map reference\n"
14739 "Pointer to route-map entries\n")
14741 DEFUN (bgp_redistribute_ipv6
,
14742 bgp_redistribute_ipv6_cmd
,
14743 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
14744 "Redistribute information from another routing protocol\n"
14745 FRR_IP6_REDIST_HELP_STR_BGPD
)
14747 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14748 int idx_protocol
= 1;
14751 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
14753 vty_out(vty
, "%% Invalid route type\n");
14754 return CMD_WARNING_CONFIG_FAILED
;
14757 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
14758 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
14761 DEFUN (bgp_redistribute_ipv6_rmap
,
14762 bgp_redistribute_ipv6_rmap_cmd
,
14763 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
14764 "Redistribute information from another routing protocol\n"
14765 FRR_IP6_REDIST_HELP_STR_BGPD
14766 "Route map reference\n"
14767 "Pointer to route-map entries\n")
14769 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14770 int idx_protocol
= 1;
14773 struct bgp_redist
*red
;
14775 struct route_map
*route_map
=
14776 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
14778 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
14780 vty_out(vty
, "%% Invalid route type\n");
14781 return CMD_WARNING_CONFIG_FAILED
;
14784 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
14786 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
14787 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
14790 DEFUN (bgp_redistribute_ipv6_metric
,
14791 bgp_redistribute_ipv6_metric_cmd
,
14792 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
14793 "Redistribute information from another routing protocol\n"
14794 FRR_IP6_REDIST_HELP_STR_BGPD
14795 "Metric for redistributed routes\n"
14796 "Default metric\n")
14798 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14799 int idx_protocol
= 1;
14800 int idx_number
= 3;
14803 struct bgp_redist
*red
;
14806 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
14808 vty_out(vty
, "%% Invalid route type\n");
14809 return CMD_WARNING_CONFIG_FAILED
;
14811 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
14813 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
14814 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
14815 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
14818 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
14819 bgp_redistribute_ipv6_rmap_metric_cmd
,
14820 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
14821 "Redistribute information from another routing protocol\n"
14822 FRR_IP6_REDIST_HELP_STR_BGPD
14823 "Route map reference\n"
14824 "Pointer to route-map entries\n"
14825 "Metric for redistributed routes\n"
14826 "Default metric\n")
14828 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14829 int idx_protocol
= 1;
14831 int idx_number
= 5;
14834 struct bgp_redist
*red
;
14836 struct route_map
*route_map
=
14837 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
14839 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
14841 vty_out(vty
, "%% Invalid route type\n");
14842 return CMD_WARNING_CONFIG_FAILED
;
14844 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
14846 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
14848 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
14849 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
14851 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
14854 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
14855 bgp_redistribute_ipv6_metric_rmap_cmd
,
14856 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
14857 "Redistribute information from another routing protocol\n"
14858 FRR_IP6_REDIST_HELP_STR_BGPD
14859 "Metric for redistributed routes\n"
14861 "Route map reference\n"
14862 "Pointer to route-map entries\n")
14864 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14865 int idx_protocol
= 1;
14866 int idx_number
= 3;
14870 struct bgp_redist
*red
;
14872 struct route_map
*route_map
=
14873 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
14875 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
14877 vty_out(vty
, "%% Invalid route type\n");
14878 return CMD_WARNING_CONFIG_FAILED
;
14880 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
14882 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
14883 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
14886 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
14887 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
14890 DEFUN (no_bgp_redistribute_ipv6
,
14891 no_bgp_redistribute_ipv6_cmd
,
14892 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
14894 "Redistribute information from another routing protocol\n"
14895 FRR_IP6_REDIST_HELP_STR_BGPD
14896 "Metric for redistributed routes\n"
14898 "Route map reference\n"
14899 "Pointer to route-map entries\n")
14901 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14902 int idx_protocol
= 2;
14905 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
14907 vty_out(vty
, "%% Invalid route type\n");
14908 return CMD_WARNING_CONFIG_FAILED
;
14911 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
14914 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
14915 afi_t afi
, safi_t safi
)
14919 /* Unicast redistribution only. */
14920 if (safi
!= SAFI_UNICAST
)
14923 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
14924 /* Redistribute BGP does not make sense. */
14925 if (i
!= ZEBRA_ROUTE_BGP
) {
14926 struct list
*red_list
;
14927 struct listnode
*node
;
14928 struct bgp_redist
*red
;
14930 red_list
= bgp
->redist
[afi
][i
];
14934 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
14935 /* "redistribute" configuration. */
14936 vty_out(vty
, " redistribute %s",
14937 zebra_route_string(i
));
14939 vty_out(vty
, " %d", red
->instance
);
14940 if (red
->redist_metric_flag
)
14941 vty_out(vty
, " metric %u",
14942 red
->redist_metric
);
14943 if (red
->rmap
.name
)
14944 vty_out(vty
, " route-map %s",
14946 vty_out(vty
, "\n");
14952 /* peer-group helpers for config-write */
14954 static bool peergroup_flag_check(struct peer
*peer
, uint32_t flag
)
14956 if (!peer_group_active(peer
)) {
14957 if (CHECK_FLAG(peer
->flags_invert
, flag
))
14958 return !CHECK_FLAG(peer
->flags
, flag
);
14960 return !!CHECK_FLAG(peer
->flags
, flag
);
14963 return !!CHECK_FLAG(peer
->flags_override
, flag
);
14966 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
14969 if (!peer_group_active(peer
)) {
14970 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
14971 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
14973 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
14976 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
14979 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
14980 uint8_t type
, int direct
)
14982 struct bgp_filter
*filter
;
14984 if (peer_group_active(peer
))
14985 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
14988 filter
= &peer
->filter
[afi
][safi
];
14990 case PEER_FT_DISTRIBUTE_LIST
:
14991 return !!(filter
->dlist
[direct
].name
);
14992 case PEER_FT_FILTER_LIST
:
14993 return !!(filter
->aslist
[direct
].name
);
14994 case PEER_FT_PREFIX_LIST
:
14995 return !!(filter
->plist
[direct
].name
);
14996 case PEER_FT_ROUTE_MAP
:
14997 return !!(filter
->map
[direct
].name
);
14998 case PEER_FT_UNSUPPRESS_MAP
:
14999 return !!(filter
->usmap
.name
);
15005 /* Return true if the addpath type is set for peer and different from
15008 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
15011 enum bgp_addpath_strat type
, g_type
;
15013 type
= peer
->addpath_type
[afi
][safi
];
15015 if (type
!= BGP_ADDPATH_NONE
) {
15016 if (peer_group_active(peer
)) {
15017 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
15019 if (type
!= g_type
)
15031 /* This is part of the address-family block (unicast only) */
15032 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
15037 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
15038 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
15039 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
15040 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
15041 bgp
->vpn_policy
[afi
]
15042 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
15044 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
15045 bgp
->vpn_policy
[afi
]
15046 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
15048 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
15049 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
15050 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
15051 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
15054 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
15055 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
15057 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
15060 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
15061 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
15062 bgp
->vpn_policy
[afi
].tovpn_label
);
15065 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
15066 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
15067 char buf
[RD_ADDRSTRLEN
];
15068 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
15069 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
15072 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
15073 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
15075 char buf
[PREFIX_STRLEN
];
15076 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
15077 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
15080 vty_out(vty
, "%*snexthop vpn export %s\n",
15084 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
15085 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
15087 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
15088 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
15090 char *b
= ecommunity_ecom2str(
15091 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
15092 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
15093 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
15094 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
15096 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
15097 char *b
= ecommunity_ecom2str(
15098 bgp
->vpn_policy
[afi
]
15099 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
15100 ECOMMUNITY_FORMAT_ROUTE_MAP
,
15101 ECOMMUNITY_ROUTE_TARGET
);
15102 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
15103 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
15105 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
15106 char *b
= ecommunity_ecom2str(
15107 bgp
->vpn_policy
[afi
]
15108 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
15109 ECOMMUNITY_FORMAT_ROUTE_MAP
,
15110 ECOMMUNITY_ROUTE_TARGET
);
15111 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
15112 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
15116 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
15117 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
15118 bgp
->vpn_policy
[afi
]
15119 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
15121 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
15122 char *b
= ecommunity_ecom2str(
15123 bgp
->vpn_policy
[afi
]
15124 .import_redirect_rtlist
,
15125 ECOMMUNITY_FORMAT_ROUTE_MAP
,
15126 ECOMMUNITY_ROUTE_TARGET
);
15128 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
->unit_size
15129 != ECOMMUNITY_SIZE
)
15130 vty_out(vty
, "%*srt6 redirect import %s\n",
15133 vty_out(vty
, "%*srt redirect import %s\n",
15135 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
15139 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
15140 afi_t afi
, safi_t safi
)
15142 struct bgp_filter
*filter
;
15146 filter
= &peer
->filter
[afi
][safi
];
15148 /* distribute-list. */
15149 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
15151 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
15152 filter
->dlist
[FILTER_IN
].name
);
15154 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
15156 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
15157 filter
->dlist
[FILTER_OUT
].name
);
15160 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
15162 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
15163 filter
->plist
[FILTER_IN
].name
);
15165 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
15167 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
15168 filter
->plist
[FILTER_OUT
].name
);
15171 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
15172 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
15173 filter
->map
[RMAP_IN
].name
);
15175 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
15177 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
15178 filter
->map
[RMAP_OUT
].name
);
15180 /* unsuppress-map */
15181 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
15182 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
15183 filter
->usmap
.name
);
15186 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
15188 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
15189 filter
->aslist
[FILTER_IN
].name
);
15191 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
15193 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
15194 filter
->aslist
[FILTER_OUT
].name
);
15197 /* BGP peer configuration display function. */
15198 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
15201 struct peer
*g_peer
= NULL
;
15202 char buf
[SU_ADDRSTRLEN
];
15204 int if_pg_printed
= false;
15205 int if_ras_printed
= false;
15207 /* Skip dynamic neighbors. */
15208 if (peer_dynamic_neighbor(peer
))
15212 addr
= peer
->conf_if
;
15216 /************************************
15217 ****** Global to the neighbor ******
15218 ************************************/
15219 if (peer
->conf_if
) {
15220 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
15221 vty_out(vty
, " neighbor %s interface v6only", addr
);
15223 vty_out(vty
, " neighbor %s interface", addr
);
15225 if (peer_group_active(peer
)) {
15226 vty_out(vty
, " peer-group %s", peer
->group
->name
);
15227 if_pg_printed
= true;
15228 } else if (peer
->as_type
== AS_SPECIFIED
) {
15229 vty_out(vty
, " remote-as %u", peer
->as
);
15230 if_ras_printed
= true;
15231 } else if (peer
->as_type
== AS_INTERNAL
) {
15232 vty_out(vty
, " remote-as internal");
15233 if_ras_printed
= true;
15234 } else if (peer
->as_type
== AS_EXTERNAL
) {
15235 vty_out(vty
, " remote-as external");
15236 if_ras_printed
= true;
15239 vty_out(vty
, "\n");
15242 /* remote-as and peer-group */
15243 /* peer is a member of a peer-group */
15244 if (peer_group_active(peer
)) {
15245 g_peer
= peer
->group
->conf
;
15247 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
15248 if (peer
->as_type
== AS_SPECIFIED
) {
15249 vty_out(vty
, " neighbor %s remote-as %u\n",
15251 } else if (peer
->as_type
== AS_INTERNAL
) {
15253 " neighbor %s remote-as internal\n",
15255 } else if (peer
->as_type
== AS_EXTERNAL
) {
15257 " neighbor %s remote-as external\n",
15262 /* For swpX peers we displayed the peer-group
15263 * via 'neighbor swpX interface peer-group PGNAME' */
15264 if (!if_pg_printed
)
15265 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
15266 peer
->group
->name
);
15269 /* peer is NOT a member of a peer-group */
15271 /* peer is a peer-group, declare the peer-group */
15272 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
15273 vty_out(vty
, " neighbor %s peer-group\n", addr
);
15276 if (!if_ras_printed
) {
15277 if (peer
->as_type
== AS_SPECIFIED
) {
15278 vty_out(vty
, " neighbor %s remote-as %u\n",
15280 } else if (peer
->as_type
== AS_INTERNAL
) {
15282 " neighbor %s remote-as internal\n",
15284 } else if (peer
->as_type
== AS_EXTERNAL
) {
15286 " neighbor %s remote-as external\n",
15293 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
15294 vty_out(vty
, " neighbor %s local-as %u", addr
,
15295 peer
->change_local_as
);
15296 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
15297 vty_out(vty
, " no-prepend");
15298 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
15299 vty_out(vty
, " replace-as");
15300 vty_out(vty
, "\n");
15305 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
15309 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
15310 if (peer
->tx_shutdown_message
)
15311 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
15312 peer
->tx_shutdown_message
);
15314 vty_out(vty
, " neighbor %s shutdown\n", addr
);
15317 if (peergroup_flag_check(peer
, PEER_FLAG_RTT_SHUTDOWN
))
15318 vty_out(vty
, " neighbor %s shutdown rtt %u count %u\n", addr
,
15319 peer
->rtt_expected
, peer
->rtt_keepalive_conf
);
15322 if (peer
->bfd_info
) {
15323 if (!peer_group_active(peer
) || !g_peer
->bfd_info
) {
15324 bgp_bfd_peer_config_write(vty
, peer
, addr
);
15329 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
15330 vty_out(vty
, " neighbor %s password %s\n", addr
,
15333 /* neighbor solo */
15334 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
15335 if (!peer_group_active(peer
)) {
15336 vty_out(vty
, " neighbor %s solo\n", addr
);
15341 if (peer
->port
!= BGP_PORT_DEFAULT
) {
15342 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
15345 /* Local interface name */
15346 if (peer
->ifname
) {
15347 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
15351 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
15352 vty_out(vty
, " neighbor %s passive\n", addr
);
15354 /* ebgp-multihop */
15355 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
15356 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
15357 && peer
->ttl
== MAXTTL
)) {
15358 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
15359 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
15364 /* ttl-security hops */
15365 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
15366 if (!peer_group_active(peer
)
15367 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
15368 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
15369 addr
, peer
->gtsm_hops
);
15373 /* disable-connected-check */
15374 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
15375 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
15377 /* enforce-first-as */
15378 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
15379 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
15381 /* update-source */
15382 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
15383 if (peer
->update_source
)
15384 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
15385 sockunion2str(peer
->update_source
, buf
,
15387 else if (peer
->update_if
)
15388 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
15392 /* advertisement-interval */
15393 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
15394 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
15398 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
15399 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
15400 peer
->keepalive
, peer
->holdtime
);
15402 /* timers connect */
15403 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
15404 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
15406 /* need special-case handling for changed default values due to
15407 * config profile / version (because there is no "timers bgp connect"
15408 * command, we need to save this per-peer :/)
15410 else if (!peer_group_active(peer
) && !peer
->connect
&&
15411 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
15412 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
15413 peer
->bgp
->default_connect_retry
);
15415 /* capability dynamic */
15416 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
15417 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
15419 /* capability extended-nexthop */
15420 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
15421 if (!peer
->conf_if
) {
15422 if (CHECK_FLAG(peer
->flags_invert
,
15423 PEER_FLAG_CAPABILITY_ENHE
))
15425 " no neighbor %s capability extended-nexthop\n",
15429 " neighbor %s capability extended-nexthop\n",
15434 /* dont-capability-negotiation */
15435 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
15436 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
15438 /* override-capability */
15439 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
15440 vty_out(vty
, " neighbor %s override-capability\n", addr
);
15442 /* strict-capability-match */
15443 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
15444 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
15446 /* Sender side AS path loop detection. */
15447 if (peer
->as_path_loop_detection
)
15448 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
15451 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
15452 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
15454 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
15455 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
15457 " neighbor %s graceful-restart-helper\n", addr
);
15458 } else if (CHECK_FLAG(
15459 peer
->peer_gr_new_status_flag
,
15460 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
15462 " neighbor %s graceful-restart\n", addr
);
15464 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
15465 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
15467 peer
->peer_gr_new_status_flag
,
15468 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
15469 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
15475 /* BGP peer configuration display function. */
15476 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
15477 struct peer
*peer
, afi_t afi
, safi_t safi
)
15479 struct peer
*g_peer
= NULL
;
15481 bool flag_scomm
, flag_secomm
, flag_slcomm
;
15483 /* Skip dynamic neighbors. */
15484 if (peer_dynamic_neighbor(peer
))
15488 addr
= peer
->conf_if
;
15492 /************************************
15493 ****** Per AF to the neighbor ******
15494 ************************************/
15495 if (peer_group_active(peer
)) {
15496 g_peer
= peer
->group
->conf
;
15498 /* If the peer-group is active but peer is not, print a 'no
15500 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
15501 vty_out(vty
, " no neighbor %s activate\n", addr
);
15504 /* If the peer-group is not active but peer is, print an
15506 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
15507 vty_out(vty
, " neighbor %s activate\n", addr
);
15510 if (peer
->afc
[afi
][safi
]) {
15511 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
15512 if (CHECK_FLAG(bgp
->flags
,
15513 BGP_FLAG_NO_DEFAULT_IPV4
)) {
15514 vty_out(vty
, " neighbor %s activate\n",
15518 vty_out(vty
, " neighbor %s activate\n", addr
);
15520 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
15521 if (!CHECK_FLAG(bgp
->flags
,
15522 BGP_FLAG_NO_DEFAULT_IPV4
)) {
15524 " no neighbor %s activate\n",
15531 /* addpath TX knobs */
15532 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
15533 switch (peer
->addpath_type
[afi
][safi
]) {
15534 case BGP_ADDPATH_ALL
:
15535 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
15538 case BGP_ADDPATH_BEST_PER_AS
:
15540 " neighbor %s addpath-tx-bestpath-per-AS\n",
15543 case BGP_ADDPATH_MAX
:
15544 case BGP_ADDPATH_NONE
:
15549 /* ORF capability. */
15550 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
15551 || peergroup_af_flag_check(peer
, afi
, safi
,
15552 PEER_FLAG_ORF_PREFIX_RM
)) {
15553 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
15555 if (peergroup_af_flag_check(peer
, afi
, safi
,
15556 PEER_FLAG_ORF_PREFIX_SM
)
15557 && peergroup_af_flag_check(peer
, afi
, safi
,
15558 PEER_FLAG_ORF_PREFIX_RM
))
15559 vty_out(vty
, " both");
15560 else if (peergroup_af_flag_check(peer
, afi
, safi
,
15561 PEER_FLAG_ORF_PREFIX_SM
))
15562 vty_out(vty
, " send");
15564 vty_out(vty
, " receive");
15565 vty_out(vty
, "\n");
15568 /* Route reflector client. */
15569 if (peergroup_af_flag_check(peer
, afi
, safi
,
15570 PEER_FLAG_REFLECTOR_CLIENT
)) {
15571 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
15574 /* next-hop-self force */
15575 if (peergroup_af_flag_check(peer
, afi
, safi
,
15576 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
15577 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
15580 /* next-hop-self */
15581 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
15582 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
15585 /* remove-private-AS */
15586 if (peergroup_af_flag_check(peer
, afi
, safi
,
15587 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
15588 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
15592 else if (peergroup_af_flag_check(peer
, afi
, safi
,
15593 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
15594 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
15598 else if (peergroup_af_flag_check(peer
, afi
, safi
,
15599 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
15600 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
15603 else if (peergroup_af_flag_check(peer
, afi
, safi
,
15604 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
15605 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
15609 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
15610 vty_out(vty
, " neighbor %s as-override\n", addr
);
15613 /* send-community print. */
15614 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
15615 PEER_FLAG_SEND_COMMUNITY
);
15616 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
15617 PEER_FLAG_SEND_EXT_COMMUNITY
);
15618 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
15619 PEER_FLAG_SEND_LARGE_COMMUNITY
);
15621 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
15622 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
15625 vty_out(vty
, " no neighbor %s send-community\n", addr
);
15628 " no neighbor %s send-community extended\n",
15632 vty_out(vty
, " no neighbor %s send-community large\n",
15636 /* Default information */
15637 if (peergroup_af_flag_check(peer
, afi
, safi
,
15638 PEER_FLAG_DEFAULT_ORIGINATE
)) {
15639 vty_out(vty
, " neighbor %s default-originate", addr
);
15641 if (peer
->default_rmap
[afi
][safi
].name
)
15642 vty_out(vty
, " route-map %s",
15643 peer
->default_rmap
[afi
][safi
].name
);
15645 vty_out(vty
, "\n");
15648 /* Soft reconfiguration inbound. */
15649 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
15650 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
15654 /* maximum-prefix. */
15655 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
15656 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
15657 peer
->pmax
[afi
][safi
]);
15659 if (peer
->pmax_threshold
[afi
][safi
]
15660 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
15661 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
15662 if (peer_af_flag_check(peer
, afi
, safi
,
15663 PEER_FLAG_MAX_PREFIX_WARNING
))
15664 vty_out(vty
, " warning-only");
15665 if (peer
->pmax_restart
[afi
][safi
])
15666 vty_out(vty
, " restart %u",
15667 peer
->pmax_restart
[afi
][safi
]);
15668 if (peer_af_flag_check(peer
, afi
, safi
,
15669 PEER_FLAG_MAX_PREFIX_FORCE
))
15670 vty_out(vty
, " force");
15672 vty_out(vty
, "\n");
15675 /* maximum-prefix-out */
15676 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
15677 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
15678 addr
, peer
->pmax_out
[afi
][safi
]);
15680 /* Route server client. */
15681 if (peergroup_af_flag_check(peer
, afi
, safi
,
15682 PEER_FLAG_RSERVER_CLIENT
)) {
15683 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
15686 /* Nexthop-local unchanged. */
15687 if (peergroup_af_flag_check(peer
, afi
, safi
,
15688 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
15689 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
15692 /* allowas-in <1-10> */
15693 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
15694 if (peer_af_flag_check(peer
, afi
, safi
,
15695 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
15696 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
15697 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
15698 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
15700 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
15701 peer
->allowas_in
[afi
][safi
]);
15706 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
15707 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
15708 peer
->weight
[afi
][safi
]);
15711 bgp_config_write_filter(vty
, peer
, afi
, safi
);
15713 /* atribute-unchanged. */
15714 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
15715 || (safi
!= SAFI_EVPN
15716 && peer_af_flag_check(peer
, afi
, safi
,
15717 PEER_FLAG_NEXTHOP_UNCHANGED
))
15718 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
15720 if (!peer_group_active(peer
)
15721 || peergroup_af_flag_check(peer
, afi
, safi
,
15722 PEER_FLAG_AS_PATH_UNCHANGED
)
15723 || peergroup_af_flag_check(peer
, afi
, safi
,
15724 PEER_FLAG_NEXTHOP_UNCHANGED
)
15725 || peergroup_af_flag_check(peer
, afi
, safi
,
15726 PEER_FLAG_MED_UNCHANGED
)) {
15729 " neighbor %s attribute-unchanged%s%s%s\n",
15731 peer_af_flag_check(peer
, afi
, safi
,
15732 PEER_FLAG_AS_PATH_UNCHANGED
)
15735 peer_af_flag_check(peer
, afi
, safi
,
15736 PEER_FLAG_NEXTHOP_UNCHANGED
)
15739 peer_af_flag_check(peer
, afi
, safi
,
15740 PEER_FLAG_MED_UNCHANGED
)
15747 /* Address family based peer configuration display. */
15748 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
15752 struct peer_group
*group
;
15753 struct listnode
*node
, *nnode
;
15756 vty_frame(vty
, " !\n address-family ");
15757 if (afi
== AFI_IP
) {
15758 if (safi
== SAFI_UNICAST
)
15759 vty_frame(vty
, "ipv4 unicast");
15760 else if (safi
== SAFI_LABELED_UNICAST
)
15761 vty_frame(vty
, "ipv4 labeled-unicast");
15762 else if (safi
== SAFI_MULTICAST
)
15763 vty_frame(vty
, "ipv4 multicast");
15764 else if (safi
== SAFI_MPLS_VPN
)
15765 vty_frame(vty
, "ipv4 vpn");
15766 else if (safi
== SAFI_ENCAP
)
15767 vty_frame(vty
, "ipv4 encap");
15768 else if (safi
== SAFI_FLOWSPEC
)
15769 vty_frame(vty
, "ipv4 flowspec");
15770 } else if (afi
== AFI_IP6
) {
15771 if (safi
== SAFI_UNICAST
)
15772 vty_frame(vty
, "ipv6 unicast");
15773 else if (safi
== SAFI_LABELED_UNICAST
)
15774 vty_frame(vty
, "ipv6 labeled-unicast");
15775 else if (safi
== SAFI_MULTICAST
)
15776 vty_frame(vty
, "ipv6 multicast");
15777 else if (safi
== SAFI_MPLS_VPN
)
15778 vty_frame(vty
, "ipv6 vpn");
15779 else if (safi
== SAFI_ENCAP
)
15780 vty_frame(vty
, "ipv6 encap");
15781 else if (safi
== SAFI_FLOWSPEC
)
15782 vty_frame(vty
, "ipv6 flowspec");
15783 } else if (afi
== AFI_L2VPN
) {
15784 if (safi
== SAFI_EVPN
)
15785 vty_frame(vty
, "l2vpn evpn");
15787 vty_frame(vty
, "\n");
15789 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
15791 bgp_config_write_network(vty
, bgp
, afi
, safi
);
15793 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
15795 /* BGP flag dampening. */
15796 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
15797 bgp_config_write_damp(vty
, afi
, safi
);
15799 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
15800 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
15802 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
15803 /* Skip dynamic neighbors. */
15804 if (peer_dynamic_neighbor(peer
))
15807 /* Do not display doppelganger peers */
15808 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
15809 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
15812 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
15813 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
15815 if (safi
== SAFI_EVPN
)
15816 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
15818 if (safi
== SAFI_FLOWSPEC
)
15819 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
15821 if (safi
== SAFI_UNICAST
) {
15822 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
15823 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15824 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
15826 vty_out(vty
, " export vpn\n");
15828 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15829 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
15831 vty_out(vty
, " import vpn\n");
15833 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15834 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15837 for (ALL_LIST_ELEMENTS_RO(
15838 bgp
->vpn_policy
[afi
].import_vrf
, node
,
15840 vty_out(vty
, " import vrf %s\n", name
);
15844 vty_endframe(vty
, " exit-address-family\n");
15847 int bgp_config_write(struct vty
*vty
)
15850 struct peer_group
*group
;
15852 struct listnode
*node
, *nnode
;
15853 struct listnode
*mnode
, *mnnode
;
15855 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
15856 vty_out(vty
, "bgp route-map delay-timer %u\n",
15857 bm
->rmap_update_timer
);
15859 if (bm
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
15860 vty_out(vty
, "bgp update-delay %d", bm
->v_update_delay
);
15861 if (bm
->v_update_delay
!= bm
->v_establish_wait
)
15862 vty_out(vty
, " %d", bm
->v_establish_wait
);
15863 vty_out(vty
, "\n");
15866 if (CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
15867 vty_out(vty
, "bgp graceful-shutdown\n");
15869 /* No-RIB (Zebra) option flag configuration */
15870 if (bgp_option_check(BGP_OPT_NO_FIB
))
15871 vty_out(vty
, "bgp no-rib\n");
15873 /* BGP configuration. */
15874 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
15876 /* skip all auto created vrf as they dont have user config */
15877 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
15880 /* Router bgp ASN */
15881 vty_out(vty
, "router bgp %u", bgp
->as
);
15884 vty_out(vty
, " %s %s",
15885 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
15886 ? "view" : "vrf", bgp
->name
);
15887 vty_out(vty
, "\n");
15889 /* BGP fast-external-failover. */
15890 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
15891 vty_out(vty
, " no bgp fast-external-failover\n");
15893 /* BGP router ID. */
15894 if (bgp
->router_id_static
.s_addr
!= 0)
15895 vty_out(vty
, " bgp router-id %s\n",
15896 inet_ntoa(bgp
->router_id_static
));
15898 /* BGP log-neighbor-changes. */
15899 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
15900 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
15901 vty_out(vty
, " %sbgp log-neighbor-changes\n",
15902 CHECK_FLAG(bgp
->flags
,
15903 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
15907 /* BGP configuration. */
15908 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
15909 vty_out(vty
, " bgp always-compare-med\n");
15911 /* RFC8212 default eBGP policy. */
15912 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
15913 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
15914 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
15915 CHECK_FLAG(bgp
->flags
,
15916 BGP_FLAG_EBGP_REQUIRES_POLICY
)
15920 /* draft-ietf-idr-deprecate-as-set-confed-set */
15921 if (bgp
->reject_as_sets
)
15922 vty_out(vty
, " bgp reject-as-sets\n");
15924 /* BGP default ipv4-unicast. */
15925 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
))
15926 vty_out(vty
, " no bgp default ipv4-unicast\n");
15928 /* BGP default local-preference. */
15929 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
15930 vty_out(vty
, " bgp default local-preference %u\n",
15931 bgp
->default_local_pref
);
15933 /* BGP default show-hostname */
15934 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
15935 != SAVE_BGP_SHOW_HOSTNAME
)
15936 vty_out(vty
, " %sbgp default show-hostname\n",
15937 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
15941 /* BGP default show-nexthop-hostname */
15942 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
15943 != SAVE_BGP_SHOW_HOSTNAME
)
15944 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
15945 CHECK_FLAG(bgp
->flags
,
15946 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
15950 /* BGP default subgroup-pkt-queue-max. */
15951 if (bgp
->default_subgroup_pkt_queue_max
15952 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
15953 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
15954 bgp
->default_subgroup_pkt_queue_max
);
15956 /* BGP client-to-client reflection. */
15957 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
15958 vty_out(vty
, " no bgp client-to-client reflection\n");
15960 /* BGP cluster ID. */
15961 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
15962 vty_out(vty
, " bgp cluster-id %s\n",
15963 inet_ntoa(bgp
->cluster_id
));
15965 /* Disable ebgp connected nexthop check */
15966 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
15968 " bgp disable-ebgp-connected-route-check\n");
15970 /* Confederation identifier*/
15971 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
15972 vty_out(vty
, " bgp confederation identifier %u\n",
15975 /* Confederation peer */
15976 if (bgp
->confed_peers_cnt
> 0) {
15979 vty_out(vty
, " bgp confederation peers");
15981 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
15982 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
15984 vty_out(vty
, "\n");
15987 /* BGP deterministic-med. */
15988 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
15989 != SAVE_BGP_DETERMINISTIC_MED
)
15990 vty_out(vty
, " %sbgp deterministic-med\n",
15991 CHECK_FLAG(bgp
->flags
,
15992 BGP_FLAG_DETERMINISTIC_MED
)
15996 /* BGP update-delay. */
15997 bgp_config_write_update_delay(vty
, bgp
);
15999 if (bgp
->v_maxmed_onstartup
16000 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
16001 vty_out(vty
, " bgp max-med on-startup %u",
16002 bgp
->v_maxmed_onstartup
);
16003 if (bgp
->maxmed_onstartup_value
16004 != BGP_MAXMED_VALUE_DEFAULT
)
16005 vty_out(vty
, " %u",
16006 bgp
->maxmed_onstartup_value
);
16007 vty_out(vty
, "\n");
16009 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
16010 vty_out(vty
, " bgp max-med administrative");
16011 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
16012 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
16013 vty_out(vty
, "\n");
16017 bgp_config_write_wpkt_quanta(vty
, bgp
);
16019 bgp_config_write_rpkt_quanta(vty
, bgp
);
16021 /* coalesce time */
16022 bgp_config_write_coalesce_time(vty
, bgp
);
16024 /* BGP per-instance graceful-shutdown */
16025 /* BGP-wide settings and per-instance settings are mutually
16028 if (!CHECK_FLAG(bm
->flags
, BM_FLAG_GRACEFUL_SHUTDOWN
))
16029 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
16030 vty_out(vty
, " bgp graceful-shutdown\n");
16032 /* BGP graceful-restart. */
16033 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
16035 " bgp graceful-restart stalepath-time %u\n",
16036 bgp
->stalepath_time
);
16038 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
16039 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
16040 bgp
->restart_time
);
16042 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
16044 " bgp graceful-restart select-defer-time %u\n",
16045 bgp
->select_defer_time
);
16047 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
16048 vty_out(vty
, " bgp graceful-restart\n");
16050 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
16051 vty_out(vty
, " bgp graceful-restart-disable\n");
16053 /* BGP graceful-restart Preserve State F bit. */
16054 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
16056 " bgp graceful-restart preserve-fw-state\n");
16058 /* Stale timer for RIB */
16059 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
16061 " bgp graceful-restart rib-stale-time %u\n",
16062 bgp
->rib_stale_time
);
16064 /* BGP bestpath method. */
16065 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
16066 vty_out(vty
, " bgp bestpath as-path ignore\n");
16067 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
16068 vty_out(vty
, " bgp bestpath as-path confed\n");
16070 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
16071 if (CHECK_FLAG(bgp
->flags
,
16072 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
16074 " bgp bestpath as-path multipath-relax as-set\n");
16077 " bgp bestpath as-path multipath-relax\n");
16081 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
16083 " bgp route-reflector allow-outbound-policy\n");
16085 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
16086 vty_out(vty
, " bgp bestpath compare-routerid\n");
16087 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
16088 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
16089 vty_out(vty
, " bgp bestpath med");
16090 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
16091 vty_out(vty
, " confed");
16092 if (CHECK_FLAG(bgp
->flags
,
16093 BGP_FLAG_MED_MISSING_AS_WORST
))
16094 vty_out(vty
, " missing-as-worst");
16095 vty_out(vty
, "\n");
16098 /* Link bandwidth handling. */
16099 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
16100 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
16101 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
16102 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
16103 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
16104 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
16106 /* BGP network import check. */
16107 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
16108 != SAVE_BGP_IMPORT_CHECK
)
16109 vty_out(vty
, " %sbgp network import-check\n",
16110 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
16114 /* BGP timers configuration. */
16115 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
16116 && bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
16117 vty_out(vty
, " timers bgp %u %u\n",
16118 bgp
->default_keepalive
, bgp
->default_holdtime
);
16121 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
16122 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
16125 /* Normal neighbor configuration. */
16126 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
16127 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
16128 bgp_config_write_peer_global(vty
, bgp
, peer
);
16131 /* listen range and limit for dynamic BGP neighbors */
16132 bgp_config_write_listen(vty
, bgp
);
16135 * BGP default autoshutdown neighbors
16137 * This must be placed after any peer and peer-group
16138 * configuration, to avoid setting all peers to shutdown after
16139 * a daemon restart, which is undesired behavior. (see #2286)
16141 if (bgp
->autoshutdown
)
16142 vty_out(vty
, " bgp default shutdown\n");
16144 /* BGP instance administrative shutdown */
16145 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
16146 vty_out(vty
, " bgp shutdown\n");
16148 /* IPv4 unicast configuration. */
16149 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
16151 /* IPv4 multicast configuration. */
16152 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
16154 /* IPv4 labeled-unicast configuration. */
16155 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
16157 /* IPv4 VPN configuration. */
16158 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
16160 /* ENCAPv4 configuration. */
16161 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
16163 /* FLOWSPEC v4 configuration. */
16164 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
16166 /* IPv6 unicast configuration. */
16167 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
16169 /* IPv6 multicast configuration. */
16170 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
16172 /* IPv6 labeled-unicast configuration. */
16173 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
16174 SAFI_LABELED_UNICAST
);
16176 /* IPv6 VPN configuration. */
16177 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
16179 /* ENCAPv6 configuration. */
16180 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
16182 /* FLOWSPEC v6 configuration. */
16183 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
16185 /* EVPN configuration. */
16186 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
16188 hook_call(bgp_inst_config_write
, bgp
, vty
);
16190 #ifdef ENABLE_BGP_VNC
16191 bgp_rfapi_cfg_write(vty
, bgp
);
16194 vty_out(vty
, "!\n");
16200 /* BGP node structure. */
16201 static struct cmd_node bgp_node
= {
16204 .parent_node
= CONFIG_NODE
,
16205 .prompt
= "%s(config-router)# ",
16206 .config_write
= bgp_config_write
,
16209 static struct cmd_node bgp_ipv4_unicast_node
= {
16210 .name
= "bgp ipv4 unicast",
16211 .node
= BGP_IPV4_NODE
,
16212 .parent_node
= BGP_NODE
,
16213 .prompt
= "%s(config-router-af)# ",
16216 static struct cmd_node bgp_ipv4_multicast_node
= {
16217 .name
= "bgp ipv4 multicast",
16218 .node
= BGP_IPV4M_NODE
,
16219 .parent_node
= BGP_NODE
,
16220 .prompt
= "%s(config-router-af)# ",
16223 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
16224 .name
= "bgp ipv4 labeled unicast",
16225 .node
= BGP_IPV4L_NODE
,
16226 .parent_node
= BGP_NODE
,
16227 .prompt
= "%s(config-router-af)# ",
16230 static struct cmd_node bgp_ipv6_unicast_node
= {
16231 .name
= "bgp ipv6",
16232 .node
= BGP_IPV6_NODE
,
16233 .parent_node
= BGP_NODE
,
16234 .prompt
= "%s(config-router-af)# ",
16237 static struct cmd_node bgp_ipv6_multicast_node
= {
16238 .name
= "bgp ipv6 multicast",
16239 .node
= BGP_IPV6M_NODE
,
16240 .parent_node
= BGP_NODE
,
16241 .prompt
= "%s(config-router-af)# ",
16244 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
16245 .name
= "bgp ipv6 labeled unicast",
16246 .node
= BGP_IPV6L_NODE
,
16247 .parent_node
= BGP_NODE
,
16248 .prompt
= "%s(config-router-af)# ",
16251 static struct cmd_node bgp_vpnv4_node
= {
16252 .name
= "bgp vpnv4",
16253 .node
= BGP_VPNV4_NODE
,
16254 .parent_node
= BGP_NODE
,
16255 .prompt
= "%s(config-router-af)# ",
16258 static struct cmd_node bgp_vpnv6_node
= {
16259 .name
= "bgp vpnv6",
16260 .node
= BGP_VPNV6_NODE
,
16261 .parent_node
= BGP_NODE
,
16262 .prompt
= "%s(config-router-af-vpnv6)# ",
16265 static struct cmd_node bgp_evpn_node
= {
16266 .name
= "bgp evpn",
16267 .node
= BGP_EVPN_NODE
,
16268 .parent_node
= BGP_NODE
,
16269 .prompt
= "%s(config-router-evpn)# ",
16272 static struct cmd_node bgp_evpn_vni_node
= {
16273 .name
= "bgp evpn vni",
16274 .node
= BGP_EVPN_VNI_NODE
,
16275 .parent_node
= BGP_EVPN_NODE
,
16276 .prompt
= "%s(config-router-af-vni)# ",
16279 static struct cmd_node bgp_flowspecv4_node
= {
16280 .name
= "bgp ipv4 flowspec",
16281 .node
= BGP_FLOWSPECV4_NODE
,
16282 .parent_node
= BGP_NODE
,
16283 .prompt
= "%s(config-router-af)# ",
16286 static struct cmd_node bgp_flowspecv6_node
= {
16287 .name
= "bgp ipv6 flowspec",
16288 .node
= BGP_FLOWSPECV6_NODE
,
16289 .parent_node
= BGP_NODE
,
16290 .prompt
= "%s(config-router-af-vpnv6)# ",
16293 static void community_list_vty(void);
16295 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
16299 struct listnode
*lnbgp
, *lnpeer
;
16301 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
16302 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
16303 /* only provide suggestions on the appropriate input
16305 * they'll otherwise show up multiple times */
16306 enum cmd_token_type match_type
;
16307 char *name
= peer
->host
;
16309 if (peer
->conf_if
) {
16310 match_type
= VARIABLE_TKN
;
16311 name
= peer
->conf_if
;
16312 } else if (strchr(peer
->host
, ':'))
16313 match_type
= IPV6_TKN
;
16315 match_type
= IPV4_TKN
;
16317 if (token
->type
!= match_type
)
16320 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
16325 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
16326 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
16327 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
16328 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
16329 {.completions
= NULL
}};
16331 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
16334 struct peer_group
*group
;
16335 struct listnode
*lnbgp
, *lnpeer
;
16337 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
16338 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
16339 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
16344 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
16345 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
16346 {.completions
= NULL
} };
16348 void bgp_vty_init(void)
16350 cmd_variable_handler_register(bgp_var_neighbor
);
16351 cmd_variable_handler_register(bgp_var_peergroup
);
16353 /* Install bgp top node. */
16354 install_node(&bgp_node
);
16355 install_node(&bgp_ipv4_unicast_node
);
16356 install_node(&bgp_ipv4_multicast_node
);
16357 install_node(&bgp_ipv4_labeled_unicast_node
);
16358 install_node(&bgp_ipv6_unicast_node
);
16359 install_node(&bgp_ipv6_multicast_node
);
16360 install_node(&bgp_ipv6_labeled_unicast_node
);
16361 install_node(&bgp_vpnv4_node
);
16362 install_node(&bgp_vpnv6_node
);
16363 install_node(&bgp_evpn_node
);
16364 install_node(&bgp_evpn_vni_node
);
16365 install_node(&bgp_flowspecv4_node
);
16366 install_node(&bgp_flowspecv6_node
);
16368 /* Install default VTY commands to new nodes. */
16369 install_default(BGP_NODE
);
16370 install_default(BGP_IPV4_NODE
);
16371 install_default(BGP_IPV4M_NODE
);
16372 install_default(BGP_IPV4L_NODE
);
16373 install_default(BGP_IPV6_NODE
);
16374 install_default(BGP_IPV6M_NODE
);
16375 install_default(BGP_IPV6L_NODE
);
16376 install_default(BGP_VPNV4_NODE
);
16377 install_default(BGP_VPNV6_NODE
);
16378 install_default(BGP_FLOWSPECV4_NODE
);
16379 install_default(BGP_FLOWSPECV6_NODE
);
16380 install_default(BGP_EVPN_NODE
);
16381 install_default(BGP_EVPN_VNI_NODE
);
16383 /* "bgp local-mac" hidden commands. */
16384 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
16385 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
16387 /* bgp route-map delay-timer commands. */
16388 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
16389 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
16391 /* global bgp update-delay command */
16392 install_element(CONFIG_NODE
, &bgp_global_update_delay_cmd
);
16393 install_element(CONFIG_NODE
, &no_bgp_global_update_delay_cmd
);
16395 /* global bgp graceful-shutdown command */
16396 install_element(CONFIG_NODE
, &bgp_graceful_shutdown_cmd
);
16397 install_element(CONFIG_NODE
, &no_bgp_graceful_shutdown_cmd
);
16399 /* Dummy commands (Currently not supported) */
16400 install_element(BGP_NODE
, &no_synchronization_cmd
);
16401 install_element(BGP_NODE
, &no_auto_summary_cmd
);
16403 /* "router bgp" commands. */
16404 install_element(CONFIG_NODE
, &router_bgp_cmd
);
16406 /* "no router bgp" commands. */
16407 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
16409 /* "bgp router-id" commands. */
16410 install_element(BGP_NODE
, &bgp_router_id_cmd
);
16411 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
16413 /* "bgp cluster-id" commands. */
16414 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
16415 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
16417 /* "bgp no-rib" commands. */
16418 install_element(CONFIG_NODE
, &bgp_norib_cmd
);
16419 install_element(CONFIG_NODE
, &no_bgp_norib_cmd
);
16421 /* "bgp confederation" commands. */
16422 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
16423 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
16425 /* "bgp confederation peers" commands. */
16426 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
16427 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
16429 /* bgp max-med command */
16430 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
16431 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
16432 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
16433 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
16434 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
16436 /* bgp disable-ebgp-connected-nh-check */
16437 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
16438 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
16440 /* bgp update-delay command */
16441 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
16442 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
16444 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
16445 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
16447 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
16448 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
16450 /* "maximum-paths" commands. */
16451 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
16452 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
16453 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
16454 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
16455 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
16456 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
16457 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
16458 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
16459 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
16460 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
16461 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
16462 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
16463 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
16464 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
16465 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
16467 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
16468 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
16469 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
16470 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
16471 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
16472 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
16473 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
16474 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
16475 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
16476 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
16478 /* "timers bgp" commands. */
16479 install_element(BGP_NODE
, &bgp_timers_cmd
);
16480 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
16482 /* route-map delay-timer commands - per instance for backwards compat.
16484 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
16485 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
16487 /* "bgp client-to-client reflection" commands */
16488 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
16489 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
16491 /* "bgp always-compare-med" commands */
16492 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
16493 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
16495 /* bgp ebgp-requires-policy */
16496 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
16497 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
16499 /* bgp reject-as-sets */
16500 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
16501 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
16503 /* "bgp deterministic-med" commands */
16504 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
16505 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
16507 /* "bgp graceful-restart" command */
16508 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
16509 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
16511 /* "bgp graceful-restart-disable" command */
16512 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
16513 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
16515 /* "neighbor a:b:c:d graceful-restart" command */
16516 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
16517 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
16519 /* "neighbor a:b:c:d graceful-restart-disable" command */
16520 install_element(BGP_NODE
,
16521 &bgp_neighbor_graceful_restart_disable_set_cmd
);
16522 install_element(BGP_NODE
,
16523 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
16525 /* "neighbor a:b:c:d graceful-restart-helper" command */
16526 install_element(BGP_NODE
,
16527 &bgp_neighbor_graceful_restart_helper_set_cmd
);
16528 install_element(BGP_NODE
,
16529 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
16531 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
16532 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
16533 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
16534 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
16535 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
16536 install_element(BGP_NODE
,
16537 &no_bgp_graceful_restart_select_defer_time_cmd
);
16538 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
16539 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
16541 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
16542 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
16543 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
16544 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
16546 /* "bgp graceful-shutdown" commands */
16547 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
16548 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
16550 /* "bgp fast-external-failover" commands */
16551 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
16552 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
16554 /* "bgp bestpath compare-routerid" commands */
16555 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
16556 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
16558 /* "bgp bestpath as-path ignore" commands */
16559 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
16560 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
16562 /* "bgp bestpath as-path confed" commands */
16563 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
16564 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
16566 /* "bgp bestpath as-path multipath-relax" commands */
16567 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
16568 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
16570 /* "bgp log-neighbor-changes" commands */
16571 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
16572 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
16574 /* "bgp bestpath med" commands */
16575 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
16576 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
16578 /* "bgp bestpath bandwidth" commands */
16579 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
16580 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
16582 /* "no bgp default ipv4-unicast" commands. */
16583 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
16584 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
16586 /* "bgp network import-check" commands. */
16587 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
16588 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
16589 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
16591 /* "bgp default local-preference" commands. */
16592 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
16593 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
16595 /* bgp default show-hostname */
16596 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
16597 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
16599 /* bgp default show-nexthop-hostname */
16600 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
16601 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
16603 /* "bgp default subgroup-pkt-queue-max" commands. */
16604 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
16605 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
16607 /* bgp ibgp-allow-policy-mods command */
16608 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
16609 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
16611 /* "bgp listen limit" commands. */
16612 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
16613 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
16615 /* "bgp listen range" commands. */
16616 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
16617 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
16619 /* "bgp default shutdown" command */
16620 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
16622 /* "bgp shutdown" commands */
16623 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
16624 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
16625 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
16626 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
16628 /* "neighbor remote-as" commands. */
16629 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
16630 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
16631 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
16632 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
16633 install_element(BGP_NODE
,
16634 &neighbor_interface_v6only_config_remote_as_cmd
);
16635 install_element(BGP_NODE
, &no_neighbor_cmd
);
16636 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
16638 /* "neighbor peer-group" commands. */
16639 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
16640 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
16641 install_element(BGP_NODE
,
16642 &no_neighbor_interface_peer_group_remote_as_cmd
);
16644 /* "neighbor local-as" commands. */
16645 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
16646 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
16647 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
16648 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
16650 /* "neighbor solo" commands. */
16651 install_element(BGP_NODE
, &neighbor_solo_cmd
);
16652 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
16654 /* "neighbor password" commands. */
16655 install_element(BGP_NODE
, &neighbor_password_cmd
);
16656 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
16658 /* "neighbor activate" commands. */
16659 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
16660 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
16661 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
16662 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
16663 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
16664 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
16665 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
16666 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
16667 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
16668 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
16669 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
16670 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
16672 /* "no neighbor activate" commands. */
16673 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
16674 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
16675 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
16676 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
16677 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
16678 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
16679 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
16680 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
16681 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
16682 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
16683 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
16684 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
16686 /* "neighbor peer-group" set commands. */
16687 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
16688 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
16689 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
16690 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
16691 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
16692 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
16693 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
16694 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
16695 install_element(BGP_FLOWSPECV4_NODE
,
16696 &neighbor_set_peer_group_hidden_cmd
);
16697 install_element(BGP_FLOWSPECV6_NODE
,
16698 &neighbor_set_peer_group_hidden_cmd
);
16700 /* "no neighbor peer-group unset" commands. */
16701 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
16702 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
16703 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
16704 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
16705 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
16706 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
16707 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
16708 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
16709 install_element(BGP_FLOWSPECV4_NODE
,
16710 &no_neighbor_set_peer_group_hidden_cmd
);
16711 install_element(BGP_FLOWSPECV6_NODE
,
16712 &no_neighbor_set_peer_group_hidden_cmd
);
16714 /* "neighbor softreconfiguration inbound" commands.*/
16715 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
16716 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
16717 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
16718 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
16719 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
16720 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
16721 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
16722 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
16723 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
16724 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
16725 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
16726 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
16727 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
16728 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
16729 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
16730 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
16731 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
16732 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
16733 install_element(BGP_FLOWSPECV4_NODE
,
16734 &neighbor_soft_reconfiguration_cmd
);
16735 install_element(BGP_FLOWSPECV4_NODE
,
16736 &no_neighbor_soft_reconfiguration_cmd
);
16737 install_element(BGP_FLOWSPECV6_NODE
,
16738 &neighbor_soft_reconfiguration_cmd
);
16739 install_element(BGP_FLOWSPECV6_NODE
,
16740 &no_neighbor_soft_reconfiguration_cmd
);
16741 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
16742 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
16744 /* "neighbor attribute-unchanged" commands. */
16745 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
16746 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
16747 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
16748 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
16749 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
16750 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
16751 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
16752 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
16753 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
16754 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
16755 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
16756 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
16757 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
16758 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
16759 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
16760 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
16761 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
16762 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
16764 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
16765 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
16767 /* "nexthop-local unchanged" commands */
16768 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
16769 install_element(BGP_IPV6_NODE
,
16770 &no_neighbor_nexthop_local_unchanged_cmd
);
16772 /* "neighbor next-hop-self" commands. */
16773 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
16774 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
16775 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
16776 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
16777 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
16778 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
16779 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
16780 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
16781 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
16782 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
16783 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
16784 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
16785 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
16786 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
16787 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
16788 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
16789 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
16790 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
16791 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
16792 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
16794 /* "neighbor next-hop-self force" commands. */
16795 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
16796 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
16797 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
16798 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
16799 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
16800 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
16801 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
16802 install_element(BGP_IPV4_NODE
,
16803 &no_neighbor_nexthop_self_all_hidden_cmd
);
16804 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
16805 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
16806 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
16807 install_element(BGP_IPV4M_NODE
,
16808 &no_neighbor_nexthop_self_all_hidden_cmd
);
16809 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
16810 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
16811 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
16812 install_element(BGP_IPV4L_NODE
,
16813 &no_neighbor_nexthop_self_all_hidden_cmd
);
16814 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
16815 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
16816 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
16817 install_element(BGP_IPV6_NODE
,
16818 &no_neighbor_nexthop_self_all_hidden_cmd
);
16819 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
16820 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
16821 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
16822 install_element(BGP_IPV6M_NODE
,
16823 &no_neighbor_nexthop_self_all_hidden_cmd
);
16824 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
16825 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
16826 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
16827 install_element(BGP_IPV6L_NODE
,
16828 &no_neighbor_nexthop_self_all_hidden_cmd
);
16829 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
16830 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
16831 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
16832 install_element(BGP_VPNV4_NODE
,
16833 &no_neighbor_nexthop_self_all_hidden_cmd
);
16834 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
16835 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
16836 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
16837 install_element(BGP_VPNV6_NODE
,
16838 &no_neighbor_nexthop_self_all_hidden_cmd
);
16839 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
16840 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
16842 /* "neighbor as-override" commands. */
16843 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
16844 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
16845 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
16846 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
16847 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
16848 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
16849 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
16850 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
16851 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
16852 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
16853 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
16854 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
16855 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
16856 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
16857 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
16858 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
16859 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
16860 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
16862 /* "neighbor remove-private-AS" commands. */
16863 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
16864 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
16865 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
16866 install_element(BGP_NODE
,
16867 &no_neighbor_remove_private_as_all_hidden_cmd
);
16868 install_element(BGP_NODE
,
16869 &neighbor_remove_private_as_replace_as_hidden_cmd
);
16870 install_element(BGP_NODE
,
16871 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
16872 install_element(BGP_NODE
,
16873 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
16876 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
16877 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
16878 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
16879 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
16880 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
16881 install_element(BGP_IPV4_NODE
,
16882 &neighbor_remove_private_as_replace_as_cmd
);
16883 install_element(BGP_IPV4_NODE
,
16884 &no_neighbor_remove_private_as_replace_as_cmd
);
16885 install_element(BGP_IPV4_NODE
,
16886 &neighbor_remove_private_as_all_replace_as_cmd
);
16887 install_element(BGP_IPV4_NODE
,
16888 &no_neighbor_remove_private_as_all_replace_as_cmd
);
16889 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
16890 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
16891 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
16892 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
16893 install_element(BGP_IPV4M_NODE
,
16894 &neighbor_remove_private_as_replace_as_cmd
);
16895 install_element(BGP_IPV4M_NODE
,
16896 &no_neighbor_remove_private_as_replace_as_cmd
);
16897 install_element(BGP_IPV4M_NODE
,
16898 &neighbor_remove_private_as_all_replace_as_cmd
);
16899 install_element(BGP_IPV4M_NODE
,
16900 &no_neighbor_remove_private_as_all_replace_as_cmd
);
16901 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
16902 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
16903 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
16904 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
16905 install_element(BGP_IPV4L_NODE
,
16906 &neighbor_remove_private_as_replace_as_cmd
);
16907 install_element(BGP_IPV4L_NODE
,
16908 &no_neighbor_remove_private_as_replace_as_cmd
);
16909 install_element(BGP_IPV4L_NODE
,
16910 &neighbor_remove_private_as_all_replace_as_cmd
);
16911 install_element(BGP_IPV4L_NODE
,
16912 &no_neighbor_remove_private_as_all_replace_as_cmd
);
16913 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
16914 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
16915 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
16916 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
16917 install_element(BGP_IPV6_NODE
,
16918 &neighbor_remove_private_as_replace_as_cmd
);
16919 install_element(BGP_IPV6_NODE
,
16920 &no_neighbor_remove_private_as_replace_as_cmd
);
16921 install_element(BGP_IPV6_NODE
,
16922 &neighbor_remove_private_as_all_replace_as_cmd
);
16923 install_element(BGP_IPV6_NODE
,
16924 &no_neighbor_remove_private_as_all_replace_as_cmd
);
16925 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
16926 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
16927 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
16928 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
16929 install_element(BGP_IPV6M_NODE
,
16930 &neighbor_remove_private_as_replace_as_cmd
);
16931 install_element(BGP_IPV6M_NODE
,
16932 &no_neighbor_remove_private_as_replace_as_cmd
);
16933 install_element(BGP_IPV6M_NODE
,
16934 &neighbor_remove_private_as_all_replace_as_cmd
);
16935 install_element(BGP_IPV6M_NODE
,
16936 &no_neighbor_remove_private_as_all_replace_as_cmd
);
16937 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
16938 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
16939 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
16940 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
16941 install_element(BGP_IPV6L_NODE
,
16942 &neighbor_remove_private_as_replace_as_cmd
);
16943 install_element(BGP_IPV6L_NODE
,
16944 &no_neighbor_remove_private_as_replace_as_cmd
);
16945 install_element(BGP_IPV6L_NODE
,
16946 &neighbor_remove_private_as_all_replace_as_cmd
);
16947 install_element(BGP_IPV6L_NODE
,
16948 &no_neighbor_remove_private_as_all_replace_as_cmd
);
16949 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
16950 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
16951 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
16952 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
16953 install_element(BGP_VPNV4_NODE
,
16954 &neighbor_remove_private_as_replace_as_cmd
);
16955 install_element(BGP_VPNV4_NODE
,
16956 &no_neighbor_remove_private_as_replace_as_cmd
);
16957 install_element(BGP_VPNV4_NODE
,
16958 &neighbor_remove_private_as_all_replace_as_cmd
);
16959 install_element(BGP_VPNV4_NODE
,
16960 &no_neighbor_remove_private_as_all_replace_as_cmd
);
16961 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
16962 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
16963 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
16964 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
16965 install_element(BGP_VPNV6_NODE
,
16966 &neighbor_remove_private_as_replace_as_cmd
);
16967 install_element(BGP_VPNV6_NODE
,
16968 &no_neighbor_remove_private_as_replace_as_cmd
);
16969 install_element(BGP_VPNV6_NODE
,
16970 &neighbor_remove_private_as_all_replace_as_cmd
);
16971 install_element(BGP_VPNV6_NODE
,
16972 &no_neighbor_remove_private_as_all_replace_as_cmd
);
16974 /* "neighbor send-community" commands.*/
16975 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
16976 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
16977 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
16978 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
16979 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
16980 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
16981 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
16982 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
16983 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
16984 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
16985 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
16986 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
16987 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
16988 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
16989 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
16990 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
16991 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
16992 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
16993 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
16994 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
16995 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
16996 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
16997 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
16998 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
16999 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
17000 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
17001 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
17002 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
17003 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
17004 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
17005 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
17006 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
17007 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
17008 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
17009 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
17010 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
17012 /* "neighbor route-reflector" commands.*/
17013 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
17014 install_element(BGP_NODE
,
17015 &no_neighbor_route_reflector_client_hidden_cmd
);
17016 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
17017 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
17018 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
17019 install_element(BGP_IPV4M_NODE
,
17020 &no_neighbor_route_reflector_client_cmd
);
17021 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
17022 install_element(BGP_IPV4L_NODE
,
17023 &no_neighbor_route_reflector_client_cmd
);
17024 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
17025 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
17026 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
17027 install_element(BGP_IPV6M_NODE
,
17028 &no_neighbor_route_reflector_client_cmd
);
17029 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
17030 install_element(BGP_IPV6L_NODE
,
17031 &no_neighbor_route_reflector_client_cmd
);
17032 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
17033 install_element(BGP_VPNV4_NODE
,
17034 &no_neighbor_route_reflector_client_cmd
);
17035 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
17036 install_element(BGP_VPNV6_NODE
,
17037 &no_neighbor_route_reflector_client_cmd
);
17038 install_element(BGP_FLOWSPECV4_NODE
,
17039 &neighbor_route_reflector_client_cmd
);
17040 install_element(BGP_FLOWSPECV4_NODE
,
17041 &no_neighbor_route_reflector_client_cmd
);
17042 install_element(BGP_FLOWSPECV6_NODE
,
17043 &neighbor_route_reflector_client_cmd
);
17044 install_element(BGP_FLOWSPECV6_NODE
,
17045 &no_neighbor_route_reflector_client_cmd
);
17046 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
17047 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
17049 /* "neighbor route-server" commands.*/
17050 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
17051 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
17052 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
17053 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
17054 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
17055 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
17056 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
17057 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
17058 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
17059 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
17060 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
17061 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
17062 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
17063 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
17064 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
17065 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
17066 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
17067 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
17068 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
17069 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
17070 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
17071 install_element(BGP_FLOWSPECV4_NODE
,
17072 &no_neighbor_route_server_client_cmd
);
17073 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
17074 install_element(BGP_FLOWSPECV6_NODE
,
17075 &no_neighbor_route_server_client_cmd
);
17077 /* "neighbor addpath-tx-all-paths" commands.*/
17078 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
17079 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
17080 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
17081 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
17082 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
17083 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
17084 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
17085 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
17086 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
17087 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
17088 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
17089 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
17090 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
17091 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
17092 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
17093 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
17094 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
17095 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
17097 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
17098 install_element(BGP_NODE
,
17099 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
17100 install_element(BGP_NODE
,
17101 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
17102 install_element(BGP_IPV4_NODE
,
17103 &neighbor_addpath_tx_bestpath_per_as_cmd
);
17104 install_element(BGP_IPV4_NODE
,
17105 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
17106 install_element(BGP_IPV4M_NODE
,
17107 &neighbor_addpath_tx_bestpath_per_as_cmd
);
17108 install_element(BGP_IPV4M_NODE
,
17109 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
17110 install_element(BGP_IPV4L_NODE
,
17111 &neighbor_addpath_tx_bestpath_per_as_cmd
);
17112 install_element(BGP_IPV4L_NODE
,
17113 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
17114 install_element(BGP_IPV6_NODE
,
17115 &neighbor_addpath_tx_bestpath_per_as_cmd
);
17116 install_element(BGP_IPV6_NODE
,
17117 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
17118 install_element(BGP_IPV6M_NODE
,
17119 &neighbor_addpath_tx_bestpath_per_as_cmd
);
17120 install_element(BGP_IPV6M_NODE
,
17121 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
17122 install_element(BGP_IPV6L_NODE
,
17123 &neighbor_addpath_tx_bestpath_per_as_cmd
);
17124 install_element(BGP_IPV6L_NODE
,
17125 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
17126 install_element(BGP_VPNV4_NODE
,
17127 &neighbor_addpath_tx_bestpath_per_as_cmd
);
17128 install_element(BGP_VPNV4_NODE
,
17129 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
17130 install_element(BGP_VPNV6_NODE
,
17131 &neighbor_addpath_tx_bestpath_per_as_cmd
);
17132 install_element(BGP_VPNV6_NODE
,
17133 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
17135 /* "neighbor sender-as-path-loop-detection" commands. */
17136 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
17137 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
17139 /* "neighbor passive" commands. */
17140 install_element(BGP_NODE
, &neighbor_passive_cmd
);
17141 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
17144 /* "neighbor shutdown" commands. */
17145 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
17146 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
17147 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
17148 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
17149 install_element(BGP_NODE
, &neighbor_shutdown_rtt_cmd
);
17150 install_element(BGP_NODE
, &no_neighbor_shutdown_rtt_cmd
);
17152 /* "neighbor capability extended-nexthop" commands.*/
17153 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
17154 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
17156 /* "neighbor capability orf prefix-list" commands.*/
17157 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
17158 install_element(BGP_NODE
,
17159 &no_neighbor_capability_orf_prefix_hidden_cmd
);
17160 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
17161 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
17162 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
17163 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
17164 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
17165 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
17166 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
17167 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
17168 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
17169 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
17170 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
17171 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
17173 /* "neighbor capability dynamic" commands.*/
17174 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
17175 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
17177 /* "neighbor dont-capability-negotiate" commands. */
17178 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
17179 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
17181 /* "neighbor ebgp-multihop" commands. */
17182 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
17183 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
17184 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
17186 /* "neighbor disable-connected-check" commands. */
17187 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
17188 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
17190 /* "neighbor enforce-first-as" commands. */
17191 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
17192 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
17194 /* "neighbor description" commands. */
17195 install_element(BGP_NODE
, &neighbor_description_cmd
);
17196 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
17197 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
17199 /* "neighbor update-source" commands. "*/
17200 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
17201 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
17203 /* "neighbor default-originate" commands. */
17204 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
17205 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
17206 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
17207 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
17208 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
17209 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
17210 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
17211 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
17212 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
17213 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
17214 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
17215 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
17216 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
17217 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
17218 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
17219 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
17220 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
17221 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
17222 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
17223 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
17224 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
17226 /* "neighbor port" commands. */
17227 install_element(BGP_NODE
, &neighbor_port_cmd
);
17228 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
17230 /* "neighbor weight" commands. */
17231 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
17232 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
17234 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
17235 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
17236 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
17237 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
17238 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
17239 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
17240 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
17241 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
17242 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
17243 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
17244 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
17245 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
17246 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
17247 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
17248 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
17249 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
17251 /* "neighbor override-capability" commands. */
17252 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
17253 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
17255 /* "neighbor strict-capability-match" commands. */
17256 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
17257 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
17259 /* "neighbor timers" commands. */
17260 install_element(BGP_NODE
, &neighbor_timers_cmd
);
17261 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
17263 /* "neighbor timers connect" commands. */
17264 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
17265 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
17267 /* "neighbor advertisement-interval" commands. */
17268 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
17269 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
17271 /* "neighbor interface" commands. */
17272 install_element(BGP_NODE
, &neighbor_interface_cmd
);
17273 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
17275 /* "neighbor distribute" commands. */
17276 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
17277 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
17278 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
17279 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
17280 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
17281 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
17282 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
17283 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
17284 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
17285 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
17286 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
17287 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
17288 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
17289 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
17290 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
17291 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
17292 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
17293 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
17295 /* "neighbor prefix-list" commands. */
17296 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
17297 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
17298 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
17299 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
17300 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
17301 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
17302 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
17303 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
17304 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
17305 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
17306 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
17307 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
17308 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
17309 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
17310 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
17311 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
17312 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
17313 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
17314 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
17315 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
17316 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
17317 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
17319 /* "neighbor filter-list" commands. */
17320 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
17321 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
17322 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
17323 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
17324 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
17325 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
17326 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
17327 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
17328 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
17329 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
17330 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
17331 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
17332 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
17333 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
17334 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
17335 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
17336 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
17337 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
17338 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
17339 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
17340 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
17341 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
17343 /* "neighbor route-map" commands. */
17344 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
17345 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
17346 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
17347 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
17348 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
17349 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
17350 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
17351 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
17352 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
17353 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
17354 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
17355 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
17356 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
17357 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
17358 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
17359 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
17360 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
17361 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
17362 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
17363 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
17364 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
17365 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
17366 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
17367 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
17369 /* "neighbor unsuppress-map" commands. */
17370 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
17371 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
17372 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
17373 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
17374 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
17375 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
17376 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
17377 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
17378 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
17379 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
17380 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
17381 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
17382 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
17383 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
17384 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
17385 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
17386 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
17387 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
17389 /* neighbor maximum-prefix-out commands. */
17390 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
17391 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
17392 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
17393 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
17394 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
17395 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
17396 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
17397 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
17398 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
17399 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
17400 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
17401 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
17402 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
17403 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
17404 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
17405 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
17406 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
17407 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
17409 /* "neighbor maximum-prefix" commands. */
17410 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
17411 install_element(BGP_NODE
,
17412 &neighbor_maximum_prefix_threshold_hidden_cmd
);
17413 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
17414 install_element(BGP_NODE
,
17415 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
17416 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
17417 install_element(BGP_NODE
,
17418 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
17419 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
17420 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
17421 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
17422 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
17423 install_element(BGP_IPV4_NODE
,
17424 &neighbor_maximum_prefix_threshold_warning_cmd
);
17425 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
17426 install_element(BGP_IPV4_NODE
,
17427 &neighbor_maximum_prefix_threshold_restart_cmd
);
17428 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
17429 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
17430 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
17431 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
17432 install_element(BGP_IPV4M_NODE
,
17433 &neighbor_maximum_prefix_threshold_warning_cmd
);
17434 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
17435 install_element(BGP_IPV4M_NODE
,
17436 &neighbor_maximum_prefix_threshold_restart_cmd
);
17437 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
17438 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
17439 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
17440 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
17441 install_element(BGP_IPV4L_NODE
,
17442 &neighbor_maximum_prefix_threshold_warning_cmd
);
17443 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
17444 install_element(BGP_IPV4L_NODE
,
17445 &neighbor_maximum_prefix_threshold_restart_cmd
);
17446 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
17447 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
17448 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
17449 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
17450 install_element(BGP_IPV6_NODE
,
17451 &neighbor_maximum_prefix_threshold_warning_cmd
);
17452 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
17453 install_element(BGP_IPV6_NODE
,
17454 &neighbor_maximum_prefix_threshold_restart_cmd
);
17455 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
17456 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
17457 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
17458 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
17459 install_element(BGP_IPV6M_NODE
,
17460 &neighbor_maximum_prefix_threshold_warning_cmd
);
17461 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
17462 install_element(BGP_IPV6M_NODE
,
17463 &neighbor_maximum_prefix_threshold_restart_cmd
);
17464 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
17465 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
17466 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
17467 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
17468 install_element(BGP_IPV6L_NODE
,
17469 &neighbor_maximum_prefix_threshold_warning_cmd
);
17470 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
17471 install_element(BGP_IPV6L_NODE
,
17472 &neighbor_maximum_prefix_threshold_restart_cmd
);
17473 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
17474 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
17475 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
17476 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
17477 install_element(BGP_VPNV4_NODE
,
17478 &neighbor_maximum_prefix_threshold_warning_cmd
);
17479 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
17480 install_element(BGP_VPNV4_NODE
,
17481 &neighbor_maximum_prefix_threshold_restart_cmd
);
17482 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
17483 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
17484 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
17485 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
17486 install_element(BGP_VPNV6_NODE
,
17487 &neighbor_maximum_prefix_threshold_warning_cmd
);
17488 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
17489 install_element(BGP_VPNV6_NODE
,
17490 &neighbor_maximum_prefix_threshold_restart_cmd
);
17491 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
17493 /* "neighbor allowas-in" */
17494 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
17495 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
17496 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
17497 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
17498 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
17499 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
17500 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
17501 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
17502 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
17503 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
17504 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
17505 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
17506 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
17507 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
17508 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
17509 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
17510 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
17511 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
17512 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
17513 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
17515 /* address-family commands. */
17516 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
17517 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
17518 #ifdef KEEP_OLD_VPN_COMMANDS
17519 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
17520 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
17521 #endif /* KEEP_OLD_VPN_COMMANDS */
17523 install_element(BGP_NODE
, &address_family_evpn_cmd
);
17525 /* "exit-address-family" command. */
17526 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
17527 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
17528 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
17529 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
17530 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
17531 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
17532 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
17533 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
17534 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
17535 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
17536 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
17538 /* "clear ip bgp commands" */
17539 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
17541 /* clear ip bgp prefix */
17542 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
17543 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
17544 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
17546 /* "show [ip] bgp summary" commands. */
17547 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
17548 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
17549 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
17550 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
17551 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
17552 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
17553 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
17555 /* "show [ip] bgp neighbors" commands. */
17556 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
17558 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
17560 /* "show [ip] bgp peer-group" commands. */
17561 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
17563 /* "show [ip] bgp paths" commands. */
17564 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
17566 /* "show [ip] bgp community" commands. */
17567 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
17569 /* "show ip bgp large-community" commands. */
17570 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
17571 /* "show [ip] bgp attribute-info" commands. */
17572 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
17573 /* "show [ip] bgp route-leak" command */
17574 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
17576 /* "redistribute" commands. */
17577 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
17578 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
17579 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
17580 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
17581 install_element(BGP_NODE
,
17582 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
17583 install_element(BGP_NODE
,
17584 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
17585 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
17586 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
17587 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
17588 install_element(BGP_NODE
,
17589 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
17590 install_element(BGP_NODE
,
17591 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
17592 install_element(BGP_NODE
,
17593 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
17594 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
17595 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
17596 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
17597 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
17598 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
17599 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
17600 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
17601 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
17602 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
17603 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
17604 install_element(BGP_IPV4_NODE
,
17605 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
17606 install_element(BGP_IPV4_NODE
,
17607 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
17608 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
17609 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
17610 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
17611 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
17612 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
17613 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
17615 /* import|export vpn [route-map WORD] */
17616 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
17617 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
17619 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
17620 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
17622 /* ttl_security commands */
17623 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
17624 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
17626 /* "show [ip] bgp memory" commands. */
17627 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
17629 /* "show bgp martian next-hop" */
17630 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
17632 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
17634 /* "show [ip] bgp views" commands. */
17635 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
17637 /* "show [ip] bgp vrfs" commands. */
17638 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
17640 /* Community-list. */
17641 community_list_vty();
17643 /* vpn-policy commands */
17644 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
17645 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
17646 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
17647 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
17648 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
17649 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
17650 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
17651 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
17652 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
17653 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
17654 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
17655 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
17657 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
17658 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
17660 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
17661 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
17662 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
17663 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
17664 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
17665 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
17666 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
17667 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
17668 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
17669 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
17672 #include "memory.h"
17673 #include "bgp_regex.h"
17674 #include "bgp_clist.h"
17675 #include "bgp_ecommunity.h"
17677 /* VTY functions. */
17679 /* Direction value to string conversion. */
17680 static const char *community_direct_str(int direct
)
17683 case COMMUNITY_DENY
:
17685 case COMMUNITY_PERMIT
:
17692 /* Display error string. */
17693 static void community_list_perror(struct vty
*vty
, int ret
)
17696 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
17697 vty_out(vty
, "%% Can't find community-list\n");
17699 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
17700 vty_out(vty
, "%% Malformed community-list value\n");
17702 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
17704 "%% Community name conflict, previously defined as standard community\n");
17706 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
17708 "%% Community name conflict, previously defined as expanded community\n");
17713 /* "community-list" keyword help string. */
17714 #define COMMUNITY_LIST_STR "Add a community list entry\n"
17716 /*community-list standard */
17717 DEFUN (community_list_standard
,
17718 bgp_community_list_standard_cmd
,
17719 "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
17722 "Community list number (standard)\n"
17723 "Add an standard community-list entry\n"
17724 "Community list name\n"
17725 "Sequence number of an entry\n"
17726 "Sequence number\n"
17727 "Specify community to reject\n"
17728 "Specify community to accept\n"
17731 char *cl_name_or_number
= NULL
;
17734 int style
= COMMUNITY_LIST_STANDARD
;
17737 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
17739 seq
= argv
[idx
]->arg
;
17742 argv_find(argv
, argc
, "(1-99)", &idx
);
17743 argv_find(argv
, argc
, "WORD", &idx
);
17744 cl_name_or_number
= argv
[idx
]->arg
;
17745 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
17747 argv_find(argv
, argc
, "AA:NN", &idx
);
17748 char *str
= argv_concat(argv
, argc
, idx
);
17750 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
17753 XFREE(MTYPE_TMP
, str
);
17756 /* Display error string. */
17757 community_list_perror(vty
, ret
);
17758 return CMD_WARNING_CONFIG_FAILED
;
17761 return CMD_SUCCESS
;
17764 DEFUN (no_community_list_standard_all
,
17765 no_bgp_community_list_standard_all_cmd
,
17766 "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
17770 "Community list number (standard)\n"
17771 "Add an standard community-list entry\n"
17772 "Community list name\n"
17773 "Sequence number of an entry\n"
17774 "Sequence number\n"
17775 "Specify community to reject\n"
17776 "Specify community to accept\n"
17779 char *cl_name_or_number
= NULL
;
17782 int style
= COMMUNITY_LIST_STANDARD
;
17786 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
17788 seq
= argv
[idx
]->arg
;
17791 argv_find(argv
, argc
, "permit", &idx
);
17792 argv_find(argv
, argc
, "deny", &idx
);
17795 direct
= argv_find(argv
, argc
, "permit", &idx
)
17800 argv_find(argv
, argc
, "AA:NN", &idx
);
17801 str
= argv_concat(argv
, argc
, idx
);
17805 argv_find(argv
, argc
, "(1-99)", &idx
);
17806 argv_find(argv
, argc
, "WORD", &idx
);
17807 cl_name_or_number
= argv
[idx
]->arg
;
17809 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
17812 XFREE(MTYPE_TMP
, str
);
17815 community_list_perror(vty
, ret
);
17816 return CMD_WARNING_CONFIG_FAILED
;
17819 return CMD_SUCCESS
;
17822 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
17823 "no bgp community-list <(1-99)|standard WORD>",
17824 NO_STR BGP_STR COMMUNITY_LIST_STR
17825 "Community list number (standard)\n"
17826 "Add an standard community-list entry\n"
17827 "Community list name\n")
17829 /*community-list expanded */
17830 DEFUN (community_list_expanded_all
,
17831 bgp_community_list_expanded_all_cmd
,
17832 "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
17835 "Community list number (expanded)\n"
17836 "Add an expanded community-list entry\n"
17837 "Community list name\n"
17838 "Sequence number of an entry\n"
17839 "Sequence number\n"
17840 "Specify community to reject\n"
17841 "Specify community to accept\n"
17844 char *cl_name_or_number
= NULL
;
17847 int style
= COMMUNITY_LIST_EXPANDED
;
17850 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
17852 seq
= argv
[idx
]->arg
;
17856 argv_find(argv
, argc
, "(100-500)", &idx
);
17857 argv_find(argv
, argc
, "WORD", &idx
);
17858 cl_name_or_number
= argv
[idx
]->arg
;
17859 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
17861 argv_find(argv
, argc
, "AA:NN", &idx
);
17862 char *str
= argv_concat(argv
, argc
, idx
);
17864 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
17867 XFREE(MTYPE_TMP
, str
);
17870 /* Display error string. */
17871 community_list_perror(vty
, ret
);
17872 return CMD_WARNING_CONFIG_FAILED
;
17875 return CMD_SUCCESS
;
17878 DEFUN (no_community_list_expanded_all
,
17879 no_bgp_community_list_expanded_all_cmd
,
17880 "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
17884 "Community list number (expanded)\n"
17885 "Add an expanded community-list entry\n"
17886 "Community list name\n"
17887 "Sequence number of an entry\n"
17888 "Sequence number\n"
17889 "Specify community to reject\n"
17890 "Specify community to accept\n"
17893 char *cl_name_or_number
= NULL
;
17897 int style
= COMMUNITY_LIST_EXPANDED
;
17900 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
17902 seq
= argv
[idx
]->arg
;
17905 argv_find(argv
, argc
, "permit", &idx
);
17906 argv_find(argv
, argc
, "deny", &idx
);
17909 direct
= argv_find(argv
, argc
, "permit", &idx
)
17914 argv_find(argv
, argc
, "AA:NN", &idx
);
17915 str
= argv_concat(argv
, argc
, idx
);
17919 argv_find(argv
, argc
, "(100-500)", &idx
);
17920 argv_find(argv
, argc
, "WORD", &idx
);
17921 cl_name_or_number
= argv
[idx
]->arg
;
17923 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
17926 XFREE(MTYPE_TMP
, str
);
17929 community_list_perror(vty
, ret
);
17930 return CMD_WARNING_CONFIG_FAILED
;
17933 return CMD_SUCCESS
;
17936 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
17937 "no bgp community-list <(100-500)|expanded WORD>",
17938 NO_STR IP_STR COMMUNITY_LIST_STR
17939 "Community list number (expanded)\n"
17940 "Add an expanded community-list entry\n"
17941 "Community list name\n")
17943 /* Return configuration string of community-list entry. */
17944 static const char *community_list_config_str(struct community_entry
*entry
)
17951 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
17952 str
= community_str(entry
->u
.com
, false);
17953 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
17954 str
= lcommunity_str(entry
->u
.lcom
, false);
17956 str
= entry
->config
;
17961 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
17963 struct community_entry
*entry
;
17965 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
17966 if (entry
== list
->head
) {
17967 if (all_digit(list
->name
))
17968 vty_out(vty
, "Community %s list %s\n",
17969 entry
->style
== COMMUNITY_LIST_STANDARD
17971 : "(expanded) access",
17974 vty_out(vty
, "Named Community %s list %s\n",
17975 entry
->style
== COMMUNITY_LIST_STANDARD
17981 vty_out(vty
, " %s\n",
17982 community_direct_str(entry
->direct
));
17984 vty_out(vty
, " %s %s\n",
17985 community_direct_str(entry
->direct
),
17986 community_list_config_str(entry
));
17990 DEFUN (show_community_list
,
17991 show_bgp_community_list_cmd
,
17992 "show bgp community-list",
17995 "List community-list\n")
17997 struct community_list
*list
;
17998 struct community_list_master
*cm
;
18000 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
18002 return CMD_SUCCESS
;
18004 for (list
= cm
->num
.head
; list
; list
= list
->next
)
18005 community_list_show(vty
, list
);
18007 for (list
= cm
->str
.head
; list
; list
= list
->next
)
18008 community_list_show(vty
, list
);
18010 return CMD_SUCCESS
;
18013 DEFUN (show_community_list_arg
,
18014 show_bgp_community_list_arg_cmd
,
18015 "show bgp community-list <(1-500)|WORD> detail",
18018 "List community-list\n"
18019 "Community-list number\n"
18020 "Community-list name\n"
18021 "Detailed information on community-list\n")
18023 int idx_comm_list
= 3;
18024 struct community_list
*list
;
18026 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
18027 COMMUNITY_LIST_MASTER
);
18029 vty_out(vty
, "%% Can't find community-list\n");
18030 return CMD_WARNING
;
18033 community_list_show(vty
, list
);
18035 return CMD_SUCCESS
;
18039 * Large Community code.
18041 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
18042 struct cmd_token
**argv
, int style
,
18043 int reject_all_digit_name
)
18052 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
18053 seq
= argv
[idx
]->arg
;
18056 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
18059 /* All digit name check. */
18061 argv_find(argv
, argc
, "WORD", &idx
);
18062 argv_find(argv
, argc
, "(1-99)", &idx
);
18063 argv_find(argv
, argc
, "(100-500)", &idx
);
18064 cl_name
= argv
[idx
]->arg
;
18065 if (reject_all_digit_name
&& all_digit(cl_name
)) {
18066 vty_out(vty
, "%% Community name cannot have all digits\n");
18067 return CMD_WARNING_CONFIG_FAILED
;
18071 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
18072 argv_find(argv
, argc
, "LINE", &idx
);
18073 /* Concat community string argument. */
18075 str
= argv_concat(argv
, argc
, idx
);
18079 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
18081 /* Free temporary community list string allocated by
18083 XFREE(MTYPE_TMP
, str
);
18086 community_list_perror(vty
, ret
);
18087 return CMD_WARNING_CONFIG_FAILED
;
18089 return CMD_SUCCESS
;
18092 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
18093 struct cmd_token
**argv
, int style
)
18101 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
18102 seq
= argv
[idx
]->arg
;
18105 argv_find(argv
, argc
, "permit", &idx
);
18106 argv_find(argv
, argc
, "deny", &idx
);
18109 /* Check the list direct. */
18110 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
18111 direct
= COMMUNITY_PERMIT
;
18113 direct
= COMMUNITY_DENY
;
18116 argv_find(argv
, argc
, "LINE", &idx
);
18117 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
18118 /* Concat community string argument. */
18119 str
= argv_concat(argv
, argc
, idx
);
18123 argv_find(argv
, argc
, "(1-99)", &idx
);
18124 argv_find(argv
, argc
, "(100-500)", &idx
);
18125 argv_find(argv
, argc
, "WORD", &idx
);
18127 /* Unset community list. */
18128 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
18131 /* Free temporary community list string allocated by
18133 XFREE(MTYPE_TMP
, str
);
18136 community_list_perror(vty
, ret
);
18137 return CMD_WARNING_CONFIG_FAILED
;
18140 return CMD_SUCCESS
;
18143 /* "large-community-list" keyword help string. */
18144 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
18145 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
18147 DEFUN (lcommunity_list_standard
,
18148 bgp_lcommunity_list_standard_cmd
,
18149 "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...",
18151 LCOMMUNITY_LIST_STR
18152 "Large Community list number (standard)\n"
18153 "Sequence number of an entry\n"
18154 "Sequence number\n"
18155 "Specify large community to reject\n"
18156 "Specify large community to accept\n"
18157 LCOMMUNITY_VAL_STR
)
18159 return lcommunity_list_set_vty(vty
, argc
, argv
,
18160 LARGE_COMMUNITY_LIST_STANDARD
, 0);
18163 DEFUN (lcommunity_list_expanded
,
18164 bgp_lcommunity_list_expanded_cmd
,
18165 "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...",
18167 LCOMMUNITY_LIST_STR
18168 "Large Community list number (expanded)\n"
18169 "Sequence number of an entry\n"
18170 "Sequence number\n"
18171 "Specify large community to reject\n"
18172 "Specify large community to accept\n"
18173 "An ordered list as a regular-expression\n")
18175 return lcommunity_list_set_vty(vty
, argc
, argv
,
18176 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
18179 DEFUN (lcommunity_list_name_standard
,
18180 bgp_lcommunity_list_name_standard_cmd
,
18181 "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...",
18183 LCOMMUNITY_LIST_STR
18184 "Specify standard large-community-list\n"
18185 "Large Community list name\n"
18186 "Sequence number of an entry\n"
18187 "Sequence number\n"
18188 "Specify large community to reject\n"
18189 "Specify large community to accept\n"
18190 LCOMMUNITY_VAL_STR
)
18192 return lcommunity_list_set_vty(vty
, argc
, argv
,
18193 LARGE_COMMUNITY_LIST_STANDARD
, 1);
18196 DEFUN (lcommunity_list_name_expanded
,
18197 bgp_lcommunity_list_name_expanded_cmd
,
18198 "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...",
18200 LCOMMUNITY_LIST_STR
18201 "Specify expanded large-community-list\n"
18202 "Large Community list name\n"
18203 "Sequence number of an entry\n"
18204 "Sequence number\n"
18205 "Specify large community to reject\n"
18206 "Specify large community to accept\n"
18207 "An ordered list as a regular-expression\n")
18209 return lcommunity_list_set_vty(vty
, argc
, argv
,
18210 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
18213 DEFUN (no_lcommunity_list_all
,
18214 no_bgp_lcommunity_list_all_cmd
,
18215 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
18218 LCOMMUNITY_LIST_STR
18219 "Large Community list number (standard)\n"
18220 "Large Community list number (expanded)\n"
18221 "Large Community list name\n")
18223 return lcommunity_list_unset_vty(vty
, argc
, argv
,
18224 LARGE_COMMUNITY_LIST_STANDARD
);
18227 DEFUN (no_lcommunity_list_name_standard_all
,
18228 no_bgp_lcommunity_list_name_standard_all_cmd
,
18229 "no bgp large-community-list standard WORD",
18232 LCOMMUNITY_LIST_STR
18233 "Specify standard large-community-list\n"
18234 "Large Community list name\n")
18236 return lcommunity_list_unset_vty(vty
, argc
, argv
,
18237 LARGE_COMMUNITY_LIST_STANDARD
);
18240 DEFUN (no_lcommunity_list_name_expanded_all
,
18241 no_bgp_lcommunity_list_name_expanded_all_cmd
,
18242 "no bgp large-community-list expanded WORD",
18245 LCOMMUNITY_LIST_STR
18246 "Specify expanded large-community-list\n"
18247 "Large Community list name\n")
18249 return lcommunity_list_unset_vty(vty
, argc
, argv
,
18250 LARGE_COMMUNITY_LIST_EXPANDED
);
18253 DEFUN (no_lcommunity_list_standard
,
18254 no_bgp_lcommunity_list_standard_cmd
,
18255 "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...",
18258 LCOMMUNITY_LIST_STR
18259 "Large Community list number (standard)\n"
18260 "Sequence number of an entry\n"
18261 "Sequence number\n"
18262 "Specify large community to reject\n"
18263 "Specify large community to accept\n"
18264 LCOMMUNITY_VAL_STR
)
18266 return lcommunity_list_unset_vty(vty
, argc
, argv
,
18267 LARGE_COMMUNITY_LIST_STANDARD
);
18270 DEFUN (no_lcommunity_list_expanded
,
18271 no_bgp_lcommunity_list_expanded_cmd
,
18272 "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...",
18275 LCOMMUNITY_LIST_STR
18276 "Large Community list number (expanded)\n"
18277 "Sequence number of an entry\n"
18278 "Sequence number\n"
18279 "Specify large community to reject\n"
18280 "Specify large community to accept\n"
18281 "An ordered list as a regular-expression\n")
18283 return lcommunity_list_unset_vty(vty
, argc
, argv
,
18284 LARGE_COMMUNITY_LIST_EXPANDED
);
18287 DEFUN (no_lcommunity_list_name_standard
,
18288 no_bgp_lcommunity_list_name_standard_cmd
,
18289 "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...",
18292 LCOMMUNITY_LIST_STR
18293 "Specify standard large-community-list\n"
18294 "Large Community list name\n"
18295 "Sequence number of an entry\n"
18296 "Sequence number\n"
18297 "Specify large community to reject\n"
18298 "Specify large community to accept\n"
18299 LCOMMUNITY_VAL_STR
)
18301 return lcommunity_list_unset_vty(vty
, argc
, argv
,
18302 LARGE_COMMUNITY_LIST_STANDARD
);
18305 DEFUN (no_lcommunity_list_name_expanded
,
18306 no_bgp_lcommunity_list_name_expanded_cmd
,
18307 "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...",
18310 LCOMMUNITY_LIST_STR
18311 "Specify expanded large-community-list\n"
18312 "Large community list name\n"
18313 "Sequence number of an entry\n"
18314 "Sequence number\n"
18315 "Specify large community to reject\n"
18316 "Specify large community to accept\n"
18317 "An ordered list as a regular-expression\n")
18319 return lcommunity_list_unset_vty(vty
, argc
, argv
,
18320 LARGE_COMMUNITY_LIST_EXPANDED
);
18323 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
18325 struct community_entry
*entry
;
18327 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
18328 if (entry
== list
->head
) {
18329 if (all_digit(list
->name
))
18330 vty_out(vty
, "Large community %s list %s\n",
18332 LARGE_COMMUNITY_LIST_STANDARD
18334 : "(expanded) access",
18338 "Named large community %s list %s\n",
18340 LARGE_COMMUNITY_LIST_STANDARD
18346 vty_out(vty
, " %s\n",
18347 community_direct_str(entry
->direct
));
18349 vty_out(vty
, " %s %s\n",
18350 community_direct_str(entry
->direct
),
18351 community_list_config_str(entry
));
18355 DEFUN (show_lcommunity_list
,
18356 show_bgp_lcommunity_list_cmd
,
18357 "show bgp large-community-list",
18360 "List large-community list\n")
18362 struct community_list
*list
;
18363 struct community_list_master
*cm
;
18365 cm
= community_list_master_lookup(bgp_clist
,
18366 LARGE_COMMUNITY_LIST_MASTER
);
18368 return CMD_SUCCESS
;
18370 for (list
= cm
->num
.head
; list
; list
= list
->next
)
18371 lcommunity_list_show(vty
, list
);
18373 for (list
= cm
->str
.head
; list
; list
= list
->next
)
18374 lcommunity_list_show(vty
, list
);
18376 return CMD_SUCCESS
;
18379 DEFUN (show_lcommunity_list_arg
,
18380 show_bgp_lcommunity_list_arg_cmd
,
18381 "show bgp large-community-list <(1-500)|WORD> detail",
18384 "List large-community list\n"
18385 "Large-community-list number\n"
18386 "Large-community-list name\n"
18387 "Detailed information on large-community-list\n")
18389 struct community_list
*list
;
18391 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
18392 LARGE_COMMUNITY_LIST_MASTER
);
18394 vty_out(vty
, "%% Can't find large-community-list\n");
18395 return CMD_WARNING
;
18398 lcommunity_list_show(vty
, list
);
18400 return CMD_SUCCESS
;
18403 /* "extcommunity-list" keyword help string. */
18404 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
18405 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
18407 DEFUN (extcommunity_list_standard
,
18408 bgp_extcommunity_list_standard_cmd
,
18409 "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
18411 EXTCOMMUNITY_LIST_STR
18412 "Extended Community list number (standard)\n"
18413 "Specify standard extcommunity-list\n"
18414 "Community list name\n"
18415 "Sequence number of an entry\n"
18416 "Sequence number\n"
18417 "Specify community to reject\n"
18418 "Specify community to accept\n"
18419 EXTCOMMUNITY_VAL_STR
)
18421 int style
= EXTCOMMUNITY_LIST_STANDARD
;
18423 char *cl_number_or_name
= NULL
;
18428 argv_find(argv
, argc
, "(1-99)", &idx
);
18429 argv_find(argv
, argc
, "WORD", &idx
);
18430 cl_number_or_name
= argv
[idx
]->arg
;
18432 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
18433 seq
= argv
[idx
]->arg
;
18435 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
18437 argv_find(argv
, argc
, "AA:NN", &idx
);
18438 char *str
= argv_concat(argv
, argc
, idx
);
18440 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
18443 XFREE(MTYPE_TMP
, str
);
18446 community_list_perror(vty
, ret
);
18447 return CMD_WARNING_CONFIG_FAILED
;
18450 return CMD_SUCCESS
;
18453 DEFUN (extcommunity_list_name_expanded
,
18454 bgp_extcommunity_list_name_expanded_cmd
,
18455 "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...",
18457 EXTCOMMUNITY_LIST_STR
18458 "Extended Community list number (expanded)\n"
18459 "Specify expanded extcommunity-list\n"
18460 "Extended Community list name\n"
18461 "Sequence number of an entry\n"
18462 "Sequence number\n"
18463 "Specify community to reject\n"
18464 "Specify community to accept\n"
18465 "An ordered list as a regular-expression\n")
18467 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
18469 char *cl_number_or_name
= NULL
;
18473 argv_find(argv
, argc
, "(100-500)", &idx
);
18474 argv_find(argv
, argc
, "WORD", &idx
);
18475 cl_number_or_name
= argv
[idx
]->arg
;
18477 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
18478 seq
= argv
[idx
]->arg
;
18480 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
18482 argv_find(argv
, argc
, "LINE", &idx
);
18483 char *str
= argv_concat(argv
, argc
, idx
);
18485 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
18488 XFREE(MTYPE_TMP
, str
);
18491 community_list_perror(vty
, ret
);
18492 return CMD_WARNING_CONFIG_FAILED
;
18495 return CMD_SUCCESS
;
18498 DEFUN (no_extcommunity_list_standard_all
,
18499 no_bgp_extcommunity_list_standard_all_cmd
,
18500 "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
18503 EXTCOMMUNITY_LIST_STR
18504 "Extended Community list number (standard)\n"
18505 "Specify standard extcommunity-list\n"
18506 "Community list name\n"
18507 "Sequence number of an entry\n"
18508 "Sequence number\n"
18509 "Specify community to reject\n"
18510 "Specify community to accept\n"
18511 EXTCOMMUNITY_VAL_STR
)
18513 int style
= EXTCOMMUNITY_LIST_STANDARD
;
18515 char *cl_number_or_name
= NULL
;
18520 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
18521 seq
= argv
[idx
]->arg
;
18524 argv_find(argv
, argc
, "permit", &idx
);
18525 argv_find(argv
, argc
, "deny", &idx
);
18527 direct
= argv_find(argv
, argc
, "permit", &idx
)
18532 argv_find(argv
, argc
, "AA:NN", &idx
);
18533 str
= argv_concat(argv
, argc
, idx
);
18537 argv_find(argv
, argc
, "(1-99)", &idx
);
18538 argv_find(argv
, argc
, "WORD", &idx
);
18539 cl_number_or_name
= argv
[idx
]->arg
;
18541 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
18542 seq
, direct
, style
);
18544 XFREE(MTYPE_TMP
, str
);
18547 community_list_perror(vty
, ret
);
18548 return CMD_WARNING_CONFIG_FAILED
;
18551 return CMD_SUCCESS
;
18554 ALIAS(no_extcommunity_list_standard_all
,
18555 no_bgp_extcommunity_list_standard_all_list_cmd
,
18556 "no bgp extcommunity-list <(1-99)|standard WORD>",
18557 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
18558 "Extended Community list number (standard)\n"
18559 "Specify standard extcommunity-list\n"
18560 "Community list name\n")
18562 DEFUN (no_extcommunity_list_expanded_all
,
18563 no_bgp_extcommunity_list_expanded_all_cmd
,
18564 "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...",
18567 EXTCOMMUNITY_LIST_STR
18568 "Extended Community list number (expanded)\n"
18569 "Specify expanded extcommunity-list\n"
18570 "Extended Community list name\n"
18571 "Sequence number of an entry\n"
18572 "Sequence number\n"
18573 "Specify community to reject\n"
18574 "Specify community to accept\n"
18575 "An ordered list as a regular-expression\n")
18577 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
18579 char *cl_number_or_name
= NULL
;
18584 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
18585 seq
= argv
[idx
]->arg
;
18588 argv_find(argv
, argc
, "permit", &idx
);
18589 argv_find(argv
, argc
, "deny", &idx
);
18592 direct
= argv_find(argv
, argc
, "permit", &idx
)
18597 argv_find(argv
, argc
, "LINE", &idx
);
18598 str
= argv_concat(argv
, argc
, idx
);
18602 argv_find(argv
, argc
, "(100-500)", &idx
);
18603 argv_find(argv
, argc
, "WORD", &idx
);
18604 cl_number_or_name
= argv
[idx
]->arg
;
18606 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
18607 seq
, direct
, style
);
18609 XFREE(MTYPE_TMP
, str
);
18612 community_list_perror(vty
, ret
);
18613 return CMD_WARNING_CONFIG_FAILED
;
18616 return CMD_SUCCESS
;
18619 ALIAS(no_extcommunity_list_expanded_all
,
18620 no_bgp_extcommunity_list_expanded_all_list_cmd
,
18621 "no bgp extcommunity-list <(100-500)|expanded WORD>",
18622 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
18623 "Extended Community list number (expanded)\n"
18624 "Specify expanded extcommunity-list\n"
18625 "Extended Community list name\n")
18627 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
18629 struct community_entry
*entry
;
18631 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
18632 if (entry
== list
->head
) {
18633 if (all_digit(list
->name
))
18634 vty_out(vty
, "Extended community %s list %s\n",
18635 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
18637 : "(expanded) access",
18641 "Named extended community %s list %s\n",
18642 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
18648 vty_out(vty
, " %s\n",
18649 community_direct_str(entry
->direct
));
18651 vty_out(vty
, " %s %s\n",
18652 community_direct_str(entry
->direct
),
18653 community_list_config_str(entry
));
18657 DEFUN (show_extcommunity_list
,
18658 show_bgp_extcommunity_list_cmd
,
18659 "show bgp extcommunity-list",
18662 "List extended-community list\n")
18664 struct community_list
*list
;
18665 struct community_list_master
*cm
;
18667 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
18669 return CMD_SUCCESS
;
18671 for (list
= cm
->num
.head
; list
; list
= list
->next
)
18672 extcommunity_list_show(vty
, list
);
18674 for (list
= cm
->str
.head
; list
; list
= list
->next
)
18675 extcommunity_list_show(vty
, list
);
18677 return CMD_SUCCESS
;
18680 DEFUN (show_extcommunity_list_arg
,
18681 show_bgp_extcommunity_list_arg_cmd
,
18682 "show bgp extcommunity-list <(1-500)|WORD> detail",
18685 "List extended-community list\n"
18686 "Extcommunity-list number\n"
18687 "Extcommunity-list name\n"
18688 "Detailed information on extcommunity-list\n")
18690 int idx_comm_list
= 3;
18691 struct community_list
*list
;
18693 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
18694 EXTCOMMUNITY_LIST_MASTER
);
18696 vty_out(vty
, "%% Can't find extcommunity-list\n");
18697 return CMD_WARNING
;
18700 extcommunity_list_show(vty
, list
);
18702 return CMD_SUCCESS
;
18705 /* Display community-list and extcommunity-list configuration. */
18706 static int community_list_config_write(struct vty
*vty
)
18708 struct community_list
*list
;
18709 struct community_entry
*entry
;
18710 struct community_list_master
*cm
;
18713 /* Community-list. */
18714 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
18716 for (list
= cm
->num
.head
; list
; list
= list
->next
)
18717 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
18719 "bgp community-list %s seq %" PRId64
" %s %s\n",
18720 list
->name
, entry
->seq
,
18721 community_direct_str(entry
->direct
),
18722 community_list_config_str(entry
));
18725 for (list
= cm
->str
.head
; list
; list
= list
->next
)
18726 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
18728 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
18729 entry
->style
== COMMUNITY_LIST_STANDARD
18732 list
->name
, entry
->seq
,
18733 community_direct_str(entry
->direct
),
18734 community_list_config_str(entry
));
18738 /* Extcommunity-list. */
18739 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
18741 for (list
= cm
->num
.head
; list
; list
= list
->next
)
18742 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
18744 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
18745 list
->name
, entry
->seq
,
18746 community_direct_str(entry
->direct
),
18747 community_list_config_str(entry
));
18750 for (list
= cm
->str
.head
; list
; list
= list
->next
)
18751 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
18753 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
18754 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
18757 list
->name
, entry
->seq
,
18758 community_direct_str(entry
->direct
),
18759 community_list_config_str(entry
));
18764 /* lcommunity-list. */
18765 cm
= community_list_master_lookup(bgp_clist
,
18766 LARGE_COMMUNITY_LIST_MASTER
);
18768 for (list
= cm
->num
.head
; list
; list
= list
->next
)
18769 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
18771 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
18772 list
->name
, entry
->seq
,
18773 community_direct_str(entry
->direct
),
18774 community_list_config_str(entry
));
18777 for (list
= cm
->str
.head
; list
; list
= list
->next
)
18778 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
18780 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
18782 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
18785 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
18786 community_list_config_str(entry
));
18793 static int community_list_config_write(struct vty
*vty
);
18794 static struct cmd_node community_list_node
= {
18795 .name
= "community list",
18796 .node
= COMMUNITY_LIST_NODE
,
18798 .config_write
= community_list_config_write
,
18801 static void community_list_vty(void)
18803 install_node(&community_list_node
);
18805 /* Community-list. */
18806 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
18807 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
18808 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
18809 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
18810 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
18811 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
18812 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
18813 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
18815 /* Extcommunity-list. */
18816 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
18817 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
18818 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
18819 install_element(CONFIG_NODE
,
18820 &no_bgp_extcommunity_list_standard_all_list_cmd
);
18821 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
18822 install_element(CONFIG_NODE
,
18823 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
18824 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
18825 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
18827 /* Large Community List */
18828 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
18829 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
18830 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
18831 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
18832 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
18833 install_element(CONFIG_NODE
,
18834 &no_bgp_lcommunity_list_name_standard_all_cmd
);
18835 install_element(CONFIG_NODE
,
18836 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
18837 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
18838 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
18839 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
18840 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
18841 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
18842 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);