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"
35 #include "memory_vty.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_addpath.h"
68 #include "bgpd/bgp_mac.h"
70 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
71 struct prefix
*range
, int exact
);
73 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
82 return BGP_IPV4M_NODE
;
84 case SAFI_LABELED_UNICAST
:
85 return BGP_IPV4L_NODE
;
88 return BGP_VPNV4_NODE
;
91 return BGP_FLOWSPECV4_NODE
;
101 return BGP_IPV6_NODE
;
104 return BGP_IPV6M_NODE
;
106 case SAFI_LABELED_UNICAST
:
107 return BGP_IPV6L_NODE
;
110 return BGP_VPNV6_NODE
;
113 return BGP_FLOWSPECV6_NODE
;
116 return BGP_IPV4_NODE
;
121 return BGP_EVPN_NODE
;
125 // We should never be here but to clarify the switch statement..
126 return BGP_IPV4_NODE
;
130 // Impossible to happen
131 return BGP_IPV4_NODE
;
134 static const char *get_afi_safi_vty_str(afi_t afi
, safi_t safi
)
136 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
137 return "IPv4 Unicast";
138 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
139 return "IPv4 Multicast";
140 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
141 return "IPv4 Labeled Unicast";
142 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
144 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
146 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
147 return "IPv4 Flowspec";
148 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
149 return "IPv6 Unicast";
150 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
151 return "IPv6 Multicast";
152 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
153 return "IPv6 Labeled Unicast";
154 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
156 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
158 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
159 return "IPv6 Flowspec";
160 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
163 flog_err(EC_LIB_DEVELOPMENT
, "New afi/safi that needs to be taken care of?");
169 * Please note that we have intentionally camelCased
170 * the return strings here. So if you want
171 * to use this function, please ensure you
172 * are doing this within json output
174 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
176 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
177 return "ipv4Unicast";
178 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
179 return "ipv4Multicast";
180 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
181 return "ipv4LabeledUnicast";
182 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
184 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
186 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
187 return "ipv4Flowspec";
188 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
189 return "ipv6Unicast";
190 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
191 return "ipv6Multicast";
192 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
193 return "ipv6LabeledUnicast";
194 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
196 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
198 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
199 return "ipv6Flowspec";
200 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
203 flog_err(EC_LIB_DEVELOPMENT
, "New afi/safi that needs to be taken care of?");
208 /* Utility function to get address family from current node. */
209 afi_t
bgp_node_afi(struct vty
*vty
)
217 case BGP_FLOWSPECV6_NODE
:
230 /* Utility function to get subsequent address family from current
232 safi_t
bgp_node_safi(struct vty
*vty
)
238 safi
= SAFI_MPLS_VPN
;
242 safi
= SAFI_MULTICAST
;
249 safi
= SAFI_LABELED_UNICAST
;
251 case BGP_FLOWSPECV4_NODE
:
252 case BGP_FLOWSPECV6_NODE
:
253 safi
= SAFI_FLOWSPEC
;
263 * Converts an AFI in string form to afi_t
265 * @param afi string, one of
269 * @return the corresponding afi_t
271 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
273 afi_t afi
= AFI_MAX
; /* unknown */
274 if (strmatch(afi_str
, "ipv4"))
276 else if (strmatch(afi_str
, "ipv6"))
278 else if (strmatch(afi_str
, "l2vpn"))
283 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
287 if (argv_find(argv
, argc
, "ipv4", index
)) {
291 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
295 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
303 /* supports <unicast|multicast|vpn|labeled-unicast> */
304 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
306 safi_t safi
= SAFI_MAX
; /* unknown */
307 if (strmatch(safi_str
, "multicast"))
308 safi
= SAFI_MULTICAST
;
309 else if (strmatch(safi_str
, "unicast"))
311 else if (strmatch(safi_str
, "vpn"))
312 safi
= SAFI_MPLS_VPN
;
313 else if (strmatch(safi_str
, "evpn"))
315 else if (strmatch(safi_str
, "labeled-unicast"))
316 safi
= SAFI_LABELED_UNICAST
;
317 else if (strmatch(safi_str
, "flowspec"))
318 safi
= SAFI_FLOWSPEC
;
322 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
326 if (argv_find(argv
, argc
, "unicast", index
)) {
329 *safi
= SAFI_UNICAST
;
330 } else if (argv_find(argv
, argc
, "multicast", index
)) {
333 *safi
= SAFI_MULTICAST
;
334 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
337 *safi
= SAFI_LABELED_UNICAST
;
338 } else if (argv_find(argv
, argc
, "vpn", index
)) {
341 *safi
= SAFI_MPLS_VPN
;
342 } else if (argv_find(argv
, argc
, "evpn", index
)) {
346 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
349 *safi
= SAFI_FLOWSPEC
;
355 * bgp_vty_find_and_parse_afi_safi_bgp
357 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
358 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
359 * to appropriate values for the calling function. This is to allow the
360 * calling function to make decisions appropriate for the show command
361 * that is being parsed.
363 * The show commands are generally of the form:
364 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
365 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
367 * Since we use argv_find if the show command in particular doesn't have:
369 * [<view|vrf> VIEWVRFNAME]
370 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
371 * The command parsing should still be ok.
373 * vty -> The vty for the command so we can output some useful data in
374 * the event of a parse error in the vrf.
375 * argv -> The command tokens
376 * argc -> How many command tokens we have
377 * idx -> The current place in the command, generally should be 0 for this
379 * afi -> The parsed afi if it was included in the show command, returned here
380 * safi -> The parsed safi if it was included in the show command, returned here
381 * bgp -> Pointer to the bgp data structure we need to fill in.
382 * use_json -> json is configured or not
384 * The function returns the correct location in the parse tree for the
387 * Returns 0 for failure to parse correctly, else the idx position of where
388 * it found the last token.
390 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
391 struct cmd_token
**argv
, int argc
,
392 int *idx
, afi_t
*afi
, safi_t
*safi
,
393 struct bgp
**bgp
, bool use_json
)
395 char *vrf_name
= NULL
;
401 if (argv_find(argv
, argc
, "ip", idx
))
404 if (argv_find(argv
, argc
, "view", idx
))
405 vrf_name
= argv
[*idx
+ 1]->arg
;
406 else if (argv_find(argv
, argc
, "vrf", idx
)) {
407 vrf_name
= argv
[*idx
+ 1]->arg
;
408 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
412 if (strmatch(vrf_name
, "all"))
415 *bgp
= bgp_lookup_by_name(vrf_name
);
418 json_object
*json
= NULL
;
419 json
= json_object_new_object();
420 json_object_string_add(
422 "View/Vrf is unknown");
424 json_object_to_json_string_ext(json
,
425 JSON_C_TO_STRING_PRETTY
));
426 json_object_free(json
);
429 vty_out(vty
, "View/Vrf %s is unknown\n",
436 *bgp
= bgp_get_default();
439 json_object
*json
= NULL
;
440 json
= json_object_new_object();
441 json_object_string_add(
443 "Default BGP instance not found");
445 json_object_to_json_string_ext(json
,
446 JSON_C_TO_STRING_PRETTY
));
447 json_object_free(json
);
451 "Default BGP instance not found\n");
457 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
458 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
464 static int peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
466 struct interface
*ifp
= NULL
;
468 if (su
->sa
.sa_family
== AF_INET
)
469 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
470 else if (su
->sa
.sa_family
== AF_INET6
)
471 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
472 su
->sin6
.sin6_scope_id
,
481 /* Utility function for looking up peer from VTY. */
482 /* This is used only for configuration, so disallow if attempted on
483 * a dynamic neighbor.
485 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
487 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
496 ret
= str2sockunion(ip_str
, &su
);
498 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
500 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
503 "%% Malformed address or name: %s\n",
509 peer
= peer_lookup(bgp
, &su
);
512 "%% Specify remote-as or peer-group commands first\n");
515 if (peer_dynamic_neighbor(peer
)) {
517 "%% Operation not allowed on a dynamic neighbor\n");
524 /* Utility function for looking up peer or peer group. */
525 /* This is used only for configuration, so disallow if attempted on
526 * a dynamic neighbor.
528 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
530 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
533 struct peer
*peer
= NULL
;
534 struct peer_group
*group
= NULL
;
540 ret
= str2sockunion(peer_str
, &su
);
542 /* IP address, locate peer. */
543 peer
= peer_lookup(bgp
, &su
);
545 /* Not IP, could match either peer configured on interface or a
547 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
549 group
= peer_group_lookup(bgp
, peer_str
);
553 if (peer_dynamic_neighbor(peer
)) {
555 "%% Operation not allowed on a dynamic neighbor\n");
565 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
570 int bgp_vty_return(struct vty
*vty
, int ret
)
572 const char *str
= NULL
;
575 case BGP_ERR_INVALID_VALUE
:
576 str
= "Invalid value";
578 case BGP_ERR_INVALID_FLAG
:
579 str
= "Invalid flag";
581 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
582 str
= "Peer-group has been shutdown. Activate the peer-group first";
584 case BGP_ERR_PEER_FLAG_CONFLICT
:
585 str
= "Can't set override-capability and strict-capability-match at the same time";
587 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
588 str
= "Specify remote-as or peer-group remote AS first";
590 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
591 str
= "Cannot change the peer-group. Deconfigure first";
593 case BGP_ERR_PEER_GROUP_MISMATCH
:
594 str
= "Peer is not a member of this peer-group";
596 case BGP_ERR_PEER_FILTER_CONFLICT
:
597 str
= "Prefix/distribute list can not co-exist";
599 case BGP_ERR_NOT_INTERNAL_PEER
:
600 str
= "Invalid command. Not an internal neighbor";
602 case BGP_ERR_REMOVE_PRIVATE_AS
:
603 str
= "remove-private-AS cannot be configured for IBGP peers";
605 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
606 str
= "Local-AS allowed only for EBGP peers";
608 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
609 str
= "Cannot have local-as same as BGP AS number";
611 case BGP_ERR_TCPSIG_FAILED
:
612 str
= "Error while applying TCP-Sig to session(s)";
614 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
615 str
= "ebgp-multihop and ttl-security cannot be configured together";
617 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
618 str
= "ttl-security only allowed for EBGP peers";
620 case BGP_ERR_AS_OVERRIDE
:
621 str
= "as-override cannot be configured for IBGP peers";
623 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
624 str
= "Invalid limit for number of dynamic neighbors";
626 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
627 str
= "Dynamic neighbor listen range already exists";
629 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
630 str
= "Operation not allowed on a dynamic neighbor";
632 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
633 str
= "Operation not allowed on a directly connected neighbor";
635 case BGP_ERR_PEER_SAFI_CONFLICT
:
636 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
640 vty_out(vty
, "%% %s\n", str
);
641 return CMD_WARNING_CONFIG_FAILED
;
646 /* BGP clear sort. */
655 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
656 safi_t safi
, int error
)
659 case BGP_ERR_AF_UNCONFIGURED
:
661 "%%BGP: Enable %s address family for the neighbor %s\n",
662 get_afi_safi_str(afi
, safi
, false), peer
->host
);
664 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
666 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
674 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
675 struct listnode
*nnode
, enum bgp_clear_type stype
)
679 /* if afi/.safi not specified, spin thru all of them */
680 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
684 FOREACH_AFI_SAFI (tmp_afi
, tmp_safi
) {
685 if (!peer
->afc
[tmp_afi
][tmp_safi
])
688 if (stype
== BGP_CLEAR_SOFT_NONE
)
689 ret
= peer_clear(peer
, &nnode
);
691 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
694 /* if afi specified and safi not, spin thru safis on this afi */
695 } else if (safi
== SAFI_UNSPEC
) {
698 for (tmp_safi
= SAFI_UNICAST
;
699 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
700 if (!peer
->afc
[afi
][tmp_safi
])
703 if (stype
== BGP_CLEAR_SOFT_NONE
)
704 ret
= peer_clear(peer
, &nnode
);
706 ret
= peer_clear_soft(peer
, afi
,
709 /* both afi/safi specified, let the caller know if not defined */
711 if (!peer
->afc
[afi
][safi
])
714 if (stype
== BGP_CLEAR_SOFT_NONE
)
715 ret
= peer_clear(peer
, &nnode
);
717 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
723 /* `clear ip bgp' functions. */
724 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
725 enum clear_sort sort
, enum bgp_clear_type stype
,
731 struct listnode
*node
, *nnode
;
733 /* Clear all neighbors. */
735 * Pass along pointer to next node to peer_clear() when walking all
736 * nodes on the BGP instance as that may get freed if it is a
739 if (sort
== clear_all
) {
740 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
741 ret
= bgp_peer_clear(peer
, afi
, safi
, nnode
,
745 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
748 /* This is to apply read-only mode on this clear. */
749 if (stype
== BGP_CLEAR_SOFT_NONE
)
750 bgp
->update_delay_over
= 0;
755 /* Clear specified neighbor. */
756 if (sort
== clear_peer
) {
759 /* Make sockunion for lookup. */
760 ret
= str2sockunion(arg
, &su
);
762 peer
= peer_lookup_by_conf_if(bgp
, arg
);
764 peer
= peer_lookup_by_hostname(bgp
, arg
);
767 "Malformed address or name: %s\n",
773 peer
= peer_lookup(bgp
, &su
);
776 "%%BGP: Unknown neighbor - \"%s\"\n",
782 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
784 /* if afi/safi not defined for this peer, let caller know */
786 ret
= BGP_ERR_AF_UNCONFIGURED
;
789 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
794 /* Clear all neighbors belonging to a specific peer-group. */
795 if (sort
== clear_group
) {
796 struct peer_group
*group
;
798 group
= peer_group_lookup(bgp
, arg
);
800 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
804 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
805 ret
= bgp_peer_clear(peer
, afi
, safi
, nnode
, stype
);
808 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
815 "%%BGP: No %s peer belonging to peer-group %s is configured\n",
816 get_afi_safi_str(afi
, safi
, false), arg
);
821 /* Clear all external (eBGP) neighbors. */
822 if (sort
== clear_external
) {
823 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
824 if (peer
->sort
== BGP_PEER_IBGP
)
827 ret
= bgp_peer_clear(peer
, afi
, safi
, nnode
, stype
);
830 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
837 "%%BGP: No external %s peer is configured\n",
838 get_afi_safi_str(afi
, safi
, false));
843 /* Clear all neighbors belonging to a specific AS. */
844 if (sort
== clear_as
) {
845 as_t as
= strtoul(arg
, NULL
, 10);
847 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
851 ret
= bgp_peer_clear(peer
, afi
, safi
, nnode
, stype
);
854 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
861 "%%BGP: No %s peer is configured with AS %s\n",
862 get_afi_safi_str(afi
, safi
, false), arg
);
870 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
871 safi_t safi
, enum clear_sort sort
,
872 enum bgp_clear_type stype
, const char *arg
)
876 /* BGP structure lookup. */
878 bgp
= bgp_lookup_by_name(name
);
880 vty_out(vty
, "Can't find BGP instance %s\n", name
);
884 bgp
= bgp_get_default();
886 vty_out(vty
, "No BGP process is configured\n");
891 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
894 /* clear soft inbound */
895 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
900 FOREACH_AFI_SAFI (afi
, safi
)
901 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
902 BGP_CLEAR_SOFT_IN
, NULL
);
905 /* clear soft outbound */
906 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
911 FOREACH_AFI_SAFI (afi
, safi
)
912 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
913 BGP_CLEAR_SOFT_OUT
, NULL
);
917 #ifndef VTYSH_EXTRACT_PL
918 #include "bgpd/bgp_vty_clippy.c"
921 DEFUN_HIDDEN (bgp_local_mac
,
923 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
926 "VxLAN Network Identifier\n"
930 "mac-mobility sequence\n"
940 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
941 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
942 vty_out(vty
, "%% Malformed MAC address\n");
945 memset(&ip
, 0, sizeof(ip
));
946 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
948 bgp
= bgp_get_default();
950 vty_out(vty
, "Default BGP instance is not there\n");
954 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
);
956 vty_out(vty
, "Internal error\n");
963 DEFUN_HIDDEN (no_bgp_local_mac
,
964 no_bgp_local_mac_cmd
,
965 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
969 "VxLAN Network Identifier\n"
980 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
981 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
982 vty_out(vty
, "%% Malformed MAC address\n");
985 memset(&ip
, 0, sizeof(ip
));
987 bgp
= bgp_get_default();
989 vty_out(vty
, "Default BGP instance is not there\n");
993 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
995 vty_out(vty
, "Internal error\n");
1002 DEFUN (no_synchronization
,
1003 no_synchronization_cmd
,
1004 "no synchronization",
1006 "Perform IGP synchronization\n")
1011 DEFUN (no_auto_summary
,
1012 no_auto_summary_cmd
,
1015 "Enable automatic network number summarization\n")
1020 /* "router bgp" commands. */
1021 DEFUN_NOSH (router_bgp
,
1023 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1027 BGP_INSTANCE_HELP_STR
)
1030 int idx_view_vrf
= 3;
1036 const char *name
= NULL
;
1037 enum bgp_instance_type inst_type
;
1039 // "router bgp" without an ASN
1041 // Pending: Make VRF option available for ASN less config
1042 bgp
= bgp_get_default();
1045 vty_out(vty
, "%% No BGP process is configured\n");
1046 return CMD_WARNING_CONFIG_FAILED
;
1049 if (listcount(bm
->bgp
) > 1) {
1050 vty_out(vty
, "%% Please specify ASN and VRF\n");
1051 return CMD_WARNING_CONFIG_FAILED
;
1057 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1059 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1061 name
= argv
[idx_vrf
]->arg
;
1063 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1064 if (strmatch(name
, VRF_DEFAULT_NAME
))
1067 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1068 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1069 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1072 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1073 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1075 ret
= bgp_get(&bgp
, &as
, name
, inst_type
);
1077 case BGP_ERR_AS_MISMATCH
:
1078 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1079 return CMD_WARNING_CONFIG_FAILED
;
1080 case BGP_ERR_INSTANCE_MISMATCH
:
1082 "BGP instance name and AS number mismatch\n");
1084 "BGP instance is already running; AS is %u\n",
1086 return CMD_WARNING_CONFIG_FAILED
;
1090 * If we just instantiated the default instance, complete
1091 * any pending VRF-VPN leaking that was configured via
1092 * earlier "router bgp X vrf FOO" blocks.
1094 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1095 vpn_leak_postchange_all();
1097 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1098 bgp_vpn_leak_export(bgp
);
1099 /* Pending: handle when user tries to change a view to vrf n vv.
1103 /* unset the auto created flag as the user config is now present */
1104 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1105 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1110 /* "no router bgp" commands. */
1111 DEFUN (no_router_bgp
,
1113 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1118 BGP_INSTANCE_HELP_STR
)
1124 const char *name
= NULL
;
1126 // "no router bgp" without an ASN
1128 // Pending: Make VRF option available for ASN less config
1129 bgp
= bgp_get_default();
1132 vty_out(vty
, "%% No BGP process is configured\n");
1133 return CMD_WARNING_CONFIG_FAILED
;
1136 if (listcount(bm
->bgp
) > 1) {
1137 vty_out(vty
, "%% Please specify ASN and VRF\n");
1138 return CMD_WARNING_CONFIG_FAILED
;
1142 vty_out(vty
, "%% Please unconfigure l3vni %u",
1144 return CMD_WARNING_CONFIG_FAILED
;
1147 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1150 name
= argv
[idx_vrf
]->arg
;
1152 /* Lookup bgp structure. */
1153 bgp
= bgp_lookup(as
, name
);
1155 vty_out(vty
, "%% Can't find BGP instance\n");
1156 return CMD_WARNING_CONFIG_FAILED
;
1160 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1162 return CMD_WARNING_CONFIG_FAILED
;
1165 /* Cannot delete default instance if vrf instances exist */
1166 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1167 struct listnode
*node
;
1168 struct bgp
*tmp_bgp
;
1170 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1171 if (tmp_bgp
->inst_type
1172 == BGP_INSTANCE_TYPE_VRF
) {
1174 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1175 return CMD_WARNING_CONFIG_FAILED
;
1181 if (bgp_vpn_leak_unimport(bgp
, vty
))
1182 return CMD_WARNING_CONFIG_FAILED
;
1190 /* BGP router-id. */
1192 DEFPY (bgp_router_id
,
1194 "bgp router-id A.B.C.D",
1196 "Override configured router identifier\n"
1197 "Manually configured router identifier\n")
1199 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1200 bgp_router_id_static_set(bgp
, router_id
);
1204 DEFPY (no_bgp_router_id
,
1205 no_bgp_router_id_cmd
,
1206 "no bgp router-id [A.B.C.D]",
1209 "Override configured router identifier\n"
1210 "Manually configured router identifier\n")
1212 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1214 if (router_id_str
) {
1215 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1216 vty_out(vty
, "%% BGP router-id doesn't match\n");
1217 return CMD_WARNING_CONFIG_FAILED
;
1221 router_id
.s_addr
= 0;
1222 bgp_router_id_static_set(bgp
, router_id
);
1228 /* BGP Cluster ID. */
1229 DEFUN (bgp_cluster_id
,
1231 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1233 "Configure Route-Reflector Cluster-id\n"
1234 "Route-Reflector Cluster-id in IP address format\n"
1235 "Route-Reflector Cluster-id as 32 bit quantity\n")
1237 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1240 struct in_addr cluster
;
1242 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1244 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1245 return CMD_WARNING_CONFIG_FAILED
;
1248 bgp_cluster_id_set(bgp
, &cluster
);
1249 bgp_clear_star_soft_out(vty
, bgp
->name
);
1254 DEFUN (no_bgp_cluster_id
,
1255 no_bgp_cluster_id_cmd
,
1256 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1259 "Configure Route-Reflector Cluster-id\n"
1260 "Route-Reflector Cluster-id in IP address format\n"
1261 "Route-Reflector Cluster-id as 32 bit quantity\n")
1263 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1264 bgp_cluster_id_unset(bgp
);
1265 bgp_clear_star_soft_out(vty
, bgp
->name
);
1270 DEFUN (bgp_confederation_identifier
,
1271 bgp_confederation_identifier_cmd
,
1272 "bgp confederation identifier (1-4294967295)",
1273 "BGP specific commands\n"
1274 "AS confederation parameters\n"
1276 "Set routing domain confederation AS\n")
1278 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1282 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1284 bgp_confederation_id_set(bgp
, as
);
1289 DEFUN (no_bgp_confederation_identifier
,
1290 no_bgp_confederation_identifier_cmd
,
1291 "no bgp confederation identifier [(1-4294967295)]",
1293 "BGP specific commands\n"
1294 "AS confederation parameters\n"
1296 "Set routing domain confederation AS\n")
1298 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1299 bgp_confederation_id_unset(bgp
);
1304 DEFUN (bgp_confederation_peers
,
1305 bgp_confederation_peers_cmd
,
1306 "bgp confederation peers (1-4294967295)...",
1307 "BGP specific commands\n"
1308 "AS confederation parameters\n"
1309 "Peer ASs in BGP confederation\n"
1312 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1317 for (i
= idx_asn
; i
< argc
; i
++) {
1318 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1320 if (bgp
->as
== as
) {
1322 "%% Local member-AS not allowed in confed peer list\n");
1326 bgp_confederation_peers_add(bgp
, as
);
1331 DEFUN (no_bgp_confederation_peers
,
1332 no_bgp_confederation_peers_cmd
,
1333 "no bgp confederation peers (1-4294967295)...",
1335 "BGP specific commands\n"
1336 "AS confederation parameters\n"
1337 "Peer ASs in BGP confederation\n"
1340 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1345 for (i
= idx_asn
; i
< argc
; i
++) {
1346 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1348 bgp_confederation_peers_remove(bgp
, as
);
1354 * Central routine for maximum-paths configuration.
1355 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1356 * @set: 1 for setting values, 0 for removing the max-paths config.
1358 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1359 const char *mpaths
, uint16_t options
,
1362 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1363 uint16_t maxpaths
= 0;
1368 afi
= bgp_node_afi(vty
);
1369 safi
= bgp_node_safi(vty
);
1372 maxpaths
= strtol(mpaths
, NULL
, 10);
1373 if (maxpaths
> multipath_num
) {
1375 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1376 maxpaths
, multipath_num
);
1377 return CMD_WARNING_CONFIG_FAILED
;
1379 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1382 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1386 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1387 (set
== 1) ? "" : "un",
1388 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1389 maxpaths
, afi
, safi
);
1390 return CMD_WARNING_CONFIG_FAILED
;
1393 bgp_recalculate_all_bestpaths(bgp
);
1398 DEFUN (bgp_maxmed_admin
,
1399 bgp_maxmed_admin_cmd
,
1400 "bgp max-med administrative ",
1402 "Advertise routes with max-med\n"
1403 "Administratively applied, for an indefinite period\n")
1405 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1407 bgp
->v_maxmed_admin
= 1;
1408 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1410 bgp_maxmed_update(bgp
);
1415 DEFUN (bgp_maxmed_admin_medv
,
1416 bgp_maxmed_admin_medv_cmd
,
1417 "bgp max-med administrative (0-4294967295)",
1419 "Advertise routes with max-med\n"
1420 "Administratively applied, for an indefinite period\n"
1421 "Max MED value to be used\n")
1423 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1426 bgp
->v_maxmed_admin
= 1;
1427 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1429 bgp_maxmed_update(bgp
);
1434 DEFUN (no_bgp_maxmed_admin
,
1435 no_bgp_maxmed_admin_cmd
,
1436 "no bgp max-med administrative [(0-4294967295)]",
1439 "Advertise routes with max-med\n"
1440 "Administratively applied, for an indefinite period\n"
1441 "Max MED value to be used\n")
1443 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1444 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1445 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1446 bgp_maxmed_update(bgp
);
1451 DEFUN (bgp_maxmed_onstartup
,
1452 bgp_maxmed_onstartup_cmd
,
1453 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1455 "Advertise routes with max-med\n"
1456 "Effective on a startup\n"
1457 "Time (seconds) period for max-med\n"
1458 "Max MED value to be used\n")
1460 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1463 argv_find(argv
, argc
, "(5-86400)", &idx
);
1464 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1465 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1466 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1468 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1470 bgp_maxmed_update(bgp
);
1475 DEFUN (no_bgp_maxmed_onstartup
,
1476 no_bgp_maxmed_onstartup_cmd
,
1477 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1480 "Advertise routes with max-med\n"
1481 "Effective on a startup\n"
1482 "Time (seconds) period for max-med\n"
1483 "Max MED value to be used\n")
1485 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1487 /* Cancel max-med onstartup if its on */
1488 if (bgp
->t_maxmed_onstartup
) {
1489 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1490 bgp
->maxmed_onstartup_over
= 1;
1493 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1494 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1496 bgp_maxmed_update(bgp
);
1501 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1504 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1505 uint16_t update_delay
;
1506 uint16_t establish_wait
;
1508 update_delay
= strtoul(delay
, NULL
, 10);
1510 if (!wait
) /* update-delay <delay> */
1512 bgp
->v_update_delay
= update_delay
;
1513 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1517 /* update-delay <delay> <establish-wait> */
1518 establish_wait
= atoi(wait
);
1519 if (update_delay
< establish_wait
) {
1521 "%%Failed: update-delay less than the establish-wait!\n");
1522 return CMD_WARNING_CONFIG_FAILED
;
1525 bgp
->v_update_delay
= update_delay
;
1526 bgp
->v_establish_wait
= establish_wait
;
1531 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1533 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1535 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1536 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1541 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1543 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1544 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1545 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1546 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1552 /* Update-delay configuration */
1553 DEFUN (bgp_update_delay
,
1554 bgp_update_delay_cmd
,
1555 "update-delay (0-3600)",
1556 "Force initial delay for best-path and updates\n"
1560 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1563 DEFUN (bgp_update_delay_establish_wait
,
1564 bgp_update_delay_establish_wait_cmd
,
1565 "update-delay (0-3600) (1-3600)",
1566 "Force initial delay for best-path and updates\n"
1571 int idx_number_2
= 2;
1572 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1573 argv
[idx_number_2
]->arg
);
1576 /* Update-delay deconfiguration */
1577 DEFUN (no_bgp_update_delay
,
1578 no_bgp_update_delay_cmd
,
1579 "no update-delay [(0-3600) [(1-3600)]]",
1581 "Force initial delay for best-path and updates\n"
1585 return bgp_update_delay_deconfig_vty(vty
);
1589 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1592 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1595 uint32_t quanta
= strtoul(num
, NULL
, 10);
1596 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
,
1597 memory_order_relaxed
);
1599 atomic_store_explicit(&bgp
->wpkt_quanta
, BGP_WRITE_PACKET_MAX
,
1600 memory_order_relaxed
);
1606 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1609 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1612 uint32_t quanta
= strtoul(num
, NULL
, 10);
1613 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
,
1614 memory_order_relaxed
);
1616 atomic_store_explicit(&bgp
->rpkt_quanta
, BGP_READ_PACKET_MAX
,
1617 memory_order_relaxed
);
1623 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1626 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1627 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1628 vty_out(vty
, " write-quanta %d\n", quanta
);
1631 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1634 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1635 if (quanta
!= BGP_READ_PACKET_MAX
)
1636 vty_out(vty
, " read-quanta %d\n", quanta
);
1639 /* Packet quanta configuration */
1640 DEFUN (bgp_wpkt_quanta
,
1641 bgp_wpkt_quanta_cmd
,
1642 "write-quanta (1-10)",
1643 "How many packets to write to peer socket per run\n"
1644 "Number of packets\n")
1647 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1650 DEFUN (no_bgp_wpkt_quanta
,
1651 no_bgp_wpkt_quanta_cmd
,
1652 "no write-quanta (1-10)",
1654 "How many packets to write to peer socket per I/O cycle\n"
1655 "Number of packets\n")
1658 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1661 DEFUN (bgp_rpkt_quanta
,
1662 bgp_rpkt_quanta_cmd
,
1663 "read-quanta (1-10)",
1664 "How many packets to read from peer socket per I/O cycle\n"
1665 "Number of packets\n")
1668 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1671 DEFUN (no_bgp_rpkt_quanta
,
1672 no_bgp_rpkt_quanta_cmd
,
1673 "no read-quanta (1-10)",
1675 "How many packets to read from peer socket per I/O cycle\n"
1676 "Number of packets\n")
1679 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1682 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1684 if (!bgp
->heuristic_coalesce
)
1685 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1689 DEFUN (bgp_coalesce_time
,
1690 bgp_coalesce_time_cmd
,
1691 "coalesce-time (0-4294967295)",
1692 "Subgroup coalesce timer\n"
1693 "Subgroup coalesce timer value (in ms)\n")
1695 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1698 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1699 bgp
->heuristic_coalesce
= false;
1700 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1704 DEFUN (no_bgp_coalesce_time
,
1705 no_bgp_coalesce_time_cmd
,
1706 "no coalesce-time (0-4294967295)",
1708 "Subgroup coalesce timer\n"
1709 "Subgroup coalesce timer value (in ms)\n")
1711 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1713 bgp
->heuristic_coalesce
= true;
1714 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1718 /* Maximum-paths configuration */
1719 DEFUN (bgp_maxpaths
,
1721 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1722 "Forward packets over multiple paths\n"
1723 "Number of paths\n")
1726 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1727 argv
[idx_number
]->arg
, 0, 1);
1730 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1731 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1732 "Forward packets over multiple paths\n"
1733 "Number of paths\n")
1735 DEFUN (bgp_maxpaths_ibgp
,
1736 bgp_maxpaths_ibgp_cmd
,
1737 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1738 "Forward packets over multiple paths\n"
1740 "Number of paths\n")
1743 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1744 argv
[idx_number
]->arg
, 0, 1);
1747 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1748 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1749 "Forward packets over multiple paths\n"
1751 "Number of paths\n")
1753 DEFUN (bgp_maxpaths_ibgp_cluster
,
1754 bgp_maxpaths_ibgp_cluster_cmd
,
1755 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1756 "Forward packets over multiple paths\n"
1759 "Match the cluster length\n")
1762 return bgp_maxpaths_config_vty(
1763 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1764 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1767 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1768 "maximum-paths ibgp " CMD_RANGE_STR(
1769 1, MULTIPATH_NUM
) " equal-cluster-length",
1770 "Forward packets over multiple paths\n"
1773 "Match the cluster length\n")
1775 DEFUN (no_bgp_maxpaths
,
1776 no_bgp_maxpaths_cmd
,
1777 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1779 "Forward packets over multiple paths\n"
1780 "Number of paths\n")
1782 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1785 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1786 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1787 "Forward packets over multiple paths\n"
1788 "Number of paths\n")
1790 DEFUN (no_bgp_maxpaths_ibgp
,
1791 no_bgp_maxpaths_ibgp_cmd
,
1792 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1794 "Forward packets over multiple paths\n"
1797 "Match the cluster length\n")
1799 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1802 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1803 "no maximum-paths ibgp [" CMD_RANGE_STR(
1804 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1806 "Forward packets over multiple paths\n"
1809 "Match the cluster length\n")
1811 void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1814 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1815 vty_out(vty
, " maximum-paths %d\n",
1816 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1819 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1820 vty_out(vty
, " maximum-paths ibgp %d",
1821 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1822 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1823 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1824 vty_out(vty
, " equal-cluster-length");
1833 "timers bgp (0-65535) (0-65535)",
1834 "Adjust routing timers\n"
1836 "Keepalive interval\n"
1839 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1841 int idx_number_2
= 3;
1842 unsigned long keepalive
= 0;
1843 unsigned long holdtime
= 0;
1845 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1846 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1848 /* Holdtime value check. */
1849 if (holdtime
< 3 && holdtime
!= 0) {
1851 "%% hold time value must be either 0 or greater than 3\n");
1852 return CMD_WARNING_CONFIG_FAILED
;
1855 bgp_timers_set(bgp
, keepalive
, holdtime
);
1860 DEFUN (no_bgp_timers
,
1862 "no timers bgp [(0-65535) (0-65535)]",
1864 "Adjust routing timers\n"
1866 "Keepalive interval\n"
1869 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1870 bgp_timers_unset(bgp
);
1876 DEFUN (bgp_client_to_client_reflection
,
1877 bgp_client_to_client_reflection_cmd
,
1878 "bgp client-to-client reflection",
1879 "BGP specific commands\n"
1880 "Configure client to client route reflection\n"
1881 "reflection of routes allowed\n")
1883 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1884 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1885 bgp_clear_star_soft_out(vty
, bgp
->name
);
1890 DEFUN (no_bgp_client_to_client_reflection
,
1891 no_bgp_client_to_client_reflection_cmd
,
1892 "no bgp client-to-client reflection",
1894 "BGP specific commands\n"
1895 "Configure client to client route reflection\n"
1896 "reflection of routes allowed\n")
1898 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1899 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1900 bgp_clear_star_soft_out(vty
, bgp
->name
);
1905 /* "bgp always-compare-med" configuration. */
1906 DEFUN (bgp_always_compare_med
,
1907 bgp_always_compare_med_cmd
,
1908 "bgp always-compare-med",
1909 "BGP specific commands\n"
1910 "Allow comparing MED from different neighbors\n")
1912 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1913 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1914 bgp_recalculate_all_bestpaths(bgp
);
1919 DEFUN (no_bgp_always_compare_med
,
1920 no_bgp_always_compare_med_cmd
,
1921 "no bgp always-compare-med",
1923 "BGP specific commands\n"
1924 "Allow comparing MED from different neighbors\n")
1926 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1927 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1928 bgp_recalculate_all_bestpaths(bgp
);
1934 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
1935 "bgp ebgp-requires-policy",
1936 "BGP specific commands\n"
1937 "Require in and out policy for eBGP peers (RFC8212)\n")
1939 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1940 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_ENABLED
;
1944 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
1945 "no bgp ebgp-requires-policy",
1947 "BGP specific commands\n"
1948 "Require in and out policy for eBGP peers (RFC8212)\n")
1950 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1951 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_DISABLED
;
1956 /* "bgp deterministic-med" configuration. */
1957 DEFUN (bgp_deterministic_med
,
1958 bgp_deterministic_med_cmd
,
1959 "bgp deterministic-med",
1960 "BGP specific commands\n"
1961 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1963 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1965 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1966 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1967 bgp_recalculate_all_bestpaths(bgp
);
1973 DEFUN (no_bgp_deterministic_med
,
1974 no_bgp_deterministic_med_cmd
,
1975 "no bgp deterministic-med",
1977 "BGP specific commands\n"
1978 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1980 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1981 int bestpath_per_as_used
;
1985 struct listnode
*node
, *nnode
;
1987 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1988 bestpath_per_as_used
= 0;
1990 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1991 FOREACH_AFI_SAFI (afi
, safi
)
1992 if (bgp_addpath_dmed_required(
1993 peer
->addpath_type
[afi
][safi
])) {
1994 bestpath_per_as_used
= 1;
1998 if (bestpath_per_as_used
)
2002 if (bestpath_per_as_used
) {
2004 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2005 return CMD_WARNING_CONFIG_FAILED
;
2007 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
2008 bgp_recalculate_all_bestpaths(bgp
);
2015 /* "bgp graceful-restart" configuration. */
2016 DEFUN (bgp_graceful_restart
,
2017 bgp_graceful_restart_cmd
,
2018 "bgp graceful-restart",
2019 "BGP specific commands\n"
2020 "Graceful restart capability parameters\n")
2022 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2023 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
2027 DEFUN (no_bgp_graceful_restart
,
2028 no_bgp_graceful_restart_cmd
,
2029 "no bgp graceful-restart",
2031 "BGP specific commands\n"
2032 "Graceful restart capability parameters\n")
2034 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2035 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
2039 DEFUN (bgp_graceful_restart_stalepath_time
,
2040 bgp_graceful_restart_stalepath_time_cmd
,
2041 "bgp graceful-restart stalepath-time (1-4095)",
2042 "BGP specific commands\n"
2043 "Graceful restart capability parameters\n"
2044 "Set the max time to hold onto restarting peer's stale paths\n"
2045 "Delay value (seconds)\n")
2047 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2051 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2052 bgp
->stalepath_time
= stalepath
;
2056 DEFUN (bgp_graceful_restart_restart_time
,
2057 bgp_graceful_restart_restart_time_cmd
,
2058 "bgp graceful-restart restart-time (1-4095)",
2059 "BGP specific commands\n"
2060 "Graceful restart capability parameters\n"
2061 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2062 "Delay value (seconds)\n")
2064 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2068 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2069 bgp
->restart_time
= restart
;
2073 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2074 no_bgp_graceful_restart_stalepath_time_cmd
,
2075 "no bgp graceful-restart stalepath-time [(1-4095)]",
2077 "BGP specific commands\n"
2078 "Graceful restart capability parameters\n"
2079 "Set the max time to hold onto restarting peer's stale paths\n"
2080 "Delay value (seconds)\n")
2082 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2084 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2088 DEFUN (no_bgp_graceful_restart_restart_time
,
2089 no_bgp_graceful_restart_restart_time_cmd
,
2090 "no bgp graceful-restart restart-time [(1-4095)]",
2092 "BGP specific commands\n"
2093 "Graceful restart capability parameters\n"
2094 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2095 "Delay value (seconds)\n")
2097 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2099 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2103 DEFUN (bgp_graceful_restart_preserve_fw
,
2104 bgp_graceful_restart_preserve_fw_cmd
,
2105 "bgp graceful-restart preserve-fw-state",
2106 "BGP specific commands\n"
2107 "Graceful restart capability parameters\n"
2108 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2110 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2111 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2115 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2116 no_bgp_graceful_restart_preserve_fw_cmd
,
2117 "no bgp graceful-restart preserve-fw-state",
2119 "BGP specific commands\n"
2120 "Graceful restart capability parameters\n"
2121 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2123 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2124 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2128 /* "bgp graceful-shutdown" configuration */
2129 DEFUN (bgp_graceful_shutdown
,
2130 bgp_graceful_shutdown_cmd
,
2131 "bgp graceful-shutdown",
2133 "Graceful shutdown parameters\n")
2135 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2137 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2138 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2139 bgp_static_redo_import_check(bgp
);
2140 bgp_redistribute_redo(bgp
);
2141 bgp_clear_star_soft_out(vty
, bgp
->name
);
2142 bgp_clear_star_soft_in(vty
, bgp
->name
);
2148 DEFUN (no_bgp_graceful_shutdown
,
2149 no_bgp_graceful_shutdown_cmd
,
2150 "no bgp graceful-shutdown",
2153 "Graceful shutdown parameters\n")
2155 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2157 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2158 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2159 bgp_static_redo_import_check(bgp
);
2160 bgp_redistribute_redo(bgp
);
2161 bgp_clear_star_soft_out(vty
, bgp
->name
);
2162 bgp_clear_star_soft_in(vty
, bgp
->name
);
2168 /* "bgp fast-external-failover" configuration. */
2169 DEFUN (bgp_fast_external_failover
,
2170 bgp_fast_external_failover_cmd
,
2171 "bgp fast-external-failover",
2173 "Immediately reset session if a link to a directly connected external peer goes down\n")
2175 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2176 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2180 DEFUN (no_bgp_fast_external_failover
,
2181 no_bgp_fast_external_failover_cmd
,
2182 "no bgp fast-external-failover",
2185 "Immediately reset session if a link to a directly connected external peer goes down\n")
2187 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2188 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2192 /* "bgp bestpath compare-routerid" configuration. */
2193 DEFUN (bgp_bestpath_compare_router_id
,
2194 bgp_bestpath_compare_router_id_cmd
,
2195 "bgp bestpath compare-routerid",
2196 "BGP specific commands\n"
2197 "Change the default bestpath selection\n"
2198 "Compare router-id for identical EBGP paths\n")
2200 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2201 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2202 bgp_recalculate_all_bestpaths(bgp
);
2207 DEFUN (no_bgp_bestpath_compare_router_id
,
2208 no_bgp_bestpath_compare_router_id_cmd
,
2209 "no bgp bestpath compare-routerid",
2211 "BGP specific commands\n"
2212 "Change the default bestpath selection\n"
2213 "Compare router-id for identical EBGP paths\n")
2215 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2216 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2217 bgp_recalculate_all_bestpaths(bgp
);
2222 /* "bgp bestpath as-path ignore" configuration. */
2223 DEFUN (bgp_bestpath_aspath_ignore
,
2224 bgp_bestpath_aspath_ignore_cmd
,
2225 "bgp bestpath as-path ignore",
2226 "BGP specific commands\n"
2227 "Change the default bestpath selection\n"
2228 "AS-path attribute\n"
2229 "Ignore as-path length in selecting a route\n")
2231 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2232 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2233 bgp_recalculate_all_bestpaths(bgp
);
2238 DEFUN (no_bgp_bestpath_aspath_ignore
,
2239 no_bgp_bestpath_aspath_ignore_cmd
,
2240 "no bgp bestpath as-path ignore",
2242 "BGP specific commands\n"
2243 "Change the default bestpath selection\n"
2244 "AS-path attribute\n"
2245 "Ignore as-path length in selecting a route\n")
2247 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2248 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2249 bgp_recalculate_all_bestpaths(bgp
);
2254 /* "bgp bestpath as-path confed" configuration. */
2255 DEFUN (bgp_bestpath_aspath_confed
,
2256 bgp_bestpath_aspath_confed_cmd
,
2257 "bgp bestpath as-path confed",
2258 "BGP specific commands\n"
2259 "Change the default bestpath selection\n"
2260 "AS-path attribute\n"
2261 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2263 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2264 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2265 bgp_recalculate_all_bestpaths(bgp
);
2270 DEFUN (no_bgp_bestpath_aspath_confed
,
2271 no_bgp_bestpath_aspath_confed_cmd
,
2272 "no bgp bestpath as-path confed",
2274 "BGP specific commands\n"
2275 "Change the default bestpath selection\n"
2276 "AS-path attribute\n"
2277 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2279 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2280 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2281 bgp_recalculate_all_bestpaths(bgp
);
2286 /* "bgp bestpath as-path multipath-relax" configuration. */
2287 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2288 bgp_bestpath_aspath_multipath_relax_cmd
,
2289 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2290 "BGP specific commands\n"
2291 "Change the default bestpath selection\n"
2292 "AS-path attribute\n"
2293 "Allow load sharing across routes that have different AS paths (but same length)\n"
2294 "Generate an AS_SET\n"
2295 "Do not generate an AS_SET\n")
2297 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2299 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2301 /* no-as-set is now the default behavior so we can silently
2303 if (argv_find(argv
, argc
, "as-set", &idx
))
2304 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2306 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2308 bgp_recalculate_all_bestpaths(bgp
);
2313 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2314 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2315 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2317 "BGP specific commands\n"
2318 "Change the default bestpath selection\n"
2319 "AS-path attribute\n"
2320 "Allow load sharing across routes that have different AS paths (but same length)\n"
2321 "Generate an AS_SET\n"
2322 "Do not generate an AS_SET\n")
2324 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2325 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2326 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2327 bgp_recalculate_all_bestpaths(bgp
);
2332 /* "bgp log-neighbor-changes" configuration. */
2333 DEFUN (bgp_log_neighbor_changes
,
2334 bgp_log_neighbor_changes_cmd
,
2335 "bgp log-neighbor-changes",
2336 "BGP specific commands\n"
2337 "Log neighbor up/down and reset reason\n")
2339 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2340 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2344 DEFUN (no_bgp_log_neighbor_changes
,
2345 no_bgp_log_neighbor_changes_cmd
,
2346 "no bgp log-neighbor-changes",
2348 "BGP specific commands\n"
2349 "Log neighbor up/down and reset reason\n")
2351 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2352 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2356 /* "bgp bestpath med" configuration. */
2357 DEFUN (bgp_bestpath_med
,
2358 bgp_bestpath_med_cmd
,
2359 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2360 "BGP specific commands\n"
2361 "Change the default bestpath selection\n"
2363 "Compare MED among confederation paths\n"
2364 "Treat missing MED as the least preferred one\n"
2365 "Treat missing MED as the least preferred one\n"
2366 "Compare MED among confederation paths\n")
2368 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2371 if (argv_find(argv
, argc
, "confed", &idx
))
2372 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2374 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2375 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2377 bgp_recalculate_all_bestpaths(bgp
);
2382 DEFUN (no_bgp_bestpath_med
,
2383 no_bgp_bestpath_med_cmd
,
2384 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2386 "BGP specific commands\n"
2387 "Change the default bestpath selection\n"
2389 "Compare MED among confederation paths\n"
2390 "Treat missing MED as the least preferred one\n"
2391 "Treat missing MED as the least preferred one\n"
2392 "Compare MED among confederation paths\n")
2394 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2397 if (argv_find(argv
, argc
, "confed", &idx
))
2398 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2400 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2401 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2403 bgp_recalculate_all_bestpaths(bgp
);
2408 /* "no bgp default ipv4-unicast". */
2409 DEFUN (no_bgp_default_ipv4_unicast
,
2410 no_bgp_default_ipv4_unicast_cmd
,
2411 "no bgp default ipv4-unicast",
2413 "BGP specific commands\n"
2414 "Configure BGP defaults\n"
2415 "Activate ipv4-unicast for a peer by default\n")
2417 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2418 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2422 DEFUN (bgp_default_ipv4_unicast
,
2423 bgp_default_ipv4_unicast_cmd
,
2424 "bgp default ipv4-unicast",
2425 "BGP specific commands\n"
2426 "Configure BGP defaults\n"
2427 "Activate ipv4-unicast for a peer by default\n")
2429 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2430 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2434 /* Display hostname in certain command outputs */
2435 DEFUN (bgp_default_show_hostname
,
2436 bgp_default_show_hostname_cmd
,
2437 "bgp default show-hostname",
2438 "BGP specific commands\n"
2439 "Configure BGP defaults\n"
2440 "Show hostname in certain command outputs\n")
2442 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2443 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2447 DEFUN (no_bgp_default_show_hostname
,
2448 no_bgp_default_show_hostname_cmd
,
2449 "no bgp default show-hostname",
2451 "BGP specific commands\n"
2452 "Configure BGP defaults\n"
2453 "Show hostname in certain command outputs\n")
2455 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2456 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2460 /* "bgp network import-check" configuration. */
2461 DEFUN (bgp_network_import_check
,
2462 bgp_network_import_check_cmd
,
2463 "bgp network import-check",
2464 "BGP specific commands\n"
2465 "BGP network command\n"
2466 "Check BGP network route exists in IGP\n")
2468 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2469 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2470 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2471 bgp_static_redo_import_check(bgp
);
2477 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2478 "bgp network import-check exact",
2479 "BGP specific commands\n"
2480 "BGP network command\n"
2481 "Check BGP network route exists in IGP\n"
2482 "Match route precisely\n")
2484 DEFUN (no_bgp_network_import_check
,
2485 no_bgp_network_import_check_cmd
,
2486 "no bgp network import-check",
2488 "BGP specific commands\n"
2489 "BGP network command\n"
2490 "Check BGP network route exists in IGP\n")
2492 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2493 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2494 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2495 bgp_static_redo_import_check(bgp
);
2501 DEFUN (bgp_default_local_preference
,
2502 bgp_default_local_preference_cmd
,
2503 "bgp default local-preference (0-4294967295)",
2504 "BGP specific commands\n"
2505 "Configure BGP defaults\n"
2506 "local preference (higher=more preferred)\n"
2507 "Configure default local preference value\n")
2509 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2511 uint32_t local_pref
;
2513 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2515 bgp_default_local_preference_set(bgp
, local_pref
);
2516 bgp_clear_star_soft_in(vty
, bgp
->name
);
2521 DEFUN (no_bgp_default_local_preference
,
2522 no_bgp_default_local_preference_cmd
,
2523 "no bgp default local-preference [(0-4294967295)]",
2525 "BGP specific commands\n"
2526 "Configure BGP defaults\n"
2527 "local preference (higher=more preferred)\n"
2528 "Configure default local preference value\n")
2530 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2531 bgp_default_local_preference_unset(bgp
);
2532 bgp_clear_star_soft_in(vty
, bgp
->name
);
2538 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2539 bgp_default_subgroup_pkt_queue_max_cmd
,
2540 "bgp default subgroup-pkt-queue-max (20-100)",
2541 "BGP specific commands\n"
2542 "Configure BGP defaults\n"
2543 "subgroup-pkt-queue-max\n"
2544 "Configure subgroup packet queue max\n")
2546 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2550 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2552 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2557 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2558 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2559 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2561 "BGP specific commands\n"
2562 "Configure BGP defaults\n"
2563 "subgroup-pkt-queue-max\n"
2564 "Configure subgroup packet queue max\n")
2566 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2567 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2572 DEFUN (bgp_rr_allow_outbound_policy
,
2573 bgp_rr_allow_outbound_policy_cmd
,
2574 "bgp route-reflector allow-outbound-policy",
2575 "BGP specific commands\n"
2576 "Allow modifications made by out route-map\n"
2577 "on ibgp neighbors\n")
2579 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2581 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2582 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2583 update_group_announce_rrclients(bgp
);
2584 bgp_clear_star_soft_out(vty
, bgp
->name
);
2590 DEFUN (no_bgp_rr_allow_outbound_policy
,
2591 no_bgp_rr_allow_outbound_policy_cmd
,
2592 "no bgp route-reflector allow-outbound-policy",
2594 "BGP specific commands\n"
2595 "Allow modifications made by out route-map\n"
2596 "on ibgp neighbors\n")
2598 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2600 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2601 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2602 update_group_announce_rrclients(bgp
);
2603 bgp_clear_star_soft_out(vty
, bgp
->name
);
2609 DEFUN (bgp_listen_limit
,
2610 bgp_listen_limit_cmd
,
2611 "bgp listen limit (1-5000)",
2612 "BGP specific commands\n"
2613 "Configure BGP defaults\n"
2614 "maximum number of BGP Dynamic Neighbors that can be created\n"
2615 "Configure Dynamic Neighbors listen limit value\n")
2617 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2621 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2623 bgp_listen_limit_set(bgp
, listen_limit
);
2628 DEFUN (no_bgp_listen_limit
,
2629 no_bgp_listen_limit_cmd
,
2630 "no bgp listen limit [(1-5000)]",
2631 "BGP specific commands\n"
2632 "Configure BGP defaults\n"
2633 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2634 "Configure Dynamic Neighbors listen limit value to default\n"
2635 "Configure Dynamic Neighbors listen limit value\n")
2637 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2638 bgp_listen_limit_unset(bgp
);
2644 * Check if this listen range is already configured. Check for exact
2645 * match or overlap based on input.
2647 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2648 struct prefix
*range
, int exact
)
2650 struct listnode
*node
, *nnode
;
2651 struct listnode
*node1
, *nnode1
;
2652 struct peer_group
*group
;
2657 afi
= family2afi(range
->family
);
2658 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2659 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2662 match
= prefix_same(range
, lr
);
2664 match
= (prefix_match(range
, lr
)
2665 || prefix_match(lr
, range
));
2674 DEFUN (bgp_listen_range
,
2675 bgp_listen_range_cmd
,
2676 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
2677 "BGP specific commands\n"
2678 "Configure BGP dynamic neighbors listen range\n"
2679 "Configure BGP dynamic neighbors listen range\n"
2681 "Member of the peer-group\n"
2682 "Peer-group name\n")
2684 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2685 struct prefix range
;
2686 struct peer_group
*group
, *existing_group
;
2691 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2692 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2693 char *prefix
= argv
[idx
]->arg
;
2694 argv_find(argv
, argc
, "PGNAME", &idx
);
2695 char *peergroup
= argv
[idx
]->arg
;
2697 /* Convert IP prefix string to struct prefix. */
2698 ret
= str2prefix(prefix
, &range
);
2700 vty_out(vty
, "%% Malformed listen range\n");
2701 return CMD_WARNING_CONFIG_FAILED
;
2704 afi
= family2afi(range
.family
);
2706 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2708 "%% Malformed listen range (link-local address)\n");
2709 return CMD_WARNING_CONFIG_FAILED
;
2714 /* Check if same listen range is already configured. */
2715 existing_group
= listen_range_exists(bgp
, &range
, 1);
2716 if (existing_group
) {
2717 if (strcmp(existing_group
->name
, peergroup
) == 0)
2721 "%% Same listen range is attached to peer-group %s\n",
2722 existing_group
->name
);
2723 return CMD_WARNING_CONFIG_FAILED
;
2727 /* Check if an overlapping listen range exists. */
2728 if (listen_range_exists(bgp
, &range
, 0)) {
2730 "%% Listen range overlaps with existing listen range\n");
2731 return CMD_WARNING_CONFIG_FAILED
;
2734 group
= peer_group_lookup(bgp
, peergroup
);
2736 vty_out(vty
, "%% Configure the peer-group first\n");
2737 return CMD_WARNING_CONFIG_FAILED
;
2740 ret
= peer_group_listen_range_add(group
, &range
);
2741 return bgp_vty_return(vty
, ret
);
2744 DEFUN (no_bgp_listen_range
,
2745 no_bgp_listen_range_cmd
,
2746 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
2748 "BGP specific commands\n"
2749 "Unconfigure BGP dynamic neighbors listen range\n"
2750 "Unconfigure BGP dynamic neighbors listen range\n"
2752 "Member of the peer-group\n"
2753 "Peer-group name\n")
2755 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2756 struct prefix range
;
2757 struct peer_group
*group
;
2762 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2763 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2764 char *prefix
= argv
[idx
]->arg
;
2765 argv_find(argv
, argc
, "WORD", &idx
);
2766 char *peergroup
= argv
[idx
]->arg
;
2768 /* Convert IP prefix string to struct prefix. */
2769 ret
= str2prefix(prefix
, &range
);
2771 vty_out(vty
, "%% Malformed listen range\n");
2772 return CMD_WARNING_CONFIG_FAILED
;
2775 afi
= family2afi(range
.family
);
2777 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2779 "%% Malformed listen range (link-local address)\n");
2780 return CMD_WARNING_CONFIG_FAILED
;
2785 group
= peer_group_lookup(bgp
, peergroup
);
2787 vty_out(vty
, "%% Peer-group does not exist\n");
2788 return CMD_WARNING_CONFIG_FAILED
;
2791 ret
= peer_group_listen_range_del(group
, &range
);
2792 return bgp_vty_return(vty
, ret
);
2795 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2797 struct peer_group
*group
;
2798 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2799 struct prefix
*range
;
2801 char buf
[PREFIX2STR_BUFFER
];
2803 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2804 vty_out(vty
, " bgp listen limit %d\n",
2805 bgp
->dynamic_neighbors_limit
);
2807 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2808 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2809 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2811 prefix2str(range
, buf
, sizeof(buf
));
2813 " bgp listen range %s peer-group %s\n",
2821 DEFUN (bgp_disable_connected_route_check
,
2822 bgp_disable_connected_route_check_cmd
,
2823 "bgp disable-ebgp-connected-route-check",
2824 "BGP specific commands\n"
2825 "Disable checking if nexthop is connected on ebgp sessions\n")
2827 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2828 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2829 bgp_clear_star_soft_in(vty
, bgp
->name
);
2834 DEFUN (no_bgp_disable_connected_route_check
,
2835 no_bgp_disable_connected_route_check_cmd
,
2836 "no bgp disable-ebgp-connected-route-check",
2838 "BGP specific commands\n"
2839 "Disable checking if nexthop is connected on ebgp sessions\n")
2841 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2842 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2843 bgp_clear_star_soft_in(vty
, bgp
->name
);
2849 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2850 const char *as_str
, afi_t afi
, safi_t safi
)
2852 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2855 int as_type
= AS_SPECIFIED
;
2858 if (as_str
[0] == 'i') {
2860 as_type
= AS_INTERNAL
;
2861 } else if (as_str
[0] == 'e') {
2863 as_type
= AS_EXTERNAL
;
2865 /* Get AS number. */
2866 as
= strtoul(as_str
, NULL
, 10);
2869 /* If peer is peer group or interface peer, call proper function. */
2870 ret
= str2sockunion(peer_str
, &su
);
2874 /* Check if existing interface peer */
2875 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
2877 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2880 /* if not interface peer, check peer-group settings */
2881 if (ret
< 0 && !peer
) {
2882 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2885 "%% Create the peer-group or interface first\n");
2886 return CMD_WARNING_CONFIG_FAILED
;
2891 if (peer_address_self_check(bgp
, &su
)) {
2893 "%% Can not configure the local system as neighbor\n");
2894 return CMD_WARNING_CONFIG_FAILED
;
2896 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2899 /* This peer belongs to peer group. */
2901 case BGP_ERR_PEER_GROUP_MEMBER
:
2903 "%% Peer-group member cannot override remote-as of peer-group\n");
2904 return CMD_WARNING_CONFIG_FAILED
;
2905 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2907 "%% Peer-group members must be all internal or all external\n");
2908 return CMD_WARNING_CONFIG_FAILED
;
2910 return bgp_vty_return(vty
, ret
);
2913 DEFUN (bgp_default_shutdown
,
2914 bgp_default_shutdown_cmd
,
2915 "[no] bgp default shutdown",
2918 "Configure BGP defaults\n"
2919 "Apply administrative shutdown to newly configured peers\n")
2921 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2922 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2926 DEFUN (neighbor_remote_as
,
2927 neighbor_remote_as_cmd
,
2928 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2931 "Specify a BGP neighbor\n"
2933 "Internal BGP peer\n"
2934 "External BGP peer\n")
2937 int idx_remote_as
= 3;
2938 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2939 argv
[idx_remote_as
]->arg
, AFI_IP
,
2943 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2944 afi_t afi
, safi_t safi
, int v6only
,
2945 const char *peer_group_name
,
2948 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2950 int as_type
= AS_UNSPECIFIED
;
2952 struct peer_group
*group
;
2956 group
= peer_group_lookup(bgp
, conf_if
);
2959 vty_out(vty
, "%% Name conflict with peer-group \n");
2960 return CMD_WARNING_CONFIG_FAILED
;
2964 if (as_str
[0] == 'i') {
2965 as_type
= AS_INTERNAL
;
2966 } else if (as_str
[0] == 'e') {
2967 as_type
= AS_EXTERNAL
;
2969 /* Get AS number. */
2970 as
= strtoul(as_str
, NULL
, 10);
2971 as_type
= AS_SPECIFIED
;
2975 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2978 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
2981 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2982 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2983 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2984 as_type
, 0, 0, NULL
);
2986 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2987 as_type
, afi
, safi
, NULL
);
2990 vty_out(vty
, "%% BGP failed to create peer\n");
2991 return CMD_WARNING_CONFIG_FAILED
;
2995 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2997 /* Request zebra to initiate IPv6 RAs on this interface. We do
2999 * any unnumbered peer in order to not worry about run-time
3001 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
3003 * gets deleted later etc.)
3006 bgp_zebra_initiate_radv(bgp
, peer
);
3009 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
3010 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
3012 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
3014 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
3016 /* v6only flag changed. Reset bgp seesion */
3017 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
3018 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
3019 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
3020 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
3022 bgp_session_reset(peer
);
3025 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
3026 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
3027 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
3028 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
3031 if (peer_group_name
) {
3032 group
= peer_group_lookup(bgp
, peer_group_name
);
3034 vty_out(vty
, "%% Configure the peer-group first\n");
3035 return CMD_WARNING_CONFIG_FAILED
;
3038 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3041 return bgp_vty_return(vty
, ret
);
3044 DEFUN (neighbor_interface_config
,
3045 neighbor_interface_config_cmd
,
3046 "neighbor WORD interface [peer-group PGNAME]",
3048 "Interface name or neighbor tag\n"
3049 "Enable BGP on interface\n"
3050 "Member of the peer-group\n"
3051 "Peer-group name\n")
3054 int idx_peer_group_word
= 4;
3056 if (argc
> idx_peer_group_word
)
3057 return peer_conf_interface_get(
3058 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
3059 argv
[idx_peer_group_word
]->arg
, NULL
);
3061 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3062 SAFI_UNICAST
, 0, NULL
, NULL
);
3065 DEFUN (neighbor_interface_config_v6only
,
3066 neighbor_interface_config_v6only_cmd
,
3067 "neighbor WORD interface v6only [peer-group PGNAME]",
3069 "Interface name or neighbor tag\n"
3070 "Enable BGP on interface\n"
3071 "Enable BGP with v6 link-local only\n"
3072 "Member of the peer-group\n"
3073 "Peer-group name\n")
3076 int idx_peer_group_word
= 5;
3078 if (argc
> idx_peer_group_word
)
3079 return peer_conf_interface_get(
3080 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
3081 argv
[idx_peer_group_word
]->arg
, NULL
);
3083 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3084 SAFI_UNICAST
, 1, NULL
, NULL
);
3088 DEFUN (neighbor_interface_config_remote_as
,
3089 neighbor_interface_config_remote_as_cmd
,
3090 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
3092 "Interface name or neighbor tag\n"
3093 "Enable BGP on interface\n"
3094 "Specify a BGP neighbor\n"
3096 "Internal BGP peer\n"
3097 "External BGP peer\n")
3100 int idx_remote_as
= 4;
3101 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3102 SAFI_UNICAST
, 0, NULL
,
3103 argv
[idx_remote_as
]->arg
);
3106 DEFUN (neighbor_interface_v6only_config_remote_as
,
3107 neighbor_interface_v6only_config_remote_as_cmd
,
3108 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
3110 "Interface name or neighbor tag\n"
3111 "Enable BGP with v6 link-local only\n"
3112 "Enable BGP on interface\n"
3113 "Specify a BGP neighbor\n"
3115 "Internal BGP peer\n"
3116 "External BGP peer\n")
3119 int idx_remote_as
= 5;
3120 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3121 SAFI_UNICAST
, 1, NULL
,
3122 argv
[idx_remote_as
]->arg
);
3125 DEFUN (neighbor_peer_group
,
3126 neighbor_peer_group_cmd
,
3127 "neighbor WORD peer-group",
3129 "Interface name or neighbor tag\n"
3130 "Configure peer-group\n")
3132 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3135 struct peer_group
*group
;
3137 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3139 vty_out(vty
, "%% Name conflict with interface: \n");
3140 return CMD_WARNING_CONFIG_FAILED
;
3143 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
3145 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
3146 return CMD_WARNING_CONFIG_FAILED
;
3154 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3158 "Specify a BGP neighbor\n"
3160 "Internal BGP peer\n"
3161 "External BGP peer\n")
3163 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3167 struct peer_group
*group
;
3171 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3173 /* look up for neighbor by interface name config. */
3174 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3176 /* Request zebra to terminate IPv6 RAs on this
3179 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3184 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3186 peer_group_delete(group
);
3188 vty_out(vty
, "%% Create the peer-group first\n");
3189 return CMD_WARNING_CONFIG_FAILED
;
3192 peer
= peer_lookup(bgp
, &su
);
3194 if (peer_dynamic_neighbor(peer
)) {
3196 "%% Operation not allowed on a dynamic neighbor\n");
3197 return CMD_WARNING_CONFIG_FAILED
;
3200 other
= peer
->doppelganger
;
3202 if (other
&& other
->status
!= Deleted
)
3210 DEFUN (no_neighbor_interface_config
,
3211 no_neighbor_interface_config_cmd
,
3212 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
3216 "Configure BGP on interface\n"
3217 "Enable BGP with v6 link-local only\n"
3218 "Member of the peer-group\n"
3220 "Specify a BGP neighbor\n"
3222 "Internal BGP peer\n"
3223 "External BGP peer\n")
3225 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3229 /* look up for neighbor by interface name config. */
3230 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3232 /* Request zebra to terminate IPv6 RAs on this interface. */
3234 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3237 vty_out(vty
, "%% Create the bgp interface first\n");
3238 return CMD_WARNING_CONFIG_FAILED
;
3243 DEFUN (no_neighbor_peer_group
,
3244 no_neighbor_peer_group_cmd
,
3245 "no neighbor WORD peer-group",
3249 "Configure peer-group\n")
3251 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3253 struct peer_group
*group
;
3255 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3257 peer_group_delete(group
);
3259 vty_out(vty
, "%% Create the peer-group first\n");
3260 return CMD_WARNING_CONFIG_FAILED
;
3265 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3266 no_neighbor_interface_peer_group_remote_as_cmd
,
3267 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3270 "Interface name or neighbor tag\n"
3271 "Specify a BGP neighbor\n"
3273 "Internal BGP peer\n"
3274 "External BGP peer\n")
3276 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3278 struct peer_group
*group
;
3281 /* look up for neighbor by interface name config. */
3282 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3284 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
3288 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3290 peer_group_remote_as_delete(group
);
3292 vty_out(vty
, "%% Create the peer-group or interface first\n");
3293 return CMD_WARNING_CONFIG_FAILED
;
3298 DEFUN (neighbor_local_as
,
3299 neighbor_local_as_cmd
,
3300 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3303 "Specify a local-as number\n"
3304 "AS number used as local AS\n")
3312 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3314 return CMD_WARNING_CONFIG_FAILED
;
3316 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3317 ret
= peer_local_as_set(peer
, as
, 0, 0);
3318 return bgp_vty_return(vty
, ret
);
3321 DEFUN (neighbor_local_as_no_prepend
,
3322 neighbor_local_as_no_prepend_cmd
,
3323 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3326 "Specify a local-as number\n"
3327 "AS number used as local AS\n"
3328 "Do not prepend local-as to updates from ebgp peers\n")
3336 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3338 return CMD_WARNING_CONFIG_FAILED
;
3340 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3341 ret
= peer_local_as_set(peer
, as
, 1, 0);
3342 return bgp_vty_return(vty
, ret
);
3345 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3346 neighbor_local_as_no_prepend_replace_as_cmd
,
3347 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3350 "Specify a local-as number\n"
3351 "AS number used as local AS\n"
3352 "Do not prepend local-as to updates from ebgp peers\n"
3353 "Do not prepend local-as to updates from ibgp peers\n")
3361 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3363 return CMD_WARNING_CONFIG_FAILED
;
3365 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3366 ret
= peer_local_as_set(peer
, as
, 1, 1);
3367 return bgp_vty_return(vty
, ret
);
3370 DEFUN (no_neighbor_local_as
,
3371 no_neighbor_local_as_cmd
,
3372 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3376 "Specify a local-as number\n"
3377 "AS number used as local AS\n"
3378 "Do not prepend local-as to updates from ebgp peers\n"
3379 "Do not prepend local-as to updates from ibgp peers\n")
3385 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3387 return CMD_WARNING_CONFIG_FAILED
;
3389 ret
= peer_local_as_unset(peer
);
3390 return bgp_vty_return(vty
, ret
);
3394 DEFUN (neighbor_solo
,
3396 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3399 "Solo peer - part of its own update group\n")
3405 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3407 return CMD_WARNING_CONFIG_FAILED
;
3409 ret
= update_group_adjust_soloness(peer
, 1);
3410 return bgp_vty_return(vty
, ret
);
3413 DEFUN (no_neighbor_solo
,
3414 no_neighbor_solo_cmd
,
3415 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3419 "Solo peer - part of its own update group\n")
3425 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3427 return CMD_WARNING_CONFIG_FAILED
;
3429 ret
= update_group_adjust_soloness(peer
, 0);
3430 return bgp_vty_return(vty
, ret
);
3433 DEFUN (neighbor_password
,
3434 neighbor_password_cmd
,
3435 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3446 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3448 return CMD_WARNING_CONFIG_FAILED
;
3450 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3451 return bgp_vty_return(vty
, ret
);
3454 DEFUN (no_neighbor_password
,
3455 no_neighbor_password_cmd
,
3456 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3467 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3469 return CMD_WARNING_CONFIG_FAILED
;
3471 ret
= peer_password_unset(peer
);
3472 return bgp_vty_return(vty
, ret
);
3475 DEFUN (neighbor_activate
,
3476 neighbor_activate_cmd
,
3477 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3480 "Enable the Address Family for this Neighbor\n")
3486 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3488 return CMD_WARNING_CONFIG_FAILED
;
3490 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3491 return bgp_vty_return(vty
, ret
);
3494 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3495 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3496 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3497 "Enable the Address Family for this Neighbor\n")
3499 DEFUN (no_neighbor_activate
,
3500 no_neighbor_activate_cmd
,
3501 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3505 "Enable the Address Family for this Neighbor\n")
3512 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3514 return CMD_WARNING_CONFIG_FAILED
;
3516 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3517 return bgp_vty_return(vty
, ret
);
3520 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3521 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3522 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3523 "Enable the Address Family for this Neighbor\n")
3525 DEFUN (neighbor_set_peer_group
,
3526 neighbor_set_peer_group_cmd
,
3527 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3530 "Member of the peer-group\n"
3531 "Peer-group name\n")
3533 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3540 struct peer_group
*group
;
3542 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3544 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3546 vty_out(vty
, "%% Malformed address or name: %s\n",
3547 argv
[idx_peer
]->arg
);
3548 return CMD_WARNING_CONFIG_FAILED
;
3551 if (peer_address_self_check(bgp
, &su
)) {
3553 "%% Can not configure the local system as neighbor\n");
3554 return CMD_WARNING_CONFIG_FAILED
;
3557 /* Disallow for dynamic neighbor. */
3558 peer
= peer_lookup(bgp
, &su
);
3559 if (peer
&& peer_dynamic_neighbor(peer
)) {
3561 "%% Operation not allowed on a dynamic neighbor\n");
3562 return CMD_WARNING_CONFIG_FAILED
;
3566 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3568 vty_out(vty
, "%% Configure the peer-group first\n");
3569 return CMD_WARNING_CONFIG_FAILED
;
3572 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3574 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3576 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3578 return CMD_WARNING_CONFIG_FAILED
;
3581 return bgp_vty_return(vty
, ret
);
3584 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3585 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3586 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3587 "Member of the peer-group\n"
3588 "Peer-group name\n")
3590 DEFUN (no_neighbor_set_peer_group
,
3591 no_neighbor_set_peer_group_cmd
,
3592 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3596 "Member of the peer-group\n"
3597 "Peer-group name\n")
3599 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3604 struct peer_group
*group
;
3606 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3608 return CMD_WARNING_CONFIG_FAILED
;
3610 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3612 vty_out(vty
, "%% Configure the peer-group first\n");
3613 return CMD_WARNING_CONFIG_FAILED
;
3616 ret
= peer_delete(peer
);
3618 return bgp_vty_return(vty
, ret
);
3621 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3622 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3623 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3624 "Member of the peer-group\n"
3625 "Peer-group name\n")
3627 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3628 uint32_t flag
, int set
)
3633 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3635 return CMD_WARNING_CONFIG_FAILED
;
3638 * If 'neighbor <interface>', then this is for directly connected peers,
3639 * we should not accept disable-connected-check.
3641 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3643 "%s is directly connected peer, cannot accept disable-"
3644 "connected-check\n",
3646 return CMD_WARNING_CONFIG_FAILED
;
3649 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3650 peer_tx_shutdown_message_unset(peer
);
3653 ret
= peer_flag_set(peer
, flag
);
3655 ret
= peer_flag_unset(peer
, flag
);
3657 return bgp_vty_return(vty
, ret
);
3660 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3662 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3665 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3668 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3671 /* neighbor passive. */
3672 DEFUN (neighbor_passive
,
3673 neighbor_passive_cmd
,
3674 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3677 "Don't send open messages to this neighbor\n")
3680 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3683 DEFUN (no_neighbor_passive
,
3684 no_neighbor_passive_cmd
,
3685 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3689 "Don't send open messages to this neighbor\n")
3692 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3695 /* neighbor shutdown. */
3696 DEFUN (neighbor_shutdown_msg
,
3697 neighbor_shutdown_msg_cmd
,
3698 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3701 "Administratively shut down this neighbor\n"
3702 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3703 "Shutdown message\n")
3709 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3713 return CMD_WARNING_CONFIG_FAILED
;
3714 message
= argv_concat(argv
, argc
, 4);
3715 peer_tx_shutdown_message_set(peer
, message
);
3716 XFREE(MTYPE_TMP
, message
);
3719 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3722 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3723 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3724 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3725 "Administratively shut down this neighbor\n")
3727 DEFUN (no_neighbor_shutdown_msg
,
3728 no_neighbor_shutdown_msg_cmd
,
3729 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3733 "Administratively shut down this neighbor\n"
3734 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3735 "Shutdown message\n")
3739 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3740 PEER_FLAG_SHUTDOWN
);
3743 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3744 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3745 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3746 "Administratively shut down this neighbor\n")
3748 /* neighbor capability dynamic. */
3749 DEFUN (neighbor_capability_dynamic
,
3750 neighbor_capability_dynamic_cmd
,
3751 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3754 "Advertise capability to the peer\n"
3755 "Advertise dynamic capability to this neighbor\n")
3758 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3759 PEER_FLAG_DYNAMIC_CAPABILITY
);
3762 DEFUN (no_neighbor_capability_dynamic
,
3763 no_neighbor_capability_dynamic_cmd
,
3764 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3768 "Advertise capability to the peer\n"
3769 "Advertise dynamic capability to this neighbor\n")
3772 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3773 PEER_FLAG_DYNAMIC_CAPABILITY
);
3776 /* neighbor dont-capability-negotiate */
3777 DEFUN (neighbor_dont_capability_negotiate
,
3778 neighbor_dont_capability_negotiate_cmd
,
3779 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3782 "Do not perform capability negotiation\n")
3785 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3786 PEER_FLAG_DONT_CAPABILITY
);
3789 DEFUN (no_neighbor_dont_capability_negotiate
,
3790 no_neighbor_dont_capability_negotiate_cmd
,
3791 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3795 "Do not perform capability negotiation\n")
3798 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3799 PEER_FLAG_DONT_CAPABILITY
);
3802 /* neighbor capability extended next hop encoding */
3803 DEFUN (neighbor_capability_enhe
,
3804 neighbor_capability_enhe_cmd
,
3805 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3808 "Advertise capability to the peer\n"
3809 "Advertise extended next-hop capability to the peer\n")
3812 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3813 PEER_FLAG_CAPABILITY_ENHE
);
3816 DEFUN (no_neighbor_capability_enhe
,
3817 no_neighbor_capability_enhe_cmd
,
3818 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3822 "Advertise capability to the peer\n"
3823 "Advertise extended next-hop capability to the peer\n")
3826 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3827 PEER_FLAG_CAPABILITY_ENHE
);
3830 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3831 afi_t afi
, safi_t safi
, uint32_t flag
,
3837 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3839 return CMD_WARNING_CONFIG_FAILED
;
3842 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3844 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3846 return bgp_vty_return(vty
, ret
);
3849 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3850 afi_t afi
, safi_t safi
, uint32_t flag
)
3852 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3855 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3856 afi_t afi
, safi_t safi
, uint32_t flag
)
3858 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3861 /* neighbor capability orf prefix-list. */
3862 DEFUN (neighbor_capability_orf_prefix
,
3863 neighbor_capability_orf_prefix_cmd
,
3864 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3867 "Advertise capability to the peer\n"
3868 "Advertise ORF capability to the peer\n"
3869 "Advertise prefixlist ORF capability to this neighbor\n"
3870 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3871 "Capability to RECEIVE the ORF from this neighbor\n"
3872 "Capability to SEND the ORF to this neighbor\n")
3875 int idx_send_recv
= 5;
3878 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3879 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3880 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3881 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3882 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3883 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3885 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3886 return CMD_WARNING_CONFIG_FAILED
;
3889 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3890 bgp_node_safi(vty
), flag
);
3894 neighbor_capability_orf_prefix
,
3895 neighbor_capability_orf_prefix_hidden_cmd
,
3896 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3897 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3898 "Advertise capability to the peer\n"
3899 "Advertise ORF capability to the peer\n"
3900 "Advertise prefixlist ORF capability to this neighbor\n"
3901 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3902 "Capability to RECEIVE the ORF from this neighbor\n"
3903 "Capability to SEND the ORF to this neighbor\n")
3905 DEFUN (no_neighbor_capability_orf_prefix
,
3906 no_neighbor_capability_orf_prefix_cmd
,
3907 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3911 "Advertise capability to the peer\n"
3912 "Advertise ORF capability to the peer\n"
3913 "Advertise prefixlist ORF capability to this neighbor\n"
3914 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3915 "Capability to RECEIVE the ORF from this neighbor\n"
3916 "Capability to SEND the ORF to this neighbor\n")
3919 int idx_send_recv
= 6;
3922 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3923 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3924 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3925 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3926 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3927 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3929 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3930 return CMD_WARNING_CONFIG_FAILED
;
3933 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3934 bgp_node_afi(vty
), bgp_node_safi(vty
),
3939 no_neighbor_capability_orf_prefix
,
3940 no_neighbor_capability_orf_prefix_hidden_cmd
,
3941 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3942 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3943 "Advertise capability to the peer\n"
3944 "Advertise ORF capability to the peer\n"
3945 "Advertise prefixlist ORF capability to this neighbor\n"
3946 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3947 "Capability to RECEIVE the ORF from this neighbor\n"
3948 "Capability to SEND the ORF to this neighbor\n")
3950 /* neighbor next-hop-self. */
3951 DEFUN (neighbor_nexthop_self
,
3952 neighbor_nexthop_self_cmd
,
3953 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3956 "Disable the next hop calculation for this neighbor\n")
3959 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3960 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3963 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3964 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3965 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3966 "Disable the next hop calculation for this neighbor\n")
3968 /* neighbor next-hop-self. */
3969 DEFUN (neighbor_nexthop_self_force
,
3970 neighbor_nexthop_self_force_cmd
,
3971 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3974 "Disable the next hop calculation for this neighbor\n"
3975 "Set the next hop to self for reflected routes\n")
3978 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3980 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3983 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3984 neighbor_nexthop_self_force_hidden_cmd
,
3985 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3986 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3987 "Disable the next hop calculation for this neighbor\n"
3988 "Set the next hop to self for reflected routes\n")
3990 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3991 neighbor_nexthop_self_all_hidden_cmd
,
3992 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
3993 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3994 "Disable the next hop calculation for this neighbor\n"
3995 "Set the next hop to self for reflected routes\n")
3997 DEFUN (no_neighbor_nexthop_self
,
3998 no_neighbor_nexthop_self_cmd
,
3999 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4003 "Disable the next hop calculation for this neighbor\n")
4006 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4007 bgp_node_afi(vty
), bgp_node_safi(vty
),
4008 PEER_FLAG_NEXTHOP_SELF
);
4011 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
4012 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4013 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4014 "Disable the next hop calculation for this neighbor\n")
4016 DEFUN (no_neighbor_nexthop_self_force
,
4017 no_neighbor_nexthop_self_force_cmd
,
4018 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4022 "Disable the next hop calculation for this neighbor\n"
4023 "Set the next hop to self for reflected routes\n")
4026 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4027 bgp_node_afi(vty
), bgp_node_safi(vty
),
4028 PEER_FLAG_FORCE_NEXTHOP_SELF
);
4031 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4032 no_neighbor_nexthop_self_force_hidden_cmd
,
4033 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4034 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4035 "Disable the next hop calculation for this neighbor\n"
4036 "Set the next hop to self for reflected routes\n")
4038 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4039 no_neighbor_nexthop_self_all_hidden_cmd
,
4040 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
4041 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4042 "Disable the next hop calculation for this neighbor\n"
4043 "Set the next hop to self for reflected routes\n")
4045 /* neighbor as-override */
4046 DEFUN (neighbor_as_override
,
4047 neighbor_as_override_cmd
,
4048 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4051 "Override ASNs in outbound updates if aspath equals remote-as\n")
4054 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4055 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
4058 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
4059 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4060 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4061 "Override ASNs in outbound updates if aspath equals remote-as\n")
4063 DEFUN (no_neighbor_as_override
,
4064 no_neighbor_as_override_cmd
,
4065 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4069 "Override ASNs in outbound updates if aspath equals remote-as\n")
4072 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4073 bgp_node_afi(vty
), bgp_node_safi(vty
),
4074 PEER_FLAG_AS_OVERRIDE
);
4077 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
4078 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4079 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4080 "Override ASNs in outbound updates if aspath equals remote-as\n")
4082 /* neighbor remove-private-AS. */
4083 DEFUN (neighbor_remove_private_as
,
4084 neighbor_remove_private_as_cmd
,
4085 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4088 "Remove private ASNs in outbound updates\n")
4091 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4093 PEER_FLAG_REMOVE_PRIVATE_AS
);
4096 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
4097 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4098 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4099 "Remove private ASNs in outbound updates\n")
4101 DEFUN (neighbor_remove_private_as_all
,
4102 neighbor_remove_private_as_all_cmd
,
4103 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4106 "Remove private ASNs in outbound updates\n"
4107 "Apply to all AS numbers\n")
4110 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4112 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4115 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
4116 neighbor_remove_private_as_all_hidden_cmd
,
4117 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4118 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4119 "Remove private ASNs in outbound updates\n"
4120 "Apply to all AS numbers")
4122 DEFUN (neighbor_remove_private_as_replace_as
,
4123 neighbor_remove_private_as_replace_as_cmd
,
4124 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4127 "Remove private ASNs in outbound updates\n"
4128 "Replace private ASNs with our ASN in outbound updates\n")
4131 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4133 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4136 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
4137 neighbor_remove_private_as_replace_as_hidden_cmd
,
4138 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4139 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4140 "Remove private ASNs in outbound updates\n"
4141 "Replace private ASNs with our ASN in outbound updates\n")
4143 DEFUN (neighbor_remove_private_as_all_replace_as
,
4144 neighbor_remove_private_as_all_replace_as_cmd
,
4145 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4148 "Remove private ASNs in outbound updates\n"
4149 "Apply to all AS numbers\n"
4150 "Replace private ASNs with our ASN in outbound updates\n")
4153 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4155 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4159 neighbor_remove_private_as_all_replace_as
,
4160 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4161 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4162 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4163 "Remove private ASNs in outbound updates\n"
4164 "Apply to all AS numbers\n"
4165 "Replace private ASNs with our ASN in outbound updates\n")
4167 DEFUN (no_neighbor_remove_private_as
,
4168 no_neighbor_remove_private_as_cmd
,
4169 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4173 "Remove private ASNs in outbound updates\n")
4176 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4177 bgp_node_afi(vty
), bgp_node_safi(vty
),
4178 PEER_FLAG_REMOVE_PRIVATE_AS
);
4181 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4182 no_neighbor_remove_private_as_hidden_cmd
,
4183 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4184 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4185 "Remove private ASNs in outbound updates\n")
4187 DEFUN (no_neighbor_remove_private_as_all
,
4188 no_neighbor_remove_private_as_all_cmd
,
4189 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4193 "Remove private ASNs in outbound updates\n"
4194 "Apply to all AS numbers\n")
4197 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4198 bgp_node_afi(vty
), bgp_node_safi(vty
),
4199 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4202 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4203 no_neighbor_remove_private_as_all_hidden_cmd
,
4204 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4205 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4206 "Remove private ASNs in outbound updates\n"
4207 "Apply to all AS numbers\n")
4209 DEFUN (no_neighbor_remove_private_as_replace_as
,
4210 no_neighbor_remove_private_as_replace_as_cmd
,
4211 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4215 "Remove private ASNs in outbound updates\n"
4216 "Replace private ASNs with our ASN in outbound updates\n")
4219 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4220 bgp_node_afi(vty
), bgp_node_safi(vty
),
4221 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4224 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4225 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4226 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4227 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4228 "Remove private ASNs in outbound updates\n"
4229 "Replace private ASNs with our ASN in outbound updates\n")
4231 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4232 no_neighbor_remove_private_as_all_replace_as_cmd
,
4233 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4237 "Remove private ASNs in outbound updates\n"
4238 "Apply to all AS numbers\n"
4239 "Replace private ASNs with our ASN in outbound updates\n")
4242 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4243 bgp_node_afi(vty
), bgp_node_safi(vty
),
4244 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4248 no_neighbor_remove_private_as_all_replace_as
,
4249 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4250 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4251 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4252 "Remove private ASNs in outbound updates\n"
4253 "Apply to all AS numbers\n"
4254 "Replace private ASNs with our ASN in outbound updates\n")
4257 /* neighbor send-community. */
4258 DEFUN (neighbor_send_community
,
4259 neighbor_send_community_cmd
,
4260 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4263 "Send Community attribute to this neighbor\n")
4267 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4269 PEER_FLAG_SEND_COMMUNITY
);
4272 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4273 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4274 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4275 "Send Community attribute to this neighbor\n")
4277 DEFUN (no_neighbor_send_community
,
4278 no_neighbor_send_community_cmd
,
4279 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4283 "Send Community attribute to this neighbor\n")
4287 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4288 bgp_node_afi(vty
), bgp_node_safi(vty
),
4289 PEER_FLAG_SEND_COMMUNITY
);
4292 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4293 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4294 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4295 "Send Community attribute to this neighbor\n")
4297 /* neighbor send-community extended. */
4298 DEFUN (neighbor_send_community_type
,
4299 neighbor_send_community_type_cmd
,
4300 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4303 "Send Community attribute to this neighbor\n"
4304 "Send Standard and Extended Community attributes\n"
4305 "Send Standard, Large and Extended Community attributes\n"
4306 "Send Extended Community attributes\n"
4307 "Send Standard Community attributes\n"
4308 "Send Large Community attributes\n")
4312 const char *type
= argv
[argc
- 1]->text
;
4314 if (strmatch(type
, "standard")) {
4315 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4316 } else if (strmatch(type
, "extended")) {
4317 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4318 } else if (strmatch(type
, "large")) {
4319 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4320 } else if (strmatch(type
, "both")) {
4321 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4322 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4323 } else { /* if (strmatch(type, "all")) */
4324 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4325 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4326 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4329 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4330 bgp_node_safi(vty
), flag
);
4334 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4335 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4336 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4337 "Send Community attribute to this neighbor\n"
4338 "Send Standard and Extended Community attributes\n"
4339 "Send Standard, Large and Extended Community attributes\n"
4340 "Send Extended Community attributes\n"
4341 "Send Standard Community attributes\n"
4342 "Send Large Community attributes\n")
4344 DEFUN (no_neighbor_send_community_type
,
4345 no_neighbor_send_community_type_cmd
,
4346 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4350 "Send Community attribute to this neighbor\n"
4351 "Send Standard and Extended Community attributes\n"
4352 "Send Standard, Large and Extended Community attributes\n"
4353 "Send Extended Community attributes\n"
4354 "Send Standard Community attributes\n"
4355 "Send Large Community attributes\n")
4359 const char *type
= argv
[argc
- 1]->text
;
4361 if (strmatch(type
, "standard")) {
4362 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4363 } else if (strmatch(type
, "extended")) {
4364 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4365 } else if (strmatch(type
, "large")) {
4366 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4367 } else if (strmatch(type
, "both")) {
4368 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4369 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4370 } else { /* if (strmatch(type, "all")) */
4371 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4372 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4373 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4376 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4377 bgp_node_afi(vty
), bgp_node_safi(vty
),
4382 no_neighbor_send_community_type
,
4383 no_neighbor_send_community_type_hidden_cmd
,
4384 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4385 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4386 "Send Community attribute to this neighbor\n"
4387 "Send Standard and Extended Community attributes\n"
4388 "Send Standard, Large and Extended Community attributes\n"
4389 "Send Extended Community attributes\n"
4390 "Send Standard Community attributes\n"
4391 "Send Large Community attributes\n")
4393 /* neighbor soft-reconfig. */
4394 DEFUN (neighbor_soft_reconfiguration
,
4395 neighbor_soft_reconfiguration_cmd
,
4396 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4399 "Per neighbor soft reconfiguration\n"
4400 "Allow inbound soft reconfiguration for this neighbor\n")
4403 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4405 PEER_FLAG_SOFT_RECONFIG
);
4408 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4409 neighbor_soft_reconfiguration_hidden_cmd
,
4410 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4411 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4412 "Per neighbor soft reconfiguration\n"
4413 "Allow inbound soft reconfiguration for this neighbor\n")
4415 DEFUN (no_neighbor_soft_reconfiguration
,
4416 no_neighbor_soft_reconfiguration_cmd
,
4417 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4421 "Per neighbor soft reconfiguration\n"
4422 "Allow inbound soft reconfiguration for this neighbor\n")
4425 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4426 bgp_node_afi(vty
), bgp_node_safi(vty
),
4427 PEER_FLAG_SOFT_RECONFIG
);
4430 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4431 no_neighbor_soft_reconfiguration_hidden_cmd
,
4432 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4433 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4434 "Per neighbor soft reconfiguration\n"
4435 "Allow inbound soft reconfiguration for this neighbor\n")
4437 DEFUN (neighbor_route_reflector_client
,
4438 neighbor_route_reflector_client_cmd
,
4439 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4442 "Configure a neighbor as Route Reflector client\n")
4448 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4450 return CMD_WARNING_CONFIG_FAILED
;
4452 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4454 PEER_FLAG_REFLECTOR_CLIENT
);
4457 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4458 neighbor_route_reflector_client_hidden_cmd
,
4459 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4460 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4461 "Configure a neighbor as Route Reflector client\n")
4463 DEFUN (no_neighbor_route_reflector_client
,
4464 no_neighbor_route_reflector_client_cmd
,
4465 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4469 "Configure a neighbor as Route Reflector client\n")
4472 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4473 bgp_node_afi(vty
), bgp_node_safi(vty
),
4474 PEER_FLAG_REFLECTOR_CLIENT
);
4477 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4478 no_neighbor_route_reflector_client_hidden_cmd
,
4479 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4480 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4481 "Configure a neighbor as Route Reflector client\n")
4483 /* neighbor route-server-client. */
4484 DEFUN (neighbor_route_server_client
,
4485 neighbor_route_server_client_cmd
,
4486 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4489 "Configure a neighbor as Route Server client\n")
4494 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4496 return CMD_WARNING_CONFIG_FAILED
;
4497 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4499 PEER_FLAG_RSERVER_CLIENT
);
4502 ALIAS_HIDDEN(neighbor_route_server_client
,
4503 neighbor_route_server_client_hidden_cmd
,
4504 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4505 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4506 "Configure a neighbor as Route Server client\n")
4508 DEFUN (no_neighbor_route_server_client
,
4509 no_neighbor_route_server_client_cmd
,
4510 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4514 "Configure a neighbor as Route Server client\n")
4517 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4518 bgp_node_afi(vty
), bgp_node_safi(vty
),
4519 PEER_FLAG_RSERVER_CLIENT
);
4522 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4523 no_neighbor_route_server_client_hidden_cmd
,
4524 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4525 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4526 "Configure a neighbor as Route Server client\n")
4528 DEFUN (neighbor_nexthop_local_unchanged
,
4529 neighbor_nexthop_local_unchanged_cmd
,
4530 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4533 "Configure treatment of outgoing link-local nexthop attribute\n"
4534 "Leave link-local nexthop unchanged for this peer\n")
4537 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4539 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4542 DEFUN (no_neighbor_nexthop_local_unchanged
,
4543 no_neighbor_nexthop_local_unchanged_cmd
,
4544 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4548 "Configure treatment of outgoing link-local-nexthop attribute\n"
4549 "Leave link-local nexthop unchanged for this peer\n")
4552 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4553 bgp_node_afi(vty
), bgp_node_safi(vty
),
4554 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4557 DEFUN (neighbor_attr_unchanged
,
4558 neighbor_attr_unchanged_cmd
,
4559 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4562 "BGP attribute is propagated unchanged to this neighbor\n"
4563 "As-path attribute\n"
4564 "Nexthop attribute\n"
4568 char *peer_str
= argv
[1]->arg
;
4571 afi_t afi
= bgp_node_afi(vty
);
4572 safi_t safi
= bgp_node_safi(vty
);
4574 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4576 return CMD_WARNING_CONFIG_FAILED
;
4578 if (argv_find(argv
, argc
, "as-path", &idx
))
4579 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4581 if (argv_find(argv
, argc
, "next-hop", &idx
))
4582 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4584 if (argv_find(argv
, argc
, "med", &idx
))
4585 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4587 /* no flags means all of them! */
4589 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4590 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4591 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4593 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4594 && peer_af_flag_check(peer
, afi
, safi
,
4595 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4596 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4597 PEER_FLAG_AS_PATH_UNCHANGED
);
4600 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4601 && peer_af_flag_check(peer
, afi
, safi
,
4602 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4603 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4604 PEER_FLAG_NEXTHOP_UNCHANGED
);
4607 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4608 && peer_af_flag_check(peer
, afi
, safi
,
4609 PEER_FLAG_MED_UNCHANGED
)) {
4610 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4611 PEER_FLAG_MED_UNCHANGED
);
4615 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4619 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4620 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4621 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4622 "BGP attribute is propagated unchanged to this neighbor\n"
4623 "As-path attribute\n"
4624 "Nexthop attribute\n"
4627 DEFUN (no_neighbor_attr_unchanged
,
4628 no_neighbor_attr_unchanged_cmd
,
4629 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4633 "BGP attribute is propagated unchanged to this neighbor\n"
4634 "As-path attribute\n"
4635 "Nexthop attribute\n"
4639 char *peer
= argv
[2]->arg
;
4642 if (argv_find(argv
, argc
, "as-path", &idx
))
4643 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4645 if (argv_find(argv
, argc
, "next-hop", &idx
))
4646 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4648 if (argv_find(argv
, argc
, "med", &idx
))
4649 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4651 if (!flags
) // no flags means all of them!
4653 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4654 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4655 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4658 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4659 bgp_node_safi(vty
), flags
);
4663 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4664 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4665 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4666 "BGP attribute is propagated unchanged to this neighbor\n"
4667 "As-path attribute\n"
4668 "Nexthop attribute\n"
4671 /* EBGP multihop configuration. */
4672 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4673 const char *ttl_str
)
4678 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4680 return CMD_WARNING_CONFIG_FAILED
;
4683 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4688 ttl
= strtoul(ttl_str
, NULL
, 10);
4690 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4693 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4697 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4699 return CMD_WARNING_CONFIG_FAILED
;
4701 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4704 /* neighbor ebgp-multihop. */
4705 DEFUN (neighbor_ebgp_multihop
,
4706 neighbor_ebgp_multihop_cmd
,
4707 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4710 "Allow EBGP neighbors not on directly connected networks\n")
4713 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4716 DEFUN (neighbor_ebgp_multihop_ttl
,
4717 neighbor_ebgp_multihop_ttl_cmd
,
4718 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4721 "Allow EBGP neighbors not on directly connected networks\n"
4722 "maximum hop count\n")
4726 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4727 argv
[idx_number
]->arg
);
4730 DEFUN (no_neighbor_ebgp_multihop
,
4731 no_neighbor_ebgp_multihop_cmd
,
4732 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4736 "Allow EBGP neighbors not on directly connected networks\n"
4737 "maximum hop count\n")
4740 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4744 /* disable-connected-check */
4745 DEFUN (neighbor_disable_connected_check
,
4746 neighbor_disable_connected_check_cmd
,
4747 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4750 "one-hop away EBGP peer using loopback address\n"
4751 "Enforce EBGP neighbors perform multihop\n")
4754 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4755 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4758 DEFUN (no_neighbor_disable_connected_check
,
4759 no_neighbor_disable_connected_check_cmd
,
4760 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4764 "one-hop away EBGP peer using loopback address\n"
4765 "Enforce EBGP neighbors perform multihop\n")
4768 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4769 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4773 /* enforce-first-as */
4774 DEFUN (neighbor_enforce_first_as
,
4775 neighbor_enforce_first_as_cmd
,
4776 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4779 "Enforce the first AS for EBGP routes\n")
4783 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4784 PEER_FLAG_ENFORCE_FIRST_AS
);
4787 DEFUN (no_neighbor_enforce_first_as
,
4788 no_neighbor_enforce_first_as_cmd
,
4789 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4793 "Enforce the first AS for EBGP routes\n")
4797 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4798 PEER_FLAG_ENFORCE_FIRST_AS
);
4802 DEFUN (neighbor_description
,
4803 neighbor_description_cmd
,
4804 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4807 "Neighbor specific description\n"
4808 "Up to 80 characters describing this neighbor\n")
4815 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4817 return CMD_WARNING_CONFIG_FAILED
;
4819 str
= argv_concat(argv
, argc
, idx_line
);
4821 peer_description_set(peer
, str
);
4823 XFREE(MTYPE_TMP
, str
);
4828 DEFUN (no_neighbor_description
,
4829 no_neighbor_description_cmd
,
4830 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4834 "Neighbor specific description\n")
4839 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4841 return CMD_WARNING_CONFIG_FAILED
;
4843 peer_description_unset(peer
);
4848 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4849 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4850 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4851 "Neighbor specific description\n"
4852 "Up to 80 characters describing this neighbor\n")
4854 /* Neighbor update-source. */
4855 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4856 const char *source_str
)
4862 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4864 return CMD_WARNING_CONFIG_FAILED
;
4870 if (str2sockunion(source_str
, &su
) == 0)
4871 peer_update_source_addr_set(peer
, &su
);
4873 if (str2prefix(source_str
, &p
)) {
4875 "%% Invalid update-source, remove prefix length \n");
4876 return CMD_WARNING_CONFIG_FAILED
;
4878 peer_update_source_if_set(peer
, source_str
);
4881 peer_update_source_unset(peer
);
4886 #define BGP_UPDATE_SOURCE_HELP_STR \
4889 "Interface name (requires zebra to be running)\n"
4891 DEFUN (neighbor_update_source
,
4892 neighbor_update_source_cmd
,
4893 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4896 "Source of routing updates\n"
4897 BGP_UPDATE_SOURCE_HELP_STR
)
4901 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4902 argv
[idx_peer_2
]->arg
);
4905 DEFUN (no_neighbor_update_source
,
4906 no_neighbor_update_source_cmd
,
4907 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4911 "Source of routing updates\n"
4912 BGP_UPDATE_SOURCE_HELP_STR
)
4915 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4918 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4919 afi_t afi
, safi_t safi
,
4920 const char *rmap
, int set
)
4924 struct route_map
*route_map
= NULL
;
4926 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4928 return CMD_WARNING_CONFIG_FAILED
;
4932 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
4933 ret
= peer_default_originate_set(peer
, afi
, safi
,
4936 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4938 return bgp_vty_return(vty
, ret
);
4941 /* neighbor default-originate. */
4942 DEFUN (neighbor_default_originate
,
4943 neighbor_default_originate_cmd
,
4944 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4947 "Originate default route to this neighbor\n")
4950 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4952 bgp_node_safi(vty
), NULL
, 1);
4955 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4956 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4957 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4958 "Originate default route to this neighbor\n")
4960 DEFUN (neighbor_default_originate_rmap
,
4961 neighbor_default_originate_rmap_cmd
,
4962 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4965 "Originate default route to this neighbor\n"
4966 "Route-map to specify criteria to originate default\n"
4971 return peer_default_originate_set_vty(
4972 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4973 argv
[idx_word
]->arg
, 1);
4977 neighbor_default_originate_rmap
,
4978 neighbor_default_originate_rmap_hidden_cmd
,
4979 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4980 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4981 "Originate default route to this neighbor\n"
4982 "Route-map to specify criteria to originate default\n"
4985 DEFUN (no_neighbor_default_originate
,
4986 no_neighbor_default_originate_cmd
,
4987 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4991 "Originate default route to this neighbor\n"
4992 "Route-map to specify criteria to originate default\n"
4996 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4998 bgp_node_safi(vty
), NULL
, 0);
5002 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
5003 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
5004 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5005 "Originate default route to this neighbor\n"
5006 "Route-map to specify criteria to originate default\n"
5010 /* Set neighbor's BGP port. */
5011 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
5012 const char *port_str
)
5018 peer
= peer_lookup_vty(vty
, ip_str
);
5020 return CMD_WARNING_CONFIG_FAILED
;
5023 sp
= getservbyname("bgp", "tcp");
5024 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
5026 port
= strtoul(port_str
, NULL
, 10);
5029 peer_port_set(peer
, port
);
5034 /* Set specified peer's BGP port. */
5035 DEFUN (neighbor_port
,
5037 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
5040 "Neighbor's BGP port\n"
5041 "TCP port number\n")
5045 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
5046 argv
[idx_number
]->arg
);
5049 DEFUN (no_neighbor_port
,
5050 no_neighbor_port_cmd
,
5051 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
5055 "Neighbor's BGP port\n"
5056 "TCP port number\n")
5059 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
5063 /* neighbor weight. */
5064 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5065 safi_t safi
, const char *weight_str
)
5069 unsigned long weight
;
5071 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5073 return CMD_WARNING_CONFIG_FAILED
;
5075 weight
= strtoul(weight_str
, NULL
, 10);
5077 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
5078 return bgp_vty_return(vty
, ret
);
5081 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5087 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5089 return CMD_WARNING_CONFIG_FAILED
;
5091 ret
= peer_weight_unset(peer
, afi
, safi
);
5092 return bgp_vty_return(vty
, ret
);
5095 DEFUN (neighbor_weight
,
5096 neighbor_weight_cmd
,
5097 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5100 "Set default weight for routes from this neighbor\n"
5105 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5106 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
5109 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
5110 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5111 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5112 "Set default weight for routes from this neighbor\n"
5115 DEFUN (no_neighbor_weight
,
5116 no_neighbor_weight_cmd
,
5117 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5121 "Set default weight for routes from this neighbor\n"
5125 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
5126 bgp_node_afi(vty
), bgp_node_safi(vty
));
5129 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
5130 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5131 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5132 "Set default weight for routes from this neighbor\n"
5136 /* Override capability negotiation. */
5137 DEFUN (neighbor_override_capability
,
5138 neighbor_override_capability_cmd
,
5139 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5142 "Override capability negotiation result\n")
5145 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5146 PEER_FLAG_OVERRIDE_CAPABILITY
);
5149 DEFUN (no_neighbor_override_capability
,
5150 no_neighbor_override_capability_cmd
,
5151 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5155 "Override capability negotiation result\n")
5158 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5159 PEER_FLAG_OVERRIDE_CAPABILITY
);
5162 DEFUN (neighbor_strict_capability
,
5163 neighbor_strict_capability_cmd
,
5164 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5167 "Strict capability negotiation match\n")
5171 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5172 PEER_FLAG_STRICT_CAP_MATCH
);
5175 DEFUN (no_neighbor_strict_capability
,
5176 no_neighbor_strict_capability_cmd
,
5177 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5181 "Strict capability negotiation match\n")
5185 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5186 PEER_FLAG_STRICT_CAP_MATCH
);
5189 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5190 const char *keep_str
, const char *hold_str
)
5197 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5199 return CMD_WARNING_CONFIG_FAILED
;
5201 keepalive
= strtoul(keep_str
, NULL
, 10);
5202 holdtime
= strtoul(hold_str
, NULL
, 10);
5204 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5206 return bgp_vty_return(vty
, ret
);
5209 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5214 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5216 return CMD_WARNING_CONFIG_FAILED
;
5218 ret
= peer_timers_unset(peer
);
5220 return bgp_vty_return(vty
, ret
);
5223 DEFUN (neighbor_timers
,
5224 neighbor_timers_cmd
,
5225 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5228 "BGP per neighbor timers\n"
5229 "Keepalive interval\n"
5234 int idx_number_2
= 4;
5235 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5236 argv
[idx_number
]->arg
,
5237 argv
[idx_number_2
]->arg
);
5240 DEFUN (no_neighbor_timers
,
5241 no_neighbor_timers_cmd
,
5242 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5246 "BGP per neighbor timers\n"
5247 "Keepalive interval\n"
5251 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5255 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5256 const char *time_str
)
5262 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5264 return CMD_WARNING_CONFIG_FAILED
;
5266 connect
= strtoul(time_str
, NULL
, 10);
5268 ret
= peer_timers_connect_set(peer
, connect
);
5270 return bgp_vty_return(vty
, ret
);
5273 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5278 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5280 return CMD_WARNING_CONFIG_FAILED
;
5282 ret
= peer_timers_connect_unset(peer
);
5284 return bgp_vty_return(vty
, ret
);
5287 DEFUN (neighbor_timers_connect
,
5288 neighbor_timers_connect_cmd
,
5289 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5292 "BGP per neighbor timers\n"
5293 "BGP connect timer\n"
5298 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5299 argv
[idx_number
]->arg
);
5302 DEFUN (no_neighbor_timers_connect
,
5303 no_neighbor_timers_connect_cmd
,
5304 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5308 "BGP per neighbor timers\n"
5309 "BGP connect timer\n"
5313 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5317 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5318 const char *time_str
, int set
)
5322 uint32_t routeadv
= 0;
5324 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5326 return CMD_WARNING_CONFIG_FAILED
;
5329 routeadv
= strtoul(time_str
, NULL
, 10);
5332 ret
= peer_advertise_interval_set(peer
, routeadv
);
5334 ret
= peer_advertise_interval_unset(peer
);
5336 return bgp_vty_return(vty
, ret
);
5339 DEFUN (neighbor_advertise_interval
,
5340 neighbor_advertise_interval_cmd
,
5341 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5344 "Minimum interval between sending BGP routing updates\n"
5345 "time in seconds\n")
5349 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5350 argv
[idx_number
]->arg
, 1);
5353 DEFUN (no_neighbor_advertise_interval
,
5354 no_neighbor_advertise_interval_cmd
,
5355 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5359 "Minimum interval between sending BGP routing updates\n"
5360 "time in seconds\n")
5363 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5367 /* Time to wait before processing route-map updates */
5368 DEFUN (bgp_set_route_map_delay_timer
,
5369 bgp_set_route_map_delay_timer_cmd
,
5370 "bgp route-map delay-timer (0-600)",
5372 "BGP route-map delay timer\n"
5373 "Time in secs to wait before processing route-map changes\n"
5374 "0 disables the timer, no route updates happen when route-maps change\n")
5377 uint32_t rmap_delay_timer
;
5379 if (argv
[idx_number
]->arg
) {
5380 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5381 bm
->rmap_update_timer
= rmap_delay_timer
;
5383 /* if the dynamic update handling is being disabled, and a timer
5385 * running, stop the timer and act as if the timer has already
5388 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5389 BGP_TIMER_OFF(bm
->t_rmap_update
);
5390 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5395 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5396 return CMD_WARNING_CONFIG_FAILED
;
5400 DEFUN (no_bgp_set_route_map_delay_timer
,
5401 no_bgp_set_route_map_delay_timer_cmd
,
5402 "no bgp route-map delay-timer [(0-600)]",
5405 "Default BGP route-map delay timer\n"
5406 "Reset to default time to wait for processing route-map changes\n"
5407 "0 disables the timer, no route updates happen when route-maps change\n")
5410 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5416 /* neighbor interface */
5417 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5422 peer
= peer_lookup_vty(vty
, ip_str
);
5423 if (!peer
|| peer
->conf_if
) {
5424 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5425 return CMD_WARNING_CONFIG_FAILED
;
5429 peer_interface_set(peer
, str
);
5431 peer_interface_unset(peer
);
5436 DEFUN (neighbor_interface
,
5437 neighbor_interface_cmd
,
5438 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5446 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5449 DEFUN (no_neighbor_interface
,
5450 no_neighbor_interface_cmd
,
5451 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5459 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5462 DEFUN (neighbor_distribute_list
,
5463 neighbor_distribute_list_cmd
,
5464 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5467 "Filter updates to/from this neighbor\n"
5468 "IP access-list number\n"
5469 "IP access-list number (expanded range)\n"
5470 "IP Access-list name\n"
5471 "Filter incoming updates\n"
5472 "Filter outgoing updates\n")
5479 const char *pstr
= argv
[idx_peer
]->arg
;
5480 const char *acl
= argv
[idx_acl
]->arg
;
5481 const char *inout
= argv
[argc
- 1]->text
;
5483 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5485 return CMD_WARNING_CONFIG_FAILED
;
5487 /* Check filter direction. */
5488 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5489 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5492 return bgp_vty_return(vty
, ret
);
5496 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5497 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5498 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5499 "Filter updates to/from this neighbor\n"
5500 "IP access-list number\n"
5501 "IP access-list number (expanded range)\n"
5502 "IP Access-list name\n"
5503 "Filter incoming updates\n"
5504 "Filter outgoing updates\n")
5506 DEFUN (no_neighbor_distribute_list
,
5507 no_neighbor_distribute_list_cmd
,
5508 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5512 "Filter updates to/from this neighbor\n"
5513 "IP access-list number\n"
5514 "IP access-list number (expanded range)\n"
5515 "IP Access-list name\n"
5516 "Filter incoming updates\n"
5517 "Filter outgoing updates\n")
5523 const char *pstr
= argv
[idx_peer
]->arg
;
5524 const char *inout
= argv
[argc
- 1]->text
;
5526 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5528 return CMD_WARNING_CONFIG_FAILED
;
5530 /* Check filter direction. */
5531 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5532 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5535 return bgp_vty_return(vty
, ret
);
5539 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5540 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5541 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5542 "Filter updates to/from this neighbor\n"
5543 "IP access-list number\n"
5544 "IP access-list number (expanded range)\n"
5545 "IP Access-list name\n"
5546 "Filter incoming updates\n"
5547 "Filter outgoing updates\n")
5549 /* Set prefix list to the peer. */
5550 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5551 afi_t afi
, safi_t safi
,
5552 const char *name_str
,
5553 const char *direct_str
)
5556 int direct
= FILTER_IN
;
5559 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5561 return CMD_WARNING_CONFIG_FAILED
;
5563 /* Check filter direction. */
5564 if (strncmp(direct_str
, "i", 1) == 0)
5566 else if (strncmp(direct_str
, "o", 1) == 0)
5567 direct
= FILTER_OUT
;
5569 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5571 return bgp_vty_return(vty
, ret
);
5574 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5575 afi_t afi
, safi_t safi
,
5576 const char *direct_str
)
5580 int direct
= FILTER_IN
;
5582 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5584 return CMD_WARNING_CONFIG_FAILED
;
5586 /* Check filter direction. */
5587 if (strncmp(direct_str
, "i", 1) == 0)
5589 else if (strncmp(direct_str
, "o", 1) == 0)
5590 direct
= FILTER_OUT
;
5592 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5594 return bgp_vty_return(vty
, ret
);
5597 DEFUN (neighbor_prefix_list
,
5598 neighbor_prefix_list_cmd
,
5599 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5602 "Filter updates to/from this neighbor\n"
5603 "Name of a prefix list\n"
5604 "Filter incoming updates\n"
5605 "Filter outgoing updates\n")
5610 return peer_prefix_list_set_vty(
5611 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5612 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5615 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5616 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5617 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5618 "Filter updates to/from this neighbor\n"
5619 "Name of a prefix list\n"
5620 "Filter incoming updates\n"
5621 "Filter outgoing updates\n")
5623 DEFUN (no_neighbor_prefix_list
,
5624 no_neighbor_prefix_list_cmd
,
5625 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5629 "Filter updates to/from this neighbor\n"
5630 "Name of a prefix list\n"
5631 "Filter incoming updates\n"
5632 "Filter outgoing updates\n")
5636 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5637 bgp_node_afi(vty
), bgp_node_safi(vty
),
5638 argv
[idx_in_out
]->arg
);
5641 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5642 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5643 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5644 "Filter updates to/from this neighbor\n"
5645 "Name of a prefix list\n"
5646 "Filter incoming updates\n"
5647 "Filter outgoing updates\n")
5649 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5650 safi_t safi
, const char *name_str
,
5651 const char *direct_str
)
5655 int direct
= FILTER_IN
;
5657 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5659 return CMD_WARNING_CONFIG_FAILED
;
5661 /* Check filter direction. */
5662 if (strncmp(direct_str
, "i", 1) == 0)
5664 else if (strncmp(direct_str
, "o", 1) == 0)
5665 direct
= FILTER_OUT
;
5667 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5669 return bgp_vty_return(vty
, ret
);
5672 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5673 safi_t safi
, const char *direct_str
)
5677 int direct
= FILTER_IN
;
5679 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5681 return CMD_WARNING_CONFIG_FAILED
;
5683 /* Check filter direction. */
5684 if (strncmp(direct_str
, "i", 1) == 0)
5686 else if (strncmp(direct_str
, "o", 1) == 0)
5687 direct
= FILTER_OUT
;
5689 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5691 return bgp_vty_return(vty
, ret
);
5694 DEFUN (neighbor_filter_list
,
5695 neighbor_filter_list_cmd
,
5696 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5699 "Establish BGP filters\n"
5700 "AS path access-list name\n"
5701 "Filter incoming routes\n"
5702 "Filter outgoing routes\n")
5707 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5708 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5709 argv
[idx_in_out
]->arg
);
5712 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5713 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5714 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5715 "Establish BGP filters\n"
5716 "AS path access-list name\n"
5717 "Filter incoming routes\n"
5718 "Filter outgoing routes\n")
5720 DEFUN (no_neighbor_filter_list
,
5721 no_neighbor_filter_list_cmd
,
5722 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5726 "Establish BGP filters\n"
5727 "AS path access-list name\n"
5728 "Filter incoming routes\n"
5729 "Filter outgoing routes\n")
5733 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5734 bgp_node_afi(vty
), bgp_node_safi(vty
),
5735 argv
[idx_in_out
]->arg
);
5738 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5739 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5740 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5741 "Establish BGP filters\n"
5742 "AS path access-list name\n"
5743 "Filter incoming routes\n"
5744 "Filter outgoing routes\n")
5746 /* Set route-map to the peer. */
5747 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5748 afi_t afi
, safi_t safi
, const char *name_str
,
5749 const char *direct_str
)
5753 int direct
= RMAP_IN
;
5754 struct route_map
*route_map
;
5756 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5758 return CMD_WARNING_CONFIG_FAILED
;
5760 /* Check filter direction. */
5761 if (strncmp(direct_str
, "in", 2) == 0)
5763 else if (strncmp(direct_str
, "o", 1) == 0)
5766 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5767 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
5769 return bgp_vty_return(vty
, ret
);
5772 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5773 afi_t afi
, safi_t safi
,
5774 const char *direct_str
)
5778 int direct
= RMAP_IN
;
5780 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5782 return CMD_WARNING_CONFIG_FAILED
;
5784 /* Check filter direction. */
5785 if (strncmp(direct_str
, "in", 2) == 0)
5787 else if (strncmp(direct_str
, "o", 1) == 0)
5790 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5792 return bgp_vty_return(vty
, ret
);
5795 DEFUN (neighbor_route_map
,
5796 neighbor_route_map_cmd
,
5797 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5800 "Apply route map to neighbor\n"
5801 "Name of route map\n"
5802 "Apply map to incoming routes\n"
5803 "Apply map to outbound routes\n")
5808 return peer_route_map_set_vty(
5809 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5810 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5813 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5814 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5815 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5816 "Apply route map to neighbor\n"
5817 "Name of route map\n"
5818 "Apply map to incoming routes\n"
5819 "Apply map to outbound routes\n")
5821 DEFUN (no_neighbor_route_map
,
5822 no_neighbor_route_map_cmd
,
5823 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5827 "Apply route map to neighbor\n"
5828 "Name of route map\n"
5829 "Apply map to incoming routes\n"
5830 "Apply map to outbound routes\n")
5834 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5835 bgp_node_afi(vty
), bgp_node_safi(vty
),
5836 argv
[idx_in_out
]->arg
);
5839 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5840 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5841 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5842 "Apply route map to neighbor\n"
5843 "Name of route map\n"
5844 "Apply map to incoming routes\n"
5845 "Apply map to outbound routes\n")
5847 /* Set unsuppress-map to the peer. */
5848 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5849 afi_t afi
, safi_t safi
,
5850 const char *name_str
)
5854 struct route_map
*route_map
;
5856 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5858 return CMD_WARNING_CONFIG_FAILED
;
5860 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5861 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
5863 return bgp_vty_return(vty
, ret
);
5866 /* Unset route-map from the peer. */
5867 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5868 afi_t afi
, safi_t safi
)
5873 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5875 return CMD_WARNING_CONFIG_FAILED
;
5877 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5879 return bgp_vty_return(vty
, ret
);
5882 DEFUN (neighbor_unsuppress_map
,
5883 neighbor_unsuppress_map_cmd
,
5884 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5887 "Route-map to selectively unsuppress suppressed routes\n"
5888 "Name of route map\n")
5892 return peer_unsuppress_map_set_vty(
5893 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5894 argv
[idx_word
]->arg
);
5897 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5898 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5899 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5900 "Route-map to selectively unsuppress suppressed routes\n"
5901 "Name of route map\n")
5903 DEFUN (no_neighbor_unsuppress_map
,
5904 no_neighbor_unsuppress_map_cmd
,
5905 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5909 "Route-map to selectively unsuppress suppressed routes\n"
5910 "Name of route map\n")
5913 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5915 bgp_node_safi(vty
));
5918 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5919 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5920 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5921 "Route-map to selectively unsuppress suppressed routes\n"
5922 "Name of route map\n")
5924 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5925 afi_t afi
, safi_t safi
,
5926 const char *num_str
,
5927 const char *threshold_str
, int warning
,
5928 const char *restart_str
)
5936 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5938 return CMD_WARNING_CONFIG_FAILED
;
5940 max
= strtoul(num_str
, NULL
, 10);
5942 threshold
= atoi(threshold_str
);
5944 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5947 restart
= atoi(restart_str
);
5951 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5954 return bgp_vty_return(vty
, ret
);
5957 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5958 afi_t afi
, safi_t safi
)
5963 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5965 return CMD_WARNING_CONFIG_FAILED
;
5967 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5969 return bgp_vty_return(vty
, ret
);
5972 /* Maximum number of prefix configuration. prefix count is different
5973 for each peer configuration. So this configuration can be set for
5974 each peer configuration. */
5975 DEFUN (neighbor_maximum_prefix
,
5976 neighbor_maximum_prefix_cmd
,
5977 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5980 "Maximum number of prefix accept from this peer\n"
5981 "maximum no. of prefix limit\n")
5985 return peer_maximum_prefix_set_vty(
5986 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5987 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5990 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5991 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5992 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5993 "Maximum number of prefix accept from this peer\n"
5994 "maximum no. of prefix limit\n")
5996 DEFUN (neighbor_maximum_prefix_threshold
,
5997 neighbor_maximum_prefix_threshold_cmd
,
5998 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
6001 "Maximum number of prefix accept from this peer\n"
6002 "maximum no. of prefix limit\n"
6003 "Threshold value (%) at which to generate a warning msg\n")
6007 int idx_number_2
= 4;
6008 return peer_maximum_prefix_set_vty(
6009 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6010 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
6014 neighbor_maximum_prefix_threshold
,
6015 neighbor_maximum_prefix_threshold_hidden_cmd
,
6016 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
6017 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6018 "Maximum number of prefix accept from this peer\n"
6019 "maximum no. of prefix limit\n"
6020 "Threshold value (%) at which to generate a warning msg\n")
6022 DEFUN (neighbor_maximum_prefix_warning
,
6023 neighbor_maximum_prefix_warning_cmd
,
6024 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6027 "Maximum number of prefix accept from this peer\n"
6028 "maximum no. of prefix limit\n"
6029 "Only give warning message when limit is exceeded\n")
6033 return peer_maximum_prefix_set_vty(
6034 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6035 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
6039 neighbor_maximum_prefix_warning
,
6040 neighbor_maximum_prefix_warning_hidden_cmd
,
6041 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6042 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6043 "Maximum number of prefix accept from this peer\n"
6044 "maximum no. of prefix limit\n"
6045 "Only give warning message when limit is exceeded\n")
6047 DEFUN (neighbor_maximum_prefix_threshold_warning
,
6048 neighbor_maximum_prefix_threshold_warning_cmd
,
6049 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6052 "Maximum number of prefix accept from this peer\n"
6053 "maximum no. of prefix limit\n"
6054 "Threshold value (%) at which to generate a warning msg\n"
6055 "Only give warning message when limit is exceeded\n")
6059 int idx_number_2
= 4;
6060 return peer_maximum_prefix_set_vty(
6061 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6062 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
6066 neighbor_maximum_prefix_threshold_warning
,
6067 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
6068 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6069 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6070 "Maximum number of prefix accept from this peer\n"
6071 "maximum no. of prefix limit\n"
6072 "Threshold value (%) at which to generate a warning msg\n"
6073 "Only give warning message when limit is exceeded\n")
6075 DEFUN (neighbor_maximum_prefix_restart
,
6076 neighbor_maximum_prefix_restart_cmd
,
6077 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6080 "Maximum number of prefix accept from this peer\n"
6081 "maximum no. of prefix limit\n"
6082 "Restart bgp connection after limit is exceeded\n"
6083 "Restart interval in minutes\n")
6087 int idx_number_2
= 5;
6088 return peer_maximum_prefix_set_vty(
6089 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6090 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
6094 neighbor_maximum_prefix_restart
,
6095 neighbor_maximum_prefix_restart_hidden_cmd
,
6096 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6097 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6098 "Maximum number of prefix accept from this peer\n"
6099 "maximum no. of prefix limit\n"
6100 "Restart bgp connection after limit is exceeded\n"
6101 "Restart interval in minutes\n")
6103 DEFUN (neighbor_maximum_prefix_threshold_restart
,
6104 neighbor_maximum_prefix_threshold_restart_cmd
,
6105 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6108 "Maximum number of prefixes to accept from this peer\n"
6109 "maximum no. of prefix limit\n"
6110 "Threshold value (%) at which to generate a warning msg\n"
6111 "Restart bgp connection after limit is exceeded\n"
6112 "Restart interval in minutes\n")
6116 int idx_number_2
= 4;
6117 int idx_number_3
= 6;
6118 return peer_maximum_prefix_set_vty(
6119 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6120 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
6121 argv
[idx_number_3
]->arg
);
6125 neighbor_maximum_prefix_threshold_restart
,
6126 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
6127 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6128 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6129 "Maximum number of prefixes to accept from this peer\n"
6130 "maximum no. of prefix limit\n"
6131 "Threshold value (%) at which to generate a warning msg\n"
6132 "Restart bgp connection after limit is exceeded\n"
6133 "Restart interval in minutes\n")
6135 DEFUN (no_neighbor_maximum_prefix
,
6136 no_neighbor_maximum_prefix_cmd
,
6137 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6141 "Maximum number of prefixes to accept from this peer\n"
6142 "maximum no. of prefix limit\n"
6143 "Threshold value (%) at which to generate a warning msg\n"
6144 "Restart bgp connection after limit is exceeded\n"
6145 "Restart interval in minutes\n"
6146 "Only give warning message when limit is exceeded\n")
6149 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
6151 bgp_node_safi(vty
));
6155 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
6156 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6157 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6158 "Maximum number of prefixes to accept from this peer\n"
6159 "maximum no. of prefix limit\n"
6160 "Threshold value (%) at which to generate a warning msg\n"
6161 "Restart bgp connection after limit is exceeded\n"
6162 "Restart interval in minutes\n"
6163 "Only give warning message when limit is exceeded\n")
6166 /* "neighbor allowas-in" */
6167 DEFUN (neighbor_allowas_in
,
6168 neighbor_allowas_in_cmd
,
6169 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6172 "Accept as-path with my AS present in it\n"
6173 "Number of occurrences of AS number\n"
6174 "Only accept my AS in the as-path if the route was originated in my AS\n")
6177 int idx_number_origin
= 3;
6183 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6185 return CMD_WARNING_CONFIG_FAILED
;
6187 if (argc
<= idx_number_origin
)
6190 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6193 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6196 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6199 return bgp_vty_return(vty
, ret
);
6203 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6204 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6205 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6206 "Accept as-path with my AS present in it\n"
6207 "Number of occurrences of AS number\n"
6208 "Only accept my AS in the as-path if the route was originated in my AS\n")
6210 DEFUN (no_neighbor_allowas_in
,
6211 no_neighbor_allowas_in_cmd
,
6212 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6216 "allow local ASN appears in aspath attribute\n"
6217 "Number of occurrences of AS number\n"
6218 "Only accept my AS in the as-path if the route was originated in my AS\n")
6224 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6226 return CMD_WARNING_CONFIG_FAILED
;
6228 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6229 bgp_node_safi(vty
));
6231 return bgp_vty_return(vty
, ret
);
6235 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6236 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6237 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6238 "allow local ASN appears in aspath attribute\n"
6239 "Number of occurrences of AS number\n"
6240 "Only accept my AS in the as-path if the route was originated in my AS\n")
6242 DEFUN (neighbor_ttl_security
,
6243 neighbor_ttl_security_cmd
,
6244 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6247 "BGP ttl-security parameters\n"
6248 "Specify the maximum number of hops to the BGP peer\n"
6249 "Number of hops to BGP peer\n")
6256 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6258 return CMD_WARNING_CONFIG_FAILED
;
6260 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6263 * If 'neighbor swpX', then this is for directly connected peers,
6264 * we should not accept a ttl-security hops value greater than 1.
6266 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6268 "%s is directly connected peer, hops cannot exceed 1\n",
6269 argv
[idx_peer
]->arg
);
6270 return CMD_WARNING_CONFIG_FAILED
;
6273 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6276 DEFUN (no_neighbor_ttl_security
,
6277 no_neighbor_ttl_security_cmd
,
6278 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6282 "BGP ttl-security parameters\n"
6283 "Specify the maximum number of hops to the BGP peer\n"
6284 "Number of hops to BGP peer\n")
6289 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6291 return CMD_WARNING_CONFIG_FAILED
;
6293 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6296 DEFUN (neighbor_addpath_tx_all_paths
,
6297 neighbor_addpath_tx_all_paths_cmd
,
6298 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6301 "Use addpath to advertise all paths to a neighbor\n")
6306 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6308 return CMD_WARNING_CONFIG_FAILED
;
6310 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6315 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6316 neighbor_addpath_tx_all_paths_hidden_cmd
,
6317 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6318 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6319 "Use addpath to advertise all paths to a neighbor\n")
6321 DEFUN (no_neighbor_addpath_tx_all_paths
,
6322 no_neighbor_addpath_tx_all_paths_cmd
,
6323 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6327 "Use addpath to advertise all paths to a neighbor\n")
6332 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6334 return CMD_WARNING_CONFIG_FAILED
;
6336 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6337 != BGP_ADDPATH_ALL
) {
6339 "%% Peer not currently configured to transmit all paths.");
6340 return CMD_WARNING_CONFIG_FAILED
;
6343 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6349 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6350 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6351 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6352 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6353 "Use addpath to advertise all paths to a neighbor\n")
6355 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6356 neighbor_addpath_tx_bestpath_per_as_cmd
,
6357 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6360 "Use addpath to advertise the bestpath per each neighboring AS\n")
6365 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6367 return CMD_WARNING_CONFIG_FAILED
;
6369 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6370 BGP_ADDPATH_BEST_PER_AS
);
6375 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6376 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6377 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6378 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6379 "Use addpath to advertise the bestpath per each neighboring AS\n")
6381 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6382 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6383 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6387 "Use addpath to advertise the bestpath per each neighboring AS\n")
6392 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6394 return CMD_WARNING_CONFIG_FAILED
;
6396 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6397 != BGP_ADDPATH_BEST_PER_AS
) {
6399 "%% Peer not currently configured to transmit all best path per as.");
6400 return CMD_WARNING_CONFIG_FAILED
;
6403 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6409 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6410 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6411 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6412 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6413 "Use addpath to advertise the bestpath per each neighboring AS\n")
6415 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6416 struct ecommunity
**list
)
6418 struct ecommunity
*ecom
= NULL
;
6419 struct ecommunity
*ecomadd
;
6421 for (; argc
; --argc
, ++argv
) {
6423 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6424 ECOMMUNITY_ROUTE_TARGET
, 0);
6426 vty_out(vty
, "Malformed community-list value\n");
6428 ecommunity_free(&ecom
);
6429 return CMD_WARNING_CONFIG_FAILED
;
6433 ecommunity_merge(ecom
, ecomadd
);
6434 ecommunity_free(&ecomadd
);
6441 ecommunity_free(&*list
);
6449 * v2vimport is true if we are handling a `import vrf ...` command
6451 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6455 switch (vty
->node
) {
6464 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6469 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6470 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6471 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6472 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6474 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6478 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6479 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6480 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6481 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6483 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6490 DEFPY (af_rd_vpn_export
,
6491 af_rd_vpn_export_cmd
,
6492 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6494 "Specify route distinguisher\n"
6495 "Between current address-family and vpn\n"
6496 "For routes leaked from current address-family to vpn\n"
6497 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6499 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6500 struct prefix_rd prd
;
6506 if (argv_find(argv
, argc
, "no", &idx
))
6510 ret
= str2prefix_rd(rd_str
, &prd
);
6512 vty_out(vty
, "%% Malformed rd\n");
6513 return CMD_WARNING_CONFIG_FAILED
;
6517 afi
= vpn_policy_getafi(vty
, bgp
, false);
6519 return CMD_WARNING_CONFIG_FAILED
;
6522 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6524 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6525 bgp_get_default(), bgp
);
6528 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6529 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6530 BGP_VPN_POLICY_TOVPN_RD_SET
);
6532 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6533 BGP_VPN_POLICY_TOVPN_RD_SET
);
6536 /* post-change: re-export vpn routes */
6537 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6538 bgp_get_default(), bgp
);
6543 ALIAS (af_rd_vpn_export
,
6544 af_no_rd_vpn_export_cmd
,
6547 "Specify route distinguisher\n"
6548 "Between current address-family and vpn\n"
6549 "For routes leaked from current address-family to vpn\n")
6551 DEFPY (af_label_vpn_export
,
6552 af_label_vpn_export_cmd
,
6553 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6555 "label value for VRF\n"
6556 "Between current address-family and vpn\n"
6557 "For routes leaked from current address-family to vpn\n"
6558 "Label Value <0-1048575>\n"
6559 "Automatically assign a label\n")
6561 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6562 mpls_label_t label
= MPLS_LABEL_NONE
;
6567 if (argv_find(argv
, argc
, "no", &idx
))
6570 /* If "no ...", squash trailing parameter */
6576 label
= label_val
; /* parser should force unsigned */
6579 afi
= vpn_policy_getafi(vty
, bgp
, false);
6581 return CMD_WARNING_CONFIG_FAILED
;
6584 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6585 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6590 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6592 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6593 bgp_get_default(), bgp
);
6595 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6596 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6598 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6601 * label has previously been automatically
6602 * assigned by labelpool: release it
6604 * NB if tovpn_label == MPLS_LABEL_NONE it
6605 * means the automatic assignment is in flight
6606 * and therefore the labelpool callback must
6607 * detect that the auto label is not needed.
6610 bgp_lp_release(LP_TYPE_VRF
,
6611 &bgp
->vpn_policy
[afi
],
6612 bgp
->vpn_policy
[afi
].tovpn_label
);
6614 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6615 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6618 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6620 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6621 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6622 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6623 vpn_leak_label_callback
);
6626 /* post-change: re-export vpn routes */
6627 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6628 bgp_get_default(), bgp
);
6633 ALIAS (af_label_vpn_export
,
6634 af_no_label_vpn_export_cmd
,
6635 "no label vpn export",
6637 "label value for VRF\n"
6638 "Between current address-family and vpn\n"
6639 "For routes leaked from current address-family to vpn\n")
6641 DEFPY (af_nexthop_vpn_export
,
6642 af_nexthop_vpn_export_cmd
,
6643 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6645 "Specify next hop to use for VRF advertised prefixes\n"
6646 "Between current address-family and vpn\n"
6647 "For routes leaked from current address-family to vpn\n"
6651 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6657 if (argv_find(argv
, argc
, "no", &idx
))
6661 if (!sockunion2hostprefix(nexthop_str
, &p
))
6662 return CMD_WARNING_CONFIG_FAILED
;
6665 afi
= vpn_policy_getafi(vty
, bgp
, false);
6667 return CMD_WARNING_CONFIG_FAILED
;
6670 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6672 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6673 bgp_get_default(), bgp
);
6676 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6677 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6678 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6680 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6681 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6684 /* post-change: re-export vpn routes */
6685 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6686 bgp_get_default(), bgp
);
6691 ALIAS (af_nexthop_vpn_export
,
6692 af_no_nexthop_vpn_export_cmd
,
6693 "no nexthop vpn export",
6695 "Specify next hop to use for VRF advertised prefixes\n"
6696 "Between current address-family and vpn\n"
6697 "For routes leaked from current address-family to vpn\n")
6699 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6701 if (!strcmp(dstr
, "import")) {
6702 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6703 } else if (!strcmp(dstr
, "export")) {
6704 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6705 } else if (!strcmp(dstr
, "both")) {
6706 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6707 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6709 vty_out(vty
, "%% direction parse error\n");
6710 return CMD_WARNING_CONFIG_FAILED
;
6715 DEFPY (af_rt_vpn_imexport
,
6716 af_rt_vpn_imexport_cmd
,
6717 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6719 "Specify route target list\n"
6720 "Specify route target list\n"
6721 "Between current address-family and vpn\n"
6722 "For routes leaked from vpn to current address-family: match any\n"
6723 "For routes leaked from current address-family to vpn: set\n"
6724 "both import: match any and export: set\n"
6725 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6727 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6729 struct ecommunity
*ecom
= NULL
;
6730 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6731 vpn_policy_direction_t dir
;
6736 if (argv_find(argv
, argc
, "no", &idx
))
6739 afi
= vpn_policy_getafi(vty
, bgp
, false);
6741 return CMD_WARNING_CONFIG_FAILED
;
6743 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6744 if (ret
!= CMD_SUCCESS
)
6748 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6749 vty_out(vty
, "%% Missing RTLIST\n");
6750 return CMD_WARNING_CONFIG_FAILED
;
6752 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6753 if (ret
!= CMD_SUCCESS
) {
6758 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6762 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6765 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6767 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6768 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6769 ecommunity_dup(ecom
);
6771 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6773 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6774 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6777 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6781 ecommunity_free(&ecom
);
6786 ALIAS (af_rt_vpn_imexport
,
6787 af_no_rt_vpn_imexport_cmd
,
6788 "no <rt|route-target> vpn <import|export|both>$direction_str",
6790 "Specify route target list\n"
6791 "Specify route target list\n"
6792 "Between current address-family and vpn\n"
6793 "For routes leaked from vpn to current address-family\n"
6794 "For routes leaked from current address-family to vpn\n"
6795 "both import and export\n")
6797 DEFPY (af_route_map_vpn_imexport
,
6798 af_route_map_vpn_imexport_cmd
,
6799 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6800 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6802 "Specify route map\n"
6803 "Between current address-family and vpn\n"
6804 "For routes leaked from vpn to current address-family\n"
6805 "For routes leaked from current address-family to vpn\n"
6806 "name of route-map\n")
6808 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6810 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6811 vpn_policy_direction_t dir
;
6816 if (argv_find(argv
, argc
, "no", &idx
))
6819 afi
= vpn_policy_getafi(vty
, bgp
, false);
6821 return CMD_WARNING_CONFIG_FAILED
;
6823 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6824 if (ret
!= CMD_SUCCESS
)
6827 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6831 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6834 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6835 XFREE(MTYPE_ROUTE_MAP_NAME
,
6836 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6837 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6838 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6839 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6840 route_map_lookup_warn_noexist(vty
, rmap_str
);
6841 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6844 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6845 XFREE(MTYPE_ROUTE_MAP_NAME
,
6846 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6847 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6848 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6851 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6857 ALIAS (af_route_map_vpn_imexport
,
6858 af_no_route_map_vpn_imexport_cmd
,
6859 "no route-map vpn <import|export>$direction_str",
6861 "Specify route map\n"
6862 "Between current address-family and vpn\n"
6863 "For routes leaked from vpn to current address-family\n"
6864 "For routes leaked from current address-family to vpn\n")
6866 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6867 "[no] import vrf route-map RMAP$rmap_str",
6869 "Import routes from another VRF\n"
6870 "Vrf routes being filtered\n"
6871 "Specify route map\n"
6872 "name of route-map\n")
6874 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6875 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6879 struct bgp
*bgp_default
;
6881 if (argv_find(argv
, argc
, "no", &idx
))
6884 afi
= vpn_policy_getafi(vty
, bgp
, true);
6886 return CMD_WARNING_CONFIG_FAILED
;
6888 bgp_default
= bgp_get_default();
6893 /* Auto-create assuming the same AS */
6894 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6895 BGP_INSTANCE_TYPE_DEFAULT
);
6899 "VRF default is not configured as a bgp instance\n");
6904 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6907 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6908 XFREE(MTYPE_ROUTE_MAP_NAME
,
6909 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6910 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6911 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6912 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6913 route_map_lookup_warn_noexist(vty
, rmap_str
);
6914 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6917 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6918 XFREE(MTYPE_ROUTE_MAP_NAME
,
6919 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6920 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6921 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6924 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6929 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6930 "no import vrf route-map",
6932 "Import routes from another VRF\n"
6933 "Vrf routes being filtered\n"
6934 "Specify route map\n")
6936 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
6937 "[no] import vrf VIEWVRFNAME$import_name",
6939 "Import routes from another VRF\n"
6940 "VRF to import from\n"
6941 "The name of the VRF\n")
6943 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6944 struct listnode
*node
;
6945 struct bgp
*vrf_bgp
, *bgp_default
;
6948 bool remove
= false;
6951 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
6955 if (import_name
== NULL
) {
6956 vty_out(vty
, "%% Missing import name\n");
6960 if (argv_find(argv
, argc
, "no", &idx
))
6963 afi
= vpn_policy_getafi(vty
, bgp
, true);
6965 return CMD_WARNING_CONFIG_FAILED
;
6967 safi
= bgp_node_safi(vty
);
6969 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
6970 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
6971 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
6972 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
6973 remove
? "unimport" : "import", import_name
);
6977 bgp_default
= bgp_get_default();
6979 /* Auto-create assuming the same AS */
6980 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6981 BGP_INSTANCE_TYPE_DEFAULT
);
6985 "VRF default is not configured as a bgp instance\n");
6990 vrf_bgp
= bgp_lookup_by_name(import_name
);
6992 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
6993 vrf_bgp
= bgp_default
;
6995 /* Auto-create assuming the same AS */
6996 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
7000 "VRF %s is not configured as a bgp instance\n",
7007 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
7009 /* Already importing from "import_vrf"? */
7010 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
7012 if (strcmp(vname
, import_name
) == 0)
7016 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
7022 /* This command is valid only in a bgp vrf instance or the default instance */
7023 DEFPY (bgp_imexport_vpn
,
7024 bgp_imexport_vpn_cmd
,
7025 "[no] <import|export>$direction_str vpn",
7027 "Import routes to this address-family\n"
7028 "Export routes from this address-family\n"
7029 "to/from default instance VPN RIB\n")
7031 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7038 vpn_policy_direction_t dir
;
7040 if (argv_find(argv
, argc
, "no", &idx
))
7043 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
7044 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
7046 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
7047 return CMD_WARNING_CONFIG_FAILED
;
7050 afi
= bgp_node_afi(vty
);
7051 safi
= bgp_node_safi(vty
);
7052 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
7053 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
7054 return CMD_WARNING_CONFIG_FAILED
;
7057 if (!strcmp(direction_str
, "import")) {
7058 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
7059 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
7060 } else if (!strcmp(direction_str
, "export")) {
7061 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
7062 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
7064 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
7065 return CMD_WARNING_CONFIG_FAILED
;
7068 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7071 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7072 if (!previous_state
) {
7073 /* trigger export current vrf */
7074 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7077 if (previous_state
) {
7078 /* trigger un-export current vrf */
7079 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7081 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7087 DEFPY (af_routetarget_import
,
7088 af_routetarget_import_cmd
,
7089 "[no] <rt|route-target> redirect import RTLIST...",
7091 "Specify route target list\n"
7092 "Specify route target list\n"
7093 "Flow-spec redirect type route target\n"
7094 "Import routes to this address-family\n"
7095 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
7097 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7099 struct ecommunity
*ecom
= NULL
;
7104 if (argv_find(argv
, argc
, "no", &idx
))
7107 afi
= vpn_policy_getafi(vty
, bgp
, false);
7109 return CMD_WARNING_CONFIG_FAILED
;
7112 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7113 vty_out(vty
, "%% Missing RTLIST\n");
7114 return CMD_WARNING_CONFIG_FAILED
;
7116 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7117 if (ret
!= CMD_SUCCESS
)
7122 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7123 ecommunity_free(&bgp
->vpn_policy
[afi
]
7124 .import_redirect_rtlist
);
7125 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
7126 ecommunity_dup(ecom
);
7128 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7129 ecommunity_free(&bgp
->vpn_policy
[afi
]
7130 .import_redirect_rtlist
);
7131 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
7135 ecommunity_free(&ecom
);
7140 DEFUN_NOSH (address_family_ipv4_safi
,
7141 address_family_ipv4_safi_cmd
,
7142 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7143 "Enter Address Family command mode\n"
7145 BGP_SAFI_WITH_LABEL_HELP_STR
)
7149 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7150 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7151 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7152 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7153 && safi
!= SAFI_EVPN
) {
7155 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7156 return CMD_WARNING_CONFIG_FAILED
;
7158 vty
->node
= bgp_node_type(AFI_IP
, safi
);
7160 vty
->node
= BGP_IPV4_NODE
;
7165 DEFUN_NOSH (address_family_ipv6_safi
,
7166 address_family_ipv6_safi_cmd
,
7167 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7168 "Enter Address Family command mode\n"
7170 BGP_SAFI_WITH_LABEL_HELP_STR
)
7173 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7174 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7175 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7176 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7177 && safi
!= SAFI_EVPN
) {
7179 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7180 return CMD_WARNING_CONFIG_FAILED
;
7182 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
7184 vty
->node
= BGP_IPV6_NODE
;
7189 #ifdef KEEP_OLD_VPN_COMMANDS
7190 DEFUN_NOSH (address_family_vpnv4
,
7191 address_family_vpnv4_cmd
,
7192 "address-family vpnv4 [unicast]",
7193 "Enter Address Family command mode\n"
7195 "Address Family modifier\n")
7197 vty
->node
= BGP_VPNV4_NODE
;
7201 DEFUN_NOSH (address_family_vpnv6
,
7202 address_family_vpnv6_cmd
,
7203 "address-family vpnv6 [unicast]",
7204 "Enter Address Family command mode\n"
7206 "Address Family modifier\n")
7208 vty
->node
= BGP_VPNV6_NODE
;
7211 #endif /* KEEP_OLD_VPN_COMMANDS */
7213 DEFUN_NOSH (address_family_evpn
,
7214 address_family_evpn_cmd
,
7215 "address-family l2vpn evpn",
7216 "Enter Address Family command mode\n"
7218 "Address Family modifier\n")
7220 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7221 vty
->node
= BGP_EVPN_NODE
;
7225 DEFUN_NOSH (exit_address_family
,
7226 exit_address_family_cmd
,
7227 "exit-address-family",
7228 "Exit from Address Family configuration mode\n")
7230 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7231 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7232 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7233 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7234 || vty
->node
== BGP_EVPN_NODE
7235 || vty
->node
== BGP_FLOWSPECV4_NODE
7236 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7237 vty
->node
= BGP_NODE
;
7241 /* Recalculate bestpath and re-advertise a prefix */
7242 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7243 const char *ip_str
, afi_t afi
, safi_t safi
,
7244 struct prefix_rd
*prd
)
7247 struct prefix match
;
7248 struct bgp_node
*rn
;
7249 struct bgp_node
*rm
;
7251 struct bgp_table
*table
;
7252 struct bgp_table
*rib
;
7254 /* BGP structure lookup. */
7256 bgp
= bgp_lookup_by_name(view_name
);
7258 vty_out(vty
, "%% Can't find BGP instance %s\n",
7263 bgp
= bgp_get_default();
7265 vty_out(vty
, "%% No BGP process is configured\n");
7270 /* Check IP address argument. */
7271 ret
= str2prefix(ip_str
, &match
);
7273 vty_out(vty
, "%% address is malformed\n");
7277 match
.family
= afi2family(afi
);
7278 rib
= bgp
->rib
[afi
][safi
];
7280 if (safi
== SAFI_MPLS_VPN
) {
7281 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7282 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7285 table
= bgp_node_get_bgp_table_info(rn
);
7286 if (table
!= NULL
) {
7288 if ((rm
= bgp_node_match(table
, &match
))
7291 == match
.prefixlen
) {
7293 BGP_NODE_USER_CLEAR
);
7294 bgp_process(bgp
, rm
, afi
, safi
);
7296 bgp_unlock_node(rm
);
7301 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7302 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7303 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7304 bgp_process(bgp
, rn
, afi
, safi
);
7306 bgp_unlock_node(rn
);
7313 /* one clear bgp command to rule them all */
7314 DEFUN (clear_ip_bgp_all
,
7315 clear_ip_bgp_all_cmd
,
7316 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out>]",
7320 BGP_INSTANCE_HELP_STR
7323 BGP_SAFI_WITH_LABEL_HELP_STR
7324 "Address Family modifier\n"
7326 "BGP neighbor address to clear\n"
7327 "BGP IPv6 neighbor to clear\n"
7328 "BGP neighbor on interface to clear\n"
7329 "Clear peers with the AS number\n"
7330 "Clear all external peers\n"
7331 "Clear all members of peer-group\n"
7332 "BGP peer-group name\n"
7337 "Push out prefix-list ORF and do inbound soft reconfig\n"
7342 afi_t afi
= AFI_UNSPEC
;
7343 safi_t safi
= SAFI_UNSPEC
;
7344 enum clear_sort clr_sort
= clear_peer
;
7345 enum bgp_clear_type clr_type
;
7346 char *clr_arg
= NULL
;
7350 /* clear [ip] bgp */
7351 if (argv_find(argv
, argc
, "ip", &idx
))
7354 /* [<vrf> VIEWVRFNAME] */
7355 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7356 vrf
= argv
[idx
+ 1]->arg
;
7358 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7360 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7361 /* [<view> VIEWVRFNAME] */
7362 vrf
= argv
[idx
+ 1]->arg
;
7365 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7366 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7367 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7369 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
7370 if (argv_find(argv
, argc
, "*", &idx
)) {
7371 clr_sort
= clear_all
;
7372 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7373 clr_sort
= clear_peer
;
7374 clr_arg
= argv
[idx
]->arg
;
7375 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7376 clr_sort
= clear_peer
;
7377 clr_arg
= argv
[idx
]->arg
;
7378 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7379 clr_sort
= clear_group
;
7381 clr_arg
= argv
[idx
]->arg
;
7382 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
7383 clr_sort
= clear_peer
;
7384 clr_arg
= argv
[idx
]->arg
;
7385 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7386 clr_sort
= clear_peer
;
7387 clr_arg
= argv
[idx
]->arg
;
7388 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7389 clr_sort
= clear_as
;
7390 clr_arg
= argv
[idx
]->arg
;
7391 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7392 clr_sort
= clear_external
;
7395 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7396 if (argv_find(argv
, argc
, "soft", &idx
)) {
7397 if (argv_find(argv
, argc
, "in", &idx
)
7398 || argv_find(argv
, argc
, "out", &idx
))
7399 clr_type
= strmatch(argv
[idx
]->text
, "in")
7401 : BGP_CLEAR_SOFT_OUT
;
7403 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7404 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7405 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7406 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7407 : BGP_CLEAR_SOFT_IN
;
7408 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7409 clr_type
= BGP_CLEAR_SOFT_OUT
;
7411 clr_type
= BGP_CLEAR_SOFT_NONE
;
7413 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7416 DEFUN (clear_ip_bgp_prefix
,
7417 clear_ip_bgp_prefix_cmd
,
7418 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7422 BGP_INSTANCE_HELP_STR
7423 "Clear bestpath and re-advertise\n"
7427 char *prefix
= NULL
;
7431 /* [<view|vrf> VIEWVRFNAME] */
7432 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7433 vrf
= argv
[idx
+ 1]->arg
;
7435 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7437 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7438 /* [<view> VIEWVRFNAME] */
7439 vrf
= argv
[idx
+ 1]->arg
;
7443 prefix
= argv
[argc
- 1]->arg
;
7445 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7448 DEFUN (clear_bgp_ipv6_safi_prefix
,
7449 clear_bgp_ipv6_safi_prefix_cmd
,
7450 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7456 "Clear bestpath and re-advertise\n"
7460 int idx_ipv6_prefix
= 0;
7461 safi_t safi
= SAFI_UNICAST
;
7462 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7463 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7465 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7466 return bgp_clear_prefix(
7467 vty
, NULL
, prefix
, AFI_IP6
,
7471 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7472 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7473 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7477 BGP_INSTANCE_HELP_STR
7480 "Clear bestpath and re-advertise\n"
7484 int idx_vrfview
= 0;
7485 int idx_ipv6_prefix
= 0;
7486 safi_t safi
= SAFI_UNICAST
;
7487 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7488 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7489 char *vrfview
= NULL
;
7491 /* [<view|vrf> VIEWVRFNAME] */
7492 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
7493 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7494 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
7496 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
7497 /* [<view> VIEWVRFNAME] */
7498 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7500 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7502 return bgp_clear_prefix(
7503 vty
, vrfview
, prefix
,
7504 AFI_IP6
, safi
, NULL
);
7507 DEFUN (show_bgp_views
,
7509 "show [ip] bgp views",
7513 "Show the defined BGP views\n")
7515 struct list
*inst
= bm
->bgp
;
7516 struct listnode
*node
;
7519 vty_out(vty
, "Defined BGP views:\n");
7520 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7522 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7524 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7531 DEFUN (show_bgp_vrfs
,
7533 "show [ip] bgp vrfs [json]",
7540 char buf
[ETHER_ADDR_STRLEN
];
7541 struct list
*inst
= bm
->bgp
;
7542 struct listnode
*node
;
7544 bool uj
= use_json(argc
, argv
);
7545 json_object
*json
= NULL
;
7546 json_object
*json_vrfs
= NULL
;
7550 json
= json_object_new_object();
7551 json_vrfs
= json_object_new_object();
7554 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7555 const char *name
, *type
;
7557 struct listnode
*node2
, *nnode2
;
7558 int peers_cfg
, peers_estb
;
7559 json_object
*json_vrf
= NULL
;
7562 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7566 if (!uj
&& count
== 1) {
7568 "%4s %-5s %-16s %9s %10s %-37s\n",
7569 "Type", "Id", "routerId", "#PeersVfg",
7570 "#PeersEstb", "Name");
7571 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
7572 "L3-VNI", "RouterMAC", "Interface");
7575 peers_cfg
= peers_estb
= 0;
7577 json_vrf
= json_object_new_object();
7580 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
7581 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7584 if (peer
->status
== Established
)
7588 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7589 name
= VRF_DEFAULT_NAME
;
7598 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7600 : (int64_t)bgp
->vrf_id
;
7601 json_object_string_add(json_vrf
, "type", type
);
7602 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7603 json_object_string_add(json_vrf
, "routerId",
7604 inet_ntoa(bgp
->router_id
));
7605 json_object_int_add(json_vrf
, "numConfiguredPeers",
7607 json_object_int_add(json_vrf
, "numEstablishedPeers",
7610 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7611 json_object_string_add(
7613 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7614 json_object_string_add(json_vrf
, "interface",
7615 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
7617 json_object_object_add(json_vrfs
, name
, json_vrf
);
7620 "%4s %-5d %-16s %-9u %-10u %-37s\n",
7622 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7624 inet_ntoa(bgp
->router_id
), peers_cfg
,
7626 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
7628 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
7629 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
7635 json_object_object_add(json
, "vrfs", json_vrfs
);
7637 json_object_int_add(json
, "totalVrfs", count
);
7639 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7640 json
, JSON_C_TO_STRING_PRETTY
));
7641 json_object_free(json
);
7645 "\nTotal number of VRFs (including default): %d\n",
7652 DEFUN (show_bgp_mac_hash
,
7653 show_bgp_mac_hash_cmd
,
7654 "show bgp mac hash",
7658 "Mac Address database\n")
7660 bgp_mac_dump_table(vty
);
7665 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
7667 struct vty
*vty
= (struct vty
*)args
;
7668 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
7670 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7674 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7676 vty_out(vty
, "self nexthop database:\n");
7677 bgp_nexthop_show_address_hash(vty
, bgp
);
7679 vty_out(vty
, "Tunnel-ip database:\n");
7680 hash_iterate(bgp
->tip_hash
,
7681 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
7685 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7686 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7687 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7688 "martian next-hops\n"
7689 "martian next-hop database\n")
7691 struct bgp
*bgp
= NULL
;
7695 /* [<vrf> VIEWVRFNAME] */
7696 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7697 name
= argv
[idx
+ 1]->arg
;
7698 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7700 } else if (argv_find(argv
, argc
, "view", &idx
))
7701 /* [<view> VIEWVRFNAME] */
7702 name
= argv
[idx
+ 1]->arg
;
7704 bgp
= bgp_lookup_by_name(name
);
7706 bgp
= bgp_get_default();
7709 vty_out(vty
, "%% No BGP process is configured\n");
7712 bgp_show_martian_nexthops(vty
, bgp
);
7717 DEFUN (show_bgp_memory
,
7718 show_bgp_memory_cmd
,
7719 "show [ip] bgp memory",
7723 "Global BGP memory statistics\n")
7725 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7726 unsigned long count
;
7728 /* RIB related usage stats */
7729 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7730 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7731 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7732 count
* sizeof(struct bgp_node
)));
7734 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7735 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7736 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7737 count
* sizeof(struct bgp_path_info
)));
7738 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7739 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7742 memstrbuf
, sizeof(memstrbuf
),
7743 count
* sizeof(struct bgp_path_info_extra
)));
7745 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7746 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7747 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7748 count
* sizeof(struct bgp_static
)));
7750 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7751 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7752 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7753 count
* sizeof(struct bpacket
)));
7756 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7757 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7758 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7759 count
* sizeof(struct bgp_adj_in
)));
7760 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7761 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7762 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7763 count
* sizeof(struct bgp_adj_out
)));
7765 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7766 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7768 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7769 count
* sizeof(struct bgp_nexthop_cache
)));
7771 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7772 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7774 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7775 count
* sizeof(struct bgp_damp_info
)));
7778 count
= attr_count();
7779 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7780 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7781 count
* sizeof(struct attr
)));
7783 if ((count
= attr_unknown_count()))
7784 vty_out(vty
, "%ld unknown attributes\n", count
);
7786 /* AS_PATH attributes */
7787 count
= aspath_count();
7788 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7789 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7790 count
* sizeof(struct aspath
)));
7792 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7793 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7794 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7795 count
* sizeof(struct assegment
)));
7797 /* Other attributes */
7798 if ((count
= community_count()))
7799 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7800 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7801 count
* sizeof(struct community
)));
7802 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7803 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7804 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7805 count
* sizeof(struct ecommunity
)));
7806 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7808 "%ld BGP large-community entries, using %s of memory\n",
7809 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7810 count
* sizeof(struct lcommunity
)));
7812 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7813 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7814 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7815 count
* sizeof(struct cluster_list
)));
7817 /* Peer related usage */
7818 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7819 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7820 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7821 count
* sizeof(struct peer
)));
7823 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7824 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7825 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7826 count
* sizeof(struct peer_group
)));
7829 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7830 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7831 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7832 count
* sizeof(regex_t
)));
7836 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7838 json_object
*bestpath
= json_object_new_object();
7840 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7841 json_object_string_add(bestpath
, "asPath", "ignore");
7843 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7844 json_object_string_add(bestpath
, "asPath", "confed");
7846 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7847 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7848 json_object_string_add(bestpath
, "multiPathRelax",
7851 json_object_string_add(bestpath
, "multiPathRelax",
7854 json_object_string_add(bestpath
, "multiPathRelax", "false");
7856 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7857 json_object_string_add(bestpath
, "compareRouterId", "true");
7858 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7859 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7860 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7861 json_object_string_add(bestpath
, "med", "confed");
7862 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7863 json_object_string_add(bestpath
, "med",
7864 "missing-as-worst");
7866 json_object_string_add(bestpath
, "med", "true");
7869 json_object_object_add(json
, "bestPath", bestpath
);
7872 /* Print the error code/subcode for why the peer is down */
7873 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
7874 json_object
*json_peer
, bool use_json
)
7876 const char *code_str
;
7877 const char *subcode_str
;
7880 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
7881 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
7882 char errorcodesubcode_hexstr
[5];
7883 char errorcodesubcode_str
[256];
7885 code_str
= bgp_notify_code_str(peer
->notify
.code
);
7886 subcode_str
= bgp_notify_subcode_str(
7888 peer
->notify
.subcode
);
7890 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
7891 peer
->notify
.code
, peer
->notify
.subcode
);
7892 json_object_string_add(json_peer
,
7893 "lastErrorCodeSubcode",
7894 errorcodesubcode_hexstr
);
7895 snprintf(errorcodesubcode_str
, 255, "%s%s",
7896 code_str
, subcode_str
);
7897 json_object_string_add(json_peer
,
7898 "lastNotificationReason",
7899 errorcodesubcode_str
);
7900 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
7901 && peer
->notify
.code
== BGP_NOTIFY_CEASE
7902 && (peer
->notify
.subcode
7903 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
7904 || peer
->notify
.subcode
7905 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
7906 && peer
->notify
.length
) {
7908 const char *msg_str
;
7910 msg_str
= bgp_notify_admin_message(
7911 msgbuf
, sizeof(msgbuf
),
7912 (uint8_t *)peer
->notify
.data
,
7913 peer
->notify
.length
);
7915 json_object_string_add(
7917 "lastShutdownDescription",
7922 json_object_string_add(json_peer
, "lastResetDueTo",
7923 peer_down_str
[(int)peer
->last_reset
]);
7925 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
7926 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
7927 code_str
= bgp_notify_code_str(peer
->notify
.code
);
7929 bgp_notify_subcode_str(peer
->notify
.code
,
7930 peer
->notify
.subcode
);
7931 vty_out(vty
, " Notification %s (%s%s)\n",
7932 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
7935 code_str
, subcode_str
);
7937 vty_out(vty
, " %s\n",
7938 peer_down_str
[(int)peer
->last_reset
]);
7943 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
7946 return ((peer
->status
!= Established
) ||
7947 !peer
->afc_recv
[afi
][safi
]);
7950 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
7951 struct peer
*peer
, json_object
*json_peer
,
7952 int max_neighbor_width
, bool use_json
)
7954 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7958 if (peer_dynamic_neighbor(peer
))
7959 json_object_boolean_true_add(json_peer
,
7962 json_object_string_add(json_peer
, "hostname",
7965 if (peer
->domainname
)
7966 json_object_string_add(json_peer
, "domainname",
7968 json_object_int_add(json_peer
, "connectionsEstablished",
7970 json_object_int_add(json_peer
, "connectionsDropped",
7972 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
7973 use_json
, json_peer
);
7974 if (peer
->status
== Established
)
7975 json_object_string_add(json_peer
, "lastResetDueTo",
7976 "AFI/SAFI Not Negotiated");
7978 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
7981 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
7983 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7984 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
7985 peer
->hostname
, peer
->host
);
7987 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
7989 /* pad the neighbor column with spaces */
7990 if (len
< max_neighbor_width
)
7991 vty_out(vty
, "%*s", max_neighbor_width
- len
,
7993 vty_out(vty
, "%7d %7d %8s", peer
->established
,
7995 peer_uptime(peer
->uptime
, timebuf
,
7996 BGP_UPTIME_LEN
, 0, NULL
));
7997 if (peer
->status
== Established
)
7998 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
8000 bgp_show_peer_reset(vty
, peer
, NULL
,
8006 /* Show BGP peer's summary information. */
8007 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
8008 bool show_failed
, bool use_json
)
8011 struct listnode
*node
, *nnode
;
8012 unsigned int count
= 0, dn_count
= 0;
8013 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
8014 char neighbor_buf
[VTY_BUFSIZ
];
8015 int neighbor_col_default_width
= 16;
8016 int len
, failed_count
= 0;
8017 int max_neighbor_width
= 0;
8019 json_object
*json
= NULL
;
8020 json_object
*json_peer
= NULL
;
8021 json_object
*json_peers
= NULL
;
8022 struct peer_af
*paf
;
8024 /* labeled-unicast routes are installed in the unicast table so in order
8026 * display the correct PfxRcd value we must look at SAFI_UNICAST
8029 if (safi
== SAFI_LABELED_UNICAST
)
8030 pfx_rcd_safi
= SAFI_UNICAST
;
8032 pfx_rcd_safi
= safi
;
8035 json
= json_object_new_object();
8036 json_peers
= json_object_new_object();
8037 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8038 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8041 if (peer
->afc
[afi
][safi
]) {
8042 /* See if we have at least a single failed peer */
8043 if (bgp_has_peer_failed(peer
, afi
, safi
))
8047 if (peer_dynamic_neighbor(peer
))
8052 /* Loop over all neighbors that will be displayed to determine
8054 * characters are needed for the Neighbor column
8056 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8057 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8060 if (peer
->afc
[afi
][safi
]) {
8061 memset(dn_flag
, '\0', sizeof(dn_flag
));
8062 if (peer_dynamic_neighbor(peer
))
8066 && bgp_flag_check(bgp
,
8067 BGP_FLAG_SHOW_HOSTNAME
))
8068 sprintf(neighbor_buf
, "%s%s(%s) ",
8069 dn_flag
, peer
->hostname
,
8072 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
8075 len
= strlen(neighbor_buf
);
8077 if (len
> max_neighbor_width
)
8078 max_neighbor_width
= len
;
8080 /* See if we have at least a single failed peer */
8081 if (bgp_has_peer_failed(peer
, afi
, safi
))
8087 /* Originally we displayed the Neighbor column as 16
8088 * characters wide so make that the default
8090 if (max_neighbor_width
< neighbor_col_default_width
)
8091 max_neighbor_width
= neighbor_col_default_width
;
8094 if (show_failed
&& !failed_count
) {
8096 json_object_int_add(json
, "failedPeersCount", 0);
8097 json_object_int_add(json
, "dynamicPeers", dn_count
);
8098 json_object_int_add(json
, "totalPeers", count
);
8100 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8101 json
, JSON_C_TO_STRING_PRETTY
));
8102 json_object_free(json
);
8104 vty_out(vty
, "%% No failed BGP neighbors found\n");
8105 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8110 count
= 0; /* Reset the value as its used again */
8111 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8112 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8115 if (!peer
->afc
[afi
][safi
])
8120 char memstrbuf
[MTYPE_MEMSTR_LEN
];
8123 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
8125 : (int64_t)bgp
->vrf_id
;
8127 /* Usage summary and header */
8129 json_object_string_add(
8131 inet_ntoa(bgp
->router_id
));
8132 json_object_int_add(json
, "as", bgp
->as
);
8133 json_object_int_add(json
, "vrfId", vrf_id_ui
);
8134 json_object_string_add(
8137 == BGP_INSTANCE_TYPE_DEFAULT
)
8142 "BGP router identifier %s, local AS number %u vrf-id %d",
8143 inet_ntoa(bgp
->router_id
), bgp
->as
,
8144 bgp
->vrf_id
== VRF_UNKNOWN
8146 : (int)bgp
->vrf_id
);
8150 if (bgp_update_delay_configured(bgp
)) {
8152 json_object_int_add(
8153 json
, "updateDelayLimit",
8154 bgp
->v_update_delay
);
8156 if (bgp
->v_update_delay
8157 != bgp
->v_establish_wait
)
8158 json_object_int_add(
8160 "updateDelayEstablishWait",
8161 bgp
->v_establish_wait
);
8163 if (bgp_update_delay_active(bgp
)) {
8164 json_object_string_add(
8166 "updateDelayFirstNeighbor",
8167 bgp
->update_delay_begin_time
);
8168 json_object_boolean_true_add(
8170 "updateDelayInProgress");
8172 if (bgp
->update_delay_over
) {
8173 json_object_string_add(
8175 "updateDelayFirstNeighbor",
8176 bgp
->update_delay_begin_time
);
8177 json_object_string_add(
8179 "updateDelayBestpathResumed",
8180 bgp
->update_delay_end_time
);
8181 json_object_string_add(
8183 "updateDelayZebraUpdateResume",
8184 bgp
->update_delay_zebra_resume_time
);
8185 json_object_string_add(
8187 "updateDelayPeerUpdateResume",
8188 bgp
->update_delay_peers_resume_time
);
8193 "Read-only mode update-delay limit: %d seconds\n",
8194 bgp
->v_update_delay
);
8195 if (bgp
->v_update_delay
8196 != bgp
->v_establish_wait
)
8198 " Establish wait: %d seconds\n",
8199 bgp
->v_establish_wait
);
8201 if (bgp_update_delay_active(bgp
)) {
8203 " First neighbor established: %s\n",
8204 bgp
->update_delay_begin_time
);
8206 " Delay in progress\n");
8208 if (bgp
->update_delay_over
) {
8210 " First neighbor established: %s\n",
8211 bgp
->update_delay_begin_time
);
8213 " Best-paths resumed: %s\n",
8214 bgp
->update_delay_end_time
);
8216 " zebra update resumed: %s\n",
8217 bgp
->update_delay_zebra_resume_time
);
8219 " peers update resumed: %s\n",
8220 bgp
->update_delay_peers_resume_time
);
8227 if (bgp_maxmed_onstartup_configured(bgp
)
8228 && bgp
->maxmed_active
)
8229 json_object_boolean_true_add(
8230 json
, "maxMedOnStartup");
8231 if (bgp
->v_maxmed_admin
)
8232 json_object_boolean_true_add(
8233 json
, "maxMedAdministrative");
8235 json_object_int_add(
8236 json
, "tableVersion",
8237 bgp_table_version(bgp
->rib
[afi
][safi
]));
8239 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8240 json_object_int_add(json
, "ribCount", ents
);
8241 json_object_int_add(
8243 ents
* sizeof(struct bgp_node
));
8245 ents
= bgp
->af_peer_count
[afi
][safi
];
8246 json_object_int_add(json
, "peerCount", ents
);
8247 json_object_int_add(json
, "peerMemory",
8248 ents
* sizeof(struct peer
));
8250 if ((ents
= listcount(bgp
->group
))) {
8251 json_object_int_add(
8252 json
, "peerGroupCount", ents
);
8253 json_object_int_add(
8254 json
, "peerGroupMemory",
8255 ents
* sizeof(struct
8259 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8260 BGP_CONFIG_DAMPENING
))
8261 json_object_boolean_true_add(
8262 json
, "dampeningEnabled");
8264 if (bgp_maxmed_onstartup_configured(bgp
)
8265 && bgp
->maxmed_active
)
8267 "Max-med on-startup active\n");
8268 if (bgp
->v_maxmed_admin
)
8270 "Max-med administrative active\n");
8272 vty_out(vty
, "BGP table version %" PRIu64
"\n",
8273 bgp_table_version(bgp
->rib
[afi
][safi
]));
8275 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8277 "RIB entries %ld, using %s of memory\n",
8279 mtype_memstr(memstrbuf
,
8281 ents
* sizeof(struct
8284 /* Peer related usage */
8285 ents
= bgp
->af_peer_count
[afi
][safi
];
8286 vty_out(vty
, "Peers %ld, using %s of memory\n",
8289 memstrbuf
, sizeof(memstrbuf
),
8290 ents
* sizeof(struct peer
)));
8292 if ((ents
= listcount(bgp
->group
)))
8294 "Peer groups %ld, using %s of memory\n",
8299 ents
* sizeof(struct
8302 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8303 BGP_CONFIG_DAMPENING
))
8304 vty_out(vty
, "Dampening enabled.\n");
8307 /* Subtract 8 here because 'Neighbor' is
8309 vty_out(vty
, "Neighbor");
8310 vty_out(vty
, "%*s", max_neighbor_width
- 8,
8313 vty_out(vty
, "EstdCnt DropCnt ResetTime Reason\n");
8316 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
8321 /* Works for both failed & successful cases */
8322 if (peer_dynamic_neighbor(peer
))
8329 bgp_has_peer_failed(peer
, afi
, safi
)) {
8330 json_peer
= json_object_new_object();
8331 bgp_show_failed_summary(vty
, bgp
, peer
,
8332 json_peer
, 0, use_json
);
8333 } else if (!show_failed
) {
8334 json_peer
= json_object_new_object();
8335 if (peer_dynamic_neighbor(peer
)) {
8336 json_object_boolean_true_add(json_peer
,
8341 json_object_string_add(json_peer
, "hostname",
8344 if (peer
->domainname
)
8345 json_object_string_add(json_peer
, "domainname",
8348 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
8349 json_object_int_add(json_peer
, "version", 4);
8350 json_object_int_add(json_peer
, "msgRcvd",
8351 PEER_TOTAL_RX(peer
));
8352 json_object_int_add(json_peer
, "msgSent",
8353 PEER_TOTAL_TX(peer
));
8355 json_object_int_add(json_peer
, "tableVersion",
8356 peer
->version
[afi
][safi
]);
8357 json_object_int_add(json_peer
, "outq",
8359 json_object_int_add(json_peer
, "inq", 0);
8360 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8361 use_json
, json_peer
);
8364 * Adding "pfxRcd" field to match with the corresponding
8365 * CLI. "prefixReceivedCount" will be deprecated in
8368 json_object_int_add(json_peer
, "prefixReceivedCount",
8369 peer
->pcount
[afi
][pfx_rcd_safi
]);
8370 json_object_int_add(json_peer
, "pfxRcd",
8371 peer
->pcount
[afi
][pfx_rcd_safi
]);
8373 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
8374 if (paf
&& PAF_SUBGRP(paf
))
8375 json_object_int_add(json_peer
,
8377 (PAF_SUBGRP(paf
))->scount
);
8378 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8379 json_object_string_add(json_peer
, "state",
8381 else if (peer
->afc_recv
[afi
][safi
])
8382 json_object_string_add(
8384 lookup_msg(bgp_status_msg
, peer
->status
,
8386 else if (CHECK_FLAG(peer
->sflags
,
8387 PEER_STATUS_PREFIX_OVERFLOW
))
8388 json_object_string_add(json_peer
, "state",
8391 json_object_string_add(
8393 lookup_msg(bgp_status_msg
, peer
->status
,
8395 json_object_int_add(json_peer
, "connectionsEstablished",
8397 json_object_int_add(json_peer
, "connectionsDropped",
8400 /* Avoid creating empty peer dicts in JSON */
8401 if (json_peer
== NULL
)
8405 json_object_string_add(json_peer
, "idType",
8407 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8408 json_object_string_add(json_peer
, "idType",
8410 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8411 json_object_string_add(json_peer
, "idType",
8413 json_object_object_add(json_peers
, peer
->host
,
8417 bgp_has_peer_failed(peer
, afi
, safi
)) {
8418 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
8421 } else if (!show_failed
) {
8422 memset(dn_flag
, '\0', sizeof(dn_flag
));
8423 if (peer_dynamic_neighbor(peer
)) {
8428 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8429 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8430 peer
->hostname
, peer
->host
);
8432 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8434 /* pad the neighbor column with spaces */
8435 if (len
< max_neighbor_width
)
8436 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8439 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8440 peer
->as
, PEER_TOTAL_RX(peer
),
8441 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8442 0, peer
->obuf
->count
,
8443 peer_uptime(peer
->uptime
, timebuf
,
8444 BGP_UPTIME_LEN
, 0, NULL
));
8446 if (peer
->status
== Established
)
8447 if (peer
->afc_recv
[afi
][safi
])
8448 vty_out(vty
, " %12ld",
8452 vty_out(vty
, " NoNeg");
8454 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8455 vty_out(vty
, " Idle (Admin)");
8456 else if (CHECK_FLAG(
8458 PEER_STATUS_PREFIX_OVERFLOW
))
8459 vty_out(vty
, " Idle (PfxCt)");
8461 vty_out(vty
, " %12s",
8462 lookup_msg(bgp_status_msg
,
8463 peer
->status
, NULL
));
8472 json_object_object_add(json
, "peers", json_peers
);
8473 json_object_int_add(json
, "failedPeers", failed_count
);
8474 json_object_int_add(json
, "totalPeers", count
);
8475 json_object_int_add(json
, "dynamicPeers", dn_count
);
8478 bgp_show_bestpath_json(bgp
, json
);
8480 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8481 json
, JSON_C_TO_STRING_PRETTY
));
8482 json_object_free(json
);
8485 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8487 vty_out(vty
, "No %s neighbor is configured\n",
8488 get_afi_safi_str(afi
, safi
, false));
8492 vty_out(vty
, "* - dynamic neighbor\n");
8493 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8494 dn_count
, bgp
->dynamic_neighbors_limit
);
8501 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8502 int safi
, bool show_failed
, bool use_json
)
8505 int afi_wildcard
= (afi
== AFI_MAX
);
8506 int safi_wildcard
= (safi
== SAFI_MAX
);
8507 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8508 bool nbr_output
= false;
8510 if (use_json
&& is_wildcard
)
8511 vty_out(vty
, "{\n");
8513 afi
= 1; /* AFI_IP */
8514 while (afi
< AFI_MAX
) {
8516 safi
= 1; /* SAFI_UNICAST */
8517 while (safi
< SAFI_MAX
) {
8518 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8523 * So limit output to those afi/safi
8525 * actualy have something interesting in
8530 vty_out(vty
, ",\n");
8534 vty_out(vty
, "\"%s\":",
8535 get_afi_safi_str(afi
,
8539 vty_out(vty
, "\n%s Summary:\n",
8540 get_afi_safi_str(afi
,
8545 bgp_show_summary(vty
, bgp
, afi
, safi
, show_failed
,
8557 if (use_json
&& is_wildcard
)
8558 vty_out(vty
, "}\n");
8559 else if (!nbr_output
) {
8561 vty_out(vty
, "{}\n");
8563 vty_out(vty
, "%% No BGP neighbors found\n");
8567 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8568 safi_t safi
, bool show_failed
,
8571 struct listnode
*node
, *nnode
;
8574 bool nbr_output
= false;
8577 vty_out(vty
, "{\n");
8579 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8583 vty_out(vty
, ",\n");
8587 vty_out(vty
, "\"%s\":",
8588 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8592 vty_out(vty
, "\nInstance %s:\n",
8593 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8597 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
8602 vty_out(vty
, "}\n");
8603 else if (!nbr_output
)
8604 vty_out(vty
, "%% BGP instance not found\n");
8607 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8608 safi_t safi
, bool show_failed
, bool use_json
)
8613 if (strmatch(name
, "all")) {
8614 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8619 bgp
= bgp_lookup_by_name(name
);
8623 vty_out(vty
, "{}\n");
8626 "%% BGP instance not found\n");
8630 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
,
8631 show_failed
, use_json
);
8636 bgp
= bgp_get_default();
8639 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
8643 vty_out(vty
, "{}\n");
8645 vty_out(vty
, "%% BGP instance not found\n");
8652 /* `show [ip] bgp summary' commands. */
8653 DEFUN (show_ip_bgp_summary
,
8654 show_ip_bgp_summary_cmd
,
8655 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [failed] [json]",
8659 BGP_INSTANCE_HELP_STR
8661 BGP_SAFI_WITH_LABEL_HELP_STR
8662 "Summary of BGP neighbor status\n"
8663 "Show only sessions not in Established state\n"
8667 afi_t afi
= AFI_MAX
;
8668 safi_t safi
= SAFI_MAX
;
8669 bool show_failed
= false;
8674 if (argv_find(argv
, argc
, "ip", &idx
))
8676 /* [<vrf> VIEWVRFNAME] */
8677 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8678 vrf
= argv
[idx
+ 1]->arg
;
8679 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8681 } else if (argv_find(argv
, argc
, "view", &idx
))
8682 /* [<view> VIEWVRFNAME] */
8683 vrf
= argv
[idx
+ 1]->arg
;
8684 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8685 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8686 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8689 if (argv_find(argv
, argc
, "failed", &idx
))
8692 bool uj
= use_json(argc
, argv
);
8694 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, show_failed
, uj
);
8697 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
8700 return get_afi_safi_json_str(afi
, safi
);
8702 return get_afi_safi_vty_str(afi
, safi
);
8705 /* Show BGP peer's information. */
8706 enum show_type
{ show_all
, show_peer
, show_ipv4_all
, show_ipv6_all
, show_ipv4_peer
, show_ipv6_peer
};
8708 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8709 afi_t afi
, safi_t safi
,
8710 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8711 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8712 bool use_json
, json_object
*json_pref
)
8715 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8716 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8718 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8719 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8720 json_object_string_add(json_pref
, "sendMode",
8721 "advertisedAndReceived");
8722 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8723 json_object_string_add(json_pref
, "sendMode",
8725 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8726 json_object_string_add(json_pref
, "sendMode",
8729 vty_out(vty
, " Send-mode: ");
8730 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8731 vty_out(vty
, "advertised");
8732 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8733 vty_out(vty
, "%sreceived",
8734 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8743 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8744 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8746 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8747 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8748 json_object_string_add(json_pref
, "recvMode",
8749 "advertisedAndReceived");
8750 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8751 json_object_string_add(json_pref
, "recvMode",
8753 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8754 json_object_string_add(json_pref
, "recvMode",
8757 vty_out(vty
, " Receive-mode: ");
8758 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8759 vty_out(vty
, "advertised");
8760 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8761 vty_out(vty
, "%sreceived",
8762 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8771 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8772 safi_t safi
, bool use_json
,
8773 json_object
*json_neigh
)
8775 struct bgp_filter
*filter
;
8776 struct peer_af
*paf
;
8777 char orf_pfx_name
[BUFSIZ
];
8779 json_object
*json_af
= NULL
;
8780 json_object
*json_prefA
= NULL
;
8781 json_object
*json_prefB
= NULL
;
8782 json_object
*json_addr
= NULL
;
8785 json_addr
= json_object_new_object();
8786 json_af
= json_object_new_object();
8787 filter
= &p
->filter
[afi
][safi
];
8789 if (peer_group_active(p
))
8790 json_object_string_add(json_addr
, "peerGroupMember",
8793 paf
= peer_af_find(p
, afi
, safi
);
8794 if (paf
&& PAF_SUBGRP(paf
)) {
8795 json_object_int_add(json_addr
, "updateGroupId",
8796 PAF_UPDGRP(paf
)->id
);
8797 json_object_int_add(json_addr
, "subGroupId",
8798 PAF_SUBGRP(paf
)->id
);
8799 json_object_int_add(json_addr
, "packetQueueLength",
8800 bpacket_queue_virtual_length(paf
));
8803 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8804 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8805 PEER_CAP_ORF_PREFIX_SM_RCV
)
8806 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8807 PEER_CAP_ORF_PREFIX_RM_ADV
)
8808 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8809 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8810 json_object_int_add(json_af
, "orfType",
8812 json_prefA
= json_object_new_object();
8813 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8814 PEER_CAP_ORF_PREFIX_SM_ADV
,
8815 PEER_CAP_ORF_PREFIX_RM_ADV
,
8816 PEER_CAP_ORF_PREFIX_SM_RCV
,
8817 PEER_CAP_ORF_PREFIX_RM_RCV
,
8818 use_json
, json_prefA
);
8819 json_object_object_add(json_af
, "orfPrefixList",
8823 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8824 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8825 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8826 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8827 PEER_CAP_ORF_PREFIX_RM_ADV
)
8828 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8829 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8830 json_object_int_add(json_af
, "orfOldType",
8831 ORF_TYPE_PREFIX_OLD
);
8832 json_prefB
= json_object_new_object();
8833 bgp_show_peer_afi_orf_cap(
8834 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8835 PEER_CAP_ORF_PREFIX_RM_ADV
,
8836 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8837 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8839 json_object_object_add(json_af
, "orfOldPrefixList",
8843 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8844 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8845 PEER_CAP_ORF_PREFIX_SM_RCV
)
8846 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8847 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8848 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8849 PEER_CAP_ORF_PREFIX_RM_ADV
)
8850 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8851 PEER_CAP_ORF_PREFIX_RM_RCV
)
8852 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8853 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8854 json_object_object_add(json_addr
, "afDependentCap",
8857 json_object_free(json_af
);
8859 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8860 orf_pfx_count
= prefix_bgp_show_prefix_list(
8861 NULL
, afi
, orf_pfx_name
, use_json
);
8863 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8864 PEER_STATUS_ORF_PREFIX_SEND
)
8866 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8867 PEER_STATUS_ORF_PREFIX_SEND
))
8868 json_object_boolean_true_add(json_neigh
,
8871 json_object_int_add(json_addr
, "orfRecvCounter",
8874 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8875 PEER_STATUS_ORF_WAIT_REFRESH
))
8876 json_object_string_add(
8877 json_addr
, "orfFirstUpdate",
8878 "deferredUntilORFOrRouteRefreshRecvd");
8880 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8881 PEER_FLAG_REFLECTOR_CLIENT
))
8882 json_object_boolean_true_add(json_addr
,
8883 "routeReflectorClient");
8884 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8885 PEER_FLAG_RSERVER_CLIENT
))
8886 json_object_boolean_true_add(json_addr
,
8887 "routeServerClient");
8888 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8889 json_object_boolean_true_add(json_addr
,
8890 "inboundSoftConfigPermit");
8892 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8893 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8894 json_object_boolean_true_add(
8896 "privateAsNumsAllReplacedInUpdatesToNbr");
8897 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8898 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8899 json_object_boolean_true_add(
8901 "privateAsNumsReplacedInUpdatesToNbr");
8902 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8903 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8904 json_object_boolean_true_add(
8906 "privateAsNumsAllRemovedInUpdatesToNbr");
8907 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8908 PEER_FLAG_REMOVE_PRIVATE_AS
))
8909 json_object_boolean_true_add(
8911 "privateAsNumsRemovedInUpdatesToNbr");
8913 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8914 json_object_boolean_true_add(
8916 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8919 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8920 json_object_string_add(json_addr
,
8921 "overrideASNsInOutboundUpdates",
8922 "ifAspathEqualRemoteAs");
8924 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8925 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8926 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8927 json_object_boolean_true_add(json_addr
,
8928 "routerAlwaysNextHop");
8929 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8930 PEER_FLAG_AS_PATH_UNCHANGED
))
8931 json_object_boolean_true_add(
8932 json_addr
, "unchangedAsPathPropogatedToNbr");
8933 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8934 PEER_FLAG_NEXTHOP_UNCHANGED
))
8935 json_object_boolean_true_add(
8936 json_addr
, "unchangedNextHopPropogatedToNbr");
8937 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8938 json_object_boolean_true_add(
8939 json_addr
, "unchangedMedPropogatedToNbr");
8940 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8941 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8942 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8943 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8944 PEER_FLAG_SEND_COMMUNITY
)
8945 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8946 PEER_FLAG_SEND_EXT_COMMUNITY
))
8947 json_object_string_add(json_addr
,
8948 "commAttriSentToNbr",
8949 "extendedAndStandard");
8950 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8951 PEER_FLAG_SEND_EXT_COMMUNITY
))
8952 json_object_string_add(json_addr
,
8953 "commAttriSentToNbr",
8956 json_object_string_add(json_addr
,
8957 "commAttriSentToNbr",
8960 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8961 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8962 if (p
->default_rmap
[afi
][safi
].name
)
8963 json_object_string_add(
8964 json_addr
, "defaultRouteMap",
8965 p
->default_rmap
[afi
][safi
].name
);
8967 if (paf
&& PAF_SUBGRP(paf
)
8968 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8969 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8970 json_object_boolean_true_add(json_addr
,
8973 json_object_boolean_true_add(json_addr
,
8977 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8978 if (is_evpn_enabled())
8979 json_object_boolean_true_add(
8980 json_addr
, "advertiseAllVnis");
8983 if (filter
->plist
[FILTER_IN
].name
8984 || filter
->dlist
[FILTER_IN
].name
8985 || filter
->aslist
[FILTER_IN
].name
8986 || filter
->map
[RMAP_IN
].name
)
8987 json_object_boolean_true_add(json_addr
,
8988 "inboundPathPolicyConfig");
8989 if (filter
->plist
[FILTER_OUT
].name
8990 || filter
->dlist
[FILTER_OUT
].name
8991 || filter
->aslist
[FILTER_OUT
].name
8992 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8993 json_object_boolean_true_add(
8994 json_addr
, "outboundPathPolicyConfig");
8997 if (filter
->plist
[FILTER_IN
].name
)
8998 json_object_string_add(json_addr
,
8999 "incomingUpdatePrefixFilterList",
9000 filter
->plist
[FILTER_IN
].name
);
9001 if (filter
->plist
[FILTER_OUT
].name
)
9002 json_object_string_add(json_addr
,
9003 "outgoingUpdatePrefixFilterList",
9004 filter
->plist
[FILTER_OUT
].name
);
9006 /* distribute-list */
9007 if (filter
->dlist
[FILTER_IN
].name
)
9008 json_object_string_add(
9009 json_addr
, "incomingUpdateNetworkFilterList",
9010 filter
->dlist
[FILTER_IN
].name
);
9011 if (filter
->dlist
[FILTER_OUT
].name
)
9012 json_object_string_add(
9013 json_addr
, "outgoingUpdateNetworkFilterList",
9014 filter
->dlist
[FILTER_OUT
].name
);
9017 if (filter
->aslist
[FILTER_IN
].name
)
9018 json_object_string_add(json_addr
,
9019 "incomingUpdateAsPathFilterList",
9020 filter
->aslist
[FILTER_IN
].name
);
9021 if (filter
->aslist
[FILTER_OUT
].name
)
9022 json_object_string_add(json_addr
,
9023 "outgoingUpdateAsPathFilterList",
9024 filter
->aslist
[FILTER_OUT
].name
);
9027 if (filter
->map
[RMAP_IN
].name
)
9028 json_object_string_add(
9029 json_addr
, "routeMapForIncomingAdvertisements",
9030 filter
->map
[RMAP_IN
].name
);
9031 if (filter
->map
[RMAP_OUT
].name
)
9032 json_object_string_add(
9033 json_addr
, "routeMapForOutgoingAdvertisements",
9034 filter
->map
[RMAP_OUT
].name
);
9036 /* ebgp-requires-policy (inbound) */
9037 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9038 && !bgp_inbound_policy_exists(p
, filter
))
9039 json_object_string_add(
9040 json_addr
, "inboundEbgpRequiresPolicy",
9041 "Inbound updates discarded due to missing policy");
9043 /* ebgp-requires-policy (outbound) */
9044 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9045 && (!bgp_outbound_policy_exists(p
, filter
)))
9046 json_object_string_add(
9047 json_addr
, "outboundEbgpRequiresPolicy",
9048 "Outbound updates discarded due to missing policy");
9050 /* unsuppress-map */
9051 if (filter
->usmap
.name
)
9052 json_object_string_add(json_addr
,
9053 "selectiveUnsuppressRouteMap",
9054 filter
->usmap
.name
);
9056 /* Receive prefix count */
9057 json_object_int_add(json_addr
, "acceptedPrefixCounter",
9058 p
->pcount
[afi
][safi
]);
9059 if (paf
&& PAF_SUBGRP(paf
))
9060 json_object_int_add(json_addr
, "sentPrefixCounter",
9061 (PAF_SUBGRP(paf
))->scount
);
9063 /* Maximum prefix */
9064 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9065 json_object_int_add(json_addr
, "prefixAllowedMax",
9066 p
->pmax
[afi
][safi
]);
9067 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9068 PEER_FLAG_MAX_PREFIX_WARNING
))
9069 json_object_boolean_true_add(
9070 json_addr
, "prefixAllowedMaxWarning");
9071 json_object_int_add(json_addr
,
9072 "prefixAllowedWarningThresh",
9073 p
->pmax_threshold
[afi
][safi
]);
9074 if (p
->pmax_restart
[afi
][safi
])
9075 json_object_int_add(
9077 "prefixAllowedRestartIntervalMsecs",
9078 p
->pmax_restart
[afi
][safi
] * 60000);
9080 json_object_object_add(json_neigh
, get_afi_safi_str(afi
, safi
, true),
9084 filter
= &p
->filter
[afi
][safi
];
9086 vty_out(vty
, " For address family: %s\n",
9087 get_afi_safi_str(afi
, safi
, false));
9089 if (peer_group_active(p
))
9090 vty_out(vty
, " %s peer-group member\n",
9093 paf
= peer_af_find(p
, afi
, safi
);
9094 if (paf
&& PAF_SUBGRP(paf
)) {
9095 vty_out(vty
, " Update group %" PRIu64
9096 ", subgroup %" PRIu64
"\n",
9097 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
9098 vty_out(vty
, " Packet Queue length %d\n",
9099 bpacket_queue_virtual_length(paf
));
9101 vty_out(vty
, " Not part of any update group\n");
9103 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9104 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9105 PEER_CAP_ORF_PREFIX_SM_RCV
)
9106 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9107 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
9108 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9109 PEER_CAP_ORF_PREFIX_RM_ADV
)
9110 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9111 PEER_CAP_ORF_PREFIX_RM_RCV
)
9112 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9113 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
9114 vty_out(vty
, " AF-dependant capabilities:\n");
9116 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9117 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9118 PEER_CAP_ORF_PREFIX_SM_RCV
)
9119 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9120 PEER_CAP_ORF_PREFIX_RM_ADV
)
9121 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9122 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
9124 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
9126 bgp_show_peer_afi_orf_cap(
9127 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
9128 PEER_CAP_ORF_PREFIX_RM_ADV
,
9129 PEER_CAP_ORF_PREFIX_SM_RCV
,
9130 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
9132 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9133 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9134 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
9135 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9136 PEER_CAP_ORF_PREFIX_RM_ADV
)
9137 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9138 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
9140 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
9141 ORF_TYPE_PREFIX_OLD
);
9142 bgp_show_peer_afi_orf_cap(
9143 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
9144 PEER_CAP_ORF_PREFIX_RM_ADV
,
9145 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
9146 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
9149 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
9150 orf_pfx_count
= prefix_bgp_show_prefix_list(
9151 NULL
, afi
, orf_pfx_name
, use_json
);
9153 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9154 PEER_STATUS_ORF_PREFIX_SEND
)
9156 vty_out(vty
, " Outbound Route Filter (ORF):");
9157 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9158 PEER_STATUS_ORF_PREFIX_SEND
))
9159 vty_out(vty
, " sent;");
9161 vty_out(vty
, " received (%d entries)",
9165 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9166 PEER_STATUS_ORF_WAIT_REFRESH
))
9168 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
9170 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9171 PEER_FLAG_REFLECTOR_CLIENT
))
9172 vty_out(vty
, " Route-Reflector Client\n");
9173 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9174 PEER_FLAG_RSERVER_CLIENT
))
9175 vty_out(vty
, " Route-Server Client\n");
9176 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9178 " Inbound soft reconfiguration allowed\n");
9180 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9181 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
9183 " Private AS numbers (all) replaced in updates to this neighbor\n");
9184 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9185 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
9187 " Private AS numbers replaced in updates to this neighbor\n");
9188 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9189 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
9191 " Private AS numbers (all) removed in updates to this neighbor\n");
9192 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9193 PEER_FLAG_REMOVE_PRIVATE_AS
))
9195 " Private AS numbers removed in updates to this neighbor\n");
9197 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
9198 vty_out(vty
, " %s\n",
9199 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
9200 ->human_description
);
9202 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
9204 " Override ASNs in outbound updates if aspath equals remote-as\n");
9206 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
9207 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9208 PEER_FLAG_FORCE_NEXTHOP_SELF
))
9209 vty_out(vty
, " NEXT_HOP is always this router\n");
9210 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9211 PEER_FLAG_AS_PATH_UNCHANGED
))
9213 " AS_PATH is propagated unchanged to this neighbor\n");
9214 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9215 PEER_FLAG_NEXTHOP_UNCHANGED
))
9217 " NEXT_HOP is propagated unchanged to this neighbor\n");
9218 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
9220 " MED is propagated unchanged to this neighbor\n");
9221 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
9222 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9223 PEER_FLAG_SEND_EXT_COMMUNITY
)
9224 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9225 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
9227 " Community attribute sent to this neighbor");
9228 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9229 PEER_FLAG_SEND_COMMUNITY
)
9230 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9231 PEER_FLAG_SEND_EXT_COMMUNITY
)
9232 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9233 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9234 vty_out(vty
, "(all)\n");
9235 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9236 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9237 vty_out(vty
, "(large)\n");
9238 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9239 PEER_FLAG_SEND_EXT_COMMUNITY
))
9240 vty_out(vty
, "(extended)\n");
9242 vty_out(vty
, "(standard)\n");
9244 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9245 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9246 vty_out(vty
, " Default information originate,");
9248 if (p
->default_rmap
[afi
][safi
].name
)
9249 vty_out(vty
, " default route-map %s%s,",
9250 p
->default_rmap
[afi
][safi
].map
? "*"
9252 p
->default_rmap
[afi
][safi
].name
);
9253 if (paf
&& PAF_SUBGRP(paf
)
9254 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9255 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9256 vty_out(vty
, " default sent\n");
9258 vty_out(vty
, " default not sent\n");
9261 /* advertise-vni-all */
9262 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9263 if (is_evpn_enabled())
9264 vty_out(vty
, " advertise-all-vni\n");
9267 if (filter
->plist
[FILTER_IN
].name
9268 || filter
->dlist
[FILTER_IN
].name
9269 || filter
->aslist
[FILTER_IN
].name
9270 || filter
->map
[RMAP_IN
].name
)
9271 vty_out(vty
, " Inbound path policy configured\n");
9272 if (filter
->plist
[FILTER_OUT
].name
9273 || filter
->dlist
[FILTER_OUT
].name
9274 || filter
->aslist
[FILTER_OUT
].name
9275 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9276 vty_out(vty
, " Outbound path policy configured\n");
9279 if (filter
->plist
[FILTER_IN
].name
)
9281 " Incoming update prefix filter list is %s%s\n",
9282 filter
->plist
[FILTER_IN
].plist
? "*" : "",
9283 filter
->plist
[FILTER_IN
].name
);
9284 if (filter
->plist
[FILTER_OUT
].name
)
9286 " Outgoing update prefix filter list is %s%s\n",
9287 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
9288 filter
->plist
[FILTER_OUT
].name
);
9290 /* distribute-list */
9291 if (filter
->dlist
[FILTER_IN
].name
)
9293 " Incoming update network filter list is %s%s\n",
9294 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
9295 filter
->dlist
[FILTER_IN
].name
);
9296 if (filter
->dlist
[FILTER_OUT
].name
)
9298 " Outgoing update network filter list is %s%s\n",
9299 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
9300 filter
->dlist
[FILTER_OUT
].name
);
9303 if (filter
->aslist
[FILTER_IN
].name
)
9305 " Incoming update AS path filter list is %s%s\n",
9306 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
9307 filter
->aslist
[FILTER_IN
].name
);
9308 if (filter
->aslist
[FILTER_OUT
].name
)
9310 " Outgoing update AS path filter list is %s%s\n",
9311 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
9312 filter
->aslist
[FILTER_OUT
].name
);
9315 if (filter
->map
[RMAP_IN
].name
)
9317 " Route map for incoming advertisements is %s%s\n",
9318 filter
->map
[RMAP_IN
].map
? "*" : "",
9319 filter
->map
[RMAP_IN
].name
);
9320 if (filter
->map
[RMAP_OUT
].name
)
9322 " Route map for outgoing advertisements is %s%s\n",
9323 filter
->map
[RMAP_OUT
].map
? "*" : "",
9324 filter
->map
[RMAP_OUT
].name
);
9326 /* ebgp-requires-policy (inbound) */
9327 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9328 && !bgp_inbound_policy_exists(p
, filter
))
9330 " Inbound updates discarded due to missing policy\n");
9332 /* ebgp-requires-policy (outbound) */
9333 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9334 && !bgp_outbound_policy_exists(p
, filter
))
9336 " Outbound updates discarded due to missing policy\n");
9338 /* unsuppress-map */
9339 if (filter
->usmap
.name
)
9341 " Route map for selective unsuppress is %s%s\n",
9342 filter
->usmap
.map
? "*" : "",
9343 filter
->usmap
.name
);
9345 /* Receive prefix count */
9346 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
9348 /* Maximum prefix */
9349 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9350 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
9352 CHECK_FLAG(p
->af_flags
[afi
][safi
],
9353 PEER_FLAG_MAX_PREFIX_WARNING
)
9356 vty_out(vty
, " Threshold for warning message %d%%",
9357 p
->pmax_threshold
[afi
][safi
]);
9358 if (p
->pmax_restart
[afi
][safi
])
9359 vty_out(vty
, ", restart interval %d min",
9360 p
->pmax_restart
[afi
][safi
]);
9368 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
9372 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
9373 char timebuf
[BGP_UPTIME_LEN
];
9379 json_object
*json_neigh
= NULL
;
9385 json_neigh
= json_object_new_object();
9387 memset(dn_flag
, '\0', sizeof(dn_flag
));
9388 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9392 if (p
->conf_if
) /* Configured interface name. */
9393 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9394 BGP_PEER_SU_UNSPEC(p
)
9396 : sockunion2str(&p
->su
, buf
,
9398 else /* Configured IP address. */
9399 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9404 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9405 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9407 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9408 json_object_string_add(
9409 json_neigh
, "bgpNeighborAddr",
9410 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9412 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9414 if (p
->change_local_as
)
9415 json_object_int_add(json_neigh
, "localAs",
9416 p
->change_local_as
);
9418 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9420 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9421 json_object_boolean_true_add(json_neigh
,
9422 "localAsNoPrepend");
9424 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9425 json_object_boolean_true_add(json_neigh
,
9426 "localAsReplaceAs");
9428 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9429 || (p
->as_type
== AS_INTERNAL
))
9430 vty_out(vty
, "remote AS %u, ", p
->as
);
9432 vty_out(vty
, "remote AS Unspecified, ");
9433 vty_out(vty
, "local AS %u%s%s, ",
9434 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9435 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9438 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9442 /* peer type internal or confed-internal */
9443 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
9445 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9446 json_object_boolean_true_add(
9447 json_neigh
, "nbrConfedInternalLink");
9449 json_object_boolean_true_add(json_neigh
,
9452 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9453 vty_out(vty
, "confed-internal link\n");
9455 vty_out(vty
, "internal link\n");
9457 /* peer type external or confed-external */
9458 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
9460 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9461 json_object_boolean_true_add(
9462 json_neigh
, "nbrConfedExternalLink");
9464 json_object_boolean_true_add(json_neigh
,
9467 if (bgp_confederation_peers_check(bgp
, p
->as
))
9468 vty_out(vty
, "confed-external link\n");
9470 vty_out(vty
, "external link\n");
9474 json_object_boolean_true_add(json_neigh
,
9475 "nbrUnspecifiedLink");
9477 vty_out(vty
, "unspecified link\n");
9483 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9485 vty_out(vty
, " Description: %s\n", p
->desc
);
9491 json_object_string_add(json_neigh
, "hostname",
9495 json_object_string_add(json_neigh
, "domainname",
9498 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9499 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9502 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9509 json_object_string_add(json_neigh
, "peerGroup",
9513 struct prefix prefix
, *range
= NULL
;
9515 sockunion2hostprefix(&(p
->su
), &prefix
);
9516 range
= peer_group_lookup_dynamic_neighbor_range(
9520 prefix2str(range
, buf1
, sizeof(buf1
));
9521 json_object_string_add(
9523 "peerSubnetRangeGroup", buf1
);
9528 " Member of peer-group %s for session parameters\n",
9532 struct prefix prefix
, *range
= NULL
;
9534 sockunion2hostprefix(&(p
->su
), &prefix
);
9535 range
= peer_group_lookup_dynamic_neighbor_range(
9539 prefix2str(range
, buf1
, sizeof(buf1
));
9541 " Belongs to the subnet range group: %s\n",
9549 /* Administrative shutdown. */
9550 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9551 json_object_boolean_true_add(json_neigh
,
9555 json_object_int_add(json_neigh
, "bgpVersion", 4);
9556 json_object_string_add(
9557 json_neigh
, "remoteRouterId",
9558 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9559 json_object_string_add(
9560 json_neigh
, "localRouterId",
9561 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9565 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9566 && bgp_confederation_peers_check(bgp
, p
->as
))
9567 json_object_boolean_true_add(json_neigh
,
9571 json_object_string_add(
9572 json_neigh
, "bgpState",
9573 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9575 if (p
->status
== Established
) {
9578 uptime
= bgp_clock();
9579 uptime
-= p
->uptime
;
9580 epoch_tbuf
= time(NULL
) - uptime
;
9582 #if CONFDATE > 20200101
9584 "bgpTimerUp should be deprecated and can be removed now");
9587 * bgpTimerUp was miliseconds that was accurate
9588 * up to 1 day, then the value returned
9589 * became garbage. So in order to provide
9590 * some level of backwards compatability,
9591 * we still provde the data, but now
9592 * we are returning the correct value
9593 * and also adding a new bgpTimerUpMsec
9594 * which will allow us to deprecate
9597 json_object_int_add(json_neigh
, "bgpTimerUp",
9599 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9601 json_object_string_add(json_neigh
, "bgpTimerUpString",
9602 peer_uptime(p
->uptime
, timebuf
,
9605 json_object_int_add(json_neigh
,
9606 "bgpTimerUpEstablishedEpoch",
9610 else if (p
->status
== Active
) {
9611 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9612 json_object_string_add(json_neigh
, "bgpStateIs",
9614 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9615 json_object_string_add(json_neigh
, "bgpStateIs",
9623 uptime
= bgp_clock();
9624 uptime
-= p
->readtime
;
9625 tm
= gmtime(&uptime
);
9626 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9627 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9628 + (tm
->tm_hour
* 3600000));
9630 uptime
= bgp_clock();
9631 uptime
-= p
->last_write
;
9632 tm
= gmtime(&uptime
);
9633 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9634 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9635 + (tm
->tm_hour
* 3600000));
9637 uptime
= bgp_clock();
9638 uptime
-= p
->update_time
;
9639 tm
= gmtime(&uptime
);
9640 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9641 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9642 + (tm
->tm_hour
* 3600000));
9644 /* Configured timer values. */
9645 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9646 p
->v_holdtime
* 1000);
9647 json_object_int_add(json_neigh
,
9648 "bgpTimerKeepAliveIntervalMsecs",
9649 p
->v_keepalive
* 1000);
9650 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9651 json_object_int_add(json_neigh
,
9652 "bgpTimerConfiguredHoldTimeMsecs",
9653 p
->holdtime
* 1000);
9654 json_object_int_add(
9656 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9657 p
->keepalive
* 1000);
9658 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9659 || (bgp
->default_keepalive
9660 != BGP_DEFAULT_KEEPALIVE
)) {
9661 json_object_int_add(json_neigh
,
9662 "bgpTimerConfiguredHoldTimeMsecs",
9663 bgp
->default_holdtime
);
9664 json_object_int_add(
9666 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9667 bgp
->default_keepalive
);
9670 /* Administrative shutdown. */
9671 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9672 vty_out(vty
, " Administratively shut down\n");
9675 vty_out(vty
, " BGP version 4");
9676 vty_out(vty
, ", remote router ID %s",
9677 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9678 vty_out(vty
, ", local router ID %s\n",
9679 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9683 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9684 && bgp_confederation_peers_check(bgp
, p
->as
))
9686 " Neighbor under common administration\n");
9689 vty_out(vty
, " BGP state = %s",
9690 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9692 if (p
->status
== Established
)
9693 vty_out(vty
, ", up for %8s",
9694 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9697 else if (p
->status
== Active
) {
9698 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9699 vty_out(vty
, " (passive)");
9700 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9701 vty_out(vty
, " (NSF passive)");
9706 vty_out(vty
, " Last read %s",
9707 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9709 vty_out(vty
, ", Last write %s\n",
9710 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9713 /* Configured timer values. */
9715 " Hold time is %d, keepalive interval is %d seconds\n",
9716 p
->v_holdtime
, p
->v_keepalive
);
9717 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9718 vty_out(vty
, " Configured hold time is %d",
9720 vty_out(vty
, ", keepalive interval is %d seconds\n",
9722 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9723 || (bgp
->default_keepalive
9724 != BGP_DEFAULT_KEEPALIVE
)) {
9725 vty_out(vty
, " Configured hold time is %d",
9726 bgp
->default_holdtime
);
9727 vty_out(vty
, ", keepalive interval is %d seconds\n",
9728 bgp
->default_keepalive
);
9732 if (p
->status
== Established
) {
9733 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9734 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9735 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9736 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9737 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9738 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9739 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9740 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9741 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9742 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9743 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9744 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9745 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9746 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9747 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9748 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9749 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9750 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9751 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9752 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9754 json_object
*json_cap
= NULL
;
9756 json_cap
= json_object_new_object();
9759 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9760 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9761 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9762 && CHECK_FLAG(p
->cap
,
9764 json_object_string_add(
9765 json_cap
, "4byteAs",
9766 "advertisedAndReceived");
9767 else if (CHECK_FLAG(p
->cap
,
9769 json_object_string_add(
9770 json_cap
, "4byteAs",
9772 else if (CHECK_FLAG(p
->cap
,
9774 json_object_string_add(
9775 json_cap
, "4byteAs",
9780 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9781 || CHECK_FLAG(p
->cap
,
9782 PEER_CAP_ADDPATH_ADV
)) {
9783 json_object
*json_add
= NULL
;
9784 const char *print_store
;
9786 json_add
= json_object_new_object();
9788 FOREACH_AFI_SAFI (afi
, safi
) {
9789 json_object
*json_sub
= NULL
;
9791 json_object_new_object();
9792 print_store
= get_afi_safi_str(
9798 PEER_CAP_ADDPATH_AF_TX_ADV
)
9802 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9807 PEER_CAP_ADDPATH_AF_TX_ADV
)
9812 PEER_CAP_ADDPATH_AF_TX_RCV
))
9813 json_object_boolean_true_add(
9815 "txAdvertisedAndReceived");
9821 PEER_CAP_ADDPATH_AF_TX_ADV
))
9822 json_object_boolean_true_add(
9830 PEER_CAP_ADDPATH_AF_TX_RCV
))
9831 json_object_boolean_true_add(
9839 PEER_CAP_ADDPATH_AF_RX_ADV
)
9843 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9848 PEER_CAP_ADDPATH_AF_RX_ADV
)
9853 PEER_CAP_ADDPATH_AF_RX_RCV
))
9854 json_object_boolean_true_add(
9856 "rxAdvertisedAndReceived");
9862 PEER_CAP_ADDPATH_AF_RX_ADV
))
9863 json_object_boolean_true_add(
9871 PEER_CAP_ADDPATH_AF_RX_RCV
))
9872 json_object_boolean_true_add(
9880 PEER_CAP_ADDPATH_AF_TX_ADV
)
9884 PEER_CAP_ADDPATH_AF_TX_RCV
)
9888 PEER_CAP_ADDPATH_AF_RX_ADV
)
9892 PEER_CAP_ADDPATH_AF_RX_RCV
))
9893 json_object_object_add(
9902 json_object_object_add(
9903 json_cap
, "addPath", json_add
);
9907 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9908 || CHECK_FLAG(p
->cap
,
9909 PEER_CAP_DYNAMIC_ADV
)) {
9910 if (CHECK_FLAG(p
->cap
,
9911 PEER_CAP_DYNAMIC_ADV
)
9912 && CHECK_FLAG(p
->cap
,
9913 PEER_CAP_DYNAMIC_RCV
))
9914 json_object_string_add(
9915 json_cap
, "dynamic",
9916 "advertisedAndReceived");
9917 else if (CHECK_FLAG(
9919 PEER_CAP_DYNAMIC_ADV
))
9920 json_object_string_add(
9921 json_cap
, "dynamic",
9923 else if (CHECK_FLAG(
9925 PEER_CAP_DYNAMIC_RCV
))
9926 json_object_string_add(
9927 json_cap
, "dynamic",
9931 /* Extended nexthop */
9932 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9933 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9934 json_object
*json_nxt
= NULL
;
9935 const char *print_store
;
9938 if (CHECK_FLAG(p
->cap
,
9940 && CHECK_FLAG(p
->cap
,
9942 json_object_string_add(
9945 "advertisedAndReceived");
9946 else if (CHECK_FLAG(p
->cap
,
9948 json_object_string_add(
9952 else if (CHECK_FLAG(p
->cap
,
9954 json_object_string_add(
9959 if (CHECK_FLAG(p
->cap
,
9960 PEER_CAP_ENHE_RCV
)) {
9962 json_object_new_object();
9964 for (safi
= SAFI_UNICAST
;
9965 safi
< SAFI_MAX
; safi
++) {
9970 PEER_CAP_ENHE_AF_RCV
)) {
9971 print_store
= get_afi_safi_str(
9974 json_object_string_add(
9977 "recieved"); /* misspelled for compatibility */
9980 json_object_object_add(
9982 "extendedNexthopFamililesByPeer",
9988 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9989 || CHECK_FLAG(p
->cap
,
9990 PEER_CAP_REFRESH_NEW_RCV
)
9991 || CHECK_FLAG(p
->cap
,
9992 PEER_CAP_REFRESH_OLD_RCV
)) {
9993 if (CHECK_FLAG(p
->cap
,
9994 PEER_CAP_REFRESH_ADV
)
9997 PEER_CAP_REFRESH_NEW_RCV
)
10000 PEER_CAP_REFRESH_OLD_RCV
))) {
10003 PEER_CAP_REFRESH_OLD_RCV
)
10006 PEER_CAP_REFRESH_NEW_RCV
))
10007 json_object_string_add(
10010 "advertisedAndReceivedOldNew");
10014 PEER_CAP_REFRESH_OLD_RCV
))
10015 json_object_string_add(
10018 "advertisedAndReceivedOld");
10020 json_object_string_add(
10023 "advertisedAndReceivedNew");
10028 PEER_CAP_REFRESH_ADV
))
10029 json_object_string_add(
10036 PEER_CAP_REFRESH_NEW_RCV
)
10039 PEER_CAP_REFRESH_OLD_RCV
))
10040 json_object_string_add(
10046 /* Multiprotocol Extensions */
10047 json_object
*json_multi
= NULL
;
10048 json_multi
= json_object_new_object();
10050 FOREACH_AFI_SAFI (afi
, safi
) {
10051 if (p
->afc_adv
[afi
][safi
]
10052 || p
->afc_recv
[afi
][safi
]) {
10053 json_object
*json_exten
= NULL
;
10055 json_object_new_object();
10057 if (p
->afc_adv
[afi
][safi
]
10058 && p
->afc_recv
[afi
][safi
])
10059 json_object_boolean_true_add(
10061 "advertisedAndReceived");
10062 else if (p
->afc_adv
[afi
][safi
])
10063 json_object_boolean_true_add(
10066 else if (p
->afc_recv
[afi
][safi
])
10067 json_object_boolean_true_add(
10071 json_object_object_add(
10073 get_afi_safi_str(afi
,
10079 json_object_object_add(
10080 json_cap
, "multiprotocolExtensions",
10083 /* Hostname capabilities */
10084 json_object
*json_hname
= NULL
;
10086 json_hname
= json_object_new_object();
10088 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10089 json_object_string_add(
10090 json_hname
, "advHostName",
10091 bgp
->peer_self
->hostname
10095 json_object_string_add(
10096 json_hname
, "advDomainName",
10097 bgp
->peer_self
->domainname
10104 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10105 json_object_string_add(
10106 json_hname
, "rcvHostName",
10107 p
->hostname
? p
->hostname
10109 json_object_string_add(
10110 json_hname
, "rcvDomainName",
10111 p
->domainname
? p
->domainname
10115 json_object_object_add(json_cap
, "hostName",
10118 /* Gracefull Restart */
10119 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10120 || CHECK_FLAG(p
->cap
,
10121 PEER_CAP_RESTART_ADV
)) {
10122 if (CHECK_FLAG(p
->cap
,
10123 PEER_CAP_RESTART_ADV
)
10124 && CHECK_FLAG(p
->cap
,
10125 PEER_CAP_RESTART_RCV
))
10126 json_object_string_add(
10129 "advertisedAndReceived");
10130 else if (CHECK_FLAG(
10132 PEER_CAP_RESTART_ADV
))
10133 json_object_string_add(
10135 "gracefulRestartCapability",
10137 else if (CHECK_FLAG(
10139 PEER_CAP_RESTART_RCV
))
10140 json_object_string_add(
10142 "gracefulRestartCapability",
10145 if (CHECK_FLAG(p
->cap
,
10146 PEER_CAP_RESTART_RCV
)) {
10147 int restart_af_count
= 0;
10148 json_object
*json_restart
=
10151 json_object_new_object();
10153 json_object_int_add(
10155 "gracefulRestartRemoteTimerMsecs",
10156 p
->v_gr_restart
* 1000);
10158 FOREACH_AFI_SAFI (afi
, safi
) {
10163 PEER_CAP_RESTART_AF_RCV
)) {
10168 json_object_new_object();
10174 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
10175 json_object_boolean_true_add(
10178 restart_af_count
++;
10179 json_object_object_add(
10188 if (!restart_af_count
) {
10189 json_object_string_add(
10191 "addressFamiliesByPeer",
10196 json_object_object_add(
10198 "addressFamiliesByPeer",
10202 json_object_object_add(json_neigh
,
10203 "neighborCapabilities",
10206 vty_out(vty
, " Neighbor capabilities:\n");
10209 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
10210 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
10211 vty_out(vty
, " 4 Byte AS:");
10212 if (CHECK_FLAG(p
->cap
,
10214 vty_out(vty
, " advertised");
10215 if (CHECK_FLAG(p
->cap
,
10217 vty_out(vty
, " %sreceived",
10223 vty_out(vty
, "\n");
10227 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
10228 || CHECK_FLAG(p
->cap
,
10229 PEER_CAP_ADDPATH_ADV
)) {
10230 vty_out(vty
, " AddPath:\n");
10232 FOREACH_AFI_SAFI (afi
, safi
) {
10236 PEER_CAP_ADDPATH_AF_TX_ADV
)
10240 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
10252 PEER_CAP_ADDPATH_AF_TX_ADV
))
10264 PEER_CAP_ADDPATH_AF_TX_RCV
))
10271 PEER_CAP_ADDPATH_AF_TX_ADV
)
10275 vty_out(vty
, "\n");
10281 PEER_CAP_ADDPATH_AF_RX_ADV
)
10285 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
10297 PEER_CAP_ADDPATH_AF_RX_ADV
))
10309 PEER_CAP_ADDPATH_AF_RX_RCV
))
10316 PEER_CAP_ADDPATH_AF_RX_ADV
)
10320 vty_out(vty
, "\n");
10326 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10327 || CHECK_FLAG(p
->cap
,
10328 PEER_CAP_DYNAMIC_ADV
)) {
10329 vty_out(vty
, " Dynamic:");
10330 if (CHECK_FLAG(p
->cap
,
10331 PEER_CAP_DYNAMIC_ADV
))
10332 vty_out(vty
, " advertised");
10333 if (CHECK_FLAG(p
->cap
,
10334 PEER_CAP_DYNAMIC_RCV
))
10335 vty_out(vty
, " %sreceived",
10338 PEER_CAP_DYNAMIC_ADV
)
10341 vty_out(vty
, "\n");
10344 /* Extended nexthop */
10345 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10346 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10347 vty_out(vty
, " Extended nexthop:");
10348 if (CHECK_FLAG(p
->cap
,
10349 PEER_CAP_ENHE_ADV
))
10350 vty_out(vty
, " advertised");
10351 if (CHECK_FLAG(p
->cap
,
10352 PEER_CAP_ENHE_RCV
))
10353 vty_out(vty
, " %sreceived",
10359 vty_out(vty
, "\n");
10361 if (CHECK_FLAG(p
->cap
,
10362 PEER_CAP_ENHE_RCV
)) {
10364 " Address families by peer:\n ");
10365 for (safi
= SAFI_UNICAST
;
10366 safi
< SAFI_MAX
; safi
++)
10371 PEER_CAP_ENHE_AF_RCV
))
10381 /* Route Refresh */
10382 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10383 || CHECK_FLAG(p
->cap
,
10384 PEER_CAP_REFRESH_NEW_RCV
)
10385 || CHECK_FLAG(p
->cap
,
10386 PEER_CAP_REFRESH_OLD_RCV
)) {
10387 vty_out(vty
, " Route refresh:");
10388 if (CHECK_FLAG(p
->cap
,
10389 PEER_CAP_REFRESH_ADV
))
10390 vty_out(vty
, " advertised");
10391 if (CHECK_FLAG(p
->cap
,
10392 PEER_CAP_REFRESH_NEW_RCV
)
10395 PEER_CAP_REFRESH_OLD_RCV
))
10396 vty_out(vty
, " %sreceived(%s)",
10399 PEER_CAP_REFRESH_ADV
)
10404 PEER_CAP_REFRESH_OLD_RCV
)
10407 PEER_CAP_REFRESH_NEW_RCV
))
10411 PEER_CAP_REFRESH_OLD_RCV
)
10415 vty_out(vty
, "\n");
10418 /* Multiprotocol Extensions */
10419 FOREACH_AFI_SAFI (afi
, safi
)
10420 if (p
->afc_adv
[afi
][safi
]
10421 || p
->afc_recv
[afi
][safi
]) {
10423 " Address Family %s:",
10428 if (p
->afc_adv
[afi
][safi
])
10431 if (p
->afc_recv
[afi
][safi
])
10438 vty_out(vty
, "\n");
10441 /* Hostname capability */
10442 vty_out(vty
, " Hostname Capability:");
10444 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10446 " advertised (name: %s,domain name: %s)",
10447 bgp
->peer_self
->hostname
10451 bgp
->peer_self
->domainname
10456 vty_out(vty
, " not advertised");
10459 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10461 " received (name: %s,domain name: %s)",
10462 p
->hostname
? p
->hostname
10464 p
->domainname
? p
->domainname
10467 vty_out(vty
, " not received");
10470 vty_out(vty
, "\n");
10472 /* Gracefull Restart */
10473 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10474 || CHECK_FLAG(p
->cap
,
10475 PEER_CAP_RESTART_ADV
)) {
10477 " Graceful Restart Capabilty:");
10478 if (CHECK_FLAG(p
->cap
,
10479 PEER_CAP_RESTART_ADV
))
10480 vty_out(vty
, " advertised");
10481 if (CHECK_FLAG(p
->cap
,
10482 PEER_CAP_RESTART_RCV
))
10483 vty_out(vty
, " %sreceived",
10486 PEER_CAP_RESTART_ADV
)
10489 vty_out(vty
, "\n");
10491 if (CHECK_FLAG(p
->cap
,
10492 PEER_CAP_RESTART_RCV
)) {
10493 int restart_af_count
= 0;
10496 " Remote Restart timer is %d seconds\n",
10499 " Address families by peer:\n ");
10501 FOREACH_AFI_SAFI (afi
, safi
)
10506 PEER_CAP_RESTART_AF_RCV
)) {
10520 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10522 : "not preserved");
10523 restart_af_count
++;
10525 if (!restart_af_count
)
10526 vty_out(vty
, "none");
10527 vty_out(vty
, "\n");
10534 /* graceful restart information */
10535 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10536 || p
->t_gr_stale
) {
10537 json_object
*json_grace
= NULL
;
10538 json_object
*json_grace_send
= NULL
;
10539 json_object
*json_grace_recv
= NULL
;
10540 int eor_send_af_count
= 0;
10541 int eor_receive_af_count
= 0;
10544 json_grace
= json_object_new_object();
10545 json_grace_send
= json_object_new_object();
10546 json_grace_recv
= json_object_new_object();
10548 if (p
->status
== Established
) {
10549 FOREACH_AFI_SAFI (afi
, safi
) {
10550 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10551 PEER_STATUS_EOR_SEND
)) {
10552 json_object_boolean_true_add(
10554 get_afi_safi_str(afi
,
10557 eor_send_af_count
++;
10560 FOREACH_AFI_SAFI (afi
, safi
) {
10562 p
->af_sflags
[afi
][safi
],
10563 PEER_STATUS_EOR_RECEIVED
)) {
10564 json_object_boolean_true_add(
10566 get_afi_safi_str(afi
,
10569 eor_receive_af_count
++;
10574 json_object_object_add(json_grace
, "endOfRibSend",
10576 json_object_object_add(json_grace
, "endOfRibRecv",
10579 if (p
->t_gr_restart
)
10580 json_object_int_add(json_grace
,
10581 "gracefulRestartTimerMsecs",
10582 thread_timer_remain_second(
10587 json_object_int_add(
10589 "gracefulStalepathTimerMsecs",
10590 thread_timer_remain_second(
10594 json_object_object_add(
10595 json_neigh
, "gracefulRestartInfo", json_grace
);
10597 vty_out(vty
, " Graceful restart information:\n");
10598 if (p
->status
== Established
) {
10599 vty_out(vty
, " End-of-RIB send: ");
10600 FOREACH_AFI_SAFI (afi
, safi
) {
10601 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10602 PEER_STATUS_EOR_SEND
)) {
10603 vty_out(vty
, "%s%s",
10604 eor_send_af_count
? ", "
10606 get_afi_safi_str(afi
,
10609 eor_send_af_count
++;
10612 vty_out(vty
, "\n");
10613 vty_out(vty
, " End-of-RIB received: ");
10614 FOREACH_AFI_SAFI (afi
, safi
) {
10616 p
->af_sflags
[afi
][safi
],
10617 PEER_STATUS_EOR_RECEIVED
)) {
10618 vty_out(vty
, "%s%s",
10619 eor_receive_af_count
10622 get_afi_safi_str(afi
,
10625 eor_receive_af_count
++;
10628 vty_out(vty
, "\n");
10631 if (p
->t_gr_restart
)
10633 " The remaining time of restart timer is %ld\n",
10634 thread_timer_remain_second(
10639 " The remaining time of stalepath timer is %ld\n",
10640 thread_timer_remain_second(
10645 json_object
*json_stat
= NULL
;
10646 json_stat
= json_object_new_object();
10647 /* Packet counts. */
10648 json_object_int_add(json_stat
, "depthInq", 0);
10649 json_object_int_add(json_stat
, "depthOutq",
10650 (unsigned long)p
->obuf
->count
);
10651 json_object_int_add(json_stat
, "opensSent",
10652 atomic_load_explicit(&p
->open_out
,
10653 memory_order_relaxed
));
10654 json_object_int_add(json_stat
, "opensRecv",
10655 atomic_load_explicit(&p
->open_in
,
10656 memory_order_relaxed
));
10657 json_object_int_add(json_stat
, "notificationsSent",
10658 atomic_load_explicit(&p
->notify_out
,
10659 memory_order_relaxed
));
10660 json_object_int_add(json_stat
, "notificationsRecv",
10661 atomic_load_explicit(&p
->notify_in
,
10662 memory_order_relaxed
));
10663 json_object_int_add(json_stat
, "updatesSent",
10664 atomic_load_explicit(&p
->update_out
,
10665 memory_order_relaxed
));
10666 json_object_int_add(json_stat
, "updatesRecv",
10667 atomic_load_explicit(&p
->update_in
,
10668 memory_order_relaxed
));
10669 json_object_int_add(json_stat
, "keepalivesSent",
10670 atomic_load_explicit(&p
->keepalive_out
,
10671 memory_order_relaxed
));
10672 json_object_int_add(json_stat
, "keepalivesRecv",
10673 atomic_load_explicit(&p
->keepalive_in
,
10674 memory_order_relaxed
));
10675 json_object_int_add(json_stat
, "routeRefreshSent",
10676 atomic_load_explicit(&p
->refresh_out
,
10677 memory_order_relaxed
));
10678 json_object_int_add(json_stat
, "routeRefreshRecv",
10679 atomic_load_explicit(&p
->refresh_in
,
10680 memory_order_relaxed
));
10681 json_object_int_add(json_stat
, "capabilitySent",
10682 atomic_load_explicit(&p
->dynamic_cap_out
,
10683 memory_order_relaxed
));
10684 json_object_int_add(json_stat
, "capabilityRecv",
10685 atomic_load_explicit(&p
->dynamic_cap_in
,
10686 memory_order_relaxed
));
10687 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10688 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10689 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10691 /* Packet counts. */
10692 vty_out(vty
, " Message statistics:\n");
10693 vty_out(vty
, " Inq depth is 0\n");
10694 vty_out(vty
, " Outq depth is %lu\n",
10695 (unsigned long)p
->obuf
->count
);
10696 vty_out(vty
, " Sent Rcvd\n");
10697 vty_out(vty
, " Opens: %10d %10d\n",
10698 atomic_load_explicit(&p
->open_out
,
10699 memory_order_relaxed
),
10700 atomic_load_explicit(&p
->open_in
,
10701 memory_order_relaxed
));
10702 vty_out(vty
, " Notifications: %10d %10d\n",
10703 atomic_load_explicit(&p
->notify_out
,
10704 memory_order_relaxed
),
10705 atomic_load_explicit(&p
->notify_in
,
10706 memory_order_relaxed
));
10707 vty_out(vty
, " Updates: %10d %10d\n",
10708 atomic_load_explicit(&p
->update_out
,
10709 memory_order_relaxed
),
10710 atomic_load_explicit(&p
->update_in
,
10711 memory_order_relaxed
));
10712 vty_out(vty
, " Keepalives: %10d %10d\n",
10713 atomic_load_explicit(&p
->keepalive_out
,
10714 memory_order_relaxed
),
10715 atomic_load_explicit(&p
->keepalive_in
,
10716 memory_order_relaxed
));
10717 vty_out(vty
, " Route Refresh: %10d %10d\n",
10718 atomic_load_explicit(&p
->refresh_out
,
10719 memory_order_relaxed
),
10720 atomic_load_explicit(&p
->refresh_in
,
10721 memory_order_relaxed
));
10722 vty_out(vty
, " Capability: %10d %10d\n",
10723 atomic_load_explicit(&p
->dynamic_cap_out
,
10724 memory_order_relaxed
),
10725 atomic_load_explicit(&p
->dynamic_cap_in
,
10726 memory_order_relaxed
));
10727 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10732 /* advertisement-interval */
10733 json_object_int_add(json_neigh
,
10734 "minBtwnAdvertisementRunsTimerMsecs",
10735 p
->v_routeadv
* 1000);
10737 /* Update-source. */
10738 if (p
->update_if
|| p
->update_source
) {
10740 json_object_string_add(json_neigh
,
10743 else if (p
->update_source
)
10744 json_object_string_add(
10745 json_neigh
, "updateSource",
10746 sockunion2str(p
->update_source
, buf1
,
10750 /* advertisement-interval */
10752 " Minimum time between advertisement runs is %d seconds\n",
10755 /* Update-source. */
10756 if (p
->update_if
|| p
->update_source
) {
10757 vty_out(vty
, " Update source is ");
10759 vty_out(vty
, "%s", p
->update_if
);
10760 else if (p
->update_source
)
10762 sockunion2str(p
->update_source
, buf1
,
10764 vty_out(vty
, "\n");
10767 vty_out(vty
, "\n");
10770 /* Address Family Information */
10771 json_object
*json_hold
= NULL
;
10774 json_hold
= json_object_new_object();
10776 FOREACH_AFI_SAFI (afi
, safi
)
10777 if (p
->afc
[afi
][safi
])
10778 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10782 json_object_object_add(json_neigh
, "addressFamilyInfo",
10784 json_object_int_add(json_neigh
, "connectionsEstablished",
10786 json_object_int_add(json_neigh
, "connectionsDropped",
10789 vty_out(vty
, " Connections established %d; dropped %d\n",
10790 p
->established
, p
->dropped
);
10792 if (!p
->last_reset
) {
10794 json_object_string_add(json_neigh
, "lastReset",
10797 vty_out(vty
, " Last reset never\n");
10803 uptime
= bgp_clock();
10804 uptime
-= p
->resettime
;
10805 tm
= gmtime(&uptime
);
10806 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10807 (tm
->tm_sec
* 1000)
10808 + (tm
->tm_min
* 60000)
10809 + (tm
->tm_hour
* 3600000));
10810 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
10812 vty_out(vty
, " Last reset %s, ",
10813 peer_uptime(p
->resettime
, timebuf
,
10814 BGP_UPTIME_LEN
, 0, NULL
));
10816 bgp_show_peer_reset(vty
, p
, NULL
, false);
10817 if (p
->last_reset_cause_size
) {
10818 msg
= p
->last_reset_cause
;
10820 " Message received that caused BGP to send a NOTIFICATION:\n ");
10821 for (i
= 1; i
<= p
->last_reset_cause_size
;
10823 vty_out(vty
, "%02X", *msg
++);
10825 if (i
!= p
->last_reset_cause_size
) {
10827 vty_out(vty
, "\n ");
10828 } else if (i
% 4 == 0) {
10833 vty_out(vty
, "\n");
10838 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10840 json_object_boolean_true_add(json_neigh
,
10841 "prefixesConfigExceedMax");
10844 " Peer had exceeded the max. no. of prefixes configured.\n");
10846 if (p
->t_pmax_restart
) {
10848 json_object_boolean_true_add(
10849 json_neigh
, "reducePrefixNumFrom");
10850 json_object_int_add(json_neigh
,
10851 "restartInTimerMsec",
10852 thread_timer_remain_second(
10857 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10858 p
->host
, thread_timer_remain_second(
10859 p
->t_pmax_restart
));
10862 json_object_boolean_true_add(
10864 "reducePrefixNumAndClearIpBgp");
10867 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10872 /* EBGP Multihop and GTSM */
10873 if (p
->sort
!= BGP_PEER_IBGP
) {
10875 if (p
->gtsm_hops
> 0)
10876 json_object_int_add(json_neigh
,
10877 "externalBgpNbrMaxHopsAway",
10879 else if (p
->ttl
> 1)
10880 json_object_int_add(json_neigh
,
10881 "externalBgpNbrMaxHopsAway",
10884 if (p
->gtsm_hops
> 0)
10886 " External BGP neighbor may be up to %d hops away.\n",
10888 else if (p
->ttl
> 1)
10890 " External BGP neighbor may be up to %d hops away.\n",
10894 if (p
->gtsm_hops
> 0) {
10896 json_object_int_add(json_neigh
,
10897 "internalBgpNbrMaxHopsAway",
10901 " Internal BGP neighbor may be up to %d hops away.\n",
10906 /* Local address. */
10909 json_object_string_add(json_neigh
, "hostLocal",
10910 sockunion2str(p
->su_local
, buf1
,
10912 json_object_int_add(json_neigh
, "portLocal",
10913 ntohs(p
->su_local
->sin
.sin_port
));
10915 vty_out(vty
, "Local host: %s, Local port: %d\n",
10916 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10917 ntohs(p
->su_local
->sin
.sin_port
));
10920 /* Remote address. */
10921 if (p
->su_remote
) {
10923 json_object_string_add(json_neigh
, "hostForeign",
10924 sockunion2str(p
->su_remote
, buf1
,
10926 json_object_int_add(json_neigh
, "portForeign",
10927 ntohs(p
->su_remote
->sin
.sin_port
));
10929 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10930 sockunion2str(p
->su_remote
, buf1
,
10932 ntohs(p
->su_remote
->sin
.sin_port
));
10935 /* Nexthop display. */
10938 json_object_string_add(json_neigh
, "nexthop",
10940 &p
->nexthop
.v4
, buf1
,
10942 json_object_string_add(json_neigh
, "nexthopGlobal",
10943 inet_ntop(AF_INET6
,
10944 &p
->nexthop
.v6_global
,
10945 buf1
, sizeof(buf1
)));
10946 json_object_string_add(json_neigh
, "nexthopLocal",
10947 inet_ntop(AF_INET6
,
10948 &p
->nexthop
.v6_local
,
10949 buf1
, sizeof(buf1
)));
10950 if (p
->shared_network
)
10951 json_object_string_add(json_neigh
,
10955 json_object_string_add(json_neigh
,
10957 "nonSharedNetwork");
10959 vty_out(vty
, "Nexthop: %s\n",
10960 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10962 vty_out(vty
, "Nexthop global: %s\n",
10963 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10965 vty_out(vty
, "Nexthop local: %s\n",
10966 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10968 vty_out(vty
, "BGP connection: %s\n",
10969 p
->shared_network
? "shared network"
10970 : "non shared network");
10974 /* Timer information. */
10976 json_object_int_add(json_neigh
, "connectRetryTimer",
10978 if (p
->status
== Established
&& p
->rtt
)
10979 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10982 json_object_int_add(
10983 json_neigh
, "nextStartTimerDueInMsecs",
10984 thread_timer_remain_second(p
->t_start
) * 1000);
10986 json_object_int_add(
10987 json_neigh
, "nextConnectTimerDueInMsecs",
10988 thread_timer_remain_second(p
->t_connect
)
10990 if (p
->t_routeadv
) {
10991 json_object_int_add(json_neigh
, "mraiInterval",
10993 json_object_int_add(
10994 json_neigh
, "mraiTimerExpireInMsecs",
10995 thread_timer_remain_second(p
->t_routeadv
)
10999 json_object_int_add(json_neigh
, "authenticationEnabled",
11003 json_object_string_add(json_neigh
, "readThread", "on");
11005 json_object_string_add(json_neigh
, "readThread", "off");
11007 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
11008 json_object_string_add(json_neigh
, "writeThread", "on");
11010 json_object_string_add(json_neigh
, "writeThread",
11013 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
11015 if (p
->status
== Established
&& p
->rtt
)
11016 vty_out(vty
, "Estimated round trip time: %d ms\n",
11019 vty_out(vty
, "Next start timer due in %ld seconds\n",
11020 thread_timer_remain_second(p
->t_start
));
11022 vty_out(vty
, "Next connect timer due in %ld seconds\n",
11023 thread_timer_remain_second(p
->t_connect
));
11026 "MRAI (interval %u) timer expires in %ld seconds\n",
11028 thread_timer_remain_second(p
->t_routeadv
));
11030 vty_out(vty
, "Peer Authentication Enabled\n");
11032 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
11033 p
->t_read
? "on" : "off",
11034 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
11039 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
11040 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
11041 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
11044 vty_out(vty
, "\n");
11046 /* BFD information. */
11047 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
11050 if (p
->conf_if
) /* Configured interface name. */
11051 json_object_object_add(json
, p
->conf_if
, json_neigh
);
11052 else /* Configured IP address. */
11053 json_object_object_add(json
, p
->host
, json_neigh
);
11057 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
11058 enum show_type type
, union sockunion
*su
,
11059 const char *conf_if
, bool use_json
,
11062 struct listnode
*node
, *nnode
;
11065 bool nbr_output
= false;
11066 afi_t afi
= AFI_MAX
;
11067 safi_t safi
= SAFI_MAX
;
11069 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
11071 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
11075 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11076 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11081 bgp_show_peer(vty
, peer
, use_json
, json
);
11087 && !strcmp(peer
->conf_if
, conf_if
))
11089 && !strcmp(peer
->hostname
, conf_if
))) {
11091 bgp_show_peer(vty
, peer
, use_json
,
11095 if (sockunion_same(&peer
->su
, su
)) {
11097 bgp_show_peer(vty
, peer
, use_json
,
11102 case show_ipv4_peer
:
11103 case show_ipv6_peer
:
11104 FOREACH_SAFI (safi
) {
11105 if (peer
->afc
[afi
][safi
]) {
11108 && !strcmp(peer
->conf_if
, conf_if
))
11110 && !strcmp(peer
->hostname
, conf_if
))) {
11112 bgp_show_peer(vty
, peer
, use_json
,
11117 if (sockunion_same(&peer
->su
, su
)) {
11119 bgp_show_peer(vty
, peer
, use_json
,
11127 case show_ipv4_all
:
11128 case show_ipv6_all
:
11129 FOREACH_SAFI (safi
) {
11130 if (peer
->afc
[afi
][safi
]) {
11131 bgp_show_peer(vty
, peer
, use_json
, json
);
11140 if ((type
== show_peer
|| type
== show_ipv4_peer
||
11141 type
== show_ipv6_peer
) && !find
) {
11143 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
11145 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
11148 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
11149 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
11150 vty_out(vty
, "%% No BGP neighbors found\n");
11153 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11154 json
, JSON_C_TO_STRING_PRETTY
));
11156 vty_out(vty
, "\n");
11159 return CMD_SUCCESS
;
11162 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
11163 enum show_type type
,
11164 const char *ip_str
,
11167 struct listnode
*node
, *nnode
;
11169 union sockunion su
;
11170 json_object
*json
= NULL
;
11171 int ret
, is_first
= 1;
11172 bool nbr_output
= false;
11175 vty_out(vty
, "{\n");
11177 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11180 if (!(json
= json_object_new_object())) {
11182 EC_BGP_JSON_MEM_ERROR
,
11183 "Unable to allocate memory for JSON object");
11185 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
11189 json_object_int_add(json
, "vrfId",
11190 (bgp
->vrf_id
== VRF_UNKNOWN
)
11192 : (int64_t)bgp
->vrf_id
);
11193 json_object_string_add(
11195 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11200 vty_out(vty
, ",\n");
11204 vty_out(vty
, "\"%s\":",
11205 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11209 vty_out(vty
, "\nInstance %s:\n",
11210 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11215 if (type
== show_peer
|| type
== show_ipv4_peer
||
11216 type
== show_ipv6_peer
) {
11217 ret
= str2sockunion(ip_str
, &su
);
11219 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11222 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11225 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
11228 json_object_free(json
);
11232 vty_out(vty
, "}\n");
11233 json_object_free(json
);
11235 else if (!nbr_output
)
11236 vty_out(vty
, "%% BGP instance not found\n");
11239 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
11240 enum show_type type
, const char *ip_str
,
11245 union sockunion su
;
11246 json_object
*json
= NULL
;
11249 if (strmatch(name
, "all")) {
11250 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
11252 return CMD_SUCCESS
;
11254 bgp
= bgp_lookup_by_name(name
);
11257 json
= json_object_new_object();
11258 vty_out(vty
, "%s\n",
11259 json_object_to_json_string_ext(
11261 JSON_C_TO_STRING_PRETTY
));
11262 json_object_free(json
);
11265 "%% BGP instance not found\n");
11267 return CMD_WARNING
;
11271 bgp
= bgp_get_default();
11275 json
= json_object_new_object();
11277 ret
= str2sockunion(ip_str
, &su
);
11279 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11282 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11285 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
11288 json_object_free(json
);
11291 vty_out(vty
, "{}\n");
11293 vty_out(vty
, "%% BGP instance not found\n");
11296 return CMD_SUCCESS
;
11299 /* "show [ip] bgp neighbors" commands. */
11300 DEFUN (show_ip_bgp_neighbors
,
11301 show_ip_bgp_neighbors_cmd
,
11302 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
11306 BGP_INSTANCE_HELP_STR
11309 "Detailed information on TCP and BGP neighbor connections\n"
11310 "Neighbor to display information about\n"
11311 "Neighbor to display information about\n"
11312 "Neighbor on BGP configured interface\n"
11316 char *sh_arg
= NULL
;
11317 enum show_type sh_type
;
11318 afi_t afi
= AFI_MAX
;
11320 bool uj
= use_json(argc
, argv
);
11324 /* [<vrf> VIEWVRFNAME] */
11325 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11326 vrf
= argv
[idx
+ 1]->arg
;
11327 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11329 } else if (argv_find(argv
, argc
, "view", &idx
))
11330 /* [<view> VIEWVRFNAME] */
11331 vrf
= argv
[idx
+ 1]->arg
;
11335 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
11336 sh_type
= show_ipv4_all
;
11338 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
11339 sh_type
= show_ipv6_all
;
11342 sh_type
= show_all
;
11345 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
11346 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
11347 || argv_find(argv
, argc
, "WORD", &idx
)) {
11348 sh_type
= show_peer
;
11349 sh_arg
= argv
[idx
]->arg
;
11352 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
11353 sh_type
= show_ipv4_peer
;
11354 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
11355 sh_type
= show_ipv6_peer
;
11358 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
11361 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
11362 paths' and `show ip mbgp paths'. Those functions results are the
11364 DEFUN (show_ip_bgp_paths
,
11365 show_ip_bgp_paths_cmd
,
11366 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
11371 "Path information\n")
11373 vty_out(vty
, "Address Refcnt Path\n");
11374 aspath_print_all_vty(vty
);
11375 return CMD_SUCCESS
;
11380 static void community_show_all_iterator(struct hash_bucket
*bucket
,
11383 struct community
*com
;
11385 com
= (struct community
*)bucket
->data
;
11386 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
11387 community_str(com
, false));
11390 /* Show BGP's community internal data. */
11391 DEFUN (show_ip_bgp_community_info
,
11392 show_ip_bgp_community_info_cmd
,
11393 "show [ip] bgp community-info",
11397 "List all bgp community information\n")
11399 vty_out(vty
, "Address Refcnt Community\n");
11401 hash_iterate(community_hash(),
11402 (void (*)(struct hash_bucket
*,
11403 void *))community_show_all_iterator
,
11406 return CMD_SUCCESS
;
11409 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
11412 struct lcommunity
*lcom
;
11414 lcom
= (struct lcommunity
*)bucket
->data
;
11415 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11416 lcommunity_str(lcom
, false));
11419 /* Show BGP's community internal data. */
11420 DEFUN (show_ip_bgp_lcommunity_info
,
11421 show_ip_bgp_lcommunity_info_cmd
,
11422 "show ip bgp large-community-info",
11426 "List all bgp large-community information\n")
11428 vty_out(vty
, "Address Refcnt Large-community\n");
11430 hash_iterate(lcommunity_hash(),
11431 (void (*)(struct hash_bucket
*,
11432 void *))lcommunity_show_all_iterator
,
11435 return CMD_SUCCESS
;
11439 DEFUN (show_ip_bgp_attr_info
,
11440 show_ip_bgp_attr_info_cmd
,
11441 "show [ip] bgp attribute-info",
11445 "List all bgp attribute information\n")
11447 attr_show_all(vty
);
11448 return CMD_SUCCESS
;
11451 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
11452 afi_t afi
, safi_t safi
,
11453 bool use_json
, json_object
*json
)
11456 struct listnode
*node
;
11458 char buf1
[INET6_ADDRSTRLEN
];
11460 vpn_policy_direction_t dir
;
11463 json_object
*json_import_vrfs
= NULL
;
11464 json_object
*json_export_vrfs
= NULL
;
11466 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11469 vty_out(vty
, "%s\n",
11470 json_object_to_json_string_ext(
11472 JSON_C_TO_STRING_PRETTY
));
11473 json_object_free(json
);
11475 return CMD_WARNING
;
11478 /* Provide context for the block */
11479 json_object_string_add(json
, "vrf", name
? name
: "default");
11480 json_object_string_add(json
, "afiSafi",
11481 get_afi_safi_str(afi
, safi
, true));
11483 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11484 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11485 json_object_string_add(json
, "importFromVrfs", "none");
11486 json_object_string_add(json
, "importRts", "none");
11488 json_import_vrfs
= json_object_new_array();
11490 for (ALL_LIST_ELEMENTS_RO(
11491 bgp
->vpn_policy
[afi
].import_vrf
,
11493 json_object_array_add(json_import_vrfs
,
11494 json_object_new_string(vname
));
11496 json_object_object_add(json
, "importFromVrfs",
11498 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11499 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11500 ecom_str
= ecommunity_ecom2str(
11501 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11502 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11503 json_object_string_add(json
, "importRts",
11505 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11507 json_object_string_add(json
, "importRts",
11511 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11512 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11513 json_object_string_add(json
, "exportToVrfs", "none");
11514 json_object_string_add(json
, "routeDistinguisher",
11516 json_object_string_add(json
, "exportRts", "none");
11518 json_export_vrfs
= json_object_new_array();
11520 for (ALL_LIST_ELEMENTS_RO(
11521 bgp
->vpn_policy
[afi
].export_vrf
,
11523 json_object_array_add(json_export_vrfs
,
11524 json_object_new_string(vname
));
11525 json_object_object_add(json
, "exportToVrfs",
11527 json_object_string_add(json
, "routeDistinguisher",
11528 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11529 buf1
, RD_ADDRSTRLEN
));
11531 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11532 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11533 ecom_str
= ecommunity_ecom2str(
11534 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11535 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11536 json_object_string_add(json
, "exportRts",
11538 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11540 json_object_string_add(json
, "exportRts",
11545 vty_out(vty
, "%s\n",
11546 json_object_to_json_string_ext(json
,
11547 JSON_C_TO_STRING_PRETTY
));
11548 json_object_free(json
);
11551 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11554 vty_out(vty
, "%% No such BGP instance exist\n");
11555 return CMD_WARNING
;
11558 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11559 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11561 "This VRF is not importing %s routes from any other VRF\n",
11562 get_afi_safi_str(afi
, safi
, false));
11565 "This VRF is importing %s routes from the following VRFs:\n",
11566 get_afi_safi_str(afi
, safi
, false));
11568 for (ALL_LIST_ELEMENTS_RO(
11569 bgp
->vpn_policy
[afi
].import_vrf
,
11571 vty_out(vty
, " %s\n", vname
);
11573 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11575 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11576 ecom_str
= ecommunity_ecom2str(
11577 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11578 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11579 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11581 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11583 vty_out(vty
, "Import RT(s):\n");
11586 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11587 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11589 "This VRF is not exporting %s routes to any other VRF\n",
11590 get_afi_safi_str(afi
, safi
, false));
11593 "This VRF is exporting %s routes to the following VRFs:\n",
11594 get_afi_safi_str(afi
, safi
, false));
11596 for (ALL_LIST_ELEMENTS_RO(
11597 bgp
->vpn_policy
[afi
].export_vrf
,
11599 vty_out(vty
, " %s\n", vname
);
11601 vty_out(vty
, "RD: %s\n",
11602 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11603 buf1
, RD_ADDRSTRLEN
));
11605 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11606 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11607 ecom_str
= ecommunity_ecom2str(
11608 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11609 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11610 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11611 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11613 vty_out(vty
, "Import RT(s):\n");
11617 return CMD_SUCCESS
;
11620 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
11621 safi_t safi
, bool use_json
)
11623 struct listnode
*node
, *nnode
;
11625 char *vrf_name
= NULL
;
11626 json_object
*json
= NULL
;
11627 json_object
*json_vrf
= NULL
;
11628 json_object
*json_vrfs
= NULL
;
11631 json
= json_object_new_object();
11632 json_vrfs
= json_object_new_object();
11635 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11637 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
11638 vrf_name
= bgp
->name
;
11641 json_vrf
= json_object_new_object();
11643 vty_out(vty
, "\nInstance %s:\n",
11644 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11645 ? VRF_DEFAULT_NAME
: bgp
->name
);
11647 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
11649 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11650 json_object_object_add(json_vrfs
,
11651 VRF_DEFAULT_NAME
, json_vrf
);
11653 json_object_object_add(json_vrfs
, vrf_name
,
11659 json_object_object_add(json
, "vrfs", json_vrfs
);
11660 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
11661 JSON_C_TO_STRING_PRETTY
));
11662 json_object_free(json
);
11665 return CMD_SUCCESS
;
11668 /* "show [ip] bgp route-leak" command. */
11669 DEFUN (show_ip_bgp_route_leak
,
11670 show_ip_bgp_route_leak_cmd
,
11671 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11675 BGP_INSTANCE_HELP_STR
11678 "Route leaking information\n"
11682 afi_t afi
= AFI_MAX
;
11683 safi_t safi
= SAFI_MAX
;
11685 bool uj
= use_json(argc
, argv
);
11687 json_object
*json
= NULL
;
11689 /* show [ip] bgp */
11690 if (argv_find(argv
, argc
, "ip", &idx
)) {
11692 safi
= SAFI_UNICAST
;
11694 /* [vrf VIEWVRFNAME] */
11695 if (argv_find(argv
, argc
, "view", &idx
)) {
11697 "%% This command is not applicable to BGP views\n");
11698 return CMD_WARNING
;
11701 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11702 vrf
= argv
[idx
+ 1]->arg
;
11703 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11706 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11707 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11708 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11711 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11713 "%% This command is applicable only for unicast ipv4|ipv6\n");
11714 return CMD_WARNING
;
11717 if (vrf
&& strmatch(vrf
, "all"))
11718 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
11721 json
= json_object_new_object();
11723 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
11726 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11729 struct listnode
*node
, *nnode
;
11732 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11733 vty_out(vty
, "\nInstance %s:\n",
11734 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11737 update_group_show(bgp
, afi
, safi
, vty
, 0);
11741 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11742 int safi
, uint64_t subgrp_id
)
11747 if (strmatch(name
, "all")) {
11748 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11749 return CMD_SUCCESS
;
11751 bgp
= bgp_lookup_by_name(name
);
11754 bgp
= bgp_get_default();
11758 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11759 return CMD_SUCCESS
;
11762 DEFUN (show_ip_bgp_updgrps
,
11763 show_ip_bgp_updgrps_cmd
,
11764 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11768 BGP_INSTANCE_HELP_STR
11770 BGP_SAFI_WITH_LABEL_HELP_STR
11771 "Detailed info about dynamic update groups\n"
11772 "Specific subgroup to display detailed info for\n")
11775 afi_t afi
= AFI_IP6
;
11776 safi_t safi
= SAFI_UNICAST
;
11777 uint64_t subgrp_id
= 0;
11781 /* show [ip] bgp */
11782 if (argv_find(argv
, argc
, "ip", &idx
))
11784 /* [<vrf> VIEWVRFNAME] */
11785 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11786 vrf
= argv
[idx
+ 1]->arg
;
11787 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11789 } else if (argv_find(argv
, argc
, "view", &idx
))
11790 /* [<view> VIEWVRFNAME] */
11791 vrf
= argv
[idx
+ 1]->arg
;
11792 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11793 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11794 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11797 /* get subgroup id, if provided */
11799 if (argv
[idx
]->type
== VARIABLE_TKN
)
11800 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11802 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11805 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11806 show_bgp_instance_all_ipv6_updgrps_cmd
,
11807 "show [ip] bgp <view|vrf> all update-groups",
11811 BGP_INSTANCE_ALL_HELP_STR
11812 "Detailed info about dynamic update groups\n")
11814 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11815 return CMD_SUCCESS
;
11818 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
11819 show_bgp_l2vpn_evpn_updgrps_cmd
,
11820 "show [ip] bgp l2vpn evpn update-groups",
11824 "l2vpn address family\n"
11825 "evpn sub-address family\n"
11826 "Detailed info about dynamic update groups\n")
11829 uint64_t subgrp_id
= 0;
11831 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
11832 return CMD_SUCCESS
;
11835 DEFUN (show_bgp_updgrps_stats
,
11836 show_bgp_updgrps_stats_cmd
,
11837 "show [ip] bgp update-groups statistics",
11841 "Detailed info about dynamic update groups\n"
11846 bgp
= bgp_get_default();
11848 update_group_show_stats(bgp
, vty
);
11850 return CMD_SUCCESS
;
11853 DEFUN (show_bgp_instance_updgrps_stats
,
11854 show_bgp_instance_updgrps_stats_cmd
,
11855 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11859 BGP_INSTANCE_HELP_STR
11860 "Detailed info about dynamic update groups\n"
11866 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11868 update_group_show_stats(bgp
, vty
);
11870 return CMD_SUCCESS
;
11873 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11874 afi_t afi
, safi_t safi
,
11875 const char *what
, uint64_t subgrp_id
)
11880 bgp
= bgp_lookup_by_name(name
);
11882 bgp
= bgp_get_default();
11885 if (!strcmp(what
, "advertise-queue"))
11886 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11888 else if (!strcmp(what
, "advertised-routes"))
11889 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11891 else if (!strcmp(what
, "packet-queue"))
11892 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11897 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11898 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11899 "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",
11900 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11902 "Detailed info about dynamic update groups\n"
11903 "Specific subgroup to display info for\n"
11904 "Advertisement queue\n"
11905 "Announced routes\n"
11908 uint64_t subgrp_id
= 0;
11912 subgrp_id
= strtoull(sgid
, NULL
, 10);
11917 afiz
= bgp_vty_afi_from_str(afi
);
11921 afiz
= bgp_vty_afi_from_str(afi
);
11922 if (afiz
!= AFI_IP
)
11924 "%% Cannot specify both 'ip' and 'ipv6'\n");
11925 return CMD_WARNING
;
11928 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11930 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11931 return CMD_SUCCESS
;
11934 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11936 struct listnode
*node
, *nnode
;
11937 struct prefix
*range
;
11940 char buf
[PREFIX2STR_BUFFER
];
11943 const char *peer_status
;
11944 const char *af_str
;
11949 conf
= group
->conf
;
11951 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11952 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11953 group
->name
, conf
->as
);
11954 } else if (conf
->as_type
== AS_INTERNAL
) {
11955 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11956 group
->name
, group
->bgp
->as
);
11958 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11961 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11962 vty_out(vty
, " Peer-group type is internal\n");
11964 vty_out(vty
, " Peer-group type is external\n");
11966 /* Display AFs configured. */
11967 vty_out(vty
, " Configured address-families:");
11968 FOREACH_AFI_SAFI (afi
, safi
) {
11969 if (conf
->afc
[afi
][safi
]) {
11971 vty_out(vty
, " %s;", get_afi_safi_str(afi
, safi
, false));
11975 vty_out(vty
, " none\n");
11977 vty_out(vty
, "\n");
11979 /* Display listen ranges (for dynamic neighbors), if any */
11980 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11983 else if (afi
== AFI_IP6
)
11987 lr_count
= listcount(group
->listen_range
[afi
]);
11989 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11993 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11995 prefix2str(range
, buf
, sizeof(buf
));
11996 vty_out(vty
, " %s\n", buf
);
12001 /* Display group members and their status */
12002 if (listcount(group
->peer
)) {
12003 vty_out(vty
, " Peer-group members:\n");
12004 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
12005 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
12006 peer_status
= "Idle (Admin)";
12007 else if (CHECK_FLAG(peer
->sflags
,
12008 PEER_STATUS_PREFIX_OVERFLOW
))
12009 peer_status
= "Idle (PfxCt)";
12011 peer_status
= lookup_msg(bgp_status_msg
,
12012 peer
->status
, NULL
);
12014 dynamic
= peer_dynamic_neighbor(peer
);
12015 vty_out(vty
, " %s %s %s \n", peer
->host
,
12016 dynamic
? "(dynamic)" : "", peer_status
);
12020 return CMD_SUCCESS
;
12023 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
12024 const char *group_name
)
12027 struct listnode
*node
, *nnode
;
12028 struct peer_group
*group
;
12029 bool found
= false;
12031 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
12034 vty_out(vty
, "%% BGP instance not found\n");
12035 return CMD_WARNING
;
12038 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
12040 if (strmatch(group
->name
, group_name
)) {
12041 bgp_show_one_peer_group(vty
, group
);
12046 bgp_show_one_peer_group(vty
, group
);
12050 if (group_name
&& !found
)
12051 vty_out(vty
, "%% No such peer-group\n");
12053 return CMD_SUCCESS
;
12056 DEFUN (show_ip_bgp_peer_groups
,
12057 show_ip_bgp_peer_groups_cmd
,
12058 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
12062 BGP_INSTANCE_HELP_STR
12063 "Detailed information on BGP peer groups\n"
12064 "Peer group name\n")
12069 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
12071 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
12073 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
12077 /* Redistribute VTY commands. */
12079 DEFUN (bgp_redistribute_ipv4
,
12080 bgp_redistribute_ipv4_cmd
,
12081 "redistribute " FRR_IP_REDIST_STR_BGPD
,
12082 "Redistribute information from another routing protocol\n"
12083 FRR_IP_REDIST_HELP_STR_BGPD
)
12085 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12086 int idx_protocol
= 1;
12089 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12091 vty_out(vty
, "%% Invalid route type\n");
12092 return CMD_WARNING_CONFIG_FAILED
;
12095 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12096 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
12100 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
12101 "redistribute " FRR_IP_REDIST_STR_BGPD
,
12102 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
12104 DEFUN (bgp_redistribute_ipv4_rmap
,
12105 bgp_redistribute_ipv4_rmap_cmd
,
12106 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
12107 "Redistribute information from another routing protocol\n"
12108 FRR_IP_REDIST_HELP_STR_BGPD
12109 "Route map reference\n"
12110 "Pointer to route-map entries\n")
12112 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12113 int idx_protocol
= 1;
12116 struct bgp_redist
*red
;
12118 struct route_map
*route_map
= route_map_lookup_warn_noexist(
12119 vty
, argv
[idx_word
]->arg
);
12121 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12123 vty_out(vty
, "%% Invalid route type\n");
12124 return CMD_WARNING_CONFIG_FAILED
;
12127 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12129 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12130 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12134 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
12135 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
12136 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12137 "Route map reference\n"
12138 "Pointer to route-map entries\n")
12140 DEFUN (bgp_redistribute_ipv4_metric
,
12141 bgp_redistribute_ipv4_metric_cmd
,
12142 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12143 "Redistribute information from another routing protocol\n"
12144 FRR_IP_REDIST_HELP_STR_BGPD
12145 "Metric for redistributed routes\n"
12146 "Default metric\n")
12148 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12149 int idx_protocol
= 1;
12150 int idx_number
= 3;
12153 struct bgp_redist
*red
;
12156 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12158 vty_out(vty
, "%% Invalid route type\n");
12159 return CMD_WARNING_CONFIG_FAILED
;
12161 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12163 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12164 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12165 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12169 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
12170 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12171 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12172 "Metric for redistributed routes\n"
12173 "Default metric\n")
12175 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
12176 bgp_redistribute_ipv4_rmap_metric_cmd
,
12177 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12178 "Redistribute information from another routing protocol\n"
12179 FRR_IP_REDIST_HELP_STR_BGPD
12180 "Route map reference\n"
12181 "Pointer to route-map entries\n"
12182 "Metric for redistributed routes\n"
12183 "Default metric\n")
12185 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12186 int idx_protocol
= 1;
12188 int idx_number
= 5;
12191 struct bgp_redist
*red
;
12193 struct route_map
*route_map
=
12194 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12196 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12198 vty_out(vty
, "%% Invalid route type\n");
12199 return CMD_WARNING_CONFIG_FAILED
;
12201 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12203 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12205 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12206 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12207 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12211 bgp_redistribute_ipv4_rmap_metric
,
12212 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
12213 "redistribute " FRR_IP_REDIST_STR_BGPD
12214 " route-map WORD metric (0-4294967295)",
12215 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12216 "Route map reference\n"
12217 "Pointer to route-map entries\n"
12218 "Metric for redistributed routes\n"
12219 "Default metric\n")
12221 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
12222 bgp_redistribute_ipv4_metric_rmap_cmd
,
12223 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12224 "Redistribute information from another routing protocol\n"
12225 FRR_IP_REDIST_HELP_STR_BGPD
12226 "Metric for redistributed routes\n"
12228 "Route map reference\n"
12229 "Pointer to route-map entries\n")
12231 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12232 int idx_protocol
= 1;
12233 int idx_number
= 3;
12237 struct bgp_redist
*red
;
12239 struct route_map
*route_map
=
12240 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12242 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12244 vty_out(vty
, "%% Invalid route type\n");
12245 return CMD_WARNING_CONFIG_FAILED
;
12247 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12249 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12250 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12252 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12253 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12257 bgp_redistribute_ipv4_metric_rmap
,
12258 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
12259 "redistribute " FRR_IP_REDIST_STR_BGPD
12260 " metric (0-4294967295) route-map WORD",
12261 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12262 "Metric for redistributed routes\n"
12264 "Route map reference\n"
12265 "Pointer to route-map entries\n")
12267 DEFUN (bgp_redistribute_ipv4_ospf
,
12268 bgp_redistribute_ipv4_ospf_cmd
,
12269 "redistribute <ospf|table> (1-65535)",
12270 "Redistribute information from another routing protocol\n"
12271 "Open Shortest Path First (OSPFv2)\n"
12272 "Non-main Kernel Routing Table\n"
12273 "Instance ID/Table ID\n")
12275 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12276 int idx_ospf_table
= 1;
12277 int idx_number
= 2;
12278 unsigned short instance
;
12279 unsigned short protocol
;
12281 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12283 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12284 protocol
= ZEBRA_ROUTE_OSPF
;
12286 protocol
= ZEBRA_ROUTE_TABLE
;
12288 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12289 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
12292 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
12293 "redistribute <ospf|table> (1-65535)",
12294 "Redistribute information from another routing protocol\n"
12295 "Open Shortest Path First (OSPFv2)\n"
12296 "Non-main Kernel Routing Table\n"
12297 "Instance ID/Table ID\n")
12299 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
12300 bgp_redistribute_ipv4_ospf_rmap_cmd
,
12301 "redistribute <ospf|table> (1-65535) route-map WORD",
12302 "Redistribute information from another routing protocol\n"
12303 "Open Shortest Path First (OSPFv2)\n"
12304 "Non-main Kernel Routing Table\n"
12305 "Instance ID/Table ID\n"
12306 "Route map reference\n"
12307 "Pointer to route-map entries\n")
12309 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12310 int idx_ospf_table
= 1;
12311 int idx_number
= 2;
12313 struct bgp_redist
*red
;
12314 unsigned short instance
;
12317 struct route_map
*route_map
=
12318 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12320 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12321 protocol
= ZEBRA_ROUTE_OSPF
;
12323 protocol
= ZEBRA_ROUTE_TABLE
;
12325 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12326 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12328 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12329 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12332 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
12333 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
12334 "redistribute <ospf|table> (1-65535) route-map WORD",
12335 "Redistribute information from another routing protocol\n"
12336 "Open Shortest Path First (OSPFv2)\n"
12337 "Non-main Kernel Routing Table\n"
12338 "Instance ID/Table ID\n"
12339 "Route map reference\n"
12340 "Pointer to route-map entries\n")
12342 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
12343 bgp_redistribute_ipv4_ospf_metric_cmd
,
12344 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12345 "Redistribute information from another routing protocol\n"
12346 "Open Shortest Path First (OSPFv2)\n"
12347 "Non-main Kernel Routing Table\n"
12348 "Instance ID/Table ID\n"
12349 "Metric for redistributed routes\n"
12350 "Default metric\n")
12352 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12353 int idx_ospf_table
= 1;
12354 int idx_number
= 2;
12355 int idx_number_2
= 4;
12357 struct bgp_redist
*red
;
12358 unsigned short instance
;
12362 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12363 protocol
= ZEBRA_ROUTE_OSPF
;
12365 protocol
= ZEBRA_ROUTE_TABLE
;
12367 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12368 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12370 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12371 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12373 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12376 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
12377 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
12378 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12379 "Redistribute information from another routing protocol\n"
12380 "Open Shortest Path First (OSPFv2)\n"
12381 "Non-main Kernel Routing Table\n"
12382 "Instance ID/Table ID\n"
12383 "Metric for redistributed routes\n"
12384 "Default metric\n")
12386 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
12387 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
12388 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12389 "Redistribute information from another routing protocol\n"
12390 "Open Shortest Path First (OSPFv2)\n"
12391 "Non-main Kernel Routing Table\n"
12392 "Instance ID/Table ID\n"
12393 "Route map reference\n"
12394 "Pointer to route-map entries\n"
12395 "Metric for redistributed routes\n"
12396 "Default metric\n")
12398 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12399 int idx_ospf_table
= 1;
12400 int idx_number
= 2;
12402 int idx_number_2
= 6;
12404 struct bgp_redist
*red
;
12405 unsigned short instance
;
12408 struct route_map
*route_map
=
12409 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12411 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12412 protocol
= ZEBRA_ROUTE_OSPF
;
12414 protocol
= ZEBRA_ROUTE_TABLE
;
12416 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12417 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12419 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12421 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12422 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12424 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12428 bgp_redistribute_ipv4_ospf_rmap_metric
,
12429 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
12430 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12431 "Redistribute information from another routing protocol\n"
12432 "Open Shortest Path First (OSPFv2)\n"
12433 "Non-main Kernel Routing Table\n"
12434 "Instance ID/Table ID\n"
12435 "Route map reference\n"
12436 "Pointer to route-map entries\n"
12437 "Metric for redistributed routes\n"
12438 "Default metric\n")
12440 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
12441 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
12442 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12443 "Redistribute information from another routing protocol\n"
12444 "Open Shortest Path First (OSPFv2)\n"
12445 "Non-main Kernel Routing Table\n"
12446 "Instance ID/Table ID\n"
12447 "Metric for redistributed routes\n"
12449 "Route map reference\n"
12450 "Pointer to route-map entries\n")
12452 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12453 int idx_ospf_table
= 1;
12454 int idx_number
= 2;
12455 int idx_number_2
= 4;
12458 struct bgp_redist
*red
;
12459 unsigned short instance
;
12462 struct route_map
*route_map
=
12463 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12465 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12466 protocol
= ZEBRA_ROUTE_OSPF
;
12468 protocol
= ZEBRA_ROUTE_TABLE
;
12470 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12471 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12473 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12474 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12477 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12478 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12482 bgp_redistribute_ipv4_ospf_metric_rmap
,
12483 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
12484 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12485 "Redistribute information from another routing protocol\n"
12486 "Open Shortest Path First (OSPFv2)\n"
12487 "Non-main Kernel Routing Table\n"
12488 "Instance ID/Table ID\n"
12489 "Metric for redistributed routes\n"
12491 "Route map reference\n"
12492 "Pointer to route-map entries\n")
12494 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12495 no_bgp_redistribute_ipv4_ospf_cmd
,
12496 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
12498 "Redistribute information from another routing protocol\n"
12499 "Open Shortest Path First (OSPFv2)\n"
12500 "Non-main Kernel Routing Table\n"
12501 "Instance ID/Table ID\n"
12502 "Metric for redistributed routes\n"
12504 "Route map reference\n"
12505 "Pointer to route-map entries\n")
12507 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12508 int idx_ospf_table
= 2;
12509 int idx_number
= 3;
12510 unsigned short instance
;
12513 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12514 protocol
= ZEBRA_ROUTE_OSPF
;
12516 protocol
= ZEBRA_ROUTE_TABLE
;
12518 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12519 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12523 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12524 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
12526 "Redistribute information from another routing protocol\n"
12527 "Open Shortest Path First (OSPFv2)\n"
12528 "Non-main Kernel Routing Table\n"
12529 "Instance ID/Table ID\n"
12530 "Metric for redistributed routes\n"
12532 "Route map reference\n"
12533 "Pointer to route-map entries\n")
12535 DEFUN (no_bgp_redistribute_ipv4
,
12536 no_bgp_redistribute_ipv4_cmd
,
12537 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
12539 "Redistribute information from another routing protocol\n"
12540 FRR_IP_REDIST_HELP_STR_BGPD
12541 "Metric for redistributed routes\n"
12543 "Route map reference\n"
12544 "Pointer to route-map entries\n")
12546 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12547 int idx_protocol
= 2;
12550 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12552 vty_out(vty
, "%% Invalid route type\n");
12553 return CMD_WARNING_CONFIG_FAILED
;
12555 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12559 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12560 "no redistribute " FRR_IP_REDIST_STR_BGPD
12561 " [{metric (0-4294967295)|route-map WORD}]",
12563 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12564 "Metric for redistributed routes\n"
12566 "Route map reference\n"
12567 "Pointer to route-map entries\n")
12569 DEFUN (bgp_redistribute_ipv6
,
12570 bgp_redistribute_ipv6_cmd
,
12571 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12572 "Redistribute information from another routing protocol\n"
12573 FRR_IP6_REDIST_HELP_STR_BGPD
)
12575 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12576 int idx_protocol
= 1;
12579 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12581 vty_out(vty
, "%% Invalid route type\n");
12582 return CMD_WARNING_CONFIG_FAILED
;
12585 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12586 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12589 DEFUN (bgp_redistribute_ipv6_rmap
,
12590 bgp_redistribute_ipv6_rmap_cmd
,
12591 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12592 "Redistribute information from another routing protocol\n"
12593 FRR_IP6_REDIST_HELP_STR_BGPD
12594 "Route map reference\n"
12595 "Pointer to route-map entries\n")
12597 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12598 int idx_protocol
= 1;
12601 struct bgp_redist
*red
;
12603 struct route_map
*route_map
=
12604 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12606 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12608 vty_out(vty
, "%% Invalid route type\n");
12609 return CMD_WARNING_CONFIG_FAILED
;
12612 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12614 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12615 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12618 DEFUN (bgp_redistribute_ipv6_metric
,
12619 bgp_redistribute_ipv6_metric_cmd
,
12620 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12621 "Redistribute information from another routing protocol\n"
12622 FRR_IP6_REDIST_HELP_STR_BGPD
12623 "Metric for redistributed routes\n"
12624 "Default metric\n")
12626 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12627 int idx_protocol
= 1;
12628 int idx_number
= 3;
12631 struct bgp_redist
*red
;
12634 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12636 vty_out(vty
, "%% Invalid route type\n");
12637 return CMD_WARNING_CONFIG_FAILED
;
12639 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12641 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12642 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12643 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12646 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12647 bgp_redistribute_ipv6_rmap_metric_cmd
,
12648 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12649 "Redistribute information from another routing protocol\n"
12650 FRR_IP6_REDIST_HELP_STR_BGPD
12651 "Route map reference\n"
12652 "Pointer to route-map entries\n"
12653 "Metric for redistributed routes\n"
12654 "Default metric\n")
12656 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12657 int idx_protocol
= 1;
12659 int idx_number
= 5;
12662 struct bgp_redist
*red
;
12664 struct route_map
*route_map
=
12665 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12667 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12669 vty_out(vty
, "%% Invalid route type\n");
12670 return CMD_WARNING_CONFIG_FAILED
;
12672 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12674 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12676 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12677 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12679 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12682 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12683 bgp_redistribute_ipv6_metric_rmap_cmd
,
12684 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12685 "Redistribute information from another routing protocol\n"
12686 FRR_IP6_REDIST_HELP_STR_BGPD
12687 "Metric for redistributed routes\n"
12689 "Route map reference\n"
12690 "Pointer to route-map entries\n")
12692 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12693 int idx_protocol
= 1;
12694 int idx_number
= 3;
12698 struct bgp_redist
*red
;
12700 struct route_map
*route_map
=
12701 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12703 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12705 vty_out(vty
, "%% Invalid route type\n");
12706 return CMD_WARNING_CONFIG_FAILED
;
12708 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12710 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12711 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12714 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12715 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12718 DEFUN (no_bgp_redistribute_ipv6
,
12719 no_bgp_redistribute_ipv6_cmd
,
12720 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
12722 "Redistribute information from another routing protocol\n"
12723 FRR_IP6_REDIST_HELP_STR_BGPD
12724 "Metric for redistributed routes\n"
12726 "Route map reference\n"
12727 "Pointer to route-map entries\n")
12729 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12730 int idx_protocol
= 2;
12733 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12735 vty_out(vty
, "%% Invalid route type\n");
12736 return CMD_WARNING_CONFIG_FAILED
;
12739 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12742 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12747 /* Unicast redistribution only. */
12748 if (safi
!= SAFI_UNICAST
)
12751 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12752 /* Redistribute BGP does not make sense. */
12753 if (i
!= ZEBRA_ROUTE_BGP
) {
12754 struct list
*red_list
;
12755 struct listnode
*node
;
12756 struct bgp_redist
*red
;
12758 red_list
= bgp
->redist
[afi
][i
];
12762 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12763 /* "redistribute" configuration. */
12764 vty_out(vty
, " redistribute %s",
12765 zebra_route_string(i
));
12767 vty_out(vty
, " %d", red
->instance
);
12768 if (red
->redist_metric_flag
)
12769 vty_out(vty
, " metric %u",
12770 red
->redist_metric
);
12771 if (red
->rmap
.name
)
12772 vty_out(vty
, " route-map %s",
12774 vty_out(vty
, "\n");
12780 /* This is part of the address-family block (unicast only) */
12781 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12786 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12787 if (listcount(bgp
->vpn_policy
[afi
].import_vrf
))
12788 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12789 bgp
->vpn_policy
[afi
]
12790 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12792 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
12793 bgp
->vpn_policy
[afi
]
12794 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12796 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12797 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12798 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12799 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12802 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12803 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12805 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12808 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12809 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12810 bgp
->vpn_policy
[afi
].tovpn_label
);
12813 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12814 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12815 char buf
[RD_ADDRSTRLEN
];
12816 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12817 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12820 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12821 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12823 char buf
[PREFIX_STRLEN
];
12824 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12825 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12828 vty_out(vty
, "%*snexthop vpn export %s\n",
12832 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12833 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12835 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12836 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12838 char *b
= ecommunity_ecom2str(
12839 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12840 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12841 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12842 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12844 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12845 char *b
= ecommunity_ecom2str(
12846 bgp
->vpn_policy
[afi
]
12847 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12848 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12849 ECOMMUNITY_ROUTE_TARGET
);
12850 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12851 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12853 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12854 char *b
= ecommunity_ecom2str(
12855 bgp
->vpn_policy
[afi
]
12856 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12857 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12858 ECOMMUNITY_ROUTE_TARGET
);
12859 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12860 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12864 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12865 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12866 bgp
->vpn_policy
[afi
]
12867 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12869 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12870 char *b
= ecommunity_ecom2str(
12871 bgp
->vpn_policy
[afi
]
12872 .import_redirect_rtlist
,
12873 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12874 ECOMMUNITY_ROUTE_TARGET
);
12876 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12877 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12882 /* BGP node structure. */
12883 static struct cmd_node bgp_node
= {
12884 BGP_NODE
, "%s(config-router)# ", 1,
12887 static struct cmd_node bgp_ipv4_unicast_node
= {
12888 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12891 static struct cmd_node bgp_ipv4_multicast_node
= {
12892 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12895 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12896 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12899 static struct cmd_node bgp_ipv6_unicast_node
= {
12900 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12903 static struct cmd_node bgp_ipv6_multicast_node
= {
12904 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12907 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12908 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12911 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12912 "%s(config-router-af)# ", 1};
12914 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12915 "%s(config-router-af-vpnv6)# ", 1};
12917 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12918 "%s(config-router-evpn)# ", 1};
12920 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12921 "%s(config-router-af-vni)# ", 1};
12923 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12924 "%s(config-router-af)# ", 1};
12926 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12927 "%s(config-router-af-vpnv6)# ", 1};
12929 static void community_list_vty(void);
12931 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12935 struct listnode
*lnbgp
, *lnpeer
;
12937 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12938 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12939 /* only provide suggestions on the appropriate input
12941 * they'll otherwise show up multiple times */
12942 enum cmd_token_type match_type
;
12943 char *name
= peer
->host
;
12945 if (peer
->conf_if
) {
12946 match_type
= VARIABLE_TKN
;
12947 name
= peer
->conf_if
;
12948 } else if (strchr(peer
->host
, ':'))
12949 match_type
= IPV6_TKN
;
12951 match_type
= IPV4_TKN
;
12953 if (token
->type
!= match_type
)
12956 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12961 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12962 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12963 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12964 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12965 {.completions
= NULL
}};
12967 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12970 struct peer_group
*group
;
12971 struct listnode
*lnbgp
, *lnpeer
;
12973 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12974 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12975 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12980 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12981 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12982 {.completions
= NULL
} };
12984 void bgp_vty_init(void)
12986 cmd_variable_handler_register(bgp_var_neighbor
);
12987 cmd_variable_handler_register(bgp_var_peergroup
);
12989 /* Install bgp top node. */
12990 install_node(&bgp_node
, bgp_config_write
);
12991 install_node(&bgp_ipv4_unicast_node
, NULL
);
12992 install_node(&bgp_ipv4_multicast_node
, NULL
);
12993 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12994 install_node(&bgp_ipv6_unicast_node
, NULL
);
12995 install_node(&bgp_ipv6_multicast_node
, NULL
);
12996 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12997 install_node(&bgp_vpnv4_node
, NULL
);
12998 install_node(&bgp_vpnv6_node
, NULL
);
12999 install_node(&bgp_evpn_node
, NULL
);
13000 install_node(&bgp_evpn_vni_node
, NULL
);
13001 install_node(&bgp_flowspecv4_node
, NULL
);
13002 install_node(&bgp_flowspecv6_node
, NULL
);
13004 /* Install default VTY commands to new nodes. */
13005 install_default(BGP_NODE
);
13006 install_default(BGP_IPV4_NODE
);
13007 install_default(BGP_IPV4M_NODE
);
13008 install_default(BGP_IPV4L_NODE
);
13009 install_default(BGP_IPV6_NODE
);
13010 install_default(BGP_IPV6M_NODE
);
13011 install_default(BGP_IPV6L_NODE
);
13012 install_default(BGP_VPNV4_NODE
);
13013 install_default(BGP_VPNV6_NODE
);
13014 install_default(BGP_FLOWSPECV4_NODE
);
13015 install_default(BGP_FLOWSPECV6_NODE
);
13016 install_default(BGP_EVPN_NODE
);
13017 install_default(BGP_EVPN_VNI_NODE
);
13019 /* "bgp local-mac" hidden commands. */
13020 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
13021 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
13023 /* bgp route-map delay-timer commands. */
13024 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
13025 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
13027 /* Dummy commands (Currently not supported) */
13028 install_element(BGP_NODE
, &no_synchronization_cmd
);
13029 install_element(BGP_NODE
, &no_auto_summary_cmd
);
13031 /* "router bgp" commands. */
13032 install_element(CONFIG_NODE
, &router_bgp_cmd
);
13034 /* "no router bgp" commands. */
13035 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
13037 /* "bgp router-id" commands. */
13038 install_element(BGP_NODE
, &bgp_router_id_cmd
);
13039 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
13041 /* "bgp cluster-id" commands. */
13042 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
13043 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
13045 /* "bgp confederation" commands. */
13046 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
13047 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
13049 /* "bgp confederation peers" commands. */
13050 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
13051 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
13053 /* bgp max-med command */
13054 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
13055 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
13056 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
13057 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
13058 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
13060 /* bgp disable-ebgp-connected-nh-check */
13061 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
13062 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
13064 /* bgp update-delay command */
13065 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
13066 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
13067 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
13069 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
13070 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
13071 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
13072 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
13074 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
13075 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
13077 /* "maximum-paths" commands. */
13078 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
13079 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
13080 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
13081 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
13082 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
13083 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
13084 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
13085 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
13086 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
13087 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
13088 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
13089 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
13090 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
13091 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
13092 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
13094 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
13095 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
13096 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
13097 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
13098 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
13100 /* "timers bgp" commands. */
13101 install_element(BGP_NODE
, &bgp_timers_cmd
);
13102 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
13104 /* route-map delay-timer commands - per instance for backwards compat.
13106 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
13107 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
13109 /* "bgp client-to-client reflection" commands */
13110 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
13111 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
13113 /* "bgp always-compare-med" commands */
13114 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
13115 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
13117 /* bgp ebgp-requires-policy */
13118 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
13119 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
13121 /* "bgp deterministic-med" commands */
13122 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
13123 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
13125 /* "bgp graceful-restart" commands */
13126 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
13127 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
13128 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
13129 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
13130 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
13131 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
13133 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
13134 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
13136 /* "bgp graceful-shutdown" commands */
13137 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
13138 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
13140 /* "bgp fast-external-failover" commands */
13141 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
13142 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
13144 /* "bgp bestpath compare-routerid" commands */
13145 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
13146 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
13148 /* "bgp bestpath as-path ignore" commands */
13149 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
13150 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
13152 /* "bgp bestpath as-path confed" commands */
13153 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
13154 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
13156 /* "bgp bestpath as-path multipath-relax" commands */
13157 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
13158 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
13160 /* "bgp log-neighbor-changes" commands */
13161 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
13162 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
13164 /* "bgp bestpath med" commands */
13165 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
13166 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
13168 /* "no bgp default ipv4-unicast" commands. */
13169 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
13170 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
13172 /* "bgp network import-check" commands. */
13173 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
13174 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
13175 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
13177 /* "bgp default local-preference" commands. */
13178 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
13179 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
13181 /* bgp default show-hostname */
13182 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
13183 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
13185 /* "bgp default subgroup-pkt-queue-max" commands. */
13186 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
13187 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
13189 /* bgp ibgp-allow-policy-mods command */
13190 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
13191 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
13193 /* "bgp listen limit" commands. */
13194 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
13195 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
13197 /* "bgp listen range" commands. */
13198 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
13199 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
13201 /* "bgp default shutdown" command */
13202 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
13204 /* "neighbor remote-as" commands. */
13205 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
13206 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
13207 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
13208 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
13209 install_element(BGP_NODE
,
13210 &neighbor_interface_v6only_config_remote_as_cmd
);
13211 install_element(BGP_NODE
, &no_neighbor_cmd
);
13212 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
13214 /* "neighbor peer-group" commands. */
13215 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
13216 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
13217 install_element(BGP_NODE
,
13218 &no_neighbor_interface_peer_group_remote_as_cmd
);
13220 /* "neighbor local-as" commands. */
13221 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
13222 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
13223 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
13224 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
13226 /* "neighbor solo" commands. */
13227 install_element(BGP_NODE
, &neighbor_solo_cmd
);
13228 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
13230 /* "neighbor password" commands. */
13231 install_element(BGP_NODE
, &neighbor_password_cmd
);
13232 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
13234 /* "neighbor activate" commands. */
13235 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
13236 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
13237 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
13238 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
13239 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
13240 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
13241 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
13242 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
13243 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
13244 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
13245 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
13246 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
13248 /* "no neighbor activate" commands. */
13249 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
13250 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
13251 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
13252 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
13253 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
13254 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
13255 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
13256 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
13257 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
13258 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
13259 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
13260 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
13262 /* "neighbor peer-group" set commands. */
13263 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
13264 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13265 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13266 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13267 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13268 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13269 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13270 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13271 install_element(BGP_FLOWSPECV4_NODE
,
13272 &neighbor_set_peer_group_hidden_cmd
);
13273 install_element(BGP_FLOWSPECV6_NODE
,
13274 &neighbor_set_peer_group_hidden_cmd
);
13276 /* "no neighbor peer-group unset" commands. */
13277 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
13278 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13279 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13280 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13281 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13282 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13283 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13284 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13285 install_element(BGP_FLOWSPECV4_NODE
,
13286 &no_neighbor_set_peer_group_hidden_cmd
);
13287 install_element(BGP_FLOWSPECV6_NODE
,
13288 &no_neighbor_set_peer_group_hidden_cmd
);
13290 /* "neighbor softreconfiguration inbound" commands.*/
13291 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
13292 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
13293 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13294 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13295 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13296 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13297 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13298 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13299 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13300 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13301 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13302 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13303 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13304 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13305 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13306 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13307 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13308 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13309 install_element(BGP_FLOWSPECV4_NODE
,
13310 &neighbor_soft_reconfiguration_cmd
);
13311 install_element(BGP_FLOWSPECV4_NODE
,
13312 &no_neighbor_soft_reconfiguration_cmd
);
13313 install_element(BGP_FLOWSPECV6_NODE
,
13314 &neighbor_soft_reconfiguration_cmd
);
13315 install_element(BGP_FLOWSPECV6_NODE
,
13316 &no_neighbor_soft_reconfiguration_cmd
);
13317 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
13318 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13320 /* "neighbor attribute-unchanged" commands. */
13321 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
13322 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
13323 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
13324 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13325 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
13326 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13327 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
13328 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13329 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
13330 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13331 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
13332 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13333 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
13334 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13335 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
13336 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13337 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
13338 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13340 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
13341 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
13343 /* "nexthop-local unchanged" commands */
13344 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
13345 install_element(BGP_IPV6_NODE
,
13346 &no_neighbor_nexthop_local_unchanged_cmd
);
13348 /* "neighbor next-hop-self" commands. */
13349 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
13350 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
13351 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
13352 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13353 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
13354 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
13355 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
13356 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
13357 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
13358 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13359 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
13360 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
13361 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
13362 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
13363 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
13364 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13365 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
13366 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13367 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
13368 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
13370 /* "neighbor next-hop-self force" commands. */
13371 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
13372 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
13373 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13374 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
13375 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13376 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13377 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13378 install_element(BGP_IPV4_NODE
,
13379 &no_neighbor_nexthop_self_all_hidden_cmd
);
13380 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
13381 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13382 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13383 install_element(BGP_IPV4M_NODE
,
13384 &no_neighbor_nexthop_self_all_hidden_cmd
);
13385 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
13386 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13387 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13388 install_element(BGP_IPV4L_NODE
,
13389 &no_neighbor_nexthop_self_all_hidden_cmd
);
13390 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13391 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13392 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13393 install_element(BGP_IPV6_NODE
,
13394 &no_neighbor_nexthop_self_all_hidden_cmd
);
13395 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
13396 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13397 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13398 install_element(BGP_IPV6M_NODE
,
13399 &no_neighbor_nexthop_self_all_hidden_cmd
);
13400 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
13401 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13402 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13403 install_element(BGP_IPV6L_NODE
,
13404 &no_neighbor_nexthop_self_all_hidden_cmd
);
13405 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13406 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13407 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13408 install_element(BGP_VPNV4_NODE
,
13409 &no_neighbor_nexthop_self_all_hidden_cmd
);
13410 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13411 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13412 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13413 install_element(BGP_VPNV6_NODE
,
13414 &no_neighbor_nexthop_self_all_hidden_cmd
);
13416 /* "neighbor as-override" commands. */
13417 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
13418 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
13419 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
13420 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
13421 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
13422 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
13423 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
13424 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
13425 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
13426 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
13427 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
13428 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
13429 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
13430 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
13431 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
13432 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
13433 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
13434 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
13436 /* "neighbor remove-private-AS" commands. */
13437 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
13438 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
13439 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
13440 install_element(BGP_NODE
,
13441 &no_neighbor_remove_private_as_all_hidden_cmd
);
13442 install_element(BGP_NODE
,
13443 &neighbor_remove_private_as_replace_as_hidden_cmd
);
13444 install_element(BGP_NODE
,
13445 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
13446 install_element(BGP_NODE
,
13447 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13450 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13451 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
13452 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13453 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13454 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13455 install_element(BGP_IPV4_NODE
,
13456 &neighbor_remove_private_as_replace_as_cmd
);
13457 install_element(BGP_IPV4_NODE
,
13458 &no_neighbor_remove_private_as_replace_as_cmd
);
13459 install_element(BGP_IPV4_NODE
,
13460 &neighbor_remove_private_as_all_replace_as_cmd
);
13461 install_element(BGP_IPV4_NODE
,
13462 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13463 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
13464 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
13465 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
13466 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13467 install_element(BGP_IPV4M_NODE
,
13468 &neighbor_remove_private_as_replace_as_cmd
);
13469 install_element(BGP_IPV4M_NODE
,
13470 &no_neighbor_remove_private_as_replace_as_cmd
);
13471 install_element(BGP_IPV4M_NODE
,
13472 &neighbor_remove_private_as_all_replace_as_cmd
);
13473 install_element(BGP_IPV4M_NODE
,
13474 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13475 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
13476 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
13477 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
13478 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13479 install_element(BGP_IPV4L_NODE
,
13480 &neighbor_remove_private_as_replace_as_cmd
);
13481 install_element(BGP_IPV4L_NODE
,
13482 &no_neighbor_remove_private_as_replace_as_cmd
);
13483 install_element(BGP_IPV4L_NODE
,
13484 &neighbor_remove_private_as_all_replace_as_cmd
);
13485 install_element(BGP_IPV4L_NODE
,
13486 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13487 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
13488 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13489 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13490 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13491 install_element(BGP_IPV6_NODE
,
13492 &neighbor_remove_private_as_replace_as_cmd
);
13493 install_element(BGP_IPV6_NODE
,
13494 &no_neighbor_remove_private_as_replace_as_cmd
);
13495 install_element(BGP_IPV6_NODE
,
13496 &neighbor_remove_private_as_all_replace_as_cmd
);
13497 install_element(BGP_IPV6_NODE
,
13498 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13499 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
13500 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
13501 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
13502 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13503 install_element(BGP_IPV6M_NODE
,
13504 &neighbor_remove_private_as_replace_as_cmd
);
13505 install_element(BGP_IPV6M_NODE
,
13506 &no_neighbor_remove_private_as_replace_as_cmd
);
13507 install_element(BGP_IPV6M_NODE
,
13508 &neighbor_remove_private_as_all_replace_as_cmd
);
13509 install_element(BGP_IPV6M_NODE
,
13510 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13511 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
13512 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
13513 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
13514 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13515 install_element(BGP_IPV6L_NODE
,
13516 &neighbor_remove_private_as_replace_as_cmd
);
13517 install_element(BGP_IPV6L_NODE
,
13518 &no_neighbor_remove_private_as_replace_as_cmd
);
13519 install_element(BGP_IPV6L_NODE
,
13520 &neighbor_remove_private_as_all_replace_as_cmd
);
13521 install_element(BGP_IPV6L_NODE
,
13522 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13523 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
13524 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13525 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13526 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13527 install_element(BGP_VPNV4_NODE
,
13528 &neighbor_remove_private_as_replace_as_cmd
);
13529 install_element(BGP_VPNV4_NODE
,
13530 &no_neighbor_remove_private_as_replace_as_cmd
);
13531 install_element(BGP_VPNV4_NODE
,
13532 &neighbor_remove_private_as_all_replace_as_cmd
);
13533 install_element(BGP_VPNV4_NODE
,
13534 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13535 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
13536 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13537 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13538 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13539 install_element(BGP_VPNV6_NODE
,
13540 &neighbor_remove_private_as_replace_as_cmd
);
13541 install_element(BGP_VPNV6_NODE
,
13542 &no_neighbor_remove_private_as_replace_as_cmd
);
13543 install_element(BGP_VPNV6_NODE
,
13544 &neighbor_remove_private_as_all_replace_as_cmd
);
13545 install_element(BGP_VPNV6_NODE
,
13546 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13548 /* "neighbor send-community" commands.*/
13549 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
13550 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
13551 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
13552 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
13553 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
13554 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
13555 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
13556 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
13557 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
13558 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
13559 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
13560 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
13561 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
13562 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
13563 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
13564 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
13565 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
13566 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
13567 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
13568 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
13569 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
13570 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
13571 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
13572 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
13573 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
13574 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
13575 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
13576 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
13577 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
13578 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
13579 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
13580 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
13581 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
13582 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
13583 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
13584 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
13586 /* "neighbor route-reflector" commands.*/
13587 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
13588 install_element(BGP_NODE
,
13589 &no_neighbor_route_reflector_client_hidden_cmd
);
13590 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
13591 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
13592 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
13593 install_element(BGP_IPV4M_NODE
,
13594 &no_neighbor_route_reflector_client_cmd
);
13595 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
13596 install_element(BGP_IPV4L_NODE
,
13597 &no_neighbor_route_reflector_client_cmd
);
13598 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
13599 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
13600 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
13601 install_element(BGP_IPV6M_NODE
,
13602 &no_neighbor_route_reflector_client_cmd
);
13603 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
13604 install_element(BGP_IPV6L_NODE
,
13605 &no_neighbor_route_reflector_client_cmd
);
13606 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
13607 install_element(BGP_VPNV4_NODE
,
13608 &no_neighbor_route_reflector_client_cmd
);
13609 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
13610 install_element(BGP_VPNV6_NODE
,
13611 &no_neighbor_route_reflector_client_cmd
);
13612 install_element(BGP_FLOWSPECV4_NODE
,
13613 &neighbor_route_reflector_client_cmd
);
13614 install_element(BGP_FLOWSPECV4_NODE
,
13615 &no_neighbor_route_reflector_client_cmd
);
13616 install_element(BGP_FLOWSPECV6_NODE
,
13617 &neighbor_route_reflector_client_cmd
);
13618 install_element(BGP_FLOWSPECV6_NODE
,
13619 &no_neighbor_route_reflector_client_cmd
);
13620 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
13621 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
13623 /* "neighbor route-server" commands.*/
13624 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
13625 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
13626 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
13627 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
13628 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
13629 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
13630 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
13631 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
13632 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
13633 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
13634 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
13635 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
13636 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
13637 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
13638 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
13639 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
13640 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
13641 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
13642 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
13643 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
13644 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
13645 install_element(BGP_FLOWSPECV4_NODE
,
13646 &no_neighbor_route_server_client_cmd
);
13647 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
13648 install_element(BGP_FLOWSPECV6_NODE
,
13649 &no_neighbor_route_server_client_cmd
);
13651 /* "neighbor addpath-tx-all-paths" commands.*/
13652 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
13653 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
13654 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13655 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13656 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13657 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13658 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13659 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13660 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13661 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13662 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13663 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13664 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13665 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13666 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13667 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13668 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13669 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13671 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
13672 install_element(BGP_NODE
,
13673 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13674 install_element(BGP_NODE
,
13675 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13676 install_element(BGP_IPV4_NODE
,
13677 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13678 install_element(BGP_IPV4_NODE
,
13679 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13680 install_element(BGP_IPV4M_NODE
,
13681 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13682 install_element(BGP_IPV4M_NODE
,
13683 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13684 install_element(BGP_IPV4L_NODE
,
13685 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13686 install_element(BGP_IPV4L_NODE
,
13687 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13688 install_element(BGP_IPV6_NODE
,
13689 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13690 install_element(BGP_IPV6_NODE
,
13691 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13692 install_element(BGP_IPV6M_NODE
,
13693 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13694 install_element(BGP_IPV6M_NODE
,
13695 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13696 install_element(BGP_IPV6L_NODE
,
13697 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13698 install_element(BGP_IPV6L_NODE
,
13699 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13700 install_element(BGP_VPNV4_NODE
,
13701 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13702 install_element(BGP_VPNV4_NODE
,
13703 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13704 install_element(BGP_VPNV6_NODE
,
13705 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13706 install_element(BGP_VPNV6_NODE
,
13707 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13709 /* "neighbor passive" commands. */
13710 install_element(BGP_NODE
, &neighbor_passive_cmd
);
13711 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13714 /* "neighbor shutdown" commands. */
13715 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13716 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13717 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13718 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13720 /* "neighbor capability extended-nexthop" commands.*/
13721 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13722 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13724 /* "neighbor capability orf prefix-list" commands.*/
13725 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13726 install_element(BGP_NODE
,
13727 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13728 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13729 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13730 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13731 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13732 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13733 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13734 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13735 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13736 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13737 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13738 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13739 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13741 /* "neighbor capability dynamic" commands.*/
13742 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13743 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13745 /* "neighbor dont-capability-negotiate" commands. */
13746 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13747 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13749 /* "neighbor ebgp-multihop" commands. */
13750 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13751 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13752 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13754 /* "neighbor disable-connected-check" commands. */
13755 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13756 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13758 /* "neighbor enforce-first-as" commands. */
13759 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13760 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13762 /* "neighbor description" commands. */
13763 install_element(BGP_NODE
, &neighbor_description_cmd
);
13764 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13765 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13767 /* "neighbor update-source" commands. "*/
13768 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13769 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13771 /* "neighbor default-originate" commands. */
13772 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13773 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13774 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13775 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13776 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13777 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13778 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13779 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13780 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13781 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13782 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13783 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13784 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13785 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13786 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13787 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13788 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13789 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13790 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13791 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13792 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13794 /* "neighbor port" commands. */
13795 install_element(BGP_NODE
, &neighbor_port_cmd
);
13796 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13798 /* "neighbor weight" commands. */
13799 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13800 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13802 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13803 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13804 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13805 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13806 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13807 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13808 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13809 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13810 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13811 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13812 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13813 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13814 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13815 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13816 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13817 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13819 /* "neighbor override-capability" commands. */
13820 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13821 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13823 /* "neighbor strict-capability-match" commands. */
13824 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13825 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13827 /* "neighbor timers" commands. */
13828 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13829 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13831 /* "neighbor timers connect" commands. */
13832 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13833 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13835 /* "neighbor advertisement-interval" commands. */
13836 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13837 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13839 /* "neighbor interface" commands. */
13840 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13841 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13843 /* "neighbor distribute" commands. */
13844 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13845 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13846 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13847 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13848 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13849 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13850 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13851 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13852 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13853 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13854 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13855 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13856 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13857 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13858 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13859 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13860 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13861 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13863 /* "neighbor prefix-list" commands. */
13864 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13865 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13866 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13867 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13868 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13869 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13870 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13871 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13872 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13873 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13874 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13875 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13876 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13877 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13878 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13879 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13880 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13881 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13882 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13883 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13884 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13885 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13887 /* "neighbor filter-list" commands. */
13888 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13889 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13890 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13891 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13892 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13893 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13894 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13895 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13896 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13897 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13898 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13899 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13900 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13901 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13902 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13903 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13904 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13905 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13906 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13907 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13908 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13909 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13911 /* "neighbor route-map" commands. */
13912 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13913 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13914 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13915 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13916 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13917 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13918 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13919 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13920 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13921 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13922 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13923 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13924 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13925 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13926 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13927 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13928 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13929 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13930 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13931 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13932 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13933 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13934 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13935 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13937 /* "neighbor unsuppress-map" commands. */
13938 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13939 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13940 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13941 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13942 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13943 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13944 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13945 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13946 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13947 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13948 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13949 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13950 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13951 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13952 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13953 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13954 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13955 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13957 /* "neighbor maximum-prefix" commands. */
13958 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13959 install_element(BGP_NODE
,
13960 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13961 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13962 install_element(BGP_NODE
,
13963 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13964 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13965 install_element(BGP_NODE
,
13966 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13967 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13968 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13969 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13970 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13971 install_element(BGP_IPV4_NODE
,
13972 &neighbor_maximum_prefix_threshold_warning_cmd
);
13973 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13974 install_element(BGP_IPV4_NODE
,
13975 &neighbor_maximum_prefix_threshold_restart_cmd
);
13976 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13977 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13978 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13979 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13980 install_element(BGP_IPV4M_NODE
,
13981 &neighbor_maximum_prefix_threshold_warning_cmd
);
13982 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13983 install_element(BGP_IPV4M_NODE
,
13984 &neighbor_maximum_prefix_threshold_restart_cmd
);
13985 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13986 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13987 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13988 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13989 install_element(BGP_IPV4L_NODE
,
13990 &neighbor_maximum_prefix_threshold_warning_cmd
);
13991 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13992 install_element(BGP_IPV4L_NODE
,
13993 &neighbor_maximum_prefix_threshold_restart_cmd
);
13994 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13995 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13996 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13997 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13998 install_element(BGP_IPV6_NODE
,
13999 &neighbor_maximum_prefix_threshold_warning_cmd
);
14000 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14001 install_element(BGP_IPV6_NODE
,
14002 &neighbor_maximum_prefix_threshold_restart_cmd
);
14003 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
14004 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
14005 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14006 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14007 install_element(BGP_IPV6M_NODE
,
14008 &neighbor_maximum_prefix_threshold_warning_cmd
);
14009 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14010 install_element(BGP_IPV6M_NODE
,
14011 &neighbor_maximum_prefix_threshold_restart_cmd
);
14012 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
14013 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
14014 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14015 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14016 install_element(BGP_IPV6L_NODE
,
14017 &neighbor_maximum_prefix_threshold_warning_cmd
);
14018 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14019 install_element(BGP_IPV6L_NODE
,
14020 &neighbor_maximum_prefix_threshold_restart_cmd
);
14021 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
14022 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
14023 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14024 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14025 install_element(BGP_VPNV4_NODE
,
14026 &neighbor_maximum_prefix_threshold_warning_cmd
);
14027 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14028 install_element(BGP_VPNV4_NODE
,
14029 &neighbor_maximum_prefix_threshold_restart_cmd
);
14030 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
14031 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
14032 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14033 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14034 install_element(BGP_VPNV6_NODE
,
14035 &neighbor_maximum_prefix_threshold_warning_cmd
);
14036 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14037 install_element(BGP_VPNV6_NODE
,
14038 &neighbor_maximum_prefix_threshold_restart_cmd
);
14039 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
14041 /* "neighbor allowas-in" */
14042 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
14043 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
14044 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
14045 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
14046 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
14047 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
14048 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
14049 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
14050 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
14051 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
14052 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
14053 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
14054 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
14055 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
14056 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
14057 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
14058 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
14059 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
14060 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
14061 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
14063 /* address-family commands. */
14064 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
14065 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
14066 #ifdef KEEP_OLD_VPN_COMMANDS
14067 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
14068 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
14069 #endif /* KEEP_OLD_VPN_COMMANDS */
14071 install_element(BGP_NODE
, &address_family_evpn_cmd
);
14073 /* "exit-address-family" command. */
14074 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
14075 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
14076 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
14077 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
14078 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
14079 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
14080 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
14081 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
14082 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
14083 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
14084 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
14086 /* "clear ip bgp commands" */
14087 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
14089 /* clear ip bgp prefix */
14090 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
14091 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
14092 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
14094 /* "show [ip] bgp summary" commands. */
14095 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
14096 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
14097 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
14098 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
14099 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
14100 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
14101 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
14103 /* "show [ip] bgp neighbors" commands. */
14104 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
14106 /* "show [ip] bgp peer-group" commands. */
14107 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
14109 /* "show [ip] bgp paths" commands. */
14110 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
14112 /* "show [ip] bgp community" commands. */
14113 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
14115 /* "show ip bgp large-community" commands. */
14116 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
14117 /* "show [ip] bgp attribute-info" commands. */
14118 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
14119 /* "show [ip] bgp route-leak" command */
14120 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
14122 /* "redistribute" commands. */
14123 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
14124 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
14125 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
14126 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
14127 install_element(BGP_NODE
,
14128 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
14129 install_element(BGP_NODE
,
14130 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
14131 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
14132 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
14133 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
14134 install_element(BGP_NODE
,
14135 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
14136 install_element(BGP_NODE
,
14137 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
14138 install_element(BGP_NODE
,
14139 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
14140 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
14141 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
14142 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
14143 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
14144 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
14145 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
14146 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
14147 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
14148 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
14149 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
14150 install_element(BGP_IPV4_NODE
,
14151 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
14152 install_element(BGP_IPV4_NODE
,
14153 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
14154 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
14155 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
14156 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
14157 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
14158 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
14159 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
14161 /* import|export vpn [route-map WORD] */
14162 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
14163 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
14165 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
14166 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
14168 /* ttl_security commands */
14169 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
14170 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
14172 /* "show [ip] bgp memory" commands. */
14173 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
14175 /* "show bgp martian next-hop" */
14176 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
14178 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
14180 /* "show [ip] bgp views" commands. */
14181 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
14183 /* "show [ip] bgp vrfs" commands. */
14184 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
14186 /* Community-list. */
14187 community_list_vty();
14189 /* vpn-policy commands */
14190 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
14191 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
14192 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
14193 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
14194 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
14195 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
14196 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
14197 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
14198 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
14199 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
14200 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
14201 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
14203 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
14204 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
14206 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
14207 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
14208 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
14209 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
14210 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
14211 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
14212 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
14213 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
14214 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14215 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14216 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
14217 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
14220 #include "memory.h"
14221 #include "bgp_regex.h"
14222 #include "bgp_clist.h"
14223 #include "bgp_ecommunity.h"
14225 /* VTY functions. */
14227 /* Direction value to string conversion. */
14228 static const char *community_direct_str(int direct
)
14231 case COMMUNITY_DENY
:
14233 case COMMUNITY_PERMIT
:
14240 /* Display error string. */
14241 static void community_list_perror(struct vty
*vty
, int ret
)
14244 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
14245 vty_out(vty
, "%% Can't find community-list\n");
14247 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
14248 vty_out(vty
, "%% Malformed community-list value\n");
14250 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
14252 "%% Community name conflict, previously defined as standard community\n");
14254 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
14256 "%% Community name conflict, previously defined as expanded community\n");
14261 /* "community-list" keyword help string. */
14262 #define COMMUNITY_LIST_STR "Add a community list entry\n"
14264 /*community-list standard */
14265 DEFUN (community_list_standard
,
14266 bgp_community_list_standard_cmd
,
14267 "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14270 "Community list number (standard)\n"
14271 "Add an standard community-list entry\n"
14272 "Community list name\n"
14273 "Specify community to reject\n"
14274 "Specify community to accept\n"
14277 char *cl_name_or_number
= NULL
;
14279 int style
= COMMUNITY_LIST_STANDARD
;
14283 if (argv_find(argv
, argc
, "ip", &idx
)) {
14284 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14285 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14286 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14287 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14290 argv_find(argv
, argc
, "(1-99)", &idx
);
14291 argv_find(argv
, argc
, "WORD", &idx
);
14292 cl_name_or_number
= argv
[idx
]->arg
;
14293 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14295 argv_find(argv
, argc
, "AA:NN", &idx
);
14296 char *str
= argv_concat(argv
, argc
, idx
);
14298 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14301 XFREE(MTYPE_TMP
, str
);
14304 /* Display error string. */
14305 community_list_perror(vty
, ret
);
14306 return CMD_WARNING_CONFIG_FAILED
;
14309 return CMD_SUCCESS
;
14312 #if CONFDATE > 20191005
14313 CPP_NOTICE("bgpd: remove deprecated 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' command")
14315 ALIAS (community_list_standard
,
14316 ip_community_list_standard_cmd
,
14317 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14320 "Community list number (standard)\n"
14321 "Add an standard community-list entry\n"
14322 "Community list name\n"
14323 "Specify community to reject\n"
14324 "Specify community to accept\n"
14327 DEFUN (no_community_list_standard_all
,
14328 no_bgp_community_list_standard_all_cmd
,
14329 "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14333 "Community list number (standard)\n"
14334 "Add an standard community-list entry\n"
14335 "Community list name\n"
14336 "Specify community to reject\n"
14337 "Specify community to accept\n"
14340 char *cl_name_or_number
= NULL
;
14343 int style
= COMMUNITY_LIST_STANDARD
;
14347 if (argv_find(argv
, argc
, "ip", &idx
)) {
14348 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
14349 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14350 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14351 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> |AA:NN' being used");
14354 argv_find(argv
, argc
, "permit", &idx
);
14355 argv_find(argv
, argc
, "deny", &idx
);
14358 direct
= argv_find(argv
, argc
, "permit", &idx
)
14363 argv_find(argv
, argc
, "AA:NN", &idx
);
14364 str
= argv_concat(argv
, argc
, idx
);
14368 argv_find(argv
, argc
, "(1-99)", &idx
);
14369 argv_find(argv
, argc
, "WORD", &idx
);
14370 cl_name_or_number
= argv
[idx
]->arg
;
14372 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14375 XFREE(MTYPE_TMP
, str
);
14378 community_list_perror(vty
, ret
);
14379 return CMD_WARNING_CONFIG_FAILED
;
14382 return CMD_SUCCESS
;
14384 ALIAS (no_community_list_standard_all
,
14385 no_ip_community_list_standard_all_cmd
,
14386 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14390 "Community list number (standard)\n"
14391 "Add an standard community-list entry\n"
14392 "Community list name\n"
14393 "Specify community to reject\n"
14394 "Specify community to accept\n"
14397 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
14398 "no bgp community-list <(1-99)|standard WORD>",
14399 NO_STR BGP_STR COMMUNITY_LIST_STR
14400 "Community list number (standard)\n"
14401 "Add an standard community-list entry\n"
14402 "Community list name\n")
14404 ALIAS(no_community_list_standard_all
, no_ip_community_list_standard_all_list_cmd
,
14405 "no ip community-list <(1-99)|standard WORD>",
14406 NO_STR BGP_STR COMMUNITY_LIST_STR
14407 "Community list number (standard)\n"
14408 "Add an standard community-list entry\n"
14409 "Community list name\n")
14411 /*community-list expanded */
14412 DEFUN (community_list_expanded_all
,
14413 bgp_community_list_expanded_all_cmd
,
14414 "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14417 "Community list number (expanded)\n"
14418 "Add an expanded community-list entry\n"
14419 "Community list name\n"
14420 "Specify community to reject\n"
14421 "Specify community to accept\n"
14424 char *cl_name_or_number
= NULL
;
14426 int style
= COMMUNITY_LIST_EXPANDED
;
14429 if (argv_find(argv
, argc
, "ip", &idx
)) {
14430 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14431 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14432 vty_out(vty
, "'bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14433 zlog_warn("Deprecated option: 'ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14435 argv_find(argv
, argc
, "(100-500)", &idx
);
14436 argv_find(argv
, argc
, "WORD", &idx
);
14437 cl_name_or_number
= argv
[idx
]->arg
;
14438 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14440 argv_find(argv
, argc
, "AA:NN", &idx
);
14441 char *str
= argv_concat(argv
, argc
, idx
);
14443 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14446 XFREE(MTYPE_TMP
, str
);
14449 /* Display error string. */
14450 community_list_perror(vty
, ret
);
14451 return CMD_WARNING_CONFIG_FAILED
;
14454 return CMD_SUCCESS
;
14457 ALIAS (community_list_expanded_all
,
14458 ip_community_list_expanded_all_cmd
,
14459 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14462 "Community list number (expanded)\n"
14463 "Add an expanded community-list entry\n"
14464 "Community list name\n"
14465 "Specify community to reject\n"
14466 "Specify community to accept\n"
14469 DEFUN (no_community_list_expanded_all
,
14470 no_bgp_community_list_expanded_all_cmd
,
14471 "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14475 "Community list number (expanded)\n"
14476 "Add an expanded community-list entry\n"
14477 "Community list name\n"
14478 "Specify community to reject\n"
14479 "Specify community to accept\n"
14482 char *cl_name_or_number
= NULL
;
14485 int style
= COMMUNITY_LIST_EXPANDED
;
14488 if (argv_find(argv
, argc
, "ip", &idx
)) {
14489 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14490 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14491 vty_out(vty
, "'no bgp community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN'\n");
14492 zlog_warn("Deprecated option: 'no ip community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> AA:NN' being used");
14496 argv_find(argv
, argc
, "permit", &idx
);
14497 argv_find(argv
, argc
, "deny", &idx
);
14500 direct
= argv_find(argv
, argc
, "permit", &idx
)
14505 argv_find(argv
, argc
, "AA:NN", &idx
);
14506 str
= argv_concat(argv
, argc
, idx
);
14510 argv_find(argv
, argc
, "(100-500)", &idx
);
14511 argv_find(argv
, argc
, "WORD", &idx
);
14512 cl_name_or_number
= argv
[idx
]->arg
;
14514 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14517 XFREE(MTYPE_TMP
, str
);
14520 community_list_perror(vty
, ret
);
14521 return CMD_WARNING_CONFIG_FAILED
;
14524 return CMD_SUCCESS
;
14527 ALIAS (no_community_list_expanded_all
,
14528 no_ip_community_list_expanded_all_cmd
,
14529 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14533 "Community list number (expanded)\n"
14534 "Add an expanded community-list entry\n"
14535 "Community list name\n"
14536 "Specify community to reject\n"
14537 "Specify community to accept\n"
14540 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
14541 "no bgp community-list <(100-500)|expanded WORD>",
14542 NO_STR IP_STR COMMUNITY_LIST_STR
14543 "Community list number (expanded)\n"
14544 "Add an expanded community-list entry\n"
14545 "Community list name\n")
14547 ALIAS(no_community_list_expanded_all
, no_ip_community_list_expanded_all_list_cmd
,
14548 "no ip community-list <(100-500)|expanded WORD>",
14549 NO_STR IP_STR COMMUNITY_LIST_STR
14550 "Community list number (expanded)\n"
14551 "Add an expanded community-list entry\n"
14552 "Community list name\n")
14554 /* Return configuration string of community-list entry. */
14555 static const char *community_list_config_str(struct community_entry
*entry
)
14562 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
14563 str
= community_str(entry
->u
.com
, false);
14564 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
14565 str
= lcommunity_str(entry
->u
.lcom
, false);
14567 str
= entry
->config
;
14572 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
14574 struct community_entry
*entry
;
14576 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14577 if (entry
== list
->head
) {
14578 if (all_digit(list
->name
))
14579 vty_out(vty
, "Community %s list %s\n",
14580 entry
->style
== COMMUNITY_LIST_STANDARD
14582 : "(expanded) access",
14585 vty_out(vty
, "Named Community %s list %s\n",
14586 entry
->style
== COMMUNITY_LIST_STANDARD
14592 vty_out(vty
, " %s\n",
14593 community_direct_str(entry
->direct
));
14595 vty_out(vty
, " %s %s\n",
14596 community_direct_str(entry
->direct
),
14597 community_list_config_str(entry
));
14601 DEFUN (show_community_list
,
14602 show_bgp_community_list_cmd
,
14603 "show bgp community-list",
14606 "List community-list\n")
14608 struct community_list
*list
;
14609 struct community_list_master
*cm
;
14612 if (argv_find(argv
, argc
, "ip", &idx
)) {
14613 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14614 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14615 vty_out(vty
, "'show bgp community-list <(1-500)|WORD>'\n");
14616 zlog_warn("Deprecated option: 'ip show community-list <(1-500)|WORD>' being used");
14618 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14620 return CMD_SUCCESS
;
14622 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14623 community_list_show(vty
, list
);
14625 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14626 community_list_show(vty
, list
);
14628 return CMD_SUCCESS
;
14631 ALIAS (show_community_list
,
14632 show_ip_community_list_cmd
,
14633 "show ip community-list",
14636 "List community-list\n")
14638 DEFUN (show_community_list_arg
,
14639 show_bgp_community_list_arg_cmd
,
14640 "show bgp community-list <(1-500)|WORD> detail",
14643 "List community-list\n"
14644 "Community-list number\n"
14645 "Community-list name\n"
14646 "Detailed information on community-list\n")
14648 int idx_comm_list
= 3;
14649 struct community_list
*list
;
14652 if (argv_find(argv
, argc
, "ip", &idx
)) {
14653 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14654 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14655 vty_out(vty
, "'show bgp community-list <(1-500)|WORD> detail'\n");
14656 zlog_warn("Deprecated option: 'show ip community-list <(1-500)|WORD>' being used");
14658 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
14659 COMMUNITY_LIST_MASTER
);
14661 vty_out(vty
, "%% Can't find community-list\n");
14662 return CMD_WARNING
;
14665 community_list_show(vty
, list
);
14667 return CMD_SUCCESS
;
14670 ALIAS (show_community_list_arg
,
14671 show_ip_community_list_arg_cmd
,
14672 "show ip community-list <(1-500)|WORD>",
14675 "List community-list\n"
14676 "Community-list number\n"
14677 "Community-list name\n")
14680 * Large Community code.
14682 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
14683 struct cmd_token
**argv
, int style
,
14684 int reject_all_digit_name
)
14692 if (argv_find(argv
, argc
, "ip", &idx
)) {
14693 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14694 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14695 vty_out(vty
, "'bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14696 zlog_warn("Deprecated option: 'large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14698 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14701 /* All digit name check. */
14703 argv_find(argv
, argc
, "WORD", &idx
);
14704 argv_find(argv
, argc
, "(1-99)", &idx
);
14705 argv_find(argv
, argc
, "(100-500)", &idx
);
14706 cl_name
= argv
[idx
]->arg
;
14707 if (reject_all_digit_name
&& all_digit(cl_name
)) {
14708 vty_out(vty
, "%% Community name cannot have all digits\n");
14709 return CMD_WARNING_CONFIG_FAILED
;
14713 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
14714 argv_find(argv
, argc
, "LINE", &idx
);
14715 /* Concat community string argument. */
14717 str
= argv_concat(argv
, argc
, idx
);
14721 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
14723 /* Free temporary community list string allocated by
14725 XFREE(MTYPE_TMP
, str
);
14728 community_list_perror(vty
, ret
);
14729 return CMD_WARNING_CONFIG_FAILED
;
14731 return CMD_SUCCESS
;
14734 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
14735 struct cmd_token
**argv
, int style
)
14742 if (argv_find(argv
, argc
, "ip", &idx
)) {
14743 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
14744 vty_out(vty
, "if you are using this please migrate to the below command.\n");
14745 vty_out(vty
, "'no bgp large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>'\n");
14746 zlog_warn("Deprecated option: 'no ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' being used");
14748 argv_find(argv
, argc
, "permit", &idx
);
14749 argv_find(argv
, argc
, "deny", &idx
);
14752 /* Check the list direct. */
14753 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
14754 direct
= COMMUNITY_PERMIT
;
14756 direct
= COMMUNITY_DENY
;
14759 argv_find(argv
, argc
, "LINE", &idx
);
14760 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
14761 /* Concat community string argument. */
14762 str
= argv_concat(argv
, argc
, idx
);
14766 argv_find(argv
, argc
, "(1-99)", &idx
);
14767 argv_find(argv
, argc
, "(100-500)", &idx
);
14768 argv_find(argv
, argc
, "WORD", &idx
);
14770 /* Unset community list. */
14771 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
14774 /* Free temporary community list string allocated by
14776 XFREE(MTYPE_TMP
, str
);
14779 community_list_perror(vty
, ret
);
14780 return CMD_WARNING_CONFIG_FAILED
;
14783 return CMD_SUCCESS
;
14786 /* "large-community-list" keyword help string. */
14787 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
14788 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
14790 #if CONFDATE > 20191005
14791 CPP_NOTICE("bgpd: remove deprecated 'ip large-community-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:BB:CC>' command")
14793 DEFUN (lcommunity_list_standard
,
14794 bgp_lcommunity_list_standard_cmd
,
14795 "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...",
14797 LCOMMUNITY_LIST_STR
14798 "Large Community list number (standard)\n"
14799 "Specify large community to reject\n"
14800 "Specify large community to accept\n"
14801 LCOMMUNITY_VAL_STR
)
14803 return lcommunity_list_set_vty(vty
, argc
, argv
,
14804 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14807 ALIAS (lcommunity_list_standard
,
14808 ip_lcommunity_list_standard_cmd
,
14809 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
14811 LCOMMUNITY_LIST_STR
14812 "Large Community list number (standard)\n"
14813 "Specify large community to reject\n"
14814 "Specify large community to accept\n"
14815 LCOMMUNITY_VAL_STR
)
14817 DEFUN (lcommunity_list_expanded
,
14818 bgp_lcommunity_list_expanded_cmd
,
14819 "bgp large-community-list (100-500) <deny|permit> LINE...",
14821 LCOMMUNITY_LIST_STR
14822 "Large Community list number (expanded)\n"
14823 "Specify large community to reject\n"
14824 "Specify large community to accept\n"
14825 "An ordered list as a regular-expression\n")
14827 return lcommunity_list_set_vty(vty
, argc
, argv
,
14828 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
14831 ALIAS (lcommunity_list_expanded
,
14832 ip_lcommunity_list_expanded_cmd
,
14833 "ip large-community-list (100-500) <deny|permit> LINE...",
14835 LCOMMUNITY_LIST_STR
14836 "Large Community list number (expanded)\n"
14837 "Specify large community to reject\n"
14838 "Specify large community to accept\n"
14839 "An ordered list as a regular-expression\n")
14841 DEFUN (lcommunity_list_name_standard
,
14842 bgp_lcommunity_list_name_standard_cmd
,
14843 "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
14845 LCOMMUNITY_LIST_STR
14846 "Specify standard large-community-list\n"
14847 "Large Community list name\n"
14848 "Specify large community to reject\n"
14849 "Specify large community to accept\n"
14850 LCOMMUNITY_VAL_STR
)
14852 return lcommunity_list_set_vty(vty
, argc
, argv
,
14853 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14856 ALIAS (lcommunity_list_name_standard
,
14857 ip_lcommunity_list_name_standard_cmd
,
14858 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
14860 LCOMMUNITY_LIST_STR
14861 "Specify standard large-community-list\n"
14862 "Large Community list name\n"
14863 "Specify large community to reject\n"
14864 "Specify large community to accept\n"
14865 LCOMMUNITY_VAL_STR
)
14867 DEFUN (lcommunity_list_name_expanded
,
14868 bgp_lcommunity_list_name_expanded_cmd
,
14869 "bgp large-community-list expanded WORD <deny|permit> LINE...",
14871 LCOMMUNITY_LIST_STR
14872 "Specify expanded large-community-list\n"
14873 "Large Community list name\n"
14874 "Specify large community to reject\n"
14875 "Specify large community to accept\n"
14876 "An ordered list as a regular-expression\n")
14878 return lcommunity_list_set_vty(vty
, argc
, argv
,
14879 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
14882 ALIAS (lcommunity_list_name_expanded
,
14883 ip_lcommunity_list_name_expanded_cmd
,
14884 "ip large-community-list expanded WORD <deny|permit> LINE...",
14886 LCOMMUNITY_LIST_STR
14887 "Specify expanded large-community-list\n"
14888 "Large Community list name\n"
14889 "Specify large community to reject\n"
14890 "Specify large community to accept\n"
14891 "An ordered list as a regular-expression\n")
14893 DEFUN (no_lcommunity_list_standard_all
,
14894 no_bgp_lcommunity_list_standard_all_cmd
,
14895 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
14898 LCOMMUNITY_LIST_STR
14899 "Large Community list number (standard)\n"
14900 "Large Community list number (expanded)\n"
14901 "Large Community list name\n")
14903 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14904 LARGE_COMMUNITY_LIST_STANDARD
);
14907 ALIAS (no_lcommunity_list_standard_all
,
14908 no_ip_lcommunity_list_standard_all_cmd
,
14909 "no ip large-community-list <(1-99)|(100-500)|WORD>",
14912 LCOMMUNITY_LIST_STR
14913 "Large Community list number (standard)\n"
14914 "Large Community list number (expanded)\n"
14915 "Large Community list name\n")
14917 DEFUN (no_lcommunity_list_name_expanded_all
,
14918 no_bgp_lcommunity_list_name_expanded_all_cmd
,
14919 "no bgp large-community-list expanded WORD",
14922 LCOMMUNITY_LIST_STR
14923 "Specify expanded large-community-list\n"
14924 "Large Community list name\n")
14926 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14927 LARGE_COMMUNITY_LIST_EXPANDED
);
14930 ALIAS (no_lcommunity_list_name_expanded_all
,
14931 no_ip_lcommunity_list_name_expanded_all_cmd
,
14932 "no ip large-community-list expanded WORD",
14935 LCOMMUNITY_LIST_STR
14936 "Specify expanded large-community-list\n"
14937 "Large Community list name\n")
14939 DEFUN (no_lcommunity_list_standard
,
14940 no_bgp_lcommunity_list_standard_cmd
,
14941 "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
14944 LCOMMUNITY_LIST_STR
14945 "Large Community list number (standard)\n"
14946 "Specify large community to reject\n"
14947 "Specify large community to accept\n"
14948 LCOMMUNITY_VAL_STR
)
14950 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14951 LARGE_COMMUNITY_LIST_STANDARD
);
14954 ALIAS (no_lcommunity_list_standard
,
14955 no_ip_lcommunity_list_standard_cmd
,
14956 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
14959 LCOMMUNITY_LIST_STR
14960 "Large Community list number (standard)\n"
14961 "Specify large community to reject\n"
14962 "Specify large community to accept\n"
14963 LCOMMUNITY_VAL_STR
)
14965 DEFUN (no_lcommunity_list_expanded
,
14966 no_bgp_lcommunity_list_expanded_cmd
,
14967 "no bgp large-community-list (100-500) <deny|permit> LINE...",
14970 LCOMMUNITY_LIST_STR
14971 "Large Community list number (expanded)\n"
14972 "Specify large community to reject\n"
14973 "Specify large community to accept\n"
14974 "An ordered list as a regular-expression\n")
14976 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14977 LARGE_COMMUNITY_LIST_EXPANDED
);
14980 ALIAS (no_lcommunity_list_expanded
,
14981 no_ip_lcommunity_list_expanded_cmd
,
14982 "no ip large-community-list (100-500) <deny|permit> LINE...",
14985 LCOMMUNITY_LIST_STR
14986 "Large Community list number (expanded)\n"
14987 "Specify large community to reject\n"
14988 "Specify large community to accept\n"
14989 "An ordered list as a regular-expression\n")
14991 DEFUN (no_lcommunity_list_name_standard
,
14992 no_bgp_lcommunity_list_name_standard_cmd
,
14993 "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
14996 LCOMMUNITY_LIST_STR
14997 "Specify standard large-community-list\n"
14998 "Large Community list name\n"
14999 "Specify large community to reject\n"
15000 "Specify large community to accept\n"
15001 LCOMMUNITY_VAL_STR
)
15003 return lcommunity_list_unset_vty(vty
, argc
, argv
,
15004 LARGE_COMMUNITY_LIST_STANDARD
);
15007 ALIAS (no_lcommunity_list_name_standard
,
15008 no_ip_lcommunity_list_name_standard_cmd
,
15009 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
15012 LCOMMUNITY_LIST_STR
15013 "Specify standard large-community-list\n"
15014 "Large Community list name\n"
15015 "Specify large community to reject\n"
15016 "Specify large community to accept\n"
15017 LCOMMUNITY_VAL_STR
)
15019 DEFUN (no_lcommunity_list_name_expanded
,
15020 no_bgp_lcommunity_list_name_expanded_cmd
,
15021 "no bgp large-community-list expanded WORD <deny|permit> LINE...",
15024 LCOMMUNITY_LIST_STR
15025 "Specify expanded large-community-list\n"
15026 "Large community list name\n"
15027 "Specify large community to reject\n"
15028 "Specify large community to accept\n"
15029 "An ordered list as a regular-expression\n")
15031 return lcommunity_list_unset_vty(vty
, argc
, argv
,
15032 LARGE_COMMUNITY_LIST_EXPANDED
);
15035 ALIAS (no_lcommunity_list_name_expanded
,
15036 no_ip_lcommunity_list_name_expanded_cmd
,
15037 "no ip large-community-list expanded WORD <deny|permit> LINE...",
15040 LCOMMUNITY_LIST_STR
15041 "Specify expanded large-community-list\n"
15042 "Large community list name\n"
15043 "Specify large community to reject\n"
15044 "Specify large community to accept\n"
15045 "An ordered list as a regular-expression\n")
15047 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
15049 struct community_entry
*entry
;
15051 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15052 if (entry
== list
->head
) {
15053 if (all_digit(list
->name
))
15054 vty_out(vty
, "Large community %s list %s\n",
15056 LARGE_COMMUNITY_LIST_STANDARD
15058 : "(expanded) access",
15062 "Named large community %s list %s\n",
15064 LARGE_COMMUNITY_LIST_STANDARD
15070 vty_out(vty
, " %s\n",
15071 community_direct_str(entry
->direct
));
15073 vty_out(vty
, " %s %s\n",
15074 community_direct_str(entry
->direct
),
15075 community_list_config_str(entry
));
15079 DEFUN (show_lcommunity_list
,
15080 show_bgp_lcommunity_list_cmd
,
15081 "show bgp large-community-list",
15084 "List large-community list\n")
15086 struct community_list
*list
;
15087 struct community_list_master
*cm
;
15090 if (argv_find(argv
, argc
, "ip", &idx
)) {
15091 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15092 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15093 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD>'\n");
15094 zlog_warn("Deprecated option: 'ip show large-community-list <(1-500)|WORD>' being used");
15097 cm
= community_list_master_lookup(bgp_clist
,
15098 LARGE_COMMUNITY_LIST_MASTER
);
15100 return CMD_SUCCESS
;
15102 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15103 lcommunity_list_show(vty
, list
);
15105 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15106 lcommunity_list_show(vty
, list
);
15108 return CMD_SUCCESS
;
15111 ALIAS (show_lcommunity_list
,
15112 show_ip_lcommunity_list_cmd
,
15113 "show ip large-community-list",
15116 "List large-community list\n")
15118 DEFUN (show_lcommunity_list_arg
,
15119 show_bgp_lcommunity_list_arg_cmd
,
15120 "show bgp large-community-list <(1-500)|WORD> detail",
15123 "List large-community list\n"
15124 "Large-community-list number\n"
15125 "Large-community-list name\n"
15126 "Detailed information on large-community-list\n")
15128 struct community_list
*list
;
15131 if (argv_find(argv
, argc
, "ip", &idx
)) {
15132 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15133 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15134 vty_out(vty
, "'show bgp large-community-list <(1-500)|WORD> detail'\n");
15135 zlog_warn("Deprecated option: 'show ip large-community-list <(1-500)|WORD>' being used");
15138 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
15139 LARGE_COMMUNITY_LIST_MASTER
);
15141 vty_out(vty
, "%% Can't find large-community-list\n");
15142 return CMD_WARNING
;
15145 lcommunity_list_show(vty
, list
);
15147 return CMD_SUCCESS
;
15150 ALIAS (show_lcommunity_list_arg
,
15151 show_ip_lcommunity_list_arg_cmd
,
15152 "show ip large-community-list <(1-500)|WORD>",
15155 "List large-community list\n"
15156 "large-community-list number\n"
15157 "large-community-list name\n")
15159 /* "extcommunity-list" keyword help string. */
15160 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
15161 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
15163 DEFUN (extcommunity_list_standard
,
15164 bgp_extcommunity_list_standard_cmd
,
15165 "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15167 EXTCOMMUNITY_LIST_STR
15168 "Extended Community list number (standard)\n"
15169 "Specify standard extcommunity-list\n"
15170 "Community list name\n"
15171 "Specify community to reject\n"
15172 "Specify community to accept\n"
15173 EXTCOMMUNITY_VAL_STR
)
15175 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15177 char *cl_number_or_name
= NULL
;
15180 if (argv_find(argv
, argc
, "ip", &idx
)) {
15181 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15182 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15183 vty_out(vty
, "'bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15184 zlog_warn("Deprecated option: 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15186 argv_find(argv
, argc
, "(1-99)", &idx
);
15187 argv_find(argv
, argc
, "WORD", &idx
);
15188 cl_number_or_name
= argv
[idx
]->arg
;
15189 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15191 argv_find(argv
, argc
, "AA:NN", &idx
);
15192 char *str
= argv_concat(argv
, argc
, idx
);
15194 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15197 XFREE(MTYPE_TMP
, str
);
15200 community_list_perror(vty
, ret
);
15201 return CMD_WARNING_CONFIG_FAILED
;
15204 return CMD_SUCCESS
;
15207 #if CONFDATE > 20191005
15208 CPP_NOTICE("bgpd: remove deprecated 'ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' command")
15210 ALIAS (extcommunity_list_standard
,
15211 ip_extcommunity_list_standard_cmd
,
15212 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15214 EXTCOMMUNITY_LIST_STR
15215 "Extended Community list number (standard)\n"
15216 "Specify standard extcommunity-list\n"
15217 "Community list name\n"
15218 "Specify community to reject\n"
15219 "Specify community to accept\n"
15220 EXTCOMMUNITY_VAL_STR
)
15222 DEFUN (extcommunity_list_name_expanded
,
15223 bgp_extcommunity_list_name_expanded_cmd
,
15224 "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15226 EXTCOMMUNITY_LIST_STR
15227 "Extended Community list number (expanded)\n"
15228 "Specify expanded extcommunity-list\n"
15229 "Extended Community list name\n"
15230 "Specify community to reject\n"
15231 "Specify community to accept\n"
15232 "An ordered list as a regular-expression\n")
15234 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15236 char *cl_number_or_name
= NULL
;
15239 if (argv_find(argv
, argc
, "ip", &idx
)) {
15240 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15241 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15242 vty_out(vty
, "'extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15243 zlog_warn("Deprecated option: ‘ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15246 argv_find(argv
, argc
, "(100-500)", &idx
);
15247 argv_find(argv
, argc
, "WORD", &idx
);
15248 cl_number_or_name
= argv
[idx
]->arg
;
15249 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15251 argv_find(argv
, argc
, "LINE", &idx
);
15252 char *str
= argv_concat(argv
, argc
, idx
);
15254 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15257 XFREE(MTYPE_TMP
, str
);
15260 community_list_perror(vty
, ret
);
15261 return CMD_WARNING_CONFIG_FAILED
;
15264 return CMD_SUCCESS
;
15267 ALIAS (extcommunity_list_name_expanded
,
15268 ip_extcommunity_list_name_expanded_cmd
,
15269 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15271 EXTCOMMUNITY_LIST_STR
15272 "Extended Community list number (expanded)\n"
15273 "Specify expanded extcommunity-list\n"
15274 "Extended Community list name\n"
15275 "Specify community to reject\n"
15276 "Specify community to accept\n"
15277 "An ordered list as a regular-expression\n")
15279 DEFUN (no_extcommunity_list_standard_all
,
15280 no_bgp_extcommunity_list_standard_all_cmd
,
15281 "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15284 EXTCOMMUNITY_LIST_STR
15285 "Extended Community list number (standard)\n"
15286 "Specify standard extcommunity-list\n"
15287 "Community list name\n"
15288 "Specify community to reject\n"
15289 "Specify community to accept\n"
15290 EXTCOMMUNITY_VAL_STR
)
15292 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15294 char *cl_number_or_name
= NULL
;
15298 if (argv_find(argv
, argc
, "ip", &idx
)) {
15299 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15300 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15301 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15302 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15306 argv_find(argv
, argc
, "permit", &idx
);
15307 argv_find(argv
, argc
, "deny", &idx
);
15310 direct
= argv_find(argv
, argc
, "permit", &idx
)
15315 argv_find(argv
, argc
, "AA:NN", &idx
);
15316 str
= argv_concat(argv
, argc
, idx
);
15320 argv_find(argv
, argc
, "(1-99)", &idx
);
15321 argv_find(argv
, argc
, "WORD", &idx
);
15322 cl_number_or_name
= argv
[idx
]->arg
;
15324 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15327 XFREE(MTYPE_TMP
, str
);
15330 community_list_perror(vty
, ret
);
15331 return CMD_WARNING_CONFIG_FAILED
;
15334 return CMD_SUCCESS
;
15337 ALIAS (no_extcommunity_list_standard_all
,
15338 no_ip_extcommunity_list_standard_all_cmd
,
15339 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15342 EXTCOMMUNITY_LIST_STR
15343 "Extended Community list number (standard)\n"
15344 "Specify standard extcommunity-list\n"
15345 "Community list name\n"
15346 "Specify community to reject\n"
15347 "Specify community to accept\n"
15348 EXTCOMMUNITY_VAL_STR
)
15350 ALIAS(no_extcommunity_list_standard_all
,
15351 no_bgp_extcommunity_list_standard_all_list_cmd
,
15352 "no bgp extcommunity-list <(1-99)|standard WORD>",
15353 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15354 "Extended Community list number (standard)\n"
15355 "Specify standard extcommunity-list\n"
15356 "Community list name\n")
15358 ALIAS(no_extcommunity_list_standard_all
,
15359 no_ip_extcommunity_list_standard_all_list_cmd
,
15360 "no ip extcommunity-list <(1-99)|standard WORD>",
15361 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15362 "Extended Community list number (standard)\n"
15363 "Specify standard extcommunity-list\n"
15364 "Community list name\n")
15366 DEFUN (no_extcommunity_list_expanded_all
,
15367 no_bgp_extcommunity_list_expanded_all_cmd
,
15368 "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15371 EXTCOMMUNITY_LIST_STR
15372 "Extended Community list number (expanded)\n"
15373 "Specify expanded extcommunity-list\n"
15374 "Extended Community list name\n"
15375 "Specify community to reject\n"
15376 "Specify community to accept\n"
15377 "An ordered list as a regular-expression\n")
15379 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15381 char *cl_number_or_name
= NULL
;
15385 if (argv_find(argv
, argc
, "ip", &idx
)) {
15386 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15387 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15388 vty_out(vty
, "'no bgp extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>'\n");
15389 zlog_warn("Deprecated option: ‘no ip extcommunity-list <(1-99)|(100-500)|standard|expanded> <deny|permit> <LINE|AA:NN>' being used");
15393 argv_find(argv
, argc
, "permit", &idx
);
15394 argv_find(argv
, argc
, "deny", &idx
);
15397 direct
= argv_find(argv
, argc
, "permit", &idx
)
15402 argv_find(argv
, argc
, "LINE", &idx
);
15403 str
= argv_concat(argv
, argc
, idx
);
15407 argv_find(argv
, argc
, "(100-500)", &idx
);
15408 argv_find(argv
, argc
, "WORD", &idx
);
15409 cl_number_or_name
= argv
[idx
]->arg
;
15411 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15414 XFREE(MTYPE_TMP
, str
);
15417 community_list_perror(vty
, ret
);
15418 return CMD_WARNING_CONFIG_FAILED
;
15421 return CMD_SUCCESS
;
15424 ALIAS (no_extcommunity_list_expanded_all
,
15425 no_ip_extcommunity_list_expanded_all_cmd
,
15426 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15429 EXTCOMMUNITY_LIST_STR
15430 "Extended Community list number (expanded)\n"
15431 "Specify expanded extcommunity-list\n"
15432 "Extended Community list name\n"
15433 "Specify community to reject\n"
15434 "Specify community to accept\n"
15435 "An ordered list as a regular-expression\n")
15437 ALIAS(no_extcommunity_list_expanded_all
,
15438 no_ip_extcommunity_list_expanded_all_list_cmd
,
15439 "no ip extcommunity-list <(100-500)|expanded WORD>",
15440 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15441 "Extended Community list number (expanded)\n"
15442 "Specify expanded extcommunity-list\n"
15443 "Extended Community list name\n")
15445 ALIAS(no_extcommunity_list_expanded_all
,
15446 no_bgp_extcommunity_list_expanded_all_list_cmd
,
15447 "no bgp extcommunity-list <(100-500)|expanded WORD>",
15448 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15449 "Extended Community list number (expanded)\n"
15450 "Specify expanded extcommunity-list\n"
15451 "Extended Community list name\n")
15453 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
15455 struct community_entry
*entry
;
15457 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15458 if (entry
== list
->head
) {
15459 if (all_digit(list
->name
))
15460 vty_out(vty
, "Extended community %s list %s\n",
15461 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15463 : "(expanded) access",
15467 "Named extended community %s list %s\n",
15468 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15474 vty_out(vty
, " %s\n",
15475 community_direct_str(entry
->direct
));
15477 vty_out(vty
, " %s %s\n",
15478 community_direct_str(entry
->direct
),
15479 community_list_config_str(entry
));
15483 DEFUN (show_extcommunity_list
,
15484 show_bgp_extcommunity_list_cmd
,
15485 "show bgp extcommunity-list",
15488 "List extended-community list\n")
15490 struct community_list
*list
;
15491 struct community_list_master
*cm
;
15494 if (argv_find(argv
, argc
, "ip", &idx
)) {
15495 vty_out(vty
, "This config option is deprecated, and is scheduled for removal\n");
15496 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15497 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD>'\n");
15498 zlog_warn("Deprecated option: 'ip show extcommunity-list <(1-500)|WORD>' being used");
15500 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15502 return CMD_SUCCESS
;
15504 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15505 extcommunity_list_show(vty
, list
);
15507 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15508 extcommunity_list_show(vty
, list
);
15510 return CMD_SUCCESS
;
15513 ALIAS (show_extcommunity_list
,
15514 show_ip_extcommunity_list_cmd
,
15515 "show ip extcommunity-list",
15518 "List extended-community list\n")
15520 DEFUN (show_extcommunity_list_arg
,
15521 show_bgp_extcommunity_list_arg_cmd
,
15522 "show bgp extcommunity-list <(1-500)|WORD> detail",
15525 "List extended-community list\n"
15526 "Extcommunity-list number\n"
15527 "Extcommunity-list name\n"
15528 "Detailed information on extcommunity-list\n")
15530 int idx_comm_list
= 3;
15531 struct community_list
*list
;
15534 if (argv_find(argv
, argc
, "ip", &idx
)) {
15535 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
15536 vty_out(vty
, "if you are using this please migrate to the below command.\n");
15537 vty_out(vty
, "'show bgp extcommunity-list <(1-500)|WORD> detail'\n");
15538 zlog_warn("Deprecated option: 'show ip extcommunity-list <(1-500)|WORD>' being used");
15540 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
15541 EXTCOMMUNITY_LIST_MASTER
);
15543 vty_out(vty
, "%% Can't find extcommunity-list\n");
15544 return CMD_WARNING
;
15547 extcommunity_list_show(vty
, list
);
15549 return CMD_SUCCESS
;
15552 ALIAS (show_extcommunity_list_arg
,
15553 show_ip_extcommunity_list_arg_cmd
,
15554 "show ip extcommunity-list <(1-500)|WORD>",
15557 "List extended-community list\n"
15558 "Extcommunity-list number\n"
15559 "Extcommunity-list name\n")
15561 /* Display community-list and extcommunity-list configuration. */
15562 static int community_list_config_write(struct vty
*vty
)
15564 struct community_list
*list
;
15565 struct community_entry
*entry
;
15566 struct community_list_master
*cm
;
15569 /* Community-list. */
15570 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
15572 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15573 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15574 vty_out(vty
, "bgp community-list %s %s %s\n", list
->name
,
15575 community_direct_str(entry
->direct
),
15576 community_list_config_str(entry
));
15579 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15580 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15581 vty_out(vty
, "bgp community-list %s %s %s %s\n",
15582 entry
->style
== COMMUNITY_LIST_STANDARD
15585 list
->name
, community_direct_str(entry
->direct
),
15586 community_list_config_str(entry
));
15590 /* Extcommunity-list. */
15591 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15593 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15594 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15595 vty_out(vty
, "bgp extcommunity-list %s %s %s\n",
15596 list
->name
, community_direct_str(entry
->direct
),
15597 community_list_config_str(entry
));
15600 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15601 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15602 vty_out(vty
, "bgp extcommunity-list %s %s %s %s\n",
15603 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15606 list
->name
, community_direct_str(entry
->direct
),
15607 community_list_config_str(entry
));
15612 /* lcommunity-list. */
15613 cm
= community_list_master_lookup(bgp_clist
,
15614 LARGE_COMMUNITY_LIST_MASTER
);
15616 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15617 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15618 vty_out(vty
, "bgp large-community-list %s %s %s\n",
15619 list
->name
, community_direct_str(entry
->direct
),
15620 community_list_config_str(entry
));
15623 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15624 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15625 vty_out(vty
, "bgp large-community-list %s %s %s %s\n",
15626 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
15629 list
->name
, community_direct_str(entry
->direct
),
15630 community_list_config_str(entry
));
15637 static struct cmd_node community_list_node
= {
15638 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
15641 static void community_list_vty(void)
15643 install_node(&community_list_node
, community_list_config_write
);
15645 /* Community-list. */
15646 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
15647 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
15648 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
15649 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
15650 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
15651 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
15652 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
15653 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
15654 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
15655 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
15656 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
15657 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_list_cmd
);
15658 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
15659 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_list_cmd
);
15660 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
15661 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
15663 /* Extcommunity-list. */
15664 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
15665 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
15666 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
15667 install_element(CONFIG_NODE
,
15668 &no_bgp_extcommunity_list_standard_all_list_cmd
);
15669 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
15670 install_element(CONFIG_NODE
,
15671 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
15672 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
15673 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
15674 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
15675 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
15676 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
15677 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_list_cmd
);
15678 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
15679 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_list_cmd
);
15680 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
15681 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
15683 /* Large Community List */
15684 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
15685 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
15686 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
15687 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
15688 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_all_cmd
);
15689 install_element(CONFIG_NODE
,
15690 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
15691 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
15692 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
15693 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
15694 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
15695 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
15696 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);
15697 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
15698 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
15699 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
15700 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
15701 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
15702 install_element(CONFIG_NODE
,
15703 &no_ip_lcommunity_list_name_expanded_all_cmd
);
15704 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
15705 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
15706 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
15707 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
15708 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
15709 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);