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 FRR_CFG_DEFAULT_BOOL(BGP_IMPORT_CHECK
,
79 .match_profile
= "traditional",
80 .match_version
= "< 7.4",
84 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_HOSTNAME
,
85 { .val_bool
= true, .match_profile
= "datacenter", },
86 { .val_bool
= false },
88 FRR_CFG_DEFAULT_BOOL(BGP_SHOW_NEXTHOP_HOSTNAME
,
89 { .val_bool
= true, .match_profile
= "datacenter", },
90 { .val_bool
= false },
92 FRR_CFG_DEFAULT_BOOL(BGP_LOG_NEIGHBOR_CHANGES
,
93 { .val_bool
= true, .match_profile
= "datacenter", },
94 { .val_bool
= false },
96 FRR_CFG_DEFAULT_BOOL(BGP_DETERMINISTIC_MED
,
97 { .val_bool
= true, .match_profile
= "datacenter", },
98 { .val_bool
= false },
100 FRR_CFG_DEFAULT_ULONG(BGP_CONNECT_RETRY
,
101 { .val_ulong
= 10, .match_profile
= "datacenter", },
102 { .val_ulong
= 120 },
104 FRR_CFG_DEFAULT_ULONG(BGP_HOLDTIME
,
105 { .val_ulong
= 9, .match_profile
= "datacenter", },
106 { .val_ulong
= 180 },
108 FRR_CFG_DEFAULT_ULONG(BGP_KEEPALIVE
,
109 { .val_ulong
= 3, .match_profile
= "datacenter", },
112 FRR_CFG_DEFAULT_BOOL(BGP_EBGP_REQUIRES_POLICY
,
113 { .val_bool
= false, .match_profile
= "datacenter", },
114 { .val_bool
= false, .match_version
= "< 7.4", },
115 { .val_bool
= true },
118 DEFINE_HOOK(bgp_inst_config_write
,
119 (struct bgp
*bgp
, struct vty
*vty
),
123 "The Graceful Restart No Operation was executed as cmd same as previous one."
125 "The Graceful Restart command used is not valid at this moment."
126 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
127 struct prefix
*range
, int exact
);
129 /* Show BGP peer's information. */
139 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
140 struct prefix
*range
, int exact
);
142 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
147 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
150 afi_t afi
, bool use_json
);
152 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
158 return BGP_IPV4_NODE
;
160 return BGP_IPV4M_NODE
;
161 case SAFI_LABELED_UNICAST
:
162 return BGP_IPV4L_NODE
;
164 return BGP_VPNV4_NODE
;
166 return BGP_FLOWSPECV4_NODE
;
169 return BGP_IPV4_NODE
;
175 return BGP_IPV6_NODE
;
177 return BGP_IPV6M_NODE
;
178 case SAFI_LABELED_UNICAST
:
179 return BGP_IPV6L_NODE
;
181 return BGP_VPNV6_NODE
;
183 return BGP_FLOWSPECV6_NODE
;
186 return BGP_IPV4_NODE
;
190 return BGP_EVPN_NODE
;
193 // We should never be here but to clarify the switch statement..
194 return BGP_IPV4_NODE
;
197 // Impossible to happen
198 return BGP_IPV4_NODE
;
201 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
203 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
204 return "IPv4 Unicast";
205 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
206 return "IPv4 Multicast";
207 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
208 return "IPv4 Labeled Unicast";
209 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
211 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
213 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
214 return "IPv4 Flowspec";
215 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
216 return "IPv6 Unicast";
217 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
218 return "IPv6 Multicast";
219 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
220 return "IPv6 Labeled Unicast";
221 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
223 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
225 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
226 return "IPv6 Flowspec";
227 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
234 * Please note that we have intentionally camelCased
235 * the return strings here. So if you want
236 * to use this function, please ensure you
237 * are doing this within json output
239 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
241 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
242 return "ipv4Unicast";
243 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
244 return "ipv4Multicast";
245 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
246 return "ipv4LabeledUnicast";
247 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
249 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
251 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
252 return "ipv4Flowspec";
253 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
254 return "ipv6Unicast";
255 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
256 return "ipv6Multicast";
257 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
258 return "ipv6LabeledUnicast";
259 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
261 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
263 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
264 return "ipv6Flowspec";
265 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
271 /* Utility function to get address family from current node. */
272 afi_t
bgp_node_afi(struct vty
*vty
)
280 case BGP_FLOWSPECV6_NODE
:
293 /* Utility function to get subsequent address family from current
295 safi_t
bgp_node_safi(struct vty
*vty
)
301 safi
= SAFI_MPLS_VPN
;
305 safi
= SAFI_MULTICAST
;
312 safi
= SAFI_LABELED_UNICAST
;
314 case BGP_FLOWSPECV4_NODE
:
315 case BGP_FLOWSPECV6_NODE
:
316 safi
= SAFI_FLOWSPEC
;
326 * Converts an AFI in string form to afi_t
328 * @param afi string, one of
332 * @return the corresponding afi_t
334 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
336 afi_t afi
= AFI_MAX
; /* unknown */
337 if (strmatch(afi_str
, "ipv4"))
339 else if (strmatch(afi_str
, "ipv6"))
341 else if (strmatch(afi_str
, "l2vpn"))
346 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
350 if (argv_find(argv
, argc
, "ipv4", index
)) {
354 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
358 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
366 /* supports <unicast|multicast|vpn|labeled-unicast> */
367 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
369 safi_t safi
= SAFI_MAX
; /* unknown */
370 if (strmatch(safi_str
, "multicast"))
371 safi
= SAFI_MULTICAST
;
372 else if (strmatch(safi_str
, "unicast"))
374 else if (strmatch(safi_str
, "vpn"))
375 safi
= SAFI_MPLS_VPN
;
376 else if (strmatch(safi_str
, "evpn"))
378 else if (strmatch(safi_str
, "labeled-unicast"))
379 safi
= SAFI_LABELED_UNICAST
;
380 else if (strmatch(safi_str
, "flowspec"))
381 safi
= SAFI_FLOWSPEC
;
385 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
389 if (argv_find(argv
, argc
, "unicast", index
)) {
392 *safi
= SAFI_UNICAST
;
393 } else if (argv_find(argv
, argc
, "multicast", index
)) {
396 *safi
= SAFI_MULTICAST
;
397 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
400 *safi
= SAFI_LABELED_UNICAST
;
401 } else if (argv_find(argv
, argc
, "vpn", index
)) {
404 *safi
= SAFI_MPLS_VPN
;
405 } else if (argv_find(argv
, argc
, "evpn", index
)) {
409 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
412 *safi
= SAFI_FLOWSPEC
;
417 int bgp_get_vty(struct bgp
**bgp
, as_t
*as
, const char *name
,
418 enum bgp_instance_type inst_type
)
420 int ret
= bgp_get(bgp
, as
, name
, inst_type
);
422 if (ret
== BGP_CREATED
) {
423 bgp_timers_set(*bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
424 DFLT_BGP_CONNECT_RETRY
);
426 if (DFLT_BGP_IMPORT_CHECK
)
427 SET_FLAG((*bgp
)->flags
, BGP_FLAG_IMPORT_CHECK
);
428 if (DFLT_BGP_SHOW_HOSTNAME
)
429 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_HOSTNAME
);
430 if (DFLT_BGP_SHOW_NEXTHOP_HOSTNAME
)
431 SET_FLAG((*bgp
)->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
432 if (DFLT_BGP_LOG_NEIGHBOR_CHANGES
)
433 SET_FLAG((*bgp
)->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
434 if (DFLT_BGP_DETERMINISTIC_MED
)
435 SET_FLAG((*bgp
)->flags
, BGP_FLAG_DETERMINISTIC_MED
);
436 if (DFLT_BGP_EBGP_REQUIRES_POLICY
)
437 SET_FLAG((*bgp
)->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
445 * bgp_vty_find_and_parse_afi_safi_bgp
447 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
448 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
449 * to appropriate values for the calling function. This is to allow the
450 * calling function to make decisions appropriate for the show command
451 * that is being parsed.
453 * The show commands are generally of the form:
454 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
455 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
457 * Since we use argv_find if the show command in particular doesn't have:
459 * [<view|vrf> VIEWVRFNAME]
460 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
461 * The command parsing should still be ok.
463 * vty -> The vty for the command so we can output some useful data in
464 * the event of a parse error in the vrf.
465 * argv -> The command tokens
466 * argc -> How many command tokens we have
467 * idx -> The current place in the command, generally should be 0 for this
469 * afi -> The parsed afi if it was included in the show command, returned here
470 * safi -> The parsed safi if it was included in the show command, returned here
471 * bgp -> Pointer to the bgp data structure we need to fill in.
472 * use_json -> json is configured or not
474 * The function returns the correct location in the parse tree for the
477 * Returns 0 for failure to parse correctly, else the idx position of where
478 * it found the last token.
480 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
481 struct cmd_token
**argv
, int argc
,
482 int *idx
, afi_t
*afi
, safi_t
*safi
,
483 struct bgp
**bgp
, bool use_json
)
485 char *vrf_name
= NULL
;
491 if (argv_find(argv
, argc
, "ip", idx
))
494 if (argv_find(argv
, argc
, "view", idx
))
495 vrf_name
= argv
[*idx
+ 1]->arg
;
496 else if (argv_find(argv
, argc
, "vrf", idx
)) {
497 vrf_name
= argv
[*idx
+ 1]->arg
;
498 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
502 if (strmatch(vrf_name
, "all"))
505 *bgp
= bgp_lookup_by_name(vrf_name
);
508 json_object
*json
= NULL
;
509 json
= json_object_new_object();
510 json_object_string_add(
512 "View/Vrf is unknown");
514 json_object_to_json_string_ext(json
,
515 JSON_C_TO_STRING_PRETTY
));
516 json_object_free(json
);
519 vty_out(vty
, "View/Vrf %s is unknown\n",
526 *bgp
= bgp_get_default();
529 json_object
*json
= NULL
;
530 json
= json_object_new_object();
531 json_object_string_add(
533 "Default BGP instance not found");
535 json_object_to_json_string_ext(json
,
536 JSON_C_TO_STRING_PRETTY
));
537 json_object_free(json
);
541 "Default BGP instance not found\n");
547 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
548 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
554 static bool peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
556 struct interface
*ifp
= NULL
;
558 if (su
->sa
.sa_family
== AF_INET
)
559 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
560 else if (su
->sa
.sa_family
== AF_INET6
)
561 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
562 su
->sin6
.sin6_scope_id
,
571 /* Utility function for looking up peer from VTY. */
572 /* This is used only for configuration, so disallow if attempted on
573 * a dynamic neighbor.
575 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
577 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
586 ret
= str2sockunion(ip_str
, &su
);
588 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
590 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
593 "%% Malformed address or name: %s\n",
599 peer
= peer_lookup(bgp
, &su
);
602 "%% Specify remote-as or peer-group commands first\n");
605 if (peer_dynamic_neighbor(peer
)) {
607 "%% Operation not allowed on a dynamic neighbor\n");
614 /* Utility function for looking up peer or peer group. */
615 /* This is used only for configuration, so disallow if attempted on
616 * a dynamic neighbor.
618 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
620 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
623 struct peer
*peer
= NULL
;
624 struct peer_group
*group
= NULL
;
630 ret
= str2sockunion(peer_str
, &su
);
632 /* IP address, locate peer. */
633 peer
= peer_lookup(bgp
, &su
);
635 /* Not IP, could match either peer configured on interface or a
637 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
639 group
= peer_group_lookup(bgp
, peer_str
);
643 if (peer_dynamic_neighbor(peer
)) {
645 "%% Operation not allowed on a dynamic neighbor\n");
655 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
660 int bgp_vty_return(struct vty
*vty
, int ret
)
662 const char *str
= NULL
;
665 case BGP_ERR_INVALID_VALUE
:
666 str
= "Invalid value";
668 case BGP_ERR_INVALID_FLAG
:
669 str
= "Invalid flag";
671 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
672 str
= "Peer-group has been shutdown. Activate the peer-group first";
674 case BGP_ERR_PEER_FLAG_CONFLICT
:
675 str
= "Can't set override-capability and strict-capability-match at the same time";
677 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
678 str
= "Specify remote-as or peer-group remote AS first";
680 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
681 str
= "Cannot change the peer-group. Deconfigure first";
683 case BGP_ERR_PEER_GROUP_MISMATCH
:
684 str
= "Peer is not a member of this peer-group";
686 case BGP_ERR_PEER_FILTER_CONFLICT
:
687 str
= "Prefix/distribute list can not co-exist";
689 case BGP_ERR_NOT_INTERNAL_PEER
:
690 str
= "Invalid command. Not an internal neighbor";
692 case BGP_ERR_REMOVE_PRIVATE_AS
:
693 str
= "remove-private-AS cannot be configured for IBGP peers";
695 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
696 str
= "Local-AS allowed only for EBGP peers";
698 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
699 str
= "Cannot have local-as same as BGP AS number";
701 case BGP_ERR_TCPSIG_FAILED
:
702 str
= "Error while applying TCP-Sig to session(s)";
704 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
705 str
= "ebgp-multihop and ttl-security cannot be configured together";
707 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
708 str
= "ttl-security only allowed for EBGP peers";
710 case BGP_ERR_AS_OVERRIDE
:
711 str
= "as-override cannot be configured for IBGP peers";
713 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
714 str
= "Invalid limit for number of dynamic neighbors";
716 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
717 str
= "Dynamic neighbor listen range already exists";
719 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
720 str
= "Operation not allowed on a dynamic neighbor";
722 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
723 str
= "Operation not allowed on a directly connected neighbor";
725 case BGP_ERR_PEER_SAFI_CONFLICT
:
728 case BGP_ERR_GR_INVALID_CMD
:
729 str
= "The Graceful Restart command used is not valid at this moment.";
731 case BGP_ERR_GR_OPERATION_FAILED
:
732 str
= "The Graceful Restart Operation failed due to an err.";
734 case BGP_GR_NO_OPERATION
:
739 vty_out(vty
, "%% %s\n", str
);
740 return CMD_WARNING_CONFIG_FAILED
;
745 /* BGP clear sort. */
754 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
755 safi_t safi
, int error
)
758 case BGP_ERR_AF_UNCONFIGURED
:
760 "%%BGP: Enable %s address family for the neighbor %s\n",
761 get_afi_safi_str(afi
, safi
, false), peer
->host
);
763 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
765 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
773 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
774 struct listnode
**nnode
, enum bgp_clear_type stype
)
778 /* if afi/.safi not specified, spin thru all of them */
779 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
783 FOREACH_AFI_SAFI (tmp_afi
, tmp_safi
) {
784 if (!peer
->afc
[tmp_afi
][tmp_safi
])
787 if (stype
== BGP_CLEAR_SOFT_NONE
)
788 ret
= peer_clear(peer
, nnode
);
790 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
793 /* if afi specified and safi not, spin thru safis on this afi */
794 } else if (safi
== SAFI_UNSPEC
) {
797 for (tmp_safi
= SAFI_UNICAST
;
798 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
799 if (!peer
->afc
[afi
][tmp_safi
])
802 if (stype
== BGP_CLEAR_SOFT_NONE
)
803 ret
= peer_clear(peer
, nnode
);
805 ret
= peer_clear_soft(peer
, afi
,
808 /* both afi/safi specified, let the caller know if not defined */
810 if (!peer
->afc
[afi
][safi
])
813 if (stype
== BGP_CLEAR_SOFT_NONE
)
814 ret
= peer_clear(peer
, nnode
);
816 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
822 /* `clear ip bgp' functions. */
823 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
824 enum clear_sort sort
, enum bgp_clear_type stype
,
831 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
833 /* Clear all neighbors. */
835 * Pass along pointer to next node to peer_clear() when walking all
836 * nodes on the BGP instance as that may get freed if it is a
839 if (sort
== clear_all
) {
840 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
842 bgp_peer_gr_flags_update(peer
);
844 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
845 gr_router_detected
= true;
847 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
,
851 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
854 if (gr_router_detected
855 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
856 bgp_zebra_send_capabilities(bgp
, false);
857 } else if (!gr_router_detected
858 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
859 bgp_zebra_send_capabilities(bgp
, true);
862 /* This is to apply read-only mode on this clear. */
863 if (stype
== BGP_CLEAR_SOFT_NONE
)
864 bgp
->update_delay_over
= 0;
869 /* Clear specified neighbor. */
870 if (sort
== clear_peer
) {
873 /* Make sockunion for lookup. */
874 ret
= str2sockunion(arg
, &su
);
876 peer
= peer_lookup_by_conf_if(bgp
, arg
);
878 peer
= peer_lookup_by_hostname(bgp
, arg
);
881 "Malformed address or name: %s\n",
887 peer
= peer_lookup(bgp
, &su
);
890 "%%BGP: Unknown neighbor - \"%s\"\n",
896 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
897 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
899 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
901 /* if afi/safi not defined for this peer, let caller know */
903 ret
= BGP_ERR_AF_UNCONFIGURED
;
906 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
911 /* Clear all neighbors belonging to a specific peer-group. */
912 if (sort
== clear_group
) {
913 struct peer_group
*group
;
915 group
= peer_group_lookup(bgp
, arg
);
917 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
921 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
922 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
925 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
932 "%%BGP: No %s peer belonging to peer-group %s is configured\n",
933 get_afi_safi_str(afi
, safi
, false), arg
);
938 /* Clear all external (eBGP) neighbors. */
939 if (sort
== clear_external
) {
940 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
941 if (peer
->sort
== BGP_PEER_IBGP
)
944 bgp_peer_gr_flags_update(peer
);
946 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
947 gr_router_detected
= true;
949 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
952 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
957 if (gr_router_detected
958 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
959 bgp_zebra_send_capabilities(bgp
, false);
960 } else if (!gr_router_detected
961 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
962 bgp_zebra_send_capabilities(bgp
, true);
967 "%%BGP: No external %s peer is configured\n",
968 get_afi_safi_str(afi
, safi
, false));
973 /* Clear all neighbors belonging to a specific AS. */
974 if (sort
== clear_as
) {
975 as_t as
= strtoul(arg
, NULL
, 10);
977 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
981 bgp_peer_gr_flags_update(peer
);
983 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_GRACEFUL_RESTART
))
984 gr_router_detected
= true;
986 ret
= bgp_peer_clear(peer
, afi
, safi
, &nnode
, stype
);
989 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
994 if (gr_router_detected
995 && bgp
->present_zebra_gr_state
== ZEBRA_GR_DISABLE
) {
996 bgp_zebra_send_capabilities(bgp
, false);
997 } else if (!gr_router_detected
998 && bgp
->present_zebra_gr_state
== ZEBRA_GR_ENABLE
) {
999 bgp_zebra_send_capabilities(bgp
, true);
1004 "%%BGP: No %s peer is configured with AS %s\n",
1005 get_afi_safi_str(afi
, safi
, false), arg
);
1013 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
1014 safi_t safi
, enum clear_sort sort
,
1015 enum bgp_clear_type stype
, const char *arg
)
1019 /* BGP structure lookup. */
1021 bgp
= bgp_lookup_by_name(name
);
1023 vty_out(vty
, "Can't find BGP instance %s\n", name
);
1027 bgp
= bgp_get_default();
1029 vty_out(vty
, "No BGP process is configured\n");
1034 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
1037 /* clear soft inbound */
1038 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
1043 FOREACH_AFI_SAFI (afi
, safi
)
1044 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1045 BGP_CLEAR_SOFT_IN
, NULL
);
1048 /* clear soft outbound */
1049 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
1054 FOREACH_AFI_SAFI (afi
, safi
)
1055 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
1056 BGP_CLEAR_SOFT_OUT
, NULL
);
1060 #ifndef VTYSH_EXTRACT_PL
1061 #include "bgpd/bgp_vty_clippy.c"
1064 DEFUN_HIDDEN (bgp_local_mac
,
1066 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
1068 "Local MAC config\n"
1069 "VxLAN Network Identifier\n"
1073 "mac-mobility sequence\n"
1083 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
1084 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
1085 vty_out(vty
, "%% Malformed MAC address\n");
1088 memset(&ip
, 0, sizeof(ip
));
1089 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
1091 bgp
= bgp_get_default();
1093 vty_out(vty
, "Default BGP instance is not there\n");
1097 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
,
1100 vty_out(vty
, "Internal error\n");
1107 DEFUN_HIDDEN (no_bgp_local_mac
,
1108 no_bgp_local_mac_cmd
,
1109 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
1112 "Local MAC config\n"
1113 "VxLAN Network Identifier\n"
1124 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
1125 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
1126 vty_out(vty
, "%% Malformed MAC address\n");
1129 memset(&ip
, 0, sizeof(ip
));
1131 bgp
= bgp_get_default();
1133 vty_out(vty
, "Default BGP instance is not there\n");
1137 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
1139 vty_out(vty
, "Internal error\n");
1146 DEFUN (no_synchronization
,
1147 no_synchronization_cmd
,
1148 "no synchronization",
1150 "Perform IGP synchronization\n")
1155 DEFUN (no_auto_summary
,
1156 no_auto_summary_cmd
,
1159 "Enable automatic network number summarization\n")
1164 /* "router bgp" commands. */
1165 DEFUN_NOSH (router_bgp
,
1167 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1171 BGP_INSTANCE_HELP_STR
)
1174 int idx_view_vrf
= 3;
1180 const char *name
= NULL
;
1181 enum bgp_instance_type inst_type
;
1183 // "router bgp" without an ASN
1185 // Pending: Make VRF option available for ASN less config
1186 bgp
= bgp_get_default();
1189 vty_out(vty
, "%% No BGP process is configured\n");
1190 return CMD_WARNING_CONFIG_FAILED
;
1193 if (listcount(bm
->bgp
) > 1) {
1194 vty_out(vty
, "%% Please specify ASN and VRF\n");
1195 return CMD_WARNING_CONFIG_FAILED
;
1201 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1203 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1205 name
= argv
[idx_vrf
]->arg
;
1207 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1208 if (strmatch(name
, VRF_DEFAULT_NAME
))
1211 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1212 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1213 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1216 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1217 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1219 ret
= bgp_get_vty(&bgp
, &as
, name
, inst_type
);
1221 case BGP_ERR_AS_MISMATCH
:
1222 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1223 return CMD_WARNING_CONFIG_FAILED
;
1224 case BGP_ERR_INSTANCE_MISMATCH
:
1226 "BGP instance name and AS number mismatch\n");
1228 "BGP instance is already running; AS is %u\n",
1230 return CMD_WARNING_CONFIG_FAILED
;
1234 * If we just instantiated the default instance, complete
1235 * any pending VRF-VPN leaking that was configured via
1236 * earlier "router bgp X vrf FOO" blocks.
1238 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1239 vpn_leak_postchange_all();
1241 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1242 bgp_vpn_leak_export(bgp
);
1243 /* Pending: handle when user tries to change a view to vrf n vv.
1247 /* unset the auto created flag as the user config is now present */
1248 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1249 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1254 /* "no router bgp" commands. */
1255 DEFUN (no_router_bgp
,
1257 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1262 BGP_INSTANCE_HELP_STR
)
1268 const char *name
= NULL
;
1270 // "no router bgp" without an ASN
1272 // Pending: Make VRF option available for ASN less config
1273 bgp
= bgp_get_default();
1276 vty_out(vty
, "%% No BGP process is configured\n");
1277 return CMD_WARNING_CONFIG_FAILED
;
1280 if (listcount(bm
->bgp
) > 1) {
1281 vty_out(vty
, "%% Please specify ASN and VRF\n");
1282 return CMD_WARNING_CONFIG_FAILED
;
1286 vty_out(vty
, "%% Please unconfigure l3vni %u",
1288 return CMD_WARNING_CONFIG_FAILED
;
1291 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1294 name
= argv
[idx_vrf
]->arg
;
1296 /* Lookup bgp structure. */
1297 bgp
= bgp_lookup(as
, name
);
1299 vty_out(vty
, "%% Can't find BGP instance\n");
1300 return CMD_WARNING_CONFIG_FAILED
;
1304 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1306 return CMD_WARNING_CONFIG_FAILED
;
1309 /* Cannot delete default instance if vrf instances exist */
1310 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1311 struct listnode
*node
;
1312 struct bgp
*tmp_bgp
;
1314 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1315 if (tmp_bgp
->inst_type
1316 == BGP_INSTANCE_TYPE_VRF
) {
1318 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1319 return CMD_WARNING_CONFIG_FAILED
;
1325 if (bgp_vpn_leak_unimport(bgp
, vty
))
1326 return CMD_WARNING_CONFIG_FAILED
;
1334 /* BGP router-id. */
1336 DEFPY (bgp_router_id
,
1338 "bgp router-id A.B.C.D",
1340 "Override configured router identifier\n"
1341 "Manually configured router identifier\n")
1343 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1344 bgp_router_id_static_set(bgp
, router_id
);
1348 DEFPY (no_bgp_router_id
,
1349 no_bgp_router_id_cmd
,
1350 "no bgp router-id [A.B.C.D]",
1353 "Override configured router identifier\n"
1354 "Manually configured router identifier\n")
1356 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1358 if (router_id_str
) {
1359 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1360 vty_out(vty
, "%% BGP router-id doesn't match\n");
1361 return CMD_WARNING_CONFIG_FAILED
;
1365 router_id
.s_addr
= 0;
1366 bgp_router_id_static_set(bgp
, router_id
);
1372 /* BGP Cluster ID. */
1373 DEFUN (bgp_cluster_id
,
1375 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1377 "Configure Route-Reflector Cluster-id\n"
1378 "Route-Reflector Cluster-id in IP address format\n"
1379 "Route-Reflector Cluster-id as 32 bit quantity\n")
1381 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1384 struct in_addr cluster
;
1386 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1388 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1389 return CMD_WARNING_CONFIG_FAILED
;
1392 bgp_cluster_id_set(bgp
, &cluster
);
1393 bgp_clear_star_soft_out(vty
, bgp
->name
);
1398 DEFUN (no_bgp_cluster_id
,
1399 no_bgp_cluster_id_cmd
,
1400 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1403 "Configure Route-Reflector Cluster-id\n"
1404 "Route-Reflector Cluster-id in IP address format\n"
1405 "Route-Reflector Cluster-id as 32 bit quantity\n")
1407 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1408 bgp_cluster_id_unset(bgp
);
1409 bgp_clear_star_soft_out(vty
, bgp
->name
);
1414 DEFUN (bgp_confederation_identifier
,
1415 bgp_confederation_identifier_cmd
,
1416 "bgp confederation identifier (1-4294967295)",
1417 "BGP specific commands\n"
1418 "AS confederation parameters\n"
1420 "Set routing domain confederation AS\n")
1422 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1426 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1428 bgp_confederation_id_set(bgp
, as
);
1433 DEFUN (no_bgp_confederation_identifier
,
1434 no_bgp_confederation_identifier_cmd
,
1435 "no bgp confederation identifier [(1-4294967295)]",
1437 "BGP specific commands\n"
1438 "AS confederation parameters\n"
1440 "Set routing domain confederation AS\n")
1442 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1443 bgp_confederation_id_unset(bgp
);
1448 DEFUN (bgp_confederation_peers
,
1449 bgp_confederation_peers_cmd
,
1450 "bgp confederation peers (1-4294967295)...",
1451 "BGP specific commands\n"
1452 "AS confederation parameters\n"
1453 "Peer ASs in BGP confederation\n"
1456 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1461 for (i
= idx_asn
; i
< argc
; i
++) {
1462 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1464 if (bgp
->as
== as
) {
1466 "%% Local member-AS not allowed in confed peer list\n");
1470 bgp_confederation_peers_add(bgp
, as
);
1475 DEFUN (no_bgp_confederation_peers
,
1476 no_bgp_confederation_peers_cmd
,
1477 "no bgp confederation peers (1-4294967295)...",
1479 "BGP specific commands\n"
1480 "AS confederation parameters\n"
1481 "Peer ASs in BGP confederation\n"
1484 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1489 for (i
= idx_asn
; i
< argc
; i
++) {
1490 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1492 bgp_confederation_peers_remove(bgp
, as
);
1498 * Central routine for maximum-paths configuration.
1499 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1500 * @set: 1 for setting values, 0 for removing the max-paths config.
1502 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1503 const char *mpaths
, uint16_t options
,
1506 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1507 uint16_t maxpaths
= 0;
1512 afi
= bgp_node_afi(vty
);
1513 safi
= bgp_node_safi(vty
);
1516 maxpaths
= strtol(mpaths
, NULL
, 10);
1517 if (maxpaths
> multipath_num
) {
1519 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1520 maxpaths
, multipath_num
);
1521 return CMD_WARNING_CONFIG_FAILED
;
1523 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1526 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1530 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1531 (set
== 1) ? "" : "un",
1532 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1533 maxpaths
, afi
, safi
);
1534 return CMD_WARNING_CONFIG_FAILED
;
1537 bgp_recalculate_all_bestpaths(bgp
);
1542 DEFUN (bgp_maxmed_admin
,
1543 bgp_maxmed_admin_cmd
,
1544 "bgp max-med administrative ",
1546 "Advertise routes with max-med\n"
1547 "Administratively applied, for an indefinite period\n")
1549 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1551 bgp
->v_maxmed_admin
= 1;
1552 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1554 bgp_maxmed_update(bgp
);
1559 DEFUN (bgp_maxmed_admin_medv
,
1560 bgp_maxmed_admin_medv_cmd
,
1561 "bgp max-med administrative (0-4294967295)",
1563 "Advertise routes with max-med\n"
1564 "Administratively applied, for an indefinite period\n"
1565 "Max MED value to be used\n")
1567 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1570 bgp
->v_maxmed_admin
= 1;
1571 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1573 bgp_maxmed_update(bgp
);
1578 DEFUN (no_bgp_maxmed_admin
,
1579 no_bgp_maxmed_admin_cmd
,
1580 "no bgp max-med administrative [(0-4294967295)]",
1583 "Advertise routes with max-med\n"
1584 "Administratively applied, for an indefinite period\n"
1585 "Max MED value to be used\n")
1587 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1588 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1589 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1590 bgp_maxmed_update(bgp
);
1595 DEFUN (bgp_maxmed_onstartup
,
1596 bgp_maxmed_onstartup_cmd
,
1597 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1599 "Advertise routes with max-med\n"
1600 "Effective on a startup\n"
1601 "Time (seconds) period for max-med\n"
1602 "Max MED value to be used\n")
1604 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1607 argv_find(argv
, argc
, "(5-86400)", &idx
);
1608 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1609 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1610 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1612 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1614 bgp_maxmed_update(bgp
);
1619 DEFUN (no_bgp_maxmed_onstartup
,
1620 no_bgp_maxmed_onstartup_cmd
,
1621 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1624 "Advertise routes with max-med\n"
1625 "Effective on a startup\n"
1626 "Time (seconds) period for max-med\n"
1627 "Max MED value to be used\n")
1629 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1631 /* Cancel max-med onstartup if its on */
1632 if (bgp
->t_maxmed_onstartup
) {
1633 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1634 bgp
->maxmed_onstartup_over
= 1;
1637 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1638 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1640 bgp_maxmed_update(bgp
);
1645 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1648 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1649 uint16_t update_delay
;
1650 uint16_t establish_wait
;
1652 update_delay
= strtoul(delay
, NULL
, 10);
1654 if (!wait
) /* update-delay <delay> */
1656 bgp
->v_update_delay
= update_delay
;
1657 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1661 /* update-delay <delay> <establish-wait> */
1662 establish_wait
= atoi(wait
);
1663 if (update_delay
< establish_wait
) {
1665 "%%Failed: update-delay less than the establish-wait!\n");
1666 return CMD_WARNING_CONFIG_FAILED
;
1669 bgp
->v_update_delay
= update_delay
;
1670 bgp
->v_establish_wait
= establish_wait
;
1675 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1677 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1679 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1680 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1685 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1687 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1688 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1689 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1690 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1696 /* Update-delay configuration */
1697 DEFUN (bgp_update_delay
,
1698 bgp_update_delay_cmd
,
1699 "update-delay (0-3600)",
1700 "Force initial delay for best-path and updates\n"
1704 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1707 DEFUN (bgp_update_delay_establish_wait
,
1708 bgp_update_delay_establish_wait_cmd
,
1709 "update-delay (0-3600) (1-3600)",
1710 "Force initial delay for best-path and updates\n"
1715 int idx_number_2
= 2;
1716 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1717 argv
[idx_number_2
]->arg
);
1720 /* Update-delay deconfiguration */
1721 DEFUN (no_bgp_update_delay
,
1722 no_bgp_update_delay_cmd
,
1723 "no update-delay [(0-3600) [(1-3600)]]",
1725 "Force initial delay for best-path and updates\n"
1729 return bgp_update_delay_deconfig_vty(vty
);
1733 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
1736 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1738 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
1739 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
1744 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
1747 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1749 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
1750 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
1755 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1758 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1759 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1760 vty_out(vty
, " write-quanta %d\n", quanta
);
1763 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1766 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1767 if (quanta
!= BGP_READ_PACKET_MAX
)
1768 vty_out(vty
, " read-quanta %d\n", quanta
);
1771 /* Packet quanta configuration
1773 * XXX: The value set here controls the size of a stack buffer in the IO
1774 * thread. When changing these limits be careful to prevent stack overflow.
1776 * Furthermore, the maximums used here should correspond to
1777 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
1779 DEFPY (bgp_wpkt_quanta
,
1780 bgp_wpkt_quanta_cmd
,
1781 "[no] write-quanta (1-64)$quanta",
1783 "How many packets to write to peer socket per run\n"
1784 "Number of packets\n")
1786 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
1789 DEFPY (bgp_rpkt_quanta
,
1790 bgp_rpkt_quanta_cmd
,
1791 "[no] read-quanta (1-10)$quanta",
1793 "How many packets to read from peer socket per I/O cycle\n"
1794 "Number of packets\n")
1796 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
1799 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1801 if (!bgp
->heuristic_coalesce
)
1802 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1806 DEFUN (bgp_coalesce_time
,
1807 bgp_coalesce_time_cmd
,
1808 "coalesce-time (0-4294967295)",
1809 "Subgroup coalesce timer\n"
1810 "Subgroup coalesce timer value (in ms)\n")
1812 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1815 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1816 bgp
->heuristic_coalesce
= false;
1817 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1821 DEFUN (no_bgp_coalesce_time
,
1822 no_bgp_coalesce_time_cmd
,
1823 "no coalesce-time (0-4294967295)",
1825 "Subgroup coalesce timer\n"
1826 "Subgroup coalesce timer value (in ms)\n")
1828 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1830 bgp
->heuristic_coalesce
= true;
1831 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1835 /* Maximum-paths configuration */
1836 DEFUN (bgp_maxpaths
,
1838 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1839 "Forward packets over multiple paths\n"
1840 "Number of paths\n")
1843 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1844 argv
[idx_number
]->arg
, 0, 1);
1847 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1848 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1849 "Forward packets over multiple paths\n"
1850 "Number of paths\n")
1852 DEFUN (bgp_maxpaths_ibgp
,
1853 bgp_maxpaths_ibgp_cmd
,
1854 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1855 "Forward packets over multiple paths\n"
1857 "Number of paths\n")
1860 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1861 argv
[idx_number
]->arg
, 0, 1);
1864 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1865 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1866 "Forward packets over multiple paths\n"
1868 "Number of paths\n")
1870 DEFUN (bgp_maxpaths_ibgp_cluster
,
1871 bgp_maxpaths_ibgp_cluster_cmd
,
1872 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1873 "Forward packets over multiple paths\n"
1876 "Match the cluster length\n")
1879 return bgp_maxpaths_config_vty(
1880 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1881 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1884 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1885 "maximum-paths ibgp " CMD_RANGE_STR(
1886 1, MULTIPATH_NUM
) " equal-cluster-length",
1887 "Forward packets over multiple paths\n"
1890 "Match the cluster length\n")
1892 DEFUN (no_bgp_maxpaths
,
1893 no_bgp_maxpaths_cmd
,
1894 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1896 "Forward packets over multiple paths\n"
1897 "Number of paths\n")
1899 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1902 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1903 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1904 "Forward packets over multiple paths\n"
1905 "Number of paths\n")
1907 DEFUN (no_bgp_maxpaths_ibgp
,
1908 no_bgp_maxpaths_ibgp_cmd
,
1909 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1911 "Forward packets over multiple paths\n"
1914 "Match the cluster length\n")
1916 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1919 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1920 "no maximum-paths ibgp [" CMD_RANGE_STR(
1921 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1923 "Forward packets over multiple paths\n"
1926 "Match the cluster length\n")
1928 static void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
,
1929 afi_t afi
, safi_t safi
)
1931 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1932 vty_out(vty
, " maximum-paths %d\n",
1933 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1936 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1937 vty_out(vty
, " maximum-paths ibgp %d",
1938 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1939 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1940 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1941 vty_out(vty
, " equal-cluster-length");
1950 "timers bgp (0-65535) (0-65535)",
1951 "Adjust routing timers\n"
1953 "Keepalive interval\n"
1956 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1958 int idx_number_2
= 3;
1959 unsigned long keepalive
= 0;
1960 unsigned long holdtime
= 0;
1962 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1963 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1965 /* Holdtime value check. */
1966 if (holdtime
< 3 && holdtime
!= 0) {
1968 "%% hold time value must be either 0 or greater than 3\n");
1969 return CMD_WARNING_CONFIG_FAILED
;
1972 bgp_timers_set(bgp
, keepalive
, holdtime
, DFLT_BGP_CONNECT_RETRY
);
1977 DEFUN (no_bgp_timers
,
1979 "no timers bgp [(0-65535) (0-65535)]",
1981 "Adjust routing timers\n"
1983 "Keepalive interval\n"
1986 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1987 bgp_timers_set(bgp
, DFLT_BGP_KEEPALIVE
, DFLT_BGP_HOLDTIME
,
1988 DFLT_BGP_CONNECT_RETRY
);
1994 DEFUN (bgp_client_to_client_reflection
,
1995 bgp_client_to_client_reflection_cmd
,
1996 "bgp client-to-client reflection",
1997 "BGP specific commands\n"
1998 "Configure client to client route reflection\n"
1999 "reflection of routes allowed\n")
2001 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2002 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2003 bgp_clear_star_soft_out(vty
, bgp
->name
);
2008 DEFUN (no_bgp_client_to_client_reflection
,
2009 no_bgp_client_to_client_reflection_cmd
,
2010 "no bgp client-to-client reflection",
2012 "BGP specific commands\n"
2013 "Configure client to client route reflection\n"
2014 "reflection of routes allowed\n")
2016 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2017 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
2018 bgp_clear_star_soft_out(vty
, bgp
->name
);
2023 /* "bgp always-compare-med" configuration. */
2024 DEFUN (bgp_always_compare_med
,
2025 bgp_always_compare_med_cmd
,
2026 "bgp always-compare-med",
2027 "BGP specific commands\n"
2028 "Allow comparing MED from different neighbors\n")
2030 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2031 SET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2032 bgp_recalculate_all_bestpaths(bgp
);
2037 DEFUN (no_bgp_always_compare_med
,
2038 no_bgp_always_compare_med_cmd
,
2039 "no bgp always-compare-med",
2041 "BGP specific commands\n"
2042 "Allow comparing MED from different neighbors\n")
2044 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2045 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
);
2046 bgp_recalculate_all_bestpaths(bgp
);
2052 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
2053 "bgp ebgp-requires-policy",
2054 "BGP specific commands\n"
2055 "Require in and out policy for eBGP peers (RFC8212)\n")
2057 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2058 SET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2062 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
2063 "no bgp ebgp-requires-policy",
2065 "BGP specific commands\n"
2066 "Require in and out policy for eBGP peers (RFC8212)\n")
2068 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2069 UNSET_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
);
2073 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
2074 "bgp reject-as-sets",
2075 "BGP specific commands\n"
2076 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2078 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2079 struct listnode
*node
, *nnode
;
2082 bgp
->reject_as_sets
= true;
2084 /* Reset existing BGP sessions to reject routes
2085 * with aspath containing AS_SET or AS_CONFED_SET.
2087 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2088 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2089 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2090 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2091 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2098 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
2099 "no bgp reject-as-sets",
2101 "BGP specific commands\n"
2102 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
2104 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2105 struct listnode
*node
, *nnode
;
2108 bgp
->reject_as_sets
= false;
2110 /* Reset existing BGP sessions to reject routes
2111 * with aspath containing AS_SET or AS_CONFED_SET.
2113 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2114 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2115 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
2116 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2117 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2124 /* "bgp deterministic-med" configuration. */
2125 DEFUN (bgp_deterministic_med
,
2126 bgp_deterministic_med_cmd
,
2127 "bgp deterministic-med",
2128 "BGP specific commands\n"
2129 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2131 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2133 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2134 SET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2135 bgp_recalculate_all_bestpaths(bgp
);
2141 DEFUN (no_bgp_deterministic_med
,
2142 no_bgp_deterministic_med_cmd
,
2143 "no bgp deterministic-med",
2145 "BGP specific commands\n"
2146 "Pick the best-MED path among paths advertised from the neighboring AS\n")
2148 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2149 int bestpath_per_as_used
;
2153 struct listnode
*node
, *nnode
;
2155 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)) {
2156 bestpath_per_as_used
= 0;
2158 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2159 FOREACH_AFI_SAFI (afi
, safi
)
2160 if (bgp_addpath_dmed_required(
2161 peer
->addpath_type
[afi
][safi
])) {
2162 bestpath_per_as_used
= 1;
2166 if (bestpath_per_as_used
)
2170 if (bestpath_per_as_used
) {
2172 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2173 return CMD_WARNING_CONFIG_FAILED
;
2175 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
);
2176 bgp_recalculate_all_bestpaths(bgp
);
2183 /* "bgp graceful-restart mode" configuration. */
2184 DEFUN (bgp_graceful_restart
,
2185 bgp_graceful_restart_cmd
,
2186 "bgp graceful-restart",
2187 "BGP specific commands\n"
2191 int ret
= BGP_GR_FAILURE
;
2193 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2194 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : START ");
2196 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2198 ret
= bgp_gr_update_all(bgp
, GLOBAL_GR_CMD
);
2200 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2203 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2204 zlog_debug("[BGP_GR] bgp_graceful_restart_cmd : END ");
2206 "Graceful restart configuration changed, reset all peers to take effect\n");
2207 return bgp_vty_return(vty
, ret
);
2210 DEFUN (no_bgp_graceful_restart
,
2211 no_bgp_graceful_restart_cmd
,
2212 "no bgp graceful-restart",
2214 "BGP specific commands\n"
2218 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2220 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2221 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : START ");
2223 int ret
= BGP_GR_FAILURE
;
2225 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_GR_CMD
);
2227 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2230 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2231 zlog_debug("[BGP_GR] no_bgp_graceful_restart_cmd : END ");
2233 "Graceful restart configuration changed, reset all peers to take effect\n");
2235 return bgp_vty_return(vty
, ret
);
2238 DEFUN (bgp_graceful_restart_stalepath_time
,
2239 bgp_graceful_restart_stalepath_time_cmd
,
2240 "bgp graceful-restart stalepath-time (1-4095)",
2241 "BGP specific commands\n"
2242 "Graceful restart capability parameters\n"
2243 "Set the max time to hold onto restarting peer's stale paths\n"
2244 "Delay value (seconds)\n")
2246 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2250 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2251 bgp
->stalepath_time
= stalepath
;
2255 DEFUN (bgp_graceful_restart_restart_time
,
2256 bgp_graceful_restart_restart_time_cmd
,
2257 "bgp graceful-restart restart-time (1-4095)",
2258 "BGP specific commands\n"
2259 "Graceful restart capability parameters\n"
2260 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2261 "Delay value (seconds)\n")
2263 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2267 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2268 bgp
->restart_time
= restart
;
2272 DEFUN (bgp_graceful_restart_select_defer_time
,
2273 bgp_graceful_restart_select_defer_time_cmd
,
2274 "bgp graceful-restart select-defer-time (0-3600)",
2275 "BGP specific commands\n"
2276 "Graceful restart capability parameters\n"
2277 "Set the time to defer the BGP route selection after restart\n"
2278 "Delay value (seconds, 0 - disable)\n")
2280 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2282 uint32_t defer_time
;
2284 defer_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2285 bgp
->select_defer_time
= defer_time
;
2286 if (defer_time
== 0)
2287 SET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2289 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2294 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2295 no_bgp_graceful_restart_stalepath_time_cmd
,
2296 "no bgp graceful-restart stalepath-time [(1-4095)]",
2298 "BGP specific commands\n"
2299 "Graceful restart capability parameters\n"
2300 "Set the max time to hold onto restarting peer's stale paths\n"
2301 "Delay value (seconds)\n")
2303 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2305 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2309 DEFUN (no_bgp_graceful_restart_restart_time
,
2310 no_bgp_graceful_restart_restart_time_cmd
,
2311 "no bgp graceful-restart restart-time [(1-4095)]",
2313 "BGP specific commands\n"
2314 "Graceful restart capability parameters\n"
2315 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2316 "Delay value (seconds)\n")
2318 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2320 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2324 DEFUN (no_bgp_graceful_restart_select_defer_time
,
2325 no_bgp_graceful_restart_select_defer_time_cmd
,
2326 "no bgp graceful-restart select-defer-time [(0-3600)]",
2328 "BGP specific commands\n"
2329 "Graceful restart capability parameters\n"
2330 "Set the time to defer the BGP route selection after restart\n"
2331 "Delay value (seconds)\n")
2333 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2335 bgp
->select_defer_time
= BGP_DEFAULT_SELECT_DEFERRAL_TIME
;
2336 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SELECT_DEFER_DISABLE
);
2341 DEFUN (bgp_graceful_restart_preserve_fw
,
2342 bgp_graceful_restart_preserve_fw_cmd
,
2343 "bgp graceful-restart preserve-fw-state",
2344 "BGP specific commands\n"
2345 "Graceful restart capability parameters\n"
2346 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2348 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2349 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2353 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2354 no_bgp_graceful_restart_preserve_fw_cmd
,
2355 "no bgp graceful-restart preserve-fw-state",
2357 "BGP specific commands\n"
2358 "Graceful restart capability parameters\n"
2359 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2361 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2362 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
);
2366 DEFUN (bgp_graceful_restart_disable
,
2367 bgp_graceful_restart_disable_cmd
,
2368 "bgp graceful-restart-disable",
2369 "BGP specific commands\n"
2372 int ret
= BGP_GR_FAILURE
;
2374 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2376 "[BGP_GR] bgp_graceful_restart_disable_cmd : START ");
2378 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2380 ret
= bgp_gr_update_all(bgp
, GLOBAL_DISABLE_CMD
);
2382 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
,
2385 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2387 "[BGP_GR] bgp_graceful_restart_disable_cmd : END ");
2389 "Graceful restart configuration changed, reset all peers to take effect\n");
2391 return bgp_vty_return(vty
, ret
);
2394 DEFUN (no_bgp_graceful_restart_disable
,
2395 no_bgp_graceful_restart_disable_cmd
,
2396 "no bgp graceful-restart-disable",
2398 "BGP specific commands\n"
2402 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2404 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2406 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : START ");
2408 int ret
= BGP_GR_FAILURE
;
2410 ret
= bgp_gr_update_all(bgp
, NO_GLOBAL_DISABLE_CMD
);
2412 VTY_BGP_GR_ROUTER_DETECT_AND_SEND_CAPABILITY_TO_ZEBRA(bgp
, bgp
->peer
,
2415 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2417 "[BGP_GR] no_bgp_graceful_restart_disable_cmd : END ");
2419 "Graceful restart configuration changed, reset all peers to take effect\n");
2421 return bgp_vty_return(vty
, ret
);
2424 DEFUN (bgp_neighbor_graceful_restart_set
,
2425 bgp_neighbor_graceful_restart_set_cmd
,
2426 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
2434 int ret
= BGP_GR_FAILURE
;
2436 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2438 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2440 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : START ");
2442 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2444 return CMD_WARNING_CONFIG_FAILED
;
2446 ret
= bgp_neighbor_graceful_restart(peer
, PEER_GR_CMD
);
2448 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2449 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2451 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2453 "[BGP_GR] bgp_neighbor_graceful_restart_set_cmd : END ");
2455 "Graceful restart configuration changed, reset this peer to take effect\n");
2457 return bgp_vty_return(vty
, ret
);
2460 DEFUN (no_bgp_neighbor_graceful_restart
,
2461 no_bgp_neighbor_graceful_restart_set_cmd
,
2462 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart",
2470 int ret
= BGP_GR_FAILURE
;
2473 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2475 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2477 return CMD_WARNING_CONFIG_FAILED
;
2479 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2481 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : START ");
2483 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_GR_CMD
);
2485 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2486 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2488 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2490 "[BGP_GR] no_bgp_neighbor_graceful_restart_set_cmd : END ");
2492 "Graceful restart configuration changed, reset this peer to take effect\n");
2494 return bgp_vty_return(vty
, ret
);
2497 DEFUN (bgp_neighbor_graceful_restart_helper_set
,
2498 bgp_neighbor_graceful_restart_helper_set_cmd
,
2499 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
2502 GR_NEIGHBOR_HELPER_CMD
2507 int ret
= BGP_GR_FAILURE
;
2509 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2511 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2513 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : START ");
2515 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2518 return CMD_WARNING_CONFIG_FAILED
;
2521 ret
= bgp_neighbor_graceful_restart(peer
, PEER_HELPER_CMD
);
2523 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2524 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2526 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2528 "[BGP_GR] bgp_neighbor_graceful_restart_helper_set_cmd : END ");
2530 "Graceful restart configuration changed, reset this peer to take effect\n");
2532 return bgp_vty_return(vty
, ret
);
2535 DEFUN (no_bgp_neighbor_graceful_restart_helper
,
2536 no_bgp_neighbor_graceful_restart_helper_set_cmd
,
2537 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-helper",
2541 NO_GR_NEIGHBOR_HELPER_CMD
2545 int ret
= BGP_GR_FAILURE
;
2548 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2550 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2552 return CMD_WARNING_CONFIG_FAILED
;
2554 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2556 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : START ");
2558 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_HELPER_CMD
);
2560 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2561 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2563 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2565 "[BGP_GR] no_bgp_neighbor_graceful_restart_helper_set_cmd : END ");
2567 "Graceful restart configuration changed, reset this peer to take effect\n");
2569 return bgp_vty_return(vty
, ret
);
2572 DEFUN (bgp_neighbor_graceful_restart_disable_set
,
2573 bgp_neighbor_graceful_restart_disable_set_cmd
,
2574 "neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
2577 GR_NEIGHBOR_DISABLE_CMD
2582 int ret
= BGP_GR_FAILURE
;
2584 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2586 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2588 "[BGP_GR] bgp_neighbor_graceful_restart_disable_set_cmd : START ");
2590 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2592 return CMD_WARNING_CONFIG_FAILED
;
2594 ret
= bgp_neighbor_graceful_restart(peer
, PEER_DISABLE_CMD
);
2596 if (peer
->bgp
->t_startup
)
2597 bgp_peer_gr_flags_update(peer
);
2599 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2600 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2602 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2604 "[BGP_GR]bgp_neighbor_graceful_restart_disable_set_cmd : END ");
2606 "Graceful restart configuration changed, reset this peer to take effect\n");
2608 return bgp_vty_return(vty
, ret
);
2611 DEFUN (no_bgp_neighbor_graceful_restart_disable
,
2612 no_bgp_neighbor_graceful_restart_disable_set_cmd
,
2613 "no neighbor <A.B.C.D|X:X::X:X|WORD> graceful-restart-disable",
2617 NO_GR_NEIGHBOR_DISABLE_CMD
2621 int ret
= BGP_GR_FAILURE
;
2624 VTY_BGP_GR_DEFINE_LOOP_VARIABLE
;
2626 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
2628 return CMD_WARNING_CONFIG_FAILED
;
2630 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2632 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : START ");
2634 ret
= bgp_neighbor_graceful_restart(peer
, NO_PEER_DISABLE_CMD
);
2636 VTY_BGP_GR_ROUTER_DETECT(bgp
, peer
, peer
->bgp
->peer
);
2637 VTY_SEND_BGP_GR_CAPABILITY_TO_ZEBRA(peer
->bgp
, ret
);
2639 if (BGP_DEBUG(graceful_restart
, GRACEFUL_RESTART
))
2641 "[BGP_GR] no_bgp_neighbor_graceful_restart_disable_set_cmd : END ");
2643 "Graceful restart configuration changed, reset this peer to take effect\n");
2645 return bgp_vty_return(vty
, ret
);
2648 DEFUN_HIDDEN (bgp_graceful_restart_disable_eor
,
2649 bgp_graceful_restart_disable_eor_cmd
,
2650 "bgp graceful-restart disable-eor",
2651 "BGP specific commands\n"
2652 "Graceful restart configuration parameters\n"
2653 "Disable EOR Check\n")
2655 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2656 SET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
2661 DEFUN_HIDDEN (no_bgp_graceful_restart_disable_eor
,
2662 no_bgp_graceful_restart_disable_eor_cmd
,
2663 "no bgp graceful-restart disable-eor",
2665 "BGP specific commands\n"
2666 "Graceful restart configuration parameters\n"
2667 "Disable EOR Check\n")
2669 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2670 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GR_DISABLE_EOR
);
2675 DEFUN (bgp_graceful_restart_rib_stale_time
,
2676 bgp_graceful_restart_rib_stale_time_cmd
,
2677 "bgp graceful-restart rib-stale-time (1-3600)",
2678 "BGP specific commands\n"
2679 "Graceful restart configuration parameters\n"
2680 "Specify the stale route removal timer in rib\n"
2681 "Delay value (seconds)\n")
2683 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2685 uint32_t stale_time
;
2687 stale_time
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2688 bgp
->rib_stale_time
= stale_time
;
2689 /* Send the stale timer update message to RIB */
2690 if (bgp_zebra_stale_timer_update(bgp
))
2696 DEFUN (no_bgp_graceful_restart_rib_stale_time
,
2697 no_bgp_graceful_restart_rib_stale_time_cmd
,
2698 "no bgp graceful-restart rib-stale-time [(1-3600)]",
2700 "BGP specific commands\n"
2701 "Graceful restart configuration parameters\n"
2702 "Specify the stale route removal timer in rib\n"
2703 "Delay value (seconds)\n")
2705 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2707 bgp
->rib_stale_time
= BGP_DEFAULT_RIB_STALE_TIME
;
2708 /* Send the stale timer update message to RIB */
2709 if (bgp_zebra_stale_timer_update(bgp
))
2715 /* "bgp graceful-shutdown" configuration */
2716 DEFUN (bgp_graceful_shutdown
,
2717 bgp_graceful_shutdown_cmd
,
2718 "bgp graceful-shutdown",
2720 "Graceful shutdown parameters\n")
2722 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2724 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2725 SET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2726 bgp_static_redo_import_check(bgp
);
2727 bgp_redistribute_redo(bgp
);
2728 bgp_clear_star_soft_out(vty
, bgp
->name
);
2729 bgp_clear_star_soft_in(vty
, bgp
->name
);
2735 DEFUN (no_bgp_graceful_shutdown
,
2736 no_bgp_graceful_shutdown_cmd
,
2737 "no bgp graceful-shutdown",
2740 "Graceful shutdown parameters\n")
2742 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2744 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2745 UNSET_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2746 bgp_static_redo_import_check(bgp
);
2747 bgp_redistribute_redo(bgp
);
2748 bgp_clear_star_soft_out(vty
, bgp
->name
);
2749 bgp_clear_star_soft_in(vty
, bgp
->name
);
2755 /* "bgp fast-external-failover" configuration. */
2756 DEFUN (bgp_fast_external_failover
,
2757 bgp_fast_external_failover_cmd
,
2758 "bgp fast-external-failover",
2760 "Immediately reset session if a link to a directly connected external peer goes down\n")
2762 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2763 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2767 DEFUN (no_bgp_fast_external_failover
,
2768 no_bgp_fast_external_failover_cmd
,
2769 "no bgp fast-external-failover",
2772 "Immediately reset session if a link to a directly connected external peer goes down\n")
2774 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2775 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2779 /* "bgp bestpath compare-routerid" configuration. */
2780 DEFUN (bgp_bestpath_compare_router_id
,
2781 bgp_bestpath_compare_router_id_cmd
,
2782 "bgp bestpath compare-routerid",
2783 "BGP specific commands\n"
2784 "Change the default bestpath selection\n"
2785 "Compare router-id for identical EBGP paths\n")
2787 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2788 SET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
2789 bgp_recalculate_all_bestpaths(bgp
);
2794 DEFUN (no_bgp_bestpath_compare_router_id
,
2795 no_bgp_bestpath_compare_router_id_cmd
,
2796 "no bgp bestpath compare-routerid",
2798 "BGP specific commands\n"
2799 "Change the default bestpath selection\n"
2800 "Compare router-id for identical EBGP paths\n")
2802 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2803 UNSET_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
);
2804 bgp_recalculate_all_bestpaths(bgp
);
2809 /* "bgp bestpath as-path ignore" configuration. */
2810 DEFUN (bgp_bestpath_aspath_ignore
,
2811 bgp_bestpath_aspath_ignore_cmd
,
2812 "bgp bestpath as-path ignore",
2813 "BGP specific commands\n"
2814 "Change the default bestpath selection\n"
2815 "AS-path attribute\n"
2816 "Ignore as-path length in selecting a route\n")
2818 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2819 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
2820 bgp_recalculate_all_bestpaths(bgp
);
2825 DEFUN (no_bgp_bestpath_aspath_ignore
,
2826 no_bgp_bestpath_aspath_ignore_cmd
,
2827 "no bgp bestpath as-path ignore",
2829 "BGP specific commands\n"
2830 "Change the default bestpath selection\n"
2831 "AS-path attribute\n"
2832 "Ignore as-path length in selecting a route\n")
2834 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2835 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
);
2836 bgp_recalculate_all_bestpaths(bgp
);
2841 /* "bgp bestpath as-path confed" configuration. */
2842 DEFUN (bgp_bestpath_aspath_confed
,
2843 bgp_bestpath_aspath_confed_cmd
,
2844 "bgp bestpath as-path confed",
2845 "BGP specific commands\n"
2846 "Change the default bestpath selection\n"
2847 "AS-path attribute\n"
2848 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2850 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2851 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
2852 bgp_recalculate_all_bestpaths(bgp
);
2857 DEFUN (no_bgp_bestpath_aspath_confed
,
2858 no_bgp_bestpath_aspath_confed_cmd
,
2859 "no bgp bestpath as-path confed",
2861 "BGP specific commands\n"
2862 "Change the default bestpath selection\n"
2863 "AS-path attribute\n"
2864 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2866 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2867 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
);
2868 bgp_recalculate_all_bestpaths(bgp
);
2873 /* "bgp bestpath as-path multipath-relax" configuration. */
2874 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2875 bgp_bestpath_aspath_multipath_relax_cmd
,
2876 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2877 "BGP specific commands\n"
2878 "Change the default bestpath selection\n"
2879 "AS-path attribute\n"
2880 "Allow load sharing across routes that have different AS paths (but same length)\n"
2881 "Generate an AS_SET\n"
2882 "Do not generate an AS_SET\n")
2884 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2886 SET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2888 /* no-as-set is now the default behavior so we can silently
2890 if (argv_find(argv
, argc
, "as-set", &idx
))
2891 SET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2893 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2895 bgp_recalculate_all_bestpaths(bgp
);
2900 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2901 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2902 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2904 "BGP specific commands\n"
2905 "Change the default bestpath selection\n"
2906 "AS-path attribute\n"
2907 "Allow load sharing across routes that have different AS paths (but same length)\n"
2908 "Generate an AS_SET\n"
2909 "Do not generate an AS_SET\n")
2911 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2912 UNSET_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2913 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2914 bgp_recalculate_all_bestpaths(bgp
);
2919 /* "bgp log-neighbor-changes" configuration. */
2920 DEFUN (bgp_log_neighbor_changes
,
2921 bgp_log_neighbor_changes_cmd
,
2922 "bgp log-neighbor-changes",
2923 "BGP specific commands\n"
2924 "Log neighbor up/down and reset reason\n")
2926 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2927 SET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2931 DEFUN (no_bgp_log_neighbor_changes
,
2932 no_bgp_log_neighbor_changes_cmd
,
2933 "no bgp log-neighbor-changes",
2935 "BGP specific commands\n"
2936 "Log neighbor up/down and reset reason\n")
2938 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2939 UNSET_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2943 /* "bgp bestpath med" configuration. */
2944 DEFUN (bgp_bestpath_med
,
2945 bgp_bestpath_med_cmd
,
2946 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2947 "BGP specific commands\n"
2948 "Change the default bestpath selection\n"
2950 "Compare MED among confederation paths\n"
2951 "Treat missing MED as the least preferred one\n"
2952 "Treat missing MED as the least preferred one\n"
2953 "Compare MED among confederation paths\n")
2955 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2958 if (argv_find(argv
, argc
, "confed", &idx
))
2959 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
2961 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2962 SET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
2964 bgp_recalculate_all_bestpaths(bgp
);
2969 DEFUN (no_bgp_bestpath_med
,
2970 no_bgp_bestpath_med_cmd
,
2971 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2973 "BGP specific commands\n"
2974 "Change the default bestpath selection\n"
2976 "Compare MED among confederation paths\n"
2977 "Treat missing MED as the least preferred one\n"
2978 "Treat missing MED as the least preferred one\n"
2979 "Compare MED among confederation paths\n")
2981 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2984 if (argv_find(argv
, argc
, "confed", &idx
))
2985 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
);
2987 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2988 UNSET_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
);
2990 bgp_recalculate_all_bestpaths(bgp
);
2995 /* "bgp bestpath bandwidth" configuration. */
2996 DEFPY (bgp_bestpath_bw
,
2997 bgp_bestpath_bw_cmd
,
2998 "bgp bestpath bandwidth <ignore|skip-missing|default-weight-for-missing>$bw_cfg",
2999 "BGP specific commands\n"
3000 "Change the default bestpath selection\n"
3001 "Link Bandwidth attribute\n"
3002 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3003 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3004 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3006 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3011 vty_out(vty
, "%% Bandwidth configuration must be specified\n");
3012 return CMD_ERR_INCOMPLETE
;
3014 if (!strcmp(bw_cfg
, "ignore"))
3015 bgp
->lb_handling
= BGP_LINK_BW_IGNORE_BW
;
3016 else if (!strcmp(bw_cfg
, "skip-missing"))
3017 bgp
->lb_handling
= BGP_LINK_BW_SKIP_MISSING
;
3018 else if (!strcmp(bw_cfg
, "default-weight-for-missing"))
3019 bgp
->lb_handling
= BGP_LINK_BW_DEFWT_4_MISSING
;
3021 return CMD_ERR_NO_MATCH
;
3023 /* This config is used in route install, so redo that. */
3024 FOREACH_AFI_SAFI (afi
, safi
) {
3025 if (!bgp_fibupd_safi(safi
))
3027 bgp_zebra_announce_table(bgp
, afi
, safi
);
3033 DEFPY (no_bgp_bestpath_bw
,
3034 no_bgp_bestpath_bw_cmd
,
3035 "no bgp bestpath bandwidth [<ignore|skip-missing|default-weight-for-missing>$bw_cfg]",
3037 "BGP specific commands\n"
3038 "Change the default bestpath selection\n"
3039 "Link Bandwidth attribute\n"
3040 "Ignore link bandwidth (i.e., do regular ECMP, not weighted)\n"
3041 "Ignore paths without link bandwidth for ECMP (if other paths have it)\n"
3042 "Assign a low default weight (value 1) to paths not having link bandwidth\n")
3044 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3048 bgp
->lb_handling
= BGP_LINK_BW_ECMP
;
3050 /* This config is used in route install, so redo that. */
3051 FOREACH_AFI_SAFI (afi
, safi
) {
3052 if (!bgp_fibupd_safi(safi
))
3054 bgp_zebra_announce_table(bgp
, afi
, safi
);
3059 /* "no bgp default ipv4-unicast". */
3060 DEFUN (no_bgp_default_ipv4_unicast
,
3061 no_bgp_default_ipv4_unicast_cmd
,
3062 "no bgp default ipv4-unicast",
3064 "BGP specific commands\n"
3065 "Configure BGP defaults\n"
3066 "Activate ipv4-unicast for a peer by default\n")
3068 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3069 SET_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
);
3073 DEFUN (bgp_default_ipv4_unicast
,
3074 bgp_default_ipv4_unicast_cmd
,
3075 "bgp default ipv4-unicast",
3076 "BGP specific commands\n"
3077 "Configure BGP defaults\n"
3078 "Activate ipv4-unicast for a peer by default\n")
3080 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3081 UNSET_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
);
3085 /* Display hostname in certain command outputs */
3086 DEFUN (bgp_default_show_hostname
,
3087 bgp_default_show_hostname_cmd
,
3088 "bgp default show-hostname",
3089 "BGP specific commands\n"
3090 "Configure BGP defaults\n"
3091 "Show hostname in certain command outputs\n")
3093 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3094 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3098 DEFUN (no_bgp_default_show_hostname
,
3099 no_bgp_default_show_hostname_cmd
,
3100 "no bgp default show-hostname",
3102 "BGP specific commands\n"
3103 "Configure BGP defaults\n"
3104 "Show hostname in certain command outputs\n")
3106 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3107 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
);
3111 /* Display hostname in certain command outputs */
3112 DEFUN (bgp_default_show_nexthop_hostname
,
3113 bgp_default_show_nexthop_hostname_cmd
,
3114 "bgp default show-nexthop-hostname",
3115 "BGP specific commands\n"
3116 "Configure BGP defaults\n"
3117 "Show hostname for nexthop in certain command outputs\n")
3119 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3120 SET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3124 DEFUN (no_bgp_default_show_nexthop_hostname
,
3125 no_bgp_default_show_nexthop_hostname_cmd
,
3126 "no bgp default show-nexthop-hostname",
3128 "BGP specific commands\n"
3129 "Configure BGP defaults\n"
3130 "Show hostname for nexthop in certain command outputs\n")
3132 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3133 UNSET_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
);
3137 /* "bgp network import-check" configuration. */
3138 DEFUN (bgp_network_import_check
,
3139 bgp_network_import_check_cmd
,
3140 "bgp network import-check",
3141 "BGP specific commands\n"
3142 "BGP network command\n"
3143 "Check BGP network route exists in IGP\n")
3145 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3146 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3147 SET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3148 bgp_static_redo_import_check(bgp
);
3154 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
3155 "bgp network import-check exact",
3156 "BGP specific commands\n"
3157 "BGP network command\n"
3158 "Check BGP network route exists in IGP\n"
3159 "Match route precisely\n")
3161 DEFUN (no_bgp_network_import_check
,
3162 no_bgp_network_import_check_cmd
,
3163 "no bgp network import-check",
3165 "BGP specific commands\n"
3166 "BGP network command\n"
3167 "Check BGP network route exists in IGP\n")
3169 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3170 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)) {
3171 UNSET_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
);
3172 bgp_static_redo_import_check(bgp
);
3178 DEFUN (bgp_default_local_preference
,
3179 bgp_default_local_preference_cmd
,
3180 "bgp default local-preference (0-4294967295)",
3181 "BGP specific commands\n"
3182 "Configure BGP defaults\n"
3183 "local preference (higher=more preferred)\n"
3184 "Configure default local preference value\n")
3186 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3188 uint32_t local_pref
;
3190 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3192 bgp_default_local_preference_set(bgp
, local_pref
);
3193 bgp_clear_star_soft_in(vty
, bgp
->name
);
3198 DEFUN (no_bgp_default_local_preference
,
3199 no_bgp_default_local_preference_cmd
,
3200 "no bgp default local-preference [(0-4294967295)]",
3202 "BGP specific commands\n"
3203 "Configure BGP defaults\n"
3204 "local preference (higher=more preferred)\n"
3205 "Configure default local preference value\n")
3207 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3208 bgp_default_local_preference_unset(bgp
);
3209 bgp_clear_star_soft_in(vty
, bgp
->name
);
3215 DEFUN (bgp_default_subgroup_pkt_queue_max
,
3216 bgp_default_subgroup_pkt_queue_max_cmd
,
3217 "bgp default subgroup-pkt-queue-max (20-100)",
3218 "BGP specific commands\n"
3219 "Configure BGP defaults\n"
3220 "subgroup-pkt-queue-max\n"
3221 "Configure subgroup packet queue max\n")
3223 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3227 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3229 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
3234 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
3235 no_bgp_default_subgroup_pkt_queue_max_cmd
,
3236 "no bgp default subgroup-pkt-queue-max [(20-100)]",
3238 "BGP specific commands\n"
3239 "Configure BGP defaults\n"
3240 "subgroup-pkt-queue-max\n"
3241 "Configure subgroup packet queue max\n")
3243 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3244 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
3249 DEFUN (bgp_rr_allow_outbound_policy
,
3250 bgp_rr_allow_outbound_policy_cmd
,
3251 "bgp route-reflector allow-outbound-policy",
3252 "BGP specific commands\n"
3253 "Allow modifications made by out route-map\n"
3254 "on ibgp neighbors\n")
3256 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3258 if (!CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
3259 SET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
3260 update_group_announce_rrclients(bgp
);
3261 bgp_clear_star_soft_out(vty
, bgp
->name
);
3267 DEFUN (no_bgp_rr_allow_outbound_policy
,
3268 no_bgp_rr_allow_outbound_policy_cmd
,
3269 "no bgp route-reflector allow-outbound-policy",
3271 "BGP specific commands\n"
3272 "Allow modifications made by out route-map\n"
3273 "on ibgp neighbors\n")
3275 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3277 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
3278 UNSET_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
3279 update_group_announce_rrclients(bgp
);
3280 bgp_clear_star_soft_out(vty
, bgp
->name
);
3286 DEFUN (bgp_listen_limit
,
3287 bgp_listen_limit_cmd
,
3288 "bgp listen limit (1-5000)",
3289 "BGP specific commands\n"
3290 "BGP Dynamic Neighbors listen commands\n"
3291 "Maximum number of BGP Dynamic Neighbors that can be created\n"
3292 "Configure Dynamic Neighbors listen limit value\n")
3294 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3298 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3300 bgp_listen_limit_set(bgp
, listen_limit
);
3305 DEFUN (no_bgp_listen_limit
,
3306 no_bgp_listen_limit_cmd
,
3307 "no bgp listen limit [(1-5000)]",
3309 "BGP specific commands\n"
3310 "BGP Dynamic Neighbors listen commands\n"
3311 "Maximum number of BGP Dynamic Neighbors that can be created\n"
3312 "Configure Dynamic Neighbors listen limit value\n")
3314 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3315 bgp_listen_limit_unset(bgp
);
3321 * Check if this listen range is already configured. Check for exact
3322 * match or overlap based on input.
3324 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
3325 struct prefix
*range
, int exact
)
3327 struct listnode
*node
, *nnode
;
3328 struct listnode
*node1
, *nnode1
;
3329 struct peer_group
*group
;
3334 afi
= family2afi(range
->family
);
3335 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
3336 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
3339 match
= prefix_same(range
, lr
);
3341 match
= (prefix_match(range
, lr
)
3342 || prefix_match(lr
, range
));
3351 DEFUN (bgp_listen_range
,
3352 bgp_listen_range_cmd
,
3353 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
3354 "BGP specific commands\n"
3355 "Configure BGP dynamic neighbors listen range\n"
3356 "Configure BGP dynamic neighbors listen range\n"
3358 "Member of the peer-group\n"
3359 "Peer-group name\n")
3361 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3362 struct prefix range
;
3363 struct peer_group
*group
, *existing_group
;
3368 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
3369 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
3370 char *prefix
= argv
[idx
]->arg
;
3371 argv_find(argv
, argc
, "PGNAME", &idx
);
3372 char *peergroup
= argv
[idx
]->arg
;
3374 /* Convert IP prefix string to struct prefix. */
3375 ret
= str2prefix(prefix
, &range
);
3377 vty_out(vty
, "%% Malformed listen range\n");
3378 return CMD_WARNING_CONFIG_FAILED
;
3381 afi
= family2afi(range
.family
);
3383 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
3385 "%% Malformed listen range (link-local address)\n");
3386 return CMD_WARNING_CONFIG_FAILED
;
3391 /* Check if same listen range is already configured. */
3392 existing_group
= listen_range_exists(bgp
, &range
, 1);
3393 if (existing_group
) {
3394 if (strcmp(existing_group
->name
, peergroup
) == 0)
3398 "%% Same listen range is attached to peer-group %s\n",
3399 existing_group
->name
);
3400 return CMD_WARNING_CONFIG_FAILED
;
3404 /* Check if an overlapping listen range exists. */
3405 if (listen_range_exists(bgp
, &range
, 0)) {
3407 "%% Listen range overlaps with existing listen range\n");
3408 return CMD_WARNING_CONFIG_FAILED
;
3411 group
= peer_group_lookup(bgp
, peergroup
);
3413 vty_out(vty
, "%% Configure the peer-group first\n");
3414 return CMD_WARNING_CONFIG_FAILED
;
3417 ret
= peer_group_listen_range_add(group
, &range
);
3418 return bgp_vty_return(vty
, ret
);
3421 DEFUN (no_bgp_listen_range
,
3422 no_bgp_listen_range_cmd
,
3423 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
3425 "BGP specific commands\n"
3426 "Unconfigure BGP dynamic neighbors listen range\n"
3427 "Unconfigure BGP dynamic neighbors listen range\n"
3429 "Member of the peer-group\n"
3430 "Peer-group name\n")
3432 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3433 struct prefix range
;
3434 struct peer_group
*group
;
3439 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
3440 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
3441 char *prefix
= argv
[idx
]->arg
;
3442 argv_find(argv
, argc
, "PGNAME", &idx
);
3443 char *peergroup
= argv
[idx
]->arg
;
3445 /* Convert IP prefix string to struct prefix. */
3446 ret
= str2prefix(prefix
, &range
);
3448 vty_out(vty
, "%% Malformed listen range\n");
3449 return CMD_WARNING_CONFIG_FAILED
;
3452 afi
= family2afi(range
.family
);
3454 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
3456 "%% Malformed listen range (link-local address)\n");
3457 return CMD_WARNING_CONFIG_FAILED
;
3462 group
= peer_group_lookup(bgp
, peergroup
);
3464 vty_out(vty
, "%% Peer-group does not exist\n");
3465 return CMD_WARNING_CONFIG_FAILED
;
3468 ret
= peer_group_listen_range_del(group
, &range
);
3469 return bgp_vty_return(vty
, ret
);
3472 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
3474 struct peer_group
*group
;
3475 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
3476 struct prefix
*range
;
3478 char buf
[PREFIX2STR_BUFFER
];
3480 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
3481 vty_out(vty
, " bgp listen limit %d\n",
3482 bgp
->dynamic_neighbors_limit
);
3484 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
3485 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
3486 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
3488 prefix2str(range
, buf
, sizeof(buf
));
3490 " bgp listen range %s peer-group %s\n",
3498 DEFUN (bgp_disable_connected_route_check
,
3499 bgp_disable_connected_route_check_cmd
,
3500 "bgp disable-ebgp-connected-route-check",
3501 "BGP specific commands\n"
3502 "Disable checking if nexthop is connected on ebgp sessions\n")
3504 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3505 SET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
3506 bgp_clear_star_soft_in(vty
, bgp
->name
);
3511 DEFUN (no_bgp_disable_connected_route_check
,
3512 no_bgp_disable_connected_route_check_cmd
,
3513 "no bgp disable-ebgp-connected-route-check",
3515 "BGP specific commands\n"
3516 "Disable checking if nexthop is connected on ebgp sessions\n")
3518 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3519 UNSET_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
3520 bgp_clear_star_soft_in(vty
, bgp
->name
);
3526 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
3527 const char *as_str
, afi_t afi
, safi_t safi
)
3529 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3532 int as_type
= AS_SPECIFIED
;
3535 if (as_str
[0] == 'i') {
3537 as_type
= AS_INTERNAL
;
3538 } else if (as_str
[0] == 'e') {
3540 as_type
= AS_EXTERNAL
;
3542 /* Get AS number. */
3543 as
= strtoul(as_str
, NULL
, 10);
3546 /* If peer is peer group or interface peer, call proper function. */
3547 ret
= str2sockunion(peer_str
, &su
);
3551 /* Check if existing interface peer */
3552 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
3554 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
3557 /* if not interface peer, check peer-group settings */
3558 if (ret
< 0 && !peer
) {
3559 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
3562 "%% Create the peer-group or interface first\n");
3563 return CMD_WARNING_CONFIG_FAILED
;
3568 if (peer_address_self_check(bgp
, &su
)) {
3570 "%% Can not configure the local system as neighbor\n");
3571 return CMD_WARNING_CONFIG_FAILED
;
3573 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
3576 /* This peer belongs to peer group. */
3578 case BGP_ERR_PEER_GROUP_MEMBER
:
3580 "%% Peer-group member cannot override remote-as of peer-group\n");
3581 return CMD_WARNING_CONFIG_FAILED
;
3582 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
3584 "%% Peer-group members must be all internal or all external\n");
3585 return CMD_WARNING_CONFIG_FAILED
;
3587 return bgp_vty_return(vty
, ret
);
3590 DEFUN (bgp_default_shutdown
,
3591 bgp_default_shutdown_cmd
,
3592 "[no] bgp default shutdown",
3595 "Configure BGP defaults\n"
3596 "Apply administrative shutdown to newly configured peers\n")
3598 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3599 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
3603 DEFPY(bgp_shutdown_msg
, bgp_shutdown_msg_cmd
, "bgp shutdown message MSG...",
3605 "Enable administrative shutdown of the BGP instance\n"
3606 "Add a shutdown message (RFC 8203)\n"
3607 "Shutdown message\n")
3609 char *msgstr
= NULL
;
3611 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3614 msgstr
= argv_concat(argv
, argc
, 3);
3616 bgp_shutdown_enable(bgp
, msgstr
);
3617 XFREE(MTYPE_TMP
, msgstr
);
3622 DEFPY(bgp_shutdown
, bgp_shutdown_cmd
, "bgp shutdown",
3623 BGP_STR
"Enable administrative shutdown of the BGP instance\n")
3625 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3627 bgp_shutdown_enable(bgp
, NULL
);
3632 DEFPY(no_bgp_shutdown
, no_bgp_shutdown_cmd
, "no bgp shutdown",
3633 NO_STR BGP_STR
"Disable administrative shutdown of the BGP instance\n")
3635 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3637 bgp_shutdown_disable(bgp
);
3642 DEFPY(no_bgp_shutdown_msg
, no_bgp_shutdown_msg_cmd
,
3643 "no bgp shutdown message MSG...", NO_STR BGP_STR
3644 "Disable administrative shutdown of the BGP instance\n"
3645 "Add a shutdown message (RFC 8203)\n" "Shutdown message\n")
3647 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3649 bgp_shutdown_disable(bgp
);
3654 DEFUN (neighbor_remote_as
,
3655 neighbor_remote_as_cmd
,
3656 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
3659 "Specify a BGP neighbor\n"
3661 "Internal BGP peer\n"
3662 "External BGP peer\n")
3665 int idx_remote_as
= 3;
3666 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
3667 argv
[idx_remote_as
]->arg
, AFI_IP
,
3671 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
3672 afi_t afi
, safi_t safi
, int v6only
,
3673 const char *peer_group_name
,
3676 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3678 int as_type
= AS_UNSPECIFIED
;
3680 struct peer_group
*group
;
3684 group
= peer_group_lookup(bgp
, conf_if
);
3687 vty_out(vty
, "%% Name conflict with peer-group \n");
3688 return CMD_WARNING_CONFIG_FAILED
;
3692 if (as_str
[0] == 'i') {
3693 as_type
= AS_INTERNAL
;
3694 } else if (as_str
[0] == 'e') {
3695 as_type
= AS_EXTERNAL
;
3697 /* Get AS number. */
3698 as
= strtoul(as_str
, NULL
, 10);
3699 as_type
= AS_SPECIFIED
;
3703 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
3706 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
3709 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
)
3710 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
3711 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
3712 as_type
, 0, 0, NULL
);
3714 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
3715 as_type
, afi
, safi
, NULL
);
3718 vty_out(vty
, "%% BGP failed to create peer\n");
3719 return CMD_WARNING_CONFIG_FAILED
;
3723 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
3725 /* Request zebra to initiate IPv6 RAs on this interface. We do
3727 * any unnumbered peer in order to not worry about run-time
3729 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
3731 * gets deleted later etc.)
3734 bgp_zebra_initiate_radv(bgp
, peer
);
3737 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
3738 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
3740 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
3742 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
3744 /* v6only flag changed. Reset bgp seesion */
3745 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
3746 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
3747 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
3748 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
3750 bgp_session_reset(peer
);
3753 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
3754 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
3755 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
3756 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
3759 if (peer_group_name
) {
3760 group
= peer_group_lookup(bgp
, peer_group_name
);
3762 vty_out(vty
, "%% Configure the peer-group first\n");
3763 return CMD_WARNING_CONFIG_FAILED
;
3766 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3769 return bgp_vty_return(vty
, ret
);
3772 DEFUN (neighbor_interface_config
,
3773 neighbor_interface_config_cmd
,
3774 "neighbor WORD interface [peer-group PGNAME]",
3776 "Interface name or neighbor tag\n"
3777 "Enable BGP on interface\n"
3778 "Member of the peer-group\n"
3779 "Peer-group name\n")
3782 int idx_peer_group_word
= 4;
3784 if (argc
> idx_peer_group_word
)
3785 return peer_conf_interface_get(
3786 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
3787 argv
[idx_peer_group_word
]->arg
, NULL
);
3789 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3790 SAFI_UNICAST
, 0, NULL
, NULL
);
3793 DEFUN (neighbor_interface_config_v6only
,
3794 neighbor_interface_config_v6only_cmd
,
3795 "neighbor WORD interface v6only [peer-group PGNAME]",
3797 "Interface name or neighbor tag\n"
3798 "Enable BGP on interface\n"
3799 "Enable BGP with v6 link-local only\n"
3800 "Member of the peer-group\n"
3801 "Peer-group name\n")
3804 int idx_peer_group_word
= 5;
3806 if (argc
> idx_peer_group_word
)
3807 return peer_conf_interface_get(
3808 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
3809 argv
[idx_peer_group_word
]->arg
, NULL
);
3811 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3812 SAFI_UNICAST
, 1, NULL
, NULL
);
3816 DEFUN (neighbor_interface_config_remote_as
,
3817 neighbor_interface_config_remote_as_cmd
,
3818 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
3820 "Interface name or neighbor tag\n"
3821 "Enable BGP on interface\n"
3822 "Specify a BGP neighbor\n"
3824 "Internal BGP peer\n"
3825 "External BGP peer\n")
3828 int idx_remote_as
= 4;
3829 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3830 SAFI_UNICAST
, 0, NULL
,
3831 argv
[idx_remote_as
]->arg
);
3834 DEFUN (neighbor_interface_v6only_config_remote_as
,
3835 neighbor_interface_v6only_config_remote_as_cmd
,
3836 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
3838 "Interface name or neighbor tag\n"
3839 "Enable BGP with v6 link-local only\n"
3840 "Enable BGP on interface\n"
3841 "Specify a BGP neighbor\n"
3843 "Internal BGP peer\n"
3844 "External BGP peer\n")
3847 int idx_remote_as
= 5;
3848 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3849 SAFI_UNICAST
, 1, NULL
,
3850 argv
[idx_remote_as
]->arg
);
3853 DEFUN (neighbor_peer_group
,
3854 neighbor_peer_group_cmd
,
3855 "neighbor WORD peer-group",
3857 "Interface name or neighbor tag\n"
3858 "Configure peer-group\n")
3860 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3863 struct peer_group
*group
;
3865 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3867 vty_out(vty
, "%% Name conflict with interface: \n");
3868 return CMD_WARNING_CONFIG_FAILED
;
3871 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
3873 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
3874 return CMD_WARNING_CONFIG_FAILED
;
3882 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3886 "Specify a BGP neighbor\n"
3888 "Internal BGP peer\n"
3889 "External BGP peer\n")
3891 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3895 struct peer_group
*group
;
3899 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3901 /* look up for neighbor by interface name config. */
3902 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3904 /* Request zebra to terminate IPv6 RAs on this
3907 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3908 peer_notify_unconfig(peer
);
3913 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3915 peer_group_notify_unconfig(group
);
3916 peer_group_delete(group
);
3918 vty_out(vty
, "%% Create the peer-group first\n");
3919 return CMD_WARNING_CONFIG_FAILED
;
3922 peer
= peer_lookup(bgp
, &su
);
3924 if (peer_dynamic_neighbor(peer
)) {
3926 "%% Operation not allowed on a dynamic neighbor\n");
3927 return CMD_WARNING_CONFIG_FAILED
;
3930 other
= peer
->doppelganger
;
3932 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
3933 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3935 peer_notify_unconfig(peer
);
3937 if (other
&& other
->status
!= Deleted
) {
3938 peer_notify_unconfig(other
);
3947 DEFUN (no_neighbor_interface_config
,
3948 no_neighbor_interface_config_cmd
,
3949 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
3953 "Configure BGP on interface\n"
3954 "Enable BGP with v6 link-local only\n"
3955 "Member of the peer-group\n"
3957 "Specify a BGP neighbor\n"
3959 "Internal BGP peer\n"
3960 "External BGP peer\n")
3962 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3966 /* look up for neighbor by interface name config. */
3967 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3969 /* Request zebra to terminate IPv6 RAs on this interface. */
3971 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3972 peer_notify_unconfig(peer
);
3975 vty_out(vty
, "%% Create the bgp interface first\n");
3976 return CMD_WARNING_CONFIG_FAILED
;
3981 DEFUN (no_neighbor_peer_group
,
3982 no_neighbor_peer_group_cmd
,
3983 "no neighbor WORD peer-group",
3987 "Configure peer-group\n")
3989 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3991 struct peer_group
*group
;
3993 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3995 peer_group_notify_unconfig(group
);
3996 peer_group_delete(group
);
3998 vty_out(vty
, "%% Create the peer-group first\n");
3999 return CMD_WARNING_CONFIG_FAILED
;
4004 DEFUN (no_neighbor_interface_peer_group_remote_as
,
4005 no_neighbor_interface_peer_group_remote_as_cmd
,
4006 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
4009 "Interface name or neighbor tag\n"
4010 "Specify a BGP neighbor\n"
4012 "Internal BGP peer\n"
4013 "External BGP peer\n")
4015 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4017 struct peer_group
*group
;
4020 /* look up for neighbor by interface name config. */
4021 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
4023 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
4027 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4029 peer_group_remote_as_delete(group
);
4031 vty_out(vty
, "%% Create the peer-group or interface first\n");
4032 return CMD_WARNING_CONFIG_FAILED
;
4037 DEFUN (neighbor_local_as
,
4038 neighbor_local_as_cmd
,
4039 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
4042 "Specify a local-as number\n"
4043 "AS number used as local AS\n")
4051 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4053 return CMD_WARNING_CONFIG_FAILED
;
4055 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4056 ret
= peer_local_as_set(peer
, as
, 0, 0);
4057 return bgp_vty_return(vty
, ret
);
4060 DEFUN (neighbor_local_as_no_prepend
,
4061 neighbor_local_as_no_prepend_cmd
,
4062 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
4065 "Specify a local-as number\n"
4066 "AS number used as local AS\n"
4067 "Do not prepend local-as to updates from ebgp peers\n")
4075 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4077 return CMD_WARNING_CONFIG_FAILED
;
4079 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4080 ret
= peer_local_as_set(peer
, as
, 1, 0);
4081 return bgp_vty_return(vty
, ret
);
4084 DEFUN (neighbor_local_as_no_prepend_replace_as
,
4085 neighbor_local_as_no_prepend_replace_as_cmd
,
4086 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
4089 "Specify a local-as number\n"
4090 "AS number used as local AS\n"
4091 "Do not prepend local-as to updates from ebgp peers\n"
4092 "Do not prepend local-as to updates from ibgp peers\n")
4100 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4102 return CMD_WARNING_CONFIG_FAILED
;
4104 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
4105 ret
= peer_local_as_set(peer
, as
, 1, 1);
4106 return bgp_vty_return(vty
, ret
);
4109 DEFUN (no_neighbor_local_as
,
4110 no_neighbor_local_as_cmd
,
4111 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
4115 "Specify a local-as number\n"
4116 "AS number used as local AS\n"
4117 "Do not prepend local-as to updates from ebgp peers\n"
4118 "Do not prepend local-as to updates from ibgp peers\n")
4124 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4126 return CMD_WARNING_CONFIG_FAILED
;
4128 ret
= peer_local_as_unset(peer
);
4129 return bgp_vty_return(vty
, ret
);
4133 DEFUN (neighbor_solo
,
4135 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4138 "Solo peer - part of its own update group\n")
4144 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4146 return CMD_WARNING_CONFIG_FAILED
;
4148 ret
= update_group_adjust_soloness(peer
, 1);
4149 return bgp_vty_return(vty
, ret
);
4152 DEFUN (no_neighbor_solo
,
4153 no_neighbor_solo_cmd
,
4154 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
4158 "Solo peer - part of its own update group\n")
4164 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4166 return CMD_WARNING_CONFIG_FAILED
;
4168 ret
= update_group_adjust_soloness(peer
, 0);
4169 return bgp_vty_return(vty
, ret
);
4172 DEFUN (neighbor_password
,
4173 neighbor_password_cmd
,
4174 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
4185 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4187 return CMD_WARNING_CONFIG_FAILED
;
4189 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
4190 return bgp_vty_return(vty
, ret
);
4193 DEFUN (no_neighbor_password
,
4194 no_neighbor_password_cmd
,
4195 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
4206 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4208 return CMD_WARNING_CONFIG_FAILED
;
4210 ret
= peer_password_unset(peer
);
4211 return bgp_vty_return(vty
, ret
);
4214 DEFUN (neighbor_activate
,
4215 neighbor_activate_cmd
,
4216 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4219 "Enable the Address Family for this Neighbor\n")
4225 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4227 return CMD_WARNING_CONFIG_FAILED
;
4229 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
4230 return bgp_vty_return(vty
, ret
);
4233 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
4234 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4235 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4236 "Enable the Address Family for this Neighbor\n")
4238 DEFUN (no_neighbor_activate
,
4239 no_neighbor_activate_cmd
,
4240 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4244 "Enable the Address Family for this Neighbor\n")
4251 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4253 return CMD_WARNING_CONFIG_FAILED
;
4255 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
4256 return bgp_vty_return(vty
, ret
);
4259 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
4260 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
4261 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4262 "Enable the Address Family for this Neighbor\n")
4264 DEFUN (neighbor_set_peer_group
,
4265 neighbor_set_peer_group_cmd
,
4266 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4269 "Member of the peer-group\n"
4270 "Peer-group name\n")
4272 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4279 struct peer_group
*group
;
4281 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
4283 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
4285 vty_out(vty
, "%% Malformed address or name: %s\n",
4286 argv
[idx_peer
]->arg
);
4287 return CMD_WARNING_CONFIG_FAILED
;
4290 if (peer_address_self_check(bgp
, &su
)) {
4292 "%% Can not configure the local system as neighbor\n");
4293 return CMD_WARNING_CONFIG_FAILED
;
4296 /* Disallow for dynamic neighbor. */
4297 peer
= peer_lookup(bgp
, &su
);
4298 if (peer
&& peer_dynamic_neighbor(peer
)) {
4300 "%% Operation not allowed on a dynamic neighbor\n");
4301 return CMD_WARNING_CONFIG_FAILED
;
4305 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4307 vty_out(vty
, "%% Configure the peer-group first\n");
4308 return CMD_WARNING_CONFIG_FAILED
;
4311 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
4313 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
4315 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
4317 return CMD_WARNING_CONFIG_FAILED
;
4320 return bgp_vty_return(vty
, ret
);
4323 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
4324 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4325 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4326 "Member of the peer-group\n"
4327 "Peer-group name\n")
4329 DEFUN (no_neighbor_set_peer_group
,
4330 no_neighbor_set_peer_group_cmd
,
4331 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4335 "Member of the peer-group\n"
4336 "Peer-group name\n")
4338 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
4343 struct peer_group
*group
;
4345 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4347 return CMD_WARNING_CONFIG_FAILED
;
4349 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
4351 vty_out(vty
, "%% Configure the peer-group first\n");
4352 return CMD_WARNING_CONFIG_FAILED
;
4355 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
4356 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
4358 peer_notify_unconfig(peer
);
4359 ret
= peer_delete(peer
);
4361 return bgp_vty_return(vty
, ret
);
4364 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
4365 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
4366 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4367 "Member of the peer-group\n"
4368 "Peer-group name\n")
4370 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
4371 uint32_t flag
, int set
)
4376 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4378 return CMD_WARNING_CONFIG_FAILED
;
4381 * If 'neighbor <interface>', then this is for directly connected peers,
4382 * we should not accept disable-connected-check.
4384 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
4386 "%s is directly connected peer, cannot accept disable-connected-check\n",
4388 return CMD_WARNING_CONFIG_FAILED
;
4391 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
4392 peer_tx_shutdown_message_unset(peer
);
4395 ret
= peer_flag_set(peer
, flag
);
4397 ret
= peer_flag_unset(peer
, flag
);
4399 return bgp_vty_return(vty
, ret
);
4402 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
4404 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
4407 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
4410 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
4413 /* neighbor passive. */
4414 DEFUN (neighbor_passive
,
4415 neighbor_passive_cmd
,
4416 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
4419 "Don't send open messages to this neighbor\n")
4422 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
4425 DEFUN (no_neighbor_passive
,
4426 no_neighbor_passive_cmd
,
4427 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
4431 "Don't send open messages to this neighbor\n")
4434 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
4437 /* neighbor shutdown. */
4438 DEFUN (neighbor_shutdown_msg
,
4439 neighbor_shutdown_msg_cmd
,
4440 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
4443 "Administratively shut down this neighbor\n"
4444 "Add a shutdown message (RFC 8203)\n"
4445 "Shutdown message\n")
4451 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4455 return CMD_WARNING_CONFIG_FAILED
;
4456 message
= argv_concat(argv
, argc
, 4);
4457 peer_tx_shutdown_message_set(peer
, message
);
4458 XFREE(MTYPE_TMP
, message
);
4461 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
4464 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
4465 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
4466 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4467 "Administratively shut down this neighbor\n")
4469 DEFUN (no_neighbor_shutdown_msg
,
4470 no_neighbor_shutdown_msg_cmd
,
4471 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
4475 "Administratively shut down this neighbor\n"
4476 "Remove a shutdown message (RFC 8203)\n"
4477 "Shutdown message\n")
4481 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4482 PEER_FLAG_SHUTDOWN
);
4485 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
4486 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
4487 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4488 "Administratively shut down this neighbor\n")
4490 /* neighbor capability dynamic. */
4491 DEFUN (neighbor_capability_dynamic
,
4492 neighbor_capability_dynamic_cmd
,
4493 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
4496 "Advertise capability to the peer\n"
4497 "Advertise dynamic capability to this neighbor\n")
4500 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4501 PEER_FLAG_DYNAMIC_CAPABILITY
);
4504 DEFUN (no_neighbor_capability_dynamic
,
4505 no_neighbor_capability_dynamic_cmd
,
4506 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
4510 "Advertise capability to the peer\n"
4511 "Advertise dynamic capability to this neighbor\n")
4514 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4515 PEER_FLAG_DYNAMIC_CAPABILITY
);
4518 /* neighbor dont-capability-negotiate */
4519 DEFUN (neighbor_dont_capability_negotiate
,
4520 neighbor_dont_capability_negotiate_cmd
,
4521 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
4524 "Do not perform capability negotiation\n")
4527 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4528 PEER_FLAG_DONT_CAPABILITY
);
4531 DEFUN (no_neighbor_dont_capability_negotiate
,
4532 no_neighbor_dont_capability_negotiate_cmd
,
4533 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
4537 "Do not perform capability negotiation\n")
4540 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4541 PEER_FLAG_DONT_CAPABILITY
);
4544 /* neighbor capability extended next hop encoding */
4545 DEFUN (neighbor_capability_enhe
,
4546 neighbor_capability_enhe_cmd
,
4547 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
4550 "Advertise capability to the peer\n"
4551 "Advertise extended next-hop capability to the peer\n")
4554 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4555 PEER_FLAG_CAPABILITY_ENHE
);
4558 DEFUN (no_neighbor_capability_enhe
,
4559 no_neighbor_capability_enhe_cmd
,
4560 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
4564 "Advertise capability to the peer\n"
4565 "Advertise extended next-hop capability to the peer\n")
4568 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4569 PEER_FLAG_CAPABILITY_ENHE
);
4572 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
4573 afi_t afi
, safi_t safi
, uint32_t flag
,
4579 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4581 return CMD_WARNING_CONFIG_FAILED
;
4584 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
4586 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
4588 return bgp_vty_return(vty
, ret
);
4591 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
4592 afi_t afi
, safi_t safi
, uint32_t flag
)
4594 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
4597 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
4598 afi_t afi
, safi_t safi
, uint32_t flag
)
4600 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
4603 /* neighbor capability orf prefix-list. */
4604 DEFUN (neighbor_capability_orf_prefix
,
4605 neighbor_capability_orf_prefix_cmd
,
4606 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
4609 "Advertise capability to the peer\n"
4610 "Advertise ORF capability to the peer\n"
4611 "Advertise prefixlist ORF capability to this neighbor\n"
4612 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
4613 "Capability to RECEIVE the ORF from this neighbor\n"
4614 "Capability to SEND the ORF to this neighbor\n")
4616 int idx_send_recv
= 5;
4617 char *peer_str
= argv
[1]->arg
;
4619 afi_t afi
= bgp_node_afi(vty
);
4620 safi_t safi
= bgp_node_safi(vty
);
4622 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4624 return CMD_WARNING_CONFIG_FAILED
;
4626 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
4627 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
4628 PEER_FLAG_ORF_PREFIX_SM
);
4630 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
4631 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
4632 PEER_FLAG_ORF_PREFIX_RM
);
4634 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
4635 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
4636 PEER_FLAG_ORF_PREFIX_SM
)
4637 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
4638 PEER_FLAG_ORF_PREFIX_RM
);
4640 return CMD_WARNING_CONFIG_FAILED
;
4644 neighbor_capability_orf_prefix
,
4645 neighbor_capability_orf_prefix_hidden_cmd
,
4646 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
4647 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4648 "Advertise capability to the peer\n"
4649 "Advertise ORF capability to the peer\n"
4650 "Advertise prefixlist ORF capability to this neighbor\n"
4651 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
4652 "Capability to RECEIVE the ORF from this neighbor\n"
4653 "Capability to SEND the ORF to this neighbor\n")
4655 DEFUN (no_neighbor_capability_orf_prefix
,
4656 no_neighbor_capability_orf_prefix_cmd
,
4657 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
4661 "Advertise capability to the peer\n"
4662 "Advertise ORF capability to the peer\n"
4663 "Advertise prefixlist ORF capability to this neighbor\n"
4664 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
4665 "Capability to RECEIVE the ORF from this neighbor\n"
4666 "Capability to SEND the ORF to this neighbor\n")
4668 int idx_send_recv
= 6;
4669 char *peer_str
= argv
[2]->arg
;
4671 afi_t afi
= bgp_node_afi(vty
);
4672 safi_t safi
= bgp_node_safi(vty
);
4674 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4676 return CMD_WARNING_CONFIG_FAILED
;
4678 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
4679 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4680 PEER_FLAG_ORF_PREFIX_SM
);
4682 if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
4683 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4684 PEER_FLAG_ORF_PREFIX_RM
);
4686 if (strmatch(argv
[idx_send_recv
]->text
, "both"))
4687 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4688 PEER_FLAG_ORF_PREFIX_SM
)
4689 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4690 PEER_FLAG_ORF_PREFIX_RM
);
4692 return CMD_WARNING_CONFIG_FAILED
;
4696 no_neighbor_capability_orf_prefix
,
4697 no_neighbor_capability_orf_prefix_hidden_cmd
,
4698 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
4699 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4700 "Advertise capability to the peer\n"
4701 "Advertise ORF capability to the peer\n"
4702 "Advertise prefixlist ORF capability to this neighbor\n"
4703 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
4704 "Capability to RECEIVE the ORF from this neighbor\n"
4705 "Capability to SEND the ORF to this neighbor\n")
4707 /* neighbor next-hop-self. */
4708 DEFUN (neighbor_nexthop_self
,
4709 neighbor_nexthop_self_cmd
,
4710 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4713 "Disable the next hop calculation for this neighbor\n")
4716 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4717 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
4720 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
4721 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4722 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4723 "Disable the next hop calculation for this neighbor\n")
4725 /* neighbor next-hop-self. */
4726 DEFUN (neighbor_nexthop_self_force
,
4727 neighbor_nexthop_self_force_cmd
,
4728 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4731 "Disable the next hop calculation for this neighbor\n"
4732 "Set the next hop to self for reflected routes\n")
4735 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4737 PEER_FLAG_FORCE_NEXTHOP_SELF
);
4740 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
4741 neighbor_nexthop_self_force_hidden_cmd
,
4742 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4743 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4744 "Disable the next hop calculation for this neighbor\n"
4745 "Set the next hop to self for reflected routes\n")
4747 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
4748 neighbor_nexthop_self_all_hidden_cmd
,
4749 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
4750 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4751 "Disable the next hop calculation for this neighbor\n"
4752 "Set the next hop to self for reflected routes\n")
4754 DEFUN (no_neighbor_nexthop_self
,
4755 no_neighbor_nexthop_self_cmd
,
4756 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4760 "Disable the next hop calculation for this neighbor\n")
4763 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4764 bgp_node_afi(vty
), bgp_node_safi(vty
),
4765 PEER_FLAG_NEXTHOP_SELF
);
4768 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
4769 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4770 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4771 "Disable the next hop calculation for this neighbor\n")
4773 DEFUN (no_neighbor_nexthop_self_force
,
4774 no_neighbor_nexthop_self_force_cmd
,
4775 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4779 "Disable the next hop calculation for this neighbor\n"
4780 "Set the next hop to self for reflected routes\n")
4783 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4784 bgp_node_afi(vty
), bgp_node_safi(vty
),
4785 PEER_FLAG_FORCE_NEXTHOP_SELF
);
4788 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4789 no_neighbor_nexthop_self_force_hidden_cmd
,
4790 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4791 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4792 "Disable the next hop calculation for this neighbor\n"
4793 "Set the next hop to self for reflected routes\n")
4795 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4796 no_neighbor_nexthop_self_all_hidden_cmd
,
4797 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
4798 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4799 "Disable the next hop calculation for this neighbor\n"
4800 "Set the next hop to self for reflected routes\n")
4802 /* neighbor as-override */
4803 DEFUN (neighbor_as_override
,
4804 neighbor_as_override_cmd
,
4805 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4808 "Override ASNs in outbound updates if aspath equals remote-as\n")
4811 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4812 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
4815 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
4816 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4817 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4818 "Override ASNs in outbound updates if aspath equals remote-as\n")
4820 DEFUN (no_neighbor_as_override
,
4821 no_neighbor_as_override_cmd
,
4822 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4826 "Override ASNs in outbound updates if aspath equals remote-as\n")
4829 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4830 bgp_node_afi(vty
), bgp_node_safi(vty
),
4831 PEER_FLAG_AS_OVERRIDE
);
4834 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
4835 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4836 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4837 "Override ASNs in outbound updates if aspath equals remote-as\n")
4839 /* neighbor remove-private-AS. */
4840 DEFUN (neighbor_remove_private_as
,
4841 neighbor_remove_private_as_cmd
,
4842 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4845 "Remove private ASNs in outbound updates\n")
4848 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4850 PEER_FLAG_REMOVE_PRIVATE_AS
);
4853 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
4854 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4855 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4856 "Remove private ASNs in outbound updates\n")
4858 DEFUN (neighbor_remove_private_as_all
,
4859 neighbor_remove_private_as_all_cmd
,
4860 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4863 "Remove private ASNs in outbound updates\n"
4864 "Apply to all AS numbers\n")
4867 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4869 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4872 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
4873 neighbor_remove_private_as_all_hidden_cmd
,
4874 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4875 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4876 "Remove private ASNs in outbound updates\n"
4877 "Apply to all AS numbers")
4879 DEFUN (neighbor_remove_private_as_replace_as
,
4880 neighbor_remove_private_as_replace_as_cmd
,
4881 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4884 "Remove private ASNs in outbound updates\n"
4885 "Replace private ASNs with our ASN in outbound updates\n")
4888 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4890 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4893 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
4894 neighbor_remove_private_as_replace_as_hidden_cmd
,
4895 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4896 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4897 "Remove private ASNs in outbound updates\n"
4898 "Replace private ASNs with our ASN in outbound updates\n")
4900 DEFUN (neighbor_remove_private_as_all_replace_as
,
4901 neighbor_remove_private_as_all_replace_as_cmd
,
4902 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4905 "Remove private ASNs in outbound updates\n"
4906 "Apply to all AS numbers\n"
4907 "Replace private ASNs with our ASN in outbound updates\n")
4910 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4912 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4916 neighbor_remove_private_as_all_replace_as
,
4917 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4918 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4919 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4920 "Remove private ASNs in outbound updates\n"
4921 "Apply to all AS numbers\n"
4922 "Replace private ASNs with our ASN in outbound updates\n")
4924 DEFUN (no_neighbor_remove_private_as
,
4925 no_neighbor_remove_private_as_cmd
,
4926 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4930 "Remove private ASNs in outbound updates\n")
4933 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4934 bgp_node_afi(vty
), bgp_node_safi(vty
),
4935 PEER_FLAG_REMOVE_PRIVATE_AS
);
4938 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4939 no_neighbor_remove_private_as_hidden_cmd
,
4940 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4941 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4942 "Remove private ASNs in outbound updates\n")
4944 DEFUN (no_neighbor_remove_private_as_all
,
4945 no_neighbor_remove_private_as_all_cmd
,
4946 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4950 "Remove private ASNs in outbound updates\n"
4951 "Apply to all AS numbers\n")
4954 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4955 bgp_node_afi(vty
), bgp_node_safi(vty
),
4956 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4959 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4960 no_neighbor_remove_private_as_all_hidden_cmd
,
4961 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4962 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4963 "Remove private ASNs in outbound updates\n"
4964 "Apply to all AS numbers\n")
4966 DEFUN (no_neighbor_remove_private_as_replace_as
,
4967 no_neighbor_remove_private_as_replace_as_cmd
,
4968 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4972 "Remove private ASNs in outbound updates\n"
4973 "Replace private ASNs with our ASN in outbound updates\n")
4976 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4977 bgp_node_afi(vty
), bgp_node_safi(vty
),
4978 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4981 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4982 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4983 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4984 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4985 "Remove private ASNs in outbound updates\n"
4986 "Replace private ASNs with our ASN in outbound updates\n")
4988 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4989 no_neighbor_remove_private_as_all_replace_as_cmd
,
4990 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4994 "Remove private ASNs in outbound updates\n"
4995 "Apply to all AS numbers\n"
4996 "Replace private ASNs with our ASN in outbound updates\n")
4999 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5000 bgp_node_afi(vty
), bgp_node_safi(vty
),
5001 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
5005 no_neighbor_remove_private_as_all_replace_as
,
5006 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
5007 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
5008 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5009 "Remove private ASNs in outbound updates\n"
5010 "Apply to all AS numbers\n"
5011 "Replace private ASNs with our ASN in outbound updates\n")
5014 /* neighbor send-community. */
5015 DEFUN (neighbor_send_community
,
5016 neighbor_send_community_cmd
,
5017 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5020 "Send Community attribute to this neighbor\n")
5024 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5026 PEER_FLAG_SEND_COMMUNITY
);
5029 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
5030 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5031 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5032 "Send Community attribute to this neighbor\n")
5034 DEFUN (no_neighbor_send_community
,
5035 no_neighbor_send_community_cmd
,
5036 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5040 "Send Community attribute to this neighbor\n")
5044 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5045 bgp_node_afi(vty
), bgp_node_safi(vty
),
5046 PEER_FLAG_SEND_COMMUNITY
);
5049 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
5050 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
5051 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5052 "Send Community attribute to this neighbor\n")
5054 /* neighbor send-community extended. */
5055 DEFUN (neighbor_send_community_type
,
5056 neighbor_send_community_type_cmd
,
5057 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5060 "Send Community attribute to this neighbor\n"
5061 "Send Standard and Extended Community attributes\n"
5062 "Send Standard, Large and Extended Community attributes\n"
5063 "Send Extended Community attributes\n"
5064 "Send Standard Community attributes\n"
5065 "Send Large Community attributes\n")
5067 const char *type
= argv
[argc
- 1]->text
;
5068 char *peer_str
= argv
[1]->arg
;
5070 afi_t afi
= bgp_node_afi(vty
);
5071 safi_t safi
= bgp_node_safi(vty
);
5073 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5075 return CMD_WARNING_CONFIG_FAILED
;
5077 if (strmatch(type
, "standard"))
5078 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5079 PEER_FLAG_SEND_COMMUNITY
);
5081 if (strmatch(type
, "extended"))
5082 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5083 PEER_FLAG_SEND_EXT_COMMUNITY
);
5085 if (strmatch(type
, "large"))
5086 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5087 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5089 if (strmatch(type
, "both")) {
5090 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5091 PEER_FLAG_SEND_COMMUNITY
)
5092 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5093 PEER_FLAG_SEND_EXT_COMMUNITY
);
5095 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5096 PEER_FLAG_SEND_COMMUNITY
)
5097 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5098 PEER_FLAG_SEND_EXT_COMMUNITY
)
5099 | peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5100 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5104 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
5105 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5106 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5107 "Send Community attribute to this neighbor\n"
5108 "Send Standard and Extended Community attributes\n"
5109 "Send Standard, Large and Extended Community attributes\n"
5110 "Send Extended Community attributes\n"
5111 "Send Standard Community attributes\n"
5112 "Send Large Community attributes\n")
5114 DEFUN (no_neighbor_send_community_type
,
5115 no_neighbor_send_community_type_cmd
,
5116 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5120 "Send Community attribute to this neighbor\n"
5121 "Send Standard and Extended Community attributes\n"
5122 "Send Standard, Large and Extended Community attributes\n"
5123 "Send Extended Community attributes\n"
5124 "Send Standard Community attributes\n"
5125 "Send Large Community attributes\n")
5127 const char *type
= argv
[argc
- 1]->text
;
5128 char *peer_str
= argv
[2]->arg
;
5130 afi_t afi
= bgp_node_afi(vty
);
5131 safi_t safi
= bgp_node_safi(vty
);
5133 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5135 return CMD_WARNING_CONFIG_FAILED
;
5137 if (strmatch(type
, "standard"))
5138 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5139 PEER_FLAG_SEND_COMMUNITY
);
5141 if (strmatch(type
, "extended"))
5142 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5143 PEER_FLAG_SEND_EXT_COMMUNITY
);
5145 if (strmatch(type
, "large"))
5146 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5147 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5149 if (strmatch(type
, "both")) {
5151 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5152 PEER_FLAG_SEND_COMMUNITY
)
5153 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5154 PEER_FLAG_SEND_EXT_COMMUNITY
);
5157 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5158 PEER_FLAG_SEND_COMMUNITY
)
5159 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5160 PEER_FLAG_SEND_EXT_COMMUNITY
)
5161 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5162 PEER_FLAG_SEND_LARGE_COMMUNITY
);
5166 no_neighbor_send_community_type
,
5167 no_neighbor_send_community_type_hidden_cmd
,
5168 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
5169 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5170 "Send Community attribute to this neighbor\n"
5171 "Send Standard and Extended Community attributes\n"
5172 "Send Standard, Large and Extended Community attributes\n"
5173 "Send Extended Community attributes\n"
5174 "Send Standard Community attributes\n"
5175 "Send Large Community attributes\n")
5177 /* neighbor soft-reconfig. */
5178 DEFUN (neighbor_soft_reconfiguration
,
5179 neighbor_soft_reconfiguration_cmd
,
5180 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5183 "Per neighbor soft reconfiguration\n"
5184 "Allow inbound soft reconfiguration for this neighbor\n")
5187 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5189 PEER_FLAG_SOFT_RECONFIG
);
5192 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
5193 neighbor_soft_reconfiguration_hidden_cmd
,
5194 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5195 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5196 "Per neighbor soft reconfiguration\n"
5197 "Allow inbound soft reconfiguration for this neighbor\n")
5199 DEFUN (no_neighbor_soft_reconfiguration
,
5200 no_neighbor_soft_reconfiguration_cmd
,
5201 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5205 "Per neighbor soft reconfiguration\n"
5206 "Allow inbound soft reconfiguration for this neighbor\n")
5209 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5210 bgp_node_afi(vty
), bgp_node_safi(vty
),
5211 PEER_FLAG_SOFT_RECONFIG
);
5214 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
5215 no_neighbor_soft_reconfiguration_hidden_cmd
,
5216 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
5217 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5218 "Per neighbor soft reconfiguration\n"
5219 "Allow inbound soft reconfiguration for this neighbor\n")
5221 DEFUN (neighbor_route_reflector_client
,
5222 neighbor_route_reflector_client_cmd
,
5223 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5226 "Configure a neighbor as Route Reflector client\n")
5232 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5234 return CMD_WARNING_CONFIG_FAILED
;
5236 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5238 PEER_FLAG_REFLECTOR_CLIENT
);
5241 ALIAS_HIDDEN(neighbor_route_reflector_client
,
5242 neighbor_route_reflector_client_hidden_cmd
,
5243 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5244 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5245 "Configure a neighbor as Route Reflector client\n")
5247 DEFUN (no_neighbor_route_reflector_client
,
5248 no_neighbor_route_reflector_client_cmd
,
5249 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5253 "Configure a neighbor as Route Reflector client\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_REFLECTOR_CLIENT
);
5261 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
5262 no_neighbor_route_reflector_client_hidden_cmd
,
5263 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
5264 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5265 "Configure a neighbor as Route Reflector client\n")
5267 /* neighbor route-server-client. */
5268 DEFUN (neighbor_route_server_client
,
5269 neighbor_route_server_client_cmd
,
5270 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5273 "Configure a neighbor as Route Server client\n")
5278 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5280 return CMD_WARNING_CONFIG_FAILED
;
5281 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5283 PEER_FLAG_RSERVER_CLIENT
);
5286 ALIAS_HIDDEN(neighbor_route_server_client
,
5287 neighbor_route_server_client_hidden_cmd
,
5288 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5289 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5290 "Configure a neighbor as Route Server client\n")
5292 DEFUN (no_neighbor_route_server_client
,
5293 no_neighbor_route_server_client_cmd
,
5294 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5298 "Configure a neighbor as Route Server client\n")
5301 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5302 bgp_node_afi(vty
), bgp_node_safi(vty
),
5303 PEER_FLAG_RSERVER_CLIENT
);
5306 ALIAS_HIDDEN(no_neighbor_route_server_client
,
5307 no_neighbor_route_server_client_hidden_cmd
,
5308 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
5309 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5310 "Configure a neighbor as Route Server client\n")
5312 DEFUN (neighbor_nexthop_local_unchanged
,
5313 neighbor_nexthop_local_unchanged_cmd
,
5314 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
5317 "Configure treatment of outgoing link-local nexthop attribute\n"
5318 "Leave link-local nexthop unchanged for this peer\n")
5321 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5323 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
5326 DEFUN (no_neighbor_nexthop_local_unchanged
,
5327 no_neighbor_nexthop_local_unchanged_cmd
,
5328 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
5332 "Configure treatment of outgoing link-local-nexthop attribute\n"
5333 "Leave link-local nexthop unchanged for this peer\n")
5336 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5337 bgp_node_afi(vty
), bgp_node_safi(vty
),
5338 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
5341 DEFUN (neighbor_attr_unchanged
,
5342 neighbor_attr_unchanged_cmd
,
5343 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
5346 "BGP attribute is propagated unchanged to this neighbor\n"
5347 "As-path attribute\n"
5348 "Nexthop attribute\n"
5352 char *peer_str
= argv
[1]->arg
;
5354 bool aspath
= false;
5355 bool nexthop
= false;
5357 afi_t afi
= bgp_node_afi(vty
);
5358 safi_t safi
= bgp_node_safi(vty
);
5361 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5363 return CMD_WARNING_CONFIG_FAILED
;
5365 if (argv_find(argv
, argc
, "as-path", &idx
))
5369 if (argv_find(argv
, argc
, "next-hop", &idx
))
5373 if (argv_find(argv
, argc
, "med", &idx
))
5376 /* no flags means all of them! */
5377 if (!aspath
&& !nexthop
&& !med
) {
5378 ret
= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5379 PEER_FLAG_AS_PATH_UNCHANGED
);
5380 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5381 PEER_FLAG_NEXTHOP_UNCHANGED
);
5382 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5383 PEER_FLAG_MED_UNCHANGED
);
5386 if (peer_af_flag_check(peer
, afi
, safi
,
5387 PEER_FLAG_AS_PATH_UNCHANGED
)) {
5388 ret
|= peer_af_flag_unset_vty(
5389 vty
, peer_str
, afi
, safi
,
5390 PEER_FLAG_AS_PATH_UNCHANGED
);
5393 ret
|= peer_af_flag_set_vty(
5394 vty
, peer_str
, afi
, safi
,
5395 PEER_FLAG_AS_PATH_UNCHANGED
);
5398 if (peer_af_flag_check(peer
, afi
, safi
,
5399 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
5400 ret
|= peer_af_flag_unset_vty(
5401 vty
, peer_str
, afi
, safi
,
5402 PEER_FLAG_NEXTHOP_UNCHANGED
);
5405 ret
|= peer_af_flag_set_vty(
5406 vty
, peer_str
, afi
, safi
,
5407 PEER_FLAG_NEXTHOP_UNCHANGED
);
5410 if (peer_af_flag_check(peer
, afi
, safi
,
5411 PEER_FLAG_MED_UNCHANGED
)) {
5412 ret
|= peer_af_flag_unset_vty(
5413 vty
, peer_str
, afi
, safi
,
5414 PEER_FLAG_MED_UNCHANGED
);
5417 ret
|= peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
,
5418 PEER_FLAG_MED_UNCHANGED
);
5425 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
5426 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
5427 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5428 "BGP attribute is propagated unchanged to this neighbor\n"
5429 "As-path attribute\n"
5430 "Nexthop attribute\n"
5433 DEFUN (no_neighbor_attr_unchanged
,
5434 no_neighbor_attr_unchanged_cmd
,
5435 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
5439 "BGP attribute is propagated unchanged to this neighbor\n"
5440 "As-path attribute\n"
5441 "Nexthop attribute\n"
5445 char *peer_str
= argv
[2]->arg
;
5447 bool aspath
= false;
5448 bool nexthop
= false;
5450 afi_t afi
= bgp_node_afi(vty
);
5451 safi_t safi
= bgp_node_safi(vty
);
5454 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5456 return CMD_WARNING_CONFIG_FAILED
;
5458 if (argv_find(argv
, argc
, "as-path", &idx
))
5462 if (argv_find(argv
, argc
, "next-hop", &idx
))
5466 if (argv_find(argv
, argc
, "med", &idx
))
5469 if (!aspath
&& !nexthop
&& !med
) // no flags means all of them!
5470 return peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5471 PEER_FLAG_AS_PATH_UNCHANGED
)
5472 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5473 PEER_FLAG_NEXTHOP_UNCHANGED
)
5474 | peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5475 PEER_FLAG_MED_UNCHANGED
);
5478 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5479 PEER_FLAG_AS_PATH_UNCHANGED
);
5482 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5483 PEER_FLAG_NEXTHOP_UNCHANGED
);
5486 ret
|= peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
5487 PEER_FLAG_MED_UNCHANGED
);
5493 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
5494 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
5495 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5496 "BGP attribute is propagated unchanged to this neighbor\n"
5497 "As-path attribute\n"
5498 "Nexthop attribute\n"
5501 /* EBGP multihop configuration. */
5502 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
5503 const char *ttl_str
)
5508 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5510 return CMD_WARNING_CONFIG_FAILED
;
5513 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
5518 ttl
= strtoul(ttl_str
, NULL
, 10);
5520 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
5523 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
5527 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5529 return CMD_WARNING_CONFIG_FAILED
;
5531 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
5534 /* neighbor ebgp-multihop. */
5535 DEFUN (neighbor_ebgp_multihop
,
5536 neighbor_ebgp_multihop_cmd
,
5537 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
5540 "Allow EBGP neighbors not on directly connected networks\n")
5543 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5546 DEFUN (neighbor_ebgp_multihop_ttl
,
5547 neighbor_ebgp_multihop_ttl_cmd
,
5548 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
5551 "Allow EBGP neighbors not on directly connected networks\n"
5552 "maximum hop count\n")
5556 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
5557 argv
[idx_number
]->arg
);
5560 DEFUN (no_neighbor_ebgp_multihop
,
5561 no_neighbor_ebgp_multihop_cmd
,
5562 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
5566 "Allow EBGP neighbors not on directly connected networks\n"
5567 "maximum hop count\n")
5570 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
5574 /* disable-connected-check */
5575 DEFUN (neighbor_disable_connected_check
,
5576 neighbor_disable_connected_check_cmd
,
5577 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
5580 "one-hop away EBGP peer using loopback address\n"
5581 "Enforce EBGP neighbors perform multihop\n")
5584 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5585 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
5588 DEFUN (no_neighbor_disable_connected_check
,
5589 no_neighbor_disable_connected_check_cmd
,
5590 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
5594 "one-hop away EBGP peer using loopback address\n"
5595 "Enforce EBGP neighbors perform multihop\n")
5598 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5599 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
5603 /* enforce-first-as */
5604 DEFUN (neighbor_enforce_first_as
,
5605 neighbor_enforce_first_as_cmd
,
5606 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
5609 "Enforce the first AS for EBGP routes\n")
5613 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5614 PEER_FLAG_ENFORCE_FIRST_AS
);
5617 DEFUN (no_neighbor_enforce_first_as
,
5618 no_neighbor_enforce_first_as_cmd
,
5619 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
5623 "Enforce the first AS for EBGP routes\n")
5627 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5628 PEER_FLAG_ENFORCE_FIRST_AS
);
5632 DEFUN (neighbor_description
,
5633 neighbor_description_cmd
,
5634 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
5637 "Neighbor specific description\n"
5638 "Up to 80 characters describing this neighbor\n")
5645 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5647 return CMD_WARNING_CONFIG_FAILED
;
5649 str
= argv_concat(argv
, argc
, idx_line
);
5651 peer_description_set(peer
, str
);
5653 XFREE(MTYPE_TMP
, str
);
5658 DEFUN (no_neighbor_description
,
5659 no_neighbor_description_cmd
,
5660 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
5664 "Neighbor specific description\n")
5669 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5671 return CMD_WARNING_CONFIG_FAILED
;
5673 peer_description_unset(peer
);
5678 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
5679 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
5680 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5681 "Neighbor specific description\n"
5682 "Up to 80 characters describing this neighbor\n")
5684 /* Neighbor update-source. */
5685 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
5686 const char *source_str
)
5692 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5694 return CMD_WARNING_CONFIG_FAILED
;
5700 if (str2sockunion(source_str
, &su
) == 0)
5701 peer_update_source_addr_set(peer
, &su
);
5703 if (str2prefix(source_str
, &p
)) {
5705 "%% Invalid update-source, remove prefix length \n");
5706 return CMD_WARNING_CONFIG_FAILED
;
5708 peer_update_source_if_set(peer
, source_str
);
5711 peer_update_source_unset(peer
);
5716 #define BGP_UPDATE_SOURCE_HELP_STR \
5719 "Interface name (requires zebra to be running)\n"
5721 DEFUN (neighbor_update_source
,
5722 neighbor_update_source_cmd
,
5723 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
5726 "Source of routing updates\n"
5727 BGP_UPDATE_SOURCE_HELP_STR
)
5731 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
5732 argv
[idx_peer_2
]->arg
);
5735 DEFUN (no_neighbor_update_source
,
5736 no_neighbor_update_source_cmd
,
5737 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
5741 "Source of routing updates\n"
5742 BGP_UPDATE_SOURCE_HELP_STR
)
5745 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5748 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
5749 afi_t afi
, safi_t safi
,
5750 const char *rmap
, int set
)
5754 struct route_map
*route_map
= NULL
;
5756 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
5758 return CMD_WARNING_CONFIG_FAILED
;
5762 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
5763 ret
= peer_default_originate_set(peer
, afi
, safi
,
5766 ret
= peer_default_originate_unset(peer
, afi
, safi
);
5768 return bgp_vty_return(vty
, ret
);
5771 /* neighbor default-originate. */
5772 DEFUN (neighbor_default_originate
,
5773 neighbor_default_originate_cmd
,
5774 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
5777 "Originate default route to this neighbor\n")
5780 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
5782 bgp_node_safi(vty
), NULL
, 1);
5785 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
5786 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
5787 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5788 "Originate default route to this neighbor\n")
5790 DEFUN (neighbor_default_originate_rmap
,
5791 neighbor_default_originate_rmap_cmd
,
5792 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
5795 "Originate default route to this neighbor\n"
5796 "Route-map to specify criteria to originate default\n"
5801 return peer_default_originate_set_vty(
5802 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5803 argv
[idx_word
]->arg
, 1);
5807 neighbor_default_originate_rmap
,
5808 neighbor_default_originate_rmap_hidden_cmd
,
5809 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
5810 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5811 "Originate default route to this neighbor\n"
5812 "Route-map to specify criteria to originate default\n"
5815 DEFUN (no_neighbor_default_originate
,
5816 no_neighbor_default_originate_cmd
,
5817 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
5821 "Originate default route to this neighbor\n"
5822 "Route-map to specify criteria to originate default\n"
5826 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
5828 bgp_node_safi(vty
), NULL
, 0);
5832 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
5833 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
5834 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5835 "Originate default route to this neighbor\n"
5836 "Route-map to specify criteria to originate default\n"
5840 /* Set neighbor's BGP port. */
5841 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
5842 const char *port_str
)
5848 peer
= peer_lookup_vty(vty
, ip_str
);
5850 return CMD_WARNING_CONFIG_FAILED
;
5853 sp
= getservbyname("bgp", "tcp");
5854 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
5856 port
= strtoul(port_str
, NULL
, 10);
5859 peer_port_set(peer
, port
);
5864 /* Set specified peer's BGP port. */
5865 DEFUN (neighbor_port
,
5867 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
5870 "Neighbor's BGP port\n"
5871 "TCP port number\n")
5875 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
5876 argv
[idx_number
]->arg
);
5879 DEFUN (no_neighbor_port
,
5880 no_neighbor_port_cmd
,
5881 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
5885 "Neighbor's BGP port\n"
5886 "TCP port number\n")
5889 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
5893 /* neighbor weight. */
5894 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5895 safi_t safi
, const char *weight_str
)
5899 unsigned long weight
;
5901 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5903 return CMD_WARNING_CONFIG_FAILED
;
5905 weight
= strtoul(weight_str
, NULL
, 10);
5907 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
5908 return bgp_vty_return(vty
, ret
);
5911 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5917 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5919 return CMD_WARNING_CONFIG_FAILED
;
5921 ret
= peer_weight_unset(peer
, afi
, safi
);
5922 return bgp_vty_return(vty
, ret
);
5925 DEFUN (neighbor_weight
,
5926 neighbor_weight_cmd
,
5927 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5930 "Set default weight for routes from this neighbor\n"
5935 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5936 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
5939 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
5940 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5941 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5942 "Set default weight for routes from this neighbor\n"
5945 DEFUN (no_neighbor_weight
,
5946 no_neighbor_weight_cmd
,
5947 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5951 "Set default weight for routes from this neighbor\n"
5955 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
5956 bgp_node_afi(vty
), bgp_node_safi(vty
));
5959 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
5960 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5961 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5962 "Set default weight for routes from this neighbor\n"
5966 /* Override capability negotiation. */
5967 DEFUN (neighbor_override_capability
,
5968 neighbor_override_capability_cmd
,
5969 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5972 "Override capability negotiation result\n")
5975 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5976 PEER_FLAG_OVERRIDE_CAPABILITY
);
5979 DEFUN (no_neighbor_override_capability
,
5980 no_neighbor_override_capability_cmd
,
5981 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5985 "Override capability negotiation result\n")
5988 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5989 PEER_FLAG_OVERRIDE_CAPABILITY
);
5992 DEFUN (neighbor_strict_capability
,
5993 neighbor_strict_capability_cmd
,
5994 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5997 "Strict capability negotiation match\n")
6001 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
6002 PEER_FLAG_STRICT_CAP_MATCH
);
6005 DEFUN (no_neighbor_strict_capability
,
6006 no_neighbor_strict_capability_cmd
,
6007 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
6011 "Strict capability negotiation match\n")
6015 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6016 PEER_FLAG_STRICT_CAP_MATCH
);
6019 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
6020 const char *keep_str
, const char *hold_str
)
6027 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6029 return CMD_WARNING_CONFIG_FAILED
;
6031 keepalive
= strtoul(keep_str
, NULL
, 10);
6032 holdtime
= strtoul(hold_str
, NULL
, 10);
6034 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
6036 return bgp_vty_return(vty
, ret
);
6039 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
6044 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6046 return CMD_WARNING_CONFIG_FAILED
;
6048 ret
= peer_timers_unset(peer
);
6050 return bgp_vty_return(vty
, ret
);
6053 DEFUN (neighbor_timers
,
6054 neighbor_timers_cmd
,
6055 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
6058 "BGP per neighbor timers\n"
6059 "Keepalive interval\n"
6064 int idx_number_2
= 4;
6065 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
6066 argv
[idx_number
]->arg
,
6067 argv
[idx_number_2
]->arg
);
6070 DEFUN (no_neighbor_timers
,
6071 no_neighbor_timers_cmd
,
6072 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
6076 "BGP per neighbor timers\n"
6077 "Keepalive interval\n"
6081 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
6085 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
6086 const char *time_str
)
6092 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6094 return CMD_WARNING_CONFIG_FAILED
;
6096 connect
= strtoul(time_str
, NULL
, 10);
6098 ret
= peer_timers_connect_set(peer
, connect
);
6100 return bgp_vty_return(vty
, ret
);
6103 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
6108 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6110 return CMD_WARNING_CONFIG_FAILED
;
6112 ret
= peer_timers_connect_unset(peer
);
6114 return bgp_vty_return(vty
, ret
);
6117 DEFUN (neighbor_timers_connect
,
6118 neighbor_timers_connect_cmd
,
6119 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
6122 "BGP per neighbor timers\n"
6123 "BGP connect timer\n"
6128 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
6129 argv
[idx_number
]->arg
);
6132 DEFUN (no_neighbor_timers_connect
,
6133 no_neighbor_timers_connect_cmd
,
6134 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
6138 "BGP per neighbor timers\n"
6139 "BGP connect timer\n"
6143 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
6147 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
6148 const char *time_str
, int set
)
6152 uint32_t routeadv
= 0;
6154 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6156 return CMD_WARNING_CONFIG_FAILED
;
6159 routeadv
= strtoul(time_str
, NULL
, 10);
6162 ret
= peer_advertise_interval_set(peer
, routeadv
);
6164 ret
= peer_advertise_interval_unset(peer
);
6166 return bgp_vty_return(vty
, ret
);
6169 DEFUN (neighbor_advertise_interval
,
6170 neighbor_advertise_interval_cmd
,
6171 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
6174 "Minimum interval between sending BGP routing updates\n"
6175 "time in seconds\n")
6179 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
6180 argv
[idx_number
]->arg
, 1);
6183 DEFUN (no_neighbor_advertise_interval
,
6184 no_neighbor_advertise_interval_cmd
,
6185 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
6189 "Minimum interval between sending BGP routing updates\n"
6190 "time in seconds\n")
6193 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
6197 /* Time to wait before processing route-map updates */
6198 DEFUN (bgp_set_route_map_delay_timer
,
6199 bgp_set_route_map_delay_timer_cmd
,
6200 "bgp route-map delay-timer (0-600)",
6202 "BGP route-map delay timer\n"
6203 "Time in secs to wait before processing route-map changes\n"
6204 "0 disables the timer, no route updates happen when route-maps change\n")
6207 uint32_t rmap_delay_timer
;
6209 if (argv
[idx_number
]->arg
) {
6210 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6211 bm
->rmap_update_timer
= rmap_delay_timer
;
6213 /* if the dynamic update handling is being disabled, and a timer
6215 * running, stop the timer and act as if the timer has already
6218 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
6219 BGP_TIMER_OFF(bm
->t_rmap_update
);
6220 thread_execute(bm
->master
, bgp_route_map_update_timer
,
6225 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
6226 return CMD_WARNING_CONFIG_FAILED
;
6230 DEFUN (no_bgp_set_route_map_delay_timer
,
6231 no_bgp_set_route_map_delay_timer_cmd
,
6232 "no bgp route-map delay-timer [(0-600)]",
6235 "Default BGP route-map delay timer\n"
6236 "Reset to default time to wait for processing route-map changes\n"
6237 "0 disables the timer, no route updates happen when route-maps change\n")
6240 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
6246 /* neighbor interface */
6247 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
6252 peer
= peer_lookup_vty(vty
, ip_str
);
6253 if (!peer
|| peer
->conf_if
) {
6254 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
6255 return CMD_WARNING_CONFIG_FAILED
;
6259 peer_interface_set(peer
, str
);
6261 peer_interface_unset(peer
);
6266 DEFUN (neighbor_interface
,
6267 neighbor_interface_cmd
,
6268 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
6276 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
6279 DEFUN (no_neighbor_interface
,
6280 no_neighbor_interface_cmd
,
6281 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
6289 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
6292 DEFUN (neighbor_distribute_list
,
6293 neighbor_distribute_list_cmd
,
6294 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
6297 "Filter updates to/from this neighbor\n"
6298 "IP access-list number\n"
6299 "IP access-list number (expanded range)\n"
6300 "IP Access-list name\n"
6301 "Filter incoming updates\n"
6302 "Filter outgoing updates\n")
6309 const char *pstr
= argv
[idx_peer
]->arg
;
6310 const char *acl
= argv
[idx_acl
]->arg
;
6311 const char *inout
= argv
[argc
- 1]->text
;
6313 peer
= peer_and_group_lookup_vty(vty
, pstr
);
6315 return CMD_WARNING_CONFIG_FAILED
;
6317 /* Check filter direction. */
6318 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
6319 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6322 return bgp_vty_return(vty
, ret
);
6326 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
6327 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
6328 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6329 "Filter updates to/from this neighbor\n"
6330 "IP access-list number\n"
6331 "IP access-list number (expanded range)\n"
6332 "IP Access-list name\n"
6333 "Filter incoming updates\n"
6334 "Filter outgoing updates\n")
6336 DEFUN (no_neighbor_distribute_list
,
6337 no_neighbor_distribute_list_cmd
,
6338 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
6342 "Filter updates to/from this neighbor\n"
6343 "IP access-list number\n"
6344 "IP access-list number (expanded range)\n"
6345 "IP Access-list name\n"
6346 "Filter incoming updates\n"
6347 "Filter outgoing updates\n")
6353 const char *pstr
= argv
[idx_peer
]->arg
;
6354 const char *inout
= argv
[argc
- 1]->text
;
6356 peer
= peer_and_group_lookup_vty(vty
, pstr
);
6358 return CMD_WARNING_CONFIG_FAILED
;
6360 /* Check filter direction. */
6361 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
6362 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6365 return bgp_vty_return(vty
, ret
);
6369 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
6370 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
6371 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6372 "Filter updates to/from this neighbor\n"
6373 "IP access-list number\n"
6374 "IP access-list number (expanded range)\n"
6375 "IP Access-list name\n"
6376 "Filter incoming updates\n"
6377 "Filter outgoing updates\n")
6379 /* Set prefix list to the peer. */
6380 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
6381 afi_t afi
, safi_t safi
,
6382 const char *name_str
,
6383 const char *direct_str
)
6386 int direct
= FILTER_IN
;
6389 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6391 return CMD_WARNING_CONFIG_FAILED
;
6393 /* Check filter direction. */
6394 if (strncmp(direct_str
, "i", 1) == 0)
6396 else if (strncmp(direct_str
, "o", 1) == 0)
6397 direct
= FILTER_OUT
;
6399 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
6401 return bgp_vty_return(vty
, ret
);
6404 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
6405 afi_t afi
, safi_t safi
,
6406 const char *direct_str
)
6410 int direct
= FILTER_IN
;
6412 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6414 return CMD_WARNING_CONFIG_FAILED
;
6416 /* Check filter direction. */
6417 if (strncmp(direct_str
, "i", 1) == 0)
6419 else if (strncmp(direct_str
, "o", 1) == 0)
6420 direct
= FILTER_OUT
;
6422 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
6424 return bgp_vty_return(vty
, ret
);
6427 DEFUN (neighbor_prefix_list
,
6428 neighbor_prefix_list_cmd
,
6429 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
6432 "Filter updates to/from this neighbor\n"
6433 "Name of a prefix list\n"
6434 "Filter incoming updates\n"
6435 "Filter outgoing updates\n")
6440 return peer_prefix_list_set_vty(
6441 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6442 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
6445 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
6446 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
6447 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6448 "Filter updates to/from this neighbor\n"
6449 "Name of a prefix list\n"
6450 "Filter incoming updates\n"
6451 "Filter outgoing updates\n")
6453 DEFUN (no_neighbor_prefix_list
,
6454 no_neighbor_prefix_list_cmd
,
6455 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
6459 "Filter updates to/from this neighbor\n"
6460 "Name of a prefix list\n"
6461 "Filter incoming updates\n"
6462 "Filter outgoing updates\n")
6466 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
6467 bgp_node_afi(vty
), bgp_node_safi(vty
),
6468 argv
[idx_in_out
]->arg
);
6471 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
6472 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
6473 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6474 "Filter updates to/from this neighbor\n"
6475 "Name of a prefix list\n"
6476 "Filter incoming updates\n"
6477 "Filter outgoing updates\n")
6479 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6480 safi_t safi
, const char *name_str
,
6481 const char *direct_str
)
6485 int direct
= FILTER_IN
;
6487 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6489 return CMD_WARNING_CONFIG_FAILED
;
6491 /* Check filter direction. */
6492 if (strncmp(direct_str
, "i", 1) == 0)
6494 else if (strncmp(direct_str
, "o", 1) == 0)
6495 direct
= FILTER_OUT
;
6497 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
6499 return bgp_vty_return(vty
, ret
);
6502 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
6503 safi_t safi
, const char *direct_str
)
6507 int direct
= FILTER_IN
;
6509 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6511 return CMD_WARNING_CONFIG_FAILED
;
6513 /* Check filter direction. */
6514 if (strncmp(direct_str
, "i", 1) == 0)
6516 else if (strncmp(direct_str
, "o", 1) == 0)
6517 direct
= FILTER_OUT
;
6519 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
6521 return bgp_vty_return(vty
, ret
);
6524 DEFUN (neighbor_filter_list
,
6525 neighbor_filter_list_cmd
,
6526 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
6529 "Establish BGP filters\n"
6530 "AS path access-list name\n"
6531 "Filter incoming routes\n"
6532 "Filter outgoing routes\n")
6537 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6538 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
6539 argv
[idx_in_out
]->arg
);
6542 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
6543 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
6544 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6545 "Establish BGP filters\n"
6546 "AS path access-list name\n"
6547 "Filter incoming routes\n"
6548 "Filter outgoing routes\n")
6550 DEFUN (no_neighbor_filter_list
,
6551 no_neighbor_filter_list_cmd
,
6552 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
6556 "Establish BGP filters\n"
6557 "AS path access-list name\n"
6558 "Filter incoming routes\n"
6559 "Filter outgoing routes\n")
6563 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
6564 bgp_node_afi(vty
), bgp_node_safi(vty
),
6565 argv
[idx_in_out
]->arg
);
6568 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
6569 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
6570 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6571 "Establish BGP filters\n"
6572 "AS path access-list name\n"
6573 "Filter incoming routes\n"
6574 "Filter outgoing routes\n")
6576 /* Set route-map to the peer. */
6577 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
6578 afi_t afi
, safi_t safi
, const char *name_str
,
6579 const char *direct_str
)
6583 int direct
= RMAP_IN
;
6584 struct route_map
*route_map
;
6586 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6588 return CMD_WARNING_CONFIG_FAILED
;
6590 /* Check filter direction. */
6591 if (strncmp(direct_str
, "in", 2) == 0)
6593 else if (strncmp(direct_str
, "o", 1) == 0)
6596 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
6597 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
6599 return bgp_vty_return(vty
, ret
);
6602 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
6603 afi_t afi
, safi_t safi
,
6604 const char *direct_str
)
6608 int direct
= RMAP_IN
;
6610 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6612 return CMD_WARNING_CONFIG_FAILED
;
6614 /* Check filter direction. */
6615 if (strncmp(direct_str
, "in", 2) == 0)
6617 else if (strncmp(direct_str
, "o", 1) == 0)
6620 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
6622 return bgp_vty_return(vty
, ret
);
6625 DEFUN (neighbor_route_map
,
6626 neighbor_route_map_cmd
,
6627 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
6630 "Apply route map to neighbor\n"
6631 "Name of route map\n"
6632 "Apply map to incoming routes\n"
6633 "Apply map to outbound routes\n")
6638 return peer_route_map_set_vty(
6639 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6640 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
6643 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
6644 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
6645 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6646 "Apply route map to neighbor\n"
6647 "Name of route map\n"
6648 "Apply map to incoming routes\n"
6649 "Apply map to outbound routes\n")
6651 DEFUN (no_neighbor_route_map
,
6652 no_neighbor_route_map_cmd
,
6653 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
6657 "Apply route map to neighbor\n"
6658 "Name of route map\n"
6659 "Apply map to incoming routes\n"
6660 "Apply map to outbound routes\n")
6664 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
6665 bgp_node_afi(vty
), bgp_node_safi(vty
),
6666 argv
[idx_in_out
]->arg
);
6669 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
6670 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
6671 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6672 "Apply route map to neighbor\n"
6673 "Name of route map\n"
6674 "Apply map to incoming routes\n"
6675 "Apply map to outbound routes\n")
6677 /* Set unsuppress-map to the peer. */
6678 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
6679 afi_t afi
, safi_t safi
,
6680 const char *name_str
)
6684 struct route_map
*route_map
;
6686 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6688 return CMD_WARNING_CONFIG_FAILED
;
6690 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
6691 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
6693 return bgp_vty_return(vty
, ret
);
6696 /* Unset route-map from the peer. */
6697 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
6698 afi_t afi
, safi_t safi
)
6703 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6705 return CMD_WARNING_CONFIG_FAILED
;
6707 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
6709 return bgp_vty_return(vty
, ret
);
6712 DEFUN (neighbor_unsuppress_map
,
6713 neighbor_unsuppress_map_cmd
,
6714 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
6717 "Route-map to selectively unsuppress suppressed routes\n"
6718 "Name of route map\n")
6722 return peer_unsuppress_map_set_vty(
6723 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6724 argv
[idx_word
]->arg
);
6727 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
6728 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
6729 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6730 "Route-map to selectively unsuppress suppressed routes\n"
6731 "Name of route map\n")
6733 DEFUN (no_neighbor_unsuppress_map
,
6734 no_neighbor_unsuppress_map_cmd
,
6735 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
6739 "Route-map to selectively unsuppress suppressed routes\n"
6740 "Name of route map\n")
6743 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
6745 bgp_node_safi(vty
));
6748 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
6749 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
6750 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6751 "Route-map to selectively unsuppress suppressed routes\n"
6752 "Name of route map\n")
6754 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
6755 afi_t afi
, safi_t safi
,
6756 const char *num_str
,
6757 const char *threshold_str
, int warning
,
6758 const char *restart_str
,
6759 const char *force_str
)
6767 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6769 return CMD_WARNING_CONFIG_FAILED
;
6771 max
= strtoul(num_str
, NULL
, 10);
6773 threshold
= atoi(threshold_str
);
6775 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
6778 restart
= atoi(restart_str
);
6782 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
6783 restart
, force_str
? true : false);
6785 return bgp_vty_return(vty
, ret
);
6788 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
6789 afi_t afi
, safi_t safi
)
6794 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
6796 return CMD_WARNING_CONFIG_FAILED
;
6798 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
6800 return bgp_vty_return(vty
, ret
);
6803 /* Maximum number of prefix to be sent to the neighbor. */
6804 DEFUN(neighbor_maximum_prefix_out
,
6805 neighbor_maximum_prefix_out_cmd
,
6806 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out (1-4294967295)",
6809 "Maximum number of prefixes to be sent to this peer\n"
6810 "Maximum no. of prefix limit\n")
6816 afi_t afi
= bgp_node_afi(vty
);
6817 safi_t safi
= bgp_node_safi(vty
);
6819 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6821 return CMD_WARNING_CONFIG_FAILED
;
6823 max
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6825 SET_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
);
6826 peer
->pmax_out
[afi
][safi
] = max
;
6831 DEFUN(no_neighbor_maximum_prefix_out
,
6832 no_neighbor_maximum_prefix_out_cmd
,
6833 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix-out",
6837 "Maximum number of prefixes to be sent to this peer\n")
6841 afi_t afi
= bgp_node_afi(vty
);
6842 safi_t safi
= bgp_node_safi(vty
);
6844 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6846 return CMD_WARNING_CONFIG_FAILED
;
6848 UNSET_FLAG(peer
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
);
6849 peer
->pmax_out
[afi
][safi
] = 0;
6854 /* Maximum number of prefix configuration. Prefix count is different
6855 for each peer configuration. So this configuration can be set for
6856 each peer configuration. */
6857 DEFUN (neighbor_maximum_prefix
,
6858 neighbor_maximum_prefix_cmd
,
6859 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
6862 "Maximum number of prefix accept from this peer\n"
6863 "maximum no. of prefix limit\n"
6864 "Force checking all received routes not only accepted\n")
6871 if (argv_find(argv
, argc
, "force", &idx_force
))
6872 force
= argv
[idx_force
]->arg
;
6874 return peer_maximum_prefix_set_vty(
6875 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6876 argv
[idx_number
]->arg
, NULL
, 0, NULL
, force
);
6879 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
6880 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) [force]",
6881 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6882 "Maximum number of prefix accept from this peer\n"
6883 "maximum no. of prefix limit\n"
6884 "Force checking all received routes not only accepted\n")
6886 DEFUN (neighbor_maximum_prefix_threshold
,
6887 neighbor_maximum_prefix_threshold_cmd
,
6888 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
6891 "Maximum number of prefix accept from this peer\n"
6892 "maximum no. of prefix limit\n"
6893 "Threshold value (%) at which to generate a warning msg\n"
6894 "Force checking all received routes not only accepted\n")
6898 int idx_number_2
= 4;
6902 if (argv_find(argv
, argc
, "force", &idx_force
))
6903 force
= argv
[idx_force
]->arg
;
6905 return peer_maximum_prefix_set_vty(
6906 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6907 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
, force
);
6911 neighbor_maximum_prefix_threshold
,
6912 neighbor_maximum_prefix_threshold_hidden_cmd
,
6913 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) [force]",
6914 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6915 "Maximum number of prefix accept from this peer\n"
6916 "maximum no. of prefix limit\n"
6917 "Threshold value (%) at which to generate a warning msg\n"
6918 "Force checking all received routes not only accepted\n")
6920 DEFUN (neighbor_maximum_prefix_warning
,
6921 neighbor_maximum_prefix_warning_cmd
,
6922 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
6925 "Maximum number of prefix accept from this peer\n"
6926 "maximum no. of prefix limit\n"
6927 "Only give warning message when limit is exceeded\n"
6928 "Force checking all received routes not only accepted\n")
6935 if (argv_find(argv
, argc
, "force", &idx_force
))
6936 force
= argv
[idx_force
]->arg
;
6938 return peer_maximum_prefix_set_vty(
6939 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6940 argv
[idx_number
]->arg
, NULL
, 1, NULL
, force
);
6944 neighbor_maximum_prefix_warning
,
6945 neighbor_maximum_prefix_warning_hidden_cmd
,
6946 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only [force]",
6947 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6948 "Maximum number of prefix accept from this peer\n"
6949 "maximum no. of prefix limit\n"
6950 "Only give warning message when limit is exceeded\n"
6951 "Force checking all received routes not only accepted\n")
6953 DEFUN (neighbor_maximum_prefix_threshold_warning
,
6954 neighbor_maximum_prefix_threshold_warning_cmd
,
6955 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
6958 "Maximum number of prefix accept from this peer\n"
6959 "maximum no. of prefix limit\n"
6960 "Threshold value (%) at which to generate a warning msg\n"
6961 "Only give warning message when limit is exceeded\n"
6962 "Force checking all received routes not only accepted\n")
6966 int idx_number_2
= 4;
6970 if (argv_find(argv
, argc
, "force", &idx_force
))
6971 force
= argv
[idx_force
]->arg
;
6973 return peer_maximum_prefix_set_vty(
6974 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6975 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
, force
);
6979 neighbor_maximum_prefix_threshold_warning
,
6980 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
6981 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only [force]",
6982 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6983 "Maximum number of prefix accept from this peer\n"
6984 "maximum no. of prefix limit\n"
6985 "Threshold value (%) at which to generate a warning msg\n"
6986 "Only give warning message when limit is exceeded\n"
6987 "Force checking all received routes not only accepted\n")
6989 DEFUN (neighbor_maximum_prefix_restart
,
6990 neighbor_maximum_prefix_restart_cmd
,
6991 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
6994 "Maximum number of prefix accept from this peer\n"
6995 "maximum no. of prefix limit\n"
6996 "Restart bgp connection after limit is exceeded\n"
6997 "Restart interval in minutes\n"
6998 "Force checking all received routes not only accepted\n")
7002 int idx_number_2
= 5;
7006 if (argv_find(argv
, argc
, "force", &idx_force
))
7007 force
= argv
[idx_force
]->arg
;
7009 return peer_maximum_prefix_set_vty(
7010 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7011 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
, force
);
7015 neighbor_maximum_prefix_restart
,
7016 neighbor_maximum_prefix_restart_hidden_cmd
,
7017 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535) [force]",
7018 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7019 "Maximum number of prefix accept from this peer\n"
7020 "maximum no. of prefix limit\n"
7021 "Restart bgp connection after limit is exceeded\n"
7022 "Restart interval in minutes\n"
7023 "Force checking all received routes not only accepted\n")
7025 DEFUN (neighbor_maximum_prefix_threshold_restart
,
7026 neighbor_maximum_prefix_threshold_restart_cmd
,
7027 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
7030 "Maximum number of prefixes to accept from this peer\n"
7031 "maximum no. of prefix limit\n"
7032 "Threshold value (%) at which to generate a warning msg\n"
7033 "Restart bgp connection after limit is exceeded\n"
7034 "Restart interval in minutes\n"
7035 "Force checking all received routes not only accepted\n")
7039 int idx_number_2
= 4;
7040 int idx_number_3
= 6;
7044 if (argv_find(argv
, argc
, "force", &idx_force
))
7045 force
= argv
[idx_force
]->arg
;
7047 return peer_maximum_prefix_set_vty(
7048 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7049 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
7050 argv
[idx_number_3
]->arg
, force
);
7054 neighbor_maximum_prefix_threshold_restart
,
7055 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
7056 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535) [force]",
7057 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7058 "Maximum number of prefixes to accept from this peer\n"
7059 "maximum no. of prefix limit\n"
7060 "Threshold value (%) at which to generate a warning msg\n"
7061 "Restart bgp connection after limit is exceeded\n"
7062 "Restart interval in minutes\n"
7063 "Force checking all received routes not only accepted\n")
7065 DEFUN (no_neighbor_maximum_prefix
,
7066 no_neighbor_maximum_prefix_cmd
,
7067 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
7071 "Maximum number of prefixes to accept from this peer\n"
7072 "maximum no. of prefix limit\n"
7073 "Threshold value (%) at which to generate a warning msg\n"
7074 "Restart bgp connection after limit is exceeded\n"
7075 "Restart interval in minutes\n"
7076 "Only give warning message when limit is exceeded\n"
7077 "Force checking all received routes not only accepted\n")
7080 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
7082 bgp_node_safi(vty
));
7086 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
7087 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only] [force]]",
7088 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7089 "Maximum number of prefixes to accept from this peer\n"
7090 "maximum no. of prefix limit\n"
7091 "Threshold value (%) at which to generate a warning msg\n"
7092 "Restart bgp connection after limit is exceeded\n"
7093 "Restart interval in minutes\n"
7094 "Only give warning message when limit is exceeded\n"
7095 "Force checking all received routes not only accepted\n")
7098 /* "neighbor allowas-in" */
7099 DEFUN (neighbor_allowas_in
,
7100 neighbor_allowas_in_cmd
,
7101 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
7104 "Accept as-path with my AS present in it\n"
7105 "Number of occurrences of AS number\n"
7106 "Only accept my AS in the as-path if the route was originated in my AS\n")
7109 int idx_number_origin
= 3;
7115 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7117 return CMD_WARNING_CONFIG_FAILED
;
7119 if (argc
<= idx_number_origin
)
7122 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
7125 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
7128 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7131 return bgp_vty_return(vty
, ret
);
7135 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
7136 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
7137 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7138 "Accept as-path with my AS present in it\n"
7139 "Number of occurrences of AS number\n"
7140 "Only accept my AS in the as-path if the route was originated in my AS\n")
7142 DEFUN (no_neighbor_allowas_in
,
7143 no_neighbor_allowas_in_cmd
,
7144 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
7148 "allow local ASN appears in aspath attribute\n"
7149 "Number of occurrences of AS number\n"
7150 "Only accept my AS in the as-path if the route was originated in my AS\n")
7156 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7158 return CMD_WARNING_CONFIG_FAILED
;
7160 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
7161 bgp_node_safi(vty
));
7163 return bgp_vty_return(vty
, ret
);
7167 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
7168 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
7169 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7170 "allow local ASN appears in aspath attribute\n"
7171 "Number of occurrences of AS number\n"
7172 "Only accept my AS in the as-path if the route was originated in my AS\n")
7174 DEFUN (neighbor_ttl_security
,
7175 neighbor_ttl_security_cmd
,
7176 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
7179 "BGP ttl-security parameters\n"
7180 "Specify the maximum number of hops to the BGP peer\n"
7181 "Number of hops to BGP peer\n")
7188 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7190 return CMD_WARNING_CONFIG_FAILED
;
7192 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
7195 * If 'neighbor swpX', then this is for directly connected peers,
7196 * we should not accept a ttl-security hops value greater than 1.
7198 if (peer
->conf_if
&& (gtsm_hops
> BGP_GTSM_HOPS_CONNECTED
)) {
7200 "%s is directly connected peer, hops cannot exceed 1\n",
7201 argv
[idx_peer
]->arg
);
7202 return CMD_WARNING_CONFIG_FAILED
;
7205 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
7208 DEFUN (no_neighbor_ttl_security
,
7209 no_neighbor_ttl_security_cmd
,
7210 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
7214 "BGP ttl-security parameters\n"
7215 "Specify the maximum number of hops to the BGP peer\n"
7216 "Number of hops to BGP peer\n")
7221 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7223 return CMD_WARNING_CONFIG_FAILED
;
7225 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
7228 DEFUN (neighbor_addpath_tx_all_paths
,
7229 neighbor_addpath_tx_all_paths_cmd
,
7230 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
7233 "Use addpath to advertise all paths to a neighbor\n")
7238 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7240 return CMD_WARNING_CONFIG_FAILED
;
7242 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7247 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
7248 neighbor_addpath_tx_all_paths_hidden_cmd
,
7249 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
7250 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7251 "Use addpath to advertise all paths to a neighbor\n")
7253 DEFUN (no_neighbor_addpath_tx_all_paths
,
7254 no_neighbor_addpath_tx_all_paths_cmd
,
7255 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
7259 "Use addpath to advertise all paths to a neighbor\n")
7264 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7266 return CMD_WARNING_CONFIG_FAILED
;
7268 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
7269 != BGP_ADDPATH_ALL
) {
7271 "%% Peer not currently configured to transmit all paths.");
7272 return CMD_WARNING_CONFIG_FAILED
;
7275 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7281 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
7282 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
7283 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
7284 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7285 "Use addpath to advertise all paths to a neighbor\n")
7287 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
7288 neighbor_addpath_tx_bestpath_per_as_cmd
,
7289 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
7292 "Use addpath to advertise the bestpath per each neighboring AS\n")
7297 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7299 return CMD_WARNING_CONFIG_FAILED
;
7301 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7302 BGP_ADDPATH_BEST_PER_AS
);
7307 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
7308 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
7309 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
7310 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7311 "Use addpath to advertise the bestpath per each neighboring AS\n")
7313 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
7314 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
7315 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
7319 "Use addpath to advertise the bestpath per each neighboring AS\n")
7324 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
7326 return CMD_WARNING_CONFIG_FAILED
;
7328 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
7329 != BGP_ADDPATH_BEST_PER_AS
) {
7331 "%% Peer not currently configured to transmit all best path per as.");
7332 return CMD_WARNING_CONFIG_FAILED
;
7335 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
7341 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
7342 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
7343 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
7344 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
7345 "Use addpath to advertise the bestpath per each neighboring AS\n")
7348 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
7349 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
7352 "Detect AS loops before sending to neighbor\n")
7356 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7358 return CMD_WARNING_CONFIG_FAILED
;
7360 peer
->as_path_loop_detection
= true;
7366 no_neighbor_aspath_loop_detection
,
7367 no_neighbor_aspath_loop_detection_cmd
,
7368 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
7372 "Detect AS loops before sending to neighbor\n")
7376 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
7378 return CMD_WARNING_CONFIG_FAILED
;
7380 peer
->as_path_loop_detection
= false;
7385 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
7386 struct ecommunity
**list
)
7388 struct ecommunity
*ecom
= NULL
;
7389 struct ecommunity
*ecomadd
;
7391 for (; argc
; --argc
, ++argv
) {
7393 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
7394 ECOMMUNITY_ROUTE_TARGET
, 0);
7396 vty_out(vty
, "Malformed community-list value\n");
7398 ecommunity_free(&ecom
);
7399 return CMD_WARNING_CONFIG_FAILED
;
7403 ecommunity_merge(ecom
, ecomadd
);
7404 ecommunity_free(&ecomadd
);
7411 ecommunity_free(&*list
);
7419 * v2vimport is true if we are handling a `import vrf ...` command
7421 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
7425 switch (vty
->node
) {
7434 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
7439 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
7440 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
7441 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
7442 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
7444 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
7448 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
7449 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
7450 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
7451 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
7453 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
7460 DEFPY (af_rd_vpn_export
,
7461 af_rd_vpn_export_cmd
,
7462 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
7464 "Specify route distinguisher\n"
7465 "Between current address-family and vpn\n"
7466 "For routes leaked from current address-family to vpn\n"
7467 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
7469 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7470 struct prefix_rd prd
;
7476 if (argv_find(argv
, argc
, "no", &idx
))
7480 ret
= str2prefix_rd(rd_str
, &prd
);
7482 vty_out(vty
, "%% Malformed rd\n");
7483 return CMD_WARNING_CONFIG_FAILED
;
7487 afi
= vpn_policy_getafi(vty
, bgp
, false);
7489 return CMD_WARNING_CONFIG_FAILED
;
7492 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
7494 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
7495 bgp_get_default(), bgp
);
7498 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
7499 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
7500 BGP_VPN_POLICY_TOVPN_RD_SET
);
7502 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
7503 BGP_VPN_POLICY_TOVPN_RD_SET
);
7506 /* post-change: re-export vpn routes */
7507 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
7508 bgp_get_default(), bgp
);
7513 ALIAS (af_rd_vpn_export
,
7514 af_no_rd_vpn_export_cmd
,
7517 "Specify route distinguisher\n"
7518 "Between current address-family and vpn\n"
7519 "For routes leaked from current address-family to vpn\n")
7521 DEFPY (af_label_vpn_export
,
7522 af_label_vpn_export_cmd
,
7523 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
7525 "label value for VRF\n"
7526 "Between current address-family and vpn\n"
7527 "For routes leaked from current address-family to vpn\n"
7528 "Label Value <0-1048575>\n"
7529 "Automatically assign a label\n")
7531 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7532 mpls_label_t label
= MPLS_LABEL_NONE
;
7537 if (argv_find(argv
, argc
, "no", &idx
))
7540 /* If "no ...", squash trailing parameter */
7546 label
= label_val
; /* parser should force unsigned */
7549 afi
= vpn_policy_getafi(vty
, bgp
, false);
7551 return CMD_WARNING_CONFIG_FAILED
;
7554 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
7555 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
7560 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
7562 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
7563 bgp_get_default(), bgp
);
7565 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
7566 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
7568 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
7571 * label has previously been automatically
7572 * assigned by labelpool: release it
7574 * NB if tovpn_label == MPLS_LABEL_NONE it
7575 * means the automatic assignment is in flight
7576 * and therefore the labelpool callback must
7577 * detect that the auto label is not needed.
7580 bgp_lp_release(LP_TYPE_VRF
,
7581 &bgp
->vpn_policy
[afi
],
7582 bgp
->vpn_policy
[afi
].tovpn_label
);
7584 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
7585 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
7588 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
7590 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
7591 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
7592 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
7593 vpn_leak_label_callback
);
7596 /* post-change: re-export vpn routes */
7597 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
7598 bgp_get_default(), bgp
);
7603 ALIAS (af_label_vpn_export
,
7604 af_no_label_vpn_export_cmd
,
7605 "no label vpn export",
7607 "label value for VRF\n"
7608 "Between current address-family and vpn\n"
7609 "For routes leaked from current address-family to vpn\n")
7611 DEFPY (af_nexthop_vpn_export
,
7612 af_nexthop_vpn_export_cmd
,
7613 "[no] nexthop vpn export [<A.B.C.D|X:X::X:X>$nexthop_su]",
7615 "Specify next hop to use for VRF advertised prefixes\n"
7616 "Between current address-family and vpn\n"
7617 "For routes leaked from current address-family to vpn\n"
7621 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7627 vty_out(vty
, "%% Nexthop required\n");
7628 return CMD_WARNING_CONFIG_FAILED
;
7631 if (!sockunion2hostprefix(nexthop_su
, &p
))
7632 return CMD_WARNING_CONFIG_FAILED
;
7635 afi
= vpn_policy_getafi(vty
, bgp
, false);
7637 return CMD_WARNING_CONFIG_FAILED
;
7640 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
7642 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
7643 bgp_get_default(), bgp
);
7646 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
7647 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
7648 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
7650 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
7651 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
7654 /* post-change: re-export vpn routes */
7655 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
7656 bgp_get_default(), bgp
);
7661 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
7663 if (!strcmp(dstr
, "import")) {
7664 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
7665 } else if (!strcmp(dstr
, "export")) {
7666 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
7667 } else if (!strcmp(dstr
, "both")) {
7668 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
7669 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
7671 vty_out(vty
, "%% direction parse error\n");
7672 return CMD_WARNING_CONFIG_FAILED
;
7677 DEFPY (af_rt_vpn_imexport
,
7678 af_rt_vpn_imexport_cmd
,
7679 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
7681 "Specify route target list\n"
7682 "Specify route target list\n"
7683 "Between current address-family and vpn\n"
7684 "For routes leaked from vpn to current address-family: match any\n"
7685 "For routes leaked from current address-family to vpn: set\n"
7686 "both import: match any and export: set\n"
7687 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
7689 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7691 struct ecommunity
*ecom
= NULL
;
7692 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
7693 vpn_policy_direction_t dir
;
7698 if (argv_find(argv
, argc
, "no", &idx
))
7701 afi
= vpn_policy_getafi(vty
, bgp
, false);
7703 return CMD_WARNING_CONFIG_FAILED
;
7705 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
7706 if (ret
!= CMD_SUCCESS
)
7710 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7711 vty_out(vty
, "%% Missing RTLIST\n");
7712 return CMD_WARNING_CONFIG_FAILED
;
7714 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7715 if (ret
!= CMD_SUCCESS
) {
7720 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
7724 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7727 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
7729 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
7730 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
7731 ecommunity_dup(ecom
);
7733 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
7735 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
7736 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
7739 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7743 ecommunity_free(&ecom
);
7748 ALIAS (af_rt_vpn_imexport
,
7749 af_no_rt_vpn_imexport_cmd
,
7750 "no <rt|route-target> vpn <import|export|both>$direction_str",
7752 "Specify route target list\n"
7753 "Specify route target list\n"
7754 "Between current address-family and vpn\n"
7755 "For routes leaked from vpn to current address-family\n"
7756 "For routes leaked from current address-family to vpn\n"
7757 "both import and export\n")
7759 DEFPY (af_route_map_vpn_imexport
,
7760 af_route_map_vpn_imexport_cmd
,
7761 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
7762 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
7764 "Specify route map\n"
7765 "Between current address-family and vpn\n"
7766 "For routes leaked from vpn to current address-family\n"
7767 "For routes leaked from current address-family to vpn\n"
7768 "name of route-map\n")
7770 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7772 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
7773 vpn_policy_direction_t dir
;
7778 if (argv_find(argv
, argc
, "no", &idx
))
7781 afi
= vpn_policy_getafi(vty
, bgp
, false);
7783 return CMD_WARNING_CONFIG_FAILED
;
7785 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
7786 if (ret
!= CMD_SUCCESS
)
7789 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
7793 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7796 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
7797 XFREE(MTYPE_ROUTE_MAP_NAME
,
7798 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
7799 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
7800 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
7801 bgp
->vpn_policy
[afi
].rmap
[dir
] =
7802 route_map_lookup_warn_noexist(vty
, rmap_str
);
7803 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
7806 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
7807 XFREE(MTYPE_ROUTE_MAP_NAME
,
7808 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
7809 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
7810 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
7813 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7819 ALIAS (af_route_map_vpn_imexport
,
7820 af_no_route_map_vpn_imexport_cmd
,
7821 "no route-map vpn <import|export>$direction_str",
7823 "Specify route map\n"
7824 "Between current address-family and vpn\n"
7825 "For routes leaked from vpn to current address-family\n"
7826 "For routes leaked from current address-family to vpn\n")
7828 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
7829 "import vrf route-map RMAP$rmap_str",
7830 "Import routes from another VRF\n"
7831 "Vrf routes being filtered\n"
7832 "Specify route map\n"
7833 "name of route-map\n")
7835 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7836 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
7838 struct bgp
*bgp_default
;
7840 afi
= vpn_policy_getafi(vty
, bgp
, true);
7842 return CMD_WARNING_CONFIG_FAILED
;
7844 bgp_default
= bgp_get_default();
7849 /* Auto-create assuming the same AS */
7850 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
7851 BGP_INSTANCE_TYPE_DEFAULT
);
7855 "VRF default is not configured as a bgp instance\n");
7860 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7862 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
7863 XFREE(MTYPE_ROUTE_MAP_NAME
,
7864 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
7865 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
7866 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
7867 bgp
->vpn_policy
[afi
].rmap
[dir
] =
7868 route_map_lookup_warn_noexist(vty
, rmap_str
);
7869 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
7872 SET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
7873 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
7875 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7880 DEFPY(af_no_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
7881 "no import vrf route-map [RMAP$rmap_str]",
7883 "Import routes from another VRF\n"
7884 "Vrf routes being filtered\n"
7885 "Specify route map\n"
7886 "name of route-map\n")
7888 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7889 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
7892 afi
= vpn_policy_getafi(vty
, bgp
, true);
7894 return CMD_WARNING_CONFIG_FAILED
;
7896 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7898 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
7899 XFREE(MTYPE_ROUTE_MAP_NAME
,
7900 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
7901 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
7902 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
7904 if (bgp
->vpn_policy
[afi
].import_vrf
->count
== 0)
7905 UNSET_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
7906 BGP_CONFIG_VRF_TO_VRF_IMPORT
);
7908 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7913 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
7914 "[no] import vrf VIEWVRFNAME$import_name",
7916 "Import routes from another VRF\n"
7917 "VRF to import from\n"
7918 "The name of the VRF\n")
7920 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7921 struct listnode
*node
;
7922 struct bgp
*vrf_bgp
, *bgp_default
;
7925 bool remove
= false;
7928 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
7932 if (import_name
== NULL
) {
7933 vty_out(vty
, "%% Missing import name\n");
7937 if (strcmp(import_name
, "route-map") == 0) {
7938 vty_out(vty
, "%% Must include route-map name\n");
7942 if (argv_find(argv
, argc
, "no", &idx
))
7945 afi
= vpn_policy_getafi(vty
, bgp
, true);
7947 return CMD_WARNING_CONFIG_FAILED
;
7949 safi
= bgp_node_safi(vty
);
7951 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
7952 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
7953 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
7954 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
7955 remove
? "unimport" : "import", import_name
);
7959 bgp_default
= bgp_get_default();
7961 /* Auto-create assuming the same AS */
7962 ret
= bgp_get_vty(&bgp_default
, &as
, NULL
,
7963 BGP_INSTANCE_TYPE_DEFAULT
);
7967 "VRF default is not configured as a bgp instance\n");
7972 vrf_bgp
= bgp_lookup_by_name(import_name
);
7974 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
7975 vrf_bgp
= bgp_default
;
7977 /* Auto-create assuming the same AS */
7978 ret
= bgp_get_vty(&vrf_bgp
, &as
, import_name
, bgp_type
);
7982 "VRF %s is not configured as a bgp instance\n",
7989 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
7991 /* Already importing from "import_vrf"? */
7992 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
7994 if (strcmp(vname
, import_name
) == 0)
7998 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
8004 /* This command is valid only in a bgp vrf instance or the default instance */
8005 DEFPY (bgp_imexport_vpn
,
8006 bgp_imexport_vpn_cmd
,
8007 "[no] <import|export>$direction_str vpn",
8009 "Import routes to this address-family\n"
8010 "Export routes from this address-family\n"
8011 "to/from default instance VPN RIB\n")
8013 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8020 vpn_policy_direction_t dir
;
8022 if (argv_find(argv
, argc
, "no", &idx
))
8025 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
8026 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
8028 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
8029 return CMD_WARNING_CONFIG_FAILED
;
8032 afi
= bgp_node_afi(vty
);
8033 safi
= bgp_node_safi(vty
);
8034 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
8035 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
8036 return CMD_WARNING_CONFIG_FAILED
;
8039 if (!strcmp(direction_str
, "import")) {
8040 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
8041 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
8042 } else if (!strcmp(direction_str
, "export")) {
8043 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
8044 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
8046 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
8047 return CMD_WARNING_CONFIG_FAILED
;
8050 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
8053 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
8054 if (!previous_state
) {
8055 /* trigger export current vrf */
8056 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
8059 if (previous_state
) {
8060 /* trigger un-export current vrf */
8061 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
8063 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
8069 DEFPY (af_routetarget_import
,
8070 af_routetarget_import_cmd
,
8071 "[no] <rt|route-target> redirect import RTLIST...",
8073 "Specify route target list\n"
8074 "Specify route target list\n"
8075 "Flow-spec redirect type route target\n"
8076 "Import routes to this address-family\n"
8077 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
8079 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8081 struct ecommunity
*ecom
= NULL
;
8086 if (argv_find(argv
, argc
, "no", &idx
))
8089 afi
= vpn_policy_getafi(vty
, bgp
, false);
8091 return CMD_WARNING_CONFIG_FAILED
;
8094 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
8095 vty_out(vty
, "%% Missing RTLIST\n");
8096 return CMD_WARNING_CONFIG_FAILED
;
8098 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
8099 if (ret
!= CMD_SUCCESS
)
8104 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
8105 ecommunity_free(&bgp
->vpn_policy
[afi
]
8106 .import_redirect_rtlist
);
8107 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
8108 ecommunity_dup(ecom
);
8110 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
8111 ecommunity_free(&bgp
->vpn_policy
[afi
]
8112 .import_redirect_rtlist
);
8113 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
8117 ecommunity_free(&ecom
);
8122 DEFUN_NOSH (address_family_ipv4_safi
,
8123 address_family_ipv4_safi_cmd
,
8124 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
8125 "Enter Address Family command mode\n"
8127 BGP_SAFI_WITH_LABEL_HELP_STR
)
8131 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8132 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
8133 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
8134 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
8135 && safi
!= SAFI_EVPN
) {
8137 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
8138 return CMD_WARNING_CONFIG_FAILED
;
8140 vty
->node
= bgp_node_type(AFI_IP
, safi
);
8142 vty
->node
= BGP_IPV4_NODE
;
8147 DEFUN_NOSH (address_family_ipv6_safi
,
8148 address_family_ipv6_safi_cmd
,
8149 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
8150 "Enter Address Family command mode\n"
8152 BGP_SAFI_WITH_LABEL_HELP_STR
)
8155 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8156 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
8157 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
8158 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
8159 && safi
!= SAFI_EVPN
) {
8161 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
8162 return CMD_WARNING_CONFIG_FAILED
;
8164 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
8166 vty
->node
= BGP_IPV6_NODE
;
8171 #ifdef KEEP_OLD_VPN_COMMANDS
8172 DEFUN_NOSH (address_family_vpnv4
,
8173 address_family_vpnv4_cmd
,
8174 "address-family vpnv4 [unicast]",
8175 "Enter Address Family command mode\n"
8177 "Address Family modifier\n")
8179 vty
->node
= BGP_VPNV4_NODE
;
8183 DEFUN_NOSH (address_family_vpnv6
,
8184 address_family_vpnv6_cmd
,
8185 "address-family vpnv6 [unicast]",
8186 "Enter Address Family command mode\n"
8188 "Address Family modifier\n")
8190 vty
->node
= BGP_VPNV6_NODE
;
8193 #endif /* KEEP_OLD_VPN_COMMANDS */
8195 DEFUN_NOSH (address_family_evpn
,
8196 address_family_evpn_cmd
,
8197 "address-family l2vpn evpn",
8198 "Enter Address Family command mode\n"
8200 "Address Family modifier\n")
8202 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
8203 vty
->node
= BGP_EVPN_NODE
;
8207 DEFUN_NOSH (exit_address_family
,
8208 exit_address_family_cmd
,
8209 "exit-address-family",
8210 "Exit from Address Family configuration mode\n")
8212 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
8213 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
8214 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
8215 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
8216 || vty
->node
== BGP_EVPN_NODE
8217 || vty
->node
== BGP_FLOWSPECV4_NODE
8218 || vty
->node
== BGP_FLOWSPECV6_NODE
)
8219 vty
->node
= BGP_NODE
;
8223 /* Recalculate bestpath and re-advertise a prefix */
8224 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
8225 const char *ip_str
, afi_t afi
, safi_t safi
,
8226 struct prefix_rd
*prd
)
8229 struct prefix match
;
8230 struct bgp_dest
*dest
;
8231 struct bgp_dest
*rm
;
8233 struct bgp_table
*table
;
8234 struct bgp_table
*rib
;
8236 /* BGP structure lookup. */
8238 bgp
= bgp_lookup_by_name(view_name
);
8240 vty_out(vty
, "%% Can't find BGP instance %s\n",
8245 bgp
= bgp_get_default();
8247 vty_out(vty
, "%% No BGP process is configured\n");
8252 /* Check IP address argument. */
8253 ret
= str2prefix(ip_str
, &match
);
8255 vty_out(vty
, "%% address is malformed\n");
8259 match
.family
= afi2family(afi
);
8260 rib
= bgp
->rib
[afi
][safi
];
8262 if (safi
== SAFI_MPLS_VPN
) {
8263 for (dest
= bgp_table_top(rib
); dest
;
8264 dest
= bgp_route_next(dest
)) {
8265 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
8267 if (prd
&& memcmp(dest_p
->u
.val
, prd
->val
, 8) != 0)
8270 table
= bgp_dest_get_bgp_table_info(dest
);
8274 if ((rm
= bgp_node_match(table
, &match
)) != NULL
) {
8275 const struct prefix
*rm_p
=
8276 bgp_dest_get_prefix(rm
);
8278 if (rm_p
->prefixlen
== match
.prefixlen
) {
8280 BGP_NODE_USER_CLEAR
);
8281 bgp_process(bgp
, rm
, afi
, safi
);
8283 bgp_dest_unlock_node(rm
);
8287 if ((dest
= bgp_node_match(rib
, &match
)) != NULL
) {
8288 const struct prefix
*dest_p
= bgp_dest_get_prefix(dest
);
8290 if (dest_p
->prefixlen
== match
.prefixlen
) {
8291 SET_FLAG(dest
->flags
, BGP_NODE_USER_CLEAR
);
8292 bgp_process(bgp
, dest
, afi
, safi
);
8294 bgp_dest_unlock_node(dest
);
8301 /* one clear bgp command to rule them all */
8302 DEFUN (clear_ip_bgp_all
,
8303 clear_ip_bgp_all_cmd
,
8304 "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>]",
8308 BGP_INSTANCE_HELP_STR
8311 BGP_SAFI_WITH_LABEL_HELP_STR
8312 "Address Family modifier\n"
8314 "BGP IPv4 neighbor to clear\n"
8315 "BGP IPv6 neighbor to clear\n"
8316 "BGP neighbor on interface to clear\n"
8317 "Clear peers with the AS number\n"
8318 "Clear all external peers\n"
8319 "Clear all members of peer-group\n"
8320 "BGP peer-group name\n"
8325 "Push out prefix-list ORF and do inbound soft reconfig\n"
8330 afi_t afi
= AFI_UNSPEC
;
8331 safi_t safi
= SAFI_UNSPEC
;
8332 enum clear_sort clr_sort
= clear_peer
;
8333 enum bgp_clear_type clr_type
;
8334 char *clr_arg
= NULL
;
8338 /* clear [ip] bgp */
8339 if (argv_find(argv
, argc
, "ip", &idx
))
8342 /* [<vrf> VIEWVRFNAME] */
8343 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8344 vrf
= argv
[idx
+ 1]->arg
;
8346 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8348 } else if (argv_find(argv
, argc
, "view", &idx
)) {
8349 /* [<view> VIEWVRFNAME] */
8350 vrf
= argv
[idx
+ 1]->arg
;
8353 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8354 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
8355 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8357 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
8358 if (argv_find(argv
, argc
, "*", &idx
)) {
8359 clr_sort
= clear_all
;
8360 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
8361 clr_sort
= clear_peer
;
8362 clr_arg
= argv
[idx
]->arg
;
8363 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
8364 clr_sort
= clear_peer
;
8365 clr_arg
= argv
[idx
]->arg
;
8366 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
8367 clr_sort
= clear_group
;
8369 clr_arg
= argv
[idx
]->arg
;
8370 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
8371 clr_sort
= clear_peer
;
8372 clr_arg
= argv
[idx
]->arg
;
8373 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
8374 clr_sort
= clear_peer
;
8375 clr_arg
= argv
[idx
]->arg
;
8376 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
8377 clr_sort
= clear_as
;
8378 clr_arg
= argv
[idx
]->arg
;
8379 } else if (argv_find(argv
, argc
, "external", &idx
)) {
8380 clr_sort
= clear_external
;
8383 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
8384 if (argv_find(argv
, argc
, "soft", &idx
)) {
8385 if (argv_find(argv
, argc
, "in", &idx
)
8386 || argv_find(argv
, argc
, "out", &idx
))
8387 clr_type
= strmatch(argv
[idx
]->text
, "in")
8389 : BGP_CLEAR_SOFT_OUT
;
8391 clr_type
= BGP_CLEAR_SOFT_BOTH
;
8392 } else if (argv_find(argv
, argc
, "in", &idx
)) {
8393 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
8394 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
8395 : BGP_CLEAR_SOFT_IN
;
8396 } else if (argv_find(argv
, argc
, "out", &idx
)) {
8397 clr_type
= BGP_CLEAR_SOFT_OUT
;
8399 clr_type
= BGP_CLEAR_SOFT_NONE
;
8401 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
8404 DEFUN (clear_ip_bgp_prefix
,
8405 clear_ip_bgp_prefix_cmd
,
8406 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
8410 BGP_INSTANCE_HELP_STR
8411 "Clear bestpath and re-advertise\n"
8415 char *prefix
= NULL
;
8419 /* [<view|vrf> VIEWVRFNAME] */
8420 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8421 vrf
= argv
[idx
+ 1]->arg
;
8423 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8425 } else if (argv_find(argv
, argc
, "view", &idx
)) {
8426 /* [<view> VIEWVRFNAME] */
8427 vrf
= argv
[idx
+ 1]->arg
;
8431 prefix
= argv
[argc
- 1]->arg
;
8433 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
8436 DEFUN (clear_bgp_ipv6_safi_prefix
,
8437 clear_bgp_ipv6_safi_prefix_cmd
,
8438 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
8444 "Clear bestpath and re-advertise\n"
8448 int idx_ipv6_prefix
= 0;
8449 safi_t safi
= SAFI_UNICAST
;
8450 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
8451 argv
[idx_ipv6_prefix
]->arg
: NULL
;
8453 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
8454 return bgp_clear_prefix(
8455 vty
, NULL
, prefix
, AFI_IP6
,
8459 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
8460 clear_bgp_instance_ipv6_safi_prefix_cmd
,
8461 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
8465 BGP_INSTANCE_HELP_STR
8468 "Clear bestpath and re-advertise\n"
8472 int idx_vrfview
= 0;
8473 int idx_ipv6_prefix
= 0;
8474 safi_t safi
= SAFI_UNICAST
;
8475 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
8476 argv
[idx_ipv6_prefix
]->arg
: NULL
;
8477 char *vrfview
= NULL
;
8479 /* [<view|vrf> VIEWVRFNAME] */
8480 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
8481 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
8482 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
8484 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
8485 /* [<view> VIEWVRFNAME] */
8486 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
8488 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
8490 return bgp_clear_prefix(
8491 vty
, vrfview
, prefix
,
8492 AFI_IP6
, safi
, NULL
);
8495 DEFUN (show_bgp_views
,
8497 "show [ip] bgp views",
8501 "Show the defined BGP views\n")
8503 struct list
*inst
= bm
->bgp
;
8504 struct listnode
*node
;
8507 vty_out(vty
, "Defined BGP views:\n");
8508 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
8510 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
8512 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
8519 DEFUN (show_bgp_vrfs
,
8521 "show [ip] bgp vrfs [json]",
8528 char buf
[ETHER_ADDR_STRLEN
];
8529 struct list
*inst
= bm
->bgp
;
8530 struct listnode
*node
;
8532 bool uj
= use_json(argc
, argv
);
8533 json_object
*json
= NULL
;
8534 json_object
*json_vrfs
= NULL
;
8538 json
= json_object_new_object();
8539 json_vrfs
= json_object_new_object();
8542 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
8543 const char *name
, *type
;
8545 struct listnode
*node2
, *nnode2
;
8546 int peers_cfg
, peers_estb
;
8547 json_object
*json_vrf
= NULL
;
8550 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
8554 if (!uj
&& count
== 1) {
8556 "%4s %-5s %-16s %9s %10s %-37s\n",
8557 "Type", "Id", "routerId", "#PeersCfg",
8558 "#PeersEstb", "Name");
8559 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
8560 "L3-VNI", "RouterMAC", "Interface");
8563 peers_cfg
= peers_estb
= 0;
8565 json_vrf
= json_object_new_object();
8568 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
8569 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8572 if (peer
->status
== Established
)
8576 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
8577 name
= VRF_DEFAULT_NAME
;
8586 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
8588 : (int64_t)bgp
->vrf_id
;
8589 json_object_string_add(json_vrf
, "type", type
);
8590 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
8591 json_object_string_add(json_vrf
, "routerId",
8592 inet_ntoa(bgp
->router_id
));
8593 json_object_int_add(json_vrf
, "numConfiguredPeers",
8595 json_object_int_add(json_vrf
, "numEstablishedPeers",
8598 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
8599 json_object_string_add(
8601 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
8602 json_object_string_add(json_vrf
, "interface",
8603 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
8605 json_object_object_add(json_vrfs
, name
, json_vrf
);
8608 "%4s %-5d %-16s %-9u %-10u %-37s\n",
8610 bgp
->vrf_id
== VRF_UNKNOWN
? -1
8612 inet_ntoa(bgp
->router_id
), peers_cfg
,
8614 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
8616 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
8617 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
8623 json_object_object_add(json
, "vrfs", json_vrfs
);
8625 json_object_int_add(json
, "totalVrfs", count
);
8627 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8628 json
, JSON_C_TO_STRING_PRETTY
));
8629 json_object_free(json
);
8633 "\nTotal number of VRFs (including default): %d\n",
8640 DEFUN (show_bgp_mac_hash
,
8641 show_bgp_mac_hash_cmd
,
8642 "show bgp mac hash",
8646 "Mac Address database\n")
8648 bgp_mac_dump_table(vty
);
8653 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
8655 struct vty
*vty
= (struct vty
*)args
;
8656 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
8658 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
8662 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
8664 vty_out(vty
, "self nexthop database:\n");
8665 bgp_nexthop_show_address_hash(vty
, bgp
);
8667 vty_out(vty
, "Tunnel-ip database:\n");
8668 hash_iterate(bgp
->tip_hash
,
8669 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
8673 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
8674 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
8675 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
8676 "martian next-hops\n"
8677 "martian next-hop database\n")
8679 struct bgp
*bgp
= NULL
;
8683 /* [<vrf> VIEWVRFNAME] */
8684 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8685 name
= argv
[idx
+ 1]->arg
;
8686 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
8688 } else if (argv_find(argv
, argc
, "view", &idx
))
8689 /* [<view> VIEWVRFNAME] */
8690 name
= argv
[idx
+ 1]->arg
;
8692 bgp
= bgp_lookup_by_name(name
);
8694 bgp
= bgp_get_default();
8697 vty_out(vty
, "%% No BGP process is configured\n");
8700 bgp_show_martian_nexthops(vty
, bgp
);
8705 DEFUN (show_bgp_memory
,
8706 show_bgp_memory_cmd
,
8707 "show [ip] bgp memory",
8711 "Global BGP memory statistics\n")
8713 char memstrbuf
[MTYPE_MEMSTR_LEN
];
8714 unsigned long count
;
8716 /* RIB related usage stats */
8717 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
8718 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
8719 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8720 count
* sizeof(struct bgp_dest
)));
8722 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
8723 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
8724 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8725 count
* sizeof(struct bgp_path_info
)));
8726 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
8727 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
8730 memstrbuf
, sizeof(memstrbuf
),
8731 count
* sizeof(struct bgp_path_info_extra
)));
8733 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
8734 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
8735 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8736 count
* sizeof(struct bgp_static
)));
8738 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
8739 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
8740 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8741 count
* sizeof(struct bpacket
)));
8744 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
8745 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
8746 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8747 count
* sizeof(struct bgp_adj_in
)));
8748 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
8749 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
8750 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8751 count
* sizeof(struct bgp_adj_out
)));
8753 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
8754 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
8756 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8757 count
* sizeof(struct bgp_nexthop_cache
)));
8759 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
8760 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
8762 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8763 count
* sizeof(struct bgp_damp_info
)));
8766 count
= attr_count();
8767 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
8768 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8769 count
* sizeof(struct attr
)));
8771 if ((count
= attr_unknown_count()))
8772 vty_out(vty
, "%ld unknown attributes\n", count
);
8774 /* AS_PATH attributes */
8775 count
= aspath_count();
8776 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
8777 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8778 count
* sizeof(struct aspath
)));
8780 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
8781 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
8782 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8783 count
* sizeof(struct assegment
)));
8785 /* Other attributes */
8786 if ((count
= community_count()))
8787 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
8788 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8789 count
* sizeof(struct community
)));
8790 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
8791 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
8792 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8793 count
* sizeof(struct ecommunity
)));
8794 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
8796 "%ld BGP large-community entries, using %s of memory\n",
8797 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8798 count
* sizeof(struct lcommunity
)));
8800 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
8801 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
8802 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8803 count
* sizeof(struct cluster_list
)));
8805 /* Peer related usage */
8806 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
8807 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
8808 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8809 count
* sizeof(struct peer
)));
8811 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
8812 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
8813 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8814 count
* sizeof(struct peer_group
)));
8817 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
8818 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
8819 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
8820 count
* sizeof(regex_t
)));
8824 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
8826 json_object
*bestpath
= json_object_new_object();
8828 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
8829 json_object_string_add(bestpath
, "asPath", "ignore");
8831 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
8832 json_object_string_add(bestpath
, "asPath", "confed");
8834 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
8835 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
8836 json_object_string_add(bestpath
, "multiPathRelax",
8839 json_object_string_add(bestpath
, "multiPathRelax",
8842 json_object_string_add(bestpath
, "multiPathRelax", "false");
8844 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
8845 json_object_string_add(bestpath
, "compareRouterId", "true");
8846 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
8847 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
8848 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
8849 json_object_string_add(bestpath
, "med", "confed");
8850 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
))
8851 json_object_string_add(bestpath
, "med",
8852 "missing-as-worst");
8854 json_object_string_add(bestpath
, "med", "true");
8857 json_object_object_add(json
, "bestPath", bestpath
);
8860 /* Print the error code/subcode for why the peer is down */
8861 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
8862 json_object
*json_peer
, bool use_json
)
8864 const char *code_str
;
8865 const char *subcode_str
;
8868 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
8869 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
8870 char errorcodesubcode_hexstr
[5];
8871 char errorcodesubcode_str
[256];
8873 code_str
= bgp_notify_code_str(peer
->notify
.code
);
8874 subcode_str
= bgp_notify_subcode_str(
8876 peer
->notify
.subcode
);
8878 snprintf(errorcodesubcode_hexstr
,
8879 sizeof(errorcodesubcode_hexstr
), "%02X%02X",
8880 peer
->notify
.code
, peer
->notify
.subcode
);
8881 json_object_string_add(json_peer
,
8882 "lastErrorCodeSubcode",
8883 errorcodesubcode_hexstr
);
8884 snprintf(errorcodesubcode_str
, 255, "%s%s",
8885 code_str
, subcode_str
);
8886 json_object_string_add(json_peer
,
8887 "lastNotificationReason",
8888 errorcodesubcode_str
);
8889 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
8890 && peer
->notify
.code
== BGP_NOTIFY_CEASE
8891 && (peer
->notify
.subcode
8892 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
8893 || peer
->notify
.subcode
8894 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
8895 && peer
->notify
.length
) {
8897 const char *msg_str
;
8899 msg_str
= bgp_notify_admin_message(
8900 msgbuf
, sizeof(msgbuf
),
8901 (uint8_t *)peer
->notify
.data
,
8902 peer
->notify
.length
);
8904 json_object_string_add(
8906 "lastShutdownDescription",
8911 json_object_string_add(json_peer
, "lastResetDueTo",
8912 peer_down_str
[(int)peer
->last_reset
]);
8913 json_object_int_add(json_peer
, "lastResetCode",
8916 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
8917 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
8918 code_str
= bgp_notify_code_str(peer
->notify
.code
);
8920 bgp_notify_subcode_str(peer
->notify
.code
,
8921 peer
->notify
.subcode
);
8922 vty_out(vty
, " Notification %s (%s%s)\n",
8923 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
8926 code_str
, subcode_str
);
8928 vty_out(vty
, " %s\n",
8929 peer_down_str
[(int)peer
->last_reset
]);
8934 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
8937 return ((peer
->status
!= Established
) ||
8938 !peer
->afc_recv
[afi
][safi
]);
8941 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
8942 struct peer
*peer
, json_object
*json_peer
,
8943 int max_neighbor_width
, bool use_json
)
8945 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
8949 if (peer_dynamic_neighbor(peer
))
8950 json_object_boolean_true_add(json_peer
,
8953 json_object_string_add(json_peer
, "hostname",
8956 if (peer
->domainname
)
8957 json_object_string_add(json_peer
, "domainname",
8959 json_object_int_add(json_peer
, "connectionsEstablished",
8961 json_object_int_add(json_peer
, "connectionsDropped",
8963 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8964 use_json
, json_peer
);
8965 if (peer
->status
== Established
)
8966 json_object_string_add(json_peer
, "lastResetDueTo",
8967 "AFI/SAFI Not Negotiated");
8969 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
8972 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
8974 && CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
))
8975 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8976 peer
->hostname
, peer
->host
);
8978 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8980 /* pad the neighbor column with spaces */
8981 if (len
< max_neighbor_width
)
8982 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8984 vty_out(vty
, "%7d %7d %9s", peer
->established
,
8986 peer_uptime(peer
->uptime
, timebuf
,
8987 BGP_UPTIME_LEN
, 0, NULL
));
8988 if (peer
->status
== Established
)
8989 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
8991 bgp_show_peer_reset(vty
, peer
, NULL
,
8997 /* Show BGP peer's summary information. */
8998 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
8999 bool show_failed
, bool show_established
,
9003 struct listnode
*node
, *nnode
;
9004 unsigned int count
= 0, dn_count
= 0;
9005 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
9006 char neighbor_buf
[VTY_BUFSIZ
];
9007 int neighbor_col_default_width
= 16;
9008 int len
, failed_count
= 0;
9009 int max_neighbor_width
= 0;
9011 json_object
*json
= NULL
;
9012 json_object
*json_peer
= NULL
;
9013 json_object
*json_peers
= NULL
;
9014 struct peer_af
*paf
;
9015 struct bgp_filter
*filter
;
9017 /* labeled-unicast routes are installed in the unicast table so in order
9019 * display the correct PfxRcd value we must look at SAFI_UNICAST
9022 if (safi
== SAFI_LABELED_UNICAST
)
9023 pfx_rcd_safi
= SAFI_UNICAST
;
9025 pfx_rcd_safi
= safi
;
9028 json
= json_object_new_object();
9029 json_peers
= json_object_new_object();
9030 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
9031 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
9034 if (peer
->afc
[afi
][safi
]) {
9035 /* See if we have at least a single failed peer */
9036 if (bgp_has_peer_failed(peer
, afi
, safi
))
9040 if (peer_dynamic_neighbor(peer
))
9045 /* Loop over all neighbors that will be displayed to determine
9047 * characters are needed for the Neighbor column
9049 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
9050 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
9053 if (peer
->afc
[afi
][safi
]) {
9054 memset(dn_flag
, '\0', sizeof(dn_flag
));
9055 if (peer_dynamic_neighbor(peer
))
9059 && CHECK_FLAG(bgp
->flags
,
9060 BGP_FLAG_SHOW_HOSTNAME
))
9061 snprintf(neighbor_buf
,
9062 sizeof(neighbor_buf
),
9063 "%s%s(%s) ", dn_flag
,
9064 peer
->hostname
, peer
->host
);
9066 snprintf(neighbor_buf
,
9067 sizeof(neighbor_buf
), "%s%s ",
9068 dn_flag
, peer
->host
);
9070 len
= strlen(neighbor_buf
);
9072 if (len
> max_neighbor_width
)
9073 max_neighbor_width
= len
;
9075 /* See if we have at least a single failed peer */
9076 if (bgp_has_peer_failed(peer
, afi
, safi
))
9082 /* Originally we displayed the Neighbor column as 16
9083 * characters wide so make that the default
9085 if (max_neighbor_width
< neighbor_col_default_width
)
9086 max_neighbor_width
= neighbor_col_default_width
;
9089 if (show_failed
&& !failed_count
) {
9091 json_object_int_add(json
, "failedPeersCount", 0);
9092 json_object_int_add(json
, "dynamicPeers", dn_count
);
9093 json_object_int_add(json
, "totalPeers", count
);
9095 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
9096 json
, JSON_C_TO_STRING_PRETTY
));
9097 json_object_free(json
);
9099 vty_out(vty
, "%% No failed BGP neighbors found\n");
9100 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
9105 count
= 0; /* Reset the value as its used again */
9106 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
9107 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
9110 if (!peer
->afc
[afi
][safi
])
9115 char memstrbuf
[MTYPE_MEMSTR_LEN
];
9118 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
9120 : (int64_t)bgp
->vrf_id
;
9122 /* Usage summary and header */
9124 json_object_string_add(
9126 inet_ntoa(bgp
->router_id
));
9127 json_object_int_add(json
, "as", bgp
->as
);
9128 json_object_int_add(json
, "vrfId", vrf_id_ui
);
9129 json_object_string_add(
9132 == BGP_INSTANCE_TYPE_DEFAULT
)
9137 "BGP router identifier %s, local AS number %u vrf-id %d",
9138 inet_ntoa(bgp
->router_id
), bgp
->as
,
9139 bgp
->vrf_id
== VRF_UNKNOWN
9141 : (int)bgp
->vrf_id
);
9145 if (bgp_update_delay_configured(bgp
)) {
9147 json_object_int_add(
9148 json
, "updateDelayLimit",
9149 bgp
->v_update_delay
);
9151 if (bgp
->v_update_delay
9152 != bgp
->v_establish_wait
)
9153 json_object_int_add(
9155 "updateDelayEstablishWait",
9156 bgp
->v_establish_wait
);
9158 if (bgp_update_delay_active(bgp
)) {
9159 json_object_string_add(
9161 "updateDelayFirstNeighbor",
9162 bgp
->update_delay_begin_time
);
9163 json_object_boolean_true_add(
9165 "updateDelayInProgress");
9167 if (bgp
->update_delay_over
) {
9168 json_object_string_add(
9170 "updateDelayFirstNeighbor",
9171 bgp
->update_delay_begin_time
);
9172 json_object_string_add(
9174 "updateDelayBestpathResumed",
9175 bgp
->update_delay_end_time
);
9176 json_object_string_add(
9178 "updateDelayZebraUpdateResume",
9179 bgp
->update_delay_zebra_resume_time
);
9180 json_object_string_add(
9182 "updateDelayPeerUpdateResume",
9183 bgp
->update_delay_peers_resume_time
);
9188 "Read-only mode update-delay limit: %d seconds\n",
9189 bgp
->v_update_delay
);
9190 if (bgp
->v_update_delay
9191 != bgp
->v_establish_wait
)
9193 " Establish wait: %d seconds\n",
9194 bgp
->v_establish_wait
);
9196 if (bgp_update_delay_active(bgp
)) {
9198 " First neighbor established: %s\n",
9199 bgp
->update_delay_begin_time
);
9201 " Delay in progress\n");
9203 if (bgp
->update_delay_over
) {
9205 " First neighbor established: %s\n",
9206 bgp
->update_delay_begin_time
);
9208 " Best-paths resumed: %s\n",
9209 bgp
->update_delay_end_time
);
9211 " zebra update resumed: %s\n",
9212 bgp
->update_delay_zebra_resume_time
);
9214 " peers update resumed: %s\n",
9215 bgp
->update_delay_peers_resume_time
);
9222 if (bgp_maxmed_onstartup_configured(bgp
)
9223 && bgp
->maxmed_active
)
9224 json_object_boolean_true_add(
9225 json
, "maxMedOnStartup");
9226 if (bgp
->v_maxmed_admin
)
9227 json_object_boolean_true_add(
9228 json
, "maxMedAdministrative");
9230 json_object_int_add(
9231 json
, "tableVersion",
9232 bgp_table_version(bgp
->rib
[afi
][safi
]));
9234 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
9235 json_object_int_add(json
, "ribCount", ents
);
9236 json_object_int_add(
9238 ents
* sizeof(struct bgp_dest
));
9240 ents
= bgp
->af_peer_count
[afi
][safi
];
9241 json_object_int_add(json
, "peerCount", ents
);
9242 json_object_int_add(json
, "peerMemory",
9243 ents
* sizeof(struct peer
));
9245 if ((ents
= listcount(bgp
->group
))) {
9246 json_object_int_add(
9247 json
, "peerGroupCount", ents
);
9248 json_object_int_add(
9249 json
, "peerGroupMemory",
9250 ents
* sizeof(struct
9254 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
9255 BGP_CONFIG_DAMPENING
))
9256 json_object_boolean_true_add(
9257 json
, "dampeningEnabled");
9259 if (bgp_maxmed_onstartup_configured(bgp
)
9260 && bgp
->maxmed_active
)
9262 "Max-med on-startup active\n");
9263 if (bgp
->v_maxmed_admin
)
9265 "Max-med administrative active\n");
9267 vty_out(vty
, "BGP table version %" PRIu64
"\n",
9268 bgp_table_version(bgp
->rib
[afi
][safi
]));
9270 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
9272 "RIB entries %ld, using %s of memory\n",
9275 memstrbuf
, sizeof(memstrbuf
),
9280 /* Peer related usage */
9281 ents
= bgp
->af_peer_count
[afi
][safi
];
9282 vty_out(vty
, "Peers %ld, using %s of memory\n",
9285 memstrbuf
, sizeof(memstrbuf
),
9286 ents
* sizeof(struct peer
)));
9288 if ((ents
= listcount(bgp
->group
)))
9290 "Peer groups %ld, using %s of memory\n",
9295 ents
* sizeof(struct
9298 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
9299 BGP_CONFIG_DAMPENING
))
9300 vty_out(vty
, "Dampening enabled.\n");
9303 /* Subtract 8 here because 'Neighbor' is
9305 vty_out(vty
, "Neighbor");
9306 vty_out(vty
, "%*s", max_neighbor_width
- 8,
9309 vty_out(vty
, "EstdCnt DropCnt ResetTime Reason\n");
9312 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd PfxSnt\n");
9316 paf
= peer_af_find(peer
, afi
, safi
);
9317 filter
= &peer
->filter
[afi
][safi
];
9320 /* Works for both failed & successful cases */
9321 if (peer_dynamic_neighbor(peer
))
9328 bgp_has_peer_failed(peer
, afi
, safi
)) {
9329 json_peer
= json_object_new_object();
9330 bgp_show_failed_summary(vty
, bgp
, peer
,
9331 json_peer
, 0, use_json
);
9332 } else if (!show_failed
) {
9333 if (show_established
9334 && bgp_has_peer_failed(peer
, afi
, safi
))
9337 json_peer
= json_object_new_object();
9338 if (peer_dynamic_neighbor(peer
)) {
9339 json_object_boolean_true_add(json_peer
,
9344 json_object_string_add(json_peer
, "hostname",
9347 if (peer
->domainname
)
9348 json_object_string_add(json_peer
, "domainname",
9351 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
9352 json_object_int_add(json_peer
, "version", 4);
9353 json_object_int_add(json_peer
, "msgRcvd",
9354 PEER_TOTAL_RX(peer
));
9355 json_object_int_add(json_peer
, "msgSent",
9356 PEER_TOTAL_TX(peer
));
9358 atomic_size_t outq_count
, inq_count
;
9359 outq_count
= atomic_load_explicit(
9361 memory_order_relaxed
);
9362 inq_count
= atomic_load_explicit(
9364 memory_order_relaxed
);
9366 json_object_int_add(json_peer
, "tableVersion",
9367 peer
->version
[afi
][safi
]);
9368 json_object_int_add(json_peer
, "outq",
9370 json_object_int_add(json_peer
, "inq",
9372 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9373 use_json
, json_peer
);
9375 json_object_int_add(json_peer
, "pfxRcd",
9376 peer
->pcount
[afi
][pfx_rcd_safi
]);
9378 if (paf
&& PAF_SUBGRP(paf
))
9379 json_object_int_add(json_peer
,
9381 (PAF_SUBGRP(paf
))->scount
);
9382 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
9383 || CHECK_FLAG(peer
->bgp
->flags
,
9385 json_object_string_add(json_peer
, "state",
9387 else if (peer
->afc_recv
[afi
][safi
])
9388 json_object_string_add(
9390 lookup_msg(bgp_status_msg
, peer
->status
,
9392 else if (CHECK_FLAG(peer
->sflags
,
9393 PEER_STATUS_PREFIX_OVERFLOW
))
9394 json_object_string_add(json_peer
, "state",
9397 json_object_string_add(
9399 lookup_msg(bgp_status_msg
, peer
->status
,
9401 json_object_int_add(json_peer
, "connectionsEstablished",
9403 json_object_int_add(json_peer
, "connectionsDropped",
9406 /* Avoid creating empty peer dicts in JSON */
9407 if (json_peer
== NULL
)
9411 json_object_string_add(json_peer
, "idType",
9413 else if (peer
->su
.sa
.sa_family
== AF_INET
)
9414 json_object_string_add(json_peer
, "idType",
9416 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
9417 json_object_string_add(json_peer
, "idType",
9419 json_object_object_add(json_peers
, peer
->host
,
9423 bgp_has_peer_failed(peer
, afi
, safi
)) {
9424 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
9427 } else if (!show_failed
) {
9428 if (show_established
9429 && bgp_has_peer_failed(peer
, afi
, safi
))
9432 memset(dn_flag
, '\0', sizeof(dn_flag
));
9433 if (peer_dynamic_neighbor(peer
)) {
9438 && CHECK_FLAG(bgp
->flags
,
9439 BGP_FLAG_SHOW_HOSTNAME
))
9440 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
9444 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
9446 /* pad the neighbor column with spaces */
9447 if (len
< max_neighbor_width
)
9448 vty_out(vty
, "%*s", max_neighbor_width
- len
,
9451 atomic_size_t outq_count
, inq_count
;
9452 outq_count
= atomic_load_explicit(
9454 memory_order_relaxed
);
9455 inq_count
= atomic_load_explicit(
9457 memory_order_relaxed
);
9460 "4 %10u %9u %9u %8" PRIu64
" %4zu %4zu %8s",
9461 peer
->as
, PEER_TOTAL_RX(peer
),
9462 PEER_TOTAL_TX(peer
),
9463 peer
->version
[afi
][safi
], inq_count
,
9465 peer_uptime(peer
->uptime
, timebuf
,
9466 BGP_UPTIME_LEN
, 0, NULL
));
9468 if (peer
->status
== Established
) {
9469 if (peer
->afc_recv
[afi
][safi
]) {
9472 BGP_FLAG_EBGP_REQUIRES_POLICY
)
9473 && !bgp_inbound_policy_exists(
9475 vty_out(vty
, " %12s",
9484 vty_out(vty
, " NoNeg");
9487 if (paf
&& PAF_SUBGRP(paf
)) {
9490 BGP_FLAG_EBGP_REQUIRES_POLICY
)
9491 && !bgp_outbound_policy_exists(
9493 vty_out(vty
, " %8s",
9503 if (CHECK_FLAG(peer
->flags
,
9505 || CHECK_FLAG(peer
->bgp
->flags
,
9507 vty_out(vty
, " Idle (Admin)");
9508 else if (CHECK_FLAG(
9510 PEER_STATUS_PREFIX_OVERFLOW
))
9511 vty_out(vty
, " Idle (PfxCt)");
9513 vty_out(vty
, " %12s",
9514 lookup_msg(bgp_status_msg
,
9515 peer
->status
, NULL
));
9517 vty_out(vty
, " %8u", 0);
9526 json_object_object_add(json
, "peers", json_peers
);
9527 json_object_int_add(json
, "failedPeers", failed_count
);
9528 json_object_int_add(json
, "totalPeers", count
);
9529 json_object_int_add(json
, "dynamicPeers", dn_count
);
9532 bgp_show_bestpath_json(bgp
, json
);
9534 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
9535 json
, JSON_C_TO_STRING_PRETTY
));
9536 json_object_free(json
);
9539 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
9541 vty_out(vty
, "No %s neighbor is configured\n",
9542 get_afi_safi_str(afi
, safi
, false));
9546 vty_out(vty
, "* - dynamic neighbor\n");
9547 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
9548 dn_count
, bgp
->dynamic_neighbors_limit
);
9555 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
9556 int safi
, bool show_failed
,
9557 bool show_established
, bool use_json
)
9560 int afi_wildcard
= (afi
== AFI_MAX
);
9561 int safi_wildcard
= (safi
== SAFI_MAX
);
9562 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
9563 bool nbr_output
= false;
9565 if (use_json
&& is_wildcard
)
9566 vty_out(vty
, "{\n");
9568 afi
= 1; /* AFI_IP */
9569 while (afi
< AFI_MAX
) {
9571 safi
= 1; /* SAFI_UNICAST */
9572 while (safi
< SAFI_MAX
) {
9573 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
9578 * So limit output to those afi/safi
9580 * actualy have something interesting in
9585 vty_out(vty
, ",\n");
9589 vty_out(vty
, "\"%s\":",
9590 get_afi_safi_str(afi
,
9594 vty_out(vty
, "\n%s Summary:\n",
9595 get_afi_safi_str(afi
,
9600 bgp_show_summary(vty
, bgp
, afi
, safi
,
9601 show_failed
, show_established
,
9613 if (use_json
&& is_wildcard
)
9614 vty_out(vty
, "}\n");
9615 else if (!nbr_output
) {
9617 vty_out(vty
, "{}\n");
9619 vty_out(vty
, "%% No BGP neighbors found\n");
9623 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
9624 safi_t safi
, bool show_failed
,
9625 bool show_established
,
9628 struct listnode
*node
, *nnode
;
9631 bool nbr_output
= false;
9634 vty_out(vty
, "{\n");
9636 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
9640 vty_out(vty
, ",\n");
9644 vty_out(vty
, "\"%s\":",
9645 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
9649 vty_out(vty
, "\nInstance %s:\n",
9650 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
9654 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
9655 show_established
, use_json
);
9659 vty_out(vty
, "}\n");
9660 else if (!nbr_output
)
9661 vty_out(vty
, "%% BGP instance not found\n");
9664 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
9665 safi_t safi
, bool show_failed
, bool show_established
,
9671 if (strmatch(name
, "all")) {
9672 bgp_show_all_instances_summary_vty(
9673 vty
, afi
, safi
, show_failed
, show_established
,
9677 bgp
= bgp_lookup_by_name(name
);
9681 vty_out(vty
, "{}\n");
9684 "%% BGP instance not found\n");
9688 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
,
9689 show_failed
, show_established
,
9695 bgp
= bgp_get_default();
9698 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
9699 show_established
, use_json
);
9702 vty_out(vty
, "{}\n");
9704 vty_out(vty
, "%% BGP instance not found\n");
9711 /* `show [ip] bgp summary' commands. */
9712 DEFUN (show_ip_bgp_summary
,
9713 show_ip_bgp_summary_cmd
,
9714 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [established|failed] [json]",
9718 BGP_INSTANCE_HELP_STR
9720 BGP_SAFI_WITH_LABEL_HELP_STR
9721 "Summary of BGP neighbor status\n"
9722 "Show only sessions in Established state\n"
9723 "Show only sessions not in Established state\n"
9727 afi_t afi
= AFI_MAX
;
9728 safi_t safi
= SAFI_MAX
;
9729 bool show_failed
= false;
9730 bool show_established
= false;
9735 if (argv_find(argv
, argc
, "ip", &idx
))
9737 /* [<vrf> VIEWVRFNAME] */
9738 if (argv_find(argv
, argc
, "vrf", &idx
)) {
9739 vrf
= argv
[idx
+ 1]->arg
;
9740 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
9742 } else if (argv_find(argv
, argc
, "view", &idx
))
9743 /* [<view> VIEWVRFNAME] */
9744 vrf
= argv
[idx
+ 1]->arg
;
9745 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
9746 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
9747 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
9750 if (argv_find(argv
, argc
, "failed", &idx
))
9752 if (argv_find(argv
, argc
, "established", &idx
))
9753 show_established
= true;
9755 bool uj
= use_json(argc
, argv
);
9757 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, show_failed
,
9758 show_established
, uj
);
9761 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
9764 return get_afi_safi_json_str(afi
, safi
);
9766 return get_afi_safi_vty_str(afi
, safi
);
9770 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
9771 afi_t afi
, safi_t safi
,
9772 uint16_t adv_smcap
, uint16_t adv_rmcap
,
9773 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
9774 bool use_json
, json_object
*json_pref
)
9777 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
9778 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
9780 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
9781 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
9782 json_object_string_add(json_pref
, "sendMode",
9783 "advertisedAndReceived");
9784 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
9785 json_object_string_add(json_pref
, "sendMode",
9787 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
9788 json_object_string_add(json_pref
, "sendMode",
9791 vty_out(vty
, " Send-mode: ");
9792 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
9793 vty_out(vty
, "advertised");
9794 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
9795 vty_out(vty
, "%sreceived",
9796 CHECK_FLAG(p
->af_cap
[afi
][safi
],
9805 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
9806 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
9808 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
9809 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
9810 json_object_string_add(json_pref
, "recvMode",
9811 "advertisedAndReceived");
9812 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
9813 json_object_string_add(json_pref
, "recvMode",
9815 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
9816 json_object_string_add(json_pref
, "recvMode",
9819 vty_out(vty
, " Receive-mode: ");
9820 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
9821 vty_out(vty
, "advertised");
9822 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
9823 vty_out(vty
, "%sreceived",
9824 CHECK_FLAG(p
->af_cap
[afi
][safi
],
9833 static void bgp_show_neighnor_graceful_restart_rbit(struct vty
*vty
,
9838 bool rbit_status
= false;
9841 vty_out(vty
, "\n R bit: ");
9843 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_ADV
)
9844 && (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
))
9845 && (p
->status
== Established
)) {
9847 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_BIT_RCV
))
9850 rbit_status
= false;
9855 json_object_boolean_true_add(json
, "rBit");
9857 vty_out(vty
, "True\n");
9860 json_object_boolean_false_add(json
, "rBit");
9862 vty_out(vty
, "False\n");
9866 static void bgp_show_neighbor_graceful_restart_remote_mode(struct vty
*vty
,
9871 const char *mode
= "NotApplicable";
9874 vty_out(vty
, "\n Remote GR Mode: ");
9876 if (CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
9877 && (peer
->status
== Established
)) {
9879 if ((peer
->nsf_af_count
== 0)
9880 && !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
9884 } else if (peer
->nsf_af_count
== 0
9885 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
9889 } else if (peer
->nsf_af_count
!= 0
9890 && CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
)) {
9897 json_object_string_add(json
, "remoteGrMode", mode
);
9899 vty_out(vty
, mode
, "\n");
9902 static void bgp_show_neighbor_graceful_restart_local_mode(struct vty
*vty
,
9907 const char *mode
= "Invalid";
9910 vty_out(vty
, " Local GR Mode: ");
9912 if (bgp_peer_gr_mode_get(p
) == PEER_HELPER
)
9914 else if (bgp_peer_gr_mode_get(p
) == PEER_GR
)
9916 else if (bgp_peer_gr_mode_get(p
) == PEER_DISABLE
)
9918 else if (bgp_peer_gr_mode_get(p
) == PEER_GLOBAL_INHERIT
) {
9919 if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_HELPER
)
9921 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_GR
)
9923 else if (bgp_global_gr_mode_get(p
->bgp
) == GLOBAL_DISABLE
)
9930 json_object_string_add(json
, "localGrMode", mode
);
9932 vty_out(vty
, mode
, "\n");
9936 static void bgp_show_neighbor_graceful_restart_capability_per_afi_safi(
9937 struct vty
*vty
, struct peer
*peer
, bool use_json
, json_object
*json
)
9941 json_object
*json_afi_safi
= NULL
;
9942 json_object
*json_timer
= NULL
;
9943 json_object
*json_endofrib_status
= NULL
;
9944 bool eor_flag
= false;
9946 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
9947 for (safi
= SAFI_UNICAST
; safi
<= SAFI_MPLS_VPN
; safi
++) {
9948 if (!peer
->afc
[afi
][safi
])
9951 if (!CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_ADV
)
9952 || !CHECK_FLAG(peer
->cap
, PEER_CAP_RESTART_RCV
))
9956 json_afi_safi
= json_object_new_object();
9957 json_endofrib_status
= json_object_new_object();
9958 json_timer
= json_object_new_object();
9961 if (peer
->eor_stime
[afi
][safi
]
9962 >= peer
->pkt_stime
[afi
][safi
])
9968 vty_out(vty
, " %s:\n",
9969 get_afi_safi_str(afi
, safi
, false));
9971 vty_out(vty
, " F bit: ");
9974 if (peer
->nsf
[afi
][safi
]
9975 && CHECK_FLAG(peer
->af_cap
[afi
][safi
],
9976 PEER_CAP_RESTART_AF_PRESERVE_RCV
)) {
9979 json_object_boolean_true_add(
9980 json_afi_safi
, "fBit");
9982 vty_out(vty
, "True\n");
9985 json_object_boolean_false_add(
9986 json_afi_safi
, "fBit");
9988 vty_out(vty
, "False\n");
9992 vty_out(vty
, " End-of-RIB sent: ");
9994 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
9995 PEER_STATUS_EOR_SEND
)) {
9997 json_object_boolean_true_add(
9998 json_endofrib_status
,
10001 PRINT_EOR_JSON(eor_flag
);
10003 vty_out(vty
, "Yes\n");
10005 " End-of-RIB sent after update: ");
10007 PRINT_EOR(eor_flag
);
10011 json_object_boolean_false_add(
10012 json_endofrib_status
,
10014 json_object_boolean_false_add(
10015 json_endofrib_status
,
10016 "endOfRibSentAfterUpdate");
10018 vty_out(vty
, "No\n");
10020 " End-of-RIB sent after update: ");
10021 vty_out(vty
, "No\n");
10026 vty_out(vty
, " End-of-RIB received: ");
10028 if (CHECK_FLAG(peer
->af_sflags
[afi
][safi
],
10029 PEER_STATUS_EOR_RECEIVED
)) {
10031 json_object_boolean_true_add(
10032 json_endofrib_status
,
10035 vty_out(vty
, "Yes\n");
10038 json_object_boolean_false_add(
10039 json_endofrib_status
,
10042 vty_out(vty
, "No\n");
10046 json_object_int_add(json_timer
,
10048 peer
->bgp
->stalepath_time
);
10050 if (peer
->t_gr_stale
!= NULL
) {
10051 json_object_int_add(
10053 "stalePathTimerRemaining",
10054 thread_timer_remain_second(
10055 peer
->t_gr_stale
));
10058 /* Display Configured Selection
10059 * Deferral only when when
10060 * Gr mode is enabled.
10062 if (CHECK_FLAG(peer
->flags
,
10063 PEER_FLAG_GRACEFUL_RESTART
)) {
10064 json_object_int_add(
10066 "selectionDeferralTimer",
10067 peer
->bgp
->stalepath_time
);
10070 if (peer
->bgp
->gr_info
[afi
][safi
]
10074 json_object_int_add(
10076 "selectionDeferralTimerRemaining",
10077 thread_timer_remain_second(
10081 .t_select_deferral
));
10084 vty_out(vty
, " Timers:\n");
10086 " Configured Stale Path Time(sec): %u\n",
10087 peer
->bgp
->stalepath_time
);
10089 if (peer
->t_gr_stale
!= NULL
)
10091 " Stale Path Remaining(sec): %ld\n",
10092 thread_timer_remain_second(
10093 peer
->t_gr_stale
));
10094 /* Display Configured Selection
10095 * Deferral only when when
10096 * Gr mode is enabled.
10098 if (CHECK_FLAG(peer
->flags
,
10099 PEER_FLAG_GRACEFUL_RESTART
))
10101 " Configured Selection Deferral Time(sec): %u\n",
10102 peer
->bgp
->select_defer_time
);
10104 if (peer
->bgp
->gr_info
[afi
][safi
]
10108 " Selection Deferral Time Remaining(sec): %ld\n",
10109 thread_timer_remain_second(
10113 .t_select_deferral
));
10116 json_object_object_add(json_afi_safi
,
10118 json_endofrib_status
);
10119 json_object_object_add(json_afi_safi
, "timers",
10121 json_object_object_add(
10122 json
, get_afi_safi_str(afi
, safi
, true),
10129 static void bgp_show_neighbor_graceful_restart_time(struct vty
*vty
,
10135 json_object
*json_timer
= NULL
;
10137 json_timer
= json_object_new_object();
10139 json_object_int_add(json_timer
, "configuredRestartTimer",
10140 p
->bgp
->restart_time
);
10142 json_object_int_add(json_timer
, "receivedRestartTimer",
10145 if (p
->t_gr_restart
!= NULL
)
10146 json_object_int_add(
10147 json_timer
, "restartTimerRemaining",
10148 thread_timer_remain_second(p
->t_gr_restart
));
10150 json_object_object_add(json
, "timers", json_timer
);
10153 vty_out(vty
, " Timers:\n");
10154 vty_out(vty
, " Configured Restart Time(sec): %u\n",
10155 p
->bgp
->restart_time
);
10157 vty_out(vty
, " Received Restart Time(sec): %u\n",
10159 if (p
->t_gr_restart
!= NULL
)
10160 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
10161 thread_timer_remain_second(p
->t_gr_restart
));
10162 if (p
->t_gr_restart
!= NULL
) {
10163 vty_out(vty
, " Restart Time Remaining(sec): %ld\n",
10164 thread_timer_remain_second(p
->t_gr_restart
));
10169 static void bgp_show_peer_gr_status(struct vty
*vty
, struct peer
*p
,
10170 bool use_json
, json_object
*json
)
10172 char buf
[SU_ADDRSTRLEN
] = {0};
10173 char dn_flag
[2] = {0};
10174 /* '*' + v6 address of neighbor */
10175 char neighborAddr
[INET6_ADDRSTRLEN
+ 1] = {0};
10177 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
10182 json_object_string_add(
10183 json
, "neighborAddr",
10184 BGP_PEER_SU_UNSPEC(p
)
10186 : sockunion2str(&p
->su
, buf
,
10189 vty_out(vty
, "BGP neighbor on %s: %s\n", p
->conf_if
,
10190 BGP_PEER_SU_UNSPEC(p
)
10192 : sockunion2str(&p
->su
, buf
,
10195 snprintf(neighborAddr
, sizeof(neighborAddr
), "%s%s", dn_flag
,
10199 json_object_string_add(json
, "neighborAddr",
10202 vty_out(vty
, "BGP neighbor is %s\n", neighborAddr
);
10205 /* more gr info in new format */
10206 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, json
);
10209 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
10210 safi_t safi
, bool use_json
,
10211 json_object
*json_neigh
)
10213 struct bgp_filter
*filter
;
10214 struct peer_af
*paf
;
10215 char orf_pfx_name
[BUFSIZ
];
10217 json_object
*json_af
= NULL
;
10218 json_object
*json_prefA
= NULL
;
10219 json_object
*json_prefB
= NULL
;
10220 json_object
*json_addr
= NULL
;
10223 json_addr
= json_object_new_object();
10224 json_af
= json_object_new_object();
10225 filter
= &p
->filter
[afi
][safi
];
10227 if (peer_group_active(p
))
10228 json_object_string_add(json_addr
, "peerGroupMember",
10231 paf
= peer_af_find(p
, afi
, safi
);
10232 if (paf
&& PAF_SUBGRP(paf
)) {
10233 json_object_int_add(json_addr
, "updateGroupId",
10234 PAF_UPDGRP(paf
)->id
);
10235 json_object_int_add(json_addr
, "subGroupId",
10236 PAF_SUBGRP(paf
)->id
);
10237 json_object_int_add(json_addr
, "packetQueueLength",
10238 bpacket_queue_virtual_length(paf
));
10241 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
10242 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10243 PEER_CAP_ORF_PREFIX_SM_RCV
)
10244 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10245 PEER_CAP_ORF_PREFIX_RM_ADV
)
10246 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10247 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
10248 json_object_int_add(json_af
, "orfType",
10250 json_prefA
= json_object_new_object();
10251 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
10252 PEER_CAP_ORF_PREFIX_SM_ADV
,
10253 PEER_CAP_ORF_PREFIX_RM_ADV
,
10254 PEER_CAP_ORF_PREFIX_SM_RCV
,
10255 PEER_CAP_ORF_PREFIX_RM_RCV
,
10256 use_json
, json_prefA
);
10257 json_object_object_add(json_af
, "orfPrefixList",
10261 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
10262 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10263 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
10264 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10265 PEER_CAP_ORF_PREFIX_RM_ADV
)
10266 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10267 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
10268 json_object_int_add(json_af
, "orfOldType",
10269 ORF_TYPE_PREFIX_OLD
);
10270 json_prefB
= json_object_new_object();
10271 bgp_show_peer_afi_orf_cap(
10272 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
10273 PEER_CAP_ORF_PREFIX_RM_ADV
,
10274 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
10275 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
10277 json_object_object_add(json_af
, "orfOldPrefixList",
10281 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
10282 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10283 PEER_CAP_ORF_PREFIX_SM_RCV
)
10284 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10285 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
10286 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10287 PEER_CAP_ORF_PREFIX_RM_ADV
)
10288 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10289 PEER_CAP_ORF_PREFIX_RM_RCV
)
10290 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10291 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
10292 json_object_object_add(json_addr
, "afDependentCap",
10295 json_object_free(json_af
);
10297 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
10298 p
->host
, afi
, safi
);
10299 orf_pfx_count
= prefix_bgp_show_prefix_list(
10300 NULL
, afi
, orf_pfx_name
, use_json
);
10302 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10303 PEER_STATUS_ORF_PREFIX_SEND
)
10304 || orf_pfx_count
) {
10305 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10306 PEER_STATUS_ORF_PREFIX_SEND
))
10307 json_object_boolean_true_add(json_neigh
,
10310 json_object_int_add(json_addr
, "orfRecvCounter",
10313 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10314 PEER_STATUS_ORF_WAIT_REFRESH
))
10315 json_object_string_add(
10316 json_addr
, "orfFirstUpdate",
10317 "deferredUntilORFOrRouteRefreshRecvd");
10319 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10320 PEER_FLAG_REFLECTOR_CLIENT
))
10321 json_object_boolean_true_add(json_addr
,
10322 "routeReflectorClient");
10323 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10324 PEER_FLAG_RSERVER_CLIENT
))
10325 json_object_boolean_true_add(json_addr
,
10326 "routeServerClient");
10327 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
10328 json_object_boolean_true_add(json_addr
,
10329 "inboundSoftConfigPermit");
10331 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10332 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
10333 json_object_boolean_true_add(
10335 "privateAsNumsAllReplacedInUpdatesToNbr");
10336 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10337 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
10338 json_object_boolean_true_add(
10340 "privateAsNumsReplacedInUpdatesToNbr");
10341 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10342 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
10343 json_object_boolean_true_add(
10345 "privateAsNumsAllRemovedInUpdatesToNbr");
10346 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10347 PEER_FLAG_REMOVE_PRIVATE_AS
))
10348 json_object_boolean_true_add(
10350 "privateAsNumsRemovedInUpdatesToNbr");
10352 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
10353 json_object_boolean_true_add(
10355 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
10358 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
10359 json_object_string_add(json_addr
,
10360 "overrideASNsInOutboundUpdates",
10361 "ifAspathEqualRemoteAs");
10363 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
10364 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
10365 PEER_FLAG_FORCE_NEXTHOP_SELF
))
10366 json_object_boolean_true_add(json_addr
,
10367 "routerAlwaysNextHop");
10368 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10369 PEER_FLAG_AS_PATH_UNCHANGED
))
10370 json_object_boolean_true_add(
10371 json_addr
, "unchangedAsPathPropogatedToNbr");
10372 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10373 PEER_FLAG_NEXTHOP_UNCHANGED
))
10374 json_object_boolean_true_add(
10375 json_addr
, "unchangedNextHopPropogatedToNbr");
10376 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
10377 json_object_boolean_true_add(
10378 json_addr
, "unchangedMedPropogatedToNbr");
10379 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
10380 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
10381 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
10382 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10383 PEER_FLAG_SEND_COMMUNITY
)
10384 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
10385 PEER_FLAG_SEND_EXT_COMMUNITY
))
10386 json_object_string_add(json_addr
,
10387 "commAttriSentToNbr",
10388 "extendedAndStandard");
10389 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10390 PEER_FLAG_SEND_EXT_COMMUNITY
))
10391 json_object_string_add(json_addr
,
10392 "commAttriSentToNbr",
10395 json_object_string_add(json_addr
,
10396 "commAttriSentToNbr",
10399 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10400 PEER_FLAG_DEFAULT_ORIGINATE
)) {
10401 if (p
->default_rmap
[afi
][safi
].name
)
10402 json_object_string_add(
10403 json_addr
, "defaultRouteMap",
10404 p
->default_rmap
[afi
][safi
].name
);
10406 if (paf
&& PAF_SUBGRP(paf
)
10407 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
10408 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
10409 json_object_boolean_true_add(json_addr
,
10412 json_object_boolean_true_add(json_addr
,
10416 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
10417 if (is_evpn_enabled())
10418 json_object_boolean_true_add(
10419 json_addr
, "advertiseAllVnis");
10422 if (filter
->plist
[FILTER_IN
].name
10423 || filter
->dlist
[FILTER_IN
].name
10424 || filter
->aslist
[FILTER_IN
].name
10425 || filter
->map
[RMAP_IN
].name
)
10426 json_object_boolean_true_add(json_addr
,
10427 "inboundPathPolicyConfig");
10428 if (filter
->plist
[FILTER_OUT
].name
10429 || filter
->dlist
[FILTER_OUT
].name
10430 || filter
->aslist
[FILTER_OUT
].name
10431 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
10432 json_object_boolean_true_add(
10433 json_addr
, "outboundPathPolicyConfig");
10436 if (filter
->plist
[FILTER_IN
].name
)
10437 json_object_string_add(json_addr
,
10438 "incomingUpdatePrefixFilterList",
10439 filter
->plist
[FILTER_IN
].name
);
10440 if (filter
->plist
[FILTER_OUT
].name
)
10441 json_object_string_add(json_addr
,
10442 "outgoingUpdatePrefixFilterList",
10443 filter
->plist
[FILTER_OUT
].name
);
10445 /* distribute-list */
10446 if (filter
->dlist
[FILTER_IN
].name
)
10447 json_object_string_add(
10448 json_addr
, "incomingUpdateNetworkFilterList",
10449 filter
->dlist
[FILTER_IN
].name
);
10450 if (filter
->dlist
[FILTER_OUT
].name
)
10451 json_object_string_add(
10452 json_addr
, "outgoingUpdateNetworkFilterList",
10453 filter
->dlist
[FILTER_OUT
].name
);
10456 if (filter
->aslist
[FILTER_IN
].name
)
10457 json_object_string_add(json_addr
,
10458 "incomingUpdateAsPathFilterList",
10459 filter
->aslist
[FILTER_IN
].name
);
10460 if (filter
->aslist
[FILTER_OUT
].name
)
10461 json_object_string_add(json_addr
,
10462 "outgoingUpdateAsPathFilterList",
10463 filter
->aslist
[FILTER_OUT
].name
);
10466 if (filter
->map
[RMAP_IN
].name
)
10467 json_object_string_add(
10468 json_addr
, "routeMapForIncomingAdvertisements",
10469 filter
->map
[RMAP_IN
].name
);
10470 if (filter
->map
[RMAP_OUT
].name
)
10471 json_object_string_add(
10472 json_addr
, "routeMapForOutgoingAdvertisements",
10473 filter
->map
[RMAP_OUT
].name
);
10475 /* ebgp-requires-policy (inbound) */
10476 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
10477 && !bgp_inbound_policy_exists(p
, filter
))
10478 json_object_string_add(
10479 json_addr
, "inboundEbgpRequiresPolicy",
10480 "Inbound updates discarded due to missing policy");
10482 /* ebgp-requires-policy (outbound) */
10483 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
10484 && (!bgp_outbound_policy_exists(p
, filter
)))
10485 json_object_string_add(
10486 json_addr
, "outboundEbgpRequiresPolicy",
10487 "Outbound updates discarded due to missing policy");
10489 /* unsuppress-map */
10490 if (filter
->usmap
.name
)
10491 json_object_string_add(json_addr
,
10492 "selectiveUnsuppressRouteMap",
10493 filter
->usmap
.name
);
10495 /* Receive prefix count */
10496 json_object_int_add(json_addr
, "acceptedPrefixCounter",
10497 p
->pcount
[afi
][safi
]);
10498 if (paf
&& PAF_SUBGRP(paf
))
10499 json_object_int_add(json_addr
, "sentPrefixCounter",
10500 (PAF_SUBGRP(paf
))->scount
);
10502 /* Maximum prefix */
10503 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX_OUT
))
10504 json_object_int_add(json_addr
, "prefixOutAllowedMax",
10505 p
->pmax_out
[afi
][safi
]);
10507 /* Maximum prefix */
10508 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
10509 json_object_int_add(json_addr
, "prefixAllowedMax",
10510 p
->pmax
[afi
][safi
]);
10511 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10512 PEER_FLAG_MAX_PREFIX_WARNING
))
10513 json_object_boolean_true_add(
10514 json_addr
, "prefixAllowedMaxWarning");
10515 json_object_int_add(json_addr
,
10516 "prefixAllowedWarningThresh",
10517 p
->pmax_threshold
[afi
][safi
]);
10518 if (p
->pmax_restart
[afi
][safi
])
10519 json_object_int_add(
10521 "prefixAllowedRestartIntervalMsecs",
10522 p
->pmax_restart
[afi
][safi
] * 60000);
10524 json_object_object_add(json_neigh
,
10525 get_afi_safi_str(afi
, safi
, true),
10529 filter
= &p
->filter
[afi
][safi
];
10531 vty_out(vty
, " For address family: %s\n",
10532 get_afi_safi_str(afi
, safi
, false));
10534 if (peer_group_active(p
))
10535 vty_out(vty
, " %s peer-group member\n",
10538 paf
= peer_af_find(p
, afi
, safi
);
10539 if (paf
&& PAF_SUBGRP(paf
)) {
10540 vty_out(vty
, " Update group %" PRIu64
", subgroup %" PRIu64
"\n",
10541 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
10542 vty_out(vty
, " Packet Queue length %d\n",
10543 bpacket_queue_virtual_length(paf
));
10545 vty_out(vty
, " Not part of any update group\n");
10547 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
10548 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10549 PEER_CAP_ORF_PREFIX_SM_RCV
)
10550 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10551 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
10552 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10553 PEER_CAP_ORF_PREFIX_RM_ADV
)
10554 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10555 PEER_CAP_ORF_PREFIX_RM_RCV
)
10556 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10557 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
10558 vty_out(vty
, " AF-dependant capabilities:\n");
10560 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
10561 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10562 PEER_CAP_ORF_PREFIX_SM_RCV
)
10563 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10564 PEER_CAP_ORF_PREFIX_RM_ADV
)
10565 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10566 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
10568 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
10570 bgp_show_peer_afi_orf_cap(
10571 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
10572 PEER_CAP_ORF_PREFIX_RM_ADV
,
10573 PEER_CAP_ORF_PREFIX_SM_RCV
,
10574 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
10576 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
10577 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10578 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
10579 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10580 PEER_CAP_ORF_PREFIX_RM_ADV
)
10581 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
10582 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
10584 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
10585 ORF_TYPE_PREFIX_OLD
);
10586 bgp_show_peer_afi_orf_cap(
10587 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
10588 PEER_CAP_ORF_PREFIX_RM_ADV
,
10589 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
10590 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
10593 snprintf(orf_pfx_name
, sizeof(orf_pfx_name
), "%s.%d.%d",
10594 p
->host
, afi
, safi
);
10595 orf_pfx_count
= prefix_bgp_show_prefix_list(
10596 NULL
, afi
, orf_pfx_name
, use_json
);
10598 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10599 PEER_STATUS_ORF_PREFIX_SEND
)
10600 || orf_pfx_count
) {
10601 vty_out(vty
, " Outbound Route Filter (ORF):");
10602 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10603 PEER_STATUS_ORF_PREFIX_SEND
))
10604 vty_out(vty
, " sent;");
10606 vty_out(vty
, " received (%d entries)",
10608 vty_out(vty
, "\n");
10610 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10611 PEER_STATUS_ORF_WAIT_REFRESH
))
10613 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
10615 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10616 PEER_FLAG_REFLECTOR_CLIENT
))
10617 vty_out(vty
, " Route-Reflector Client\n");
10618 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10619 PEER_FLAG_RSERVER_CLIENT
))
10620 vty_out(vty
, " Route-Server Client\n");
10621 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
10623 " Inbound soft reconfiguration allowed\n");
10625 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10626 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
10628 " Private AS numbers (all) replaced in updates to this neighbor\n");
10629 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10630 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
10632 " Private AS numbers replaced in updates to this neighbor\n");
10633 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10634 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
10636 " Private AS numbers (all) removed in updates to this neighbor\n");
10637 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10638 PEER_FLAG_REMOVE_PRIVATE_AS
))
10640 " Private AS numbers removed in updates to this neighbor\n");
10642 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
10643 vty_out(vty
, " %s\n",
10644 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
10645 ->human_description
);
10647 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
10649 " Override ASNs in outbound updates if aspath equals remote-as\n");
10651 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
10652 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
10653 PEER_FLAG_FORCE_NEXTHOP_SELF
))
10654 vty_out(vty
, " NEXT_HOP is always this router\n");
10655 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10656 PEER_FLAG_AS_PATH_UNCHANGED
))
10658 " AS_PATH is propagated unchanged to this neighbor\n");
10659 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10660 PEER_FLAG_NEXTHOP_UNCHANGED
))
10662 " NEXT_HOP is propagated unchanged to this neighbor\n");
10663 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
10665 " MED is propagated unchanged to this neighbor\n");
10666 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
10667 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
10668 PEER_FLAG_SEND_EXT_COMMUNITY
)
10669 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
10670 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
10672 " Community attribute sent to this neighbor");
10673 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10674 PEER_FLAG_SEND_COMMUNITY
)
10675 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
10676 PEER_FLAG_SEND_EXT_COMMUNITY
)
10677 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
10678 PEER_FLAG_SEND_LARGE_COMMUNITY
))
10679 vty_out(vty
, "(all)\n");
10680 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10681 PEER_FLAG_SEND_LARGE_COMMUNITY
))
10682 vty_out(vty
, "(large)\n");
10683 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10684 PEER_FLAG_SEND_EXT_COMMUNITY
))
10685 vty_out(vty
, "(extended)\n");
10687 vty_out(vty
, "(standard)\n");
10689 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10690 PEER_FLAG_DEFAULT_ORIGINATE
)) {
10691 vty_out(vty
, " Default information originate,");
10693 if (p
->default_rmap
[afi
][safi
].name
)
10694 vty_out(vty
, " default route-map %s%s,",
10695 p
->default_rmap
[afi
][safi
].map
? "*"
10697 p
->default_rmap
[afi
][safi
].name
);
10698 if (paf
&& PAF_SUBGRP(paf
)
10699 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
10700 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
10701 vty_out(vty
, " default sent\n");
10703 vty_out(vty
, " default not sent\n");
10706 /* advertise-vni-all */
10707 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
10708 if (is_evpn_enabled())
10709 vty_out(vty
, " advertise-all-vni\n");
10712 if (filter
->plist
[FILTER_IN
].name
10713 || filter
->dlist
[FILTER_IN
].name
10714 || filter
->aslist
[FILTER_IN
].name
10715 || filter
->map
[RMAP_IN
].name
)
10716 vty_out(vty
, " Inbound path policy configured\n");
10717 if (filter
->plist
[FILTER_OUT
].name
10718 || filter
->dlist
[FILTER_OUT
].name
10719 || filter
->aslist
[FILTER_OUT
].name
10720 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
10721 vty_out(vty
, " Outbound path policy configured\n");
10724 if (filter
->plist
[FILTER_IN
].name
)
10726 " Incoming update prefix filter list is %s%s\n",
10727 filter
->plist
[FILTER_IN
].plist
? "*" : "",
10728 filter
->plist
[FILTER_IN
].name
);
10729 if (filter
->plist
[FILTER_OUT
].name
)
10731 " Outgoing update prefix filter list is %s%s\n",
10732 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
10733 filter
->plist
[FILTER_OUT
].name
);
10735 /* distribute-list */
10736 if (filter
->dlist
[FILTER_IN
].name
)
10738 " Incoming update network filter list is %s%s\n",
10739 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
10740 filter
->dlist
[FILTER_IN
].name
);
10741 if (filter
->dlist
[FILTER_OUT
].name
)
10743 " Outgoing update network filter list is %s%s\n",
10744 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
10745 filter
->dlist
[FILTER_OUT
].name
);
10748 if (filter
->aslist
[FILTER_IN
].name
)
10750 " Incoming update AS path filter list is %s%s\n",
10751 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
10752 filter
->aslist
[FILTER_IN
].name
);
10753 if (filter
->aslist
[FILTER_OUT
].name
)
10755 " Outgoing update AS path filter list is %s%s\n",
10756 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
10757 filter
->aslist
[FILTER_OUT
].name
);
10760 if (filter
->map
[RMAP_IN
].name
)
10762 " Route map for incoming advertisements is %s%s\n",
10763 filter
->map
[RMAP_IN
].map
? "*" : "",
10764 filter
->map
[RMAP_IN
].name
);
10765 if (filter
->map
[RMAP_OUT
].name
)
10767 " Route map for outgoing advertisements is %s%s\n",
10768 filter
->map
[RMAP_OUT
].map
? "*" : "",
10769 filter
->map
[RMAP_OUT
].name
);
10771 /* ebgp-requires-policy (inbound) */
10772 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
10773 && !bgp_inbound_policy_exists(p
, filter
))
10775 " Inbound updates discarded due to missing policy\n");
10777 /* ebgp-requires-policy (outbound) */
10778 if (CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
10779 && !bgp_outbound_policy_exists(p
, filter
))
10781 " Outbound updates discarded due to missing policy\n");
10783 /* unsuppress-map */
10784 if (filter
->usmap
.name
)
10786 " Route map for selective unsuppress is %s%s\n",
10787 filter
->usmap
.map
? "*" : "",
10788 filter
->usmap
.name
);
10790 /* Receive prefix count */
10791 vty_out(vty
, " %u accepted prefixes\n",
10792 p
->pcount
[afi
][safi
]);
10794 /* maximum-prefix-out */
10795 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
10796 PEER_FLAG_MAX_PREFIX_OUT
))
10798 " Maximum allowed prefixes sent %u\n",
10799 p
->pmax_out
[afi
][safi
]);
10801 /* Maximum prefix */
10802 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
10804 " Maximum prefixes allowed %u%s\n",
10805 p
->pmax
[afi
][safi
],
10806 CHECK_FLAG(p
->af_flags
[afi
][safi
],
10807 PEER_FLAG_MAX_PREFIX_WARNING
)
10808 ? " (warning-only)"
10810 vty_out(vty
, " Threshold for warning message %d%%",
10811 p
->pmax_threshold
[afi
][safi
]);
10812 if (p
->pmax_restart
[afi
][safi
])
10813 vty_out(vty
, ", restart interval %d min",
10814 p
->pmax_restart
[afi
][safi
]);
10815 vty_out(vty
, "\n");
10818 vty_out(vty
, "\n");
10822 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
10826 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
10827 char timebuf
[BGP_UPTIME_LEN
];
10833 json_object
*json_neigh
= NULL
;
10839 json_neigh
= json_object_new_object();
10841 memset(dn_flag
, '\0', sizeof(dn_flag
));
10842 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
10846 if (p
->conf_if
) /* Configured interface name. */
10847 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
10848 BGP_PEER_SU_UNSPEC(p
)
10850 : sockunion2str(&p
->su
, buf
,
10852 else /* Configured IP address. */
10853 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
10858 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
10859 json_object_string_add(json_neigh
, "bgpNeighborAddr",
10861 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
10862 json_object_string_add(
10863 json_neigh
, "bgpNeighborAddr",
10864 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
10866 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
10868 if (p
->change_local_as
)
10869 json_object_int_add(json_neigh
, "localAs",
10870 p
->change_local_as
);
10872 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
10874 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
10875 json_object_boolean_true_add(json_neigh
,
10876 "localAsNoPrepend");
10878 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
10879 json_object_boolean_true_add(json_neigh
,
10880 "localAsReplaceAs");
10882 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
10883 || (p
->as_type
== AS_INTERNAL
))
10884 vty_out(vty
, "remote AS %u, ", p
->as
);
10886 vty_out(vty
, "remote AS Unspecified, ");
10887 vty_out(vty
, "local AS %u%s%s, ",
10888 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
10889 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
10892 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
10896 /* peer type internal or confed-internal */
10897 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
10899 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
10900 json_object_boolean_true_add(
10901 json_neigh
, "nbrConfedInternalLink");
10903 json_object_boolean_true_add(json_neigh
,
10904 "nbrInternalLink");
10906 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
10907 vty_out(vty
, "confed-internal link\n");
10909 vty_out(vty
, "internal link\n");
10911 /* peer type external or confed-external */
10912 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
10914 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
10915 json_object_boolean_true_add(
10916 json_neigh
, "nbrConfedExternalLink");
10918 json_object_boolean_true_add(json_neigh
,
10919 "nbrExternalLink");
10921 if (bgp_confederation_peers_check(bgp
, p
->as
))
10922 vty_out(vty
, "confed-external link\n");
10924 vty_out(vty
, "external link\n");
10928 json_object_boolean_true_add(json_neigh
,
10929 "nbrUnspecifiedLink");
10931 vty_out(vty
, "unspecified link\n");
10937 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
10939 vty_out(vty
, " Description: %s\n", p
->desc
);
10945 json_object_string_add(json_neigh
, "hostname",
10949 json_object_string_add(json_neigh
, "domainname",
10952 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
10953 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
10956 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
10963 json_object_string_add(json_neigh
, "peerGroup",
10967 struct prefix prefix
, *range
= NULL
;
10969 sockunion2hostprefix(&(p
->su
), &prefix
);
10970 range
= peer_group_lookup_dynamic_neighbor_range(
10971 p
->group
, &prefix
);
10974 prefix2str(range
, buf1
, sizeof(buf1
));
10975 json_object_string_add(
10977 "peerSubnetRangeGroup", buf1
);
10982 " Member of peer-group %s for session parameters\n",
10986 struct prefix prefix
, *range
= NULL
;
10988 sockunion2hostprefix(&(p
->su
), &prefix
);
10989 range
= peer_group_lookup_dynamic_neighbor_range(
10990 p
->group
, &prefix
);
10994 " Belongs to the subnet range group: %pFX\n",
11002 /* Administrative shutdown. */
11003 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
11004 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
11005 json_object_boolean_true_add(json_neigh
,
11009 json_object_int_add(json_neigh
, "bgpVersion", 4);
11010 json_object_string_add(
11011 json_neigh
, "remoteRouterId",
11012 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
11013 json_object_string_add(
11014 json_neigh
, "localRouterId",
11015 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
11018 /* Confederation */
11019 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
11020 && bgp_confederation_peers_check(bgp
, p
->as
))
11021 json_object_boolean_true_add(json_neigh
,
11025 json_object_string_add(
11026 json_neigh
, "bgpState",
11027 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
11029 if (p
->status
== Established
) {
11032 uptime
= bgp_clock();
11033 uptime
-= p
->uptime
;
11034 epoch_tbuf
= time(NULL
) - uptime
;
11036 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
11038 json_object_string_add(json_neigh
, "bgpTimerUpString",
11039 peer_uptime(p
->uptime
, timebuf
,
11042 json_object_int_add(json_neigh
,
11043 "bgpTimerUpEstablishedEpoch",
11047 else if (p
->status
== Active
) {
11048 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
11049 json_object_string_add(json_neigh
, "bgpStateIs",
11051 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
11052 json_object_string_add(json_neigh
, "bgpStateIs",
11060 uptime
= bgp_clock();
11061 uptime
-= p
->readtime
;
11062 gmtime_r(&uptime
, &tm
);
11064 json_object_int_add(json_neigh
, "bgpTimerLastRead",
11065 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
11066 + (tm
.tm_hour
* 3600000));
11068 uptime
= bgp_clock();
11069 uptime
-= p
->last_write
;
11070 gmtime_r(&uptime
, &tm
);
11072 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
11073 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
11074 + (tm
.tm_hour
* 3600000));
11076 uptime
= bgp_clock();
11077 uptime
-= p
->update_time
;
11078 gmtime_r(&uptime
, &tm
);
11080 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
11081 (tm
.tm_sec
* 1000) + (tm
.tm_min
* 60000)
11082 + (tm
.tm_hour
* 3600000));
11084 /* Configured timer values. */
11085 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
11086 p
->v_holdtime
* 1000);
11087 json_object_int_add(json_neigh
,
11088 "bgpTimerKeepAliveIntervalMsecs",
11089 p
->v_keepalive
* 1000);
11090 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
11091 json_object_int_add(json_neigh
,
11092 "bgpTimerConfiguredHoldTimeMsecs",
11093 p
->holdtime
* 1000);
11094 json_object_int_add(
11096 "bgpTimerConfiguredKeepAliveIntervalMsecs",
11097 p
->keepalive
* 1000);
11098 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
11099 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
11100 json_object_int_add(json_neigh
,
11101 "bgpTimerConfiguredHoldTimeMsecs",
11102 bgp
->default_holdtime
);
11103 json_object_int_add(
11105 "bgpTimerConfiguredKeepAliveIntervalMsecs",
11106 bgp
->default_keepalive
);
11109 /* Administrative shutdown. */
11110 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
)
11111 || CHECK_FLAG(p
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
11112 vty_out(vty
, " Administratively shut down\n");
11115 vty_out(vty
, " BGP version 4");
11116 vty_out(vty
, ", remote router ID %s",
11117 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
11118 vty_out(vty
, ", local router ID %s\n",
11119 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
11122 /* Confederation */
11123 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
11124 && bgp_confederation_peers_check(bgp
, p
->as
))
11126 " Neighbor under common administration\n");
11129 vty_out(vty
, " BGP state = %s",
11130 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
11132 if (p
->status
== Established
)
11133 vty_out(vty
, ", up for %8s",
11134 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
11137 else if (p
->status
== Active
) {
11138 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
11139 vty_out(vty
, " (passive)");
11140 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
11141 vty_out(vty
, " (NSF passive)");
11143 vty_out(vty
, "\n");
11146 vty_out(vty
, " Last read %s",
11147 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
11149 vty_out(vty
, ", Last write %s\n",
11150 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
11153 /* Configured timer values. */
11155 " Hold time is %d, keepalive interval is %d seconds\n",
11156 p
->v_holdtime
, p
->v_keepalive
);
11157 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
11158 vty_out(vty
, " Configured hold time is %d",
11160 vty_out(vty
, ", keepalive interval is %d seconds\n",
11162 } else if ((bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
11163 || (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
)) {
11164 vty_out(vty
, " Configured hold time is %d",
11165 bgp
->default_holdtime
);
11166 vty_out(vty
, ", keepalive interval is %d seconds\n",
11167 bgp
->default_keepalive
);
11171 if (p
->status
== Established
) {
11172 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
11173 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
11174 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
11175 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
11176 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
11177 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
11178 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
11179 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
11180 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
11181 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
11182 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
11183 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
11184 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
11185 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
11186 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
11187 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
11188 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
11189 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
11190 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
11191 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
11193 json_object
*json_cap
= NULL
;
11195 json_cap
= json_object_new_object();
11198 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
11199 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
11200 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
11201 && CHECK_FLAG(p
->cap
,
11203 json_object_string_add(
11204 json_cap
, "4byteAs",
11205 "advertisedAndReceived");
11206 else if (CHECK_FLAG(p
->cap
,
11208 json_object_string_add(
11209 json_cap
, "4byteAs",
11211 else if (CHECK_FLAG(p
->cap
,
11213 json_object_string_add(
11214 json_cap
, "4byteAs",
11219 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
11220 || CHECK_FLAG(p
->cap
,
11221 PEER_CAP_ADDPATH_ADV
)) {
11222 json_object
*json_add
= NULL
;
11223 const char *print_store
;
11225 json_add
= json_object_new_object();
11227 FOREACH_AFI_SAFI (afi
, safi
) {
11228 json_object
*json_sub
= NULL
;
11230 json_object_new_object();
11231 print_store
= get_afi_safi_str(
11237 PEER_CAP_ADDPATH_AF_TX_ADV
)
11241 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
11246 PEER_CAP_ADDPATH_AF_TX_ADV
)
11251 PEER_CAP_ADDPATH_AF_TX_RCV
))
11252 json_object_boolean_true_add(
11254 "txAdvertisedAndReceived");
11260 PEER_CAP_ADDPATH_AF_TX_ADV
))
11261 json_object_boolean_true_add(
11269 PEER_CAP_ADDPATH_AF_TX_RCV
))
11270 json_object_boolean_true_add(
11278 PEER_CAP_ADDPATH_AF_RX_ADV
)
11282 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
11287 PEER_CAP_ADDPATH_AF_RX_ADV
)
11292 PEER_CAP_ADDPATH_AF_RX_RCV
))
11293 json_object_boolean_true_add(
11295 "rxAdvertisedAndReceived");
11301 PEER_CAP_ADDPATH_AF_RX_ADV
))
11302 json_object_boolean_true_add(
11310 PEER_CAP_ADDPATH_AF_RX_RCV
))
11311 json_object_boolean_true_add(
11319 PEER_CAP_ADDPATH_AF_TX_ADV
)
11323 PEER_CAP_ADDPATH_AF_TX_RCV
)
11327 PEER_CAP_ADDPATH_AF_RX_ADV
)
11331 PEER_CAP_ADDPATH_AF_RX_RCV
))
11332 json_object_object_add(
11341 json_object_object_add(
11342 json_cap
, "addPath", json_add
);
11346 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
11347 || CHECK_FLAG(p
->cap
,
11348 PEER_CAP_DYNAMIC_ADV
)) {
11349 if (CHECK_FLAG(p
->cap
,
11350 PEER_CAP_DYNAMIC_ADV
)
11351 && CHECK_FLAG(p
->cap
,
11352 PEER_CAP_DYNAMIC_RCV
))
11353 json_object_string_add(
11354 json_cap
, "dynamic",
11355 "advertisedAndReceived");
11356 else if (CHECK_FLAG(
11358 PEER_CAP_DYNAMIC_ADV
))
11359 json_object_string_add(
11360 json_cap
, "dynamic",
11362 else if (CHECK_FLAG(
11364 PEER_CAP_DYNAMIC_RCV
))
11365 json_object_string_add(
11366 json_cap
, "dynamic",
11370 /* Extended nexthop */
11371 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
11372 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
11373 json_object
*json_nxt
= NULL
;
11374 const char *print_store
;
11377 if (CHECK_FLAG(p
->cap
,
11379 && CHECK_FLAG(p
->cap
,
11380 PEER_CAP_ENHE_RCV
))
11381 json_object_string_add(
11384 "advertisedAndReceived");
11385 else if (CHECK_FLAG(p
->cap
,
11386 PEER_CAP_ENHE_ADV
))
11387 json_object_string_add(
11391 else if (CHECK_FLAG(p
->cap
,
11392 PEER_CAP_ENHE_RCV
))
11393 json_object_string_add(
11398 if (CHECK_FLAG(p
->cap
,
11399 PEER_CAP_ENHE_RCV
)) {
11401 json_object_new_object();
11403 for (safi
= SAFI_UNICAST
;
11404 safi
< SAFI_MAX
; safi
++) {
11409 PEER_CAP_ENHE_AF_RCV
)) {
11410 print_store
= get_afi_safi_str(
11413 json_object_string_add(
11416 "recieved"); /* misspelled for compatibility */
11419 json_object_object_add(
11421 "extendedNexthopFamililesByPeer",
11426 /* Route Refresh */
11427 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
11428 || CHECK_FLAG(p
->cap
,
11429 PEER_CAP_REFRESH_NEW_RCV
)
11430 || CHECK_FLAG(p
->cap
,
11431 PEER_CAP_REFRESH_OLD_RCV
)) {
11432 if (CHECK_FLAG(p
->cap
,
11433 PEER_CAP_REFRESH_ADV
)
11436 PEER_CAP_REFRESH_NEW_RCV
)
11439 PEER_CAP_REFRESH_OLD_RCV
))) {
11442 PEER_CAP_REFRESH_OLD_RCV
)
11445 PEER_CAP_REFRESH_NEW_RCV
))
11446 json_object_string_add(
11449 "advertisedAndReceivedOldNew");
11453 PEER_CAP_REFRESH_OLD_RCV
))
11454 json_object_string_add(
11457 "advertisedAndReceivedOld");
11459 json_object_string_add(
11462 "advertisedAndReceivedNew");
11467 PEER_CAP_REFRESH_ADV
))
11468 json_object_string_add(
11475 PEER_CAP_REFRESH_NEW_RCV
)
11478 PEER_CAP_REFRESH_OLD_RCV
))
11479 json_object_string_add(
11485 /* Multiprotocol Extensions */
11486 json_object
*json_multi
= NULL
;
11487 json_multi
= json_object_new_object();
11489 FOREACH_AFI_SAFI (afi
, safi
) {
11490 if (p
->afc_adv
[afi
][safi
]
11491 || p
->afc_recv
[afi
][safi
]) {
11492 json_object
*json_exten
= NULL
;
11494 json_object_new_object();
11496 if (p
->afc_adv
[afi
][safi
]
11497 && p
->afc_recv
[afi
][safi
])
11498 json_object_boolean_true_add(
11500 "advertisedAndReceived");
11501 else if (p
->afc_adv
[afi
][safi
])
11502 json_object_boolean_true_add(
11505 else if (p
->afc_recv
[afi
][safi
])
11506 json_object_boolean_true_add(
11510 json_object_object_add(
11512 get_afi_safi_str(afi
,
11518 json_object_object_add(
11519 json_cap
, "multiprotocolExtensions",
11522 /* Hostname capabilities */
11523 json_object
*json_hname
= NULL
;
11525 json_hname
= json_object_new_object();
11527 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
11528 json_object_string_add(
11529 json_hname
, "advHostName",
11530 bgp
->peer_self
->hostname
11534 json_object_string_add(
11535 json_hname
, "advDomainName",
11536 bgp
->peer_self
->domainname
11543 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
11544 json_object_string_add(
11545 json_hname
, "rcvHostName",
11546 p
->hostname
? p
->hostname
11548 json_object_string_add(
11549 json_hname
, "rcvDomainName",
11550 p
->domainname
? p
->domainname
11554 json_object_object_add(json_cap
, "hostName",
11557 /* Gracefull Restart */
11558 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
11559 || CHECK_FLAG(p
->cap
,
11560 PEER_CAP_RESTART_ADV
)) {
11561 if (CHECK_FLAG(p
->cap
,
11562 PEER_CAP_RESTART_ADV
)
11563 && CHECK_FLAG(p
->cap
,
11564 PEER_CAP_RESTART_RCV
))
11565 json_object_string_add(
11568 "advertisedAndReceived");
11569 else if (CHECK_FLAG(
11571 PEER_CAP_RESTART_ADV
))
11572 json_object_string_add(
11574 "gracefulRestartCapability",
11576 else if (CHECK_FLAG(
11578 PEER_CAP_RESTART_RCV
))
11579 json_object_string_add(
11581 "gracefulRestartCapability",
11584 if (CHECK_FLAG(p
->cap
,
11585 PEER_CAP_RESTART_RCV
)) {
11586 int restart_af_count
= 0;
11587 json_object
*json_restart
=
11590 json_object_new_object();
11592 json_object_int_add(
11594 "gracefulRestartRemoteTimerMsecs",
11595 p
->v_gr_restart
* 1000);
11597 FOREACH_AFI_SAFI (afi
, safi
) {
11602 PEER_CAP_RESTART_AF_RCV
)) {
11607 json_object_new_object();
11613 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
11614 json_object_boolean_true_add(
11617 restart_af_count
++;
11618 json_object_object_add(
11627 if (!restart_af_count
) {
11628 json_object_string_add(
11630 "addressFamiliesByPeer",
11635 json_object_object_add(
11637 "addressFamiliesByPeer",
11641 json_object_object_add(json_neigh
,
11642 "neighborCapabilities",
11645 vty_out(vty
, " Neighbor capabilities:\n");
11648 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
11649 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
11650 vty_out(vty
, " 4 Byte AS:");
11651 if (CHECK_FLAG(p
->cap
,
11653 vty_out(vty
, " advertised");
11654 if (CHECK_FLAG(p
->cap
,
11656 vty_out(vty
, " %sreceived",
11662 vty_out(vty
, "\n");
11666 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
11667 || CHECK_FLAG(p
->cap
,
11668 PEER_CAP_ADDPATH_ADV
)) {
11669 vty_out(vty
, " AddPath:\n");
11671 FOREACH_AFI_SAFI (afi
, safi
) {
11675 PEER_CAP_ADDPATH_AF_TX_ADV
)
11679 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
11691 PEER_CAP_ADDPATH_AF_TX_ADV
))
11703 PEER_CAP_ADDPATH_AF_TX_RCV
))
11710 PEER_CAP_ADDPATH_AF_TX_ADV
)
11714 vty_out(vty
, "\n");
11720 PEER_CAP_ADDPATH_AF_RX_ADV
)
11724 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
11736 PEER_CAP_ADDPATH_AF_RX_ADV
))
11748 PEER_CAP_ADDPATH_AF_RX_RCV
))
11755 PEER_CAP_ADDPATH_AF_RX_ADV
)
11759 vty_out(vty
, "\n");
11765 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
11766 || CHECK_FLAG(p
->cap
,
11767 PEER_CAP_DYNAMIC_ADV
)) {
11768 vty_out(vty
, " Dynamic:");
11769 if (CHECK_FLAG(p
->cap
,
11770 PEER_CAP_DYNAMIC_ADV
))
11771 vty_out(vty
, " advertised");
11772 if (CHECK_FLAG(p
->cap
,
11773 PEER_CAP_DYNAMIC_RCV
))
11774 vty_out(vty
, " %sreceived",
11777 PEER_CAP_DYNAMIC_ADV
)
11780 vty_out(vty
, "\n");
11783 /* Extended nexthop */
11784 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
11785 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
11786 vty_out(vty
, " Extended nexthop:");
11787 if (CHECK_FLAG(p
->cap
,
11788 PEER_CAP_ENHE_ADV
))
11789 vty_out(vty
, " advertised");
11790 if (CHECK_FLAG(p
->cap
,
11791 PEER_CAP_ENHE_RCV
))
11792 vty_out(vty
, " %sreceived",
11798 vty_out(vty
, "\n");
11800 if (CHECK_FLAG(p
->cap
,
11801 PEER_CAP_ENHE_RCV
)) {
11803 " Address families by peer:\n ");
11804 for (safi
= SAFI_UNICAST
;
11805 safi
< SAFI_MAX
; safi
++)
11810 PEER_CAP_ENHE_AF_RCV
))
11820 /* Route Refresh */
11821 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
11822 || CHECK_FLAG(p
->cap
,
11823 PEER_CAP_REFRESH_NEW_RCV
)
11824 || CHECK_FLAG(p
->cap
,
11825 PEER_CAP_REFRESH_OLD_RCV
)) {
11826 vty_out(vty
, " Route refresh:");
11827 if (CHECK_FLAG(p
->cap
,
11828 PEER_CAP_REFRESH_ADV
))
11829 vty_out(vty
, " advertised");
11830 if (CHECK_FLAG(p
->cap
,
11831 PEER_CAP_REFRESH_NEW_RCV
)
11834 PEER_CAP_REFRESH_OLD_RCV
))
11835 vty_out(vty
, " %sreceived(%s)",
11838 PEER_CAP_REFRESH_ADV
)
11843 PEER_CAP_REFRESH_OLD_RCV
)
11846 PEER_CAP_REFRESH_NEW_RCV
))
11850 PEER_CAP_REFRESH_OLD_RCV
)
11854 vty_out(vty
, "\n");
11857 /* Multiprotocol Extensions */
11858 FOREACH_AFI_SAFI (afi
, safi
)
11859 if (p
->afc_adv
[afi
][safi
]
11860 || p
->afc_recv
[afi
][safi
]) {
11862 " Address Family %s:",
11867 if (p
->afc_adv
[afi
][safi
])
11870 if (p
->afc_recv
[afi
][safi
])
11877 vty_out(vty
, "\n");
11880 /* Hostname capability */
11881 vty_out(vty
, " Hostname Capability:");
11883 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
11885 " advertised (name: %s,domain name: %s)",
11886 bgp
->peer_self
->hostname
11890 bgp
->peer_self
->domainname
11895 vty_out(vty
, " not advertised");
11898 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
11900 " received (name: %s,domain name: %s)",
11901 p
->hostname
? p
->hostname
11903 p
->domainname
? p
->domainname
11906 vty_out(vty
, " not received");
11909 vty_out(vty
, "\n");
11911 /* Graceful Restart */
11912 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
11913 || CHECK_FLAG(p
->cap
,
11914 PEER_CAP_RESTART_ADV
)) {
11916 " Graceful Restart Capability:");
11917 if (CHECK_FLAG(p
->cap
,
11918 PEER_CAP_RESTART_ADV
))
11919 vty_out(vty
, " advertised");
11920 if (CHECK_FLAG(p
->cap
,
11921 PEER_CAP_RESTART_RCV
))
11922 vty_out(vty
, " %sreceived",
11925 PEER_CAP_RESTART_ADV
)
11928 vty_out(vty
, "\n");
11930 if (CHECK_FLAG(p
->cap
,
11931 PEER_CAP_RESTART_RCV
)) {
11932 int restart_af_count
= 0;
11935 " Remote Restart timer is %d seconds\n",
11938 " Address families by peer:\n ");
11940 FOREACH_AFI_SAFI (afi
, safi
)
11945 PEER_CAP_RESTART_AF_RCV
)) {
11959 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
11961 : "not preserved");
11962 restart_af_count
++;
11964 if (!restart_af_count
)
11965 vty_out(vty
, "none");
11966 vty_out(vty
, "\n");
11968 } /* Gracefull Restart */
11973 /* graceful restart information */
11974 json_object
*json_grace
= NULL
;
11975 json_object
*json_grace_send
= NULL
;
11976 json_object
*json_grace_recv
= NULL
;
11977 int eor_send_af_count
= 0;
11978 int eor_receive_af_count
= 0;
11981 json_grace
= json_object_new_object();
11982 json_grace_send
= json_object_new_object();
11983 json_grace_recv
= json_object_new_object();
11985 if ((p
->status
== Established
)
11986 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
11987 FOREACH_AFI_SAFI (afi
, safi
) {
11988 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
11989 PEER_STATUS_EOR_SEND
)) {
11990 json_object_boolean_true_add(
11992 get_afi_safi_str(afi
,
11995 eor_send_af_count
++;
11998 FOREACH_AFI_SAFI (afi
, safi
) {
12000 p
->af_sflags
[afi
][safi
],
12001 PEER_STATUS_EOR_RECEIVED
)) {
12002 json_object_boolean_true_add(
12004 get_afi_safi_str(afi
,
12007 eor_receive_af_count
++;
12011 json_object_object_add(json_grace
, "endOfRibSend",
12013 json_object_object_add(json_grace
, "endOfRibRecv",
12017 if (p
->t_gr_restart
)
12018 json_object_int_add(json_grace
,
12019 "gracefulRestartTimerMsecs",
12020 thread_timer_remain_second(
12025 json_object_int_add(
12027 "gracefulStalepathTimerMsecs",
12028 thread_timer_remain_second(
12031 /* more gr info in new format */
12032 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
,
12034 json_object_object_add(
12035 json_neigh
, "gracefulRestartInfo", json_grace
);
12037 vty_out(vty
, " Graceful restart information:\n");
12038 if ((p
->status
== Established
)
12039 && CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)) {
12041 vty_out(vty
, " End-of-RIB send: ");
12042 FOREACH_AFI_SAFI (afi
, safi
) {
12043 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
12044 PEER_STATUS_EOR_SEND
)) {
12045 vty_out(vty
, "%s%s",
12046 eor_send_af_count
? ", "
12051 eor_send_af_count
++;
12054 vty_out(vty
, "\n");
12055 vty_out(vty
, " End-of-RIB received: ");
12056 FOREACH_AFI_SAFI (afi
, safi
) {
12058 p
->af_sflags
[afi
][safi
],
12059 PEER_STATUS_EOR_RECEIVED
)) {
12060 vty_out(vty
, "%s%s",
12061 eor_receive_af_count
12064 get_afi_safi_str(afi
,
12067 eor_receive_af_count
++;
12070 vty_out(vty
, "\n");
12073 if (p
->t_gr_restart
)
12075 " The remaining time of restart timer is %ld\n",
12076 thread_timer_remain_second(
12081 " The remaining time of stalepath timer is %ld\n",
12082 thread_timer_remain_second(
12085 /* more gr info in new format */
12086 BGP_SHOW_PEER_GR_CAPABILITY(vty
, p
, use_json
, NULL
);
12090 json_object
*json_stat
= NULL
;
12091 json_stat
= json_object_new_object();
12092 /* Packet counts. */
12094 atomic_size_t outq_count
, inq_count
;
12095 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
12096 memory_order_relaxed
);
12097 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
12098 memory_order_relaxed
);
12100 json_object_int_add(json_stat
, "depthInq",
12101 (unsigned long)inq_count
);
12102 json_object_int_add(json_stat
, "depthOutq",
12103 (unsigned long)outq_count
);
12104 json_object_int_add(json_stat
, "opensSent",
12105 atomic_load_explicit(&p
->open_out
,
12106 memory_order_relaxed
));
12107 json_object_int_add(json_stat
, "opensRecv",
12108 atomic_load_explicit(&p
->open_in
,
12109 memory_order_relaxed
));
12110 json_object_int_add(json_stat
, "notificationsSent",
12111 atomic_load_explicit(&p
->notify_out
,
12112 memory_order_relaxed
));
12113 json_object_int_add(json_stat
, "notificationsRecv",
12114 atomic_load_explicit(&p
->notify_in
,
12115 memory_order_relaxed
));
12116 json_object_int_add(json_stat
, "updatesSent",
12117 atomic_load_explicit(&p
->update_out
,
12118 memory_order_relaxed
));
12119 json_object_int_add(json_stat
, "updatesRecv",
12120 atomic_load_explicit(&p
->update_in
,
12121 memory_order_relaxed
));
12122 json_object_int_add(json_stat
, "keepalivesSent",
12123 atomic_load_explicit(&p
->keepalive_out
,
12124 memory_order_relaxed
));
12125 json_object_int_add(json_stat
, "keepalivesRecv",
12126 atomic_load_explicit(&p
->keepalive_in
,
12127 memory_order_relaxed
));
12128 json_object_int_add(json_stat
, "routeRefreshSent",
12129 atomic_load_explicit(&p
->refresh_out
,
12130 memory_order_relaxed
));
12131 json_object_int_add(json_stat
, "routeRefreshRecv",
12132 atomic_load_explicit(&p
->refresh_in
,
12133 memory_order_relaxed
));
12134 json_object_int_add(json_stat
, "capabilitySent",
12135 atomic_load_explicit(&p
->dynamic_cap_out
,
12136 memory_order_relaxed
));
12137 json_object_int_add(json_stat
, "capabilityRecv",
12138 atomic_load_explicit(&p
->dynamic_cap_in
,
12139 memory_order_relaxed
));
12140 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
12141 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
12142 json_object_object_add(json_neigh
, "messageStats", json_stat
);
12144 atomic_size_t outq_count
, inq_count
;
12145 outq_count
= atomic_load_explicit(&p
->obuf
->count
,
12146 memory_order_relaxed
);
12147 inq_count
= atomic_load_explicit(&p
->ibuf
->count
,
12148 memory_order_relaxed
);
12150 /* Packet counts. */
12151 vty_out(vty
, " Message statistics:\n");
12152 vty_out(vty
, " Inq depth is %zu\n", inq_count
);
12153 vty_out(vty
, " Outq depth is %zu\n", outq_count
);
12154 vty_out(vty
, " Sent Rcvd\n");
12155 vty_out(vty
, " Opens: %10d %10d\n",
12156 atomic_load_explicit(&p
->open_out
,
12157 memory_order_relaxed
),
12158 atomic_load_explicit(&p
->open_in
,
12159 memory_order_relaxed
));
12160 vty_out(vty
, " Notifications: %10d %10d\n",
12161 atomic_load_explicit(&p
->notify_out
,
12162 memory_order_relaxed
),
12163 atomic_load_explicit(&p
->notify_in
,
12164 memory_order_relaxed
));
12165 vty_out(vty
, " Updates: %10d %10d\n",
12166 atomic_load_explicit(&p
->update_out
,
12167 memory_order_relaxed
),
12168 atomic_load_explicit(&p
->update_in
,
12169 memory_order_relaxed
));
12170 vty_out(vty
, " Keepalives: %10d %10d\n",
12171 atomic_load_explicit(&p
->keepalive_out
,
12172 memory_order_relaxed
),
12173 atomic_load_explicit(&p
->keepalive_in
,
12174 memory_order_relaxed
));
12175 vty_out(vty
, " Route Refresh: %10d %10d\n",
12176 atomic_load_explicit(&p
->refresh_out
,
12177 memory_order_relaxed
),
12178 atomic_load_explicit(&p
->refresh_in
,
12179 memory_order_relaxed
));
12180 vty_out(vty
, " Capability: %10d %10d\n",
12181 atomic_load_explicit(&p
->dynamic_cap_out
,
12182 memory_order_relaxed
),
12183 atomic_load_explicit(&p
->dynamic_cap_in
,
12184 memory_order_relaxed
));
12185 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
12190 /* advertisement-interval */
12191 json_object_int_add(json_neigh
,
12192 "minBtwnAdvertisementRunsTimerMsecs",
12193 p
->v_routeadv
* 1000);
12195 /* Update-source. */
12196 if (p
->update_if
|| p
->update_source
) {
12198 json_object_string_add(json_neigh
,
12201 else if (p
->update_source
)
12202 json_object_string_add(
12203 json_neigh
, "updateSource",
12204 sockunion2str(p
->update_source
, buf1
,
12208 /* advertisement-interval */
12210 " Minimum time between advertisement runs is %d seconds\n",
12213 /* Update-source. */
12214 if (p
->update_if
|| p
->update_source
) {
12215 vty_out(vty
, " Update source is ");
12217 vty_out(vty
, "%s", p
->update_if
);
12218 else if (p
->update_source
)
12220 sockunion2str(p
->update_source
, buf1
,
12222 vty_out(vty
, "\n");
12225 vty_out(vty
, "\n");
12228 /* Address Family Information */
12229 json_object
*json_hold
= NULL
;
12232 json_hold
= json_object_new_object();
12234 FOREACH_AFI_SAFI (afi
, safi
)
12235 if (p
->afc
[afi
][safi
])
12236 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
12240 json_object_object_add(json_neigh
, "addressFamilyInfo",
12242 json_object_int_add(json_neigh
, "connectionsEstablished",
12244 json_object_int_add(json_neigh
, "connectionsDropped",
12247 vty_out(vty
, " Connections established %d; dropped %d\n",
12248 p
->established
, p
->dropped
);
12250 if (!p
->last_reset
) {
12252 json_object_string_add(json_neigh
, "lastReset",
12255 vty_out(vty
, " Last reset never\n");
12261 uptime
= bgp_clock();
12262 uptime
-= p
->resettime
;
12263 gmtime_r(&uptime
, &tm
);
12265 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
12267 + (tm
.tm_min
* 60000)
12268 + (tm
.tm_hour
* 3600000));
12269 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
12271 vty_out(vty
, " Last reset %s, ",
12272 peer_uptime(p
->resettime
, timebuf
,
12273 BGP_UPTIME_LEN
, 0, NULL
));
12275 bgp_show_peer_reset(vty
, p
, NULL
, false);
12276 if (p
->last_reset_cause_size
) {
12277 msg
= p
->last_reset_cause
;
12279 " Message received that caused BGP to send a NOTIFICATION:\n ");
12280 for (i
= 1; i
<= p
->last_reset_cause_size
;
12282 vty_out(vty
, "%02X", *msg
++);
12284 if (i
!= p
->last_reset_cause_size
) {
12286 vty_out(vty
, "\n ");
12287 } else if (i
% 4 == 0) {
12292 vty_out(vty
, "\n");
12297 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
12299 json_object_boolean_true_add(json_neigh
,
12300 "prefixesConfigExceedMax");
12303 " Peer had exceeded the max. no. of prefixes configured.\n");
12305 if (p
->t_pmax_restart
) {
12307 json_object_boolean_true_add(
12308 json_neigh
, "reducePrefixNumFrom");
12309 json_object_int_add(json_neigh
,
12310 "restartInTimerMsec",
12311 thread_timer_remain_second(
12316 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
12317 p
->host
, thread_timer_remain_second(
12318 p
->t_pmax_restart
));
12321 json_object_boolean_true_add(
12323 "reducePrefixNumAndClearIpBgp");
12326 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
12331 /* EBGP Multihop and GTSM */
12332 if (p
->sort
!= BGP_PEER_IBGP
) {
12334 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
12335 json_object_int_add(json_neigh
,
12336 "externalBgpNbrMaxHopsAway",
12338 else if (p
->ttl
> BGP_DEFAULT_TTL
)
12339 json_object_int_add(json_neigh
,
12340 "externalBgpNbrMaxHopsAway",
12343 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
)
12345 " External BGP neighbor may be up to %d hops away.\n",
12347 else if (p
->ttl
> BGP_DEFAULT_TTL
)
12349 " External BGP neighbor may be up to %d hops away.\n",
12353 if (p
->gtsm_hops
> BGP_GTSM_HOPS_DISABLED
) {
12355 json_object_int_add(json_neigh
,
12356 "internalBgpNbrMaxHopsAway",
12360 " Internal BGP neighbor may be up to %d hops away.\n",
12365 /* Local address. */
12368 json_object_string_add(json_neigh
, "hostLocal",
12369 sockunion2str(p
->su_local
, buf1
,
12371 json_object_int_add(json_neigh
, "portLocal",
12372 ntohs(p
->su_local
->sin
.sin_port
));
12374 vty_out(vty
, "Local host: %s, Local port: %d\n",
12375 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
12376 ntohs(p
->su_local
->sin
.sin_port
));
12379 /* Remote address. */
12380 if (p
->su_remote
) {
12382 json_object_string_add(json_neigh
, "hostForeign",
12383 sockunion2str(p
->su_remote
, buf1
,
12385 json_object_int_add(json_neigh
, "portForeign",
12386 ntohs(p
->su_remote
->sin
.sin_port
));
12388 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
12389 sockunion2str(p
->su_remote
, buf1
,
12391 ntohs(p
->su_remote
->sin
.sin_port
));
12394 /* Nexthop display. */
12397 json_object_string_add(json_neigh
, "nexthop",
12399 &p
->nexthop
.v4
, buf1
,
12401 json_object_string_add(json_neigh
, "nexthopGlobal",
12402 inet_ntop(AF_INET6
,
12403 &p
->nexthop
.v6_global
,
12404 buf1
, sizeof(buf1
)));
12405 json_object_string_add(json_neigh
, "nexthopLocal",
12406 inet_ntop(AF_INET6
,
12407 &p
->nexthop
.v6_local
,
12408 buf1
, sizeof(buf1
)));
12409 if (p
->shared_network
)
12410 json_object_string_add(json_neigh
,
12414 json_object_string_add(json_neigh
,
12416 "nonSharedNetwork");
12418 vty_out(vty
, "Nexthop: %s\n",
12419 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
12421 vty_out(vty
, "Nexthop global: %s\n",
12422 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
12424 vty_out(vty
, "Nexthop local: %s\n",
12425 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
12427 vty_out(vty
, "BGP connection: %s\n",
12428 p
->shared_network
? "shared network"
12429 : "non shared network");
12433 /* Timer information. */
12435 json_object_int_add(json_neigh
, "connectRetryTimer",
12437 if (p
->status
== Established
&& p
->rtt
)
12438 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
12441 json_object_int_add(
12442 json_neigh
, "nextStartTimerDueInMsecs",
12443 thread_timer_remain_second(p
->t_start
) * 1000);
12445 json_object_int_add(
12446 json_neigh
, "nextConnectTimerDueInMsecs",
12447 thread_timer_remain_second(p
->t_connect
)
12449 if (p
->t_routeadv
) {
12450 json_object_int_add(json_neigh
, "mraiInterval",
12452 json_object_int_add(
12453 json_neigh
, "mraiTimerExpireInMsecs",
12454 thread_timer_remain_second(p
->t_routeadv
)
12458 json_object_int_add(json_neigh
, "authenticationEnabled",
12462 json_object_string_add(json_neigh
, "readThread", "on");
12464 json_object_string_add(json_neigh
, "readThread", "off");
12466 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
12467 json_object_string_add(json_neigh
, "writeThread", "on");
12469 json_object_string_add(json_neigh
, "writeThread",
12472 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
12474 if (p
->status
== Established
&& p
->rtt
)
12475 vty_out(vty
, "Estimated round trip time: %d ms\n",
12478 vty_out(vty
, "Next start timer due in %ld seconds\n",
12479 thread_timer_remain_second(p
->t_start
));
12481 vty_out(vty
, "Next connect timer due in %ld seconds\n",
12482 thread_timer_remain_second(p
->t_connect
));
12485 "MRAI (interval %u) timer expires in %ld seconds\n",
12487 thread_timer_remain_second(p
->t_routeadv
));
12489 vty_out(vty
, "Peer Authentication Enabled\n");
12491 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
12492 p
->t_read
? "on" : "off",
12493 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
12498 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
12499 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
12500 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
12503 vty_out(vty
, "\n");
12505 /* BFD information. */
12506 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
12509 if (p
->conf_if
) /* Configured interface name. */
12510 json_object_object_add(json
, p
->conf_if
, json_neigh
);
12511 else /* Configured IP address. */
12512 json_object_object_add(json
, p
->host
, json_neigh
);
12516 static int bgp_show_neighbor_graceful_restart(struct vty
*vty
, struct bgp
*bgp
,
12517 enum show_type type
,
12518 union sockunion
*su
,
12519 const char *conf_if
, afi_t afi
,
12522 struct listnode
*node
, *nnode
;
12525 safi_t safi
= SAFI_UNICAST
;
12526 json_object
*json
= NULL
;
12527 json_object
*json_neighbor
= NULL
;
12530 json
= json_object_new_object();
12531 json_neighbor
= json_object_new_object();
12534 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
12536 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
12539 if ((peer
->afc
[afi
][safi
]) == 0)
12542 if (type
== show_all
) {
12543 bgp_show_peer_gr_status(vty
, peer
, use_json
,
12547 json_object_object_add(json
, peer
->host
,
12549 json_neighbor
= NULL
;
12552 } else if (type
== show_peer
) {
12555 && !strcmp(peer
->conf_if
, conf_if
))
12557 && !strcmp(peer
->hostname
, conf_if
))) {
12559 bgp_show_peer_gr_status(vty
, peer
,
12564 if (sockunion_same(&peer
->su
, su
)) {
12566 bgp_show_peer_gr_status(vty
, peer
,
12571 if (use_json
&& find
)
12572 json_object_object_add(json
, peer
->host
,
12577 json_neighbor
= NULL
;
12582 if (type
== show_peer
&& !find
) {
12584 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
12586 vty_out(vty
, "%% No such neighbor\n");
12589 vty_out(vty
, "%s\n",
12590 json_object_to_json_string_ext(
12591 json
, JSON_C_TO_STRING_PRETTY
));
12594 json_object_free(json_neighbor
);
12595 json_object_free(json
);
12597 vty_out(vty
, "\n");
12600 return CMD_SUCCESS
;
12603 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
12604 enum show_type type
, union sockunion
*su
,
12605 const char *conf_if
, bool use_json
,
12608 struct listnode
*node
, *nnode
;
12611 bool nbr_output
= false;
12612 afi_t afi
= AFI_MAX
;
12613 safi_t safi
= SAFI_MAX
;
12615 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
12617 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
12621 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
12622 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
12627 bgp_show_peer(vty
, peer
, use_json
, json
);
12633 && !strcmp(peer
->conf_if
, conf_if
))
12635 && !strcmp(peer
->hostname
, conf_if
))) {
12637 bgp_show_peer(vty
, peer
, use_json
,
12641 if (sockunion_same(&peer
->su
, su
)) {
12643 bgp_show_peer(vty
, peer
, use_json
,
12648 case show_ipv4_peer
:
12649 case show_ipv6_peer
:
12650 FOREACH_SAFI (safi
) {
12651 if (peer
->afc
[afi
][safi
]) {
12654 && !strcmp(peer
->conf_if
, conf_if
))
12656 && !strcmp(peer
->hostname
, conf_if
))) {
12658 bgp_show_peer(vty
, peer
, use_json
,
12663 if (sockunion_same(&peer
->su
, su
)) {
12665 bgp_show_peer(vty
, peer
, use_json
,
12673 case show_ipv4_all
:
12674 case show_ipv6_all
:
12675 FOREACH_SAFI (safi
) {
12676 if (peer
->afc
[afi
][safi
]) {
12677 bgp_show_peer(vty
, peer
, use_json
, json
);
12686 if ((type
== show_peer
|| type
== show_ipv4_peer
||
12687 type
== show_ipv6_peer
) && !find
) {
12689 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
12691 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
12694 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
12695 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
12696 vty_out(vty
, "%% No BGP neighbors found\n");
12699 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
12700 json
, JSON_C_TO_STRING_PRETTY
));
12702 vty_out(vty
, "\n");
12705 return CMD_SUCCESS
;
12708 static void bgp_show_neighbor_graceful_restart_vty(struct vty
*vty
,
12709 enum show_type type
,
12710 const char *ip_str
,
12711 afi_t afi
, bool use_json
)
12716 union sockunion su
;
12718 bgp
= bgp_get_default();
12724 bgp_show_global_graceful_restart_mode_vty(vty
, bgp
, use_json
,
12728 ret
= str2sockunion(ip_str
, &su
);
12730 bgp_show_neighbor_graceful_restart(
12731 vty
, bgp
, type
, NULL
, ip_str
, afi
, use_json
);
12733 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, &su
,
12734 NULL
, afi
, use_json
);
12736 bgp_show_neighbor_graceful_restart(vty
, bgp
, type
, NULL
, NULL
,
12740 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
12741 enum show_type type
,
12742 const char *ip_str
,
12745 struct listnode
*node
, *nnode
;
12747 union sockunion su
;
12748 json_object
*json
= NULL
;
12749 int ret
, is_first
= 1;
12750 bool nbr_output
= false;
12753 vty_out(vty
, "{\n");
12755 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
12758 if (!(json
= json_object_new_object())) {
12760 EC_BGP_JSON_MEM_ERROR
,
12761 "Unable to allocate memory for JSON object");
12763 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
12767 json_object_int_add(json
, "vrfId",
12768 (bgp
->vrf_id
== VRF_UNKNOWN
)
12770 : (int64_t)bgp
->vrf_id
);
12771 json_object_string_add(
12773 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
12778 vty_out(vty
, ",\n");
12782 vty_out(vty
, "\"%s\":",
12783 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
12787 vty_out(vty
, "\nInstance %s:\n",
12788 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
12793 if (type
== show_peer
|| type
== show_ipv4_peer
||
12794 type
== show_ipv6_peer
) {
12795 ret
= str2sockunion(ip_str
, &su
);
12797 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
12800 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
12803 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
12806 json_object_free(json
);
12810 vty_out(vty
, "}\n");
12811 json_object_free(json
);
12813 else if (!nbr_output
)
12814 vty_out(vty
, "%% BGP instance not found\n");
12817 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
12818 enum show_type type
, const char *ip_str
,
12823 union sockunion su
;
12824 json_object
*json
= NULL
;
12827 if (strmatch(name
, "all")) {
12828 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
12830 return CMD_SUCCESS
;
12832 bgp
= bgp_lookup_by_name(name
);
12835 json
= json_object_new_object();
12836 vty_out(vty
, "%s\n",
12837 json_object_to_json_string_ext(
12839 JSON_C_TO_STRING_PRETTY
));
12840 json_object_free(json
);
12843 "%% BGP instance not found\n");
12845 return CMD_WARNING
;
12849 bgp
= bgp_get_default();
12853 json
= json_object_new_object();
12855 ret
= str2sockunion(ip_str
, &su
);
12857 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
12860 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
12863 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
12866 json_object_free(json
);
12869 vty_out(vty
, "{}\n");
12871 vty_out(vty
, "%% BGP instance not found\n");
12874 return CMD_SUCCESS
;
12879 /* "show [ip] bgp neighbors graceful-restart" commands. */
12880 DEFUN (show_ip_bgp_neighbors_gracrful_restart
,
12881 show_ip_bgp_neighbors_graceful_restart_cmd
,
12882 "show bgp [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] graceful-restart [json]",
12888 "Neighbor to display information about\n"
12889 "Neighbor to display information about\n"
12890 "Neighbor on BGP configured interface\n"
12894 char *sh_arg
= NULL
;
12895 enum show_type sh_type
;
12897 afi_t afi
= AFI_MAX
;
12898 bool uj
= use_json(argc
, argv
);
12900 if (!argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
12905 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
12906 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
12907 || argv_find(argv
, argc
, "WORD", &idx
)) {
12908 sh_type
= show_peer
;
12909 sh_arg
= argv
[idx
]->arg
;
12911 sh_type
= show_all
;
12913 if (!argv_find(argv
, argc
, "graceful-restart", &idx
))
12914 return CMD_SUCCESS
;
12917 return bgp_show_neighbor_graceful_restart_afi_all(vty
, sh_type
, sh_arg
,
12921 /* "show [ip] bgp neighbors" commands. */
12922 DEFUN (show_ip_bgp_neighbors
,
12923 show_ip_bgp_neighbors_cmd
,
12924 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
12928 BGP_INSTANCE_HELP_STR
12931 "Detailed information on TCP and BGP neighbor connections\n"
12932 "Neighbor to display information about\n"
12933 "Neighbor to display information about\n"
12934 "Neighbor on BGP configured interface\n"
12938 char *sh_arg
= NULL
;
12939 enum show_type sh_type
;
12940 afi_t afi
= AFI_MAX
;
12942 bool uj
= use_json(argc
, argv
);
12946 /* [<vrf> VIEWVRFNAME] */
12947 if (argv_find(argv
, argc
, "vrf", &idx
)) {
12948 vrf
= argv
[idx
+ 1]->arg
;
12949 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
12951 } else if (argv_find(argv
, argc
, "view", &idx
))
12952 /* [<view> VIEWVRFNAME] */
12953 vrf
= argv
[idx
+ 1]->arg
;
12957 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
12958 sh_type
= show_ipv4_all
;
12960 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
12961 sh_type
= show_ipv6_all
;
12964 sh_type
= show_all
;
12967 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
12968 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
12969 || argv_find(argv
, argc
, "WORD", &idx
)) {
12970 sh_type
= show_peer
;
12971 sh_arg
= argv
[idx
]->arg
;
12974 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
12975 sh_type
= show_ipv4_peer
;
12976 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
12977 sh_type
= show_ipv6_peer
;
12980 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
12983 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
12984 paths' and `show ip mbgp paths'. Those functions results are the
12986 DEFUN (show_ip_bgp_paths
,
12987 show_ip_bgp_paths_cmd
,
12988 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
12993 "Path information\n")
12995 vty_out(vty
, "Address Refcnt Path\n");
12996 aspath_print_all_vty(vty
);
12997 return CMD_SUCCESS
;
13002 static void community_show_all_iterator(struct hash_bucket
*bucket
,
13005 struct community
*com
;
13007 com
= (struct community
*)bucket
->data
;
13008 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
13009 community_str(com
, false));
13012 /* Show BGP's community internal data. */
13013 DEFUN (show_ip_bgp_community_info
,
13014 show_ip_bgp_community_info_cmd
,
13015 "show [ip] bgp community-info",
13019 "List all bgp community information\n")
13021 vty_out(vty
, "Address Refcnt Community\n");
13023 hash_iterate(community_hash(),
13024 (void (*)(struct hash_bucket
*,
13025 void *))community_show_all_iterator
,
13028 return CMD_SUCCESS
;
13031 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
13034 struct lcommunity
*lcom
;
13036 lcom
= (struct lcommunity
*)bucket
->data
;
13037 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
13038 lcommunity_str(lcom
, false));
13041 /* Show BGP's community internal data. */
13042 DEFUN (show_ip_bgp_lcommunity_info
,
13043 show_ip_bgp_lcommunity_info_cmd
,
13044 "show ip bgp large-community-info",
13048 "List all bgp large-community information\n")
13050 vty_out(vty
, "Address Refcnt Large-community\n");
13052 hash_iterate(lcommunity_hash(),
13053 (void (*)(struct hash_bucket
*,
13054 void *))lcommunity_show_all_iterator
,
13057 return CMD_SUCCESS
;
13059 /* Graceful Restart */
13061 static void bgp_show_global_graceful_restart_mode_vty(struct vty
*vty
,
13068 vty_out(vty
, "\n%s", SHOW_GR_HEADER
);
13070 enum global_mode bgp_global_gr_mode
= bgp_global_gr_mode_get(bgp
);
13072 switch (bgp_global_gr_mode
) {
13074 case GLOBAL_HELPER
:
13075 vty_out(vty
, "Global BGP GR Mode : Helper\n");
13079 vty_out(vty
, "Global BGP GR Mode : Restart\n");
13082 case GLOBAL_DISABLE
:
13083 vty_out(vty
, "Global BGP GR Mode : Disable\n");
13086 case GLOBAL_INVALID
:
13088 "Global BGP GR Mode Invalid\n");
13091 vty_out(vty
, "\n");
13094 static int bgp_show_neighbor_graceful_restart_afi_all(struct vty
*vty
,
13095 enum show_type type
,
13096 const char *ip_str
,
13097 afi_t afi
, bool use_json
)
13099 if ((afi
== AFI_MAX
) && (ip_str
== NULL
)) {
13102 while ((afi
!= AFI_L2VPN
) && (afi
< AFI_MAX
)) {
13104 bgp_show_neighbor_graceful_restart_vty(
13105 vty
, type
, ip_str
, afi
, use_json
);
13108 } else if (afi
!= AFI_MAX
) {
13109 bgp_show_neighbor_graceful_restart_vty(vty
, type
, ip_str
, afi
,
13112 return CMD_ERR_INCOMPLETE
;
13115 return CMD_SUCCESS
;
13117 /* Graceful Restart */
13119 DEFUN (show_ip_bgp_attr_info
,
13120 show_ip_bgp_attr_info_cmd
,
13121 "show [ip] bgp attribute-info",
13125 "List all bgp attribute information\n")
13127 attr_show_all(vty
);
13128 return CMD_SUCCESS
;
13131 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
13132 afi_t afi
, safi_t safi
,
13133 bool use_json
, json_object
*json
)
13136 struct listnode
*node
;
13138 char buf1
[INET6_ADDRSTRLEN
];
13140 vpn_policy_direction_t dir
;
13143 json_object
*json_import_vrfs
= NULL
;
13144 json_object
*json_export_vrfs
= NULL
;
13146 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
13149 vty_out(vty
, "%s\n",
13150 json_object_to_json_string_ext(
13152 JSON_C_TO_STRING_PRETTY
));
13153 json_object_free(json
);
13155 return CMD_WARNING
;
13158 /* Provide context for the block */
13159 json_object_string_add(json
, "vrf", name
? name
: "default");
13160 json_object_string_add(json
, "afiSafi",
13161 get_afi_safi_str(afi
, safi
, true));
13163 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
13164 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
13165 json_object_string_add(json
, "importFromVrfs", "none");
13166 json_object_string_add(json
, "importRts", "none");
13168 json_import_vrfs
= json_object_new_array();
13170 for (ALL_LIST_ELEMENTS_RO(
13171 bgp
->vpn_policy
[afi
].import_vrf
,
13173 json_object_array_add(json_import_vrfs
,
13174 json_object_new_string(vname
));
13176 json_object_object_add(json
, "importFromVrfs",
13178 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
13179 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
13180 ecom_str
= ecommunity_ecom2str(
13181 bgp
->vpn_policy
[afi
].rtlist
[dir
],
13182 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
13183 json_object_string_add(json
, "importRts",
13185 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
13187 json_object_string_add(json
, "importRts",
13191 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
13192 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
13193 json_object_string_add(json
, "exportToVrfs", "none");
13194 json_object_string_add(json
, "routeDistinguisher",
13196 json_object_string_add(json
, "exportRts", "none");
13198 json_export_vrfs
= json_object_new_array();
13200 for (ALL_LIST_ELEMENTS_RO(
13201 bgp
->vpn_policy
[afi
].export_vrf
,
13203 json_object_array_add(json_export_vrfs
,
13204 json_object_new_string(vname
));
13205 json_object_object_add(json
, "exportToVrfs",
13207 json_object_string_add(json
, "routeDistinguisher",
13208 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
13209 buf1
, RD_ADDRSTRLEN
));
13211 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
13212 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
13213 ecom_str
= ecommunity_ecom2str(
13214 bgp
->vpn_policy
[afi
].rtlist
[dir
],
13215 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
13216 json_object_string_add(json
, "exportRts",
13218 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
13220 json_object_string_add(json
, "exportRts",
13225 vty_out(vty
, "%s\n",
13226 json_object_to_json_string_ext(json
,
13227 JSON_C_TO_STRING_PRETTY
));
13228 json_object_free(json
);
13231 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
13234 vty_out(vty
, "%% No such BGP instance exist\n");
13235 return CMD_WARNING
;
13238 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
13239 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
13241 "This VRF is not importing %s routes from any other VRF\n",
13242 get_afi_safi_str(afi
, safi
, false));
13245 "This VRF is importing %s routes from the following VRFs:\n",
13246 get_afi_safi_str(afi
, safi
, false));
13248 for (ALL_LIST_ELEMENTS_RO(
13249 bgp
->vpn_policy
[afi
].import_vrf
,
13251 vty_out(vty
, " %s\n", vname
);
13253 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
13255 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
13256 ecom_str
= ecommunity_ecom2str(
13257 bgp
->vpn_policy
[afi
].rtlist
[dir
],
13258 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
13259 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
13261 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
13263 vty_out(vty
, "Import RT(s):\n");
13266 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
13267 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
13269 "This VRF is not exporting %s routes to any other VRF\n",
13270 get_afi_safi_str(afi
, safi
, false));
13273 "This VRF is exporting %s routes to the following VRFs:\n",
13274 get_afi_safi_str(afi
, safi
, false));
13276 for (ALL_LIST_ELEMENTS_RO(
13277 bgp
->vpn_policy
[afi
].export_vrf
,
13279 vty_out(vty
, " %s\n", vname
);
13281 vty_out(vty
, "RD: %s\n",
13282 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
13283 buf1
, RD_ADDRSTRLEN
));
13285 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
13286 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
13287 ecom_str
= ecommunity_ecom2str(
13288 bgp
->vpn_policy
[afi
].rtlist
[dir
],
13289 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
13290 vty_out(vty
, "Export RT: %s\n", ecom_str
);
13291 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
13293 vty_out(vty
, "Import RT(s):\n");
13297 return CMD_SUCCESS
;
13300 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
13301 safi_t safi
, bool use_json
)
13303 struct listnode
*node
, *nnode
;
13305 char *vrf_name
= NULL
;
13306 json_object
*json
= NULL
;
13307 json_object
*json_vrf
= NULL
;
13308 json_object
*json_vrfs
= NULL
;
13311 json
= json_object_new_object();
13312 json_vrfs
= json_object_new_object();
13315 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
13317 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
13318 vrf_name
= bgp
->name
;
13321 json_vrf
= json_object_new_object();
13323 vty_out(vty
, "\nInstance %s:\n",
13324 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
13325 ? VRF_DEFAULT_NAME
: bgp
->name
);
13327 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
13329 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
13330 json_object_object_add(json_vrfs
,
13331 VRF_DEFAULT_NAME
, json_vrf
);
13333 json_object_object_add(json_vrfs
, vrf_name
,
13339 json_object_object_add(json
, "vrfs", json_vrfs
);
13340 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
13341 JSON_C_TO_STRING_PRETTY
));
13342 json_object_free(json
);
13345 return CMD_SUCCESS
;
13348 /* "show [ip] bgp route-leak" command. */
13349 DEFUN (show_ip_bgp_route_leak
,
13350 show_ip_bgp_route_leak_cmd
,
13351 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
13355 BGP_INSTANCE_HELP_STR
13358 "Route leaking information\n"
13362 afi_t afi
= AFI_MAX
;
13363 safi_t safi
= SAFI_MAX
;
13365 bool uj
= use_json(argc
, argv
);
13367 json_object
*json
= NULL
;
13369 /* show [ip] bgp */
13370 if (argv_find(argv
, argc
, "ip", &idx
)) {
13372 safi
= SAFI_UNICAST
;
13374 /* [vrf VIEWVRFNAME] */
13375 if (argv_find(argv
, argc
, "view", &idx
)) {
13377 "%% This command is not applicable to BGP views\n");
13378 return CMD_WARNING
;
13381 if (argv_find(argv
, argc
, "vrf", &idx
)) {
13382 vrf
= argv
[idx
+ 1]->arg
;
13383 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
13386 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
13387 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
13388 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
13391 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
13393 "%% This command is applicable only for unicast ipv4|ipv6\n");
13394 return CMD_WARNING
;
13397 if (vrf
&& strmatch(vrf
, "all"))
13398 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
13401 json
= json_object_new_object();
13403 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
13406 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
13409 struct listnode
*node
, *nnode
;
13412 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
13413 vty_out(vty
, "\nInstance %s:\n",
13414 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
13417 update_group_show(bgp
, afi
, safi
, vty
, 0);
13421 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
13422 int safi
, uint64_t subgrp_id
)
13427 if (strmatch(name
, "all")) {
13428 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
13429 return CMD_SUCCESS
;
13431 bgp
= bgp_lookup_by_name(name
);
13434 bgp
= bgp_get_default();
13438 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
13439 return CMD_SUCCESS
;
13442 DEFUN (show_ip_bgp_updgrps
,
13443 show_ip_bgp_updgrps_cmd
,
13444 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
13448 BGP_INSTANCE_HELP_STR
13450 BGP_SAFI_WITH_LABEL_HELP_STR
13451 "Detailed info about dynamic update groups\n"
13452 "Specific subgroup to display detailed info for\n")
13455 afi_t afi
= AFI_IP6
;
13456 safi_t safi
= SAFI_UNICAST
;
13457 uint64_t subgrp_id
= 0;
13461 /* show [ip] bgp */
13462 if (argv_find(argv
, argc
, "ip", &idx
))
13464 /* [<vrf> VIEWVRFNAME] */
13465 if (argv_find(argv
, argc
, "vrf", &idx
)) {
13466 vrf
= argv
[idx
+ 1]->arg
;
13467 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
13469 } else if (argv_find(argv
, argc
, "view", &idx
))
13470 /* [<view> VIEWVRFNAME] */
13471 vrf
= argv
[idx
+ 1]->arg
;
13472 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
13473 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
13474 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
13477 /* get subgroup id, if provided */
13479 if (argv
[idx
]->type
== VARIABLE_TKN
)
13480 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
13482 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
13485 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
13486 show_bgp_instance_all_ipv6_updgrps_cmd
,
13487 "show [ip] bgp <view|vrf> all update-groups",
13491 BGP_INSTANCE_ALL_HELP_STR
13492 "Detailed info about dynamic update groups\n")
13494 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
13495 return CMD_SUCCESS
;
13498 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
13499 show_bgp_l2vpn_evpn_updgrps_cmd
,
13500 "show [ip] bgp l2vpn evpn update-groups",
13504 "l2vpn address family\n"
13505 "evpn sub-address family\n"
13506 "Detailed info about dynamic update groups\n")
13509 uint64_t subgrp_id
= 0;
13511 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
13512 return CMD_SUCCESS
;
13515 DEFUN (show_bgp_updgrps_stats
,
13516 show_bgp_updgrps_stats_cmd
,
13517 "show [ip] bgp update-groups statistics",
13521 "Detailed info about dynamic update groups\n"
13526 bgp
= bgp_get_default();
13528 update_group_show_stats(bgp
, vty
);
13530 return CMD_SUCCESS
;
13533 DEFUN (show_bgp_instance_updgrps_stats
,
13534 show_bgp_instance_updgrps_stats_cmd
,
13535 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
13539 BGP_INSTANCE_HELP_STR
13540 "Detailed info about dynamic update groups\n"
13546 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
13548 update_group_show_stats(bgp
, vty
);
13550 return CMD_SUCCESS
;
13553 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
13554 afi_t afi
, safi_t safi
,
13555 const char *what
, uint64_t subgrp_id
)
13560 bgp
= bgp_lookup_by_name(name
);
13562 bgp
= bgp_get_default();
13565 if (!strcmp(what
, "advertise-queue"))
13566 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
13568 else if (!strcmp(what
, "advertised-routes"))
13569 update_group_show_advertised(bgp
, afi
, safi
, vty
,
13571 else if (!strcmp(what
, "packet-queue"))
13572 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
13577 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
13578 show_ip_bgp_instance_updgrps_adj_s_cmd
,
13579 "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",
13580 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
13582 "Detailed info about dynamic update groups\n"
13583 "Specific subgroup to display info for\n"
13584 "Advertisement queue\n"
13585 "Announced routes\n"
13588 uint64_t subgrp_id
= 0;
13592 subgrp_id
= strtoull(sgid
, NULL
, 10);
13597 afiz
= bgp_vty_afi_from_str(afi
);
13601 afiz
= bgp_vty_afi_from_str(afi
);
13602 if (afiz
!= AFI_IP
)
13604 "%% Cannot specify both 'ip' and 'ipv6'\n");
13605 return CMD_WARNING
;
13608 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
13610 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
13611 return CMD_SUCCESS
;
13614 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
13616 struct listnode
*node
, *nnode
;
13617 struct prefix
*range
;
13620 char buf
[PREFIX2STR_BUFFER
];
13623 const char *peer_status
;
13624 const char *af_str
;
13629 conf
= group
->conf
;
13631 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
13632 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
13633 group
->name
, conf
->as
);
13634 } else if (conf
->as_type
== AS_INTERNAL
) {
13635 vty_out(vty
, "\nBGP peer-group %s, remote AS %u\n",
13636 group
->name
, group
->bgp
->as
);
13638 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
13641 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
13642 vty_out(vty
, " Peer-group type is internal\n");
13644 vty_out(vty
, " Peer-group type is external\n");
13646 /* Display AFs configured. */
13647 vty_out(vty
, " Configured address-families:");
13648 FOREACH_AFI_SAFI (afi
, safi
) {
13649 if (conf
->afc
[afi
][safi
]) {
13651 vty_out(vty
, " %s;", get_afi_safi_str(afi
, safi
, false));
13655 vty_out(vty
, " none\n");
13657 vty_out(vty
, "\n");
13659 /* Display listen ranges (for dynamic neighbors), if any */
13660 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
13663 else if (afi
== AFI_IP6
)
13667 lr_count
= listcount(group
->listen_range
[afi
]);
13669 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
13673 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
13675 prefix2str(range
, buf
, sizeof(buf
));
13676 vty_out(vty
, " %s\n", buf
);
13681 /* Display group members and their status */
13682 if (listcount(group
->peer
)) {
13683 vty_out(vty
, " Peer-group members:\n");
13684 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
13685 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
)
13686 || CHECK_FLAG(peer
->bgp
->flags
, BGP_FLAG_SHUTDOWN
))
13687 peer_status
= "Idle (Admin)";
13688 else if (CHECK_FLAG(peer
->sflags
,
13689 PEER_STATUS_PREFIX_OVERFLOW
))
13690 peer_status
= "Idle (PfxCt)";
13692 peer_status
= lookup_msg(bgp_status_msg
,
13693 peer
->status
, NULL
);
13695 dynamic
= peer_dynamic_neighbor(peer
);
13696 vty_out(vty
, " %s %s %s \n", peer
->host
,
13697 dynamic
? "(dynamic)" : "", peer_status
);
13701 return CMD_SUCCESS
;
13704 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
13705 const char *group_name
)
13708 struct listnode
*node
, *nnode
;
13709 struct peer_group
*group
;
13710 bool found
= false;
13712 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
13715 vty_out(vty
, "%% BGP instance not found\n");
13716 return CMD_WARNING
;
13719 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
13721 if (strmatch(group
->name
, group_name
)) {
13722 bgp_show_one_peer_group(vty
, group
);
13727 bgp_show_one_peer_group(vty
, group
);
13731 if (group_name
&& !found
)
13732 vty_out(vty
, "%% No such peer-group\n");
13734 return CMD_SUCCESS
;
13737 DEFUN (show_ip_bgp_peer_groups
,
13738 show_ip_bgp_peer_groups_cmd
,
13739 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
13743 BGP_INSTANCE_HELP_STR
13744 "Detailed information on BGP peer groups\n"
13745 "Peer group name\n")
13750 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
13752 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
13754 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
13758 /* Redistribute VTY commands. */
13760 DEFUN (bgp_redistribute_ipv4
,
13761 bgp_redistribute_ipv4_cmd
,
13762 "redistribute " FRR_IP_REDIST_STR_BGPD
,
13763 "Redistribute information from another routing protocol\n"
13764 FRR_IP_REDIST_HELP_STR_BGPD
)
13766 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13767 int idx_protocol
= 1;
13770 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
13772 vty_out(vty
, "%% Invalid route type\n");
13773 return CMD_WARNING_CONFIG_FAILED
;
13776 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
13777 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
13781 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
13782 "redistribute " FRR_IP_REDIST_STR_BGPD
,
13783 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
13785 DEFUN (bgp_redistribute_ipv4_rmap
,
13786 bgp_redistribute_ipv4_rmap_cmd
,
13787 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
13788 "Redistribute information from another routing protocol\n"
13789 FRR_IP_REDIST_HELP_STR_BGPD
13790 "Route map reference\n"
13791 "Pointer to route-map entries\n")
13793 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13794 int idx_protocol
= 1;
13797 struct bgp_redist
*red
;
13799 struct route_map
*route_map
= route_map_lookup_warn_noexist(
13800 vty
, argv
[idx_word
]->arg
);
13802 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
13804 vty_out(vty
, "%% Invalid route type\n");
13805 return CMD_WARNING_CONFIG_FAILED
;
13808 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
13810 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
13811 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
13815 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
13816 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
13817 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
13818 "Route map reference\n"
13819 "Pointer to route-map entries\n")
13821 DEFUN (bgp_redistribute_ipv4_metric
,
13822 bgp_redistribute_ipv4_metric_cmd
,
13823 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
13824 "Redistribute information from another routing protocol\n"
13825 FRR_IP_REDIST_HELP_STR_BGPD
13826 "Metric for redistributed routes\n"
13827 "Default metric\n")
13829 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13830 int idx_protocol
= 1;
13831 int idx_number
= 3;
13834 struct bgp_redist
*red
;
13837 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
13839 vty_out(vty
, "%% Invalid route type\n");
13840 return CMD_WARNING_CONFIG_FAILED
;
13842 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13844 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
13845 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
13846 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
13850 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
13851 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
13852 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
13853 "Metric for redistributed routes\n"
13854 "Default metric\n")
13856 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
13857 bgp_redistribute_ipv4_rmap_metric_cmd
,
13858 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
13859 "Redistribute information from another routing protocol\n"
13860 FRR_IP_REDIST_HELP_STR_BGPD
13861 "Route map reference\n"
13862 "Pointer to route-map entries\n"
13863 "Metric for redistributed routes\n"
13864 "Default metric\n")
13866 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13867 int idx_protocol
= 1;
13869 int idx_number
= 5;
13872 struct bgp_redist
*red
;
13874 struct route_map
*route_map
=
13875 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
13877 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
13879 vty_out(vty
, "%% Invalid route type\n");
13880 return CMD_WARNING_CONFIG_FAILED
;
13882 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13884 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
13886 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
13887 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
13888 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
13892 bgp_redistribute_ipv4_rmap_metric
,
13893 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
13894 "redistribute " FRR_IP_REDIST_STR_BGPD
13895 " route-map WORD metric (0-4294967295)",
13896 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
13897 "Route map reference\n"
13898 "Pointer to route-map entries\n"
13899 "Metric for redistributed routes\n"
13900 "Default metric\n")
13902 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
13903 bgp_redistribute_ipv4_metric_rmap_cmd
,
13904 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
13905 "Redistribute information from another routing protocol\n"
13906 FRR_IP_REDIST_HELP_STR_BGPD
13907 "Metric for redistributed routes\n"
13909 "Route map reference\n"
13910 "Pointer to route-map entries\n")
13912 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13913 int idx_protocol
= 1;
13914 int idx_number
= 3;
13918 struct bgp_redist
*red
;
13920 struct route_map
*route_map
=
13921 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
13923 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
13925 vty_out(vty
, "%% Invalid route type\n");
13926 return CMD_WARNING_CONFIG_FAILED
;
13928 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13930 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
13931 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
13933 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
13934 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
13938 bgp_redistribute_ipv4_metric_rmap
,
13939 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
13940 "redistribute " FRR_IP_REDIST_STR_BGPD
13941 " metric (0-4294967295) route-map WORD",
13942 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
13943 "Metric for redistributed routes\n"
13945 "Route map reference\n"
13946 "Pointer to route-map entries\n")
13948 DEFUN (bgp_redistribute_ipv4_ospf
,
13949 bgp_redistribute_ipv4_ospf_cmd
,
13950 "redistribute <ospf|table> (1-65535)",
13951 "Redistribute information from another routing protocol\n"
13952 "Open Shortest Path First (OSPFv2)\n"
13953 "Non-main Kernel Routing Table\n"
13954 "Instance ID/Table ID\n")
13956 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13957 int idx_ospf_table
= 1;
13958 int idx_number
= 2;
13959 unsigned short instance
;
13960 unsigned short protocol
;
13962 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
13964 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
13965 protocol
= ZEBRA_ROUTE_OSPF
;
13967 protocol
= ZEBRA_ROUTE_TABLE
;
13969 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
13970 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
13973 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
13974 "redistribute <ospf|table> (1-65535)",
13975 "Redistribute information from another routing protocol\n"
13976 "Open Shortest Path First (OSPFv2)\n"
13977 "Non-main Kernel Routing Table\n"
13978 "Instance ID/Table ID\n")
13980 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
13981 bgp_redistribute_ipv4_ospf_rmap_cmd
,
13982 "redistribute <ospf|table> (1-65535) route-map WORD",
13983 "Redistribute information from another routing protocol\n"
13984 "Open Shortest Path First (OSPFv2)\n"
13985 "Non-main Kernel Routing Table\n"
13986 "Instance ID/Table ID\n"
13987 "Route map reference\n"
13988 "Pointer to route-map entries\n")
13990 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
13991 int idx_ospf_table
= 1;
13992 int idx_number
= 2;
13994 struct bgp_redist
*red
;
13995 unsigned short instance
;
13998 struct route_map
*route_map
=
13999 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
14001 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
14002 protocol
= ZEBRA_ROUTE_OSPF
;
14004 protocol
= ZEBRA_ROUTE_TABLE
;
14006 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
14007 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
14009 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
14010 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
14013 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
14014 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
14015 "redistribute <ospf|table> (1-65535) route-map WORD",
14016 "Redistribute information from another routing protocol\n"
14017 "Open Shortest Path First (OSPFv2)\n"
14018 "Non-main Kernel Routing Table\n"
14019 "Instance ID/Table ID\n"
14020 "Route map reference\n"
14021 "Pointer to route-map entries\n")
14023 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
14024 bgp_redistribute_ipv4_ospf_metric_cmd
,
14025 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
14026 "Redistribute information from another routing protocol\n"
14027 "Open Shortest Path First (OSPFv2)\n"
14028 "Non-main Kernel Routing Table\n"
14029 "Instance ID/Table ID\n"
14030 "Metric for redistributed routes\n"
14031 "Default metric\n")
14033 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14034 int idx_ospf_table
= 1;
14035 int idx_number
= 2;
14036 int idx_number_2
= 4;
14038 struct bgp_redist
*red
;
14039 unsigned short instance
;
14043 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
14044 protocol
= ZEBRA_ROUTE_OSPF
;
14046 protocol
= ZEBRA_ROUTE_TABLE
;
14048 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
14049 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
14051 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
14052 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
14054 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
14057 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
14058 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
14059 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
14060 "Redistribute information from another routing protocol\n"
14061 "Open Shortest Path First (OSPFv2)\n"
14062 "Non-main Kernel Routing Table\n"
14063 "Instance ID/Table ID\n"
14064 "Metric for redistributed routes\n"
14065 "Default metric\n")
14067 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
14068 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
14069 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
14070 "Redistribute information from another routing protocol\n"
14071 "Open Shortest Path First (OSPFv2)\n"
14072 "Non-main Kernel Routing Table\n"
14073 "Instance ID/Table ID\n"
14074 "Route map reference\n"
14075 "Pointer to route-map entries\n"
14076 "Metric for redistributed routes\n"
14077 "Default metric\n")
14079 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14080 int idx_ospf_table
= 1;
14081 int idx_number
= 2;
14083 int idx_number_2
= 6;
14085 struct bgp_redist
*red
;
14086 unsigned short instance
;
14089 struct route_map
*route_map
=
14090 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
14092 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
14093 protocol
= ZEBRA_ROUTE_OSPF
;
14095 protocol
= ZEBRA_ROUTE_TABLE
;
14097 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
14098 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
14100 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
14102 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
14103 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
14105 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
14109 bgp_redistribute_ipv4_ospf_rmap_metric
,
14110 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
14111 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
14112 "Redistribute information from another routing protocol\n"
14113 "Open Shortest Path First (OSPFv2)\n"
14114 "Non-main Kernel Routing Table\n"
14115 "Instance ID/Table ID\n"
14116 "Route map reference\n"
14117 "Pointer to route-map entries\n"
14118 "Metric for redistributed routes\n"
14119 "Default metric\n")
14121 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
14122 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
14123 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
14124 "Redistribute information from another routing protocol\n"
14125 "Open Shortest Path First (OSPFv2)\n"
14126 "Non-main Kernel Routing Table\n"
14127 "Instance ID/Table ID\n"
14128 "Metric for redistributed routes\n"
14130 "Route map reference\n"
14131 "Pointer to route-map entries\n")
14133 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14134 int idx_ospf_table
= 1;
14135 int idx_number
= 2;
14136 int idx_number_2
= 4;
14139 struct bgp_redist
*red
;
14140 unsigned short instance
;
14143 struct route_map
*route_map
=
14144 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
14146 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
14147 protocol
= ZEBRA_ROUTE_OSPF
;
14149 protocol
= ZEBRA_ROUTE_TABLE
;
14151 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
14152 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
14154 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
14155 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
14158 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
14159 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
14163 bgp_redistribute_ipv4_ospf_metric_rmap
,
14164 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
14165 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
14166 "Redistribute information from another routing protocol\n"
14167 "Open Shortest Path First (OSPFv2)\n"
14168 "Non-main Kernel Routing Table\n"
14169 "Instance ID/Table ID\n"
14170 "Metric for redistributed routes\n"
14172 "Route map reference\n"
14173 "Pointer to route-map entries\n")
14175 DEFUN (no_bgp_redistribute_ipv4_ospf
,
14176 no_bgp_redistribute_ipv4_ospf_cmd
,
14177 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
14179 "Redistribute information from another routing protocol\n"
14180 "Open Shortest Path First (OSPFv2)\n"
14181 "Non-main Kernel Routing Table\n"
14182 "Instance ID/Table ID\n"
14183 "Metric for redistributed routes\n"
14185 "Route map reference\n"
14186 "Pointer to route-map entries\n")
14188 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14189 int idx_ospf_table
= 2;
14190 int idx_number
= 3;
14191 unsigned short instance
;
14194 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
14195 protocol
= ZEBRA_ROUTE_OSPF
;
14197 protocol
= ZEBRA_ROUTE_TABLE
;
14199 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
14200 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
14204 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
14205 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
14207 "Redistribute information from another routing protocol\n"
14208 "Open Shortest Path First (OSPFv2)\n"
14209 "Non-main Kernel Routing Table\n"
14210 "Instance ID/Table ID\n"
14211 "Metric for redistributed routes\n"
14213 "Route map reference\n"
14214 "Pointer to route-map entries\n")
14216 DEFUN (no_bgp_redistribute_ipv4
,
14217 no_bgp_redistribute_ipv4_cmd
,
14218 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
14220 "Redistribute information from another routing protocol\n"
14221 FRR_IP_REDIST_HELP_STR_BGPD
14222 "Metric for redistributed routes\n"
14224 "Route map reference\n"
14225 "Pointer to route-map entries\n")
14227 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14228 int idx_protocol
= 2;
14231 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
14233 vty_out(vty
, "%% Invalid route type\n");
14234 return CMD_WARNING_CONFIG_FAILED
;
14236 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
14240 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
14241 "no redistribute " FRR_IP_REDIST_STR_BGPD
14242 " [{metric (0-4294967295)|route-map WORD}]",
14244 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
14245 "Metric for redistributed routes\n"
14247 "Route map reference\n"
14248 "Pointer to route-map entries\n")
14250 DEFUN (bgp_redistribute_ipv6
,
14251 bgp_redistribute_ipv6_cmd
,
14252 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
14253 "Redistribute information from another routing protocol\n"
14254 FRR_IP6_REDIST_HELP_STR_BGPD
)
14256 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14257 int idx_protocol
= 1;
14260 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
14262 vty_out(vty
, "%% Invalid route type\n");
14263 return CMD_WARNING_CONFIG_FAILED
;
14266 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
14267 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
14270 DEFUN (bgp_redistribute_ipv6_rmap
,
14271 bgp_redistribute_ipv6_rmap_cmd
,
14272 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
14273 "Redistribute information from another routing protocol\n"
14274 FRR_IP6_REDIST_HELP_STR_BGPD
14275 "Route map reference\n"
14276 "Pointer to route-map entries\n")
14278 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14279 int idx_protocol
= 1;
14282 struct bgp_redist
*red
;
14284 struct route_map
*route_map
=
14285 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
14287 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
14289 vty_out(vty
, "%% Invalid route type\n");
14290 return CMD_WARNING_CONFIG_FAILED
;
14293 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
14295 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
14296 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
14299 DEFUN (bgp_redistribute_ipv6_metric
,
14300 bgp_redistribute_ipv6_metric_cmd
,
14301 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
14302 "Redistribute information from another routing protocol\n"
14303 FRR_IP6_REDIST_HELP_STR_BGPD
14304 "Metric for redistributed routes\n"
14305 "Default metric\n")
14307 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14308 int idx_protocol
= 1;
14309 int idx_number
= 3;
14312 struct bgp_redist
*red
;
14315 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
14317 vty_out(vty
, "%% Invalid route type\n");
14318 return CMD_WARNING_CONFIG_FAILED
;
14320 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
14322 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
14323 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
14324 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
14327 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
14328 bgp_redistribute_ipv6_rmap_metric_cmd
,
14329 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
14330 "Redistribute information from another routing protocol\n"
14331 FRR_IP6_REDIST_HELP_STR_BGPD
14332 "Route map reference\n"
14333 "Pointer to route-map entries\n"
14334 "Metric for redistributed routes\n"
14335 "Default metric\n")
14337 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14338 int idx_protocol
= 1;
14340 int idx_number
= 5;
14343 struct bgp_redist
*red
;
14345 struct route_map
*route_map
=
14346 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
14348 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
14350 vty_out(vty
, "%% Invalid route type\n");
14351 return CMD_WARNING_CONFIG_FAILED
;
14353 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
14355 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
14357 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
14358 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
14360 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
14363 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
14364 bgp_redistribute_ipv6_metric_rmap_cmd
,
14365 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
14366 "Redistribute information from another routing protocol\n"
14367 FRR_IP6_REDIST_HELP_STR_BGPD
14368 "Metric for redistributed routes\n"
14370 "Route map reference\n"
14371 "Pointer to route-map entries\n")
14373 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14374 int idx_protocol
= 1;
14375 int idx_number
= 3;
14379 struct bgp_redist
*red
;
14381 struct route_map
*route_map
=
14382 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
14384 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
14386 vty_out(vty
, "%% Invalid route type\n");
14387 return CMD_WARNING_CONFIG_FAILED
;
14389 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
14391 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
14392 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
14395 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
14396 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
14399 DEFUN (no_bgp_redistribute_ipv6
,
14400 no_bgp_redistribute_ipv6_cmd
,
14401 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
14403 "Redistribute information from another routing protocol\n"
14404 FRR_IP6_REDIST_HELP_STR_BGPD
14405 "Metric for redistributed routes\n"
14407 "Route map reference\n"
14408 "Pointer to route-map entries\n")
14410 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
14411 int idx_protocol
= 2;
14414 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
14416 vty_out(vty
, "%% Invalid route type\n");
14417 return CMD_WARNING_CONFIG_FAILED
;
14420 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
14423 static void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
,
14424 afi_t afi
, safi_t safi
)
14428 /* Unicast redistribution only. */
14429 if (safi
!= SAFI_UNICAST
)
14432 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
14433 /* Redistribute BGP does not make sense. */
14434 if (i
!= ZEBRA_ROUTE_BGP
) {
14435 struct list
*red_list
;
14436 struct listnode
*node
;
14437 struct bgp_redist
*red
;
14439 red_list
= bgp
->redist
[afi
][i
];
14443 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
14444 /* "redistribute" configuration. */
14445 vty_out(vty
, " redistribute %s",
14446 zebra_route_string(i
));
14448 vty_out(vty
, " %d", red
->instance
);
14449 if (red
->redist_metric_flag
)
14450 vty_out(vty
, " metric %u",
14451 red
->redist_metric
);
14452 if (red
->rmap
.name
)
14453 vty_out(vty
, " route-map %s",
14455 vty_out(vty
, "\n");
14461 /* peer-group helpers for config-write */
14463 static bool peergroup_flag_check(struct peer
*peer
, uint32_t flag
)
14465 if (!peer_group_active(peer
)) {
14466 if (CHECK_FLAG(peer
->flags_invert
, flag
))
14467 return !CHECK_FLAG(peer
->flags
, flag
);
14469 return !!CHECK_FLAG(peer
->flags
, flag
);
14472 return !!CHECK_FLAG(peer
->flags_override
, flag
);
14475 static bool peergroup_af_flag_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
14478 if (!peer_group_active(peer
)) {
14479 if (CHECK_FLAG(peer
->af_flags_invert
[afi
][safi
], flag
))
14480 return !peer_af_flag_check(peer
, afi
, safi
, flag
);
14482 return !!peer_af_flag_check(peer
, afi
, safi
, flag
);
14485 return !!CHECK_FLAG(peer
->af_flags_override
[afi
][safi
], flag
);
14488 static bool peergroup_filter_check(struct peer
*peer
, afi_t afi
, safi_t safi
,
14489 uint8_t type
, int direct
)
14491 struct bgp_filter
*filter
;
14493 if (peer_group_active(peer
))
14494 return !!CHECK_FLAG(peer
->filter_override
[afi
][safi
][direct
],
14497 filter
= &peer
->filter
[afi
][safi
];
14499 case PEER_FT_DISTRIBUTE_LIST
:
14500 return !!(filter
->dlist
[direct
].name
);
14501 case PEER_FT_FILTER_LIST
:
14502 return !!(filter
->aslist
[direct
].name
);
14503 case PEER_FT_PREFIX_LIST
:
14504 return !!(filter
->plist
[direct
].name
);
14505 case PEER_FT_ROUTE_MAP
:
14506 return !!(filter
->map
[direct
].name
);
14507 case PEER_FT_UNSUPPRESS_MAP
:
14508 return !!(filter
->usmap
.name
);
14514 /* Return true if the addpath type is set for peer and different from
14517 static bool peergroup_af_addpath_check(struct peer
*peer
, afi_t afi
,
14520 enum bgp_addpath_strat type
, g_type
;
14522 type
= peer
->addpath_type
[afi
][safi
];
14524 if (type
!= BGP_ADDPATH_NONE
) {
14525 if (peer_group_active(peer
)) {
14526 g_type
= peer
->group
->conf
->addpath_type
[afi
][safi
];
14528 if (type
!= g_type
)
14540 /* This is part of the address-family block (unicast only) */
14541 static void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
14546 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
14547 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
14548 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
14549 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
14550 bgp
->vpn_policy
[afi
]
14551 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
14553 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
14554 bgp
->vpn_policy
[afi
]
14555 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
14557 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
14558 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
14559 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
14560 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
14563 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
14564 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
14566 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
14569 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
14570 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
14571 bgp
->vpn_policy
[afi
].tovpn_label
);
14574 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
14575 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
14576 char buf
[RD_ADDRSTRLEN
];
14577 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
14578 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
14581 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
14582 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
14584 char buf
[PREFIX_STRLEN
];
14585 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
14586 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
14589 vty_out(vty
, "%*snexthop vpn export %s\n",
14593 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
14594 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
14596 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
14597 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
14599 char *b
= ecommunity_ecom2str(
14600 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
14601 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
14602 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
14603 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
14605 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
14606 char *b
= ecommunity_ecom2str(
14607 bgp
->vpn_policy
[afi
]
14608 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
14609 ECOMMUNITY_FORMAT_ROUTE_MAP
,
14610 ECOMMUNITY_ROUTE_TARGET
);
14611 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
14612 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
14614 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
14615 char *b
= ecommunity_ecom2str(
14616 bgp
->vpn_policy
[afi
]
14617 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
14618 ECOMMUNITY_FORMAT_ROUTE_MAP
,
14619 ECOMMUNITY_ROUTE_TARGET
);
14620 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
14621 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
14625 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
14626 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
14627 bgp
->vpn_policy
[afi
]
14628 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
14630 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
14631 char *b
= ecommunity_ecom2str(
14632 bgp
->vpn_policy
[afi
]
14633 .import_redirect_rtlist
,
14634 ECOMMUNITY_FORMAT_ROUTE_MAP
,
14635 ECOMMUNITY_ROUTE_TARGET
);
14637 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
14638 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
14642 static void bgp_config_write_filter(struct vty
*vty
, struct peer
*peer
,
14643 afi_t afi
, safi_t safi
)
14645 struct bgp_filter
*filter
;
14649 filter
= &peer
->filter
[afi
][safi
];
14651 /* distribute-list. */
14652 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
14654 vty_out(vty
, " neighbor %s distribute-list %s in\n", addr
,
14655 filter
->dlist
[FILTER_IN
].name
);
14657 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_DISTRIBUTE_LIST
,
14659 vty_out(vty
, " neighbor %s distribute-list %s out\n", addr
,
14660 filter
->dlist
[FILTER_OUT
].name
);
14663 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
14665 vty_out(vty
, " neighbor %s prefix-list %s in\n", addr
,
14666 filter
->plist
[FILTER_IN
].name
);
14668 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_PREFIX_LIST
,
14670 vty_out(vty
, " neighbor %s prefix-list %s out\n", addr
,
14671 filter
->plist
[FILTER_OUT
].name
);
14674 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
, RMAP_IN
))
14675 vty_out(vty
, " neighbor %s route-map %s in\n", addr
,
14676 filter
->map
[RMAP_IN
].name
);
14678 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_ROUTE_MAP
,
14680 vty_out(vty
, " neighbor %s route-map %s out\n", addr
,
14681 filter
->map
[RMAP_OUT
].name
);
14683 /* unsuppress-map */
14684 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_UNSUPPRESS_MAP
, 0))
14685 vty_out(vty
, " neighbor %s unsuppress-map %s\n", addr
,
14686 filter
->usmap
.name
);
14689 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
14691 vty_out(vty
, " neighbor %s filter-list %s in\n", addr
,
14692 filter
->aslist
[FILTER_IN
].name
);
14694 if (peergroup_filter_check(peer
, afi
, safi
, PEER_FT_FILTER_LIST
,
14696 vty_out(vty
, " neighbor %s filter-list %s out\n", addr
,
14697 filter
->aslist
[FILTER_OUT
].name
);
14700 /* BGP peer configuration display function. */
14701 static void bgp_config_write_peer_global(struct vty
*vty
, struct bgp
*bgp
,
14704 struct peer
*g_peer
= NULL
;
14705 char buf
[SU_ADDRSTRLEN
];
14707 int if_pg_printed
= false;
14708 int if_ras_printed
= false;
14710 /* Skip dynamic neighbors. */
14711 if (peer_dynamic_neighbor(peer
))
14715 addr
= peer
->conf_if
;
14719 /************************************
14720 ****** Global to the neighbor ******
14721 ************************************/
14722 if (peer
->conf_if
) {
14723 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
14724 vty_out(vty
, " neighbor %s interface v6only", addr
);
14726 vty_out(vty
, " neighbor %s interface", addr
);
14728 if (peer_group_active(peer
)) {
14729 vty_out(vty
, " peer-group %s", peer
->group
->name
);
14730 if_pg_printed
= true;
14731 } else if (peer
->as_type
== AS_SPECIFIED
) {
14732 vty_out(vty
, " remote-as %u", peer
->as
);
14733 if_ras_printed
= true;
14734 } else if (peer
->as_type
== AS_INTERNAL
) {
14735 vty_out(vty
, " remote-as internal");
14736 if_ras_printed
= true;
14737 } else if (peer
->as_type
== AS_EXTERNAL
) {
14738 vty_out(vty
, " remote-as external");
14739 if_ras_printed
= true;
14742 vty_out(vty
, "\n");
14745 /* remote-as and peer-group */
14746 /* peer is a member of a peer-group */
14747 if (peer_group_active(peer
)) {
14748 g_peer
= peer
->group
->conf
;
14750 if (g_peer
->as_type
== AS_UNSPECIFIED
&& !if_ras_printed
) {
14751 if (peer
->as_type
== AS_SPECIFIED
) {
14752 vty_out(vty
, " neighbor %s remote-as %u\n",
14754 } else if (peer
->as_type
== AS_INTERNAL
) {
14756 " neighbor %s remote-as internal\n",
14758 } else if (peer
->as_type
== AS_EXTERNAL
) {
14760 " neighbor %s remote-as external\n",
14765 /* For swpX peers we displayed the peer-group
14766 * via 'neighbor swpX interface peer-group PGNAME' */
14767 if (!if_pg_printed
)
14768 vty_out(vty
, " neighbor %s peer-group %s\n", addr
,
14769 peer
->group
->name
);
14772 /* peer is NOT a member of a peer-group */
14774 /* peer is a peer-group, declare the peer-group */
14775 if (CHECK_FLAG(peer
->sflags
, PEER_STATUS_GROUP
)) {
14776 vty_out(vty
, " neighbor %s peer-group\n", addr
);
14779 if (!if_ras_printed
) {
14780 if (peer
->as_type
== AS_SPECIFIED
) {
14781 vty_out(vty
, " neighbor %s remote-as %u\n",
14783 } else if (peer
->as_type
== AS_INTERNAL
) {
14785 " neighbor %s remote-as internal\n",
14787 } else if (peer
->as_type
== AS_EXTERNAL
) {
14789 " neighbor %s remote-as external\n",
14796 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS
)) {
14797 vty_out(vty
, " neighbor %s local-as %u", addr
,
14798 peer
->change_local_as
);
14799 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
14800 vty_out(vty
, " no-prepend");
14801 if (peergroup_flag_check(peer
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
14802 vty_out(vty
, " replace-as");
14803 vty_out(vty
, "\n");
14808 vty_out(vty
, " neighbor %s description %s\n", addr
, peer
->desc
);
14812 if (peergroup_flag_check(peer
, PEER_FLAG_SHUTDOWN
)) {
14813 if (peer
->tx_shutdown_message
)
14814 vty_out(vty
, " neighbor %s shutdown message %s\n", addr
,
14815 peer
->tx_shutdown_message
);
14817 vty_out(vty
, " neighbor %s shutdown\n", addr
);
14821 if (peer
->bfd_info
) {
14822 if (!peer_group_active(peer
) || !g_peer
->bfd_info
) {
14823 bgp_bfd_peer_config_write(vty
, peer
, addr
);
14828 if (peergroup_flag_check(peer
, PEER_FLAG_PASSWORD
))
14829 vty_out(vty
, " neighbor %s password %s\n", addr
,
14832 /* neighbor solo */
14833 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_LONESOUL
)) {
14834 if (!peer_group_active(peer
)) {
14835 vty_out(vty
, " neighbor %s solo\n", addr
);
14840 if (peer
->port
!= BGP_PORT_DEFAULT
) {
14841 vty_out(vty
, " neighbor %s port %d\n", addr
, peer
->port
);
14844 /* Local interface name */
14845 if (peer
->ifname
) {
14846 vty_out(vty
, " neighbor %s interface %s\n", addr
, peer
->ifname
);
14850 if (peergroup_flag_check(peer
, PEER_FLAG_PASSIVE
))
14851 vty_out(vty
, " neighbor %s passive\n", addr
);
14853 /* ebgp-multihop */
14854 if (peer
->sort
!= BGP_PEER_IBGP
&& peer
->ttl
!= BGP_DEFAULT_TTL
14855 && !(peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
14856 && peer
->ttl
== MAXTTL
)) {
14857 if (!peer_group_active(peer
) || g_peer
->ttl
!= peer
->ttl
) {
14858 vty_out(vty
, " neighbor %s ebgp-multihop %d\n", addr
,
14863 /* ttl-security hops */
14864 if (peer
->gtsm_hops
!= BGP_GTSM_HOPS_DISABLED
) {
14865 if (!peer_group_active(peer
)
14866 || g_peer
->gtsm_hops
!= peer
->gtsm_hops
) {
14867 vty_out(vty
, " neighbor %s ttl-security hops %d\n",
14868 addr
, peer
->gtsm_hops
);
14872 /* disable-connected-check */
14873 if (peergroup_flag_check(peer
, PEER_FLAG_DISABLE_CONNECTED_CHECK
))
14874 vty_out(vty
, " neighbor %s disable-connected-check\n", addr
);
14876 /* enforce-first-as */
14877 if (peergroup_flag_check(peer
, PEER_FLAG_ENFORCE_FIRST_AS
))
14878 vty_out(vty
, " neighbor %s enforce-first-as\n", addr
);
14880 /* update-source */
14881 if (peergroup_flag_check(peer
, PEER_FLAG_UPDATE_SOURCE
)) {
14882 if (peer
->update_source
)
14883 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
14884 sockunion2str(peer
->update_source
, buf
,
14886 else if (peer
->update_if
)
14887 vty_out(vty
, " neighbor %s update-source %s\n", addr
,
14891 /* advertisement-interval */
14892 if (peergroup_flag_check(peer
, PEER_FLAG_ROUTEADV
))
14893 vty_out(vty
, " neighbor %s advertisement-interval %u\n", addr
,
14897 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER
))
14898 vty_out(vty
, " neighbor %s timers %u %u\n", addr
,
14899 peer
->keepalive
, peer
->holdtime
);
14901 /* timers connect */
14902 if (peergroup_flag_check(peer
, PEER_FLAG_TIMER_CONNECT
))
14903 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
14905 /* need special-case handling for changed default values due to
14906 * config profile / version (because there is no "timers bgp connect"
14907 * command, we need to save this per-peer :/)
14909 else if (!peer_group_active(peer
) && !peer
->connect
&&
14910 peer
->bgp
->default_connect_retry
!= SAVE_BGP_CONNECT_RETRY
)
14911 vty_out(vty
, " neighbor %s timers connect %u\n", addr
,
14912 peer
->bgp
->default_connect_retry
);
14914 /* capability dynamic */
14915 if (peergroup_flag_check(peer
, PEER_FLAG_DYNAMIC_CAPABILITY
))
14916 vty_out(vty
, " neighbor %s capability dynamic\n", addr
);
14918 /* capability extended-nexthop */
14919 if (peergroup_flag_check(peer
, PEER_FLAG_CAPABILITY_ENHE
)) {
14920 if (!peer
->conf_if
) {
14921 if (CHECK_FLAG(peer
->flags_invert
,
14922 PEER_FLAG_CAPABILITY_ENHE
))
14924 " no neighbor %s capability extended-nexthop\n",
14928 " neighbor %s capability extended-nexthop\n",
14933 /* dont-capability-negotiation */
14934 if (peergroup_flag_check(peer
, PEER_FLAG_DONT_CAPABILITY
))
14935 vty_out(vty
, " neighbor %s dont-capability-negotiate\n", addr
);
14937 /* override-capability */
14938 if (peergroup_flag_check(peer
, PEER_FLAG_OVERRIDE_CAPABILITY
))
14939 vty_out(vty
, " neighbor %s override-capability\n", addr
);
14941 /* strict-capability-match */
14942 if (peergroup_flag_check(peer
, PEER_FLAG_STRICT_CAP_MATCH
))
14943 vty_out(vty
, " neighbor %s strict-capability-match\n", addr
);
14945 /* Sender side AS path loop detection. */
14946 if (peer
->as_path_loop_detection
)
14947 vty_out(vty
, " neighbor %s sender-as-path-loop-detection\n",
14950 if (!CHECK_FLAG(peer
->peer_gr_new_status_flag
,
14951 PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT
)) {
14953 if (CHECK_FLAG(peer
->peer_gr_new_status_flag
,
14954 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
)) {
14956 " neighbor %s graceful-restart-helper\n", addr
);
14957 } else if (CHECK_FLAG(
14958 peer
->peer_gr_new_status_flag
,
14959 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)) {
14961 " neighbor %s graceful-restart\n", addr
);
14963 (!(CHECK_FLAG(peer
->peer_gr_new_status_flag
,
14964 PEER_GRACEFUL_RESTART_NEW_STATE_HELPER
))
14966 peer
->peer_gr_new_status_flag
,
14967 PEER_GRACEFUL_RESTART_NEW_STATE_RESTART
)))) {
14968 vty_out(vty
, " neighbor %s graceful-restart-disable\n",
14974 /* BGP peer configuration display function. */
14975 static void bgp_config_write_peer_af(struct vty
*vty
, struct bgp
*bgp
,
14976 struct peer
*peer
, afi_t afi
, safi_t safi
)
14978 struct peer
*g_peer
= NULL
;
14980 bool flag_scomm
, flag_secomm
, flag_slcomm
;
14982 /* Skip dynamic neighbors. */
14983 if (peer_dynamic_neighbor(peer
))
14987 addr
= peer
->conf_if
;
14991 /************************************
14992 ****** Per AF to the neighbor ******
14993 ************************************/
14994 if (peer_group_active(peer
)) {
14995 g_peer
= peer
->group
->conf
;
14997 /* If the peer-group is active but peer is not, print a 'no
14999 if (g_peer
->afc
[afi
][safi
] && !peer
->afc
[afi
][safi
]) {
15000 vty_out(vty
, " no neighbor %s activate\n", addr
);
15003 /* If the peer-group is not active but peer is, print an
15005 else if (!g_peer
->afc
[afi
][safi
] && peer
->afc
[afi
][safi
]) {
15006 vty_out(vty
, " neighbor %s activate\n", addr
);
15009 if (peer
->afc
[afi
][safi
]) {
15010 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
15011 if (CHECK_FLAG(bgp
->flags
,
15012 BGP_FLAG_NO_DEFAULT_IPV4
)) {
15013 vty_out(vty
, " neighbor %s activate\n",
15017 vty_out(vty
, " neighbor %s activate\n", addr
);
15019 if ((afi
== AFI_IP
) && (safi
== SAFI_UNICAST
)) {
15020 if (!CHECK_FLAG(bgp
->flags
,
15021 BGP_FLAG_NO_DEFAULT_IPV4
)) {
15023 " no neighbor %s activate\n",
15030 /* addpath TX knobs */
15031 if (peergroup_af_addpath_check(peer
, afi
, safi
)) {
15032 switch (peer
->addpath_type
[afi
][safi
]) {
15033 case BGP_ADDPATH_ALL
:
15034 vty_out(vty
, " neighbor %s addpath-tx-all-paths\n",
15037 case BGP_ADDPATH_BEST_PER_AS
:
15039 " neighbor %s addpath-tx-bestpath-per-AS\n",
15042 case BGP_ADDPATH_MAX
:
15043 case BGP_ADDPATH_NONE
:
15048 /* ORF capability. */
15049 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ORF_PREFIX_SM
)
15050 || peergroup_af_flag_check(peer
, afi
, safi
,
15051 PEER_FLAG_ORF_PREFIX_RM
)) {
15052 vty_out(vty
, " neighbor %s capability orf prefix-list", addr
);
15054 if (peergroup_af_flag_check(peer
, afi
, safi
,
15055 PEER_FLAG_ORF_PREFIX_SM
)
15056 && peergroup_af_flag_check(peer
, afi
, safi
,
15057 PEER_FLAG_ORF_PREFIX_RM
))
15058 vty_out(vty
, " both");
15059 else if (peergroup_af_flag_check(peer
, afi
, safi
,
15060 PEER_FLAG_ORF_PREFIX_SM
))
15061 vty_out(vty
, " send");
15063 vty_out(vty
, " receive");
15064 vty_out(vty
, "\n");
15067 /* Route reflector client. */
15068 if (peergroup_af_flag_check(peer
, afi
, safi
,
15069 PEER_FLAG_REFLECTOR_CLIENT
)) {
15070 vty_out(vty
, " neighbor %s route-reflector-client\n", addr
);
15073 /* next-hop-self force */
15074 if (peergroup_af_flag_check(peer
, afi
, safi
,
15075 PEER_FLAG_FORCE_NEXTHOP_SELF
)) {
15076 vty_out(vty
, " neighbor %s next-hop-self force\n", addr
);
15079 /* next-hop-self */
15080 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_NEXTHOP_SELF
)) {
15081 vty_out(vty
, " neighbor %s next-hop-self\n", addr
);
15084 /* remove-private-AS */
15085 if (peergroup_af_flag_check(peer
, afi
, safi
,
15086 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
)) {
15087 vty_out(vty
, " neighbor %s remove-private-AS all replace-AS\n",
15091 else if (peergroup_af_flag_check(peer
, afi
, safi
,
15092 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
)) {
15093 vty_out(vty
, " neighbor %s remove-private-AS replace-AS\n",
15097 else if (peergroup_af_flag_check(peer
, afi
, safi
,
15098 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
)) {
15099 vty_out(vty
, " neighbor %s remove-private-AS all\n", addr
);
15102 else if (peergroup_af_flag_check(peer
, afi
, safi
,
15103 PEER_FLAG_REMOVE_PRIVATE_AS
)) {
15104 vty_out(vty
, " neighbor %s remove-private-AS\n", addr
);
15108 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_OVERRIDE
)) {
15109 vty_out(vty
, " neighbor %s as-override\n", addr
);
15112 /* send-community print. */
15113 flag_scomm
= peergroup_af_flag_check(peer
, afi
, safi
,
15114 PEER_FLAG_SEND_COMMUNITY
);
15115 flag_secomm
= peergroup_af_flag_check(peer
, afi
, safi
,
15116 PEER_FLAG_SEND_EXT_COMMUNITY
);
15117 flag_slcomm
= peergroup_af_flag_check(peer
, afi
, safi
,
15118 PEER_FLAG_SEND_LARGE_COMMUNITY
);
15120 if (flag_scomm
&& flag_secomm
&& flag_slcomm
) {
15121 vty_out(vty
, " no neighbor %s send-community all\n", addr
);
15124 vty_out(vty
, " no neighbor %s send-community\n", addr
);
15127 " no neighbor %s send-community extended\n",
15131 vty_out(vty
, " no neighbor %s send-community large\n",
15135 /* Default information */
15136 if (peergroup_af_flag_check(peer
, afi
, safi
,
15137 PEER_FLAG_DEFAULT_ORIGINATE
)) {
15138 vty_out(vty
, " neighbor %s default-originate", addr
);
15140 if (peer
->default_rmap
[afi
][safi
].name
)
15141 vty_out(vty
, " route-map %s",
15142 peer
->default_rmap
[afi
][safi
].name
);
15144 vty_out(vty
, "\n");
15147 /* Soft reconfiguration inbound. */
15148 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_SOFT_RECONFIG
)) {
15149 vty_out(vty
, " neighbor %s soft-reconfiguration inbound\n",
15153 /* maximum-prefix. */
15154 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX
)) {
15155 vty_out(vty
, " neighbor %s maximum-prefix %u", addr
,
15156 peer
->pmax
[afi
][safi
]);
15158 if (peer
->pmax_threshold
[afi
][safi
]
15159 != MAXIMUM_PREFIX_THRESHOLD_DEFAULT
)
15160 vty_out(vty
, " %u", peer
->pmax_threshold
[afi
][safi
]);
15161 if (peer_af_flag_check(peer
, afi
, safi
,
15162 PEER_FLAG_MAX_PREFIX_WARNING
))
15163 vty_out(vty
, " warning-only");
15164 if (peer
->pmax_restart
[afi
][safi
])
15165 vty_out(vty
, " restart %u",
15166 peer
->pmax_restart
[afi
][safi
]);
15167 if (peer_af_flag_check(peer
, afi
, safi
,
15168 PEER_FLAG_MAX_PREFIX_FORCE
))
15169 vty_out(vty
, " force");
15171 vty_out(vty
, "\n");
15174 /* maximum-prefix-out */
15175 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MAX_PREFIX_OUT
))
15176 vty_out(vty
, " neighbor %s maximum-prefix-out %u\n",
15177 addr
, peer
->pmax_out
[afi
][safi
]);
15179 /* Route server client. */
15180 if (peergroup_af_flag_check(peer
, afi
, safi
,
15181 PEER_FLAG_RSERVER_CLIENT
)) {
15182 vty_out(vty
, " neighbor %s route-server-client\n", addr
);
15185 /* Nexthop-local unchanged. */
15186 if (peergroup_af_flag_check(peer
, afi
, safi
,
15187 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
)) {
15188 vty_out(vty
, " neighbor %s nexthop-local unchanged\n", addr
);
15191 /* allowas-in <1-10> */
15192 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_ALLOWAS_IN
)) {
15193 if (peer_af_flag_check(peer
, afi
, safi
,
15194 PEER_FLAG_ALLOWAS_IN_ORIGIN
)) {
15195 vty_out(vty
, " neighbor %s allowas-in origin\n", addr
);
15196 } else if (peer
->allowas_in
[afi
][safi
] == 3) {
15197 vty_out(vty
, " neighbor %s allowas-in\n", addr
);
15199 vty_out(vty
, " neighbor %s allowas-in %d\n", addr
,
15200 peer
->allowas_in
[afi
][safi
]);
15205 if (peergroup_af_flag_check(peer
, afi
, safi
, PEER_FLAG_WEIGHT
))
15206 vty_out(vty
, " neighbor %s weight %lu\n", addr
,
15207 peer
->weight
[afi
][safi
]);
15210 bgp_config_write_filter(vty
, peer
, afi
, safi
);
15212 /* atribute-unchanged. */
15213 if (peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_AS_PATH_UNCHANGED
)
15214 || (safi
!= SAFI_EVPN
15215 && peer_af_flag_check(peer
, afi
, safi
,
15216 PEER_FLAG_NEXTHOP_UNCHANGED
))
15217 || peer_af_flag_check(peer
, afi
, safi
, PEER_FLAG_MED_UNCHANGED
)) {
15219 if (!peer_group_active(peer
)
15220 || peergroup_af_flag_check(peer
, afi
, safi
,
15221 PEER_FLAG_AS_PATH_UNCHANGED
)
15222 || peergroup_af_flag_check(peer
, afi
, safi
,
15223 PEER_FLAG_NEXTHOP_UNCHANGED
)
15224 || peergroup_af_flag_check(peer
, afi
, safi
,
15225 PEER_FLAG_MED_UNCHANGED
)) {
15228 " neighbor %s attribute-unchanged%s%s%s\n",
15230 peer_af_flag_check(peer
, afi
, safi
,
15231 PEER_FLAG_AS_PATH_UNCHANGED
)
15234 peer_af_flag_check(peer
, afi
, safi
,
15235 PEER_FLAG_NEXTHOP_UNCHANGED
)
15238 peer_af_flag_check(peer
, afi
, safi
,
15239 PEER_FLAG_MED_UNCHANGED
)
15246 /* Address family based peer configuration display. */
15247 static void bgp_config_write_family(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
15251 struct peer_group
*group
;
15252 struct listnode
*node
, *nnode
;
15255 vty_frame(vty
, " !\n address-family ");
15256 if (afi
== AFI_IP
) {
15257 if (safi
== SAFI_UNICAST
)
15258 vty_frame(vty
, "ipv4 unicast");
15259 else if (safi
== SAFI_LABELED_UNICAST
)
15260 vty_frame(vty
, "ipv4 labeled-unicast");
15261 else if (safi
== SAFI_MULTICAST
)
15262 vty_frame(vty
, "ipv4 multicast");
15263 else if (safi
== SAFI_MPLS_VPN
)
15264 vty_frame(vty
, "ipv4 vpn");
15265 else if (safi
== SAFI_ENCAP
)
15266 vty_frame(vty
, "ipv4 encap");
15267 else if (safi
== SAFI_FLOWSPEC
)
15268 vty_frame(vty
, "ipv4 flowspec");
15269 } else if (afi
== AFI_IP6
) {
15270 if (safi
== SAFI_UNICAST
)
15271 vty_frame(vty
, "ipv6 unicast");
15272 else if (safi
== SAFI_LABELED_UNICAST
)
15273 vty_frame(vty
, "ipv6 labeled-unicast");
15274 else if (safi
== SAFI_MULTICAST
)
15275 vty_frame(vty
, "ipv6 multicast");
15276 else if (safi
== SAFI_MPLS_VPN
)
15277 vty_frame(vty
, "ipv6 vpn");
15278 else if (safi
== SAFI_ENCAP
)
15279 vty_frame(vty
, "ipv6 encap");
15280 else if (safi
== SAFI_FLOWSPEC
)
15281 vty_frame(vty
, "ipv6 flowspec");
15282 } else if (afi
== AFI_L2VPN
) {
15283 if (safi
== SAFI_EVPN
)
15284 vty_frame(vty
, "l2vpn evpn");
15286 vty_frame(vty
, "\n");
15288 bgp_config_write_distance(vty
, bgp
, afi
, safi
);
15290 bgp_config_write_network(vty
, bgp
, afi
, safi
);
15292 bgp_config_write_redistribute(vty
, bgp
, afi
, safi
);
15294 /* BGP flag dampening. */
15295 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
], BGP_CONFIG_DAMPENING
))
15296 bgp_config_write_damp(vty
, afi
, safi
);
15298 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
))
15299 bgp_config_write_peer_af(vty
, bgp
, group
->conf
, afi
, safi
);
15301 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
15302 /* Skip dynamic neighbors. */
15303 if (peer_dynamic_neighbor(peer
))
15306 /* Do not display doppelganger peers */
15307 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
15308 bgp_config_write_peer_af(vty
, bgp
, peer
, afi
, safi
);
15311 bgp_config_write_maxpaths(vty
, bgp
, afi
, safi
);
15312 bgp_config_write_table_map(vty
, bgp
, afi
, safi
);
15314 if (safi
== SAFI_EVPN
)
15315 bgp_config_write_evpn_info(vty
, bgp
, afi
, safi
);
15317 if (safi
== SAFI_FLOWSPEC
)
15318 bgp_fs_config_write_pbr(vty
, bgp
, afi
, safi
);
15320 if (safi
== SAFI_UNICAST
) {
15321 bgp_vpn_policy_config_write_afi(vty
, bgp
, afi
);
15322 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15323 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)) {
15325 vty_out(vty
, " export vpn\n");
15327 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15328 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
15330 vty_out(vty
, " import vpn\n");
15332 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
15333 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
15336 for (ALL_LIST_ELEMENTS_RO(
15337 bgp
->vpn_policy
[afi
].import_vrf
, node
,
15339 vty_out(vty
, " import vrf %s\n", name
);
15343 vty_endframe(vty
, " exit-address-family\n");
15346 int bgp_config_write(struct vty
*vty
)
15349 struct peer_group
*group
;
15351 struct listnode
*node
, *nnode
;
15352 struct listnode
*mnode
, *mnnode
;
15354 if (bm
->rmap_update_timer
!= RMAP_DEFAULT_UPDATE_TIMER
)
15355 vty_out(vty
, "bgp route-map delay-timer %u\n",
15356 bm
->rmap_update_timer
);
15358 /* BGP configuration. */
15359 for (ALL_LIST_ELEMENTS(bm
->bgp
, mnode
, mnnode
, bgp
)) {
15361 /* skip all auto created vrf as they dont have user config */
15362 if (CHECK_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
))
15365 /* Router bgp ASN */
15366 vty_out(vty
, "router bgp %u", bgp
->as
);
15369 vty_out(vty
, " %s %s",
15370 (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
15371 ? "view" : "vrf", bgp
->name
);
15372 vty_out(vty
, "\n");
15374 /* BGP fast-external-failover. */
15375 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_FAST_EXT_FAILOVER
))
15376 vty_out(vty
, " no bgp fast-external-failover\n");
15378 /* BGP router ID. */
15379 if (bgp
->router_id_static
.s_addr
!= 0)
15380 vty_out(vty
, " bgp router-id %s\n",
15381 inet_ntoa(bgp
->router_id_static
));
15383 /* BGP log-neighbor-changes. */
15384 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
15385 != SAVE_BGP_LOG_NEIGHBOR_CHANGES
)
15386 vty_out(vty
, " %sbgp log-neighbor-changes\n",
15387 CHECK_FLAG(bgp
->flags
,
15388 BGP_FLAG_LOG_NEIGHBOR_CHANGES
)
15392 /* BGP configuration. */
15393 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ALWAYS_COMPARE_MED
))
15394 vty_out(vty
, " bgp always-compare-med\n");
15396 /* RFC8212 default eBGP policy. */
15397 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_EBGP_REQUIRES_POLICY
)
15398 != SAVE_BGP_EBGP_REQUIRES_POLICY
)
15399 vty_out(vty
, " %sbgp ebgp-requires-policy\n",
15400 CHECK_FLAG(bgp
->flags
,
15401 BGP_FLAG_EBGP_REQUIRES_POLICY
)
15405 /* draft-ietf-idr-deprecate-as-set-confed-set */
15406 if (bgp
->reject_as_sets
)
15407 vty_out(vty
, " bgp reject-as-sets\n");
15409 /* BGP default ipv4-unicast. */
15410 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_DEFAULT_IPV4
))
15411 vty_out(vty
, " no bgp default ipv4-unicast\n");
15413 /* BGP default local-preference. */
15414 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
15415 vty_out(vty
, " bgp default local-preference %u\n",
15416 bgp
->default_local_pref
);
15418 /* BGP default show-hostname */
15419 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
15420 != SAVE_BGP_SHOW_HOSTNAME
)
15421 vty_out(vty
, " %sbgp default show-hostname\n",
15422 CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_HOSTNAME
)
15426 /* BGP default show-nexthop-hostname */
15427 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
15428 != SAVE_BGP_SHOW_HOSTNAME
)
15429 vty_out(vty
, " %sbgp default show-nexthop-hostname\n",
15430 CHECK_FLAG(bgp
->flags
,
15431 BGP_FLAG_SHOW_NEXTHOP_HOSTNAME
)
15435 /* BGP default subgroup-pkt-queue-max. */
15436 if (bgp
->default_subgroup_pkt_queue_max
15437 != BGP_DEFAULT_SUBGROUP_PKT_QUEUE_MAX
)
15438 vty_out(vty
, " bgp default subgroup-pkt-queue-max %u\n",
15439 bgp
->default_subgroup_pkt_queue_max
);
15441 /* BGP client-to-client reflection. */
15442 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_NO_CLIENT_TO_CLIENT
))
15443 vty_out(vty
, " no bgp client-to-client reflection\n");
15445 /* BGP cluster ID. */
15446 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
15447 vty_out(vty
, " bgp cluster-id %s\n",
15448 inet_ntoa(bgp
->cluster_id
));
15450 /* Disable ebgp connected nexthop check */
15451 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
))
15453 " bgp disable-ebgp-connected-route-check\n");
15455 /* Confederation identifier*/
15456 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
15457 vty_out(vty
, " bgp confederation identifier %u\n",
15460 /* Confederation peer */
15461 if (bgp
->confed_peers_cnt
> 0) {
15464 vty_out(vty
, " bgp confederation peers");
15466 for (i
= 0; i
< bgp
->confed_peers_cnt
; i
++)
15467 vty_out(vty
, " %u", bgp
->confed_peers
[i
]);
15469 vty_out(vty
, "\n");
15472 /* BGP deterministic-med. */
15473 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_DETERMINISTIC_MED
)
15474 != SAVE_BGP_DETERMINISTIC_MED
)
15475 vty_out(vty
, " %sbgp deterministic-med\n",
15476 CHECK_FLAG(bgp
->flags
,
15477 BGP_FLAG_DETERMINISTIC_MED
)
15481 /* BGP update-delay. */
15482 bgp_config_write_update_delay(vty
, bgp
);
15484 if (bgp
->v_maxmed_onstartup
15485 != BGP_MAXMED_ONSTARTUP_UNCONFIGURED
) {
15486 vty_out(vty
, " bgp max-med on-startup %u",
15487 bgp
->v_maxmed_onstartup
);
15488 if (bgp
->maxmed_onstartup_value
15489 != BGP_MAXMED_VALUE_DEFAULT
)
15490 vty_out(vty
, " %u",
15491 bgp
->maxmed_onstartup_value
);
15492 vty_out(vty
, "\n");
15494 if (bgp
->v_maxmed_admin
!= BGP_MAXMED_ADMIN_UNCONFIGURED
) {
15495 vty_out(vty
, " bgp max-med administrative");
15496 if (bgp
->maxmed_admin_value
!= BGP_MAXMED_VALUE_DEFAULT
)
15497 vty_out(vty
, " %u", bgp
->maxmed_admin_value
);
15498 vty_out(vty
, "\n");
15502 bgp_config_write_wpkt_quanta(vty
, bgp
);
15504 bgp_config_write_rpkt_quanta(vty
, bgp
);
15506 /* coalesce time */
15507 bgp_config_write_coalesce_time(vty
, bgp
);
15509 /* BGP graceful-restart. */
15510 if (bgp
->stalepath_time
!= BGP_DEFAULT_STALEPATH_TIME
)
15512 " bgp graceful-restart stalepath-time %u\n",
15513 bgp
->stalepath_time
);
15515 if (bgp
->restart_time
!= BGP_DEFAULT_RESTART_TIME
)
15516 vty_out(vty
, " bgp graceful-restart restart-time %u\n",
15517 bgp
->restart_time
);
15519 if (bgp
->select_defer_time
!= BGP_DEFAULT_SELECT_DEFERRAL_TIME
)
15521 " bgp graceful-restart select-defer-time %u\n",
15522 bgp
->select_defer_time
);
15524 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_GR
)
15525 vty_out(vty
, " bgp graceful-restart\n");
15527 if (bgp_global_gr_mode_get(bgp
) == GLOBAL_DISABLE
)
15528 vty_out(vty
, " bgp graceful-restart-disable\n");
15530 /* BGP graceful-shutdown */
15531 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GRACEFUL_SHUTDOWN
))
15532 vty_out(vty
, " bgp graceful-shutdown\n");
15534 /* BGP graceful-restart Preserve State F bit. */
15535 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_GR_PRESERVE_FWD
))
15537 " bgp graceful-restart preserve-fw-state\n");
15539 /* Stale timer for RIB */
15540 if (bgp
->rib_stale_time
!= BGP_DEFAULT_RIB_STALE_TIME
)
15542 " bgp graceful-restart rib-stale-time %u\n",
15543 bgp
->rib_stale_time
);
15545 /* BGP bestpath method. */
15546 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_IGNORE
))
15547 vty_out(vty
, " bgp bestpath as-path ignore\n");
15548 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_CONFED
))
15549 vty_out(vty
, " bgp bestpath as-path confed\n");
15551 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
15552 if (CHECK_FLAG(bgp
->flags
,
15553 BGP_FLAG_MULTIPATH_RELAX_AS_SET
)) {
15555 " bgp bestpath as-path multipath-relax as-set\n");
15558 " bgp bestpath as-path multipath-relax\n");
15562 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
15564 " bgp route-reflector allow-outbound-policy\n");
15566 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_COMPARE_ROUTER_ID
))
15567 vty_out(vty
, " bgp bestpath compare-routerid\n");
15568 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
)
15569 || CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
15570 vty_out(vty
, " bgp bestpath med");
15571 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_MED_CONFED
))
15572 vty_out(vty
, " confed");
15573 if (CHECK_FLAG(bgp
->flags
,
15574 BGP_FLAG_MED_MISSING_AS_WORST
))
15575 vty_out(vty
, " missing-as-worst");
15576 vty_out(vty
, "\n");
15579 /* Link bandwidth handling. */
15580 if (bgp
->lb_handling
== BGP_LINK_BW_IGNORE_BW
)
15581 vty_out(vty
, " bgp bestpath bandwidth ignore\n");
15582 else if (bgp
->lb_handling
== BGP_LINK_BW_SKIP_MISSING
)
15583 vty_out(vty
, " bgp bestpath bandwidth skip-missing\n");
15584 else if (bgp
->lb_handling
== BGP_LINK_BW_DEFWT_4_MISSING
)
15585 vty_out(vty
, " bgp bestpath bandwidth default-weight-for-missing\n");
15587 /* BGP network import check. */
15588 if (!!CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
15589 != SAVE_BGP_IMPORT_CHECK
)
15590 vty_out(vty
, " %sbgp network import-check\n",
15591 CHECK_FLAG(bgp
->flags
, BGP_FLAG_IMPORT_CHECK
)
15595 /* BGP timers configuration. */
15596 if (bgp
->default_keepalive
!= SAVE_BGP_KEEPALIVE
15597 && bgp
->default_holdtime
!= SAVE_BGP_HOLDTIME
)
15598 vty_out(vty
, " timers bgp %u %u\n",
15599 bgp
->default_keepalive
, bgp
->default_holdtime
);
15602 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
15603 bgp_config_write_peer_global(vty
, bgp
, group
->conf
);
15606 /* Normal neighbor configuration. */
15607 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
15608 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
15609 bgp_config_write_peer_global(vty
, bgp
, peer
);
15612 /* listen range and limit for dynamic BGP neighbors */
15613 bgp_config_write_listen(vty
, bgp
);
15616 * BGP default autoshutdown neighbors
15618 * This must be placed after any peer and peer-group
15619 * configuration, to avoid setting all peers to shutdown after
15620 * a daemon restart, which is undesired behavior. (see #2286)
15622 if (bgp
->autoshutdown
)
15623 vty_out(vty
, " bgp default shutdown\n");
15625 /* BGP instance administrative shutdown */
15626 if (CHECK_FLAG(bgp
->flags
, BGP_FLAG_SHUTDOWN
))
15627 vty_out(vty
, " bgp shutdown\n");
15629 /* IPv4 unicast configuration. */
15630 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_UNICAST
);
15632 /* IPv4 multicast configuration. */
15633 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
15635 /* IPv4 labeled-unicast configuration. */
15636 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_LABELED_UNICAST
);
15638 /* IPv4 VPN configuration. */
15639 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
15641 /* ENCAPv4 configuration. */
15642 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_ENCAP
);
15644 /* FLOWSPEC v4 configuration. */
15645 bgp_config_write_family(vty
, bgp
, AFI_IP
, SAFI_FLOWSPEC
);
15647 /* IPv6 unicast configuration. */
15648 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
15650 /* IPv6 multicast configuration. */
15651 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MULTICAST
);
15653 /* IPv6 labeled-unicast configuration. */
15654 bgp_config_write_family(vty
, bgp
, AFI_IP6
,
15655 SAFI_LABELED_UNICAST
);
15657 /* IPv6 VPN configuration. */
15658 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_MPLS_VPN
);
15660 /* ENCAPv6 configuration. */
15661 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_ENCAP
);
15663 /* FLOWSPEC v6 configuration. */
15664 bgp_config_write_family(vty
, bgp
, AFI_IP6
, SAFI_FLOWSPEC
);
15666 /* EVPN configuration. */
15667 bgp_config_write_family(vty
, bgp
, AFI_L2VPN
, SAFI_EVPN
);
15669 hook_call(bgp_inst_config_write
, bgp
, vty
);
15671 #ifdef ENABLE_BGP_VNC
15672 bgp_rfapi_cfg_write(vty
, bgp
);
15675 vty_out(vty
, "!\n");
15681 /* BGP node structure. */
15682 static struct cmd_node bgp_node
= {
15685 .parent_node
= CONFIG_NODE
,
15686 .prompt
= "%s(config-router)# ",
15687 .config_write
= bgp_config_write
,
15690 static struct cmd_node bgp_ipv4_unicast_node
= {
15691 .name
= "bgp ipv4 unicast",
15692 .node
= BGP_IPV4_NODE
,
15693 .parent_node
= BGP_NODE
,
15694 .prompt
= "%s(config-router-af)# ",
15697 static struct cmd_node bgp_ipv4_multicast_node
= {
15698 .name
= "bgp ipv4 multicast",
15699 .node
= BGP_IPV4M_NODE
,
15700 .parent_node
= BGP_NODE
,
15701 .prompt
= "%s(config-router-af)# ",
15704 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
15705 .name
= "bgp ipv4 labeled unicast",
15706 .node
= BGP_IPV4L_NODE
,
15707 .parent_node
= BGP_NODE
,
15708 .prompt
= "%s(config-router-af)# ",
15711 static struct cmd_node bgp_ipv6_unicast_node
= {
15712 .name
= "bgp ipv6",
15713 .node
= BGP_IPV6_NODE
,
15714 .parent_node
= BGP_NODE
,
15715 .prompt
= "%s(config-router-af)# ",
15718 static struct cmd_node bgp_ipv6_multicast_node
= {
15719 .name
= "bgp ipv6 multicast",
15720 .node
= BGP_IPV6M_NODE
,
15721 .parent_node
= BGP_NODE
,
15722 .prompt
= "%s(config-router-af)# ",
15725 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
15726 .name
= "bgp ipv6 labeled unicast",
15727 .node
= BGP_IPV6L_NODE
,
15728 .parent_node
= BGP_NODE
,
15729 .prompt
= "%s(config-router-af)# ",
15732 static struct cmd_node bgp_vpnv4_node
= {
15733 .name
= "bgp vpnv4",
15734 .node
= BGP_VPNV4_NODE
,
15735 .parent_node
= BGP_NODE
,
15736 .prompt
= "%s(config-router-af)# ",
15739 static struct cmd_node bgp_vpnv6_node
= {
15740 .name
= "bgp vpnv6",
15741 .node
= BGP_VPNV6_NODE
,
15742 .parent_node
= BGP_NODE
,
15743 .prompt
= "%s(config-router-af-vpnv6)# ",
15746 static struct cmd_node bgp_evpn_node
= {
15747 .name
= "bgp evpn",
15748 .node
= BGP_EVPN_NODE
,
15749 .parent_node
= BGP_NODE
,
15750 .prompt
= "%s(config-router-evpn)# ",
15753 static struct cmd_node bgp_evpn_vni_node
= {
15754 .name
= "bgp evpn vni",
15755 .node
= BGP_EVPN_VNI_NODE
,
15756 .parent_node
= BGP_EVPN_NODE
,
15757 .prompt
= "%s(config-router-af-vni)# ",
15760 static struct cmd_node bgp_flowspecv4_node
= {
15761 .name
= "bgp ipv4 flowspec",
15762 .node
= BGP_FLOWSPECV4_NODE
,
15763 .parent_node
= BGP_NODE
,
15764 .prompt
= "%s(config-router-af)# ",
15767 static struct cmd_node bgp_flowspecv6_node
= {
15768 .name
= "bgp ipv6 flowspec",
15769 .node
= BGP_FLOWSPECV6_NODE
,
15770 .parent_node
= BGP_NODE
,
15771 .prompt
= "%s(config-router-af-vpnv6)# ",
15774 static void community_list_vty(void);
15776 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
15780 struct listnode
*lnbgp
, *lnpeer
;
15782 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
15783 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
15784 /* only provide suggestions on the appropriate input
15786 * they'll otherwise show up multiple times */
15787 enum cmd_token_type match_type
;
15788 char *name
= peer
->host
;
15790 if (peer
->conf_if
) {
15791 match_type
= VARIABLE_TKN
;
15792 name
= peer
->conf_if
;
15793 } else if (strchr(peer
->host
, ':'))
15794 match_type
= IPV6_TKN
;
15796 match_type
= IPV4_TKN
;
15798 if (token
->type
!= match_type
)
15801 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
15806 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
15807 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
15808 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
15809 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
15810 {.completions
= NULL
}};
15812 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
15815 struct peer_group
*group
;
15816 struct listnode
*lnbgp
, *lnpeer
;
15818 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
15819 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
15820 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
15825 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
15826 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
15827 {.completions
= NULL
} };
15829 void bgp_vty_init(void)
15831 cmd_variable_handler_register(bgp_var_neighbor
);
15832 cmd_variable_handler_register(bgp_var_peergroup
);
15834 /* Install bgp top node. */
15835 install_node(&bgp_node
);
15836 install_node(&bgp_ipv4_unicast_node
);
15837 install_node(&bgp_ipv4_multicast_node
);
15838 install_node(&bgp_ipv4_labeled_unicast_node
);
15839 install_node(&bgp_ipv6_unicast_node
);
15840 install_node(&bgp_ipv6_multicast_node
);
15841 install_node(&bgp_ipv6_labeled_unicast_node
);
15842 install_node(&bgp_vpnv4_node
);
15843 install_node(&bgp_vpnv6_node
);
15844 install_node(&bgp_evpn_node
);
15845 install_node(&bgp_evpn_vni_node
);
15846 install_node(&bgp_flowspecv4_node
);
15847 install_node(&bgp_flowspecv6_node
);
15849 /* Install default VTY commands to new nodes. */
15850 install_default(BGP_NODE
);
15851 install_default(BGP_IPV4_NODE
);
15852 install_default(BGP_IPV4M_NODE
);
15853 install_default(BGP_IPV4L_NODE
);
15854 install_default(BGP_IPV6_NODE
);
15855 install_default(BGP_IPV6M_NODE
);
15856 install_default(BGP_IPV6L_NODE
);
15857 install_default(BGP_VPNV4_NODE
);
15858 install_default(BGP_VPNV6_NODE
);
15859 install_default(BGP_FLOWSPECV4_NODE
);
15860 install_default(BGP_FLOWSPECV6_NODE
);
15861 install_default(BGP_EVPN_NODE
);
15862 install_default(BGP_EVPN_VNI_NODE
);
15864 /* "bgp local-mac" hidden commands. */
15865 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
15866 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
15868 /* bgp route-map delay-timer commands. */
15869 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
15870 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
15872 /* Dummy commands (Currently not supported) */
15873 install_element(BGP_NODE
, &no_synchronization_cmd
);
15874 install_element(BGP_NODE
, &no_auto_summary_cmd
);
15876 /* "router bgp" commands. */
15877 install_element(CONFIG_NODE
, &router_bgp_cmd
);
15879 /* "no router bgp" commands. */
15880 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
15882 /* "bgp router-id" commands. */
15883 install_element(BGP_NODE
, &bgp_router_id_cmd
);
15884 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
15886 /* "bgp cluster-id" commands. */
15887 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
15888 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
15890 /* "bgp confederation" commands. */
15891 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
15892 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
15894 /* "bgp confederation peers" commands. */
15895 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
15896 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
15898 /* bgp max-med command */
15899 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
15900 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
15901 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
15902 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
15903 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
15905 /* bgp disable-ebgp-connected-nh-check */
15906 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
15907 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
15909 /* bgp update-delay command */
15910 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
15911 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
15912 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
15914 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
15915 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
15917 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
15918 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
15920 /* "maximum-paths" commands. */
15921 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
15922 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
15923 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
15924 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
15925 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
15926 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
15927 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
15928 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
15929 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
15930 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
15931 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
15932 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
15933 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
15934 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
15935 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
15937 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_cmd
);
15938 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_cmd
);
15939 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cmd
);
15940 install_element(BGP_IPV4L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
15941 install_element(BGP_IPV4L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
15942 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
15943 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
15944 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
15945 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
15946 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
15948 /* "timers bgp" commands. */
15949 install_element(BGP_NODE
, &bgp_timers_cmd
);
15950 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
15952 /* route-map delay-timer commands - per instance for backwards compat.
15954 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
15955 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
15957 /* "bgp client-to-client reflection" commands */
15958 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
15959 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
15961 /* "bgp always-compare-med" commands */
15962 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
15963 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
15965 /* bgp ebgp-requires-policy */
15966 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
15967 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
15969 /* bgp reject-as-sets */
15970 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
15971 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
15973 /* "bgp deterministic-med" commands */
15974 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
15975 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
15977 /* "bgp graceful-restart" command */
15978 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
15979 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
15981 /* "bgp graceful-restart-disable" command */
15982 install_element(BGP_NODE
, &bgp_graceful_restart_disable_cmd
);
15983 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_cmd
);
15985 /* "neighbor a:b:c:d graceful-restart" command */
15986 install_element(BGP_NODE
, &bgp_neighbor_graceful_restart_set_cmd
);
15987 install_element(BGP_NODE
, &no_bgp_neighbor_graceful_restart_set_cmd
);
15989 /* "neighbor a:b:c:d graceful-restart-disable" command */
15990 install_element(BGP_NODE
,
15991 &bgp_neighbor_graceful_restart_disable_set_cmd
);
15992 install_element(BGP_NODE
,
15993 &no_bgp_neighbor_graceful_restart_disable_set_cmd
);
15995 /* "neighbor a:b:c:d graceful-restart-helper" command */
15996 install_element(BGP_NODE
,
15997 &bgp_neighbor_graceful_restart_helper_set_cmd
);
15998 install_element(BGP_NODE
,
15999 &no_bgp_neighbor_graceful_restart_helper_set_cmd
);
16001 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
16002 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
16003 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
16004 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
16005 install_element(BGP_NODE
, &bgp_graceful_restart_select_defer_time_cmd
);
16006 install_element(BGP_NODE
,
16007 &no_bgp_graceful_restart_select_defer_time_cmd
);
16008 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
16009 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
16011 install_element(BGP_NODE
, &bgp_graceful_restart_disable_eor_cmd
);
16012 install_element(BGP_NODE
, &no_bgp_graceful_restart_disable_eor_cmd
);
16013 install_element(BGP_NODE
, &bgp_graceful_restart_rib_stale_time_cmd
);
16014 install_element(BGP_NODE
, &no_bgp_graceful_restart_rib_stale_time_cmd
);
16016 /* "bgp graceful-shutdown" commands */
16017 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
16018 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
16020 /* "bgp fast-external-failover" commands */
16021 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
16022 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
16024 /* "bgp bestpath compare-routerid" commands */
16025 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
16026 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
16028 /* "bgp bestpath as-path ignore" commands */
16029 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
16030 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
16032 /* "bgp bestpath as-path confed" commands */
16033 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
16034 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
16036 /* "bgp bestpath as-path multipath-relax" commands */
16037 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
16038 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
16040 /* "bgp log-neighbor-changes" commands */
16041 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
16042 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
16044 /* "bgp bestpath med" commands */
16045 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
16046 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
16048 /* "bgp bestpath bandwidth" commands */
16049 install_element(BGP_NODE
, &bgp_bestpath_bw_cmd
);
16050 install_element(BGP_NODE
, &no_bgp_bestpath_bw_cmd
);
16052 /* "no bgp default ipv4-unicast" commands. */
16053 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
16054 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
16056 /* "bgp network import-check" commands. */
16057 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
16058 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
16059 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
16061 /* "bgp default local-preference" commands. */
16062 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
16063 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
16065 /* bgp default show-hostname */
16066 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
16067 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
16069 /* bgp default show-nexthop-hostname */
16070 install_element(BGP_NODE
, &bgp_default_show_nexthop_hostname_cmd
);
16071 install_element(BGP_NODE
, &no_bgp_default_show_nexthop_hostname_cmd
);
16073 /* "bgp default subgroup-pkt-queue-max" commands. */
16074 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
16075 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
16077 /* bgp ibgp-allow-policy-mods command */
16078 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
16079 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
16081 /* "bgp listen limit" commands. */
16082 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
16083 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
16085 /* "bgp listen range" commands. */
16086 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
16087 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
16089 /* "bgp default shutdown" command */
16090 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
16092 /* "bgp shutdown" commands */
16093 install_element(BGP_NODE
, &bgp_shutdown_cmd
);
16094 install_element(BGP_NODE
, &bgp_shutdown_msg_cmd
);
16095 install_element(BGP_NODE
, &no_bgp_shutdown_cmd
);
16096 install_element(BGP_NODE
, &no_bgp_shutdown_msg_cmd
);
16098 /* "neighbor remote-as" commands. */
16099 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
16100 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
16101 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
16102 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
16103 install_element(BGP_NODE
,
16104 &neighbor_interface_v6only_config_remote_as_cmd
);
16105 install_element(BGP_NODE
, &no_neighbor_cmd
);
16106 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
16108 /* "neighbor peer-group" commands. */
16109 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
16110 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
16111 install_element(BGP_NODE
,
16112 &no_neighbor_interface_peer_group_remote_as_cmd
);
16114 /* "neighbor local-as" commands. */
16115 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
16116 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
16117 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
16118 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
16120 /* "neighbor solo" commands. */
16121 install_element(BGP_NODE
, &neighbor_solo_cmd
);
16122 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
16124 /* "neighbor password" commands. */
16125 install_element(BGP_NODE
, &neighbor_password_cmd
);
16126 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
16128 /* "neighbor activate" commands. */
16129 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
16130 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
16131 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
16132 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
16133 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
16134 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
16135 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
16136 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
16137 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
16138 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
16139 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
16140 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
16142 /* "no neighbor activate" commands. */
16143 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
16144 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
16145 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
16146 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
16147 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
16148 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
16149 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
16150 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
16151 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
16152 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
16153 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
16154 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
16156 /* "neighbor peer-group" set commands. */
16157 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
16158 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
16159 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
16160 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
16161 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
16162 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
16163 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
16164 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
16165 install_element(BGP_FLOWSPECV4_NODE
,
16166 &neighbor_set_peer_group_hidden_cmd
);
16167 install_element(BGP_FLOWSPECV6_NODE
,
16168 &neighbor_set_peer_group_hidden_cmd
);
16170 /* "no neighbor peer-group unset" commands. */
16171 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
16172 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
16173 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
16174 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
16175 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
16176 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
16177 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
16178 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
16179 install_element(BGP_FLOWSPECV4_NODE
,
16180 &no_neighbor_set_peer_group_hidden_cmd
);
16181 install_element(BGP_FLOWSPECV6_NODE
,
16182 &no_neighbor_set_peer_group_hidden_cmd
);
16184 /* "neighbor softreconfiguration inbound" commands.*/
16185 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
16186 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
16187 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
16188 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
16189 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
16190 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
16191 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
16192 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
16193 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
16194 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
16195 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
16196 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
16197 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
16198 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
16199 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
16200 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
16201 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
16202 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
16203 install_element(BGP_FLOWSPECV4_NODE
,
16204 &neighbor_soft_reconfiguration_cmd
);
16205 install_element(BGP_FLOWSPECV4_NODE
,
16206 &no_neighbor_soft_reconfiguration_cmd
);
16207 install_element(BGP_FLOWSPECV6_NODE
,
16208 &neighbor_soft_reconfiguration_cmd
);
16209 install_element(BGP_FLOWSPECV6_NODE
,
16210 &no_neighbor_soft_reconfiguration_cmd
);
16211 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
16212 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
16214 /* "neighbor attribute-unchanged" commands. */
16215 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
16216 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
16217 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
16218 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
16219 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
16220 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
16221 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
16222 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
16223 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
16224 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
16225 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
16226 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
16227 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
16228 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
16229 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
16230 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
16231 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
16232 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
16234 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
16235 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
16237 /* "nexthop-local unchanged" commands */
16238 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
16239 install_element(BGP_IPV6_NODE
,
16240 &no_neighbor_nexthop_local_unchanged_cmd
);
16242 /* "neighbor next-hop-self" commands. */
16243 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
16244 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
16245 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
16246 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
16247 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
16248 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
16249 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
16250 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
16251 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
16252 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
16253 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
16254 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
16255 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
16256 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
16257 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
16258 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
16259 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
16260 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
16261 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
16262 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
16264 /* "neighbor next-hop-self force" commands. */
16265 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
16266 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
16267 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
16268 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
16269 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
16270 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
16271 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
16272 install_element(BGP_IPV4_NODE
,
16273 &no_neighbor_nexthop_self_all_hidden_cmd
);
16274 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
16275 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
16276 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
16277 install_element(BGP_IPV4M_NODE
,
16278 &no_neighbor_nexthop_self_all_hidden_cmd
);
16279 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
16280 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
16281 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
16282 install_element(BGP_IPV4L_NODE
,
16283 &no_neighbor_nexthop_self_all_hidden_cmd
);
16284 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
16285 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
16286 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
16287 install_element(BGP_IPV6_NODE
,
16288 &no_neighbor_nexthop_self_all_hidden_cmd
);
16289 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
16290 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
16291 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
16292 install_element(BGP_IPV6M_NODE
,
16293 &no_neighbor_nexthop_self_all_hidden_cmd
);
16294 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
16295 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
16296 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
16297 install_element(BGP_IPV6L_NODE
,
16298 &no_neighbor_nexthop_self_all_hidden_cmd
);
16299 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
16300 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
16301 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
16302 install_element(BGP_VPNV4_NODE
,
16303 &no_neighbor_nexthop_self_all_hidden_cmd
);
16304 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
16305 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
16306 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
16307 install_element(BGP_VPNV6_NODE
,
16308 &no_neighbor_nexthop_self_all_hidden_cmd
);
16309 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_force_cmd
);
16310 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_force_cmd
);
16312 /* "neighbor as-override" commands. */
16313 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
16314 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
16315 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
16316 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
16317 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
16318 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
16319 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
16320 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
16321 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
16322 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
16323 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
16324 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
16325 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
16326 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
16327 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
16328 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
16329 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
16330 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
16332 /* "neighbor remove-private-AS" commands. */
16333 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
16334 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
16335 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
16336 install_element(BGP_NODE
,
16337 &no_neighbor_remove_private_as_all_hidden_cmd
);
16338 install_element(BGP_NODE
,
16339 &neighbor_remove_private_as_replace_as_hidden_cmd
);
16340 install_element(BGP_NODE
,
16341 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
16342 install_element(BGP_NODE
,
16343 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
16346 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
16347 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
16348 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
16349 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
16350 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
16351 install_element(BGP_IPV4_NODE
,
16352 &neighbor_remove_private_as_replace_as_cmd
);
16353 install_element(BGP_IPV4_NODE
,
16354 &no_neighbor_remove_private_as_replace_as_cmd
);
16355 install_element(BGP_IPV4_NODE
,
16356 &neighbor_remove_private_as_all_replace_as_cmd
);
16357 install_element(BGP_IPV4_NODE
,
16358 &no_neighbor_remove_private_as_all_replace_as_cmd
);
16359 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
16360 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
16361 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
16362 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
16363 install_element(BGP_IPV4M_NODE
,
16364 &neighbor_remove_private_as_replace_as_cmd
);
16365 install_element(BGP_IPV4M_NODE
,
16366 &no_neighbor_remove_private_as_replace_as_cmd
);
16367 install_element(BGP_IPV4M_NODE
,
16368 &neighbor_remove_private_as_all_replace_as_cmd
);
16369 install_element(BGP_IPV4M_NODE
,
16370 &no_neighbor_remove_private_as_all_replace_as_cmd
);
16371 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
16372 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
16373 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
16374 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
16375 install_element(BGP_IPV4L_NODE
,
16376 &neighbor_remove_private_as_replace_as_cmd
);
16377 install_element(BGP_IPV4L_NODE
,
16378 &no_neighbor_remove_private_as_replace_as_cmd
);
16379 install_element(BGP_IPV4L_NODE
,
16380 &neighbor_remove_private_as_all_replace_as_cmd
);
16381 install_element(BGP_IPV4L_NODE
,
16382 &no_neighbor_remove_private_as_all_replace_as_cmd
);
16383 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
16384 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
16385 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
16386 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
16387 install_element(BGP_IPV6_NODE
,
16388 &neighbor_remove_private_as_replace_as_cmd
);
16389 install_element(BGP_IPV6_NODE
,
16390 &no_neighbor_remove_private_as_replace_as_cmd
);
16391 install_element(BGP_IPV6_NODE
,
16392 &neighbor_remove_private_as_all_replace_as_cmd
);
16393 install_element(BGP_IPV6_NODE
,
16394 &no_neighbor_remove_private_as_all_replace_as_cmd
);
16395 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
16396 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
16397 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
16398 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
16399 install_element(BGP_IPV6M_NODE
,
16400 &neighbor_remove_private_as_replace_as_cmd
);
16401 install_element(BGP_IPV6M_NODE
,
16402 &no_neighbor_remove_private_as_replace_as_cmd
);
16403 install_element(BGP_IPV6M_NODE
,
16404 &neighbor_remove_private_as_all_replace_as_cmd
);
16405 install_element(BGP_IPV6M_NODE
,
16406 &no_neighbor_remove_private_as_all_replace_as_cmd
);
16407 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
16408 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
16409 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
16410 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
16411 install_element(BGP_IPV6L_NODE
,
16412 &neighbor_remove_private_as_replace_as_cmd
);
16413 install_element(BGP_IPV6L_NODE
,
16414 &no_neighbor_remove_private_as_replace_as_cmd
);
16415 install_element(BGP_IPV6L_NODE
,
16416 &neighbor_remove_private_as_all_replace_as_cmd
);
16417 install_element(BGP_IPV6L_NODE
,
16418 &no_neighbor_remove_private_as_all_replace_as_cmd
);
16419 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
16420 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
16421 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
16422 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
16423 install_element(BGP_VPNV4_NODE
,
16424 &neighbor_remove_private_as_replace_as_cmd
);
16425 install_element(BGP_VPNV4_NODE
,
16426 &no_neighbor_remove_private_as_replace_as_cmd
);
16427 install_element(BGP_VPNV4_NODE
,
16428 &neighbor_remove_private_as_all_replace_as_cmd
);
16429 install_element(BGP_VPNV4_NODE
,
16430 &no_neighbor_remove_private_as_all_replace_as_cmd
);
16431 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
16432 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
16433 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
16434 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
16435 install_element(BGP_VPNV6_NODE
,
16436 &neighbor_remove_private_as_replace_as_cmd
);
16437 install_element(BGP_VPNV6_NODE
,
16438 &no_neighbor_remove_private_as_replace_as_cmd
);
16439 install_element(BGP_VPNV6_NODE
,
16440 &neighbor_remove_private_as_all_replace_as_cmd
);
16441 install_element(BGP_VPNV6_NODE
,
16442 &no_neighbor_remove_private_as_all_replace_as_cmd
);
16444 /* "neighbor send-community" commands.*/
16445 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
16446 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
16447 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
16448 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
16449 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
16450 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
16451 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
16452 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
16453 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
16454 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
16455 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
16456 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
16457 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
16458 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
16459 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
16460 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
16461 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
16462 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
16463 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
16464 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
16465 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
16466 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
16467 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
16468 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
16469 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
16470 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
16471 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
16472 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
16473 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
16474 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
16475 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
16476 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
16477 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
16478 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
16479 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
16480 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
16482 /* "neighbor route-reflector" commands.*/
16483 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
16484 install_element(BGP_NODE
,
16485 &no_neighbor_route_reflector_client_hidden_cmd
);
16486 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
16487 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
16488 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
16489 install_element(BGP_IPV4M_NODE
,
16490 &no_neighbor_route_reflector_client_cmd
);
16491 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
16492 install_element(BGP_IPV4L_NODE
,
16493 &no_neighbor_route_reflector_client_cmd
);
16494 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
16495 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
16496 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
16497 install_element(BGP_IPV6M_NODE
,
16498 &no_neighbor_route_reflector_client_cmd
);
16499 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
16500 install_element(BGP_IPV6L_NODE
,
16501 &no_neighbor_route_reflector_client_cmd
);
16502 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
16503 install_element(BGP_VPNV4_NODE
,
16504 &no_neighbor_route_reflector_client_cmd
);
16505 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
16506 install_element(BGP_VPNV6_NODE
,
16507 &no_neighbor_route_reflector_client_cmd
);
16508 install_element(BGP_FLOWSPECV4_NODE
,
16509 &neighbor_route_reflector_client_cmd
);
16510 install_element(BGP_FLOWSPECV4_NODE
,
16511 &no_neighbor_route_reflector_client_cmd
);
16512 install_element(BGP_FLOWSPECV6_NODE
,
16513 &neighbor_route_reflector_client_cmd
);
16514 install_element(BGP_FLOWSPECV6_NODE
,
16515 &no_neighbor_route_reflector_client_cmd
);
16516 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
16517 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
16519 /* "neighbor route-server" commands.*/
16520 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
16521 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
16522 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
16523 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
16524 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
16525 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
16526 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
16527 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
16528 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
16529 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
16530 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
16531 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
16532 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
16533 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
16534 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
16535 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
16536 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
16537 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
16538 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
16539 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
16540 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
16541 install_element(BGP_FLOWSPECV4_NODE
,
16542 &no_neighbor_route_server_client_cmd
);
16543 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
16544 install_element(BGP_FLOWSPECV6_NODE
,
16545 &no_neighbor_route_server_client_cmd
);
16547 /* "neighbor addpath-tx-all-paths" commands.*/
16548 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
16549 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
16550 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16551 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16552 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16553 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16554 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16555 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16556 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16557 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16558 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16559 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16560 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16561 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16562 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16563 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16564 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
16565 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
16567 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
16568 install_element(BGP_NODE
,
16569 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
16570 install_element(BGP_NODE
,
16571 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
16572 install_element(BGP_IPV4_NODE
,
16573 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16574 install_element(BGP_IPV4_NODE
,
16575 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16576 install_element(BGP_IPV4M_NODE
,
16577 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16578 install_element(BGP_IPV4M_NODE
,
16579 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16580 install_element(BGP_IPV4L_NODE
,
16581 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16582 install_element(BGP_IPV4L_NODE
,
16583 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16584 install_element(BGP_IPV6_NODE
,
16585 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16586 install_element(BGP_IPV6_NODE
,
16587 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16588 install_element(BGP_IPV6M_NODE
,
16589 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16590 install_element(BGP_IPV6M_NODE
,
16591 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16592 install_element(BGP_IPV6L_NODE
,
16593 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16594 install_element(BGP_IPV6L_NODE
,
16595 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16596 install_element(BGP_VPNV4_NODE
,
16597 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16598 install_element(BGP_VPNV4_NODE
,
16599 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16600 install_element(BGP_VPNV6_NODE
,
16601 &neighbor_addpath_tx_bestpath_per_as_cmd
);
16602 install_element(BGP_VPNV6_NODE
,
16603 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
16605 /* "neighbor sender-as-path-loop-detection" commands. */
16606 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
16607 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
16609 /* "neighbor passive" commands. */
16610 install_element(BGP_NODE
, &neighbor_passive_cmd
);
16611 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
16614 /* "neighbor shutdown" commands. */
16615 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
16616 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
16617 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
16618 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
16620 /* "neighbor capability extended-nexthop" commands.*/
16621 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
16622 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
16624 /* "neighbor capability orf prefix-list" commands.*/
16625 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
16626 install_element(BGP_NODE
,
16627 &no_neighbor_capability_orf_prefix_hidden_cmd
);
16628 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
16629 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
16630 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
16631 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
16632 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
16633 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
16634 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
16635 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
16636 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
16637 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
16638 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
16639 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
16641 /* "neighbor capability dynamic" commands.*/
16642 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
16643 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
16645 /* "neighbor dont-capability-negotiate" commands. */
16646 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
16647 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
16649 /* "neighbor ebgp-multihop" commands. */
16650 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
16651 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
16652 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
16654 /* "neighbor disable-connected-check" commands. */
16655 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
16656 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
16658 /* "neighbor enforce-first-as" commands. */
16659 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
16660 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
16662 /* "neighbor description" commands. */
16663 install_element(BGP_NODE
, &neighbor_description_cmd
);
16664 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
16665 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
16667 /* "neighbor update-source" commands. "*/
16668 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
16669 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
16671 /* "neighbor default-originate" commands. */
16672 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
16673 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
16674 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
16675 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
16676 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
16677 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
16678 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
16679 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
16680 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
16681 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
16682 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
16683 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
16684 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
16685 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
16686 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
16687 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
16688 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
16689 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
16690 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
16691 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
16692 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
16694 /* "neighbor port" commands. */
16695 install_element(BGP_NODE
, &neighbor_port_cmd
);
16696 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
16698 /* "neighbor weight" commands. */
16699 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
16700 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
16702 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
16703 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
16704 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
16705 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
16706 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
16707 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
16708 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
16709 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
16710 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
16711 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
16712 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
16713 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
16714 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
16715 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
16716 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
16717 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
16719 /* "neighbor override-capability" commands. */
16720 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
16721 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
16723 /* "neighbor strict-capability-match" commands. */
16724 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
16725 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
16727 /* "neighbor timers" commands. */
16728 install_element(BGP_NODE
, &neighbor_timers_cmd
);
16729 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
16731 /* "neighbor timers connect" commands. */
16732 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
16733 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
16735 /* "neighbor advertisement-interval" commands. */
16736 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
16737 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
16739 /* "neighbor interface" commands. */
16740 install_element(BGP_NODE
, &neighbor_interface_cmd
);
16741 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
16743 /* "neighbor distribute" commands. */
16744 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
16745 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
16746 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
16747 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
16748 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
16749 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
16750 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
16751 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
16752 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
16753 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
16754 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
16755 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
16756 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
16757 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
16758 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
16759 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
16760 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
16761 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
16763 /* "neighbor prefix-list" commands. */
16764 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
16765 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
16766 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
16767 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
16768 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
16769 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
16770 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
16771 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
16772 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
16773 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
16774 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
16775 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
16776 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
16777 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
16778 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
16779 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
16780 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
16781 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
16782 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
16783 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
16784 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
16785 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
16787 /* "neighbor filter-list" commands. */
16788 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
16789 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
16790 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
16791 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
16792 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
16793 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
16794 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
16795 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
16796 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
16797 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
16798 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
16799 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
16800 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
16801 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
16802 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
16803 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
16804 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
16805 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
16806 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
16807 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
16808 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
16809 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
16811 /* "neighbor route-map" commands. */
16812 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
16813 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
16814 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
16815 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
16816 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
16817 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
16818 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
16819 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
16820 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
16821 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
16822 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
16823 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
16824 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
16825 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
16826 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
16827 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
16828 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
16829 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
16830 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
16831 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
16832 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
16833 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
16834 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
16835 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
16837 /* "neighbor unsuppress-map" commands. */
16838 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
16839 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
16840 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
16841 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
16842 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
16843 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
16844 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
16845 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
16846 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
16847 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
16848 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
16849 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
16850 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
16851 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
16852 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
16853 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
16854 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
16855 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
16857 /* neighbor maximum-prefix-out commands. */
16858 install_element(BGP_NODE
, &neighbor_maximum_prefix_out_cmd
);
16859 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16860 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
16861 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16862 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_out_cmd
);
16863 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16864 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_out_cmd
);
16865 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16866 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
16867 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16868 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_out_cmd
);
16869 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16870 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_out_cmd
);
16871 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16872 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_out_cmd
);
16873 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16874 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_out_cmd
);
16875 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_out_cmd
);
16877 /* "neighbor maximum-prefix" commands. */
16878 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
16879 install_element(BGP_NODE
,
16880 &neighbor_maximum_prefix_threshold_hidden_cmd
);
16881 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
16882 install_element(BGP_NODE
,
16883 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
16884 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
16885 install_element(BGP_NODE
,
16886 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
16887 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
16888 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
16889 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16890 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16891 install_element(BGP_IPV4_NODE
,
16892 &neighbor_maximum_prefix_threshold_warning_cmd
);
16893 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16894 install_element(BGP_IPV4_NODE
,
16895 &neighbor_maximum_prefix_threshold_restart_cmd
);
16896 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
16897 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
16898 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16899 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16900 install_element(BGP_IPV4M_NODE
,
16901 &neighbor_maximum_prefix_threshold_warning_cmd
);
16902 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16903 install_element(BGP_IPV4M_NODE
,
16904 &neighbor_maximum_prefix_threshold_restart_cmd
);
16905 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
16906 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
16907 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16908 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16909 install_element(BGP_IPV4L_NODE
,
16910 &neighbor_maximum_prefix_threshold_warning_cmd
);
16911 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16912 install_element(BGP_IPV4L_NODE
,
16913 &neighbor_maximum_prefix_threshold_restart_cmd
);
16914 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
16915 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
16916 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16917 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16918 install_element(BGP_IPV6_NODE
,
16919 &neighbor_maximum_prefix_threshold_warning_cmd
);
16920 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16921 install_element(BGP_IPV6_NODE
,
16922 &neighbor_maximum_prefix_threshold_restart_cmd
);
16923 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
16924 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
16925 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16926 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16927 install_element(BGP_IPV6M_NODE
,
16928 &neighbor_maximum_prefix_threshold_warning_cmd
);
16929 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16930 install_element(BGP_IPV6M_NODE
,
16931 &neighbor_maximum_prefix_threshold_restart_cmd
);
16932 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
16933 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
16934 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16935 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16936 install_element(BGP_IPV6L_NODE
,
16937 &neighbor_maximum_prefix_threshold_warning_cmd
);
16938 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16939 install_element(BGP_IPV6L_NODE
,
16940 &neighbor_maximum_prefix_threshold_restart_cmd
);
16941 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
16942 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
16943 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16944 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16945 install_element(BGP_VPNV4_NODE
,
16946 &neighbor_maximum_prefix_threshold_warning_cmd
);
16947 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16948 install_element(BGP_VPNV4_NODE
,
16949 &neighbor_maximum_prefix_threshold_restart_cmd
);
16950 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
16951 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
16952 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
16953 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
16954 install_element(BGP_VPNV6_NODE
,
16955 &neighbor_maximum_prefix_threshold_warning_cmd
);
16956 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
16957 install_element(BGP_VPNV6_NODE
,
16958 &neighbor_maximum_prefix_threshold_restart_cmd
);
16959 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
16961 /* "neighbor allowas-in" */
16962 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
16963 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
16964 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
16965 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
16966 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
16967 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
16968 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
16969 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
16970 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
16971 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
16972 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
16973 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
16974 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
16975 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
16976 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
16977 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
16978 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
16979 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
16980 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
16981 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
16983 /* address-family commands. */
16984 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
16985 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
16986 #ifdef KEEP_OLD_VPN_COMMANDS
16987 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
16988 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
16989 #endif /* KEEP_OLD_VPN_COMMANDS */
16991 install_element(BGP_NODE
, &address_family_evpn_cmd
);
16993 /* "exit-address-family" command. */
16994 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
16995 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
16996 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
16997 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
16998 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
16999 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
17000 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
17001 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
17002 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
17003 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
17004 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
17006 /* "clear ip bgp commands" */
17007 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
17009 /* clear ip bgp prefix */
17010 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
17011 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
17012 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
17014 /* "show [ip] bgp summary" commands. */
17015 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
17016 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
17017 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
17018 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
17019 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
17020 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
17021 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
17023 /* "show [ip] bgp neighbors" commands. */
17024 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
17026 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_graceful_restart_cmd
);
17028 /* "show [ip] bgp peer-group" commands. */
17029 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
17031 /* "show [ip] bgp paths" commands. */
17032 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
17034 /* "show [ip] bgp community" commands. */
17035 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
17037 /* "show ip bgp large-community" commands. */
17038 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
17039 /* "show [ip] bgp attribute-info" commands. */
17040 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
17041 /* "show [ip] bgp route-leak" command */
17042 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
17044 /* "redistribute" commands. */
17045 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
17046 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
17047 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
17048 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
17049 install_element(BGP_NODE
,
17050 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
17051 install_element(BGP_NODE
,
17052 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
17053 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
17054 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
17055 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
17056 install_element(BGP_NODE
,
17057 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
17058 install_element(BGP_NODE
,
17059 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
17060 install_element(BGP_NODE
,
17061 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
17062 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
17063 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
17064 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
17065 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
17066 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
17067 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
17068 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
17069 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
17070 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
17071 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
17072 install_element(BGP_IPV4_NODE
,
17073 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
17074 install_element(BGP_IPV4_NODE
,
17075 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
17076 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
17077 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
17078 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
17079 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
17080 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
17081 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
17083 /* import|export vpn [route-map WORD] */
17084 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
17085 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
17087 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
17088 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
17090 /* ttl_security commands */
17091 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
17092 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
17094 /* "show [ip] bgp memory" commands. */
17095 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
17097 /* "show bgp martian next-hop" */
17098 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
17100 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
17102 /* "show [ip] bgp views" commands. */
17103 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
17105 /* "show [ip] bgp vrfs" commands. */
17106 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
17108 /* Community-list. */
17109 community_list_vty();
17111 /* vpn-policy commands */
17112 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
17113 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
17114 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
17115 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
17116 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
17117 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
17118 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
17119 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
17120 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
17121 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
17122 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
17123 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
17125 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
17126 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
17128 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
17129 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
17130 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
17131 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
17132 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
17133 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
17134 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
17135 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
17136 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
17137 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
17140 #include "memory.h"
17141 #include "bgp_regex.h"
17142 #include "bgp_clist.h"
17143 #include "bgp_ecommunity.h"
17145 /* VTY functions. */
17147 /* Direction value to string conversion. */
17148 static const char *community_direct_str(int direct
)
17151 case COMMUNITY_DENY
:
17153 case COMMUNITY_PERMIT
:
17160 /* Display error string. */
17161 static void community_list_perror(struct vty
*vty
, int ret
)
17164 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
17165 vty_out(vty
, "%% Can't find community-list\n");
17167 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
17168 vty_out(vty
, "%% Malformed community-list value\n");
17170 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
17172 "%% Community name conflict, previously defined as standard community\n");
17174 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
17176 "%% Community name conflict, previously defined as expanded community\n");
17181 /* "community-list" keyword help string. */
17182 #define COMMUNITY_LIST_STR "Add a community list entry\n"
17184 /*community-list standard */
17185 DEFUN (community_list_standard
,
17186 bgp_community_list_standard_cmd
,
17187 "bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
17190 "Community list number (standard)\n"
17191 "Add an standard community-list entry\n"
17192 "Community list name\n"
17193 "Sequence number of an entry\n"
17194 "Sequence number\n"
17195 "Specify community to reject\n"
17196 "Specify community to accept\n"
17199 char *cl_name_or_number
= NULL
;
17202 int style
= COMMUNITY_LIST_STANDARD
;
17205 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
17207 seq
= argv
[idx
]->arg
;
17210 argv_find(argv
, argc
, "(1-99)", &idx
);
17211 argv_find(argv
, argc
, "WORD", &idx
);
17212 cl_name_or_number
= argv
[idx
]->arg
;
17213 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
17215 argv_find(argv
, argc
, "AA:NN", &idx
);
17216 char *str
= argv_concat(argv
, argc
, idx
);
17218 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
17221 XFREE(MTYPE_TMP
, str
);
17224 /* Display error string. */
17225 community_list_perror(vty
, ret
);
17226 return CMD_WARNING_CONFIG_FAILED
;
17229 return CMD_SUCCESS
;
17232 DEFUN (no_community_list_standard_all
,
17233 no_bgp_community_list_standard_all_cmd
,
17234 "no bgp community-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
17238 "Community list number (standard)\n"
17239 "Add an standard community-list entry\n"
17240 "Community list name\n"
17241 "Sequence number of an entry\n"
17242 "Sequence number\n"
17243 "Specify community to reject\n"
17244 "Specify community to accept\n"
17247 char *cl_name_or_number
= NULL
;
17250 int style
= COMMUNITY_LIST_STANDARD
;
17254 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
17256 seq
= argv
[idx
]->arg
;
17259 argv_find(argv
, argc
, "permit", &idx
);
17260 argv_find(argv
, argc
, "deny", &idx
);
17263 direct
= argv_find(argv
, argc
, "permit", &idx
)
17268 argv_find(argv
, argc
, "AA:NN", &idx
);
17269 str
= argv_concat(argv
, argc
, idx
);
17273 argv_find(argv
, argc
, "(1-99)", &idx
);
17274 argv_find(argv
, argc
, "WORD", &idx
);
17275 cl_name_or_number
= argv
[idx
]->arg
;
17277 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
17280 XFREE(MTYPE_TMP
, str
);
17283 community_list_perror(vty
, ret
);
17284 return CMD_WARNING_CONFIG_FAILED
;
17287 return CMD_SUCCESS
;
17290 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
17291 "no bgp community-list <(1-99)|standard WORD>",
17292 NO_STR BGP_STR COMMUNITY_LIST_STR
17293 "Community list number (standard)\n"
17294 "Add an standard community-list entry\n"
17295 "Community list name\n")
17297 /*community-list expanded */
17298 DEFUN (community_list_expanded_all
,
17299 bgp_community_list_expanded_all_cmd
,
17300 "bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
17303 "Community list number (expanded)\n"
17304 "Add an expanded community-list entry\n"
17305 "Community list name\n"
17306 "Sequence number of an entry\n"
17307 "Sequence number\n"
17308 "Specify community to reject\n"
17309 "Specify community to accept\n"
17312 char *cl_name_or_number
= NULL
;
17315 int style
= COMMUNITY_LIST_EXPANDED
;
17318 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
17320 seq
= argv
[idx
]->arg
;
17324 argv_find(argv
, argc
, "(100-500)", &idx
);
17325 argv_find(argv
, argc
, "WORD", &idx
);
17326 cl_name_or_number
= argv
[idx
]->arg
;
17327 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
17329 argv_find(argv
, argc
, "AA:NN", &idx
);
17330 char *str
= argv_concat(argv
, argc
, idx
);
17332 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, seq
,
17335 XFREE(MTYPE_TMP
, str
);
17338 /* Display error string. */
17339 community_list_perror(vty
, ret
);
17340 return CMD_WARNING_CONFIG_FAILED
;
17343 return CMD_SUCCESS
;
17346 DEFUN (no_community_list_expanded_all
,
17347 no_bgp_community_list_expanded_all_cmd
,
17348 "no bgp community-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
17352 "Community list number (expanded)\n"
17353 "Add an expanded community-list entry\n"
17354 "Community list name\n"
17355 "Sequence number of an entry\n"
17356 "Sequence number\n"
17357 "Specify community to reject\n"
17358 "Specify community to accept\n"
17361 char *cl_name_or_number
= NULL
;
17365 int style
= COMMUNITY_LIST_EXPANDED
;
17368 argv_find(argv
, argc
, "(1-4294967295)", &idx
);
17370 seq
= argv
[idx
]->arg
;
17373 argv_find(argv
, argc
, "permit", &idx
);
17374 argv_find(argv
, argc
, "deny", &idx
);
17377 direct
= argv_find(argv
, argc
, "permit", &idx
)
17382 argv_find(argv
, argc
, "AA:NN", &idx
);
17383 str
= argv_concat(argv
, argc
, idx
);
17387 argv_find(argv
, argc
, "(100-500)", &idx
);
17388 argv_find(argv
, argc
, "WORD", &idx
);
17389 cl_name_or_number
= argv
[idx
]->arg
;
17391 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
, seq
,
17394 XFREE(MTYPE_TMP
, str
);
17397 community_list_perror(vty
, ret
);
17398 return CMD_WARNING_CONFIG_FAILED
;
17401 return CMD_SUCCESS
;
17404 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
17405 "no bgp community-list <(100-500)|expanded WORD>",
17406 NO_STR IP_STR COMMUNITY_LIST_STR
17407 "Community list number (expanded)\n"
17408 "Add an expanded community-list entry\n"
17409 "Community list name\n")
17411 /* Return configuration string of community-list entry. */
17412 static const char *community_list_config_str(struct community_entry
*entry
)
17419 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
17420 str
= community_str(entry
->u
.com
, false);
17421 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
17422 str
= lcommunity_str(entry
->u
.lcom
, false);
17424 str
= entry
->config
;
17429 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
17431 struct community_entry
*entry
;
17433 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
17434 if (entry
== list
->head
) {
17435 if (all_digit(list
->name
))
17436 vty_out(vty
, "Community %s list %s\n",
17437 entry
->style
== COMMUNITY_LIST_STANDARD
17439 : "(expanded) access",
17442 vty_out(vty
, "Named Community %s list %s\n",
17443 entry
->style
== COMMUNITY_LIST_STANDARD
17449 vty_out(vty
, " %s\n",
17450 community_direct_str(entry
->direct
));
17452 vty_out(vty
, " %s %s\n",
17453 community_direct_str(entry
->direct
),
17454 community_list_config_str(entry
));
17458 DEFUN (show_community_list
,
17459 show_bgp_community_list_cmd
,
17460 "show bgp community-list",
17463 "List community-list\n")
17465 struct community_list
*list
;
17466 struct community_list_master
*cm
;
17468 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
17470 return CMD_SUCCESS
;
17472 for (list
= cm
->num
.head
; list
; list
= list
->next
)
17473 community_list_show(vty
, list
);
17475 for (list
= cm
->str
.head
; list
; list
= list
->next
)
17476 community_list_show(vty
, list
);
17478 return CMD_SUCCESS
;
17481 DEFUN (show_community_list_arg
,
17482 show_bgp_community_list_arg_cmd
,
17483 "show bgp community-list <(1-500)|WORD> detail",
17486 "List community-list\n"
17487 "Community-list number\n"
17488 "Community-list name\n"
17489 "Detailed information on community-list\n")
17491 int idx_comm_list
= 3;
17492 struct community_list
*list
;
17494 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
17495 COMMUNITY_LIST_MASTER
);
17497 vty_out(vty
, "%% Can't find community-list\n");
17498 return CMD_WARNING
;
17501 community_list_show(vty
, list
);
17503 return CMD_SUCCESS
;
17507 * Large Community code.
17509 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
17510 struct cmd_token
**argv
, int style
,
17511 int reject_all_digit_name
)
17520 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
17521 seq
= argv
[idx
]->arg
;
17524 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
17527 /* All digit name check. */
17529 argv_find(argv
, argc
, "WORD", &idx
);
17530 argv_find(argv
, argc
, "(1-99)", &idx
);
17531 argv_find(argv
, argc
, "(100-500)", &idx
);
17532 cl_name
= argv
[idx
]->arg
;
17533 if (reject_all_digit_name
&& all_digit(cl_name
)) {
17534 vty_out(vty
, "%% Community name cannot have all digits\n");
17535 return CMD_WARNING_CONFIG_FAILED
;
17539 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
17540 argv_find(argv
, argc
, "LINE", &idx
);
17541 /* Concat community string argument. */
17543 str
= argv_concat(argv
, argc
, idx
);
17547 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, seq
, direct
, style
);
17549 /* Free temporary community list string allocated by
17551 XFREE(MTYPE_TMP
, str
);
17554 community_list_perror(vty
, ret
);
17555 return CMD_WARNING_CONFIG_FAILED
;
17557 return CMD_SUCCESS
;
17560 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
17561 struct cmd_token
**argv
, int style
)
17569 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
17570 seq
= argv
[idx
]->arg
;
17573 argv_find(argv
, argc
, "permit", &idx
);
17574 argv_find(argv
, argc
, "deny", &idx
);
17577 /* Check the list direct. */
17578 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
17579 direct
= COMMUNITY_PERMIT
;
17581 direct
= COMMUNITY_DENY
;
17584 argv_find(argv
, argc
, "LINE", &idx
);
17585 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
17586 /* Concat community string argument. */
17587 str
= argv_concat(argv
, argc
, idx
);
17591 argv_find(argv
, argc
, "(1-99)", &idx
);
17592 argv_find(argv
, argc
, "(100-500)", &idx
);
17593 argv_find(argv
, argc
, "WORD", &idx
);
17595 /* Unset community list. */
17596 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, seq
, direct
,
17599 /* Free temporary community list string allocated by
17601 XFREE(MTYPE_TMP
, str
);
17604 community_list_perror(vty
, ret
);
17605 return CMD_WARNING_CONFIG_FAILED
;
17608 return CMD_SUCCESS
;
17611 /* "large-community-list" keyword help string. */
17612 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
17613 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
17615 DEFUN (lcommunity_list_standard
,
17616 bgp_lcommunity_list_standard_cmd
,
17617 "bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:BB:CC...",
17619 LCOMMUNITY_LIST_STR
17620 "Large Community list number (standard)\n"
17621 "Sequence number of an entry\n"
17622 "Sequence number\n"
17623 "Specify large community to reject\n"
17624 "Specify large community to accept\n"
17625 LCOMMUNITY_VAL_STR
)
17627 return lcommunity_list_set_vty(vty
, argc
, argv
,
17628 LARGE_COMMUNITY_LIST_STANDARD
, 0);
17631 DEFUN (lcommunity_list_expanded
,
17632 bgp_lcommunity_list_expanded_cmd
,
17633 "bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...",
17635 LCOMMUNITY_LIST_STR
17636 "Large Community list number (expanded)\n"
17637 "Sequence number of an entry\n"
17638 "Sequence number\n"
17639 "Specify large community to reject\n"
17640 "Specify large community to accept\n"
17641 "An ordered list as a regular-expression\n")
17643 return lcommunity_list_set_vty(vty
, argc
, argv
,
17644 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
17647 DEFUN (lcommunity_list_name_standard
,
17648 bgp_lcommunity_list_name_standard_cmd
,
17649 "bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:BB:CC...",
17651 LCOMMUNITY_LIST_STR
17652 "Specify standard large-community-list\n"
17653 "Large Community list name\n"
17654 "Sequence number of an entry\n"
17655 "Sequence number\n"
17656 "Specify large community to reject\n"
17657 "Specify large community to accept\n"
17658 LCOMMUNITY_VAL_STR
)
17660 return lcommunity_list_set_vty(vty
, argc
, argv
,
17661 LARGE_COMMUNITY_LIST_STANDARD
, 1);
17664 DEFUN (lcommunity_list_name_expanded
,
17665 bgp_lcommunity_list_name_expanded_cmd
,
17666 "bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...",
17668 LCOMMUNITY_LIST_STR
17669 "Specify expanded large-community-list\n"
17670 "Large Community list name\n"
17671 "Sequence number of an entry\n"
17672 "Sequence number\n"
17673 "Specify large community to reject\n"
17674 "Specify large community to accept\n"
17675 "An ordered list as a regular-expression\n")
17677 return lcommunity_list_set_vty(vty
, argc
, argv
,
17678 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
17681 DEFUN (no_lcommunity_list_all
,
17682 no_bgp_lcommunity_list_all_cmd
,
17683 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
17686 LCOMMUNITY_LIST_STR
17687 "Large Community list number (standard)\n"
17688 "Large Community list number (expanded)\n"
17689 "Large Community list name\n")
17691 return lcommunity_list_unset_vty(vty
, argc
, argv
,
17692 LARGE_COMMUNITY_LIST_STANDARD
);
17695 DEFUN (no_lcommunity_list_name_standard_all
,
17696 no_bgp_lcommunity_list_name_standard_all_cmd
,
17697 "no bgp large-community-list standard WORD",
17700 LCOMMUNITY_LIST_STR
17701 "Specify standard large-community-list\n"
17702 "Large Community list name\n")
17704 return lcommunity_list_unset_vty(vty
, argc
, argv
,
17705 LARGE_COMMUNITY_LIST_STANDARD
);
17708 DEFUN (no_lcommunity_list_name_expanded_all
,
17709 no_bgp_lcommunity_list_name_expanded_all_cmd
,
17710 "no bgp large-community-list expanded WORD",
17713 LCOMMUNITY_LIST_STR
17714 "Specify expanded large-community-list\n"
17715 "Large Community list name\n")
17717 return lcommunity_list_unset_vty(vty
, argc
, argv
,
17718 LARGE_COMMUNITY_LIST_EXPANDED
);
17721 DEFUN (no_lcommunity_list_standard
,
17722 no_bgp_lcommunity_list_standard_cmd
,
17723 "no bgp large-community-list (1-99) [seq (1-4294967295)] <deny|permit> AA:AA:NN...",
17726 LCOMMUNITY_LIST_STR
17727 "Large Community list number (standard)\n"
17728 "Sequence number of an entry\n"
17729 "Sequence number\n"
17730 "Specify large community to reject\n"
17731 "Specify large community to accept\n"
17732 LCOMMUNITY_VAL_STR
)
17734 return lcommunity_list_unset_vty(vty
, argc
, argv
,
17735 LARGE_COMMUNITY_LIST_STANDARD
);
17738 DEFUN (no_lcommunity_list_expanded
,
17739 no_bgp_lcommunity_list_expanded_cmd
,
17740 "no bgp large-community-list (100-500) [seq (1-4294967295)] <deny|permit> LINE...",
17743 LCOMMUNITY_LIST_STR
17744 "Large Community list number (expanded)\n"
17745 "Sequence number of an entry\n"
17746 "Sequence number\n"
17747 "Specify large community to reject\n"
17748 "Specify large community to accept\n"
17749 "An ordered list as a regular-expression\n")
17751 return lcommunity_list_unset_vty(vty
, argc
, argv
,
17752 LARGE_COMMUNITY_LIST_EXPANDED
);
17755 DEFUN (no_lcommunity_list_name_standard
,
17756 no_bgp_lcommunity_list_name_standard_cmd
,
17757 "no bgp large-community-list standard WORD [seq (1-4294967295)] <deny|permit> AA:AA:NN...",
17760 LCOMMUNITY_LIST_STR
17761 "Specify standard large-community-list\n"
17762 "Large Community list name\n"
17763 "Sequence number of an entry\n"
17764 "Sequence number\n"
17765 "Specify large community to reject\n"
17766 "Specify large community to accept\n"
17767 LCOMMUNITY_VAL_STR
)
17769 return lcommunity_list_unset_vty(vty
, argc
, argv
,
17770 LARGE_COMMUNITY_LIST_STANDARD
);
17773 DEFUN (no_lcommunity_list_name_expanded
,
17774 no_bgp_lcommunity_list_name_expanded_cmd
,
17775 "no bgp large-community-list expanded WORD [seq (1-4294967295)] <deny|permit> LINE...",
17778 LCOMMUNITY_LIST_STR
17779 "Specify expanded large-community-list\n"
17780 "Large community list name\n"
17781 "Sequence number of an entry\n"
17782 "Sequence number\n"
17783 "Specify large community to reject\n"
17784 "Specify large community to accept\n"
17785 "An ordered list as a regular-expression\n")
17787 return lcommunity_list_unset_vty(vty
, argc
, argv
,
17788 LARGE_COMMUNITY_LIST_EXPANDED
);
17791 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
17793 struct community_entry
*entry
;
17795 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
17796 if (entry
== list
->head
) {
17797 if (all_digit(list
->name
))
17798 vty_out(vty
, "Large community %s list %s\n",
17800 LARGE_COMMUNITY_LIST_STANDARD
17802 : "(expanded) access",
17806 "Named large community %s list %s\n",
17808 LARGE_COMMUNITY_LIST_STANDARD
17814 vty_out(vty
, " %s\n",
17815 community_direct_str(entry
->direct
));
17817 vty_out(vty
, " %s %s\n",
17818 community_direct_str(entry
->direct
),
17819 community_list_config_str(entry
));
17823 DEFUN (show_lcommunity_list
,
17824 show_bgp_lcommunity_list_cmd
,
17825 "show bgp large-community-list",
17828 "List large-community list\n")
17830 struct community_list
*list
;
17831 struct community_list_master
*cm
;
17833 cm
= community_list_master_lookup(bgp_clist
,
17834 LARGE_COMMUNITY_LIST_MASTER
);
17836 return CMD_SUCCESS
;
17838 for (list
= cm
->num
.head
; list
; list
= list
->next
)
17839 lcommunity_list_show(vty
, list
);
17841 for (list
= cm
->str
.head
; list
; list
= list
->next
)
17842 lcommunity_list_show(vty
, list
);
17844 return CMD_SUCCESS
;
17847 DEFUN (show_lcommunity_list_arg
,
17848 show_bgp_lcommunity_list_arg_cmd
,
17849 "show bgp large-community-list <(1-500)|WORD> detail",
17852 "List large-community list\n"
17853 "Large-community-list number\n"
17854 "Large-community-list name\n"
17855 "Detailed information on large-community-list\n")
17857 struct community_list
*list
;
17859 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
17860 LARGE_COMMUNITY_LIST_MASTER
);
17862 vty_out(vty
, "%% Can't find large-community-list\n");
17863 return CMD_WARNING
;
17866 lcommunity_list_show(vty
, list
);
17868 return CMD_SUCCESS
;
17871 /* "extcommunity-list" keyword help string. */
17872 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
17873 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
17875 DEFUN (extcommunity_list_standard
,
17876 bgp_extcommunity_list_standard_cmd
,
17877 "bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
17879 EXTCOMMUNITY_LIST_STR
17880 "Extended Community list number (standard)\n"
17881 "Specify standard extcommunity-list\n"
17882 "Community list name\n"
17883 "Sequence number of an entry\n"
17884 "Sequence number\n"
17885 "Specify community to reject\n"
17886 "Specify community to accept\n"
17887 EXTCOMMUNITY_VAL_STR
)
17889 int style
= EXTCOMMUNITY_LIST_STANDARD
;
17891 char *cl_number_or_name
= NULL
;
17896 argv_find(argv
, argc
, "(1-99)", &idx
);
17897 argv_find(argv
, argc
, "WORD", &idx
);
17898 cl_number_or_name
= argv
[idx
]->arg
;
17900 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
17901 seq
= argv
[idx
]->arg
;
17903 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
17905 argv_find(argv
, argc
, "AA:NN", &idx
);
17906 char *str
= argv_concat(argv
, argc
, idx
);
17908 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
17911 XFREE(MTYPE_TMP
, str
);
17914 community_list_perror(vty
, ret
);
17915 return CMD_WARNING_CONFIG_FAILED
;
17918 return CMD_SUCCESS
;
17921 DEFUN (extcommunity_list_name_expanded
,
17922 bgp_extcommunity_list_name_expanded_cmd
,
17923 "bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...",
17925 EXTCOMMUNITY_LIST_STR
17926 "Extended Community list number (expanded)\n"
17927 "Specify expanded extcommunity-list\n"
17928 "Extended Community list name\n"
17929 "Sequence number of an entry\n"
17930 "Sequence number\n"
17931 "Specify community to reject\n"
17932 "Specify community to accept\n"
17933 "An ordered list as a regular-expression\n")
17935 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
17937 char *cl_number_or_name
= NULL
;
17941 argv_find(argv
, argc
, "(100-500)", &idx
);
17942 argv_find(argv
, argc
, "WORD", &idx
);
17943 cl_number_or_name
= argv
[idx
]->arg
;
17945 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
17946 seq
= argv
[idx
]->arg
;
17948 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
17950 argv_find(argv
, argc
, "LINE", &idx
);
17951 char *str
= argv_concat(argv
, argc
, idx
);
17953 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
, seq
,
17956 XFREE(MTYPE_TMP
, str
);
17959 community_list_perror(vty
, ret
);
17960 return CMD_WARNING_CONFIG_FAILED
;
17963 return CMD_SUCCESS
;
17966 DEFUN (no_extcommunity_list_standard_all
,
17967 no_bgp_extcommunity_list_standard_all_cmd
,
17968 "no bgp extcommunity-list <(1-99)|standard WORD> [seq (1-4294967295)] <deny|permit> AA:NN...",
17971 EXTCOMMUNITY_LIST_STR
17972 "Extended Community list number (standard)\n"
17973 "Specify standard extcommunity-list\n"
17974 "Community list name\n"
17975 "Sequence number of an entry\n"
17976 "Sequence number\n"
17977 "Specify community to reject\n"
17978 "Specify community to accept\n"
17979 EXTCOMMUNITY_VAL_STR
)
17981 int style
= EXTCOMMUNITY_LIST_STANDARD
;
17983 char *cl_number_or_name
= NULL
;
17988 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
17989 seq
= argv
[idx
]->arg
;
17992 argv_find(argv
, argc
, "permit", &idx
);
17993 argv_find(argv
, argc
, "deny", &idx
);
17995 direct
= argv_find(argv
, argc
, "permit", &idx
)
18000 argv_find(argv
, argc
, "AA:NN", &idx
);
18001 str
= argv_concat(argv
, argc
, idx
);
18005 argv_find(argv
, argc
, "(1-99)", &idx
);
18006 argv_find(argv
, argc
, "WORD", &idx
);
18007 cl_number_or_name
= argv
[idx
]->arg
;
18009 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
18010 seq
, direct
, style
);
18012 XFREE(MTYPE_TMP
, str
);
18015 community_list_perror(vty
, ret
);
18016 return CMD_WARNING_CONFIG_FAILED
;
18019 return CMD_SUCCESS
;
18022 ALIAS(no_extcommunity_list_standard_all
,
18023 no_bgp_extcommunity_list_standard_all_list_cmd
,
18024 "no bgp extcommunity-list <(1-99)|standard WORD>",
18025 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
18026 "Extended Community list number (standard)\n"
18027 "Specify standard extcommunity-list\n"
18028 "Community list name\n")
18030 DEFUN (no_extcommunity_list_expanded_all
,
18031 no_bgp_extcommunity_list_expanded_all_cmd
,
18032 "no bgp extcommunity-list <(100-500)|expanded WORD> [seq (1-4294967295)] <deny|permit> LINE...",
18035 EXTCOMMUNITY_LIST_STR
18036 "Extended Community list number (expanded)\n"
18037 "Specify expanded extcommunity-list\n"
18038 "Extended Community list name\n"
18039 "Sequence number of an entry\n"
18040 "Sequence number\n"
18041 "Specify community to reject\n"
18042 "Specify community to accept\n"
18043 "An ordered list as a regular-expression\n")
18045 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
18047 char *cl_number_or_name
= NULL
;
18052 if (argv_find(argv
, argc
, "(1-4294967295)", &idx
))
18053 seq
= argv
[idx
]->arg
;
18056 argv_find(argv
, argc
, "permit", &idx
);
18057 argv_find(argv
, argc
, "deny", &idx
);
18060 direct
= argv_find(argv
, argc
, "permit", &idx
)
18065 argv_find(argv
, argc
, "LINE", &idx
);
18066 str
= argv_concat(argv
, argc
, idx
);
18070 argv_find(argv
, argc
, "(100-500)", &idx
);
18071 argv_find(argv
, argc
, "WORD", &idx
);
18072 cl_number_or_name
= argv
[idx
]->arg
;
18074 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
18075 seq
, direct
, style
);
18077 XFREE(MTYPE_TMP
, str
);
18080 community_list_perror(vty
, ret
);
18081 return CMD_WARNING_CONFIG_FAILED
;
18084 return CMD_SUCCESS
;
18087 ALIAS(no_extcommunity_list_expanded_all
,
18088 no_bgp_extcommunity_list_expanded_all_list_cmd
,
18089 "no bgp extcommunity-list <(100-500)|expanded WORD>",
18090 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
18091 "Extended Community list number (expanded)\n"
18092 "Specify expanded extcommunity-list\n"
18093 "Extended Community list name\n")
18095 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
18097 struct community_entry
*entry
;
18099 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
18100 if (entry
== list
->head
) {
18101 if (all_digit(list
->name
))
18102 vty_out(vty
, "Extended community %s list %s\n",
18103 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
18105 : "(expanded) access",
18109 "Named extended community %s list %s\n",
18110 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
18116 vty_out(vty
, " %s\n",
18117 community_direct_str(entry
->direct
));
18119 vty_out(vty
, " %s %s\n",
18120 community_direct_str(entry
->direct
),
18121 community_list_config_str(entry
));
18125 DEFUN (show_extcommunity_list
,
18126 show_bgp_extcommunity_list_cmd
,
18127 "show bgp extcommunity-list",
18130 "List extended-community list\n")
18132 struct community_list
*list
;
18133 struct community_list_master
*cm
;
18135 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
18137 return CMD_SUCCESS
;
18139 for (list
= cm
->num
.head
; list
; list
= list
->next
)
18140 extcommunity_list_show(vty
, list
);
18142 for (list
= cm
->str
.head
; list
; list
= list
->next
)
18143 extcommunity_list_show(vty
, list
);
18145 return CMD_SUCCESS
;
18148 DEFUN (show_extcommunity_list_arg
,
18149 show_bgp_extcommunity_list_arg_cmd
,
18150 "show bgp extcommunity-list <(1-500)|WORD> detail",
18153 "List extended-community list\n"
18154 "Extcommunity-list number\n"
18155 "Extcommunity-list name\n"
18156 "Detailed information on extcommunity-list\n")
18158 int idx_comm_list
= 3;
18159 struct community_list
*list
;
18161 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
18162 EXTCOMMUNITY_LIST_MASTER
);
18164 vty_out(vty
, "%% Can't find extcommunity-list\n");
18165 return CMD_WARNING
;
18168 extcommunity_list_show(vty
, list
);
18170 return CMD_SUCCESS
;
18173 /* Display community-list and extcommunity-list configuration. */
18174 static int community_list_config_write(struct vty
*vty
)
18176 struct community_list
*list
;
18177 struct community_entry
*entry
;
18178 struct community_list_master
*cm
;
18181 /* Community-list. */
18182 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
18184 for (list
= cm
->num
.head
; list
; list
= list
->next
)
18185 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
18187 "bgp community-list %s seq %" PRId64
" %s %s\n",
18188 list
->name
, entry
->seq
,
18189 community_direct_str(entry
->direct
),
18190 community_list_config_str(entry
));
18193 for (list
= cm
->str
.head
; list
; list
= list
->next
)
18194 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
18196 "bgp community-list %s %s seq %" PRId64
" %s %s\n",
18197 entry
->style
== COMMUNITY_LIST_STANDARD
18200 list
->name
, entry
->seq
,
18201 community_direct_str(entry
->direct
),
18202 community_list_config_str(entry
));
18206 /* Extcommunity-list. */
18207 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
18209 for (list
= cm
->num
.head
; list
; list
= list
->next
)
18210 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
18212 "bgp extcommunity-list %s seq %" PRId64
" %s %s\n",
18213 list
->name
, entry
->seq
,
18214 community_direct_str(entry
->direct
),
18215 community_list_config_str(entry
));
18218 for (list
= cm
->str
.head
; list
; list
= list
->next
)
18219 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
18221 "bgp extcommunity-list %s %s seq %" PRId64
" %s %s\n",
18222 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
18225 list
->name
, entry
->seq
,
18226 community_direct_str(entry
->direct
),
18227 community_list_config_str(entry
));
18232 /* lcommunity-list. */
18233 cm
= community_list_master_lookup(bgp_clist
,
18234 LARGE_COMMUNITY_LIST_MASTER
);
18236 for (list
= cm
->num
.head
; list
; list
= list
->next
)
18237 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
18239 "bgp large-community-list %s seq %" PRId64
" %s %s\n",
18240 list
->name
, entry
->seq
,
18241 community_direct_str(entry
->direct
),
18242 community_list_config_str(entry
));
18245 for (list
= cm
->str
.head
; list
; list
= list
->next
)
18246 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
18248 "bgp large-community-list %s %s seq %" PRId64
" %s %s\n",
18250 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
18253 list
->name
, entry
->seq
, community_direct_str(entry
->direct
),
18254 community_list_config_str(entry
));
18261 static int community_list_config_write(struct vty
*vty
);
18262 static struct cmd_node community_list_node
= {
18263 .name
= "community list",
18264 .node
= COMMUNITY_LIST_NODE
,
18266 .config_write
= community_list_config_write
,
18269 static void community_list_vty(void)
18271 install_node(&community_list_node
);
18273 /* Community-list. */
18274 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
18275 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
18276 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
18277 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
18278 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
18279 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
18280 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
18281 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
18283 /* Extcommunity-list. */
18284 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
18285 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
18286 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
18287 install_element(CONFIG_NODE
,
18288 &no_bgp_extcommunity_list_standard_all_list_cmd
);
18289 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
18290 install_element(CONFIG_NODE
,
18291 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
18292 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
18293 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
18295 /* Large Community List */
18296 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
18297 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
18298 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
18299 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
18300 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_all_cmd
);
18301 install_element(CONFIG_NODE
,
18302 &no_bgp_lcommunity_list_name_standard_all_cmd
);
18303 install_element(CONFIG_NODE
,
18304 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
18305 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
18306 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
18307 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
18308 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
18309 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
18310 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);