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
)
167 * Please note that we have intentionally camelCased
168 * the return strings here. So if you want
169 * to use this function, please ensure you
170 * are doing this within json output
172 static const char *get_afi_safi_json_str(afi_t afi
, safi_t safi
)
174 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
175 return "ipv4Unicast";
176 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
177 return "ipv4Multicast";
178 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
179 return "ipv4LabeledUnicast";
180 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
182 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
184 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
185 return "ipv4Flowspec";
186 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
187 return "ipv6Unicast";
188 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
189 return "ipv6Multicast";
190 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
191 return "ipv6LabeledUnicast";
192 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
194 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
196 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
197 return "ipv6Flowspec";
198 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
204 /* Utility function to get address family from current node. */
205 afi_t
bgp_node_afi(struct vty
*vty
)
213 case BGP_FLOWSPECV6_NODE
:
226 /* Utility function to get subsequent address family from current
228 safi_t
bgp_node_safi(struct vty
*vty
)
234 safi
= SAFI_MPLS_VPN
;
238 safi
= SAFI_MULTICAST
;
245 safi
= SAFI_LABELED_UNICAST
;
247 case BGP_FLOWSPECV4_NODE
:
248 case BGP_FLOWSPECV6_NODE
:
249 safi
= SAFI_FLOWSPEC
;
259 * Converts an AFI in string form to afi_t
261 * @param afi string, one of
265 * @return the corresponding afi_t
267 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
269 afi_t afi
= AFI_MAX
; /* unknown */
270 if (strmatch(afi_str
, "ipv4"))
272 else if (strmatch(afi_str
, "ipv6"))
274 else if (strmatch(afi_str
, "l2vpn"))
279 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
283 if (argv_find(argv
, argc
, "ipv4", index
)) {
287 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
291 } else if (argv_find(argv
, argc
, "l2vpn", index
)) {
299 /* supports <unicast|multicast|vpn|labeled-unicast> */
300 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
302 safi_t safi
= SAFI_MAX
; /* unknown */
303 if (strmatch(safi_str
, "multicast"))
304 safi
= SAFI_MULTICAST
;
305 else if (strmatch(safi_str
, "unicast"))
307 else if (strmatch(safi_str
, "vpn"))
308 safi
= SAFI_MPLS_VPN
;
309 else if (strmatch(safi_str
, "evpn"))
311 else if (strmatch(safi_str
, "labeled-unicast"))
312 safi
= SAFI_LABELED_UNICAST
;
313 else if (strmatch(safi_str
, "flowspec"))
314 safi
= SAFI_FLOWSPEC
;
318 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
322 if (argv_find(argv
, argc
, "unicast", index
)) {
325 *safi
= SAFI_UNICAST
;
326 } else if (argv_find(argv
, argc
, "multicast", index
)) {
329 *safi
= SAFI_MULTICAST
;
330 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
333 *safi
= SAFI_LABELED_UNICAST
;
334 } else if (argv_find(argv
, argc
, "vpn", index
)) {
337 *safi
= SAFI_MPLS_VPN
;
338 } else if (argv_find(argv
, argc
, "evpn", index
)) {
342 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
345 *safi
= SAFI_FLOWSPEC
;
351 * bgp_vty_find_and_parse_afi_safi_bgp
353 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
354 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
355 * to appropriate values for the calling function. This is to allow the
356 * calling function to make decisions appropriate for the show command
357 * that is being parsed.
359 * The show commands are generally of the form:
360 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
361 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
363 * Since we use argv_find if the show command in particular doesn't have:
365 * [<view|vrf> VIEWVRFNAME]
366 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
367 * The command parsing should still be ok.
369 * vty -> The vty for the command so we can output some useful data in
370 * the event of a parse error in the vrf.
371 * argv -> The command tokens
372 * argc -> How many command tokens we have
373 * idx -> The current place in the command, generally should be 0 for this
375 * afi -> The parsed afi if it was included in the show command, returned here
376 * safi -> The parsed safi if it was included in the show command, returned here
377 * bgp -> Pointer to the bgp data structure we need to fill in.
378 * use_json -> json is configured or not
380 * The function returns the correct location in the parse tree for the
383 * Returns 0 for failure to parse correctly, else the idx position of where
384 * it found the last token.
386 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
387 struct cmd_token
**argv
, int argc
,
388 int *idx
, afi_t
*afi
, safi_t
*safi
,
389 struct bgp
**bgp
, bool use_json
)
391 char *vrf_name
= NULL
;
397 if (argv_find(argv
, argc
, "ip", idx
))
400 if (argv_find(argv
, argc
, "view", idx
))
401 vrf_name
= argv
[*idx
+ 1]->arg
;
402 else if (argv_find(argv
, argc
, "vrf", idx
)) {
403 vrf_name
= argv
[*idx
+ 1]->arg
;
404 if (strmatch(vrf_name
, VRF_DEFAULT_NAME
))
408 if (strmatch(vrf_name
, "all"))
411 *bgp
= bgp_lookup_by_name(vrf_name
);
414 json_object
*json
= NULL
;
415 json
= json_object_new_object();
416 json_object_string_add(
418 "View/Vrf is unknown");
420 json_object_to_json_string_ext(json
,
421 JSON_C_TO_STRING_PRETTY
));
422 json_object_free(json
);
425 vty_out(vty
, "View/Vrf %s is unknown\n",
432 *bgp
= bgp_get_default();
435 json_object
*json
= NULL
;
436 json
= json_object_new_object();
437 json_object_string_add(
439 "Default BGP instance not found");
441 json_object_to_json_string_ext(json
,
442 JSON_C_TO_STRING_PRETTY
));
443 json_object_free(json
);
447 "Default BGP instance not found\n");
453 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
454 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
460 static int peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
462 struct interface
*ifp
= NULL
;
464 if (su
->sa
.sa_family
== AF_INET
)
465 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
466 else if (su
->sa
.sa_family
== AF_INET6
)
467 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
468 su
->sin6
.sin6_scope_id
,
477 /* Utility function for looking up peer from VTY. */
478 /* This is used only for configuration, so disallow if attempted on
479 * a dynamic neighbor.
481 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
483 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
492 ret
= str2sockunion(ip_str
, &su
);
494 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
496 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
499 "%% Malformed address or name: %s\n",
505 peer
= peer_lookup(bgp
, &su
);
508 "%% Specify remote-as or peer-group commands first\n");
511 if (peer_dynamic_neighbor(peer
)) {
513 "%% Operation not allowed on a dynamic neighbor\n");
520 /* Utility function for looking up peer or peer group. */
521 /* This is used only for configuration, so disallow if attempted on
522 * a dynamic neighbor.
524 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
526 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
529 struct peer
*peer
= NULL
;
530 struct peer_group
*group
= NULL
;
536 ret
= str2sockunion(peer_str
, &su
);
538 /* IP address, locate peer. */
539 peer
= peer_lookup(bgp
, &su
);
541 /* Not IP, could match either peer configured on interface or a
543 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
545 group
= peer_group_lookup(bgp
, peer_str
);
549 if (peer_dynamic_neighbor(peer
)) {
551 "%% Operation not allowed on a dynamic neighbor\n");
561 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
566 int bgp_vty_return(struct vty
*vty
, int ret
)
568 const char *str
= NULL
;
571 case BGP_ERR_INVALID_VALUE
:
572 str
= "Invalid value";
574 case BGP_ERR_INVALID_FLAG
:
575 str
= "Invalid flag";
577 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
578 str
= "Peer-group has been shutdown. Activate the peer-group first";
580 case BGP_ERR_PEER_FLAG_CONFLICT
:
581 str
= "Can't set override-capability and strict-capability-match at the same time";
583 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
584 str
= "Specify remote-as or peer-group remote AS first";
586 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
587 str
= "Cannot change the peer-group. Deconfigure first";
589 case BGP_ERR_PEER_GROUP_MISMATCH
:
590 str
= "Peer is not a member of this peer-group";
592 case BGP_ERR_PEER_FILTER_CONFLICT
:
593 str
= "Prefix/distribute list can not co-exist";
595 case BGP_ERR_NOT_INTERNAL_PEER
:
596 str
= "Invalid command. Not an internal neighbor";
598 case BGP_ERR_REMOVE_PRIVATE_AS
:
599 str
= "remove-private-AS cannot be configured for IBGP peers";
601 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
602 str
= "Local-AS allowed only for EBGP peers";
604 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
605 str
= "Cannot have local-as same as BGP AS number";
607 case BGP_ERR_TCPSIG_FAILED
:
608 str
= "Error while applying TCP-Sig to session(s)";
610 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
611 str
= "ebgp-multihop and ttl-security cannot be configured together";
613 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
614 str
= "ttl-security only allowed for EBGP peers";
616 case BGP_ERR_AS_OVERRIDE
:
617 str
= "as-override cannot be configured for IBGP peers";
619 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
620 str
= "Invalid limit for number of dynamic neighbors";
622 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
623 str
= "Dynamic neighbor listen range already exists";
625 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
626 str
= "Operation not allowed on a dynamic neighbor";
628 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
629 str
= "Operation not allowed on a directly connected neighbor";
631 case BGP_ERR_PEER_SAFI_CONFLICT
:
632 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
636 vty_out(vty
, "%% %s\n", str
);
637 return CMD_WARNING_CONFIG_FAILED
;
642 /* BGP clear sort. */
651 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
652 safi_t safi
, int error
)
655 case BGP_ERR_AF_UNCONFIGURED
:
657 "%%BGP: Enable %s address family for the neighbor %s\n",
658 get_afi_safi_str(afi
, safi
, false), peer
->host
);
660 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
662 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
670 static int bgp_peer_clear(struct peer
*peer
, afi_t afi
, safi_t safi
,
671 struct listnode
*nnode
, enum bgp_clear_type stype
)
675 /* if afi/.safi not specified, spin thru all of them */
676 if ((afi
== AFI_UNSPEC
) && (safi
== SAFI_UNSPEC
)) {
680 FOREACH_AFI_SAFI (tmp_afi
, tmp_safi
) {
681 if (!peer
->afc
[tmp_afi
][tmp_safi
])
684 if (stype
== BGP_CLEAR_SOFT_NONE
)
685 ret
= peer_clear(peer
, &nnode
);
687 ret
= peer_clear_soft(peer
, tmp_afi
, tmp_safi
,
690 /* if afi specified and safi not, spin thru safis on this afi */
691 } else if (safi
== SAFI_UNSPEC
) {
694 for (tmp_safi
= SAFI_UNICAST
;
695 tmp_safi
< SAFI_MAX
; tmp_safi
++) {
696 if (!peer
->afc
[afi
][tmp_safi
])
699 if (stype
== BGP_CLEAR_SOFT_NONE
)
700 ret
= peer_clear(peer
, &nnode
);
702 ret
= peer_clear_soft(peer
, afi
,
705 /* both afi/safi specified, let the caller know if not defined */
707 if (!peer
->afc
[afi
][safi
])
710 if (stype
== BGP_CLEAR_SOFT_NONE
)
711 ret
= peer_clear(peer
, &nnode
);
713 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
719 /* `clear ip bgp' functions. */
720 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
721 enum clear_sort sort
, enum bgp_clear_type stype
,
727 struct listnode
*node
, *nnode
;
729 /* Clear all neighbors. */
731 * Pass along pointer to next node to peer_clear() when walking all
732 * nodes on the BGP instance as that may get freed if it is a
735 if (sort
== clear_all
) {
736 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
737 ret
= bgp_peer_clear(peer
, afi
, safi
, nnode
,
741 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
744 /* This is to apply read-only mode on this clear. */
745 if (stype
== BGP_CLEAR_SOFT_NONE
)
746 bgp
->update_delay_over
= 0;
751 /* Clear specified neighbor. */
752 if (sort
== clear_peer
) {
755 /* Make sockunion for lookup. */
756 ret
= str2sockunion(arg
, &su
);
758 peer
= peer_lookup_by_conf_if(bgp
, arg
);
760 peer
= peer_lookup_by_hostname(bgp
, arg
);
763 "Malformed address or name: %s\n",
769 peer
= peer_lookup(bgp
, &su
);
772 "%%BGP: Unknown neighbor - \"%s\"\n",
778 ret
= bgp_peer_clear(peer
, afi
, safi
, NULL
, stype
);
780 /* if afi/safi not defined for this peer, let caller know */
782 ret
= BGP_ERR_AF_UNCONFIGURED
;
785 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
790 /* Clear all neighbors belonging to a specific peer-group. */
791 if (sort
== clear_group
) {
792 struct peer_group
*group
;
794 group
= peer_group_lookup(bgp
, arg
);
796 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
800 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
801 ret
= bgp_peer_clear(peer
, afi
, safi
, nnode
, stype
);
804 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
811 "%%BGP: No %s peer belonging to peer-group %s is configured\n",
812 get_afi_safi_str(afi
, safi
, false), arg
);
817 /* Clear all external (eBGP) neighbors. */
818 if (sort
== clear_external
) {
819 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
820 if (peer
->sort
== BGP_PEER_IBGP
)
823 ret
= bgp_peer_clear(peer
, afi
, safi
, nnode
, stype
);
826 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
833 "%%BGP: No external %s peer is configured\n",
834 get_afi_safi_str(afi
, safi
, false));
839 /* Clear all neighbors belonging to a specific AS. */
840 if (sort
== clear_as
) {
841 as_t as
= strtoul(arg
, NULL
, 10);
843 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
847 ret
= bgp_peer_clear(peer
, afi
, safi
, nnode
, stype
);
850 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
857 "%%BGP: No %s peer is configured with AS %s\n",
858 get_afi_safi_str(afi
, safi
, false), arg
);
866 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
867 safi_t safi
, enum clear_sort sort
,
868 enum bgp_clear_type stype
, const char *arg
)
872 /* BGP structure lookup. */
874 bgp
= bgp_lookup_by_name(name
);
876 vty_out(vty
, "Can't find BGP instance %s\n", name
);
880 bgp
= bgp_get_default();
882 vty_out(vty
, "No BGP process is configured\n");
887 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
890 /* clear soft inbound */
891 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
896 FOREACH_AFI_SAFI (afi
, safi
)
897 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
898 BGP_CLEAR_SOFT_IN
, NULL
);
901 /* clear soft outbound */
902 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
907 FOREACH_AFI_SAFI (afi
, safi
)
908 bgp_clear_vty(vty
, name
, afi
, safi
, clear_all
,
909 BGP_CLEAR_SOFT_OUT
, NULL
);
913 #ifndef VTYSH_EXTRACT_PL
914 #include "bgpd/bgp_vty_clippy.c"
917 DEFUN_HIDDEN (bgp_local_mac
,
919 "bgp local-mac vni " CMD_VNI_RANGE
" mac WORD seq (0-4294967295)",
922 "VxLAN Network Identifier\n"
926 "mac-mobility sequence\n"
936 vni
= strtoul(argv
[3]->arg
, NULL
, 10);
937 if (!prefix_str2mac(argv
[5]->arg
, &mac
)) {
938 vty_out(vty
, "%% Malformed MAC address\n");
941 memset(&ip
, 0, sizeof(ip
));
942 seq
= strtoul(argv
[7]->arg
, NULL
, 10);
944 bgp
= bgp_get_default();
946 vty_out(vty
, "Default BGP instance is not there\n");
950 rv
= bgp_evpn_local_macip_add(bgp
, vni
, &mac
, &ip
, 0 /* flags */, seq
);
952 vty_out(vty
, "Internal error\n");
959 DEFUN_HIDDEN (no_bgp_local_mac
,
960 no_bgp_local_mac_cmd
,
961 "no bgp local-mac vni " CMD_VNI_RANGE
" mac WORD",
965 "VxLAN Network Identifier\n"
976 vni
= strtoul(argv
[4]->arg
, NULL
, 10);
977 if (!prefix_str2mac(argv
[6]->arg
, &mac
)) {
978 vty_out(vty
, "%% Malformed MAC address\n");
981 memset(&ip
, 0, sizeof(ip
));
983 bgp
= bgp_get_default();
985 vty_out(vty
, "Default BGP instance is not there\n");
989 rv
= bgp_evpn_local_macip_del(bgp
, vni
, &mac
, &ip
, ZEBRA_NEIGH_ACTIVE
);
991 vty_out(vty
, "Internal error\n");
998 DEFUN (no_synchronization
,
999 no_synchronization_cmd
,
1000 "no synchronization",
1002 "Perform IGP synchronization\n")
1007 DEFUN (no_auto_summary
,
1008 no_auto_summary_cmd
,
1011 "Enable automatic network number summarization\n")
1016 /* "router bgp" commands. */
1017 DEFUN_NOSH (router_bgp
,
1019 "router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1023 BGP_INSTANCE_HELP_STR
)
1026 int idx_view_vrf
= 3;
1032 const char *name
= NULL
;
1033 enum bgp_instance_type inst_type
;
1035 // "router bgp" without an ASN
1037 // Pending: Make VRF option available for ASN less config
1038 bgp
= bgp_get_default();
1041 vty_out(vty
, "%% No BGP process is configured\n");
1042 return CMD_WARNING_CONFIG_FAILED
;
1045 if (listcount(bm
->bgp
) > 1) {
1046 vty_out(vty
, "%% Please specify ASN and VRF\n");
1047 return CMD_WARNING_CONFIG_FAILED
;
1053 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1055 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
1057 name
= argv
[idx_vrf
]->arg
;
1059 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf")) {
1060 if (strmatch(name
, VRF_DEFAULT_NAME
))
1063 inst_type
= BGP_INSTANCE_TYPE_VRF
;
1064 } else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
1065 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
1068 if (inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1069 is_new_bgp
= (bgp_lookup(as
, name
) == NULL
);
1071 ret
= bgp_get(&bgp
, &as
, name
, inst_type
);
1073 case BGP_ERR_AS_MISMATCH
:
1074 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
1075 return CMD_WARNING_CONFIG_FAILED
;
1076 case BGP_ERR_INSTANCE_MISMATCH
:
1078 "BGP instance name and AS number mismatch\n");
1080 "BGP instance is already running; AS is %u\n",
1082 return CMD_WARNING_CONFIG_FAILED
;
1086 * If we just instantiated the default instance, complete
1087 * any pending VRF-VPN leaking that was configured via
1088 * earlier "router bgp X vrf FOO" blocks.
1090 if (is_new_bgp
&& inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
1091 vpn_leak_postchange_all();
1093 if (inst_type
== BGP_INSTANCE_TYPE_VRF
)
1094 bgp_vpn_leak_export(bgp
);
1095 /* Pending: handle when user tries to change a view to vrf n vv.
1099 /* unset the auto created flag as the user config is now present */
1100 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
1101 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
1106 /* "no router bgp" commands. */
1107 DEFUN (no_router_bgp
,
1109 "no router bgp [(1-4294967295)$instasn [<view|vrf> VIEWVRFNAME]]",
1114 BGP_INSTANCE_HELP_STR
)
1120 const char *name
= NULL
;
1122 // "no router bgp" without an ASN
1124 // Pending: Make VRF option available for ASN less config
1125 bgp
= bgp_get_default();
1128 vty_out(vty
, "%% No BGP process is configured\n");
1129 return CMD_WARNING_CONFIG_FAILED
;
1132 if (listcount(bm
->bgp
) > 1) {
1133 vty_out(vty
, "%% Please specify ASN and VRF\n");
1134 return CMD_WARNING_CONFIG_FAILED
;
1138 vty_out(vty
, "%% Please unconfigure l3vni %u",
1140 return CMD_WARNING_CONFIG_FAILED
;
1143 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
1146 name
= argv
[idx_vrf
]->arg
;
1148 /* Lookup bgp structure. */
1149 bgp
= bgp_lookup(as
, name
);
1151 vty_out(vty
, "%% Can't find BGP instance\n");
1152 return CMD_WARNING_CONFIG_FAILED
;
1156 vty_out(vty
, "%% Please unconfigure l3vni %u\n",
1158 return CMD_WARNING_CONFIG_FAILED
;
1161 /* Cannot delete default instance if vrf instances exist */
1162 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
1163 struct listnode
*node
;
1164 struct bgp
*tmp_bgp
;
1166 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, node
, tmp_bgp
)) {
1167 if (tmp_bgp
->inst_type
1168 == BGP_INSTANCE_TYPE_VRF
) {
1170 "%% Cannot delete default BGP instance. Dependent VRF instances exist\n");
1171 return CMD_WARNING_CONFIG_FAILED
;
1177 if (bgp_vpn_leak_unimport(bgp
, vty
))
1178 return CMD_WARNING_CONFIG_FAILED
;
1186 /* BGP router-id. */
1188 DEFPY (bgp_router_id
,
1190 "bgp router-id A.B.C.D",
1192 "Override configured router identifier\n"
1193 "Manually configured router identifier\n")
1195 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1196 bgp_router_id_static_set(bgp
, router_id
);
1200 DEFPY (no_bgp_router_id
,
1201 no_bgp_router_id_cmd
,
1202 "no bgp router-id [A.B.C.D]",
1205 "Override configured router identifier\n"
1206 "Manually configured router identifier\n")
1208 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1210 if (router_id_str
) {
1211 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1212 vty_out(vty
, "%% BGP router-id doesn't match\n");
1213 return CMD_WARNING_CONFIG_FAILED
;
1217 router_id
.s_addr
= 0;
1218 bgp_router_id_static_set(bgp
, router_id
);
1224 /* BGP Cluster ID. */
1225 DEFUN (bgp_cluster_id
,
1227 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1229 "Configure Route-Reflector Cluster-id\n"
1230 "Route-Reflector Cluster-id in IP address format\n"
1231 "Route-Reflector Cluster-id as 32 bit quantity\n")
1233 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1236 struct in_addr cluster
;
1238 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1240 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1241 return CMD_WARNING_CONFIG_FAILED
;
1244 bgp_cluster_id_set(bgp
, &cluster
);
1245 bgp_clear_star_soft_out(vty
, bgp
->name
);
1250 DEFUN (no_bgp_cluster_id
,
1251 no_bgp_cluster_id_cmd
,
1252 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1255 "Configure Route-Reflector Cluster-id\n"
1256 "Route-Reflector Cluster-id in IP address format\n"
1257 "Route-Reflector Cluster-id as 32 bit quantity\n")
1259 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1260 bgp_cluster_id_unset(bgp
);
1261 bgp_clear_star_soft_out(vty
, bgp
->name
);
1266 DEFUN (bgp_confederation_identifier
,
1267 bgp_confederation_identifier_cmd
,
1268 "bgp confederation identifier (1-4294967295)",
1269 "BGP specific commands\n"
1270 "AS confederation parameters\n"
1272 "Set routing domain confederation AS\n")
1274 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1278 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1280 bgp_confederation_id_set(bgp
, as
);
1285 DEFUN (no_bgp_confederation_identifier
,
1286 no_bgp_confederation_identifier_cmd
,
1287 "no bgp confederation identifier [(1-4294967295)]",
1289 "BGP specific commands\n"
1290 "AS confederation parameters\n"
1292 "Set routing domain confederation AS\n")
1294 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1295 bgp_confederation_id_unset(bgp
);
1300 DEFUN (bgp_confederation_peers
,
1301 bgp_confederation_peers_cmd
,
1302 "bgp confederation peers (1-4294967295)...",
1303 "BGP specific commands\n"
1304 "AS confederation parameters\n"
1305 "Peer ASs in BGP confederation\n"
1308 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1313 for (i
= idx_asn
; i
< argc
; i
++) {
1314 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1316 if (bgp
->as
== as
) {
1318 "%% Local member-AS not allowed in confed peer list\n");
1322 bgp_confederation_peers_add(bgp
, as
);
1327 DEFUN (no_bgp_confederation_peers
,
1328 no_bgp_confederation_peers_cmd
,
1329 "no bgp confederation peers (1-4294967295)...",
1331 "BGP specific commands\n"
1332 "AS confederation parameters\n"
1333 "Peer ASs in BGP confederation\n"
1336 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1341 for (i
= idx_asn
; i
< argc
; i
++) {
1342 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1344 bgp_confederation_peers_remove(bgp
, as
);
1350 * Central routine for maximum-paths configuration.
1351 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1352 * @set: 1 for setting values, 0 for removing the max-paths config.
1354 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1355 const char *mpaths
, uint16_t options
,
1358 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1359 uint16_t maxpaths
= 0;
1364 afi
= bgp_node_afi(vty
);
1365 safi
= bgp_node_safi(vty
);
1368 maxpaths
= strtol(mpaths
, NULL
, 10);
1369 if (maxpaths
> multipath_num
) {
1371 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1372 maxpaths
, multipath_num
);
1373 return CMD_WARNING_CONFIG_FAILED
;
1375 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1378 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1382 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1383 (set
== 1) ? "" : "un",
1384 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1385 maxpaths
, afi
, safi
);
1386 return CMD_WARNING_CONFIG_FAILED
;
1389 bgp_recalculate_all_bestpaths(bgp
);
1394 DEFUN (bgp_maxmed_admin
,
1395 bgp_maxmed_admin_cmd
,
1396 "bgp max-med administrative ",
1398 "Advertise routes with max-med\n"
1399 "Administratively applied, for an indefinite period\n")
1401 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1403 bgp
->v_maxmed_admin
= 1;
1404 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1406 bgp_maxmed_update(bgp
);
1411 DEFUN (bgp_maxmed_admin_medv
,
1412 bgp_maxmed_admin_medv_cmd
,
1413 "bgp max-med administrative (0-4294967295)",
1415 "Advertise routes with max-med\n"
1416 "Administratively applied, for an indefinite period\n"
1417 "Max MED value to be used\n")
1419 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1422 bgp
->v_maxmed_admin
= 1;
1423 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1425 bgp_maxmed_update(bgp
);
1430 DEFUN (no_bgp_maxmed_admin
,
1431 no_bgp_maxmed_admin_cmd
,
1432 "no bgp max-med administrative [(0-4294967295)]",
1435 "Advertise routes with max-med\n"
1436 "Administratively applied, for an indefinite period\n"
1437 "Max MED value to be used\n")
1439 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1440 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1441 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1442 bgp_maxmed_update(bgp
);
1447 DEFUN (bgp_maxmed_onstartup
,
1448 bgp_maxmed_onstartup_cmd
,
1449 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1451 "Advertise routes with max-med\n"
1452 "Effective on a startup\n"
1453 "Time (seconds) period for max-med\n"
1454 "Max MED value to be used\n")
1456 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1459 argv_find(argv
, argc
, "(5-86400)", &idx
);
1460 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1461 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1462 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1464 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1466 bgp_maxmed_update(bgp
);
1471 DEFUN (no_bgp_maxmed_onstartup
,
1472 no_bgp_maxmed_onstartup_cmd
,
1473 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1476 "Advertise routes with max-med\n"
1477 "Effective on a startup\n"
1478 "Time (seconds) period for max-med\n"
1479 "Max MED value to be used\n")
1481 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1483 /* Cancel max-med onstartup if its on */
1484 if (bgp
->t_maxmed_onstartup
) {
1485 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1486 bgp
->maxmed_onstartup_over
= 1;
1489 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1490 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1492 bgp_maxmed_update(bgp
);
1497 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1500 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1501 uint16_t update_delay
;
1502 uint16_t establish_wait
;
1504 update_delay
= strtoul(delay
, NULL
, 10);
1506 if (!wait
) /* update-delay <delay> */
1508 bgp
->v_update_delay
= update_delay
;
1509 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1513 /* update-delay <delay> <establish-wait> */
1514 establish_wait
= atoi(wait
);
1515 if (update_delay
< establish_wait
) {
1517 "%%Failed: update-delay less than the establish-wait!\n");
1518 return CMD_WARNING_CONFIG_FAILED
;
1521 bgp
->v_update_delay
= update_delay
;
1522 bgp
->v_establish_wait
= establish_wait
;
1527 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1529 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1531 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1532 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1537 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1539 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1540 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1541 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1542 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1548 /* Update-delay configuration */
1549 DEFUN (bgp_update_delay
,
1550 bgp_update_delay_cmd
,
1551 "update-delay (0-3600)",
1552 "Force initial delay for best-path and updates\n"
1556 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1559 DEFUN (bgp_update_delay_establish_wait
,
1560 bgp_update_delay_establish_wait_cmd
,
1561 "update-delay (0-3600) (1-3600)",
1562 "Force initial delay for best-path and updates\n"
1567 int idx_number_2
= 2;
1568 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1569 argv
[idx_number_2
]->arg
);
1572 /* Update-delay deconfiguration */
1573 DEFUN (no_bgp_update_delay
,
1574 no_bgp_update_delay_cmd
,
1575 "no update-delay [(0-3600) [(1-3600)]]",
1577 "Force initial delay for best-path and updates\n"
1581 return bgp_update_delay_deconfig_vty(vty
);
1585 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
1588 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1590 quanta
= set
? quanta
: BGP_WRITE_PACKET_MAX
;
1591 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
, memory_order_relaxed
);
1596 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, uint32_t quanta
,
1599 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1601 quanta
= set
? quanta
: BGP_READ_PACKET_MAX
;
1602 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
, memory_order_relaxed
);
1607 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1610 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1611 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1612 vty_out(vty
, " write-quanta %d\n", quanta
);
1615 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1618 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1619 if (quanta
!= BGP_READ_PACKET_MAX
)
1620 vty_out(vty
, " read-quanta %d\n", quanta
);
1623 /* Packet quanta configuration
1625 * XXX: The value set here controls the size of a stack buffer in the IO
1626 * thread. When changing these limits be careful to prevent stack overflow.
1628 * Furthermore, the maximums used here should correspond to
1629 * BGP_WRITE_PACKET_MAX and BGP_READ_PACKET_MAX.
1631 DEFPY (bgp_wpkt_quanta
,
1632 bgp_wpkt_quanta_cmd
,
1633 "[no] write-quanta (1-64)$quanta",
1635 "How many packets to write to peer socket per run\n"
1636 "Number of packets\n")
1638 return bgp_wpkt_quanta_config_vty(vty
, quanta
, !no
);
1641 DEFPY (bgp_rpkt_quanta
,
1642 bgp_rpkt_quanta_cmd
,
1643 "[no] read-quanta (1-10)$quanta",
1645 "How many packets to read from peer socket per I/O cycle\n"
1646 "Number of packets\n")
1648 return bgp_rpkt_quanta_config_vty(vty
, quanta
, !no
);
1651 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1653 if (!bgp
->heuristic_coalesce
)
1654 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1658 DEFUN (bgp_coalesce_time
,
1659 bgp_coalesce_time_cmd
,
1660 "coalesce-time (0-4294967295)",
1661 "Subgroup coalesce timer\n"
1662 "Subgroup coalesce timer value (in ms)\n")
1664 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1667 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1668 bgp
->heuristic_coalesce
= false;
1669 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1673 DEFUN (no_bgp_coalesce_time
,
1674 no_bgp_coalesce_time_cmd
,
1675 "no coalesce-time (0-4294967295)",
1677 "Subgroup coalesce timer\n"
1678 "Subgroup coalesce timer value (in ms)\n")
1680 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1682 bgp
->heuristic_coalesce
= true;
1683 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1687 /* Maximum-paths configuration */
1688 DEFUN (bgp_maxpaths
,
1690 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1691 "Forward packets over multiple paths\n"
1692 "Number of paths\n")
1695 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1696 argv
[idx_number
]->arg
, 0, 1);
1699 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1700 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1701 "Forward packets over multiple paths\n"
1702 "Number of paths\n")
1704 DEFUN (bgp_maxpaths_ibgp
,
1705 bgp_maxpaths_ibgp_cmd
,
1706 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1707 "Forward packets over multiple paths\n"
1709 "Number of paths\n")
1712 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1713 argv
[idx_number
]->arg
, 0, 1);
1716 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1717 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1718 "Forward packets over multiple paths\n"
1720 "Number of paths\n")
1722 DEFUN (bgp_maxpaths_ibgp_cluster
,
1723 bgp_maxpaths_ibgp_cluster_cmd
,
1724 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1725 "Forward packets over multiple paths\n"
1728 "Match the cluster length\n")
1731 return bgp_maxpaths_config_vty(
1732 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1733 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1736 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1737 "maximum-paths ibgp " CMD_RANGE_STR(
1738 1, MULTIPATH_NUM
) " equal-cluster-length",
1739 "Forward packets over multiple paths\n"
1742 "Match the cluster length\n")
1744 DEFUN (no_bgp_maxpaths
,
1745 no_bgp_maxpaths_cmd
,
1746 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1748 "Forward packets over multiple paths\n"
1749 "Number of paths\n")
1751 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1754 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1755 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1756 "Forward packets over multiple paths\n"
1757 "Number of paths\n")
1759 DEFUN (no_bgp_maxpaths_ibgp
,
1760 no_bgp_maxpaths_ibgp_cmd
,
1761 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1763 "Forward packets over multiple paths\n"
1766 "Match the cluster length\n")
1768 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1771 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1772 "no maximum-paths ibgp [" CMD_RANGE_STR(
1773 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1775 "Forward packets over multiple paths\n"
1778 "Match the cluster length\n")
1780 void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1783 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1784 vty_out(vty
, " maximum-paths %d\n",
1785 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1788 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1789 vty_out(vty
, " maximum-paths ibgp %d",
1790 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1791 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1792 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1793 vty_out(vty
, " equal-cluster-length");
1802 "timers bgp (0-65535) (0-65535)",
1803 "Adjust routing timers\n"
1805 "Keepalive interval\n"
1808 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1810 int idx_number_2
= 3;
1811 unsigned long keepalive
= 0;
1812 unsigned long holdtime
= 0;
1814 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1815 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1817 /* Holdtime value check. */
1818 if (holdtime
< 3 && holdtime
!= 0) {
1820 "%% hold time value must be either 0 or greater than 3\n");
1821 return CMD_WARNING_CONFIG_FAILED
;
1824 bgp_timers_set(bgp
, keepalive
, holdtime
);
1829 DEFUN (no_bgp_timers
,
1831 "no timers bgp [(0-65535) (0-65535)]",
1833 "Adjust routing timers\n"
1835 "Keepalive interval\n"
1838 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1839 bgp_timers_unset(bgp
);
1845 DEFUN (bgp_client_to_client_reflection
,
1846 bgp_client_to_client_reflection_cmd
,
1847 "bgp client-to-client reflection",
1848 "BGP specific commands\n"
1849 "Configure client to client route reflection\n"
1850 "reflection of routes allowed\n")
1852 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1853 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1854 bgp_clear_star_soft_out(vty
, bgp
->name
);
1859 DEFUN (no_bgp_client_to_client_reflection
,
1860 no_bgp_client_to_client_reflection_cmd
,
1861 "no bgp client-to-client reflection",
1863 "BGP specific commands\n"
1864 "Configure client to client route reflection\n"
1865 "reflection of routes allowed\n")
1867 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1868 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1869 bgp_clear_star_soft_out(vty
, bgp
->name
);
1874 /* "bgp always-compare-med" configuration. */
1875 DEFUN (bgp_always_compare_med
,
1876 bgp_always_compare_med_cmd
,
1877 "bgp always-compare-med",
1878 "BGP specific commands\n"
1879 "Allow comparing MED from different neighbors\n")
1881 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1882 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1883 bgp_recalculate_all_bestpaths(bgp
);
1888 DEFUN (no_bgp_always_compare_med
,
1889 no_bgp_always_compare_med_cmd
,
1890 "no bgp always-compare-med",
1892 "BGP specific commands\n"
1893 "Allow comparing MED from different neighbors\n")
1895 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1896 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1897 bgp_recalculate_all_bestpaths(bgp
);
1903 DEFUN(bgp_ebgp_requires_policy
, bgp_ebgp_requires_policy_cmd
,
1904 "bgp ebgp-requires-policy",
1905 "BGP specific commands\n"
1906 "Require in and out policy for eBGP peers (RFC8212)\n")
1908 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1909 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_ENABLED
;
1913 DEFUN(no_bgp_ebgp_requires_policy
, no_bgp_ebgp_requires_policy_cmd
,
1914 "no bgp ebgp-requires-policy",
1916 "BGP specific commands\n"
1917 "Require in and out policy for eBGP peers (RFC8212)\n")
1919 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1920 bgp
->ebgp_requires_policy
= DEFAULT_EBGP_POLICY_DISABLED
;
1925 /* "bgp deterministic-med" configuration. */
1926 DEFUN (bgp_deterministic_med
,
1927 bgp_deterministic_med_cmd
,
1928 "bgp deterministic-med",
1929 "BGP specific commands\n"
1930 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1932 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1934 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1935 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1936 bgp_recalculate_all_bestpaths(bgp
);
1942 DEFUN (no_bgp_deterministic_med
,
1943 no_bgp_deterministic_med_cmd
,
1944 "no bgp deterministic-med",
1946 "BGP specific commands\n"
1947 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1949 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1950 int bestpath_per_as_used
;
1954 struct listnode
*node
, *nnode
;
1956 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1957 bestpath_per_as_used
= 0;
1959 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1960 FOREACH_AFI_SAFI (afi
, safi
)
1961 if (bgp_addpath_dmed_required(
1962 peer
->addpath_type
[afi
][safi
])) {
1963 bestpath_per_as_used
= 1;
1967 if (bestpath_per_as_used
)
1971 if (bestpath_per_as_used
) {
1973 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
1974 return CMD_WARNING_CONFIG_FAILED
;
1976 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1977 bgp_recalculate_all_bestpaths(bgp
);
1984 /* "bgp graceful-restart" configuration. */
1985 DEFUN (bgp_graceful_restart
,
1986 bgp_graceful_restart_cmd
,
1987 "bgp graceful-restart",
1988 "BGP specific commands\n"
1989 "Graceful restart capability parameters\n")
1991 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1992 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1996 DEFUN (no_bgp_graceful_restart
,
1997 no_bgp_graceful_restart_cmd
,
1998 "no bgp graceful-restart",
2000 "BGP specific commands\n"
2001 "Graceful restart capability parameters\n")
2003 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2004 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
2008 DEFUN (bgp_graceful_restart_stalepath_time
,
2009 bgp_graceful_restart_stalepath_time_cmd
,
2010 "bgp graceful-restart stalepath-time (1-4095)",
2011 "BGP specific commands\n"
2012 "Graceful restart capability parameters\n"
2013 "Set the max time to hold onto restarting peer's stale paths\n"
2014 "Delay value (seconds)\n")
2016 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2020 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2021 bgp
->stalepath_time
= stalepath
;
2025 DEFUN (bgp_graceful_restart_restart_time
,
2026 bgp_graceful_restart_restart_time_cmd
,
2027 "bgp graceful-restart restart-time (1-4095)",
2028 "BGP specific commands\n"
2029 "Graceful restart capability parameters\n"
2030 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2031 "Delay value (seconds)\n")
2033 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2037 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2038 bgp
->restart_time
= restart
;
2042 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2043 no_bgp_graceful_restart_stalepath_time_cmd
,
2044 "no bgp graceful-restart stalepath-time [(1-4095)]",
2046 "BGP specific commands\n"
2047 "Graceful restart capability parameters\n"
2048 "Set the max time to hold onto restarting peer's stale paths\n"
2049 "Delay value (seconds)\n")
2051 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2053 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2057 DEFUN (no_bgp_graceful_restart_restart_time
,
2058 no_bgp_graceful_restart_restart_time_cmd
,
2059 "no bgp graceful-restart restart-time [(1-4095)]",
2061 "BGP specific commands\n"
2062 "Graceful restart capability parameters\n"
2063 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2064 "Delay value (seconds)\n")
2066 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2068 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2072 DEFUN (bgp_graceful_restart_preserve_fw
,
2073 bgp_graceful_restart_preserve_fw_cmd
,
2074 "bgp graceful-restart preserve-fw-state",
2075 "BGP specific commands\n"
2076 "Graceful restart capability parameters\n"
2077 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2079 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2080 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2084 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2085 no_bgp_graceful_restart_preserve_fw_cmd
,
2086 "no bgp graceful-restart preserve-fw-state",
2088 "BGP specific commands\n"
2089 "Graceful restart capability parameters\n"
2090 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2092 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2093 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2097 /* "bgp graceful-shutdown" configuration */
2098 DEFUN (bgp_graceful_shutdown
,
2099 bgp_graceful_shutdown_cmd
,
2100 "bgp graceful-shutdown",
2102 "Graceful shutdown parameters\n")
2104 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2106 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2107 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2108 bgp_static_redo_import_check(bgp
);
2109 bgp_redistribute_redo(bgp
);
2110 bgp_clear_star_soft_out(vty
, bgp
->name
);
2111 bgp_clear_star_soft_in(vty
, bgp
->name
);
2117 DEFUN (no_bgp_graceful_shutdown
,
2118 no_bgp_graceful_shutdown_cmd
,
2119 "no bgp graceful-shutdown",
2122 "Graceful shutdown parameters\n")
2124 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2126 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2127 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2128 bgp_static_redo_import_check(bgp
);
2129 bgp_redistribute_redo(bgp
);
2130 bgp_clear_star_soft_out(vty
, bgp
->name
);
2131 bgp_clear_star_soft_in(vty
, bgp
->name
);
2137 /* "bgp fast-external-failover" configuration. */
2138 DEFUN (bgp_fast_external_failover
,
2139 bgp_fast_external_failover_cmd
,
2140 "bgp fast-external-failover",
2142 "Immediately reset session if a link to a directly connected external peer goes down\n")
2144 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2145 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2149 DEFUN (no_bgp_fast_external_failover
,
2150 no_bgp_fast_external_failover_cmd
,
2151 "no bgp fast-external-failover",
2154 "Immediately reset session if a link to a directly connected external peer goes down\n")
2156 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2157 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2161 /* "bgp bestpath compare-routerid" configuration. */
2162 DEFUN (bgp_bestpath_compare_router_id
,
2163 bgp_bestpath_compare_router_id_cmd
,
2164 "bgp bestpath compare-routerid",
2165 "BGP specific commands\n"
2166 "Change the default bestpath selection\n"
2167 "Compare router-id for identical EBGP paths\n")
2169 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2170 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2171 bgp_recalculate_all_bestpaths(bgp
);
2176 DEFUN (no_bgp_bestpath_compare_router_id
,
2177 no_bgp_bestpath_compare_router_id_cmd
,
2178 "no bgp bestpath compare-routerid",
2180 "BGP specific commands\n"
2181 "Change the default bestpath selection\n"
2182 "Compare router-id for identical EBGP paths\n")
2184 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2185 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2186 bgp_recalculate_all_bestpaths(bgp
);
2191 /* "bgp bestpath as-path ignore" configuration. */
2192 DEFUN (bgp_bestpath_aspath_ignore
,
2193 bgp_bestpath_aspath_ignore_cmd
,
2194 "bgp bestpath as-path ignore",
2195 "BGP specific commands\n"
2196 "Change the default bestpath selection\n"
2197 "AS-path attribute\n"
2198 "Ignore as-path length in selecting a route\n")
2200 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2201 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2202 bgp_recalculate_all_bestpaths(bgp
);
2207 DEFUN (no_bgp_bestpath_aspath_ignore
,
2208 no_bgp_bestpath_aspath_ignore_cmd
,
2209 "no bgp bestpath as-path ignore",
2211 "BGP specific commands\n"
2212 "Change the default bestpath selection\n"
2213 "AS-path attribute\n"
2214 "Ignore as-path length in selecting a route\n")
2216 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2217 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2218 bgp_recalculate_all_bestpaths(bgp
);
2223 /* "bgp bestpath as-path confed" configuration. */
2224 DEFUN (bgp_bestpath_aspath_confed
,
2225 bgp_bestpath_aspath_confed_cmd
,
2226 "bgp bestpath as-path confed",
2227 "BGP specific commands\n"
2228 "Change the default bestpath selection\n"
2229 "AS-path attribute\n"
2230 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2232 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2233 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2234 bgp_recalculate_all_bestpaths(bgp
);
2239 DEFUN (no_bgp_bestpath_aspath_confed
,
2240 no_bgp_bestpath_aspath_confed_cmd
,
2241 "no bgp bestpath as-path confed",
2243 "BGP specific commands\n"
2244 "Change the default bestpath selection\n"
2245 "AS-path attribute\n"
2246 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2248 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2249 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2250 bgp_recalculate_all_bestpaths(bgp
);
2255 /* "bgp bestpath as-path multipath-relax" configuration. */
2256 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2257 bgp_bestpath_aspath_multipath_relax_cmd
,
2258 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2259 "BGP specific commands\n"
2260 "Change the default bestpath selection\n"
2261 "AS-path attribute\n"
2262 "Allow load sharing across routes that have different AS paths (but same length)\n"
2263 "Generate an AS_SET\n"
2264 "Do not generate an AS_SET\n")
2266 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2268 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2270 /* no-as-set is now the default behavior so we can silently
2272 if (argv_find(argv
, argc
, "as-set", &idx
))
2273 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2275 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2277 bgp_recalculate_all_bestpaths(bgp
);
2282 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2283 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2284 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2286 "BGP specific commands\n"
2287 "Change the default bestpath selection\n"
2288 "AS-path attribute\n"
2289 "Allow load sharing across routes that have different AS paths (but same length)\n"
2290 "Generate an AS_SET\n"
2291 "Do not generate an AS_SET\n")
2293 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2294 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2295 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2296 bgp_recalculate_all_bestpaths(bgp
);
2301 /* "bgp log-neighbor-changes" configuration. */
2302 DEFUN (bgp_log_neighbor_changes
,
2303 bgp_log_neighbor_changes_cmd
,
2304 "bgp log-neighbor-changes",
2305 "BGP specific commands\n"
2306 "Log neighbor up/down and reset reason\n")
2308 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2309 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2313 DEFUN (no_bgp_log_neighbor_changes
,
2314 no_bgp_log_neighbor_changes_cmd
,
2315 "no bgp log-neighbor-changes",
2317 "BGP specific commands\n"
2318 "Log neighbor up/down and reset reason\n")
2320 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2321 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2325 /* "bgp bestpath med" configuration. */
2326 DEFUN (bgp_bestpath_med
,
2327 bgp_bestpath_med_cmd
,
2328 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2329 "BGP specific commands\n"
2330 "Change the default bestpath selection\n"
2332 "Compare MED among confederation paths\n"
2333 "Treat missing MED as the least preferred one\n"
2334 "Treat missing MED as the least preferred one\n"
2335 "Compare MED among confederation paths\n")
2337 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2340 if (argv_find(argv
, argc
, "confed", &idx
))
2341 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2343 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2344 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2346 bgp_recalculate_all_bestpaths(bgp
);
2351 DEFUN (no_bgp_bestpath_med
,
2352 no_bgp_bestpath_med_cmd
,
2353 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2355 "BGP specific commands\n"
2356 "Change the default bestpath selection\n"
2358 "Compare MED among confederation paths\n"
2359 "Treat missing MED as the least preferred one\n"
2360 "Treat missing MED as the least preferred one\n"
2361 "Compare MED among confederation paths\n")
2363 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2366 if (argv_find(argv
, argc
, "confed", &idx
))
2367 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2369 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2370 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2372 bgp_recalculate_all_bestpaths(bgp
);
2377 /* "no bgp default ipv4-unicast". */
2378 DEFUN (no_bgp_default_ipv4_unicast
,
2379 no_bgp_default_ipv4_unicast_cmd
,
2380 "no bgp default ipv4-unicast",
2382 "BGP specific commands\n"
2383 "Configure BGP defaults\n"
2384 "Activate ipv4-unicast for a peer by default\n")
2386 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2387 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2391 DEFUN (bgp_default_ipv4_unicast
,
2392 bgp_default_ipv4_unicast_cmd
,
2393 "bgp default ipv4-unicast",
2394 "BGP specific commands\n"
2395 "Configure BGP defaults\n"
2396 "Activate ipv4-unicast for a peer by default\n")
2398 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2399 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2403 /* Display hostname in certain command outputs */
2404 DEFUN (bgp_default_show_hostname
,
2405 bgp_default_show_hostname_cmd
,
2406 "bgp default show-hostname",
2407 "BGP specific commands\n"
2408 "Configure BGP defaults\n"
2409 "Show hostname in certain command outputs\n")
2411 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2412 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2416 DEFUN (no_bgp_default_show_hostname
,
2417 no_bgp_default_show_hostname_cmd
,
2418 "no bgp default show-hostname",
2420 "BGP specific commands\n"
2421 "Configure BGP defaults\n"
2422 "Show hostname in certain command outputs\n")
2424 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2425 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2429 /* "bgp network import-check" configuration. */
2430 DEFUN (bgp_network_import_check
,
2431 bgp_network_import_check_cmd
,
2432 "bgp network import-check",
2433 "BGP specific commands\n"
2434 "BGP network command\n"
2435 "Check BGP network route exists in IGP\n")
2437 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2438 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2439 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2440 bgp_static_redo_import_check(bgp
);
2446 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2447 "bgp network import-check exact",
2448 "BGP specific commands\n"
2449 "BGP network command\n"
2450 "Check BGP network route exists in IGP\n"
2451 "Match route precisely\n")
2453 DEFUN (no_bgp_network_import_check
,
2454 no_bgp_network_import_check_cmd
,
2455 "no bgp network import-check",
2457 "BGP specific commands\n"
2458 "BGP network command\n"
2459 "Check BGP network route exists in IGP\n")
2461 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2462 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2463 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2464 bgp_static_redo_import_check(bgp
);
2470 DEFUN (bgp_default_local_preference
,
2471 bgp_default_local_preference_cmd
,
2472 "bgp default local-preference (0-4294967295)",
2473 "BGP specific commands\n"
2474 "Configure BGP defaults\n"
2475 "local preference (higher=more preferred)\n"
2476 "Configure default local preference value\n")
2478 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2480 uint32_t local_pref
;
2482 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2484 bgp_default_local_preference_set(bgp
, local_pref
);
2485 bgp_clear_star_soft_in(vty
, bgp
->name
);
2490 DEFUN (no_bgp_default_local_preference
,
2491 no_bgp_default_local_preference_cmd
,
2492 "no bgp default local-preference [(0-4294967295)]",
2494 "BGP specific commands\n"
2495 "Configure BGP defaults\n"
2496 "local preference (higher=more preferred)\n"
2497 "Configure default local preference value\n")
2499 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2500 bgp_default_local_preference_unset(bgp
);
2501 bgp_clear_star_soft_in(vty
, bgp
->name
);
2507 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2508 bgp_default_subgroup_pkt_queue_max_cmd
,
2509 "bgp default subgroup-pkt-queue-max (20-100)",
2510 "BGP specific commands\n"
2511 "Configure BGP defaults\n"
2512 "subgroup-pkt-queue-max\n"
2513 "Configure subgroup packet queue max\n")
2515 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2519 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2521 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2526 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2527 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2528 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2530 "BGP specific commands\n"
2531 "Configure BGP defaults\n"
2532 "subgroup-pkt-queue-max\n"
2533 "Configure subgroup packet queue max\n")
2535 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2536 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2541 DEFUN (bgp_rr_allow_outbound_policy
,
2542 bgp_rr_allow_outbound_policy_cmd
,
2543 "bgp route-reflector allow-outbound-policy",
2544 "BGP specific commands\n"
2545 "Allow modifications made by out route-map\n"
2546 "on ibgp neighbors\n")
2548 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2550 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2551 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2552 update_group_announce_rrclients(bgp
);
2553 bgp_clear_star_soft_out(vty
, bgp
->name
);
2559 DEFUN (no_bgp_rr_allow_outbound_policy
,
2560 no_bgp_rr_allow_outbound_policy_cmd
,
2561 "no bgp route-reflector allow-outbound-policy",
2563 "BGP specific commands\n"
2564 "Allow modifications made by out route-map\n"
2565 "on ibgp neighbors\n")
2567 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2569 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2570 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2571 update_group_announce_rrclients(bgp
);
2572 bgp_clear_star_soft_out(vty
, bgp
->name
);
2578 DEFUN (bgp_listen_limit
,
2579 bgp_listen_limit_cmd
,
2580 "bgp listen limit (1-5000)",
2581 "BGP specific commands\n"
2582 "Configure BGP defaults\n"
2583 "maximum number of BGP Dynamic Neighbors that can be created\n"
2584 "Configure Dynamic Neighbors listen limit value\n")
2586 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2590 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2592 bgp_listen_limit_set(bgp
, listen_limit
);
2597 DEFUN (no_bgp_listen_limit
,
2598 no_bgp_listen_limit_cmd
,
2599 "no bgp listen limit [(1-5000)]",
2600 "BGP specific commands\n"
2601 "Configure BGP defaults\n"
2602 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2603 "Configure Dynamic Neighbors listen limit value to default\n"
2604 "Configure Dynamic Neighbors listen limit value\n")
2606 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2607 bgp_listen_limit_unset(bgp
);
2613 * Check if this listen range is already configured. Check for exact
2614 * match or overlap based on input.
2616 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2617 struct prefix
*range
, int exact
)
2619 struct listnode
*node
, *nnode
;
2620 struct listnode
*node1
, *nnode1
;
2621 struct peer_group
*group
;
2626 afi
= family2afi(range
->family
);
2627 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2628 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2631 match
= prefix_same(range
, lr
);
2633 match
= (prefix_match(range
, lr
)
2634 || prefix_match(lr
, range
));
2643 DEFUN (bgp_listen_range
,
2644 bgp_listen_range_cmd
,
2645 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
2646 "BGP specific commands\n"
2647 "Configure BGP dynamic neighbors listen range\n"
2648 "Configure BGP dynamic neighbors listen range\n"
2650 "Member of the peer-group\n"
2651 "Peer-group name\n")
2653 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2654 struct prefix range
;
2655 struct peer_group
*group
, *existing_group
;
2660 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2661 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2662 char *prefix
= argv
[idx
]->arg
;
2663 argv_find(argv
, argc
, "PGNAME", &idx
);
2664 char *peergroup
= argv
[idx
]->arg
;
2666 /* Convert IP prefix string to struct prefix. */
2667 ret
= str2prefix(prefix
, &range
);
2669 vty_out(vty
, "%% Malformed listen range\n");
2670 return CMD_WARNING_CONFIG_FAILED
;
2673 afi
= family2afi(range
.family
);
2675 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2677 "%% Malformed listen range (link-local address)\n");
2678 return CMD_WARNING_CONFIG_FAILED
;
2683 /* Check if same listen range is already configured. */
2684 existing_group
= listen_range_exists(bgp
, &range
, 1);
2685 if (existing_group
) {
2686 if (strcmp(existing_group
->name
, peergroup
) == 0)
2690 "%% Same listen range is attached to peer-group %s\n",
2691 existing_group
->name
);
2692 return CMD_WARNING_CONFIG_FAILED
;
2696 /* Check if an overlapping listen range exists. */
2697 if (listen_range_exists(bgp
, &range
, 0)) {
2699 "%% Listen range overlaps with existing listen range\n");
2700 return CMD_WARNING_CONFIG_FAILED
;
2703 group
= peer_group_lookup(bgp
, peergroup
);
2705 vty_out(vty
, "%% Configure the peer-group first\n");
2706 return CMD_WARNING_CONFIG_FAILED
;
2709 ret
= peer_group_listen_range_add(group
, &range
);
2710 return bgp_vty_return(vty
, ret
);
2713 DEFUN (no_bgp_listen_range
,
2714 no_bgp_listen_range_cmd
,
2715 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
2717 "BGP specific commands\n"
2718 "Unconfigure BGP dynamic neighbors listen range\n"
2719 "Unconfigure BGP dynamic neighbors listen range\n"
2721 "Member of the peer-group\n"
2722 "Peer-group name\n")
2724 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2725 struct prefix range
;
2726 struct peer_group
*group
;
2731 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2732 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2733 char *prefix
= argv
[idx
]->arg
;
2734 argv_find(argv
, argc
, "WORD", &idx
);
2735 char *peergroup
= argv
[idx
]->arg
;
2737 /* Convert IP prefix string to struct prefix. */
2738 ret
= str2prefix(prefix
, &range
);
2740 vty_out(vty
, "%% Malformed listen range\n");
2741 return CMD_WARNING_CONFIG_FAILED
;
2744 afi
= family2afi(range
.family
);
2746 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2748 "%% Malformed listen range (link-local address)\n");
2749 return CMD_WARNING_CONFIG_FAILED
;
2754 group
= peer_group_lookup(bgp
, peergroup
);
2756 vty_out(vty
, "%% Peer-group does not exist\n");
2757 return CMD_WARNING_CONFIG_FAILED
;
2760 ret
= peer_group_listen_range_del(group
, &range
);
2761 return bgp_vty_return(vty
, ret
);
2764 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2766 struct peer_group
*group
;
2767 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2768 struct prefix
*range
;
2770 char buf
[PREFIX2STR_BUFFER
];
2772 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2773 vty_out(vty
, " bgp listen limit %d\n",
2774 bgp
->dynamic_neighbors_limit
);
2776 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2777 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2778 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2780 prefix2str(range
, buf
, sizeof(buf
));
2782 " bgp listen range %s peer-group %s\n",
2790 DEFUN (bgp_disable_connected_route_check
,
2791 bgp_disable_connected_route_check_cmd
,
2792 "bgp disable-ebgp-connected-route-check",
2793 "BGP specific commands\n"
2794 "Disable checking if nexthop is connected on ebgp sessions\n")
2796 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2797 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2798 bgp_clear_star_soft_in(vty
, bgp
->name
);
2803 DEFUN (no_bgp_disable_connected_route_check
,
2804 no_bgp_disable_connected_route_check_cmd
,
2805 "no bgp disable-ebgp-connected-route-check",
2807 "BGP specific commands\n"
2808 "Disable checking if nexthop is connected on ebgp sessions\n")
2810 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2811 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2812 bgp_clear_star_soft_in(vty
, bgp
->name
);
2818 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2819 const char *as_str
, afi_t afi
, safi_t safi
)
2821 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2824 int as_type
= AS_SPECIFIED
;
2827 if (as_str
[0] == 'i') {
2829 as_type
= AS_INTERNAL
;
2830 } else if (as_str
[0] == 'e') {
2832 as_type
= AS_EXTERNAL
;
2834 /* Get AS number. */
2835 as
= strtoul(as_str
, NULL
, 10);
2838 /* If peer is peer group or interface peer, call proper function. */
2839 ret
= str2sockunion(peer_str
, &su
);
2843 /* Check if existing interface peer */
2844 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
2846 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2849 /* if not interface peer, check peer-group settings */
2850 if (ret
< 0 && !peer
) {
2851 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2854 "%% Create the peer-group or interface first\n");
2855 return CMD_WARNING_CONFIG_FAILED
;
2860 if (peer_address_self_check(bgp
, &su
)) {
2862 "%% Can not configure the local system as neighbor\n");
2863 return CMD_WARNING_CONFIG_FAILED
;
2865 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2868 /* This peer belongs to peer group. */
2870 case BGP_ERR_PEER_GROUP_MEMBER
:
2872 "%% Peer-group member cannot override remote-as of peer-group\n");
2873 return CMD_WARNING_CONFIG_FAILED
;
2874 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2876 "%% Peer-group members must be all internal or all external\n");
2877 return CMD_WARNING_CONFIG_FAILED
;
2879 return bgp_vty_return(vty
, ret
);
2882 DEFUN (bgp_default_shutdown
,
2883 bgp_default_shutdown_cmd
,
2884 "[no] bgp default shutdown",
2887 "Configure BGP defaults\n"
2888 "Apply administrative shutdown to newly configured peers\n")
2890 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2891 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2895 DEFUN (neighbor_remote_as
,
2896 neighbor_remote_as_cmd
,
2897 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2900 "Specify a BGP neighbor\n"
2902 "Internal BGP peer\n"
2903 "External BGP peer\n")
2906 int idx_remote_as
= 3;
2907 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2908 argv
[idx_remote_as
]->arg
, AFI_IP
,
2912 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2913 afi_t afi
, safi_t safi
, int v6only
,
2914 const char *peer_group_name
,
2917 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2919 int as_type
= AS_UNSPECIFIED
;
2921 struct peer_group
*group
;
2925 group
= peer_group_lookup(bgp
, conf_if
);
2928 vty_out(vty
, "%% Name conflict with peer-group \n");
2929 return CMD_WARNING_CONFIG_FAILED
;
2933 if (as_str
[0] == 'i') {
2934 as_type
= AS_INTERNAL
;
2935 } else if (as_str
[0] == 'e') {
2936 as_type
= AS_EXTERNAL
;
2938 /* Get AS number. */
2939 as
= strtoul(as_str
, NULL
, 10);
2940 as_type
= AS_SPECIFIED
;
2944 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2947 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
2950 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2951 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2952 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2953 as_type
, 0, 0, NULL
);
2955 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2956 as_type
, afi
, safi
, NULL
);
2959 vty_out(vty
, "%% BGP failed to create peer\n");
2960 return CMD_WARNING_CONFIG_FAILED
;
2964 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2966 /* Request zebra to initiate IPv6 RAs on this interface. We do
2968 * any unnumbered peer in order to not worry about run-time
2970 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2972 * gets deleted later etc.)
2975 bgp_zebra_initiate_radv(bgp
, peer
);
2978 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2979 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2981 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2983 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
2985 /* v6only flag changed. Reset bgp seesion */
2986 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2987 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2988 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2989 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2991 bgp_session_reset(peer
);
2994 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
2995 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
2996 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
2997 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
3000 if (peer_group_name
) {
3001 group
= peer_group_lookup(bgp
, peer_group_name
);
3003 vty_out(vty
, "%% Configure the peer-group first\n");
3004 return CMD_WARNING_CONFIG_FAILED
;
3007 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3010 return bgp_vty_return(vty
, ret
);
3013 DEFUN (neighbor_interface_config
,
3014 neighbor_interface_config_cmd
,
3015 "neighbor WORD interface [peer-group PGNAME]",
3017 "Interface name or neighbor tag\n"
3018 "Enable BGP on interface\n"
3019 "Member of the peer-group\n"
3020 "Peer-group name\n")
3023 int idx_peer_group_word
= 4;
3025 if (argc
> idx_peer_group_word
)
3026 return peer_conf_interface_get(
3027 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
3028 argv
[idx_peer_group_word
]->arg
, NULL
);
3030 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3031 SAFI_UNICAST
, 0, NULL
, NULL
);
3034 DEFUN (neighbor_interface_config_v6only
,
3035 neighbor_interface_config_v6only_cmd
,
3036 "neighbor WORD interface v6only [peer-group PGNAME]",
3038 "Interface name or neighbor tag\n"
3039 "Enable BGP on interface\n"
3040 "Enable BGP with v6 link-local only\n"
3041 "Member of the peer-group\n"
3042 "Peer-group name\n")
3045 int idx_peer_group_word
= 5;
3047 if (argc
> idx_peer_group_word
)
3048 return peer_conf_interface_get(
3049 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
3050 argv
[idx_peer_group_word
]->arg
, NULL
);
3052 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3053 SAFI_UNICAST
, 1, NULL
, NULL
);
3057 DEFUN (neighbor_interface_config_remote_as
,
3058 neighbor_interface_config_remote_as_cmd
,
3059 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
3061 "Interface name or neighbor tag\n"
3062 "Enable BGP on interface\n"
3063 "Specify a BGP neighbor\n"
3065 "Internal BGP peer\n"
3066 "External BGP peer\n")
3069 int idx_remote_as
= 4;
3070 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3071 SAFI_UNICAST
, 0, NULL
,
3072 argv
[idx_remote_as
]->arg
);
3075 DEFUN (neighbor_interface_v6only_config_remote_as
,
3076 neighbor_interface_v6only_config_remote_as_cmd
,
3077 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
3079 "Interface name or neighbor tag\n"
3080 "Enable BGP with v6 link-local only\n"
3081 "Enable BGP on interface\n"
3082 "Specify a BGP neighbor\n"
3084 "Internal BGP peer\n"
3085 "External BGP peer\n")
3088 int idx_remote_as
= 5;
3089 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3090 SAFI_UNICAST
, 1, NULL
,
3091 argv
[idx_remote_as
]->arg
);
3094 DEFUN (neighbor_peer_group
,
3095 neighbor_peer_group_cmd
,
3096 "neighbor WORD peer-group",
3098 "Interface name or neighbor tag\n"
3099 "Configure peer-group\n")
3101 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3104 struct peer_group
*group
;
3106 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3108 vty_out(vty
, "%% Name conflict with interface: \n");
3109 return CMD_WARNING_CONFIG_FAILED
;
3112 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
3114 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
3115 return CMD_WARNING_CONFIG_FAILED
;
3123 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3127 "Specify a BGP neighbor\n"
3129 "Internal BGP peer\n"
3130 "External BGP peer\n")
3132 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3136 struct peer_group
*group
;
3140 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3142 /* look up for neighbor by interface name config. */
3143 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3145 /* Request zebra to terminate IPv6 RAs on this
3148 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3149 peer_notify_unconfig(peer
);
3154 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3156 peer_group_notify_unconfig(group
);
3157 peer_group_delete(group
);
3159 vty_out(vty
, "%% Create the peer-group first\n");
3160 return CMD_WARNING_CONFIG_FAILED
;
3163 peer
= peer_lookup(bgp
, &su
);
3165 if (peer_dynamic_neighbor(peer
)) {
3167 "%% Operation not allowed on a dynamic neighbor\n");
3168 return CMD_WARNING_CONFIG_FAILED
;
3171 other
= peer
->doppelganger
;
3172 peer_notify_unconfig(peer
);
3174 if (other
&& other
->status
!= Deleted
) {
3175 peer_notify_unconfig(other
);
3184 DEFUN (no_neighbor_interface_config
,
3185 no_neighbor_interface_config_cmd
,
3186 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
3190 "Configure BGP on interface\n"
3191 "Enable BGP with v6 link-local only\n"
3192 "Member of the peer-group\n"
3194 "Specify a BGP neighbor\n"
3196 "Internal BGP peer\n"
3197 "External BGP peer\n")
3199 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3203 /* look up for neighbor by interface name config. */
3204 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3206 /* Request zebra to terminate IPv6 RAs on this interface. */
3208 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3209 peer_notify_unconfig(peer
);
3212 vty_out(vty
, "%% Create the bgp interface first\n");
3213 return CMD_WARNING_CONFIG_FAILED
;
3218 DEFUN (no_neighbor_peer_group
,
3219 no_neighbor_peer_group_cmd
,
3220 "no neighbor WORD peer-group",
3224 "Configure peer-group\n")
3226 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3228 struct peer_group
*group
;
3230 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3232 peer_group_notify_unconfig(group
);
3233 peer_group_delete(group
);
3235 vty_out(vty
, "%% Create the peer-group first\n");
3236 return CMD_WARNING_CONFIG_FAILED
;
3241 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3242 no_neighbor_interface_peer_group_remote_as_cmd
,
3243 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3246 "Interface name or neighbor tag\n"
3247 "Specify a BGP neighbor\n"
3249 "Internal BGP peer\n"
3250 "External BGP peer\n")
3252 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3254 struct peer_group
*group
;
3257 /* look up for neighbor by interface name config. */
3258 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3260 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
3264 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3266 peer_group_remote_as_delete(group
);
3268 vty_out(vty
, "%% Create the peer-group or interface first\n");
3269 return CMD_WARNING_CONFIG_FAILED
;
3274 DEFUN (neighbor_local_as
,
3275 neighbor_local_as_cmd
,
3276 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3279 "Specify a local-as number\n"
3280 "AS number used as local AS\n")
3288 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3290 return CMD_WARNING_CONFIG_FAILED
;
3292 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3293 ret
= peer_local_as_set(peer
, as
, 0, 0);
3294 return bgp_vty_return(vty
, ret
);
3297 DEFUN (neighbor_local_as_no_prepend
,
3298 neighbor_local_as_no_prepend_cmd
,
3299 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3302 "Specify a local-as number\n"
3303 "AS number used as local AS\n"
3304 "Do not prepend local-as to updates from ebgp peers\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
, 1, 0);
3318 return bgp_vty_return(vty
, ret
);
3321 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3322 neighbor_local_as_no_prepend_replace_as_cmd
,
3323 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
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"
3329 "Do not prepend local-as to updates from ibgp peers\n")
3337 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3339 return CMD_WARNING_CONFIG_FAILED
;
3341 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3342 ret
= peer_local_as_set(peer
, as
, 1, 1);
3343 return bgp_vty_return(vty
, ret
);
3346 DEFUN (no_neighbor_local_as
,
3347 no_neighbor_local_as_cmd
,
3348 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3352 "Specify a local-as number\n"
3353 "AS number used as local AS\n"
3354 "Do not prepend local-as to updates from ebgp peers\n"
3355 "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 ret
= peer_local_as_unset(peer
);
3366 return bgp_vty_return(vty
, ret
);
3370 DEFUN (neighbor_solo
,
3372 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3375 "Solo peer - part of its own update group\n")
3381 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3383 return CMD_WARNING_CONFIG_FAILED
;
3385 ret
= update_group_adjust_soloness(peer
, 1);
3386 return bgp_vty_return(vty
, ret
);
3389 DEFUN (no_neighbor_solo
,
3390 no_neighbor_solo_cmd
,
3391 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3395 "Solo peer - part of its own update group\n")
3401 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3403 return CMD_WARNING_CONFIG_FAILED
;
3405 ret
= update_group_adjust_soloness(peer
, 0);
3406 return bgp_vty_return(vty
, ret
);
3409 DEFUN (neighbor_password
,
3410 neighbor_password_cmd
,
3411 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3422 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3424 return CMD_WARNING_CONFIG_FAILED
;
3426 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3427 return bgp_vty_return(vty
, ret
);
3430 DEFUN (no_neighbor_password
,
3431 no_neighbor_password_cmd
,
3432 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3443 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3445 return CMD_WARNING_CONFIG_FAILED
;
3447 ret
= peer_password_unset(peer
);
3448 return bgp_vty_return(vty
, ret
);
3451 DEFUN (neighbor_activate
,
3452 neighbor_activate_cmd
,
3453 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3456 "Enable the Address Family for this Neighbor\n")
3462 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3464 return CMD_WARNING_CONFIG_FAILED
;
3466 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3467 return bgp_vty_return(vty
, ret
);
3470 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3471 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3472 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3473 "Enable the Address Family for this Neighbor\n")
3475 DEFUN (no_neighbor_activate
,
3476 no_neighbor_activate_cmd
,
3477 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3481 "Enable the Address Family for this Neighbor\n")
3488 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3490 return CMD_WARNING_CONFIG_FAILED
;
3492 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3493 return bgp_vty_return(vty
, ret
);
3496 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3497 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3498 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3499 "Enable the Address Family for this Neighbor\n")
3501 DEFUN (neighbor_set_peer_group
,
3502 neighbor_set_peer_group_cmd
,
3503 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3506 "Member of the peer-group\n"
3507 "Peer-group name\n")
3509 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3516 struct peer_group
*group
;
3518 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3520 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3522 vty_out(vty
, "%% Malformed address or name: %s\n",
3523 argv
[idx_peer
]->arg
);
3524 return CMD_WARNING_CONFIG_FAILED
;
3527 if (peer_address_self_check(bgp
, &su
)) {
3529 "%% Can not configure the local system as neighbor\n");
3530 return CMD_WARNING_CONFIG_FAILED
;
3533 /* Disallow for dynamic neighbor. */
3534 peer
= peer_lookup(bgp
, &su
);
3535 if (peer
&& peer_dynamic_neighbor(peer
)) {
3537 "%% Operation not allowed on a dynamic neighbor\n");
3538 return CMD_WARNING_CONFIG_FAILED
;
3542 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3544 vty_out(vty
, "%% Configure the peer-group first\n");
3545 return CMD_WARNING_CONFIG_FAILED
;
3548 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3550 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3552 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3554 return CMD_WARNING_CONFIG_FAILED
;
3557 return bgp_vty_return(vty
, ret
);
3560 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3561 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3562 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3563 "Member of the peer-group\n"
3564 "Peer-group name\n")
3566 DEFUN (no_neighbor_set_peer_group
,
3567 no_neighbor_set_peer_group_cmd
,
3568 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3572 "Member of the peer-group\n"
3573 "Peer-group name\n")
3575 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3580 struct peer_group
*group
;
3582 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3584 return CMD_WARNING_CONFIG_FAILED
;
3586 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3588 vty_out(vty
, "%% Configure the peer-group first\n");
3589 return CMD_WARNING_CONFIG_FAILED
;
3592 peer_notify_unconfig(peer
);
3593 ret
= peer_delete(peer
);
3595 return bgp_vty_return(vty
, ret
);
3598 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3599 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3600 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3601 "Member of the peer-group\n"
3602 "Peer-group name\n")
3604 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3605 uint32_t flag
, int set
)
3610 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3612 return CMD_WARNING_CONFIG_FAILED
;
3615 * If 'neighbor <interface>', then this is for directly connected peers,
3616 * we should not accept disable-connected-check.
3618 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3620 "%s is directly connected peer, cannot accept disable-"
3621 "connected-check\n",
3623 return CMD_WARNING_CONFIG_FAILED
;
3626 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3627 peer_tx_shutdown_message_unset(peer
);
3630 ret
= peer_flag_set(peer
, flag
);
3632 ret
= peer_flag_unset(peer
, flag
);
3634 return bgp_vty_return(vty
, ret
);
3637 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3639 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3642 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3645 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3648 /* neighbor passive. */
3649 DEFUN (neighbor_passive
,
3650 neighbor_passive_cmd
,
3651 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3654 "Don't send open messages to this neighbor\n")
3657 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3660 DEFUN (no_neighbor_passive
,
3661 no_neighbor_passive_cmd
,
3662 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3666 "Don't send open messages to this neighbor\n")
3669 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3672 /* neighbor shutdown. */
3673 DEFUN (neighbor_shutdown_msg
,
3674 neighbor_shutdown_msg_cmd
,
3675 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3678 "Administratively shut down this neighbor\n"
3679 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3680 "Shutdown message\n")
3686 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3690 return CMD_WARNING_CONFIG_FAILED
;
3691 message
= argv_concat(argv
, argc
, 4);
3692 peer_tx_shutdown_message_set(peer
, message
);
3693 XFREE(MTYPE_TMP
, message
);
3696 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3699 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3700 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3701 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3702 "Administratively shut down this neighbor\n")
3704 DEFUN (no_neighbor_shutdown_msg
,
3705 no_neighbor_shutdown_msg_cmd
,
3706 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3710 "Administratively shut down this neighbor\n"
3711 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3712 "Shutdown message\n")
3716 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3717 PEER_FLAG_SHUTDOWN
);
3720 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3721 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3722 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3723 "Administratively shut down this neighbor\n")
3725 /* neighbor capability dynamic. */
3726 DEFUN (neighbor_capability_dynamic
,
3727 neighbor_capability_dynamic_cmd
,
3728 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3731 "Advertise capability to the peer\n"
3732 "Advertise dynamic capability to this neighbor\n")
3735 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3736 PEER_FLAG_DYNAMIC_CAPABILITY
);
3739 DEFUN (no_neighbor_capability_dynamic
,
3740 no_neighbor_capability_dynamic_cmd
,
3741 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3745 "Advertise capability to the peer\n"
3746 "Advertise dynamic capability to this neighbor\n")
3749 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3750 PEER_FLAG_DYNAMIC_CAPABILITY
);
3753 /* neighbor dont-capability-negotiate */
3754 DEFUN (neighbor_dont_capability_negotiate
,
3755 neighbor_dont_capability_negotiate_cmd
,
3756 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3759 "Do not perform capability negotiation\n")
3762 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3763 PEER_FLAG_DONT_CAPABILITY
);
3766 DEFUN (no_neighbor_dont_capability_negotiate
,
3767 no_neighbor_dont_capability_negotiate_cmd
,
3768 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3772 "Do not perform capability negotiation\n")
3775 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3776 PEER_FLAG_DONT_CAPABILITY
);
3779 /* neighbor capability extended next hop encoding */
3780 DEFUN (neighbor_capability_enhe
,
3781 neighbor_capability_enhe_cmd
,
3782 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3785 "Advertise capability to the peer\n"
3786 "Advertise extended next-hop capability to the peer\n")
3789 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3790 PEER_FLAG_CAPABILITY_ENHE
);
3793 DEFUN (no_neighbor_capability_enhe
,
3794 no_neighbor_capability_enhe_cmd
,
3795 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3799 "Advertise capability to the peer\n"
3800 "Advertise extended next-hop capability to the peer\n")
3803 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3804 PEER_FLAG_CAPABILITY_ENHE
);
3807 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3808 afi_t afi
, safi_t safi
, uint32_t flag
,
3814 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3816 return CMD_WARNING_CONFIG_FAILED
;
3819 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3821 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3823 return bgp_vty_return(vty
, ret
);
3826 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3827 afi_t afi
, safi_t safi
, uint32_t flag
)
3829 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3832 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3833 afi_t afi
, safi_t safi
, uint32_t flag
)
3835 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3838 /* neighbor capability orf prefix-list. */
3839 DEFUN (neighbor_capability_orf_prefix
,
3840 neighbor_capability_orf_prefix_cmd
,
3841 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3844 "Advertise capability to the peer\n"
3845 "Advertise ORF capability to the peer\n"
3846 "Advertise prefixlist ORF capability to this neighbor\n"
3847 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3848 "Capability to RECEIVE the ORF from this neighbor\n"
3849 "Capability to SEND the ORF to this neighbor\n")
3852 int idx_send_recv
= 5;
3855 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3856 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3857 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3858 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3859 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3860 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3862 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3863 return CMD_WARNING_CONFIG_FAILED
;
3866 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3867 bgp_node_safi(vty
), flag
);
3871 neighbor_capability_orf_prefix
,
3872 neighbor_capability_orf_prefix_hidden_cmd
,
3873 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3874 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3875 "Advertise capability to the peer\n"
3876 "Advertise ORF capability to the peer\n"
3877 "Advertise prefixlist ORF capability to this neighbor\n"
3878 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3879 "Capability to RECEIVE the ORF from this neighbor\n"
3880 "Capability to SEND the ORF to this neighbor\n")
3882 DEFUN (no_neighbor_capability_orf_prefix
,
3883 no_neighbor_capability_orf_prefix_cmd
,
3884 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3888 "Advertise capability to the peer\n"
3889 "Advertise ORF capability to the peer\n"
3890 "Advertise prefixlist ORF capability to this neighbor\n"
3891 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3892 "Capability to RECEIVE the ORF from this neighbor\n"
3893 "Capability to SEND the ORF to this neighbor\n")
3896 int idx_send_recv
= 6;
3899 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3900 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3901 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3902 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3903 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3904 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3906 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3907 return CMD_WARNING_CONFIG_FAILED
;
3910 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3911 bgp_node_afi(vty
), bgp_node_safi(vty
),
3916 no_neighbor_capability_orf_prefix
,
3917 no_neighbor_capability_orf_prefix_hidden_cmd
,
3918 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3919 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3920 "Advertise capability to the peer\n"
3921 "Advertise ORF capability to the peer\n"
3922 "Advertise prefixlist ORF capability to this neighbor\n"
3923 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3924 "Capability to RECEIVE the ORF from this neighbor\n"
3925 "Capability to SEND the ORF to this neighbor\n")
3927 /* neighbor next-hop-self. */
3928 DEFUN (neighbor_nexthop_self
,
3929 neighbor_nexthop_self_cmd
,
3930 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3933 "Disable the next hop calculation for this neighbor\n")
3936 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3937 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3940 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3941 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3942 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3943 "Disable the next hop calculation for this neighbor\n")
3945 /* neighbor next-hop-self. */
3946 DEFUN (neighbor_nexthop_self_force
,
3947 neighbor_nexthop_self_force_cmd
,
3948 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3951 "Disable the next hop calculation for this neighbor\n"
3952 "Set the next hop to self for reflected routes\n")
3955 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3957 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3960 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3961 neighbor_nexthop_self_force_hidden_cmd
,
3962 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3963 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3964 "Disable the next hop calculation for this neighbor\n"
3965 "Set the next hop to self for reflected routes\n")
3967 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3968 neighbor_nexthop_self_all_hidden_cmd
,
3969 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
3970 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3971 "Disable the next hop calculation for this neighbor\n"
3972 "Set the next hop to self for reflected routes\n")
3974 DEFUN (no_neighbor_nexthop_self
,
3975 no_neighbor_nexthop_self_cmd
,
3976 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3980 "Disable the next hop calculation for this neighbor\n")
3983 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3984 bgp_node_afi(vty
), bgp_node_safi(vty
),
3985 PEER_FLAG_NEXTHOP_SELF
);
3988 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3989 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3990 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3991 "Disable the next hop calculation for this neighbor\n")
3993 DEFUN (no_neighbor_nexthop_self_force
,
3994 no_neighbor_nexthop_self_force_cmd
,
3995 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3999 "Disable the next hop calculation for this neighbor\n"
4000 "Set the next hop to self for reflected routes\n")
4003 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4004 bgp_node_afi(vty
), bgp_node_safi(vty
),
4005 PEER_FLAG_FORCE_NEXTHOP_SELF
);
4008 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4009 no_neighbor_nexthop_self_force_hidden_cmd
,
4010 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4011 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4012 "Disable the next hop calculation for this neighbor\n"
4013 "Set the next hop to self for reflected routes\n")
4015 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4016 no_neighbor_nexthop_self_all_hidden_cmd
,
4017 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
4018 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4019 "Disable the next hop calculation for this neighbor\n"
4020 "Set the next hop to self for reflected routes\n")
4022 /* neighbor as-override */
4023 DEFUN (neighbor_as_override
,
4024 neighbor_as_override_cmd
,
4025 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4028 "Override ASNs in outbound updates if aspath equals remote-as\n")
4031 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4032 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
4035 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
4036 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4037 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4038 "Override ASNs in outbound updates if aspath equals remote-as\n")
4040 DEFUN (no_neighbor_as_override
,
4041 no_neighbor_as_override_cmd
,
4042 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4046 "Override ASNs in outbound updates if aspath equals remote-as\n")
4049 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4050 bgp_node_afi(vty
), bgp_node_safi(vty
),
4051 PEER_FLAG_AS_OVERRIDE
);
4054 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
4055 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4056 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4057 "Override ASNs in outbound updates if aspath equals remote-as\n")
4059 /* neighbor remove-private-AS. */
4060 DEFUN (neighbor_remove_private_as
,
4061 neighbor_remove_private_as_cmd
,
4062 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4065 "Remove private ASNs in outbound updates\n")
4068 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4070 PEER_FLAG_REMOVE_PRIVATE_AS
);
4073 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
4074 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4075 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4076 "Remove private ASNs in outbound updates\n")
4078 DEFUN (neighbor_remove_private_as_all
,
4079 neighbor_remove_private_as_all_cmd
,
4080 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4083 "Remove private ASNs in outbound updates\n"
4084 "Apply to all AS numbers\n")
4087 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4089 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4092 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
4093 neighbor_remove_private_as_all_hidden_cmd
,
4094 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4095 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4096 "Remove private ASNs in outbound updates\n"
4097 "Apply to all AS numbers")
4099 DEFUN (neighbor_remove_private_as_replace_as
,
4100 neighbor_remove_private_as_replace_as_cmd
,
4101 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4104 "Remove private ASNs in outbound updates\n"
4105 "Replace private ASNs with our ASN in outbound updates\n")
4108 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4110 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4113 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
4114 neighbor_remove_private_as_replace_as_hidden_cmd
,
4115 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4116 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4117 "Remove private ASNs in outbound updates\n"
4118 "Replace private ASNs with our ASN in outbound updates\n")
4120 DEFUN (neighbor_remove_private_as_all_replace_as
,
4121 neighbor_remove_private_as_all_replace_as_cmd
,
4122 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4125 "Remove private ASNs in outbound updates\n"
4126 "Apply to all AS numbers\n"
4127 "Replace private ASNs with our ASN in outbound updates\n")
4130 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4132 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4136 neighbor_remove_private_as_all_replace_as
,
4137 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4138 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4139 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4140 "Remove private ASNs in outbound updates\n"
4141 "Apply to all AS numbers\n"
4142 "Replace private ASNs with our ASN in outbound updates\n")
4144 DEFUN (no_neighbor_remove_private_as
,
4145 no_neighbor_remove_private_as_cmd
,
4146 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4150 "Remove private ASNs in outbound updates\n")
4153 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4154 bgp_node_afi(vty
), bgp_node_safi(vty
),
4155 PEER_FLAG_REMOVE_PRIVATE_AS
);
4158 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4159 no_neighbor_remove_private_as_hidden_cmd
,
4160 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4161 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4162 "Remove private ASNs in outbound updates\n")
4164 DEFUN (no_neighbor_remove_private_as_all
,
4165 no_neighbor_remove_private_as_all_cmd
,
4166 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4170 "Remove private ASNs in outbound updates\n"
4171 "Apply to all AS numbers\n")
4174 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4175 bgp_node_afi(vty
), bgp_node_safi(vty
),
4176 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4179 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4180 no_neighbor_remove_private_as_all_hidden_cmd
,
4181 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4182 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4183 "Remove private ASNs in outbound updates\n"
4184 "Apply to all AS numbers\n")
4186 DEFUN (no_neighbor_remove_private_as_replace_as
,
4187 no_neighbor_remove_private_as_replace_as_cmd
,
4188 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4192 "Remove private ASNs in outbound updates\n"
4193 "Replace private ASNs with our ASN in outbound updates\n")
4196 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4197 bgp_node_afi(vty
), bgp_node_safi(vty
),
4198 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4201 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4202 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4203 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4204 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4205 "Remove private ASNs in outbound updates\n"
4206 "Replace private ASNs with our ASN in outbound updates\n")
4208 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4209 no_neighbor_remove_private_as_all_replace_as_cmd
,
4210 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4214 "Remove private ASNs in outbound updates\n"
4215 "Apply to all AS numbers\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_ALL_REPLACE
);
4225 no_neighbor_remove_private_as_all_replace_as
,
4226 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4227 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4228 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4229 "Remove private ASNs in outbound updates\n"
4230 "Apply to all AS numbers\n"
4231 "Replace private ASNs with our ASN in outbound updates\n")
4234 /* neighbor send-community. */
4235 DEFUN (neighbor_send_community
,
4236 neighbor_send_community_cmd
,
4237 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4240 "Send Community attribute to this neighbor\n")
4244 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4246 PEER_FLAG_SEND_COMMUNITY
);
4249 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4250 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4251 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4252 "Send Community attribute to this neighbor\n")
4254 DEFUN (no_neighbor_send_community
,
4255 no_neighbor_send_community_cmd
,
4256 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4260 "Send Community attribute to this neighbor\n")
4264 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4265 bgp_node_afi(vty
), bgp_node_safi(vty
),
4266 PEER_FLAG_SEND_COMMUNITY
);
4269 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4270 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4271 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4272 "Send Community attribute to this neighbor\n")
4274 /* neighbor send-community extended. */
4275 DEFUN (neighbor_send_community_type
,
4276 neighbor_send_community_type_cmd
,
4277 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4280 "Send Community attribute to this neighbor\n"
4281 "Send Standard and Extended Community attributes\n"
4282 "Send Standard, Large and Extended Community attributes\n"
4283 "Send Extended Community attributes\n"
4284 "Send Standard Community attributes\n"
4285 "Send Large Community attributes\n")
4289 const char *type
= argv
[argc
- 1]->text
;
4291 if (strmatch(type
, "standard")) {
4292 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4293 } else if (strmatch(type
, "extended")) {
4294 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4295 } else if (strmatch(type
, "large")) {
4296 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4297 } else if (strmatch(type
, "both")) {
4298 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4299 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4300 } else { /* if (strmatch(type, "all")) */
4301 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4302 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4303 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4306 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4307 bgp_node_safi(vty
), flag
);
4311 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4312 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4313 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4314 "Send Community attribute to this neighbor\n"
4315 "Send Standard and Extended Community attributes\n"
4316 "Send Standard, Large and Extended Community attributes\n"
4317 "Send Extended Community attributes\n"
4318 "Send Standard Community attributes\n"
4319 "Send Large Community attributes\n")
4321 DEFUN (no_neighbor_send_community_type
,
4322 no_neighbor_send_community_type_cmd
,
4323 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4327 "Send Community attribute to this neighbor\n"
4328 "Send Standard and Extended Community attributes\n"
4329 "Send Standard, Large and Extended Community attributes\n"
4330 "Send Extended Community attributes\n"
4331 "Send Standard Community attributes\n"
4332 "Send Large Community attributes\n")
4336 const char *type
= argv
[argc
- 1]->text
;
4338 if (strmatch(type
, "standard")) {
4339 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4340 } else if (strmatch(type
, "extended")) {
4341 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4342 } else if (strmatch(type
, "large")) {
4343 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4344 } else if (strmatch(type
, "both")) {
4345 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4346 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4347 } else { /* if (strmatch(type, "all")) */
4348 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4349 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4350 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4353 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4354 bgp_node_afi(vty
), bgp_node_safi(vty
),
4359 no_neighbor_send_community_type
,
4360 no_neighbor_send_community_type_hidden_cmd
,
4361 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4362 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4363 "Send Community attribute to this neighbor\n"
4364 "Send Standard and Extended Community attributes\n"
4365 "Send Standard, Large and Extended Community attributes\n"
4366 "Send Extended Community attributes\n"
4367 "Send Standard Community attributes\n"
4368 "Send Large Community attributes\n")
4370 /* neighbor soft-reconfig. */
4371 DEFUN (neighbor_soft_reconfiguration
,
4372 neighbor_soft_reconfiguration_cmd
,
4373 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4376 "Per neighbor soft reconfiguration\n"
4377 "Allow inbound soft reconfiguration for this neighbor\n")
4380 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4382 PEER_FLAG_SOFT_RECONFIG
);
4385 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4386 neighbor_soft_reconfiguration_hidden_cmd
,
4387 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4388 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4389 "Per neighbor soft reconfiguration\n"
4390 "Allow inbound soft reconfiguration for this neighbor\n")
4392 DEFUN (no_neighbor_soft_reconfiguration
,
4393 no_neighbor_soft_reconfiguration_cmd
,
4394 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4398 "Per neighbor soft reconfiguration\n"
4399 "Allow inbound soft reconfiguration for this neighbor\n")
4402 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4403 bgp_node_afi(vty
), bgp_node_safi(vty
),
4404 PEER_FLAG_SOFT_RECONFIG
);
4407 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4408 no_neighbor_soft_reconfiguration_hidden_cmd
,
4409 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4410 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4411 "Per neighbor soft reconfiguration\n"
4412 "Allow inbound soft reconfiguration for this neighbor\n")
4414 DEFUN (neighbor_route_reflector_client
,
4415 neighbor_route_reflector_client_cmd
,
4416 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4419 "Configure a neighbor as Route Reflector client\n")
4425 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4427 return CMD_WARNING_CONFIG_FAILED
;
4429 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4431 PEER_FLAG_REFLECTOR_CLIENT
);
4434 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4435 neighbor_route_reflector_client_hidden_cmd
,
4436 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4437 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4438 "Configure a neighbor as Route Reflector client\n")
4440 DEFUN (no_neighbor_route_reflector_client
,
4441 no_neighbor_route_reflector_client_cmd
,
4442 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4446 "Configure a neighbor as Route Reflector client\n")
4449 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4450 bgp_node_afi(vty
), bgp_node_safi(vty
),
4451 PEER_FLAG_REFLECTOR_CLIENT
);
4454 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4455 no_neighbor_route_reflector_client_hidden_cmd
,
4456 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4457 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4458 "Configure a neighbor as Route Reflector client\n")
4460 /* neighbor route-server-client. */
4461 DEFUN (neighbor_route_server_client
,
4462 neighbor_route_server_client_cmd
,
4463 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4466 "Configure a neighbor as Route Server client\n")
4471 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4473 return CMD_WARNING_CONFIG_FAILED
;
4474 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4476 PEER_FLAG_RSERVER_CLIENT
);
4479 ALIAS_HIDDEN(neighbor_route_server_client
,
4480 neighbor_route_server_client_hidden_cmd
,
4481 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4482 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4483 "Configure a neighbor as Route Server client\n")
4485 DEFUN (no_neighbor_route_server_client
,
4486 no_neighbor_route_server_client_cmd
,
4487 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4491 "Configure a neighbor as Route Server client\n")
4494 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4495 bgp_node_afi(vty
), bgp_node_safi(vty
),
4496 PEER_FLAG_RSERVER_CLIENT
);
4499 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4500 no_neighbor_route_server_client_hidden_cmd
,
4501 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4502 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4503 "Configure a neighbor as Route Server client\n")
4505 DEFUN (neighbor_nexthop_local_unchanged
,
4506 neighbor_nexthop_local_unchanged_cmd
,
4507 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4510 "Configure treatment of outgoing link-local nexthop attribute\n"
4511 "Leave link-local nexthop unchanged for this peer\n")
4514 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4516 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4519 DEFUN (no_neighbor_nexthop_local_unchanged
,
4520 no_neighbor_nexthop_local_unchanged_cmd
,
4521 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4525 "Configure treatment of outgoing link-local-nexthop attribute\n"
4526 "Leave link-local nexthop unchanged for this peer\n")
4529 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4530 bgp_node_afi(vty
), bgp_node_safi(vty
),
4531 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4534 DEFUN (neighbor_attr_unchanged
,
4535 neighbor_attr_unchanged_cmd
,
4536 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4539 "BGP attribute is propagated unchanged to this neighbor\n"
4540 "As-path attribute\n"
4541 "Nexthop attribute\n"
4545 char *peer_str
= argv
[1]->arg
;
4548 afi_t afi
= bgp_node_afi(vty
);
4549 safi_t safi
= bgp_node_safi(vty
);
4551 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4553 return CMD_WARNING_CONFIG_FAILED
;
4555 if (argv_find(argv
, argc
, "as-path", &idx
))
4556 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4558 if (argv_find(argv
, argc
, "next-hop", &idx
))
4559 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4561 if (argv_find(argv
, argc
, "med", &idx
))
4562 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4564 /* no flags means all of them! */
4566 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4567 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4568 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4570 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4571 && peer_af_flag_check(peer
, afi
, safi
,
4572 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4573 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4574 PEER_FLAG_AS_PATH_UNCHANGED
);
4577 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4578 && peer_af_flag_check(peer
, afi
, safi
,
4579 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4580 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4581 PEER_FLAG_NEXTHOP_UNCHANGED
);
4584 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4585 && peer_af_flag_check(peer
, afi
, safi
,
4586 PEER_FLAG_MED_UNCHANGED
)) {
4587 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4588 PEER_FLAG_MED_UNCHANGED
);
4592 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4596 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4597 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4598 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4599 "BGP attribute is propagated unchanged to this neighbor\n"
4600 "As-path attribute\n"
4601 "Nexthop attribute\n"
4604 DEFUN (no_neighbor_attr_unchanged
,
4605 no_neighbor_attr_unchanged_cmd
,
4606 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4610 "BGP attribute is propagated unchanged to this neighbor\n"
4611 "As-path attribute\n"
4612 "Nexthop attribute\n"
4616 char *peer
= argv
[2]->arg
;
4619 if (argv_find(argv
, argc
, "as-path", &idx
))
4620 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4622 if (argv_find(argv
, argc
, "next-hop", &idx
))
4623 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4625 if (argv_find(argv
, argc
, "med", &idx
))
4626 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4628 if (!flags
) // no flags means all of them!
4630 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4631 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4632 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4635 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4636 bgp_node_safi(vty
), flags
);
4640 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4641 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4642 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4643 "BGP attribute is propagated unchanged to this neighbor\n"
4644 "As-path attribute\n"
4645 "Nexthop attribute\n"
4648 /* EBGP multihop configuration. */
4649 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4650 const char *ttl_str
)
4655 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4657 return CMD_WARNING_CONFIG_FAILED
;
4660 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4665 ttl
= strtoul(ttl_str
, NULL
, 10);
4667 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4670 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4674 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4676 return CMD_WARNING_CONFIG_FAILED
;
4678 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4681 /* neighbor ebgp-multihop. */
4682 DEFUN (neighbor_ebgp_multihop
,
4683 neighbor_ebgp_multihop_cmd
,
4684 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4687 "Allow EBGP neighbors not on directly connected networks\n")
4690 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4693 DEFUN (neighbor_ebgp_multihop_ttl
,
4694 neighbor_ebgp_multihop_ttl_cmd
,
4695 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4698 "Allow EBGP neighbors not on directly connected networks\n"
4699 "maximum hop count\n")
4703 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4704 argv
[idx_number
]->arg
);
4707 DEFUN (no_neighbor_ebgp_multihop
,
4708 no_neighbor_ebgp_multihop_cmd
,
4709 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4713 "Allow EBGP neighbors not on directly connected networks\n"
4714 "maximum hop count\n")
4717 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4721 /* disable-connected-check */
4722 DEFUN (neighbor_disable_connected_check
,
4723 neighbor_disable_connected_check_cmd
,
4724 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4727 "one-hop away EBGP peer using loopback address\n"
4728 "Enforce EBGP neighbors perform multihop\n")
4731 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4732 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4735 DEFUN (no_neighbor_disable_connected_check
,
4736 no_neighbor_disable_connected_check_cmd
,
4737 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4741 "one-hop away EBGP peer using loopback address\n"
4742 "Enforce EBGP neighbors perform multihop\n")
4745 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4746 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4750 /* enforce-first-as */
4751 DEFUN (neighbor_enforce_first_as
,
4752 neighbor_enforce_first_as_cmd
,
4753 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4756 "Enforce the first AS for EBGP routes\n")
4760 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4761 PEER_FLAG_ENFORCE_FIRST_AS
);
4764 DEFUN (no_neighbor_enforce_first_as
,
4765 no_neighbor_enforce_first_as_cmd
,
4766 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4770 "Enforce the first AS for EBGP routes\n")
4774 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4775 PEER_FLAG_ENFORCE_FIRST_AS
);
4779 DEFUN (neighbor_description
,
4780 neighbor_description_cmd
,
4781 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4784 "Neighbor specific description\n"
4785 "Up to 80 characters describing this neighbor\n")
4792 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4794 return CMD_WARNING_CONFIG_FAILED
;
4796 str
= argv_concat(argv
, argc
, idx_line
);
4798 peer_description_set(peer
, str
);
4800 XFREE(MTYPE_TMP
, str
);
4805 DEFUN (no_neighbor_description
,
4806 no_neighbor_description_cmd
,
4807 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4811 "Neighbor specific description\n")
4816 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4818 return CMD_WARNING_CONFIG_FAILED
;
4820 peer_description_unset(peer
);
4825 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4826 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4827 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4828 "Neighbor specific description\n"
4829 "Up to 80 characters describing this neighbor\n")
4831 /* Neighbor update-source. */
4832 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4833 const char *source_str
)
4839 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4841 return CMD_WARNING_CONFIG_FAILED
;
4847 if (str2sockunion(source_str
, &su
) == 0)
4848 peer_update_source_addr_set(peer
, &su
);
4850 if (str2prefix(source_str
, &p
)) {
4852 "%% Invalid update-source, remove prefix length \n");
4853 return CMD_WARNING_CONFIG_FAILED
;
4855 peer_update_source_if_set(peer
, source_str
);
4858 peer_update_source_unset(peer
);
4863 #define BGP_UPDATE_SOURCE_HELP_STR \
4866 "Interface name (requires zebra to be running)\n"
4868 DEFUN (neighbor_update_source
,
4869 neighbor_update_source_cmd
,
4870 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4873 "Source of routing updates\n"
4874 BGP_UPDATE_SOURCE_HELP_STR
)
4878 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4879 argv
[idx_peer_2
]->arg
);
4882 DEFUN (no_neighbor_update_source
,
4883 no_neighbor_update_source_cmd
,
4884 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4888 "Source of routing updates\n"
4889 BGP_UPDATE_SOURCE_HELP_STR
)
4892 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4895 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4896 afi_t afi
, safi_t safi
,
4897 const char *rmap
, int set
)
4901 struct route_map
*route_map
= NULL
;
4903 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4905 return CMD_WARNING_CONFIG_FAILED
;
4909 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
4910 ret
= peer_default_originate_set(peer
, afi
, safi
,
4913 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4915 return bgp_vty_return(vty
, ret
);
4918 /* neighbor default-originate. */
4919 DEFUN (neighbor_default_originate
,
4920 neighbor_default_originate_cmd
,
4921 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4924 "Originate default route to this neighbor\n")
4927 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4929 bgp_node_safi(vty
), NULL
, 1);
4932 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4933 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4934 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4935 "Originate default route to this neighbor\n")
4937 DEFUN (neighbor_default_originate_rmap
,
4938 neighbor_default_originate_rmap_cmd
,
4939 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4942 "Originate default route to this neighbor\n"
4943 "Route-map to specify criteria to originate default\n"
4948 return peer_default_originate_set_vty(
4949 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4950 argv
[idx_word
]->arg
, 1);
4954 neighbor_default_originate_rmap
,
4955 neighbor_default_originate_rmap_hidden_cmd
,
4956 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4957 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4958 "Originate default route to this neighbor\n"
4959 "Route-map to specify criteria to originate default\n"
4962 DEFUN (no_neighbor_default_originate
,
4963 no_neighbor_default_originate_cmd
,
4964 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4968 "Originate default route to this neighbor\n"
4969 "Route-map to specify criteria to originate default\n"
4973 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4975 bgp_node_safi(vty
), NULL
, 0);
4979 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4980 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4981 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4982 "Originate default route to this neighbor\n"
4983 "Route-map to specify criteria to originate default\n"
4987 /* Set neighbor's BGP port. */
4988 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4989 const char *port_str
)
4995 peer
= peer_lookup_vty(vty
, ip_str
);
4997 return CMD_WARNING_CONFIG_FAILED
;
5000 sp
= getservbyname("bgp", "tcp");
5001 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
5003 port
= strtoul(port_str
, NULL
, 10);
5006 peer_port_set(peer
, port
);
5011 /* Set specified peer's BGP port. */
5012 DEFUN (neighbor_port
,
5014 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
5017 "Neighbor's BGP port\n"
5018 "TCP port number\n")
5022 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
5023 argv
[idx_number
]->arg
);
5026 DEFUN (no_neighbor_port
,
5027 no_neighbor_port_cmd
,
5028 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
5032 "Neighbor's BGP port\n"
5033 "TCP port number\n")
5036 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
5040 /* neighbor weight. */
5041 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5042 safi_t safi
, const char *weight_str
)
5046 unsigned long weight
;
5048 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5050 return CMD_WARNING_CONFIG_FAILED
;
5052 weight
= strtoul(weight_str
, NULL
, 10);
5054 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
5055 return bgp_vty_return(vty
, ret
);
5058 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5064 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5066 return CMD_WARNING_CONFIG_FAILED
;
5068 ret
= peer_weight_unset(peer
, afi
, safi
);
5069 return bgp_vty_return(vty
, ret
);
5072 DEFUN (neighbor_weight
,
5073 neighbor_weight_cmd
,
5074 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5077 "Set default weight for routes from this neighbor\n"
5082 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5083 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
5086 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
5087 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5088 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5089 "Set default weight for routes from this neighbor\n"
5092 DEFUN (no_neighbor_weight
,
5093 no_neighbor_weight_cmd
,
5094 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5098 "Set default weight for routes from this neighbor\n"
5102 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
5103 bgp_node_afi(vty
), bgp_node_safi(vty
));
5106 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
5107 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5108 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5109 "Set default weight for routes from this neighbor\n"
5113 /* Override capability negotiation. */
5114 DEFUN (neighbor_override_capability
,
5115 neighbor_override_capability_cmd
,
5116 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5119 "Override capability negotiation result\n")
5122 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5123 PEER_FLAG_OVERRIDE_CAPABILITY
);
5126 DEFUN (no_neighbor_override_capability
,
5127 no_neighbor_override_capability_cmd
,
5128 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5132 "Override capability negotiation result\n")
5135 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5136 PEER_FLAG_OVERRIDE_CAPABILITY
);
5139 DEFUN (neighbor_strict_capability
,
5140 neighbor_strict_capability_cmd
,
5141 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5144 "Strict capability negotiation match\n")
5148 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5149 PEER_FLAG_STRICT_CAP_MATCH
);
5152 DEFUN (no_neighbor_strict_capability
,
5153 no_neighbor_strict_capability_cmd
,
5154 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5158 "Strict capability negotiation match\n")
5162 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5163 PEER_FLAG_STRICT_CAP_MATCH
);
5166 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5167 const char *keep_str
, const char *hold_str
)
5174 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5176 return CMD_WARNING_CONFIG_FAILED
;
5178 keepalive
= strtoul(keep_str
, NULL
, 10);
5179 holdtime
= strtoul(hold_str
, NULL
, 10);
5181 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5183 return bgp_vty_return(vty
, ret
);
5186 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5191 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5193 return CMD_WARNING_CONFIG_FAILED
;
5195 ret
= peer_timers_unset(peer
);
5197 return bgp_vty_return(vty
, ret
);
5200 DEFUN (neighbor_timers
,
5201 neighbor_timers_cmd
,
5202 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5205 "BGP per neighbor timers\n"
5206 "Keepalive interval\n"
5211 int idx_number_2
= 4;
5212 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5213 argv
[idx_number
]->arg
,
5214 argv
[idx_number_2
]->arg
);
5217 DEFUN (no_neighbor_timers
,
5218 no_neighbor_timers_cmd
,
5219 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5223 "BGP per neighbor timers\n"
5224 "Keepalive interval\n"
5228 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5232 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5233 const char *time_str
)
5239 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5241 return CMD_WARNING_CONFIG_FAILED
;
5243 connect
= strtoul(time_str
, NULL
, 10);
5245 ret
= peer_timers_connect_set(peer
, connect
);
5247 return bgp_vty_return(vty
, ret
);
5250 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5255 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5257 return CMD_WARNING_CONFIG_FAILED
;
5259 ret
= peer_timers_connect_unset(peer
);
5261 return bgp_vty_return(vty
, ret
);
5264 DEFUN (neighbor_timers_connect
,
5265 neighbor_timers_connect_cmd
,
5266 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5269 "BGP per neighbor timers\n"
5270 "BGP connect timer\n"
5275 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5276 argv
[idx_number
]->arg
);
5279 DEFUN (no_neighbor_timers_connect
,
5280 no_neighbor_timers_connect_cmd
,
5281 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5285 "BGP per neighbor timers\n"
5286 "BGP connect timer\n"
5290 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5294 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5295 const char *time_str
, int set
)
5299 uint32_t routeadv
= 0;
5301 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5303 return CMD_WARNING_CONFIG_FAILED
;
5306 routeadv
= strtoul(time_str
, NULL
, 10);
5309 ret
= peer_advertise_interval_set(peer
, routeadv
);
5311 ret
= peer_advertise_interval_unset(peer
);
5313 return bgp_vty_return(vty
, ret
);
5316 DEFUN (neighbor_advertise_interval
,
5317 neighbor_advertise_interval_cmd
,
5318 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5321 "Minimum interval between sending BGP routing updates\n"
5322 "time in seconds\n")
5326 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5327 argv
[idx_number
]->arg
, 1);
5330 DEFUN (no_neighbor_advertise_interval
,
5331 no_neighbor_advertise_interval_cmd
,
5332 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5336 "Minimum interval between sending BGP routing updates\n"
5337 "time in seconds\n")
5340 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5344 /* Time to wait before processing route-map updates */
5345 DEFUN (bgp_set_route_map_delay_timer
,
5346 bgp_set_route_map_delay_timer_cmd
,
5347 "bgp route-map delay-timer (0-600)",
5349 "BGP route-map delay timer\n"
5350 "Time in secs to wait before processing route-map changes\n"
5351 "0 disables the timer, no route updates happen when route-maps change\n")
5354 uint32_t rmap_delay_timer
;
5356 if (argv
[idx_number
]->arg
) {
5357 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5358 bm
->rmap_update_timer
= rmap_delay_timer
;
5360 /* if the dynamic update handling is being disabled, and a timer
5362 * running, stop the timer and act as if the timer has already
5365 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5366 BGP_TIMER_OFF(bm
->t_rmap_update
);
5367 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5372 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5373 return CMD_WARNING_CONFIG_FAILED
;
5377 DEFUN (no_bgp_set_route_map_delay_timer
,
5378 no_bgp_set_route_map_delay_timer_cmd
,
5379 "no bgp route-map delay-timer [(0-600)]",
5382 "Default BGP route-map delay timer\n"
5383 "Reset to default time to wait for processing route-map changes\n"
5384 "0 disables the timer, no route updates happen when route-maps change\n")
5387 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5393 /* neighbor interface */
5394 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5399 peer
= peer_lookup_vty(vty
, ip_str
);
5400 if (!peer
|| peer
->conf_if
) {
5401 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5402 return CMD_WARNING_CONFIG_FAILED
;
5406 peer_interface_set(peer
, str
);
5408 peer_interface_unset(peer
);
5413 DEFUN (neighbor_interface
,
5414 neighbor_interface_cmd
,
5415 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5423 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5426 DEFUN (no_neighbor_interface
,
5427 no_neighbor_interface_cmd
,
5428 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5436 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5439 DEFUN (neighbor_distribute_list
,
5440 neighbor_distribute_list_cmd
,
5441 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5444 "Filter updates to/from this neighbor\n"
5445 "IP access-list number\n"
5446 "IP access-list number (expanded range)\n"
5447 "IP Access-list name\n"
5448 "Filter incoming updates\n"
5449 "Filter outgoing updates\n")
5456 const char *pstr
= argv
[idx_peer
]->arg
;
5457 const char *acl
= argv
[idx_acl
]->arg
;
5458 const char *inout
= argv
[argc
- 1]->text
;
5460 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5462 return CMD_WARNING_CONFIG_FAILED
;
5464 /* Check filter direction. */
5465 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5466 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5469 return bgp_vty_return(vty
, ret
);
5473 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5474 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5475 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5476 "Filter updates to/from this neighbor\n"
5477 "IP access-list number\n"
5478 "IP access-list number (expanded range)\n"
5479 "IP Access-list name\n"
5480 "Filter incoming updates\n"
5481 "Filter outgoing updates\n")
5483 DEFUN (no_neighbor_distribute_list
,
5484 no_neighbor_distribute_list_cmd
,
5485 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5489 "Filter updates to/from this neighbor\n"
5490 "IP access-list number\n"
5491 "IP access-list number (expanded range)\n"
5492 "IP Access-list name\n"
5493 "Filter incoming updates\n"
5494 "Filter outgoing updates\n")
5500 const char *pstr
= argv
[idx_peer
]->arg
;
5501 const char *inout
= argv
[argc
- 1]->text
;
5503 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5505 return CMD_WARNING_CONFIG_FAILED
;
5507 /* Check filter direction. */
5508 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5509 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5512 return bgp_vty_return(vty
, ret
);
5516 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5517 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5518 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5519 "Filter updates to/from this neighbor\n"
5520 "IP access-list number\n"
5521 "IP access-list number (expanded range)\n"
5522 "IP Access-list name\n"
5523 "Filter incoming updates\n"
5524 "Filter outgoing updates\n")
5526 /* Set prefix list to the peer. */
5527 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5528 afi_t afi
, safi_t safi
,
5529 const char *name_str
,
5530 const char *direct_str
)
5533 int direct
= FILTER_IN
;
5536 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5538 return CMD_WARNING_CONFIG_FAILED
;
5540 /* Check filter direction. */
5541 if (strncmp(direct_str
, "i", 1) == 0)
5543 else if (strncmp(direct_str
, "o", 1) == 0)
5544 direct
= FILTER_OUT
;
5546 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5548 return bgp_vty_return(vty
, ret
);
5551 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5552 afi_t afi
, safi_t safi
,
5553 const char *direct_str
)
5557 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_unset(peer
, afi
, safi
, direct
);
5571 return bgp_vty_return(vty
, ret
);
5574 DEFUN (neighbor_prefix_list
,
5575 neighbor_prefix_list_cmd
,
5576 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5579 "Filter updates to/from this neighbor\n"
5580 "Name of a prefix list\n"
5581 "Filter incoming updates\n"
5582 "Filter outgoing updates\n")
5587 return peer_prefix_list_set_vty(
5588 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5589 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5592 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5593 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5594 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5595 "Filter updates to/from this neighbor\n"
5596 "Name of a prefix list\n"
5597 "Filter incoming updates\n"
5598 "Filter outgoing updates\n")
5600 DEFUN (no_neighbor_prefix_list
,
5601 no_neighbor_prefix_list_cmd
,
5602 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5606 "Filter updates to/from this neighbor\n"
5607 "Name of a prefix list\n"
5608 "Filter incoming updates\n"
5609 "Filter outgoing updates\n")
5613 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5614 bgp_node_afi(vty
), bgp_node_safi(vty
),
5615 argv
[idx_in_out
]->arg
);
5618 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5619 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5620 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5621 "Filter updates to/from this neighbor\n"
5622 "Name of a prefix list\n"
5623 "Filter incoming updates\n"
5624 "Filter outgoing updates\n")
5626 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5627 safi_t safi
, const char *name_str
,
5628 const char *direct_str
)
5632 int direct
= FILTER_IN
;
5634 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5636 return CMD_WARNING_CONFIG_FAILED
;
5638 /* Check filter direction. */
5639 if (strncmp(direct_str
, "i", 1) == 0)
5641 else if (strncmp(direct_str
, "o", 1) == 0)
5642 direct
= FILTER_OUT
;
5644 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5646 return bgp_vty_return(vty
, ret
);
5649 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5650 safi_t safi
, const char *direct_str
)
5654 int direct
= FILTER_IN
;
5656 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5658 return CMD_WARNING_CONFIG_FAILED
;
5660 /* Check filter direction. */
5661 if (strncmp(direct_str
, "i", 1) == 0)
5663 else if (strncmp(direct_str
, "o", 1) == 0)
5664 direct
= FILTER_OUT
;
5666 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5668 return bgp_vty_return(vty
, ret
);
5671 DEFUN (neighbor_filter_list
,
5672 neighbor_filter_list_cmd
,
5673 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5676 "Establish BGP filters\n"
5677 "AS path access-list name\n"
5678 "Filter incoming routes\n"
5679 "Filter outgoing routes\n")
5684 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5685 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5686 argv
[idx_in_out
]->arg
);
5689 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5690 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5691 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5692 "Establish BGP filters\n"
5693 "AS path access-list name\n"
5694 "Filter incoming routes\n"
5695 "Filter outgoing routes\n")
5697 DEFUN (no_neighbor_filter_list
,
5698 no_neighbor_filter_list_cmd
,
5699 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5703 "Establish BGP filters\n"
5704 "AS path access-list name\n"
5705 "Filter incoming routes\n"
5706 "Filter outgoing routes\n")
5710 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5711 bgp_node_afi(vty
), bgp_node_safi(vty
),
5712 argv
[idx_in_out
]->arg
);
5715 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5716 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5717 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5718 "Establish BGP filters\n"
5719 "AS path access-list name\n"
5720 "Filter incoming routes\n"
5721 "Filter outgoing routes\n")
5723 /* Set route-map to the peer. */
5724 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5725 afi_t afi
, safi_t safi
, const char *name_str
,
5726 const char *direct_str
)
5730 int direct
= RMAP_IN
;
5731 struct route_map
*route_map
;
5733 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5735 return CMD_WARNING_CONFIG_FAILED
;
5737 /* Check filter direction. */
5738 if (strncmp(direct_str
, "in", 2) == 0)
5740 else if (strncmp(direct_str
, "o", 1) == 0)
5743 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5744 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
5746 return bgp_vty_return(vty
, ret
);
5749 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5750 afi_t afi
, safi_t safi
,
5751 const char *direct_str
)
5755 int direct
= RMAP_IN
;
5757 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5759 return CMD_WARNING_CONFIG_FAILED
;
5761 /* Check filter direction. */
5762 if (strncmp(direct_str
, "in", 2) == 0)
5764 else if (strncmp(direct_str
, "o", 1) == 0)
5767 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5769 return bgp_vty_return(vty
, ret
);
5772 DEFUN (neighbor_route_map
,
5773 neighbor_route_map_cmd
,
5774 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5777 "Apply route map to neighbor\n"
5778 "Name of route map\n"
5779 "Apply map to incoming routes\n"
5780 "Apply map to outbound routes\n")
5785 return peer_route_map_set_vty(
5786 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5787 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5790 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5791 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5792 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5793 "Apply route map to neighbor\n"
5794 "Name of route map\n"
5795 "Apply map to incoming routes\n"
5796 "Apply map to outbound routes\n")
5798 DEFUN (no_neighbor_route_map
,
5799 no_neighbor_route_map_cmd
,
5800 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5804 "Apply route map to neighbor\n"
5805 "Name of route map\n"
5806 "Apply map to incoming routes\n"
5807 "Apply map to outbound routes\n")
5811 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5812 bgp_node_afi(vty
), bgp_node_safi(vty
),
5813 argv
[idx_in_out
]->arg
);
5816 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5817 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5818 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5819 "Apply route map to neighbor\n"
5820 "Name of route map\n"
5821 "Apply map to incoming routes\n"
5822 "Apply map to outbound routes\n")
5824 /* Set unsuppress-map to the peer. */
5825 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5826 afi_t afi
, safi_t safi
,
5827 const char *name_str
)
5831 struct route_map
*route_map
;
5833 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5835 return CMD_WARNING_CONFIG_FAILED
;
5837 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5838 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
5840 return bgp_vty_return(vty
, ret
);
5843 /* Unset route-map from the peer. */
5844 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5845 afi_t afi
, safi_t safi
)
5850 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5852 return CMD_WARNING_CONFIG_FAILED
;
5854 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5856 return bgp_vty_return(vty
, ret
);
5859 DEFUN (neighbor_unsuppress_map
,
5860 neighbor_unsuppress_map_cmd
,
5861 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5864 "Route-map to selectively unsuppress suppressed routes\n"
5865 "Name of route map\n")
5869 return peer_unsuppress_map_set_vty(
5870 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5871 argv
[idx_word
]->arg
);
5874 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5875 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5876 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5877 "Route-map to selectively unsuppress suppressed routes\n"
5878 "Name of route map\n")
5880 DEFUN (no_neighbor_unsuppress_map
,
5881 no_neighbor_unsuppress_map_cmd
,
5882 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5886 "Route-map to selectively unsuppress suppressed routes\n"
5887 "Name of route map\n")
5890 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5892 bgp_node_safi(vty
));
5895 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5896 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5897 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5898 "Route-map to selectively unsuppress suppressed routes\n"
5899 "Name of route map\n")
5901 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5902 afi_t afi
, safi_t safi
,
5903 const char *num_str
,
5904 const char *threshold_str
, int warning
,
5905 const char *restart_str
)
5913 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5915 return CMD_WARNING_CONFIG_FAILED
;
5917 max
= strtoul(num_str
, NULL
, 10);
5919 threshold
= atoi(threshold_str
);
5921 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5924 restart
= atoi(restart_str
);
5928 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5931 return bgp_vty_return(vty
, ret
);
5934 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5935 afi_t afi
, safi_t safi
)
5940 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5942 return CMD_WARNING_CONFIG_FAILED
;
5944 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5946 return bgp_vty_return(vty
, ret
);
5949 /* Maximum number of prefix configuration. prefix count is different
5950 for each peer configuration. So this configuration can be set for
5951 each peer configuration. */
5952 DEFUN (neighbor_maximum_prefix
,
5953 neighbor_maximum_prefix_cmd
,
5954 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5957 "Maximum number of prefix accept from this peer\n"
5958 "maximum no. of prefix limit\n")
5962 return peer_maximum_prefix_set_vty(
5963 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5964 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5967 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5968 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5969 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5970 "Maximum number of prefix accept from this peer\n"
5971 "maximum no. of prefix limit\n")
5973 DEFUN (neighbor_maximum_prefix_threshold
,
5974 neighbor_maximum_prefix_threshold_cmd
,
5975 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5978 "Maximum number of prefix accept from this peer\n"
5979 "maximum no. of prefix limit\n"
5980 "Threshold value (%) at which to generate a warning msg\n")
5984 int idx_number_2
= 4;
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
, argv
[idx_number_2
]->arg
, 0, NULL
);
5991 neighbor_maximum_prefix_threshold
,
5992 neighbor_maximum_prefix_threshold_hidden_cmd
,
5993 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5994 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5995 "Maximum number of prefix accept from this peer\n"
5996 "maximum no. of prefix limit\n"
5997 "Threshold value (%) at which to generate a warning msg\n")
5999 DEFUN (neighbor_maximum_prefix_warning
,
6000 neighbor_maximum_prefix_warning_cmd
,
6001 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6004 "Maximum number of prefix accept from this peer\n"
6005 "maximum no. of prefix limit\n"
6006 "Only give warning message when limit is exceeded\n")
6010 return peer_maximum_prefix_set_vty(
6011 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6012 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
6016 neighbor_maximum_prefix_warning
,
6017 neighbor_maximum_prefix_warning_hidden_cmd
,
6018 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6019 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6020 "Maximum number of prefix accept from this peer\n"
6021 "maximum no. of prefix limit\n"
6022 "Only give warning message when limit is exceeded\n")
6024 DEFUN (neighbor_maximum_prefix_threshold_warning
,
6025 neighbor_maximum_prefix_threshold_warning_cmd
,
6026 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6029 "Maximum number of prefix accept from this peer\n"
6030 "maximum no. of prefix limit\n"
6031 "Threshold value (%) at which to generate a warning msg\n"
6032 "Only give warning message when limit is exceeded\n")
6036 int idx_number_2
= 4;
6037 return peer_maximum_prefix_set_vty(
6038 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6039 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
6043 neighbor_maximum_prefix_threshold_warning
,
6044 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
6045 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6046 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6047 "Maximum number of prefix accept from this peer\n"
6048 "maximum no. of prefix limit\n"
6049 "Threshold value (%) at which to generate a warning msg\n"
6050 "Only give warning message when limit is exceeded\n")
6052 DEFUN (neighbor_maximum_prefix_restart
,
6053 neighbor_maximum_prefix_restart_cmd
,
6054 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6057 "Maximum number of prefix accept from this peer\n"
6058 "maximum no. of prefix limit\n"
6059 "Restart bgp connection after limit is exceeded\n"
6060 "Restart interval in minutes\n")
6064 int idx_number_2
= 5;
6065 return peer_maximum_prefix_set_vty(
6066 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6067 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
6071 neighbor_maximum_prefix_restart
,
6072 neighbor_maximum_prefix_restart_hidden_cmd
,
6073 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6074 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6075 "Maximum number of prefix accept from this peer\n"
6076 "maximum no. of prefix limit\n"
6077 "Restart bgp connection after limit is exceeded\n"
6078 "Restart interval in minutes\n")
6080 DEFUN (neighbor_maximum_prefix_threshold_restart
,
6081 neighbor_maximum_prefix_threshold_restart_cmd
,
6082 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6085 "Maximum number of prefixes to accept from this peer\n"
6086 "maximum no. of prefix limit\n"
6087 "Threshold value (%) at which to generate a warning msg\n"
6088 "Restart bgp connection after limit is exceeded\n"
6089 "Restart interval in minutes\n")
6093 int idx_number_2
= 4;
6094 int idx_number_3
= 6;
6095 return peer_maximum_prefix_set_vty(
6096 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6097 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
6098 argv
[idx_number_3
]->arg
);
6102 neighbor_maximum_prefix_threshold_restart
,
6103 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
6104 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6105 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6106 "Maximum number of prefixes to accept from this peer\n"
6107 "maximum no. of prefix limit\n"
6108 "Threshold value (%) at which to generate a warning msg\n"
6109 "Restart bgp connection after limit is exceeded\n"
6110 "Restart interval in minutes\n")
6112 DEFUN (no_neighbor_maximum_prefix
,
6113 no_neighbor_maximum_prefix_cmd
,
6114 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6118 "Maximum number of prefixes to accept from this peer\n"
6119 "maximum no. of prefix limit\n"
6120 "Threshold value (%) at which to generate a warning msg\n"
6121 "Restart bgp connection after limit is exceeded\n"
6122 "Restart interval in minutes\n"
6123 "Only give warning message when limit is exceeded\n")
6126 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
6128 bgp_node_safi(vty
));
6132 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
6133 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6134 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6135 "Maximum number of prefixes to accept from this peer\n"
6136 "maximum no. of prefix limit\n"
6137 "Threshold value (%) at which to generate a warning msg\n"
6138 "Restart bgp connection after limit is exceeded\n"
6139 "Restart interval in minutes\n"
6140 "Only give warning message when limit is exceeded\n")
6143 /* "neighbor allowas-in" */
6144 DEFUN (neighbor_allowas_in
,
6145 neighbor_allowas_in_cmd
,
6146 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6149 "Accept as-path with my AS present in it\n"
6150 "Number of occurrences of AS number\n"
6151 "Only accept my AS in the as-path if the route was originated in my AS\n")
6154 int idx_number_origin
= 3;
6160 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6162 return CMD_WARNING_CONFIG_FAILED
;
6164 if (argc
<= idx_number_origin
)
6167 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6170 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6173 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6176 return bgp_vty_return(vty
, ret
);
6180 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6181 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6182 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6183 "Accept as-path with my AS present in it\n"
6184 "Number of occurrences of AS number\n"
6185 "Only accept my AS in the as-path if the route was originated in my AS\n")
6187 DEFUN (no_neighbor_allowas_in
,
6188 no_neighbor_allowas_in_cmd
,
6189 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6193 "allow local ASN appears in aspath attribute\n"
6194 "Number of occurrences of AS number\n"
6195 "Only accept my AS in the as-path if the route was originated in my AS\n")
6201 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6203 return CMD_WARNING_CONFIG_FAILED
;
6205 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6206 bgp_node_safi(vty
));
6208 return bgp_vty_return(vty
, ret
);
6212 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6213 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6214 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6215 "allow local ASN appears in aspath attribute\n"
6216 "Number of occurrences of AS number\n"
6217 "Only accept my AS in the as-path if the route was originated in my AS\n")
6219 DEFUN (neighbor_ttl_security
,
6220 neighbor_ttl_security_cmd
,
6221 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6224 "BGP ttl-security parameters\n"
6225 "Specify the maximum number of hops to the BGP peer\n"
6226 "Number of hops to BGP peer\n")
6233 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6235 return CMD_WARNING_CONFIG_FAILED
;
6237 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6240 * If 'neighbor swpX', then this is for directly connected peers,
6241 * we should not accept a ttl-security hops value greater than 1.
6243 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6245 "%s is directly connected peer, hops cannot exceed 1\n",
6246 argv
[idx_peer
]->arg
);
6247 return CMD_WARNING_CONFIG_FAILED
;
6250 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6253 DEFUN (no_neighbor_ttl_security
,
6254 no_neighbor_ttl_security_cmd
,
6255 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6259 "BGP ttl-security parameters\n"
6260 "Specify the maximum number of hops to the BGP peer\n"
6261 "Number of hops to BGP peer\n")
6266 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6268 return CMD_WARNING_CONFIG_FAILED
;
6270 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6273 DEFUN (neighbor_addpath_tx_all_paths
,
6274 neighbor_addpath_tx_all_paths_cmd
,
6275 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6278 "Use addpath to advertise all paths to a neighbor\n")
6283 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6285 return CMD_WARNING_CONFIG_FAILED
;
6287 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6292 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6293 neighbor_addpath_tx_all_paths_hidden_cmd
,
6294 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6295 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6296 "Use addpath to advertise all paths to a neighbor\n")
6298 DEFUN (no_neighbor_addpath_tx_all_paths
,
6299 no_neighbor_addpath_tx_all_paths_cmd
,
6300 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6304 "Use addpath to advertise all paths to a neighbor\n")
6309 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6311 return CMD_WARNING_CONFIG_FAILED
;
6313 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6314 != BGP_ADDPATH_ALL
) {
6316 "%% Peer not currently configured to transmit all paths.");
6317 return CMD_WARNING_CONFIG_FAILED
;
6320 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6326 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6327 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6328 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6329 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6330 "Use addpath to advertise all paths to a neighbor\n")
6332 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6333 neighbor_addpath_tx_bestpath_per_as_cmd
,
6334 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6337 "Use addpath to advertise the bestpath per each neighboring AS\n")
6342 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6344 return CMD_WARNING_CONFIG_FAILED
;
6346 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6347 BGP_ADDPATH_BEST_PER_AS
);
6352 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6353 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6354 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6355 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6356 "Use addpath to advertise the bestpath per each neighboring AS\n")
6358 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6359 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6360 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6364 "Use addpath to advertise the bestpath per each neighboring AS\n")
6369 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6371 return CMD_WARNING_CONFIG_FAILED
;
6373 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6374 != BGP_ADDPATH_BEST_PER_AS
) {
6376 "%% Peer not currently configured to transmit all best path per as.");
6377 return CMD_WARNING_CONFIG_FAILED
;
6380 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6386 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6387 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6388 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6389 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6390 "Use addpath to advertise the bestpath per each neighboring AS\n")
6393 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
6394 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
6397 "Detect AS loops before sending to neighbor\n")
6401 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
6403 return CMD_WARNING_CONFIG_FAILED
;
6405 peer
->as_path_loop_detection
= true;
6411 no_neighbor_aspath_loop_detection
,
6412 no_neighbor_aspath_loop_detection_cmd
,
6413 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
6417 "Detect AS loops before sending to neighbor\n")
6421 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
6423 return CMD_WARNING_CONFIG_FAILED
;
6425 peer
->as_path_loop_detection
= false;
6430 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6431 struct ecommunity
**list
)
6433 struct ecommunity
*ecom
= NULL
;
6434 struct ecommunity
*ecomadd
;
6436 for (; argc
; --argc
, ++argv
) {
6438 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6439 ECOMMUNITY_ROUTE_TARGET
, 0);
6441 vty_out(vty
, "Malformed community-list value\n");
6443 ecommunity_free(&ecom
);
6444 return CMD_WARNING_CONFIG_FAILED
;
6448 ecommunity_merge(ecom
, ecomadd
);
6449 ecommunity_free(&ecomadd
);
6456 ecommunity_free(&*list
);
6464 * v2vimport is true if we are handling a `import vrf ...` command
6466 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6470 switch (vty
->node
) {
6479 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6484 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6485 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6486 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6487 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6489 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6493 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6494 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6495 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6496 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6498 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6505 DEFPY (af_rd_vpn_export
,
6506 af_rd_vpn_export_cmd
,
6507 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6509 "Specify route distinguisher\n"
6510 "Between current address-family and vpn\n"
6511 "For routes leaked from current address-family to vpn\n"
6512 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6514 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6515 struct prefix_rd prd
;
6521 if (argv_find(argv
, argc
, "no", &idx
))
6525 ret
= str2prefix_rd(rd_str
, &prd
);
6527 vty_out(vty
, "%% Malformed rd\n");
6528 return CMD_WARNING_CONFIG_FAILED
;
6532 afi
= vpn_policy_getafi(vty
, bgp
, false);
6534 return CMD_WARNING_CONFIG_FAILED
;
6537 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6539 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6540 bgp_get_default(), bgp
);
6543 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6544 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6545 BGP_VPN_POLICY_TOVPN_RD_SET
);
6547 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6548 BGP_VPN_POLICY_TOVPN_RD_SET
);
6551 /* post-change: re-export vpn routes */
6552 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6553 bgp_get_default(), bgp
);
6558 ALIAS (af_rd_vpn_export
,
6559 af_no_rd_vpn_export_cmd
,
6562 "Specify route distinguisher\n"
6563 "Between current address-family and vpn\n"
6564 "For routes leaked from current address-family to vpn\n")
6566 DEFPY (af_label_vpn_export
,
6567 af_label_vpn_export_cmd
,
6568 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6570 "label value for VRF\n"
6571 "Between current address-family and vpn\n"
6572 "For routes leaked from current address-family to vpn\n"
6573 "Label Value <0-1048575>\n"
6574 "Automatically assign a label\n")
6576 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6577 mpls_label_t label
= MPLS_LABEL_NONE
;
6582 if (argv_find(argv
, argc
, "no", &idx
))
6585 /* If "no ...", squash trailing parameter */
6591 label
= label_val
; /* parser should force unsigned */
6594 afi
= vpn_policy_getafi(vty
, bgp
, false);
6596 return CMD_WARNING_CONFIG_FAILED
;
6599 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6600 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6605 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6607 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6608 bgp_get_default(), bgp
);
6610 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6611 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6613 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6616 * label has previously been automatically
6617 * assigned by labelpool: release it
6619 * NB if tovpn_label == MPLS_LABEL_NONE it
6620 * means the automatic assignment is in flight
6621 * and therefore the labelpool callback must
6622 * detect that the auto label is not needed.
6625 bgp_lp_release(LP_TYPE_VRF
,
6626 &bgp
->vpn_policy
[afi
],
6627 bgp
->vpn_policy
[afi
].tovpn_label
);
6629 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6630 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6633 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6635 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6636 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6637 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6638 vpn_leak_label_callback
);
6641 /* post-change: re-export vpn routes */
6642 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6643 bgp_get_default(), bgp
);
6648 ALIAS (af_label_vpn_export
,
6649 af_no_label_vpn_export_cmd
,
6650 "no label vpn export",
6652 "label value for VRF\n"
6653 "Between current address-family and vpn\n"
6654 "For routes leaked from current address-family to vpn\n")
6656 DEFPY (af_nexthop_vpn_export
,
6657 af_nexthop_vpn_export_cmd
,
6658 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6660 "Specify next hop to use for VRF advertised prefixes\n"
6661 "Between current address-family and vpn\n"
6662 "For routes leaked from current address-family to vpn\n"
6666 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6672 if (argv_find(argv
, argc
, "no", &idx
))
6676 if (!sockunion2hostprefix(nexthop_str
, &p
))
6677 return CMD_WARNING_CONFIG_FAILED
;
6680 afi
= vpn_policy_getafi(vty
, bgp
, false);
6682 return CMD_WARNING_CONFIG_FAILED
;
6685 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6687 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6688 bgp_get_default(), bgp
);
6691 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6692 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6693 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6695 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6696 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6699 /* post-change: re-export vpn routes */
6700 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6701 bgp_get_default(), bgp
);
6706 ALIAS (af_nexthop_vpn_export
,
6707 af_no_nexthop_vpn_export_cmd
,
6708 "no nexthop vpn export",
6710 "Specify next hop to use for VRF advertised prefixes\n"
6711 "Between current address-family and vpn\n"
6712 "For routes leaked from current address-family to vpn\n")
6714 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6716 if (!strcmp(dstr
, "import")) {
6717 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6718 } else if (!strcmp(dstr
, "export")) {
6719 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6720 } else if (!strcmp(dstr
, "both")) {
6721 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6722 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6724 vty_out(vty
, "%% direction parse error\n");
6725 return CMD_WARNING_CONFIG_FAILED
;
6730 DEFPY (af_rt_vpn_imexport
,
6731 af_rt_vpn_imexport_cmd
,
6732 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6734 "Specify route target list\n"
6735 "Specify route target list\n"
6736 "Between current address-family and vpn\n"
6737 "For routes leaked from vpn to current address-family: match any\n"
6738 "For routes leaked from current address-family to vpn: set\n"
6739 "both import: match any and export: set\n"
6740 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6742 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6744 struct ecommunity
*ecom
= NULL
;
6745 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6746 vpn_policy_direction_t dir
;
6751 if (argv_find(argv
, argc
, "no", &idx
))
6754 afi
= vpn_policy_getafi(vty
, bgp
, false);
6756 return CMD_WARNING_CONFIG_FAILED
;
6758 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6759 if (ret
!= CMD_SUCCESS
)
6763 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6764 vty_out(vty
, "%% Missing RTLIST\n");
6765 return CMD_WARNING_CONFIG_FAILED
;
6767 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6768 if (ret
!= CMD_SUCCESS
) {
6773 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6777 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6780 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6782 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6783 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6784 ecommunity_dup(ecom
);
6786 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6788 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6789 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6792 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6796 ecommunity_free(&ecom
);
6801 ALIAS (af_rt_vpn_imexport
,
6802 af_no_rt_vpn_imexport_cmd
,
6803 "no <rt|route-target> vpn <import|export|both>$direction_str",
6805 "Specify route target list\n"
6806 "Specify route target list\n"
6807 "Between current address-family and vpn\n"
6808 "For routes leaked from vpn to current address-family\n"
6809 "For routes leaked from current address-family to vpn\n"
6810 "both import and export\n")
6812 DEFPY (af_route_map_vpn_imexport
,
6813 af_route_map_vpn_imexport_cmd
,
6814 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6815 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6817 "Specify route map\n"
6818 "Between current address-family and vpn\n"
6819 "For routes leaked from vpn to current address-family\n"
6820 "For routes leaked from current address-family to vpn\n"
6821 "name of route-map\n")
6823 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6825 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6826 vpn_policy_direction_t dir
;
6831 if (argv_find(argv
, argc
, "no", &idx
))
6834 afi
= vpn_policy_getafi(vty
, bgp
, false);
6836 return CMD_WARNING_CONFIG_FAILED
;
6838 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6839 if (ret
!= CMD_SUCCESS
)
6842 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6846 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6849 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6850 XFREE(MTYPE_ROUTE_MAP_NAME
,
6851 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6852 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6853 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6854 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6855 route_map_lookup_warn_noexist(vty
, rmap_str
);
6856 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6859 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6860 XFREE(MTYPE_ROUTE_MAP_NAME
,
6861 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6862 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6863 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6866 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6872 ALIAS (af_route_map_vpn_imexport
,
6873 af_no_route_map_vpn_imexport_cmd
,
6874 "no route-map vpn <import|export>$direction_str",
6876 "Specify route map\n"
6877 "Between current address-family and vpn\n"
6878 "For routes leaked from vpn to current address-family\n"
6879 "For routes leaked from current address-family to vpn\n")
6881 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6882 "[no] import vrf route-map RMAP$rmap_str",
6884 "Import routes from another VRF\n"
6885 "Vrf routes being filtered\n"
6886 "Specify route map\n"
6887 "name of route-map\n")
6889 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6890 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6894 struct bgp
*bgp_default
;
6896 if (argv_find(argv
, argc
, "no", &idx
))
6899 afi
= vpn_policy_getafi(vty
, bgp
, true);
6901 return CMD_WARNING_CONFIG_FAILED
;
6903 bgp_default
= bgp_get_default();
6908 /* Auto-create assuming the same AS */
6909 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6910 BGP_INSTANCE_TYPE_DEFAULT
);
6914 "VRF default is not configured as a bgp instance\n");
6919 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6922 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6923 XFREE(MTYPE_ROUTE_MAP_NAME
,
6924 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6925 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6926 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6927 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6928 route_map_lookup_warn_noexist(vty
, rmap_str
);
6929 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6932 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6933 XFREE(MTYPE_ROUTE_MAP_NAME
,
6934 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6935 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6936 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6939 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6944 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6945 "no import vrf route-map",
6947 "Import routes from another VRF\n"
6948 "Vrf routes being filtered\n"
6949 "Specify route map\n")
6951 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
6952 "[no] import vrf VIEWVRFNAME$import_name",
6954 "Import routes from another VRF\n"
6955 "VRF to import from\n"
6956 "The name of the VRF\n")
6958 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6959 struct listnode
*node
;
6960 struct bgp
*vrf_bgp
, *bgp_default
;
6963 bool remove
= false;
6966 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
6970 if (import_name
== NULL
) {
6971 vty_out(vty
, "%% Missing import name\n");
6975 if (argv_find(argv
, argc
, "no", &idx
))
6978 afi
= vpn_policy_getafi(vty
, bgp
, true);
6980 return CMD_WARNING_CONFIG_FAILED
;
6982 safi
= bgp_node_safi(vty
);
6984 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
6985 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
6986 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
6987 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
6988 remove
? "unimport" : "import", import_name
);
6992 bgp_default
= bgp_get_default();
6994 /* Auto-create assuming the same AS */
6995 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6996 BGP_INSTANCE_TYPE_DEFAULT
);
7000 "VRF default is not configured as a bgp instance\n");
7005 vrf_bgp
= bgp_lookup_by_name(import_name
);
7007 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
7008 vrf_bgp
= bgp_default
;
7010 /* Auto-create assuming the same AS */
7011 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
7015 "VRF %s is not configured as a bgp instance\n",
7022 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
7024 /* Already importing from "import_vrf"? */
7025 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
7027 if (strcmp(vname
, import_name
) == 0)
7031 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
7037 /* This command is valid only in a bgp vrf instance or the default instance */
7038 DEFPY (bgp_imexport_vpn
,
7039 bgp_imexport_vpn_cmd
,
7040 "[no] <import|export>$direction_str vpn",
7042 "Import routes to this address-family\n"
7043 "Export routes from this address-family\n"
7044 "to/from default instance VPN RIB\n")
7046 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7053 vpn_policy_direction_t dir
;
7055 if (argv_find(argv
, argc
, "no", &idx
))
7058 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
7059 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
7061 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
7062 return CMD_WARNING_CONFIG_FAILED
;
7065 afi
= bgp_node_afi(vty
);
7066 safi
= bgp_node_safi(vty
);
7067 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
7068 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
7069 return CMD_WARNING_CONFIG_FAILED
;
7072 if (!strcmp(direction_str
, "import")) {
7073 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
7074 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
7075 } else if (!strcmp(direction_str
, "export")) {
7076 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
7077 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
7079 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
7080 return CMD_WARNING_CONFIG_FAILED
;
7083 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7086 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7087 if (!previous_state
) {
7088 /* trigger export current vrf */
7089 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7092 if (previous_state
) {
7093 /* trigger un-export current vrf */
7094 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7096 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7102 DEFPY (af_routetarget_import
,
7103 af_routetarget_import_cmd
,
7104 "[no] <rt|route-target> redirect import RTLIST...",
7106 "Specify route target list\n"
7107 "Specify route target list\n"
7108 "Flow-spec redirect type route target\n"
7109 "Import routes to this address-family\n"
7110 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
7112 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7114 struct ecommunity
*ecom
= NULL
;
7119 if (argv_find(argv
, argc
, "no", &idx
))
7122 afi
= vpn_policy_getafi(vty
, bgp
, false);
7124 return CMD_WARNING_CONFIG_FAILED
;
7127 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7128 vty_out(vty
, "%% Missing RTLIST\n");
7129 return CMD_WARNING_CONFIG_FAILED
;
7131 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7132 if (ret
!= CMD_SUCCESS
)
7137 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7138 ecommunity_free(&bgp
->vpn_policy
[afi
]
7139 .import_redirect_rtlist
);
7140 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
7141 ecommunity_dup(ecom
);
7143 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7144 ecommunity_free(&bgp
->vpn_policy
[afi
]
7145 .import_redirect_rtlist
);
7146 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
7150 ecommunity_free(&ecom
);
7155 DEFUN_NOSH (address_family_ipv4_safi
,
7156 address_family_ipv4_safi_cmd
,
7157 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7158 "Enter Address Family command mode\n"
7160 BGP_SAFI_WITH_LABEL_HELP_STR
)
7164 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7165 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7166 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7167 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7168 && safi
!= SAFI_EVPN
) {
7170 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7171 return CMD_WARNING_CONFIG_FAILED
;
7173 vty
->node
= bgp_node_type(AFI_IP
, safi
);
7175 vty
->node
= BGP_IPV4_NODE
;
7180 DEFUN_NOSH (address_family_ipv6_safi
,
7181 address_family_ipv6_safi_cmd
,
7182 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7183 "Enter Address Family command mode\n"
7185 BGP_SAFI_WITH_LABEL_HELP_STR
)
7188 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7189 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7190 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7191 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7192 && safi
!= SAFI_EVPN
) {
7194 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7195 return CMD_WARNING_CONFIG_FAILED
;
7197 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
7199 vty
->node
= BGP_IPV6_NODE
;
7204 #ifdef KEEP_OLD_VPN_COMMANDS
7205 DEFUN_NOSH (address_family_vpnv4
,
7206 address_family_vpnv4_cmd
,
7207 "address-family vpnv4 [unicast]",
7208 "Enter Address Family command mode\n"
7210 "Address Family modifier\n")
7212 vty
->node
= BGP_VPNV4_NODE
;
7216 DEFUN_NOSH (address_family_vpnv6
,
7217 address_family_vpnv6_cmd
,
7218 "address-family vpnv6 [unicast]",
7219 "Enter Address Family command mode\n"
7221 "Address Family modifier\n")
7223 vty
->node
= BGP_VPNV6_NODE
;
7226 #endif /* KEEP_OLD_VPN_COMMANDS */
7228 DEFUN_NOSH (address_family_evpn
,
7229 address_family_evpn_cmd
,
7230 "address-family l2vpn evpn",
7231 "Enter Address Family command mode\n"
7233 "Address Family modifier\n")
7235 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7236 vty
->node
= BGP_EVPN_NODE
;
7240 DEFUN_NOSH (exit_address_family
,
7241 exit_address_family_cmd
,
7242 "exit-address-family",
7243 "Exit from Address Family configuration mode\n")
7245 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7246 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7247 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7248 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7249 || vty
->node
== BGP_EVPN_NODE
7250 || vty
->node
== BGP_FLOWSPECV4_NODE
7251 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7252 vty
->node
= BGP_NODE
;
7256 /* Recalculate bestpath and re-advertise a prefix */
7257 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7258 const char *ip_str
, afi_t afi
, safi_t safi
,
7259 struct prefix_rd
*prd
)
7262 struct prefix match
;
7263 struct bgp_node
*rn
;
7264 struct bgp_node
*rm
;
7266 struct bgp_table
*table
;
7267 struct bgp_table
*rib
;
7269 /* BGP structure lookup. */
7271 bgp
= bgp_lookup_by_name(view_name
);
7273 vty_out(vty
, "%% Can't find BGP instance %s\n",
7278 bgp
= bgp_get_default();
7280 vty_out(vty
, "%% No BGP process is configured\n");
7285 /* Check IP address argument. */
7286 ret
= str2prefix(ip_str
, &match
);
7288 vty_out(vty
, "%% address is malformed\n");
7292 match
.family
= afi2family(afi
);
7293 rib
= bgp
->rib
[afi
][safi
];
7295 if (safi
== SAFI_MPLS_VPN
) {
7296 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7297 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7300 table
= bgp_node_get_bgp_table_info(rn
);
7301 if (table
!= NULL
) {
7303 if ((rm
= bgp_node_match(table
, &match
))
7306 == match
.prefixlen
) {
7308 BGP_NODE_USER_CLEAR
);
7309 bgp_process(bgp
, rm
, afi
, safi
);
7311 bgp_unlock_node(rm
);
7316 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7317 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7318 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7319 bgp_process(bgp
, rn
, afi
, safi
);
7321 bgp_unlock_node(rn
);
7328 /* one clear bgp command to rule them all */
7329 DEFUN (clear_ip_bgp_all
,
7330 clear_ip_bgp_all_cmd
,
7331 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D$neighbor|X:X::X:X$neighbor|WORD$neighbor|(1-4294967295)|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out>]",
7335 BGP_INSTANCE_HELP_STR
7338 BGP_SAFI_WITH_LABEL_HELP_STR
7339 "Address Family modifier\n"
7341 "BGP IPv4 neighbor to clear\n"
7342 "BGP IPv6 neighbor to clear\n"
7343 "BGP neighbor on interface to clear\n"
7344 "Clear peers with the AS number\n"
7345 "Clear all external peers\n"
7346 "Clear all members of peer-group\n"
7347 "BGP peer-group name\n"
7352 "Push out prefix-list ORF and do inbound soft reconfig\n"
7357 afi_t afi
= AFI_UNSPEC
;
7358 safi_t safi
= SAFI_UNSPEC
;
7359 enum clear_sort clr_sort
= clear_peer
;
7360 enum bgp_clear_type clr_type
;
7361 char *clr_arg
= NULL
;
7365 /* clear [ip] bgp */
7366 if (argv_find(argv
, argc
, "ip", &idx
))
7369 /* [<vrf> VIEWVRFNAME] */
7370 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7371 vrf
= argv
[idx
+ 1]->arg
;
7373 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7375 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7376 /* [<view> VIEWVRFNAME] */
7377 vrf
= argv
[idx
+ 1]->arg
;
7380 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7381 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7382 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7384 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
7385 if (argv_find(argv
, argc
, "*", &idx
)) {
7386 clr_sort
= clear_all
;
7387 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7388 clr_sort
= clear_peer
;
7389 clr_arg
= argv
[idx
]->arg
;
7390 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7391 clr_sort
= clear_peer
;
7392 clr_arg
= argv
[idx
]->arg
;
7393 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7394 clr_sort
= clear_group
;
7396 clr_arg
= argv
[idx
]->arg
;
7397 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
7398 clr_sort
= clear_peer
;
7399 clr_arg
= argv
[idx
]->arg
;
7400 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7401 clr_sort
= clear_peer
;
7402 clr_arg
= argv
[idx
]->arg
;
7403 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7404 clr_sort
= clear_as
;
7405 clr_arg
= argv
[idx
]->arg
;
7406 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7407 clr_sort
= clear_external
;
7410 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7411 if (argv_find(argv
, argc
, "soft", &idx
)) {
7412 if (argv_find(argv
, argc
, "in", &idx
)
7413 || argv_find(argv
, argc
, "out", &idx
))
7414 clr_type
= strmatch(argv
[idx
]->text
, "in")
7416 : BGP_CLEAR_SOFT_OUT
;
7418 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7419 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7420 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7421 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7422 : BGP_CLEAR_SOFT_IN
;
7423 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7424 clr_type
= BGP_CLEAR_SOFT_OUT
;
7426 clr_type
= BGP_CLEAR_SOFT_NONE
;
7428 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7431 DEFUN (clear_ip_bgp_prefix
,
7432 clear_ip_bgp_prefix_cmd
,
7433 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7437 BGP_INSTANCE_HELP_STR
7438 "Clear bestpath and re-advertise\n"
7442 char *prefix
= NULL
;
7446 /* [<view|vrf> VIEWVRFNAME] */
7447 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7448 vrf
= argv
[idx
+ 1]->arg
;
7450 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7452 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7453 /* [<view> VIEWVRFNAME] */
7454 vrf
= argv
[idx
+ 1]->arg
;
7458 prefix
= argv
[argc
- 1]->arg
;
7460 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7463 DEFUN (clear_bgp_ipv6_safi_prefix
,
7464 clear_bgp_ipv6_safi_prefix_cmd
,
7465 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7471 "Clear bestpath and re-advertise\n"
7475 int idx_ipv6_prefix
= 0;
7476 safi_t safi
= SAFI_UNICAST
;
7477 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7478 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7480 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7481 return bgp_clear_prefix(
7482 vty
, NULL
, prefix
, AFI_IP6
,
7486 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7487 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7488 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7492 BGP_INSTANCE_HELP_STR
7495 "Clear bestpath and re-advertise\n"
7499 int idx_vrfview
= 0;
7500 int idx_ipv6_prefix
= 0;
7501 safi_t safi
= SAFI_UNICAST
;
7502 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7503 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7504 char *vrfview
= NULL
;
7506 /* [<view|vrf> VIEWVRFNAME] */
7507 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
7508 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7509 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
7511 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
7512 /* [<view> VIEWVRFNAME] */
7513 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7515 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7517 return bgp_clear_prefix(
7518 vty
, vrfview
, prefix
,
7519 AFI_IP6
, safi
, NULL
);
7522 DEFUN (show_bgp_views
,
7524 "show [ip] bgp views",
7528 "Show the defined BGP views\n")
7530 struct list
*inst
= bm
->bgp
;
7531 struct listnode
*node
;
7534 vty_out(vty
, "Defined BGP views:\n");
7535 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7537 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7539 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7546 DEFUN (show_bgp_vrfs
,
7548 "show [ip] bgp vrfs [json]",
7555 char buf
[ETHER_ADDR_STRLEN
];
7556 struct list
*inst
= bm
->bgp
;
7557 struct listnode
*node
;
7559 bool uj
= use_json(argc
, argv
);
7560 json_object
*json
= NULL
;
7561 json_object
*json_vrfs
= NULL
;
7565 json
= json_object_new_object();
7566 json_vrfs
= json_object_new_object();
7569 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7570 const char *name
, *type
;
7572 struct listnode
*node2
, *nnode2
;
7573 int peers_cfg
, peers_estb
;
7574 json_object
*json_vrf
= NULL
;
7577 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7581 if (!uj
&& count
== 1) {
7583 "%4s %-5s %-16s %9s %10s %-37s\n",
7584 "Type", "Id", "routerId", "#PeersVfg",
7585 "#PeersEstb", "Name");
7586 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
7587 "L3-VNI", "RouterMAC", "Interface");
7590 peers_cfg
= peers_estb
= 0;
7592 json_vrf
= json_object_new_object();
7595 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
7596 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7599 if (peer
->status
== Established
)
7603 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7604 name
= VRF_DEFAULT_NAME
;
7613 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7615 : (int64_t)bgp
->vrf_id
;
7616 json_object_string_add(json_vrf
, "type", type
);
7617 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7618 json_object_string_add(json_vrf
, "routerId",
7619 inet_ntoa(bgp
->router_id
));
7620 json_object_int_add(json_vrf
, "numConfiguredPeers",
7622 json_object_int_add(json_vrf
, "numEstablishedPeers",
7625 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7626 json_object_string_add(
7628 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7629 json_object_string_add(json_vrf
, "interface",
7630 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
7632 json_object_object_add(json_vrfs
, name
, json_vrf
);
7635 "%4s %-5d %-16s %-9u %-10u %-37s\n",
7637 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7639 inet_ntoa(bgp
->router_id
), peers_cfg
,
7641 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
7643 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
7644 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
7650 json_object_object_add(json
, "vrfs", json_vrfs
);
7652 json_object_int_add(json
, "totalVrfs", count
);
7654 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7655 json
, JSON_C_TO_STRING_PRETTY
));
7656 json_object_free(json
);
7660 "\nTotal number of VRFs (including default): %d\n",
7667 DEFUN (show_bgp_mac_hash
,
7668 show_bgp_mac_hash_cmd
,
7669 "show bgp mac hash",
7673 "Mac Address database\n")
7675 bgp_mac_dump_table(vty
);
7680 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
7682 struct vty
*vty
= (struct vty
*)args
;
7683 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
7685 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7689 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7691 vty_out(vty
, "self nexthop database:\n");
7692 bgp_nexthop_show_address_hash(vty
, bgp
);
7694 vty_out(vty
, "Tunnel-ip database:\n");
7695 hash_iterate(bgp
->tip_hash
,
7696 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
7700 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7701 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7702 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7703 "martian next-hops\n"
7704 "martian next-hop database\n")
7706 struct bgp
*bgp
= NULL
;
7710 /* [<vrf> VIEWVRFNAME] */
7711 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7712 name
= argv
[idx
+ 1]->arg
;
7713 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7715 } else if (argv_find(argv
, argc
, "view", &idx
))
7716 /* [<view> VIEWVRFNAME] */
7717 name
= argv
[idx
+ 1]->arg
;
7719 bgp
= bgp_lookup_by_name(name
);
7721 bgp
= bgp_get_default();
7724 vty_out(vty
, "%% No BGP process is configured\n");
7727 bgp_show_martian_nexthops(vty
, bgp
);
7732 DEFUN (show_bgp_memory
,
7733 show_bgp_memory_cmd
,
7734 "show [ip] bgp memory",
7738 "Global BGP memory statistics\n")
7740 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7741 unsigned long count
;
7743 /* RIB related usage stats */
7744 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7745 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7746 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7747 count
* sizeof(struct bgp_node
)));
7749 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7750 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7751 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7752 count
* sizeof(struct bgp_path_info
)));
7753 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7754 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7757 memstrbuf
, sizeof(memstrbuf
),
7758 count
* sizeof(struct bgp_path_info_extra
)));
7760 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7761 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7762 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7763 count
* sizeof(struct bgp_static
)));
7765 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7766 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7767 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7768 count
* sizeof(struct bpacket
)));
7771 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7772 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7773 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7774 count
* sizeof(struct bgp_adj_in
)));
7775 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7776 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7777 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7778 count
* sizeof(struct bgp_adj_out
)));
7780 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7781 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7783 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7784 count
* sizeof(struct bgp_nexthop_cache
)));
7786 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7787 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7789 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7790 count
* sizeof(struct bgp_damp_info
)));
7793 count
= attr_count();
7794 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7795 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7796 count
* sizeof(struct attr
)));
7798 if ((count
= attr_unknown_count()))
7799 vty_out(vty
, "%ld unknown attributes\n", count
);
7801 /* AS_PATH attributes */
7802 count
= aspath_count();
7803 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7804 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7805 count
* sizeof(struct aspath
)));
7807 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7808 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7809 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7810 count
* sizeof(struct assegment
)));
7812 /* Other attributes */
7813 if ((count
= community_count()))
7814 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7815 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7816 count
* sizeof(struct community
)));
7817 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7818 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7819 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7820 count
* sizeof(struct ecommunity
)));
7821 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7823 "%ld BGP large-community entries, using %s of memory\n",
7824 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7825 count
* sizeof(struct lcommunity
)));
7827 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7828 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7829 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7830 count
* sizeof(struct cluster_list
)));
7832 /* Peer related usage */
7833 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7834 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7835 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7836 count
* sizeof(struct peer
)));
7838 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7839 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7840 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7841 count
* sizeof(struct peer_group
)));
7844 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7845 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7846 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7847 count
* sizeof(regex_t
)));
7851 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7853 json_object
*bestpath
= json_object_new_object();
7855 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7856 json_object_string_add(bestpath
, "asPath", "ignore");
7858 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7859 json_object_string_add(bestpath
, "asPath", "confed");
7861 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7862 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7863 json_object_string_add(bestpath
, "multiPathRelax",
7866 json_object_string_add(bestpath
, "multiPathRelax",
7869 json_object_string_add(bestpath
, "multiPathRelax", "false");
7871 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7872 json_object_string_add(bestpath
, "compareRouterId", "true");
7873 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7874 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7875 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7876 json_object_string_add(bestpath
, "med", "confed");
7877 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7878 json_object_string_add(bestpath
, "med",
7879 "missing-as-worst");
7881 json_object_string_add(bestpath
, "med", "true");
7884 json_object_object_add(json
, "bestPath", bestpath
);
7887 /* Print the error code/subcode for why the peer is down */
7888 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
7889 json_object
*json_peer
, bool use_json
)
7891 const char *code_str
;
7892 const char *subcode_str
;
7895 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
7896 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
7897 char errorcodesubcode_hexstr
[5];
7898 char errorcodesubcode_str
[256];
7900 code_str
= bgp_notify_code_str(peer
->notify
.code
);
7901 subcode_str
= bgp_notify_subcode_str(
7903 peer
->notify
.subcode
);
7905 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
7906 peer
->notify
.code
, peer
->notify
.subcode
);
7907 json_object_string_add(json_peer
,
7908 "lastErrorCodeSubcode",
7909 errorcodesubcode_hexstr
);
7910 snprintf(errorcodesubcode_str
, 255, "%s%s",
7911 code_str
, subcode_str
);
7912 json_object_string_add(json_peer
,
7913 "lastNotificationReason",
7914 errorcodesubcode_str
);
7915 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
7916 && peer
->notify
.code
== BGP_NOTIFY_CEASE
7917 && (peer
->notify
.subcode
7918 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
7919 || peer
->notify
.subcode
7920 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
7921 && peer
->notify
.length
) {
7923 const char *msg_str
;
7925 msg_str
= bgp_notify_admin_message(
7926 msgbuf
, sizeof(msgbuf
),
7927 (uint8_t *)peer
->notify
.data
,
7928 peer
->notify
.length
);
7930 json_object_string_add(
7932 "lastShutdownDescription",
7937 json_object_string_add(json_peer
, "lastResetDueTo",
7938 peer_down_str
[(int)peer
->last_reset
]);
7939 json_object_int_add(json_peer
, "lastResetCode",
7942 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
7943 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
7944 code_str
= bgp_notify_code_str(peer
->notify
.code
);
7946 bgp_notify_subcode_str(peer
->notify
.code
,
7947 peer
->notify
.subcode
);
7948 vty_out(vty
, " Notification %s (%s%s)\n",
7949 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
7952 code_str
, subcode_str
);
7954 vty_out(vty
, " %s\n",
7955 peer_down_str
[(int)peer
->last_reset
]);
7960 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
7963 return ((peer
->status
!= Established
) ||
7964 !peer
->afc_recv
[afi
][safi
]);
7967 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
7968 struct peer
*peer
, json_object
*json_peer
,
7969 int max_neighbor_width
, bool use_json
)
7971 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7975 if (peer_dynamic_neighbor(peer
))
7976 json_object_boolean_true_add(json_peer
,
7979 json_object_string_add(json_peer
, "hostname",
7982 if (peer
->domainname
)
7983 json_object_string_add(json_peer
, "domainname",
7985 json_object_int_add(json_peer
, "connectionsEstablished",
7987 json_object_int_add(json_peer
, "connectionsDropped",
7989 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
7990 use_json
, json_peer
);
7991 if (peer
->status
== Established
)
7992 json_object_string_add(json_peer
, "lastResetDueTo",
7993 "AFI/SAFI Not Negotiated");
7995 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
7998 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
8000 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8001 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8002 peer
->hostname
, peer
->host
);
8004 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8006 /* pad the neighbor column with spaces */
8007 if (len
< max_neighbor_width
)
8008 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8010 vty_out(vty
, "%7d %7d %8s", peer
->established
,
8012 peer_uptime(peer
->uptime
, timebuf
,
8013 BGP_UPTIME_LEN
, 0, NULL
));
8014 if (peer
->status
== Established
)
8015 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
8017 bgp_show_peer_reset(vty
, peer
, NULL
,
8023 /* Show BGP peer's summary information. */
8024 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
8025 bool show_failed
, bool use_json
)
8028 struct listnode
*node
, *nnode
;
8029 unsigned int count
= 0, dn_count
= 0;
8030 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
8031 char neighbor_buf
[VTY_BUFSIZ
];
8032 int neighbor_col_default_width
= 16;
8033 int len
, failed_count
= 0;
8034 int max_neighbor_width
= 0;
8036 json_object
*json
= NULL
;
8037 json_object
*json_peer
= NULL
;
8038 json_object
*json_peers
= NULL
;
8039 struct peer_af
*paf
;
8041 /* labeled-unicast routes are installed in the unicast table so in order
8043 * display the correct PfxRcd value we must look at SAFI_UNICAST
8046 if (safi
== SAFI_LABELED_UNICAST
)
8047 pfx_rcd_safi
= SAFI_UNICAST
;
8049 pfx_rcd_safi
= safi
;
8052 json
= json_object_new_object();
8053 json_peers
= json_object_new_object();
8054 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8055 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8058 if (peer
->afc
[afi
][safi
]) {
8059 /* See if we have at least a single failed peer */
8060 if (bgp_has_peer_failed(peer
, afi
, safi
))
8064 if (peer_dynamic_neighbor(peer
))
8069 /* Loop over all neighbors that will be displayed to determine
8071 * characters are needed for the Neighbor column
8073 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8074 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8077 if (peer
->afc
[afi
][safi
]) {
8078 memset(dn_flag
, '\0', sizeof(dn_flag
));
8079 if (peer_dynamic_neighbor(peer
))
8083 && bgp_flag_check(bgp
,
8084 BGP_FLAG_SHOW_HOSTNAME
))
8085 sprintf(neighbor_buf
, "%s%s(%s) ",
8086 dn_flag
, peer
->hostname
,
8089 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
8092 len
= strlen(neighbor_buf
);
8094 if (len
> max_neighbor_width
)
8095 max_neighbor_width
= len
;
8097 /* See if we have at least a single failed peer */
8098 if (bgp_has_peer_failed(peer
, afi
, safi
))
8104 /* Originally we displayed the Neighbor column as 16
8105 * characters wide so make that the default
8107 if (max_neighbor_width
< neighbor_col_default_width
)
8108 max_neighbor_width
= neighbor_col_default_width
;
8111 if (show_failed
&& !failed_count
) {
8113 json_object_int_add(json
, "failedPeersCount", 0);
8114 json_object_int_add(json
, "dynamicPeers", dn_count
);
8115 json_object_int_add(json
, "totalPeers", count
);
8117 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8118 json
, JSON_C_TO_STRING_PRETTY
));
8119 json_object_free(json
);
8121 vty_out(vty
, "%% No failed BGP neighbors found\n");
8122 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8127 count
= 0; /* Reset the value as its used again */
8128 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8129 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8132 if (!peer
->afc
[afi
][safi
])
8137 char memstrbuf
[MTYPE_MEMSTR_LEN
];
8140 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
8142 : (int64_t)bgp
->vrf_id
;
8144 /* Usage summary and header */
8146 json_object_string_add(
8148 inet_ntoa(bgp
->router_id
));
8149 json_object_int_add(json
, "as", bgp
->as
);
8150 json_object_int_add(json
, "vrfId", vrf_id_ui
);
8151 json_object_string_add(
8154 == BGP_INSTANCE_TYPE_DEFAULT
)
8159 "BGP router identifier %s, local AS number %u vrf-id %d",
8160 inet_ntoa(bgp
->router_id
), bgp
->as
,
8161 bgp
->vrf_id
== VRF_UNKNOWN
8163 : (int)bgp
->vrf_id
);
8167 if (bgp_update_delay_configured(bgp
)) {
8169 json_object_int_add(
8170 json
, "updateDelayLimit",
8171 bgp
->v_update_delay
);
8173 if (bgp
->v_update_delay
8174 != bgp
->v_establish_wait
)
8175 json_object_int_add(
8177 "updateDelayEstablishWait",
8178 bgp
->v_establish_wait
);
8180 if (bgp_update_delay_active(bgp
)) {
8181 json_object_string_add(
8183 "updateDelayFirstNeighbor",
8184 bgp
->update_delay_begin_time
);
8185 json_object_boolean_true_add(
8187 "updateDelayInProgress");
8189 if (bgp
->update_delay_over
) {
8190 json_object_string_add(
8192 "updateDelayFirstNeighbor",
8193 bgp
->update_delay_begin_time
);
8194 json_object_string_add(
8196 "updateDelayBestpathResumed",
8197 bgp
->update_delay_end_time
);
8198 json_object_string_add(
8200 "updateDelayZebraUpdateResume",
8201 bgp
->update_delay_zebra_resume_time
);
8202 json_object_string_add(
8204 "updateDelayPeerUpdateResume",
8205 bgp
->update_delay_peers_resume_time
);
8210 "Read-only mode update-delay limit: %d seconds\n",
8211 bgp
->v_update_delay
);
8212 if (bgp
->v_update_delay
8213 != bgp
->v_establish_wait
)
8215 " Establish wait: %d seconds\n",
8216 bgp
->v_establish_wait
);
8218 if (bgp_update_delay_active(bgp
)) {
8220 " First neighbor established: %s\n",
8221 bgp
->update_delay_begin_time
);
8223 " Delay in progress\n");
8225 if (bgp
->update_delay_over
) {
8227 " First neighbor established: %s\n",
8228 bgp
->update_delay_begin_time
);
8230 " Best-paths resumed: %s\n",
8231 bgp
->update_delay_end_time
);
8233 " zebra update resumed: %s\n",
8234 bgp
->update_delay_zebra_resume_time
);
8236 " peers update resumed: %s\n",
8237 bgp
->update_delay_peers_resume_time
);
8244 if (bgp_maxmed_onstartup_configured(bgp
)
8245 && bgp
->maxmed_active
)
8246 json_object_boolean_true_add(
8247 json
, "maxMedOnStartup");
8248 if (bgp
->v_maxmed_admin
)
8249 json_object_boolean_true_add(
8250 json
, "maxMedAdministrative");
8252 json_object_int_add(
8253 json
, "tableVersion",
8254 bgp_table_version(bgp
->rib
[afi
][safi
]));
8256 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8257 json_object_int_add(json
, "ribCount", ents
);
8258 json_object_int_add(
8260 ents
* sizeof(struct bgp_node
));
8262 ents
= bgp
->af_peer_count
[afi
][safi
];
8263 json_object_int_add(json
, "peerCount", ents
);
8264 json_object_int_add(json
, "peerMemory",
8265 ents
* sizeof(struct peer
));
8267 if ((ents
= listcount(bgp
->group
))) {
8268 json_object_int_add(
8269 json
, "peerGroupCount", ents
);
8270 json_object_int_add(
8271 json
, "peerGroupMemory",
8272 ents
* sizeof(struct
8276 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8277 BGP_CONFIG_DAMPENING
))
8278 json_object_boolean_true_add(
8279 json
, "dampeningEnabled");
8281 if (bgp_maxmed_onstartup_configured(bgp
)
8282 && bgp
->maxmed_active
)
8284 "Max-med on-startup active\n");
8285 if (bgp
->v_maxmed_admin
)
8287 "Max-med administrative active\n");
8289 vty_out(vty
, "BGP table version %" PRIu64
"\n",
8290 bgp_table_version(bgp
->rib
[afi
][safi
]));
8292 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8294 "RIB entries %ld, using %s of memory\n",
8296 mtype_memstr(memstrbuf
,
8298 ents
* sizeof(struct
8301 /* Peer related usage */
8302 ents
= bgp
->af_peer_count
[afi
][safi
];
8303 vty_out(vty
, "Peers %ld, using %s of memory\n",
8306 memstrbuf
, sizeof(memstrbuf
),
8307 ents
* sizeof(struct peer
)));
8309 if ((ents
= listcount(bgp
->group
)))
8311 "Peer groups %ld, using %s of memory\n",
8316 ents
* sizeof(struct
8319 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8320 BGP_CONFIG_DAMPENING
))
8321 vty_out(vty
, "Dampening enabled.\n");
8324 /* Subtract 8 here because 'Neighbor' is
8326 vty_out(vty
, "Neighbor");
8327 vty_out(vty
, "%*s", max_neighbor_width
- 8,
8330 vty_out(vty
, "EstdCnt DropCnt ResetTime Reason\n");
8333 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
8338 /* Works for both failed & successful cases */
8339 if (peer_dynamic_neighbor(peer
))
8346 bgp_has_peer_failed(peer
, afi
, safi
)) {
8347 json_peer
= json_object_new_object();
8348 bgp_show_failed_summary(vty
, bgp
, peer
,
8349 json_peer
, 0, use_json
);
8350 } else if (!show_failed
) {
8351 json_peer
= json_object_new_object();
8352 if (peer_dynamic_neighbor(peer
)) {
8353 json_object_boolean_true_add(json_peer
,
8358 json_object_string_add(json_peer
, "hostname",
8361 if (peer
->domainname
)
8362 json_object_string_add(json_peer
, "domainname",
8365 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
8366 json_object_int_add(json_peer
, "version", 4);
8367 json_object_int_add(json_peer
, "msgRcvd",
8368 PEER_TOTAL_RX(peer
));
8369 json_object_int_add(json_peer
, "msgSent",
8370 PEER_TOTAL_TX(peer
));
8372 json_object_int_add(json_peer
, "tableVersion",
8373 peer
->version
[afi
][safi
]);
8374 json_object_int_add(json_peer
, "outq",
8376 json_object_int_add(json_peer
, "inq", 0);
8377 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8378 use_json
, json_peer
);
8381 * Adding "pfxRcd" field to match with the corresponding
8382 * CLI. "prefixReceivedCount" will be deprecated in
8385 json_object_int_add(json_peer
, "prefixReceivedCount",
8386 peer
->pcount
[afi
][pfx_rcd_safi
]);
8387 json_object_int_add(json_peer
, "pfxRcd",
8388 peer
->pcount
[afi
][pfx_rcd_safi
]);
8390 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
8391 if (paf
&& PAF_SUBGRP(paf
))
8392 json_object_int_add(json_peer
,
8394 (PAF_SUBGRP(paf
))->scount
);
8395 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8396 json_object_string_add(json_peer
, "state",
8398 else if (peer
->afc_recv
[afi
][safi
])
8399 json_object_string_add(
8401 lookup_msg(bgp_status_msg
, peer
->status
,
8403 else if (CHECK_FLAG(peer
->sflags
,
8404 PEER_STATUS_PREFIX_OVERFLOW
))
8405 json_object_string_add(json_peer
, "state",
8408 json_object_string_add(
8410 lookup_msg(bgp_status_msg
, peer
->status
,
8412 json_object_int_add(json_peer
, "connectionsEstablished",
8414 json_object_int_add(json_peer
, "connectionsDropped",
8417 /* Avoid creating empty peer dicts in JSON */
8418 if (json_peer
== NULL
)
8422 json_object_string_add(json_peer
, "idType",
8424 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8425 json_object_string_add(json_peer
, "idType",
8427 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8428 json_object_string_add(json_peer
, "idType",
8430 json_object_object_add(json_peers
, peer
->host
,
8434 bgp_has_peer_failed(peer
, afi
, safi
)) {
8435 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
8438 } else if (!show_failed
) {
8439 memset(dn_flag
, '\0', sizeof(dn_flag
));
8440 if (peer_dynamic_neighbor(peer
)) {
8445 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8446 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8447 peer
->hostname
, peer
->host
);
8449 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8451 /* pad the neighbor column with spaces */
8452 if (len
< max_neighbor_width
)
8453 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8456 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8457 peer
->as
, PEER_TOTAL_RX(peer
),
8458 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8459 0, peer
->obuf
->count
,
8460 peer_uptime(peer
->uptime
, timebuf
,
8461 BGP_UPTIME_LEN
, 0, NULL
));
8463 if (peer
->status
== Established
)
8464 if (peer
->afc_recv
[afi
][safi
])
8465 vty_out(vty
, " %12" PRIu32
,
8470 vty_out(vty
, " NoNeg");
8472 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8473 vty_out(vty
, " Idle (Admin)");
8474 else if (CHECK_FLAG(
8476 PEER_STATUS_PREFIX_OVERFLOW
))
8477 vty_out(vty
, " Idle (PfxCt)");
8479 vty_out(vty
, " %12s",
8480 lookup_msg(bgp_status_msg
,
8481 peer
->status
, NULL
));
8490 json_object_object_add(json
, "peers", json_peers
);
8491 json_object_int_add(json
, "failedPeers", failed_count
);
8492 json_object_int_add(json
, "totalPeers", count
);
8493 json_object_int_add(json
, "dynamicPeers", dn_count
);
8496 bgp_show_bestpath_json(bgp
, json
);
8498 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8499 json
, JSON_C_TO_STRING_PRETTY
));
8500 json_object_free(json
);
8503 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8505 vty_out(vty
, "No %s neighbor is configured\n",
8506 get_afi_safi_str(afi
, safi
, false));
8510 vty_out(vty
, "* - dynamic neighbor\n");
8511 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8512 dn_count
, bgp
->dynamic_neighbors_limit
);
8519 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8520 int safi
, bool show_failed
, bool use_json
)
8523 int afi_wildcard
= (afi
== AFI_MAX
);
8524 int safi_wildcard
= (safi
== SAFI_MAX
);
8525 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8526 bool nbr_output
= false;
8528 if (use_json
&& is_wildcard
)
8529 vty_out(vty
, "{\n");
8531 afi
= 1; /* AFI_IP */
8532 while (afi
< AFI_MAX
) {
8534 safi
= 1; /* SAFI_UNICAST */
8535 while (safi
< SAFI_MAX
) {
8536 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8541 * So limit output to those afi/safi
8543 * actualy have something interesting in
8548 vty_out(vty
, ",\n");
8552 vty_out(vty
, "\"%s\":",
8553 get_afi_safi_str(afi
,
8557 vty_out(vty
, "\n%s Summary:\n",
8558 get_afi_safi_str(afi
,
8563 bgp_show_summary(vty
, bgp
, afi
, safi
, show_failed
,
8575 if (use_json
&& is_wildcard
)
8576 vty_out(vty
, "}\n");
8577 else if (!nbr_output
) {
8579 vty_out(vty
, "{}\n");
8581 vty_out(vty
, "%% No BGP neighbors found\n");
8585 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8586 safi_t safi
, bool show_failed
,
8589 struct listnode
*node
, *nnode
;
8592 bool nbr_output
= false;
8595 vty_out(vty
, "{\n");
8597 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8601 vty_out(vty
, ",\n");
8605 vty_out(vty
, "\"%s\":",
8606 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8610 vty_out(vty
, "\nInstance %s:\n",
8611 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8615 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
8620 vty_out(vty
, "}\n");
8621 else if (!nbr_output
)
8622 vty_out(vty
, "%% BGP instance not found\n");
8625 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8626 safi_t safi
, bool show_failed
, bool use_json
)
8631 if (strmatch(name
, "all")) {
8632 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8637 bgp
= bgp_lookup_by_name(name
);
8641 vty_out(vty
, "{}\n");
8644 "%% BGP instance not found\n");
8648 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
,
8649 show_failed
, use_json
);
8654 bgp
= bgp_get_default();
8657 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
8661 vty_out(vty
, "{}\n");
8663 vty_out(vty
, "%% BGP instance not found\n");
8670 /* `show [ip] bgp summary' commands. */
8671 DEFUN (show_ip_bgp_summary
,
8672 show_ip_bgp_summary_cmd
,
8673 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [failed] [json]",
8677 BGP_INSTANCE_HELP_STR
8679 BGP_SAFI_WITH_LABEL_HELP_STR
8680 "Summary of BGP neighbor status\n"
8681 "Show only sessions not in Established state\n"
8685 afi_t afi
= AFI_MAX
;
8686 safi_t safi
= SAFI_MAX
;
8687 bool show_failed
= false;
8692 if (argv_find(argv
, argc
, "ip", &idx
))
8694 /* [<vrf> VIEWVRFNAME] */
8695 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8696 vrf
= argv
[idx
+ 1]->arg
;
8697 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8699 } else if (argv_find(argv
, argc
, "view", &idx
))
8700 /* [<view> VIEWVRFNAME] */
8701 vrf
= argv
[idx
+ 1]->arg
;
8702 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8703 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8704 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8707 if (argv_find(argv
, argc
, "failed", &idx
))
8710 bool uj
= use_json(argc
, argv
);
8712 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, show_failed
, uj
);
8715 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
8718 return get_afi_safi_json_str(afi
, safi
);
8720 return get_afi_safi_vty_str(afi
, safi
);
8723 /* Show BGP peer's information. */
8724 enum show_type
{ show_all
, show_peer
, show_ipv4_all
, show_ipv6_all
, show_ipv4_peer
, show_ipv6_peer
};
8726 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8727 afi_t afi
, safi_t safi
,
8728 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8729 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8730 bool use_json
, json_object
*json_pref
)
8733 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8734 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8736 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8737 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8738 json_object_string_add(json_pref
, "sendMode",
8739 "advertisedAndReceived");
8740 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8741 json_object_string_add(json_pref
, "sendMode",
8743 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8744 json_object_string_add(json_pref
, "sendMode",
8747 vty_out(vty
, " Send-mode: ");
8748 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8749 vty_out(vty
, "advertised");
8750 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8751 vty_out(vty
, "%sreceived",
8752 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8761 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8762 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8764 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8765 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8766 json_object_string_add(json_pref
, "recvMode",
8767 "advertisedAndReceived");
8768 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8769 json_object_string_add(json_pref
, "recvMode",
8771 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8772 json_object_string_add(json_pref
, "recvMode",
8775 vty_out(vty
, " Receive-mode: ");
8776 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8777 vty_out(vty
, "advertised");
8778 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8779 vty_out(vty
, "%sreceived",
8780 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8789 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8790 safi_t safi
, bool use_json
,
8791 json_object
*json_neigh
)
8793 struct bgp_filter
*filter
;
8794 struct peer_af
*paf
;
8795 char orf_pfx_name
[BUFSIZ
];
8797 json_object
*json_af
= NULL
;
8798 json_object
*json_prefA
= NULL
;
8799 json_object
*json_prefB
= NULL
;
8800 json_object
*json_addr
= NULL
;
8803 json_addr
= json_object_new_object();
8804 json_af
= json_object_new_object();
8805 filter
= &p
->filter
[afi
][safi
];
8807 if (peer_group_active(p
))
8808 json_object_string_add(json_addr
, "peerGroupMember",
8811 paf
= peer_af_find(p
, afi
, safi
);
8812 if (paf
&& PAF_SUBGRP(paf
)) {
8813 json_object_int_add(json_addr
, "updateGroupId",
8814 PAF_UPDGRP(paf
)->id
);
8815 json_object_int_add(json_addr
, "subGroupId",
8816 PAF_SUBGRP(paf
)->id
);
8817 json_object_int_add(json_addr
, "packetQueueLength",
8818 bpacket_queue_virtual_length(paf
));
8821 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8822 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8823 PEER_CAP_ORF_PREFIX_SM_RCV
)
8824 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8825 PEER_CAP_ORF_PREFIX_RM_ADV
)
8826 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8827 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8828 json_object_int_add(json_af
, "orfType",
8830 json_prefA
= json_object_new_object();
8831 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8832 PEER_CAP_ORF_PREFIX_SM_ADV
,
8833 PEER_CAP_ORF_PREFIX_RM_ADV
,
8834 PEER_CAP_ORF_PREFIX_SM_RCV
,
8835 PEER_CAP_ORF_PREFIX_RM_RCV
,
8836 use_json
, json_prefA
);
8837 json_object_object_add(json_af
, "orfPrefixList",
8841 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8842 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8843 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8844 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8845 PEER_CAP_ORF_PREFIX_RM_ADV
)
8846 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8847 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8848 json_object_int_add(json_af
, "orfOldType",
8849 ORF_TYPE_PREFIX_OLD
);
8850 json_prefB
= json_object_new_object();
8851 bgp_show_peer_afi_orf_cap(
8852 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8853 PEER_CAP_ORF_PREFIX_RM_ADV
,
8854 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8855 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8857 json_object_object_add(json_af
, "orfOldPrefixList",
8861 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8862 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8863 PEER_CAP_ORF_PREFIX_SM_RCV
)
8864 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8865 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8866 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8867 PEER_CAP_ORF_PREFIX_RM_ADV
)
8868 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8869 PEER_CAP_ORF_PREFIX_RM_RCV
)
8870 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8871 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8872 json_object_object_add(json_addr
, "afDependentCap",
8875 json_object_free(json_af
);
8877 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8878 orf_pfx_count
= prefix_bgp_show_prefix_list(
8879 NULL
, afi
, orf_pfx_name
, use_json
);
8881 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8882 PEER_STATUS_ORF_PREFIX_SEND
)
8884 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8885 PEER_STATUS_ORF_PREFIX_SEND
))
8886 json_object_boolean_true_add(json_neigh
,
8889 json_object_int_add(json_addr
, "orfRecvCounter",
8892 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8893 PEER_STATUS_ORF_WAIT_REFRESH
))
8894 json_object_string_add(
8895 json_addr
, "orfFirstUpdate",
8896 "deferredUntilORFOrRouteRefreshRecvd");
8898 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8899 PEER_FLAG_REFLECTOR_CLIENT
))
8900 json_object_boolean_true_add(json_addr
,
8901 "routeReflectorClient");
8902 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8903 PEER_FLAG_RSERVER_CLIENT
))
8904 json_object_boolean_true_add(json_addr
,
8905 "routeServerClient");
8906 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8907 json_object_boolean_true_add(json_addr
,
8908 "inboundSoftConfigPermit");
8910 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8911 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8912 json_object_boolean_true_add(
8914 "privateAsNumsAllReplacedInUpdatesToNbr");
8915 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8916 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8917 json_object_boolean_true_add(
8919 "privateAsNumsReplacedInUpdatesToNbr");
8920 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8921 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8922 json_object_boolean_true_add(
8924 "privateAsNumsAllRemovedInUpdatesToNbr");
8925 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8926 PEER_FLAG_REMOVE_PRIVATE_AS
))
8927 json_object_boolean_true_add(
8929 "privateAsNumsRemovedInUpdatesToNbr");
8931 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8932 json_object_boolean_true_add(
8934 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8937 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8938 json_object_string_add(json_addr
,
8939 "overrideASNsInOutboundUpdates",
8940 "ifAspathEqualRemoteAs");
8942 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8943 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8944 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8945 json_object_boolean_true_add(json_addr
,
8946 "routerAlwaysNextHop");
8947 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8948 PEER_FLAG_AS_PATH_UNCHANGED
))
8949 json_object_boolean_true_add(
8950 json_addr
, "unchangedAsPathPropogatedToNbr");
8951 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8952 PEER_FLAG_NEXTHOP_UNCHANGED
))
8953 json_object_boolean_true_add(
8954 json_addr
, "unchangedNextHopPropogatedToNbr");
8955 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8956 json_object_boolean_true_add(
8957 json_addr
, "unchangedMedPropogatedToNbr");
8958 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8959 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8960 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8961 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8962 PEER_FLAG_SEND_COMMUNITY
)
8963 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8964 PEER_FLAG_SEND_EXT_COMMUNITY
))
8965 json_object_string_add(json_addr
,
8966 "commAttriSentToNbr",
8967 "extendedAndStandard");
8968 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8969 PEER_FLAG_SEND_EXT_COMMUNITY
))
8970 json_object_string_add(json_addr
,
8971 "commAttriSentToNbr",
8974 json_object_string_add(json_addr
,
8975 "commAttriSentToNbr",
8978 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8979 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8980 if (p
->default_rmap
[afi
][safi
].name
)
8981 json_object_string_add(
8982 json_addr
, "defaultRouteMap",
8983 p
->default_rmap
[afi
][safi
].name
);
8985 if (paf
&& PAF_SUBGRP(paf
)
8986 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8987 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8988 json_object_boolean_true_add(json_addr
,
8991 json_object_boolean_true_add(json_addr
,
8995 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8996 if (is_evpn_enabled())
8997 json_object_boolean_true_add(
8998 json_addr
, "advertiseAllVnis");
9001 if (filter
->plist
[FILTER_IN
].name
9002 || filter
->dlist
[FILTER_IN
].name
9003 || filter
->aslist
[FILTER_IN
].name
9004 || filter
->map
[RMAP_IN
].name
)
9005 json_object_boolean_true_add(json_addr
,
9006 "inboundPathPolicyConfig");
9007 if (filter
->plist
[FILTER_OUT
].name
9008 || filter
->dlist
[FILTER_OUT
].name
9009 || filter
->aslist
[FILTER_OUT
].name
9010 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9011 json_object_boolean_true_add(
9012 json_addr
, "outboundPathPolicyConfig");
9015 if (filter
->plist
[FILTER_IN
].name
)
9016 json_object_string_add(json_addr
,
9017 "incomingUpdatePrefixFilterList",
9018 filter
->plist
[FILTER_IN
].name
);
9019 if (filter
->plist
[FILTER_OUT
].name
)
9020 json_object_string_add(json_addr
,
9021 "outgoingUpdatePrefixFilterList",
9022 filter
->plist
[FILTER_OUT
].name
);
9024 /* distribute-list */
9025 if (filter
->dlist
[FILTER_IN
].name
)
9026 json_object_string_add(
9027 json_addr
, "incomingUpdateNetworkFilterList",
9028 filter
->dlist
[FILTER_IN
].name
);
9029 if (filter
->dlist
[FILTER_OUT
].name
)
9030 json_object_string_add(
9031 json_addr
, "outgoingUpdateNetworkFilterList",
9032 filter
->dlist
[FILTER_OUT
].name
);
9035 if (filter
->aslist
[FILTER_IN
].name
)
9036 json_object_string_add(json_addr
,
9037 "incomingUpdateAsPathFilterList",
9038 filter
->aslist
[FILTER_IN
].name
);
9039 if (filter
->aslist
[FILTER_OUT
].name
)
9040 json_object_string_add(json_addr
,
9041 "outgoingUpdateAsPathFilterList",
9042 filter
->aslist
[FILTER_OUT
].name
);
9045 if (filter
->map
[RMAP_IN
].name
)
9046 json_object_string_add(
9047 json_addr
, "routeMapForIncomingAdvertisements",
9048 filter
->map
[RMAP_IN
].name
);
9049 if (filter
->map
[RMAP_OUT
].name
)
9050 json_object_string_add(
9051 json_addr
, "routeMapForOutgoingAdvertisements",
9052 filter
->map
[RMAP_OUT
].name
);
9054 /* ebgp-requires-policy (inbound) */
9055 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9056 && !bgp_inbound_policy_exists(p
, filter
))
9057 json_object_string_add(
9058 json_addr
, "inboundEbgpRequiresPolicy",
9059 "Inbound updates discarded due to missing policy");
9061 /* ebgp-requires-policy (outbound) */
9062 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9063 && (!bgp_outbound_policy_exists(p
, filter
)))
9064 json_object_string_add(
9065 json_addr
, "outboundEbgpRequiresPolicy",
9066 "Outbound updates discarded due to missing policy");
9068 /* unsuppress-map */
9069 if (filter
->usmap
.name
)
9070 json_object_string_add(json_addr
,
9071 "selectiveUnsuppressRouteMap",
9072 filter
->usmap
.name
);
9074 /* Receive prefix count */
9075 json_object_int_add(json_addr
, "acceptedPrefixCounter",
9076 p
->pcount
[afi
][safi
]);
9077 if (paf
&& PAF_SUBGRP(paf
))
9078 json_object_int_add(json_addr
, "sentPrefixCounter",
9079 (PAF_SUBGRP(paf
))->scount
);
9081 /* Maximum prefix */
9082 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9083 json_object_int_add(json_addr
, "prefixAllowedMax",
9084 p
->pmax
[afi
][safi
]);
9085 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9086 PEER_FLAG_MAX_PREFIX_WARNING
))
9087 json_object_boolean_true_add(
9088 json_addr
, "prefixAllowedMaxWarning");
9089 json_object_int_add(json_addr
,
9090 "prefixAllowedWarningThresh",
9091 p
->pmax_threshold
[afi
][safi
]);
9092 if (p
->pmax_restart
[afi
][safi
])
9093 json_object_int_add(
9095 "prefixAllowedRestartIntervalMsecs",
9096 p
->pmax_restart
[afi
][safi
] * 60000);
9098 json_object_object_add(json_neigh
, get_afi_safi_str(afi
, safi
, true),
9102 filter
= &p
->filter
[afi
][safi
];
9104 vty_out(vty
, " For address family: %s\n",
9105 get_afi_safi_str(afi
, safi
, false));
9107 if (peer_group_active(p
))
9108 vty_out(vty
, " %s peer-group member\n",
9111 paf
= peer_af_find(p
, afi
, safi
);
9112 if (paf
&& PAF_SUBGRP(paf
)) {
9113 vty_out(vty
, " Update group %" PRIu64
9114 ", subgroup %" PRIu64
"\n",
9115 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
9116 vty_out(vty
, " Packet Queue length %d\n",
9117 bpacket_queue_virtual_length(paf
));
9119 vty_out(vty
, " Not part of any update group\n");
9121 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9122 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9123 PEER_CAP_ORF_PREFIX_SM_RCV
)
9124 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9125 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
9126 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9127 PEER_CAP_ORF_PREFIX_RM_ADV
)
9128 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9129 PEER_CAP_ORF_PREFIX_RM_RCV
)
9130 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9131 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
9132 vty_out(vty
, " AF-dependant capabilities:\n");
9134 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9135 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9136 PEER_CAP_ORF_PREFIX_SM_RCV
)
9137 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9138 PEER_CAP_ORF_PREFIX_RM_ADV
)
9139 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9140 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
9142 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
9144 bgp_show_peer_afi_orf_cap(
9145 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
9146 PEER_CAP_ORF_PREFIX_RM_ADV
,
9147 PEER_CAP_ORF_PREFIX_SM_RCV
,
9148 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
9150 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9151 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9152 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
9153 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9154 PEER_CAP_ORF_PREFIX_RM_ADV
)
9155 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9156 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
9158 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
9159 ORF_TYPE_PREFIX_OLD
);
9160 bgp_show_peer_afi_orf_cap(
9161 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
9162 PEER_CAP_ORF_PREFIX_RM_ADV
,
9163 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
9164 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
9167 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
9168 orf_pfx_count
= prefix_bgp_show_prefix_list(
9169 NULL
, afi
, orf_pfx_name
, use_json
);
9171 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9172 PEER_STATUS_ORF_PREFIX_SEND
)
9174 vty_out(vty
, " Outbound Route Filter (ORF):");
9175 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9176 PEER_STATUS_ORF_PREFIX_SEND
))
9177 vty_out(vty
, " sent;");
9179 vty_out(vty
, " received (%d entries)",
9183 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9184 PEER_STATUS_ORF_WAIT_REFRESH
))
9186 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
9188 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9189 PEER_FLAG_REFLECTOR_CLIENT
))
9190 vty_out(vty
, " Route-Reflector Client\n");
9191 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9192 PEER_FLAG_RSERVER_CLIENT
))
9193 vty_out(vty
, " Route-Server Client\n");
9194 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9196 " Inbound soft reconfiguration allowed\n");
9198 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9199 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
9201 " Private AS numbers (all) replaced in updates to this neighbor\n");
9202 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9203 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
9205 " Private AS numbers replaced in updates to this neighbor\n");
9206 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9207 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
9209 " Private AS numbers (all) removed in updates to this neighbor\n");
9210 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9211 PEER_FLAG_REMOVE_PRIVATE_AS
))
9213 " Private AS numbers removed in updates to this neighbor\n");
9215 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
9216 vty_out(vty
, " %s\n",
9217 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
9218 ->human_description
);
9220 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
9222 " Override ASNs in outbound updates if aspath equals remote-as\n");
9224 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
9225 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9226 PEER_FLAG_FORCE_NEXTHOP_SELF
))
9227 vty_out(vty
, " NEXT_HOP is always this router\n");
9228 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9229 PEER_FLAG_AS_PATH_UNCHANGED
))
9231 " AS_PATH is propagated unchanged to this neighbor\n");
9232 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9233 PEER_FLAG_NEXTHOP_UNCHANGED
))
9235 " NEXT_HOP is propagated unchanged to this neighbor\n");
9236 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
9238 " MED is propagated unchanged to this neighbor\n");
9239 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
9240 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9241 PEER_FLAG_SEND_EXT_COMMUNITY
)
9242 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9243 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
9245 " Community attribute sent to this neighbor");
9246 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9247 PEER_FLAG_SEND_COMMUNITY
)
9248 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9249 PEER_FLAG_SEND_EXT_COMMUNITY
)
9250 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9251 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9252 vty_out(vty
, "(all)\n");
9253 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9254 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9255 vty_out(vty
, "(large)\n");
9256 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9257 PEER_FLAG_SEND_EXT_COMMUNITY
))
9258 vty_out(vty
, "(extended)\n");
9260 vty_out(vty
, "(standard)\n");
9262 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9263 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9264 vty_out(vty
, " Default information originate,");
9266 if (p
->default_rmap
[afi
][safi
].name
)
9267 vty_out(vty
, " default route-map %s%s,",
9268 p
->default_rmap
[afi
][safi
].map
? "*"
9270 p
->default_rmap
[afi
][safi
].name
);
9271 if (paf
&& PAF_SUBGRP(paf
)
9272 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9273 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9274 vty_out(vty
, " default sent\n");
9276 vty_out(vty
, " default not sent\n");
9279 /* advertise-vni-all */
9280 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9281 if (is_evpn_enabled())
9282 vty_out(vty
, " advertise-all-vni\n");
9285 if (filter
->plist
[FILTER_IN
].name
9286 || filter
->dlist
[FILTER_IN
].name
9287 || filter
->aslist
[FILTER_IN
].name
9288 || filter
->map
[RMAP_IN
].name
)
9289 vty_out(vty
, " Inbound path policy configured\n");
9290 if (filter
->plist
[FILTER_OUT
].name
9291 || filter
->dlist
[FILTER_OUT
].name
9292 || filter
->aslist
[FILTER_OUT
].name
9293 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9294 vty_out(vty
, " Outbound path policy configured\n");
9297 if (filter
->plist
[FILTER_IN
].name
)
9299 " Incoming update prefix filter list is %s%s\n",
9300 filter
->plist
[FILTER_IN
].plist
? "*" : "",
9301 filter
->plist
[FILTER_IN
].name
);
9302 if (filter
->plist
[FILTER_OUT
].name
)
9304 " Outgoing update prefix filter list is %s%s\n",
9305 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
9306 filter
->plist
[FILTER_OUT
].name
);
9308 /* distribute-list */
9309 if (filter
->dlist
[FILTER_IN
].name
)
9311 " Incoming update network filter list is %s%s\n",
9312 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
9313 filter
->dlist
[FILTER_IN
].name
);
9314 if (filter
->dlist
[FILTER_OUT
].name
)
9316 " Outgoing update network filter list is %s%s\n",
9317 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
9318 filter
->dlist
[FILTER_OUT
].name
);
9321 if (filter
->aslist
[FILTER_IN
].name
)
9323 " Incoming update AS path filter list is %s%s\n",
9324 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
9325 filter
->aslist
[FILTER_IN
].name
);
9326 if (filter
->aslist
[FILTER_OUT
].name
)
9328 " Outgoing update AS path filter list is %s%s\n",
9329 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
9330 filter
->aslist
[FILTER_OUT
].name
);
9333 if (filter
->map
[RMAP_IN
].name
)
9335 " Route map for incoming advertisements is %s%s\n",
9336 filter
->map
[RMAP_IN
].map
? "*" : "",
9337 filter
->map
[RMAP_IN
].name
);
9338 if (filter
->map
[RMAP_OUT
].name
)
9340 " Route map for outgoing advertisements is %s%s\n",
9341 filter
->map
[RMAP_OUT
].map
? "*" : "",
9342 filter
->map
[RMAP_OUT
].name
);
9344 /* ebgp-requires-policy (inbound) */
9345 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9346 && !bgp_inbound_policy_exists(p
, filter
))
9348 " Inbound updates discarded due to missing policy\n");
9350 /* ebgp-requires-policy (outbound) */
9351 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9352 && !bgp_outbound_policy_exists(p
, filter
))
9354 " Outbound updates discarded due to missing policy\n");
9356 /* unsuppress-map */
9357 if (filter
->usmap
.name
)
9359 " Route map for selective unsuppress is %s%s\n",
9360 filter
->usmap
.map
? "*" : "",
9361 filter
->usmap
.name
);
9363 /* Receive prefix count */
9364 vty_out(vty
, " %" PRIu32
" accepted prefixes\n",
9365 p
->pcount
[afi
][safi
]);
9367 /* Maximum prefix */
9368 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9370 " Maximum prefixes allowed %" PRIu32
"%s\n",
9372 CHECK_FLAG(p
->af_flags
[afi
][safi
],
9373 PEER_FLAG_MAX_PREFIX_WARNING
)
9376 vty_out(vty
, " Threshold for warning message %d%%",
9377 p
->pmax_threshold
[afi
][safi
]);
9378 if (p
->pmax_restart
[afi
][safi
])
9379 vty_out(vty
, ", restart interval %d min",
9380 p
->pmax_restart
[afi
][safi
]);
9388 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
9392 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
9393 char timebuf
[BGP_UPTIME_LEN
];
9399 json_object
*json_neigh
= NULL
;
9405 json_neigh
= json_object_new_object();
9407 memset(dn_flag
, '\0', sizeof(dn_flag
));
9408 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9412 if (p
->conf_if
) /* Configured interface name. */
9413 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9414 BGP_PEER_SU_UNSPEC(p
)
9416 : sockunion2str(&p
->su
, buf
,
9418 else /* Configured IP address. */
9419 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9424 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9425 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9427 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9428 json_object_string_add(
9429 json_neigh
, "bgpNeighborAddr",
9430 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9432 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9434 if (p
->change_local_as
)
9435 json_object_int_add(json_neigh
, "localAs",
9436 p
->change_local_as
);
9438 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9440 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9441 json_object_boolean_true_add(json_neigh
,
9442 "localAsNoPrepend");
9444 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9445 json_object_boolean_true_add(json_neigh
,
9446 "localAsReplaceAs");
9448 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9449 || (p
->as_type
== AS_INTERNAL
))
9450 vty_out(vty
, "remote AS %u, ", p
->as
);
9452 vty_out(vty
, "remote AS Unspecified, ");
9453 vty_out(vty
, "local AS %u%s%s, ",
9454 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9455 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9458 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9462 /* peer type internal or confed-internal */
9463 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
9465 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9466 json_object_boolean_true_add(
9467 json_neigh
, "nbrConfedInternalLink");
9469 json_object_boolean_true_add(json_neigh
,
9472 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9473 vty_out(vty
, "confed-internal link\n");
9475 vty_out(vty
, "internal link\n");
9477 /* peer type external or confed-external */
9478 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
9480 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9481 json_object_boolean_true_add(
9482 json_neigh
, "nbrConfedExternalLink");
9484 json_object_boolean_true_add(json_neigh
,
9487 if (bgp_confederation_peers_check(bgp
, p
->as
))
9488 vty_out(vty
, "confed-external link\n");
9490 vty_out(vty
, "external link\n");
9494 json_object_boolean_true_add(json_neigh
,
9495 "nbrUnspecifiedLink");
9497 vty_out(vty
, "unspecified link\n");
9503 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9505 vty_out(vty
, " Description: %s\n", p
->desc
);
9511 json_object_string_add(json_neigh
, "hostname",
9515 json_object_string_add(json_neigh
, "domainname",
9518 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9519 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9522 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9529 json_object_string_add(json_neigh
, "peerGroup",
9533 struct prefix prefix
, *range
= NULL
;
9535 sockunion2hostprefix(&(p
->su
), &prefix
);
9536 range
= peer_group_lookup_dynamic_neighbor_range(
9540 prefix2str(range
, buf1
, sizeof(buf1
));
9541 json_object_string_add(
9543 "peerSubnetRangeGroup", buf1
);
9548 " Member of peer-group %s for session parameters\n",
9552 struct prefix prefix
, *range
= NULL
;
9554 sockunion2hostprefix(&(p
->su
), &prefix
);
9555 range
= peer_group_lookup_dynamic_neighbor_range(
9559 prefix2str(range
, buf1
, sizeof(buf1
));
9561 " Belongs to the subnet range group: %s\n",
9569 /* Administrative shutdown. */
9570 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9571 json_object_boolean_true_add(json_neigh
,
9575 json_object_int_add(json_neigh
, "bgpVersion", 4);
9576 json_object_string_add(
9577 json_neigh
, "remoteRouterId",
9578 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9579 json_object_string_add(
9580 json_neigh
, "localRouterId",
9581 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9585 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9586 && bgp_confederation_peers_check(bgp
, p
->as
))
9587 json_object_boolean_true_add(json_neigh
,
9591 json_object_string_add(
9592 json_neigh
, "bgpState",
9593 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9595 if (p
->status
== Established
) {
9598 uptime
= bgp_clock();
9599 uptime
-= p
->uptime
;
9600 epoch_tbuf
= time(NULL
) - uptime
;
9602 #if CONFDATE > 20200101
9604 "bgpTimerUp should be deprecated and can be removed now");
9607 * bgpTimerUp was miliseconds that was accurate
9608 * up to 1 day, then the value returned
9609 * became garbage. So in order to provide
9610 * some level of backwards compatability,
9611 * we still provde the data, but now
9612 * we are returning the correct value
9613 * and also adding a new bgpTimerUpMsec
9614 * which will allow us to deprecate
9617 json_object_int_add(json_neigh
, "bgpTimerUp",
9619 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9621 json_object_string_add(json_neigh
, "bgpTimerUpString",
9622 peer_uptime(p
->uptime
, timebuf
,
9625 json_object_int_add(json_neigh
,
9626 "bgpTimerUpEstablishedEpoch",
9630 else if (p
->status
== Active
) {
9631 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9632 json_object_string_add(json_neigh
, "bgpStateIs",
9634 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9635 json_object_string_add(json_neigh
, "bgpStateIs",
9643 uptime
= bgp_clock();
9644 uptime
-= p
->readtime
;
9645 tm
= gmtime(&uptime
);
9646 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9647 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9648 + (tm
->tm_hour
* 3600000));
9650 uptime
= bgp_clock();
9651 uptime
-= p
->last_write
;
9652 tm
= gmtime(&uptime
);
9653 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9654 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9655 + (tm
->tm_hour
* 3600000));
9657 uptime
= bgp_clock();
9658 uptime
-= p
->update_time
;
9659 tm
= gmtime(&uptime
);
9660 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9661 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9662 + (tm
->tm_hour
* 3600000));
9664 /* Configured timer values. */
9665 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9666 p
->v_holdtime
* 1000);
9667 json_object_int_add(json_neigh
,
9668 "bgpTimerKeepAliveIntervalMsecs",
9669 p
->v_keepalive
* 1000);
9670 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9671 json_object_int_add(json_neigh
,
9672 "bgpTimerConfiguredHoldTimeMsecs",
9673 p
->holdtime
* 1000);
9674 json_object_int_add(
9676 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9677 p
->keepalive
* 1000);
9678 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9679 || (bgp
->default_keepalive
9680 != BGP_DEFAULT_KEEPALIVE
)) {
9681 json_object_int_add(json_neigh
,
9682 "bgpTimerConfiguredHoldTimeMsecs",
9683 bgp
->default_holdtime
);
9684 json_object_int_add(
9686 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9687 bgp
->default_keepalive
);
9690 /* Administrative shutdown. */
9691 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9692 vty_out(vty
, " Administratively shut down\n");
9695 vty_out(vty
, " BGP version 4");
9696 vty_out(vty
, ", remote router ID %s",
9697 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9698 vty_out(vty
, ", local router ID %s\n",
9699 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9703 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9704 && bgp_confederation_peers_check(bgp
, p
->as
))
9706 " Neighbor under common administration\n");
9709 vty_out(vty
, " BGP state = %s",
9710 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9712 if (p
->status
== Established
)
9713 vty_out(vty
, ", up for %8s",
9714 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9717 else if (p
->status
== Active
) {
9718 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9719 vty_out(vty
, " (passive)");
9720 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9721 vty_out(vty
, " (NSF passive)");
9726 vty_out(vty
, " Last read %s",
9727 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9729 vty_out(vty
, ", Last write %s\n",
9730 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9733 /* Configured timer values. */
9735 " Hold time is %d, keepalive interval is %d seconds\n",
9736 p
->v_holdtime
, p
->v_keepalive
);
9737 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9738 vty_out(vty
, " Configured hold time is %d",
9740 vty_out(vty
, ", keepalive interval is %d seconds\n",
9742 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9743 || (bgp
->default_keepalive
9744 != BGP_DEFAULT_KEEPALIVE
)) {
9745 vty_out(vty
, " Configured hold time is %d",
9746 bgp
->default_holdtime
);
9747 vty_out(vty
, ", keepalive interval is %d seconds\n",
9748 bgp
->default_keepalive
);
9752 if (p
->status
== Established
) {
9753 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9754 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9755 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9756 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9757 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9758 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9759 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9760 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9761 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9762 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9763 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9764 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9765 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9766 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9767 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9768 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9769 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9770 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9771 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9772 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9774 json_object
*json_cap
= NULL
;
9776 json_cap
= json_object_new_object();
9779 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9780 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9781 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9782 && CHECK_FLAG(p
->cap
,
9784 json_object_string_add(
9785 json_cap
, "4byteAs",
9786 "advertisedAndReceived");
9787 else if (CHECK_FLAG(p
->cap
,
9789 json_object_string_add(
9790 json_cap
, "4byteAs",
9792 else if (CHECK_FLAG(p
->cap
,
9794 json_object_string_add(
9795 json_cap
, "4byteAs",
9800 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9801 || CHECK_FLAG(p
->cap
,
9802 PEER_CAP_ADDPATH_ADV
)) {
9803 json_object
*json_add
= NULL
;
9804 const char *print_store
;
9806 json_add
= json_object_new_object();
9808 FOREACH_AFI_SAFI (afi
, safi
) {
9809 json_object
*json_sub
= NULL
;
9811 json_object_new_object();
9812 print_store
= get_afi_safi_str(
9818 PEER_CAP_ADDPATH_AF_TX_ADV
)
9822 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9827 PEER_CAP_ADDPATH_AF_TX_ADV
)
9832 PEER_CAP_ADDPATH_AF_TX_RCV
))
9833 json_object_boolean_true_add(
9835 "txAdvertisedAndReceived");
9841 PEER_CAP_ADDPATH_AF_TX_ADV
))
9842 json_object_boolean_true_add(
9850 PEER_CAP_ADDPATH_AF_TX_RCV
))
9851 json_object_boolean_true_add(
9859 PEER_CAP_ADDPATH_AF_RX_ADV
)
9863 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9868 PEER_CAP_ADDPATH_AF_RX_ADV
)
9873 PEER_CAP_ADDPATH_AF_RX_RCV
))
9874 json_object_boolean_true_add(
9876 "rxAdvertisedAndReceived");
9882 PEER_CAP_ADDPATH_AF_RX_ADV
))
9883 json_object_boolean_true_add(
9891 PEER_CAP_ADDPATH_AF_RX_RCV
))
9892 json_object_boolean_true_add(
9900 PEER_CAP_ADDPATH_AF_TX_ADV
)
9904 PEER_CAP_ADDPATH_AF_TX_RCV
)
9908 PEER_CAP_ADDPATH_AF_RX_ADV
)
9912 PEER_CAP_ADDPATH_AF_RX_RCV
))
9913 json_object_object_add(
9922 json_object_object_add(
9923 json_cap
, "addPath", json_add
);
9927 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9928 || CHECK_FLAG(p
->cap
,
9929 PEER_CAP_DYNAMIC_ADV
)) {
9930 if (CHECK_FLAG(p
->cap
,
9931 PEER_CAP_DYNAMIC_ADV
)
9932 && CHECK_FLAG(p
->cap
,
9933 PEER_CAP_DYNAMIC_RCV
))
9934 json_object_string_add(
9935 json_cap
, "dynamic",
9936 "advertisedAndReceived");
9937 else if (CHECK_FLAG(
9939 PEER_CAP_DYNAMIC_ADV
))
9940 json_object_string_add(
9941 json_cap
, "dynamic",
9943 else if (CHECK_FLAG(
9945 PEER_CAP_DYNAMIC_RCV
))
9946 json_object_string_add(
9947 json_cap
, "dynamic",
9951 /* Extended nexthop */
9952 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9953 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9954 json_object
*json_nxt
= NULL
;
9955 const char *print_store
;
9958 if (CHECK_FLAG(p
->cap
,
9960 && CHECK_FLAG(p
->cap
,
9962 json_object_string_add(
9965 "advertisedAndReceived");
9966 else if (CHECK_FLAG(p
->cap
,
9968 json_object_string_add(
9972 else if (CHECK_FLAG(p
->cap
,
9974 json_object_string_add(
9979 if (CHECK_FLAG(p
->cap
,
9980 PEER_CAP_ENHE_RCV
)) {
9982 json_object_new_object();
9984 for (safi
= SAFI_UNICAST
;
9985 safi
< SAFI_MAX
; safi
++) {
9990 PEER_CAP_ENHE_AF_RCV
)) {
9991 print_store
= get_afi_safi_str(
9994 json_object_string_add(
9997 "recieved"); /* misspelled for compatibility */
10000 json_object_object_add(
10002 "extendedNexthopFamililesByPeer",
10007 /* Route Refresh */
10008 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10009 || CHECK_FLAG(p
->cap
,
10010 PEER_CAP_REFRESH_NEW_RCV
)
10011 || CHECK_FLAG(p
->cap
,
10012 PEER_CAP_REFRESH_OLD_RCV
)) {
10013 if (CHECK_FLAG(p
->cap
,
10014 PEER_CAP_REFRESH_ADV
)
10017 PEER_CAP_REFRESH_NEW_RCV
)
10020 PEER_CAP_REFRESH_OLD_RCV
))) {
10023 PEER_CAP_REFRESH_OLD_RCV
)
10026 PEER_CAP_REFRESH_NEW_RCV
))
10027 json_object_string_add(
10030 "advertisedAndReceivedOldNew");
10034 PEER_CAP_REFRESH_OLD_RCV
))
10035 json_object_string_add(
10038 "advertisedAndReceivedOld");
10040 json_object_string_add(
10043 "advertisedAndReceivedNew");
10048 PEER_CAP_REFRESH_ADV
))
10049 json_object_string_add(
10056 PEER_CAP_REFRESH_NEW_RCV
)
10059 PEER_CAP_REFRESH_OLD_RCV
))
10060 json_object_string_add(
10066 /* Multiprotocol Extensions */
10067 json_object
*json_multi
= NULL
;
10068 json_multi
= json_object_new_object();
10070 FOREACH_AFI_SAFI (afi
, safi
) {
10071 if (p
->afc_adv
[afi
][safi
]
10072 || p
->afc_recv
[afi
][safi
]) {
10073 json_object
*json_exten
= NULL
;
10075 json_object_new_object();
10077 if (p
->afc_adv
[afi
][safi
]
10078 && p
->afc_recv
[afi
][safi
])
10079 json_object_boolean_true_add(
10081 "advertisedAndReceived");
10082 else if (p
->afc_adv
[afi
][safi
])
10083 json_object_boolean_true_add(
10086 else if (p
->afc_recv
[afi
][safi
])
10087 json_object_boolean_true_add(
10091 json_object_object_add(
10093 get_afi_safi_str(afi
,
10099 json_object_object_add(
10100 json_cap
, "multiprotocolExtensions",
10103 /* Hostname capabilities */
10104 json_object
*json_hname
= NULL
;
10106 json_hname
= json_object_new_object();
10108 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10109 json_object_string_add(
10110 json_hname
, "advHostName",
10111 bgp
->peer_self
->hostname
10115 json_object_string_add(
10116 json_hname
, "advDomainName",
10117 bgp
->peer_self
->domainname
10124 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10125 json_object_string_add(
10126 json_hname
, "rcvHostName",
10127 p
->hostname
? p
->hostname
10129 json_object_string_add(
10130 json_hname
, "rcvDomainName",
10131 p
->domainname
? p
->domainname
10135 json_object_object_add(json_cap
, "hostName",
10138 /* Gracefull Restart */
10139 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10140 || CHECK_FLAG(p
->cap
,
10141 PEER_CAP_RESTART_ADV
)) {
10142 if (CHECK_FLAG(p
->cap
,
10143 PEER_CAP_RESTART_ADV
)
10144 && CHECK_FLAG(p
->cap
,
10145 PEER_CAP_RESTART_RCV
))
10146 json_object_string_add(
10149 "advertisedAndReceived");
10150 else if (CHECK_FLAG(
10152 PEER_CAP_RESTART_ADV
))
10153 json_object_string_add(
10155 "gracefulRestartCapability",
10157 else if (CHECK_FLAG(
10159 PEER_CAP_RESTART_RCV
))
10160 json_object_string_add(
10162 "gracefulRestartCapability",
10165 if (CHECK_FLAG(p
->cap
,
10166 PEER_CAP_RESTART_RCV
)) {
10167 int restart_af_count
= 0;
10168 json_object
*json_restart
=
10171 json_object_new_object();
10173 json_object_int_add(
10175 "gracefulRestartRemoteTimerMsecs",
10176 p
->v_gr_restart
* 1000);
10178 FOREACH_AFI_SAFI (afi
, safi
) {
10183 PEER_CAP_RESTART_AF_RCV
)) {
10188 json_object_new_object();
10194 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
10195 json_object_boolean_true_add(
10198 restart_af_count
++;
10199 json_object_object_add(
10208 if (!restart_af_count
) {
10209 json_object_string_add(
10211 "addressFamiliesByPeer",
10216 json_object_object_add(
10218 "addressFamiliesByPeer",
10222 json_object_object_add(json_neigh
,
10223 "neighborCapabilities",
10226 vty_out(vty
, " Neighbor capabilities:\n");
10229 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
10230 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
10231 vty_out(vty
, " 4 Byte AS:");
10232 if (CHECK_FLAG(p
->cap
,
10234 vty_out(vty
, " advertised");
10235 if (CHECK_FLAG(p
->cap
,
10237 vty_out(vty
, " %sreceived",
10243 vty_out(vty
, "\n");
10247 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
10248 || CHECK_FLAG(p
->cap
,
10249 PEER_CAP_ADDPATH_ADV
)) {
10250 vty_out(vty
, " AddPath:\n");
10252 FOREACH_AFI_SAFI (afi
, safi
) {
10256 PEER_CAP_ADDPATH_AF_TX_ADV
)
10260 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
10272 PEER_CAP_ADDPATH_AF_TX_ADV
))
10284 PEER_CAP_ADDPATH_AF_TX_RCV
))
10291 PEER_CAP_ADDPATH_AF_TX_ADV
)
10295 vty_out(vty
, "\n");
10301 PEER_CAP_ADDPATH_AF_RX_ADV
)
10305 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
10317 PEER_CAP_ADDPATH_AF_RX_ADV
))
10329 PEER_CAP_ADDPATH_AF_RX_RCV
))
10336 PEER_CAP_ADDPATH_AF_RX_ADV
)
10340 vty_out(vty
, "\n");
10346 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10347 || CHECK_FLAG(p
->cap
,
10348 PEER_CAP_DYNAMIC_ADV
)) {
10349 vty_out(vty
, " Dynamic:");
10350 if (CHECK_FLAG(p
->cap
,
10351 PEER_CAP_DYNAMIC_ADV
))
10352 vty_out(vty
, " advertised");
10353 if (CHECK_FLAG(p
->cap
,
10354 PEER_CAP_DYNAMIC_RCV
))
10355 vty_out(vty
, " %sreceived",
10358 PEER_CAP_DYNAMIC_ADV
)
10361 vty_out(vty
, "\n");
10364 /* Extended nexthop */
10365 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10366 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10367 vty_out(vty
, " Extended nexthop:");
10368 if (CHECK_FLAG(p
->cap
,
10369 PEER_CAP_ENHE_ADV
))
10370 vty_out(vty
, " advertised");
10371 if (CHECK_FLAG(p
->cap
,
10372 PEER_CAP_ENHE_RCV
))
10373 vty_out(vty
, " %sreceived",
10379 vty_out(vty
, "\n");
10381 if (CHECK_FLAG(p
->cap
,
10382 PEER_CAP_ENHE_RCV
)) {
10384 " Address families by peer:\n ");
10385 for (safi
= SAFI_UNICAST
;
10386 safi
< SAFI_MAX
; safi
++)
10391 PEER_CAP_ENHE_AF_RCV
))
10401 /* Route Refresh */
10402 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10403 || CHECK_FLAG(p
->cap
,
10404 PEER_CAP_REFRESH_NEW_RCV
)
10405 || CHECK_FLAG(p
->cap
,
10406 PEER_CAP_REFRESH_OLD_RCV
)) {
10407 vty_out(vty
, " Route refresh:");
10408 if (CHECK_FLAG(p
->cap
,
10409 PEER_CAP_REFRESH_ADV
))
10410 vty_out(vty
, " advertised");
10411 if (CHECK_FLAG(p
->cap
,
10412 PEER_CAP_REFRESH_NEW_RCV
)
10415 PEER_CAP_REFRESH_OLD_RCV
))
10416 vty_out(vty
, " %sreceived(%s)",
10419 PEER_CAP_REFRESH_ADV
)
10424 PEER_CAP_REFRESH_OLD_RCV
)
10427 PEER_CAP_REFRESH_NEW_RCV
))
10431 PEER_CAP_REFRESH_OLD_RCV
)
10435 vty_out(vty
, "\n");
10438 /* Multiprotocol Extensions */
10439 FOREACH_AFI_SAFI (afi
, safi
)
10440 if (p
->afc_adv
[afi
][safi
]
10441 || p
->afc_recv
[afi
][safi
]) {
10443 " Address Family %s:",
10448 if (p
->afc_adv
[afi
][safi
])
10451 if (p
->afc_recv
[afi
][safi
])
10458 vty_out(vty
, "\n");
10461 /* Hostname capability */
10462 vty_out(vty
, " Hostname Capability:");
10464 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10466 " advertised (name: %s,domain name: %s)",
10467 bgp
->peer_self
->hostname
10471 bgp
->peer_self
->domainname
10476 vty_out(vty
, " not advertised");
10479 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10481 " received (name: %s,domain name: %s)",
10482 p
->hostname
? p
->hostname
10484 p
->domainname
? p
->domainname
10487 vty_out(vty
, " not received");
10490 vty_out(vty
, "\n");
10492 /* Gracefull Restart */
10493 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10494 || CHECK_FLAG(p
->cap
,
10495 PEER_CAP_RESTART_ADV
)) {
10497 " Graceful Restart Capabilty:");
10498 if (CHECK_FLAG(p
->cap
,
10499 PEER_CAP_RESTART_ADV
))
10500 vty_out(vty
, " advertised");
10501 if (CHECK_FLAG(p
->cap
,
10502 PEER_CAP_RESTART_RCV
))
10503 vty_out(vty
, " %sreceived",
10506 PEER_CAP_RESTART_ADV
)
10509 vty_out(vty
, "\n");
10511 if (CHECK_FLAG(p
->cap
,
10512 PEER_CAP_RESTART_RCV
)) {
10513 int restart_af_count
= 0;
10516 " Remote Restart timer is %d seconds\n",
10519 " Address families by peer:\n ");
10521 FOREACH_AFI_SAFI (afi
, safi
)
10526 PEER_CAP_RESTART_AF_RCV
)) {
10540 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10542 : "not preserved");
10543 restart_af_count
++;
10545 if (!restart_af_count
)
10546 vty_out(vty
, "none");
10547 vty_out(vty
, "\n");
10554 /* graceful restart information */
10555 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10556 || p
->t_gr_stale
) {
10557 json_object
*json_grace
= NULL
;
10558 json_object
*json_grace_send
= NULL
;
10559 json_object
*json_grace_recv
= NULL
;
10560 int eor_send_af_count
= 0;
10561 int eor_receive_af_count
= 0;
10564 json_grace
= json_object_new_object();
10565 json_grace_send
= json_object_new_object();
10566 json_grace_recv
= json_object_new_object();
10568 if (p
->status
== Established
) {
10569 FOREACH_AFI_SAFI (afi
, safi
) {
10570 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10571 PEER_STATUS_EOR_SEND
)) {
10572 json_object_boolean_true_add(
10574 get_afi_safi_str(afi
,
10577 eor_send_af_count
++;
10580 FOREACH_AFI_SAFI (afi
, safi
) {
10582 p
->af_sflags
[afi
][safi
],
10583 PEER_STATUS_EOR_RECEIVED
)) {
10584 json_object_boolean_true_add(
10586 get_afi_safi_str(afi
,
10589 eor_receive_af_count
++;
10594 json_object_object_add(json_grace
, "endOfRibSend",
10596 json_object_object_add(json_grace
, "endOfRibRecv",
10599 if (p
->t_gr_restart
)
10600 json_object_int_add(json_grace
,
10601 "gracefulRestartTimerMsecs",
10602 thread_timer_remain_second(
10607 json_object_int_add(
10609 "gracefulStalepathTimerMsecs",
10610 thread_timer_remain_second(
10614 json_object_object_add(
10615 json_neigh
, "gracefulRestartInfo", json_grace
);
10617 vty_out(vty
, " Graceful restart information:\n");
10618 if (p
->status
== Established
) {
10619 vty_out(vty
, " End-of-RIB send: ");
10620 FOREACH_AFI_SAFI (afi
, safi
) {
10621 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10622 PEER_STATUS_EOR_SEND
)) {
10623 vty_out(vty
, "%s%s",
10624 eor_send_af_count
? ", "
10626 get_afi_safi_str(afi
,
10629 eor_send_af_count
++;
10632 vty_out(vty
, "\n");
10633 vty_out(vty
, " End-of-RIB received: ");
10634 FOREACH_AFI_SAFI (afi
, safi
) {
10636 p
->af_sflags
[afi
][safi
],
10637 PEER_STATUS_EOR_RECEIVED
)) {
10638 vty_out(vty
, "%s%s",
10639 eor_receive_af_count
10642 get_afi_safi_str(afi
,
10645 eor_receive_af_count
++;
10648 vty_out(vty
, "\n");
10651 if (p
->t_gr_restart
)
10653 " The remaining time of restart timer is %ld\n",
10654 thread_timer_remain_second(
10659 " The remaining time of stalepath timer is %ld\n",
10660 thread_timer_remain_second(
10665 json_object
*json_stat
= NULL
;
10666 json_stat
= json_object_new_object();
10667 /* Packet counts. */
10668 json_object_int_add(json_stat
, "depthInq", 0);
10669 json_object_int_add(json_stat
, "depthOutq",
10670 (unsigned long)p
->obuf
->count
);
10671 json_object_int_add(json_stat
, "opensSent",
10672 atomic_load_explicit(&p
->open_out
,
10673 memory_order_relaxed
));
10674 json_object_int_add(json_stat
, "opensRecv",
10675 atomic_load_explicit(&p
->open_in
,
10676 memory_order_relaxed
));
10677 json_object_int_add(json_stat
, "notificationsSent",
10678 atomic_load_explicit(&p
->notify_out
,
10679 memory_order_relaxed
));
10680 json_object_int_add(json_stat
, "notificationsRecv",
10681 atomic_load_explicit(&p
->notify_in
,
10682 memory_order_relaxed
));
10683 json_object_int_add(json_stat
, "updatesSent",
10684 atomic_load_explicit(&p
->update_out
,
10685 memory_order_relaxed
));
10686 json_object_int_add(json_stat
, "updatesRecv",
10687 atomic_load_explicit(&p
->update_in
,
10688 memory_order_relaxed
));
10689 json_object_int_add(json_stat
, "keepalivesSent",
10690 atomic_load_explicit(&p
->keepalive_out
,
10691 memory_order_relaxed
));
10692 json_object_int_add(json_stat
, "keepalivesRecv",
10693 atomic_load_explicit(&p
->keepalive_in
,
10694 memory_order_relaxed
));
10695 json_object_int_add(json_stat
, "routeRefreshSent",
10696 atomic_load_explicit(&p
->refresh_out
,
10697 memory_order_relaxed
));
10698 json_object_int_add(json_stat
, "routeRefreshRecv",
10699 atomic_load_explicit(&p
->refresh_in
,
10700 memory_order_relaxed
));
10701 json_object_int_add(json_stat
, "capabilitySent",
10702 atomic_load_explicit(&p
->dynamic_cap_out
,
10703 memory_order_relaxed
));
10704 json_object_int_add(json_stat
, "capabilityRecv",
10705 atomic_load_explicit(&p
->dynamic_cap_in
,
10706 memory_order_relaxed
));
10707 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10708 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10709 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10711 /* Packet counts. */
10712 vty_out(vty
, " Message statistics:\n");
10713 vty_out(vty
, " Inq depth is 0\n");
10714 vty_out(vty
, " Outq depth is %lu\n",
10715 (unsigned long)p
->obuf
->count
);
10716 vty_out(vty
, " Sent Rcvd\n");
10717 vty_out(vty
, " Opens: %10d %10d\n",
10718 atomic_load_explicit(&p
->open_out
,
10719 memory_order_relaxed
),
10720 atomic_load_explicit(&p
->open_in
,
10721 memory_order_relaxed
));
10722 vty_out(vty
, " Notifications: %10d %10d\n",
10723 atomic_load_explicit(&p
->notify_out
,
10724 memory_order_relaxed
),
10725 atomic_load_explicit(&p
->notify_in
,
10726 memory_order_relaxed
));
10727 vty_out(vty
, " Updates: %10d %10d\n",
10728 atomic_load_explicit(&p
->update_out
,
10729 memory_order_relaxed
),
10730 atomic_load_explicit(&p
->update_in
,
10731 memory_order_relaxed
));
10732 vty_out(vty
, " Keepalives: %10d %10d\n",
10733 atomic_load_explicit(&p
->keepalive_out
,
10734 memory_order_relaxed
),
10735 atomic_load_explicit(&p
->keepalive_in
,
10736 memory_order_relaxed
));
10737 vty_out(vty
, " Route Refresh: %10d %10d\n",
10738 atomic_load_explicit(&p
->refresh_out
,
10739 memory_order_relaxed
),
10740 atomic_load_explicit(&p
->refresh_in
,
10741 memory_order_relaxed
));
10742 vty_out(vty
, " Capability: %10d %10d\n",
10743 atomic_load_explicit(&p
->dynamic_cap_out
,
10744 memory_order_relaxed
),
10745 atomic_load_explicit(&p
->dynamic_cap_in
,
10746 memory_order_relaxed
));
10747 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10752 /* advertisement-interval */
10753 json_object_int_add(json_neigh
,
10754 "minBtwnAdvertisementRunsTimerMsecs",
10755 p
->v_routeadv
* 1000);
10757 /* Update-source. */
10758 if (p
->update_if
|| p
->update_source
) {
10760 json_object_string_add(json_neigh
,
10763 else if (p
->update_source
)
10764 json_object_string_add(
10765 json_neigh
, "updateSource",
10766 sockunion2str(p
->update_source
, buf1
,
10770 /* advertisement-interval */
10772 " Minimum time between advertisement runs is %d seconds\n",
10775 /* Update-source. */
10776 if (p
->update_if
|| p
->update_source
) {
10777 vty_out(vty
, " Update source is ");
10779 vty_out(vty
, "%s", p
->update_if
);
10780 else if (p
->update_source
)
10782 sockunion2str(p
->update_source
, buf1
,
10784 vty_out(vty
, "\n");
10787 vty_out(vty
, "\n");
10790 /* Address Family Information */
10791 json_object
*json_hold
= NULL
;
10794 json_hold
= json_object_new_object();
10796 FOREACH_AFI_SAFI (afi
, safi
)
10797 if (p
->afc
[afi
][safi
])
10798 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10802 json_object_object_add(json_neigh
, "addressFamilyInfo",
10804 json_object_int_add(json_neigh
, "connectionsEstablished",
10806 json_object_int_add(json_neigh
, "connectionsDropped",
10809 vty_out(vty
, " Connections established %d; dropped %d\n",
10810 p
->established
, p
->dropped
);
10812 if (!p
->last_reset
) {
10814 json_object_string_add(json_neigh
, "lastReset",
10817 vty_out(vty
, " Last reset never\n");
10823 uptime
= bgp_clock();
10824 uptime
-= p
->resettime
;
10825 tm
= gmtime(&uptime
);
10826 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10827 (tm
->tm_sec
* 1000)
10828 + (tm
->tm_min
* 60000)
10829 + (tm
->tm_hour
* 3600000));
10830 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
10832 vty_out(vty
, " Last reset %s, ",
10833 peer_uptime(p
->resettime
, timebuf
,
10834 BGP_UPTIME_LEN
, 0, NULL
));
10836 bgp_show_peer_reset(vty
, p
, NULL
, false);
10837 if (p
->last_reset_cause_size
) {
10838 msg
= p
->last_reset_cause
;
10840 " Message received that caused BGP to send a NOTIFICATION:\n ");
10841 for (i
= 1; i
<= p
->last_reset_cause_size
;
10843 vty_out(vty
, "%02X", *msg
++);
10845 if (i
!= p
->last_reset_cause_size
) {
10847 vty_out(vty
, "\n ");
10848 } else if (i
% 4 == 0) {
10853 vty_out(vty
, "\n");
10858 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10860 json_object_boolean_true_add(json_neigh
,
10861 "prefixesConfigExceedMax");
10864 " Peer had exceeded the max. no. of prefixes configured.\n");
10866 if (p
->t_pmax_restart
) {
10868 json_object_boolean_true_add(
10869 json_neigh
, "reducePrefixNumFrom");
10870 json_object_int_add(json_neigh
,
10871 "restartInTimerMsec",
10872 thread_timer_remain_second(
10877 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10878 p
->host
, thread_timer_remain_second(
10879 p
->t_pmax_restart
));
10882 json_object_boolean_true_add(
10884 "reducePrefixNumAndClearIpBgp");
10887 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10892 /* EBGP Multihop and GTSM */
10893 if (p
->sort
!= BGP_PEER_IBGP
) {
10895 if (p
->gtsm_hops
> 0)
10896 json_object_int_add(json_neigh
,
10897 "externalBgpNbrMaxHopsAway",
10899 else if (p
->ttl
> BGP_DEFAULT_TTL
)
10900 json_object_int_add(json_neigh
,
10901 "externalBgpNbrMaxHopsAway",
10904 if (p
->gtsm_hops
> 0)
10906 " External BGP neighbor may be up to %d hops away.\n",
10908 else if (p
->ttl
> BGP_DEFAULT_TTL
)
10910 " External BGP neighbor may be up to %d hops away.\n",
10914 if (p
->gtsm_hops
> 0) {
10916 json_object_int_add(json_neigh
,
10917 "internalBgpNbrMaxHopsAway",
10921 " Internal BGP neighbor may be up to %d hops away.\n",
10926 /* Local address. */
10929 json_object_string_add(json_neigh
, "hostLocal",
10930 sockunion2str(p
->su_local
, buf1
,
10932 json_object_int_add(json_neigh
, "portLocal",
10933 ntohs(p
->su_local
->sin
.sin_port
));
10935 vty_out(vty
, "Local host: %s, Local port: %d\n",
10936 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10937 ntohs(p
->su_local
->sin
.sin_port
));
10940 /* Remote address. */
10941 if (p
->su_remote
) {
10943 json_object_string_add(json_neigh
, "hostForeign",
10944 sockunion2str(p
->su_remote
, buf1
,
10946 json_object_int_add(json_neigh
, "portForeign",
10947 ntohs(p
->su_remote
->sin
.sin_port
));
10949 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10950 sockunion2str(p
->su_remote
, buf1
,
10952 ntohs(p
->su_remote
->sin
.sin_port
));
10955 /* Nexthop display. */
10958 json_object_string_add(json_neigh
, "nexthop",
10960 &p
->nexthop
.v4
, buf1
,
10962 json_object_string_add(json_neigh
, "nexthopGlobal",
10963 inet_ntop(AF_INET6
,
10964 &p
->nexthop
.v6_global
,
10965 buf1
, sizeof(buf1
)));
10966 json_object_string_add(json_neigh
, "nexthopLocal",
10967 inet_ntop(AF_INET6
,
10968 &p
->nexthop
.v6_local
,
10969 buf1
, sizeof(buf1
)));
10970 if (p
->shared_network
)
10971 json_object_string_add(json_neigh
,
10975 json_object_string_add(json_neigh
,
10977 "nonSharedNetwork");
10979 vty_out(vty
, "Nexthop: %s\n",
10980 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10982 vty_out(vty
, "Nexthop global: %s\n",
10983 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10985 vty_out(vty
, "Nexthop local: %s\n",
10986 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10988 vty_out(vty
, "BGP connection: %s\n",
10989 p
->shared_network
? "shared network"
10990 : "non shared network");
10994 /* Timer information. */
10996 json_object_int_add(json_neigh
, "connectRetryTimer",
10998 if (p
->status
== Established
&& p
->rtt
)
10999 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
11002 json_object_int_add(
11003 json_neigh
, "nextStartTimerDueInMsecs",
11004 thread_timer_remain_second(p
->t_start
) * 1000);
11006 json_object_int_add(
11007 json_neigh
, "nextConnectTimerDueInMsecs",
11008 thread_timer_remain_second(p
->t_connect
)
11010 if (p
->t_routeadv
) {
11011 json_object_int_add(json_neigh
, "mraiInterval",
11013 json_object_int_add(
11014 json_neigh
, "mraiTimerExpireInMsecs",
11015 thread_timer_remain_second(p
->t_routeadv
)
11019 json_object_int_add(json_neigh
, "authenticationEnabled",
11023 json_object_string_add(json_neigh
, "readThread", "on");
11025 json_object_string_add(json_neigh
, "readThread", "off");
11027 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
11028 json_object_string_add(json_neigh
, "writeThread", "on");
11030 json_object_string_add(json_neigh
, "writeThread",
11033 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
11035 if (p
->status
== Established
&& p
->rtt
)
11036 vty_out(vty
, "Estimated round trip time: %d ms\n",
11039 vty_out(vty
, "Next start timer due in %ld seconds\n",
11040 thread_timer_remain_second(p
->t_start
));
11042 vty_out(vty
, "Next connect timer due in %ld seconds\n",
11043 thread_timer_remain_second(p
->t_connect
));
11046 "MRAI (interval %u) timer expires in %ld seconds\n",
11048 thread_timer_remain_second(p
->t_routeadv
));
11050 vty_out(vty
, "Peer Authentication Enabled\n");
11052 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
11053 p
->t_read
? "on" : "off",
11054 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
11059 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
11060 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
11061 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
11064 vty_out(vty
, "\n");
11066 /* BFD information. */
11067 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
11070 if (p
->conf_if
) /* Configured interface name. */
11071 json_object_object_add(json
, p
->conf_if
, json_neigh
);
11072 else /* Configured IP address. */
11073 json_object_object_add(json
, p
->host
, json_neigh
);
11077 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
11078 enum show_type type
, union sockunion
*su
,
11079 const char *conf_if
, bool use_json
,
11082 struct listnode
*node
, *nnode
;
11085 bool nbr_output
= false;
11086 afi_t afi
= AFI_MAX
;
11087 safi_t safi
= SAFI_MAX
;
11089 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
11091 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
11095 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11096 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11101 bgp_show_peer(vty
, peer
, use_json
, json
);
11107 && !strcmp(peer
->conf_if
, conf_if
))
11109 && !strcmp(peer
->hostname
, conf_if
))) {
11111 bgp_show_peer(vty
, peer
, use_json
,
11115 if (sockunion_same(&peer
->su
, su
)) {
11117 bgp_show_peer(vty
, peer
, use_json
,
11122 case show_ipv4_peer
:
11123 case show_ipv6_peer
:
11124 FOREACH_SAFI (safi
) {
11125 if (peer
->afc
[afi
][safi
]) {
11128 && !strcmp(peer
->conf_if
, conf_if
))
11130 && !strcmp(peer
->hostname
, conf_if
))) {
11132 bgp_show_peer(vty
, peer
, use_json
,
11137 if (sockunion_same(&peer
->su
, su
)) {
11139 bgp_show_peer(vty
, peer
, use_json
,
11147 case show_ipv4_all
:
11148 case show_ipv6_all
:
11149 FOREACH_SAFI (safi
) {
11150 if (peer
->afc
[afi
][safi
]) {
11151 bgp_show_peer(vty
, peer
, use_json
, json
);
11160 if ((type
== show_peer
|| type
== show_ipv4_peer
||
11161 type
== show_ipv6_peer
) && !find
) {
11163 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
11165 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
11168 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
11169 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
11170 vty_out(vty
, "%% No BGP neighbors found\n");
11173 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11174 json
, JSON_C_TO_STRING_PRETTY
));
11176 vty_out(vty
, "\n");
11179 return CMD_SUCCESS
;
11182 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
11183 enum show_type type
,
11184 const char *ip_str
,
11187 struct listnode
*node
, *nnode
;
11189 union sockunion su
;
11190 json_object
*json
= NULL
;
11191 int ret
, is_first
= 1;
11192 bool nbr_output
= false;
11195 vty_out(vty
, "{\n");
11197 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11200 if (!(json
= json_object_new_object())) {
11202 EC_BGP_JSON_MEM_ERROR
,
11203 "Unable to allocate memory for JSON object");
11205 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
11209 json_object_int_add(json
, "vrfId",
11210 (bgp
->vrf_id
== VRF_UNKNOWN
)
11212 : (int64_t)bgp
->vrf_id
);
11213 json_object_string_add(
11215 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11220 vty_out(vty
, ",\n");
11224 vty_out(vty
, "\"%s\":",
11225 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11229 vty_out(vty
, "\nInstance %s:\n",
11230 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11235 if (type
== show_peer
|| type
== show_ipv4_peer
||
11236 type
== show_ipv6_peer
) {
11237 ret
= str2sockunion(ip_str
, &su
);
11239 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11242 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11245 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
11248 json_object_free(json
);
11252 vty_out(vty
, "}\n");
11253 json_object_free(json
);
11255 else if (!nbr_output
)
11256 vty_out(vty
, "%% BGP instance not found\n");
11259 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
11260 enum show_type type
, const char *ip_str
,
11265 union sockunion su
;
11266 json_object
*json
= NULL
;
11269 if (strmatch(name
, "all")) {
11270 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
11272 return CMD_SUCCESS
;
11274 bgp
= bgp_lookup_by_name(name
);
11277 json
= json_object_new_object();
11278 vty_out(vty
, "%s\n",
11279 json_object_to_json_string_ext(
11281 JSON_C_TO_STRING_PRETTY
));
11282 json_object_free(json
);
11285 "%% BGP instance not found\n");
11287 return CMD_WARNING
;
11291 bgp
= bgp_get_default();
11295 json
= json_object_new_object();
11297 ret
= str2sockunion(ip_str
, &su
);
11299 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11302 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11305 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
11308 json_object_free(json
);
11311 vty_out(vty
, "{}\n");
11313 vty_out(vty
, "%% BGP instance not found\n");
11316 return CMD_SUCCESS
;
11319 /* "show [ip] bgp neighbors" commands. */
11320 DEFUN (show_ip_bgp_neighbors
,
11321 show_ip_bgp_neighbors_cmd
,
11322 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
11326 BGP_INSTANCE_HELP_STR
11329 "Detailed information on TCP and BGP neighbor connections\n"
11330 "Neighbor to display information about\n"
11331 "Neighbor to display information about\n"
11332 "Neighbor on BGP configured interface\n"
11336 char *sh_arg
= NULL
;
11337 enum show_type sh_type
;
11338 afi_t afi
= AFI_MAX
;
11340 bool uj
= use_json(argc
, argv
);
11344 /* [<vrf> VIEWVRFNAME] */
11345 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11346 vrf
= argv
[idx
+ 1]->arg
;
11347 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11349 } else if (argv_find(argv
, argc
, "view", &idx
))
11350 /* [<view> VIEWVRFNAME] */
11351 vrf
= argv
[idx
+ 1]->arg
;
11355 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
11356 sh_type
= show_ipv4_all
;
11358 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
11359 sh_type
= show_ipv6_all
;
11362 sh_type
= show_all
;
11365 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
11366 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
11367 || argv_find(argv
, argc
, "WORD", &idx
)) {
11368 sh_type
= show_peer
;
11369 sh_arg
= argv
[idx
]->arg
;
11372 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
11373 sh_type
= show_ipv4_peer
;
11374 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
11375 sh_type
= show_ipv6_peer
;
11378 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
11381 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
11382 paths' and `show ip mbgp paths'. Those functions results are the
11384 DEFUN (show_ip_bgp_paths
,
11385 show_ip_bgp_paths_cmd
,
11386 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
11391 "Path information\n")
11393 vty_out(vty
, "Address Refcnt Path\n");
11394 aspath_print_all_vty(vty
);
11395 return CMD_SUCCESS
;
11400 static void community_show_all_iterator(struct hash_bucket
*bucket
,
11403 struct community
*com
;
11405 com
= (struct community
*)bucket
->data
;
11406 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
11407 community_str(com
, false));
11410 /* Show BGP's community internal data. */
11411 DEFUN (show_ip_bgp_community_info
,
11412 show_ip_bgp_community_info_cmd
,
11413 "show [ip] bgp community-info",
11417 "List all bgp community information\n")
11419 vty_out(vty
, "Address Refcnt Community\n");
11421 hash_iterate(community_hash(),
11422 (void (*)(struct hash_bucket
*,
11423 void *))community_show_all_iterator
,
11426 return CMD_SUCCESS
;
11429 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
11432 struct lcommunity
*lcom
;
11434 lcom
= (struct lcommunity
*)bucket
->data
;
11435 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11436 lcommunity_str(lcom
, false));
11439 /* Show BGP's community internal data. */
11440 DEFUN (show_ip_bgp_lcommunity_info
,
11441 show_ip_bgp_lcommunity_info_cmd
,
11442 "show ip bgp large-community-info",
11446 "List all bgp large-community information\n")
11448 vty_out(vty
, "Address Refcnt Large-community\n");
11450 hash_iterate(lcommunity_hash(),
11451 (void (*)(struct hash_bucket
*,
11452 void *))lcommunity_show_all_iterator
,
11455 return CMD_SUCCESS
;
11459 DEFUN (show_ip_bgp_attr_info
,
11460 show_ip_bgp_attr_info_cmd
,
11461 "show [ip] bgp attribute-info",
11465 "List all bgp attribute information\n")
11467 attr_show_all(vty
);
11468 return CMD_SUCCESS
;
11471 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
11472 afi_t afi
, safi_t safi
,
11473 bool use_json
, json_object
*json
)
11476 struct listnode
*node
;
11478 char buf1
[INET6_ADDRSTRLEN
];
11480 vpn_policy_direction_t dir
;
11483 json_object
*json_import_vrfs
= NULL
;
11484 json_object
*json_export_vrfs
= NULL
;
11486 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11489 vty_out(vty
, "%s\n",
11490 json_object_to_json_string_ext(
11492 JSON_C_TO_STRING_PRETTY
));
11493 json_object_free(json
);
11495 return CMD_WARNING
;
11498 /* Provide context for the block */
11499 json_object_string_add(json
, "vrf", name
? name
: "default");
11500 json_object_string_add(json
, "afiSafi",
11501 get_afi_safi_str(afi
, safi
, true));
11503 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11504 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11505 json_object_string_add(json
, "importFromVrfs", "none");
11506 json_object_string_add(json
, "importRts", "none");
11508 json_import_vrfs
= json_object_new_array();
11510 for (ALL_LIST_ELEMENTS_RO(
11511 bgp
->vpn_policy
[afi
].import_vrf
,
11513 json_object_array_add(json_import_vrfs
,
11514 json_object_new_string(vname
));
11516 json_object_object_add(json
, "importFromVrfs",
11518 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11519 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11520 ecom_str
= ecommunity_ecom2str(
11521 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11522 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11523 json_object_string_add(json
, "importRts",
11525 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11527 json_object_string_add(json
, "importRts",
11531 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11532 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11533 json_object_string_add(json
, "exportToVrfs", "none");
11534 json_object_string_add(json
, "routeDistinguisher",
11536 json_object_string_add(json
, "exportRts", "none");
11538 json_export_vrfs
= json_object_new_array();
11540 for (ALL_LIST_ELEMENTS_RO(
11541 bgp
->vpn_policy
[afi
].export_vrf
,
11543 json_object_array_add(json_export_vrfs
,
11544 json_object_new_string(vname
));
11545 json_object_object_add(json
, "exportToVrfs",
11547 json_object_string_add(json
, "routeDistinguisher",
11548 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11549 buf1
, RD_ADDRSTRLEN
));
11551 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11552 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11553 ecom_str
= ecommunity_ecom2str(
11554 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11555 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11556 json_object_string_add(json
, "exportRts",
11558 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11560 json_object_string_add(json
, "exportRts",
11565 vty_out(vty
, "%s\n",
11566 json_object_to_json_string_ext(json
,
11567 JSON_C_TO_STRING_PRETTY
));
11568 json_object_free(json
);
11571 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11574 vty_out(vty
, "%% No such BGP instance exist\n");
11575 return CMD_WARNING
;
11578 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11579 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11581 "This VRF is not importing %s routes from any other VRF\n",
11582 get_afi_safi_str(afi
, safi
, false));
11585 "This VRF is importing %s routes from the following VRFs:\n",
11586 get_afi_safi_str(afi
, safi
, false));
11588 for (ALL_LIST_ELEMENTS_RO(
11589 bgp
->vpn_policy
[afi
].import_vrf
,
11591 vty_out(vty
, " %s\n", vname
);
11593 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11595 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11596 ecom_str
= ecommunity_ecom2str(
11597 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11598 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11599 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11601 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11603 vty_out(vty
, "Import RT(s):\n");
11606 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11607 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11609 "This VRF is not exporting %s routes to any other VRF\n",
11610 get_afi_safi_str(afi
, safi
, false));
11613 "This VRF is exporting %s routes to the following VRFs:\n",
11614 get_afi_safi_str(afi
, safi
, false));
11616 for (ALL_LIST_ELEMENTS_RO(
11617 bgp
->vpn_policy
[afi
].export_vrf
,
11619 vty_out(vty
, " %s\n", vname
);
11621 vty_out(vty
, "RD: %s\n",
11622 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11623 buf1
, RD_ADDRSTRLEN
));
11625 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11626 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11627 ecom_str
= ecommunity_ecom2str(
11628 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11629 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11630 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11631 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11633 vty_out(vty
, "Import RT(s):\n");
11637 return CMD_SUCCESS
;
11640 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
11641 safi_t safi
, bool use_json
)
11643 struct listnode
*node
, *nnode
;
11645 char *vrf_name
= NULL
;
11646 json_object
*json
= NULL
;
11647 json_object
*json_vrf
= NULL
;
11648 json_object
*json_vrfs
= NULL
;
11651 json
= json_object_new_object();
11652 json_vrfs
= json_object_new_object();
11655 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11657 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
11658 vrf_name
= bgp
->name
;
11661 json_vrf
= json_object_new_object();
11663 vty_out(vty
, "\nInstance %s:\n",
11664 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11665 ? VRF_DEFAULT_NAME
: bgp
->name
);
11667 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
11669 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11670 json_object_object_add(json_vrfs
,
11671 VRF_DEFAULT_NAME
, json_vrf
);
11673 json_object_object_add(json_vrfs
, vrf_name
,
11679 json_object_object_add(json
, "vrfs", json_vrfs
);
11680 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
11681 JSON_C_TO_STRING_PRETTY
));
11682 json_object_free(json
);
11685 return CMD_SUCCESS
;
11688 /* "show [ip] bgp route-leak" command. */
11689 DEFUN (show_ip_bgp_route_leak
,
11690 show_ip_bgp_route_leak_cmd
,
11691 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11695 BGP_INSTANCE_HELP_STR
11698 "Route leaking information\n"
11702 afi_t afi
= AFI_MAX
;
11703 safi_t safi
= SAFI_MAX
;
11705 bool uj
= use_json(argc
, argv
);
11707 json_object
*json
= NULL
;
11709 /* show [ip] bgp */
11710 if (argv_find(argv
, argc
, "ip", &idx
)) {
11712 safi
= SAFI_UNICAST
;
11714 /* [vrf VIEWVRFNAME] */
11715 if (argv_find(argv
, argc
, "view", &idx
)) {
11717 "%% This command is not applicable to BGP views\n");
11718 return CMD_WARNING
;
11721 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11722 vrf
= argv
[idx
+ 1]->arg
;
11723 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11726 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11727 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11728 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11731 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11733 "%% This command is applicable only for unicast ipv4|ipv6\n");
11734 return CMD_WARNING
;
11737 if (vrf
&& strmatch(vrf
, "all"))
11738 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
11741 json
= json_object_new_object();
11743 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
11746 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11749 struct listnode
*node
, *nnode
;
11752 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11753 vty_out(vty
, "\nInstance %s:\n",
11754 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11757 update_group_show(bgp
, afi
, safi
, vty
, 0);
11761 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11762 int safi
, uint64_t subgrp_id
)
11767 if (strmatch(name
, "all")) {
11768 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11769 return CMD_SUCCESS
;
11771 bgp
= bgp_lookup_by_name(name
);
11774 bgp
= bgp_get_default();
11778 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11779 return CMD_SUCCESS
;
11782 DEFUN (show_ip_bgp_updgrps
,
11783 show_ip_bgp_updgrps_cmd
,
11784 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11788 BGP_INSTANCE_HELP_STR
11790 BGP_SAFI_WITH_LABEL_HELP_STR
11791 "Detailed info about dynamic update groups\n"
11792 "Specific subgroup to display detailed info for\n")
11795 afi_t afi
= AFI_IP6
;
11796 safi_t safi
= SAFI_UNICAST
;
11797 uint64_t subgrp_id
= 0;
11801 /* show [ip] bgp */
11802 if (argv_find(argv
, argc
, "ip", &idx
))
11804 /* [<vrf> VIEWVRFNAME] */
11805 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11806 vrf
= argv
[idx
+ 1]->arg
;
11807 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11809 } else if (argv_find(argv
, argc
, "view", &idx
))
11810 /* [<view> VIEWVRFNAME] */
11811 vrf
= argv
[idx
+ 1]->arg
;
11812 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11813 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11814 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11817 /* get subgroup id, if provided */
11819 if (argv
[idx
]->type
== VARIABLE_TKN
)
11820 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11822 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11825 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11826 show_bgp_instance_all_ipv6_updgrps_cmd
,
11827 "show [ip] bgp <view|vrf> all update-groups",
11831 BGP_INSTANCE_ALL_HELP_STR
11832 "Detailed info about dynamic update groups\n")
11834 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11835 return CMD_SUCCESS
;
11838 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
11839 show_bgp_l2vpn_evpn_updgrps_cmd
,
11840 "show [ip] bgp l2vpn evpn update-groups",
11844 "l2vpn address family\n"
11845 "evpn sub-address family\n"
11846 "Detailed info about dynamic update groups\n")
11849 uint64_t subgrp_id
= 0;
11851 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
11852 return CMD_SUCCESS
;
11855 DEFUN (show_bgp_updgrps_stats
,
11856 show_bgp_updgrps_stats_cmd
,
11857 "show [ip] bgp update-groups statistics",
11861 "Detailed info about dynamic update groups\n"
11866 bgp
= bgp_get_default();
11868 update_group_show_stats(bgp
, vty
);
11870 return CMD_SUCCESS
;
11873 DEFUN (show_bgp_instance_updgrps_stats
,
11874 show_bgp_instance_updgrps_stats_cmd
,
11875 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11879 BGP_INSTANCE_HELP_STR
11880 "Detailed info about dynamic update groups\n"
11886 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11888 update_group_show_stats(bgp
, vty
);
11890 return CMD_SUCCESS
;
11893 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11894 afi_t afi
, safi_t safi
,
11895 const char *what
, uint64_t subgrp_id
)
11900 bgp
= bgp_lookup_by_name(name
);
11902 bgp
= bgp_get_default();
11905 if (!strcmp(what
, "advertise-queue"))
11906 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11908 else if (!strcmp(what
, "advertised-routes"))
11909 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11911 else if (!strcmp(what
, "packet-queue"))
11912 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11917 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11918 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11919 "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",
11920 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11922 "Detailed info about dynamic update groups\n"
11923 "Specific subgroup to display info for\n"
11924 "Advertisement queue\n"
11925 "Announced routes\n"
11928 uint64_t subgrp_id
= 0;
11932 subgrp_id
= strtoull(sgid
, NULL
, 10);
11937 afiz
= bgp_vty_afi_from_str(afi
);
11941 afiz
= bgp_vty_afi_from_str(afi
);
11942 if (afiz
!= AFI_IP
)
11944 "%% Cannot specify both 'ip' and 'ipv6'\n");
11945 return CMD_WARNING
;
11948 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11950 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11951 return CMD_SUCCESS
;
11954 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11956 struct listnode
*node
, *nnode
;
11957 struct prefix
*range
;
11960 char buf
[PREFIX2STR_BUFFER
];
11963 const char *peer_status
;
11964 const char *af_str
;
11969 conf
= group
->conf
;
11971 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11972 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11973 group
->name
, conf
->as
);
11974 } else if (conf
->as_type
== AS_INTERNAL
) {
11975 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
11976 group
->name
, group
->bgp
->as
);
11978 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11981 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11982 vty_out(vty
, " Peer-group type is internal\n");
11984 vty_out(vty
, " Peer-group type is external\n");
11986 /* Display AFs configured. */
11987 vty_out(vty
, " Configured address-families:");
11988 FOREACH_AFI_SAFI (afi
, safi
) {
11989 if (conf
->afc
[afi
][safi
]) {
11991 vty_out(vty
, " %s;", get_afi_safi_str(afi
, safi
, false));
11995 vty_out(vty
, " none\n");
11997 vty_out(vty
, "\n");
11999 /* Display listen ranges (for dynamic neighbors), if any */
12000 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
12003 else if (afi
== AFI_IP6
)
12007 lr_count
= listcount(group
->listen_range
[afi
]);
12009 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
12013 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
12015 prefix2str(range
, buf
, sizeof(buf
));
12016 vty_out(vty
, " %s\n", buf
);
12021 /* Display group members and their status */
12022 if (listcount(group
->peer
)) {
12023 vty_out(vty
, " Peer-group members:\n");
12024 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
12025 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
12026 peer_status
= "Idle (Admin)";
12027 else if (CHECK_FLAG(peer
->sflags
,
12028 PEER_STATUS_PREFIX_OVERFLOW
))
12029 peer_status
= "Idle (PfxCt)";
12031 peer_status
= lookup_msg(bgp_status_msg
,
12032 peer
->status
, NULL
);
12034 dynamic
= peer_dynamic_neighbor(peer
);
12035 vty_out(vty
, " %s %s %s \n", peer
->host
,
12036 dynamic
? "(dynamic)" : "", peer_status
);
12040 return CMD_SUCCESS
;
12043 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
12044 const char *group_name
)
12047 struct listnode
*node
, *nnode
;
12048 struct peer_group
*group
;
12049 bool found
= false;
12051 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
12054 vty_out(vty
, "%% BGP instance not found\n");
12055 return CMD_WARNING
;
12058 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
12060 if (strmatch(group
->name
, group_name
)) {
12061 bgp_show_one_peer_group(vty
, group
);
12066 bgp_show_one_peer_group(vty
, group
);
12070 if (group_name
&& !found
)
12071 vty_out(vty
, "%% No such peer-group\n");
12073 return CMD_SUCCESS
;
12076 DEFUN (show_ip_bgp_peer_groups
,
12077 show_ip_bgp_peer_groups_cmd
,
12078 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
12082 BGP_INSTANCE_HELP_STR
12083 "Detailed information on BGP peer groups\n"
12084 "Peer group name\n")
12089 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
12091 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
12093 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
12097 /* Redistribute VTY commands. */
12099 DEFUN (bgp_redistribute_ipv4
,
12100 bgp_redistribute_ipv4_cmd
,
12101 "redistribute " FRR_IP_REDIST_STR_BGPD
,
12102 "Redistribute information from another routing protocol\n"
12103 FRR_IP_REDIST_HELP_STR_BGPD
)
12105 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12106 int idx_protocol
= 1;
12109 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12111 vty_out(vty
, "%% Invalid route type\n");
12112 return CMD_WARNING_CONFIG_FAILED
;
12115 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12116 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
12120 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
12121 "redistribute " FRR_IP_REDIST_STR_BGPD
,
12122 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
12124 DEFUN (bgp_redistribute_ipv4_rmap
,
12125 bgp_redistribute_ipv4_rmap_cmd
,
12126 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
12127 "Redistribute information from another routing protocol\n"
12128 FRR_IP_REDIST_HELP_STR_BGPD
12129 "Route map reference\n"
12130 "Pointer to route-map entries\n")
12132 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12133 int idx_protocol
= 1;
12136 struct bgp_redist
*red
;
12138 struct route_map
*route_map
= route_map_lookup_warn_noexist(
12139 vty
, argv
[idx_word
]->arg
);
12141 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12143 vty_out(vty
, "%% Invalid route type\n");
12144 return CMD_WARNING_CONFIG_FAILED
;
12147 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12149 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12150 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12154 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
12155 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
12156 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12157 "Route map reference\n"
12158 "Pointer to route-map entries\n")
12160 DEFUN (bgp_redistribute_ipv4_metric
,
12161 bgp_redistribute_ipv4_metric_cmd
,
12162 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12163 "Redistribute information from another routing protocol\n"
12164 FRR_IP_REDIST_HELP_STR_BGPD
12165 "Metric for redistributed routes\n"
12166 "Default metric\n")
12168 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12169 int idx_protocol
= 1;
12170 int idx_number
= 3;
12173 struct bgp_redist
*red
;
12176 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12178 vty_out(vty
, "%% Invalid route type\n");
12179 return CMD_WARNING_CONFIG_FAILED
;
12181 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12183 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12184 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12185 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12189 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
12190 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12191 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12192 "Metric for redistributed routes\n"
12193 "Default metric\n")
12195 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
12196 bgp_redistribute_ipv4_rmap_metric_cmd
,
12197 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12198 "Redistribute information from another routing protocol\n"
12199 FRR_IP_REDIST_HELP_STR_BGPD
12200 "Route map reference\n"
12201 "Pointer to route-map entries\n"
12202 "Metric for redistributed routes\n"
12203 "Default metric\n")
12205 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12206 int idx_protocol
= 1;
12208 int idx_number
= 5;
12211 struct bgp_redist
*red
;
12213 struct route_map
*route_map
=
12214 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12216 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12218 vty_out(vty
, "%% Invalid route type\n");
12219 return CMD_WARNING_CONFIG_FAILED
;
12221 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12223 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12225 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12226 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12227 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12231 bgp_redistribute_ipv4_rmap_metric
,
12232 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
12233 "redistribute " FRR_IP_REDIST_STR_BGPD
12234 " route-map WORD metric (0-4294967295)",
12235 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12236 "Route map reference\n"
12237 "Pointer to route-map entries\n"
12238 "Metric for redistributed routes\n"
12239 "Default metric\n")
12241 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
12242 bgp_redistribute_ipv4_metric_rmap_cmd
,
12243 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12244 "Redistribute information from another routing protocol\n"
12245 FRR_IP_REDIST_HELP_STR_BGPD
12246 "Metric for redistributed routes\n"
12248 "Route map reference\n"
12249 "Pointer to route-map entries\n")
12251 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12252 int idx_protocol
= 1;
12253 int idx_number
= 3;
12257 struct bgp_redist
*red
;
12259 struct route_map
*route_map
=
12260 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12262 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12264 vty_out(vty
, "%% Invalid route type\n");
12265 return CMD_WARNING_CONFIG_FAILED
;
12267 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12269 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12270 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12272 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12273 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12277 bgp_redistribute_ipv4_metric_rmap
,
12278 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
12279 "redistribute " FRR_IP_REDIST_STR_BGPD
12280 " metric (0-4294967295) route-map WORD",
12281 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12282 "Metric for redistributed routes\n"
12284 "Route map reference\n"
12285 "Pointer to route-map entries\n")
12287 DEFUN (bgp_redistribute_ipv4_ospf
,
12288 bgp_redistribute_ipv4_ospf_cmd
,
12289 "redistribute <ospf|table> (1-65535)",
12290 "Redistribute information from another routing protocol\n"
12291 "Open Shortest Path First (OSPFv2)\n"
12292 "Non-main Kernel Routing Table\n"
12293 "Instance ID/Table ID\n")
12295 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12296 int idx_ospf_table
= 1;
12297 int idx_number
= 2;
12298 unsigned short instance
;
12299 unsigned short protocol
;
12301 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12303 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12304 protocol
= ZEBRA_ROUTE_OSPF
;
12306 protocol
= ZEBRA_ROUTE_TABLE
;
12308 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12309 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
12312 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
12313 "redistribute <ospf|table> (1-65535)",
12314 "Redistribute information from another routing protocol\n"
12315 "Open Shortest Path First (OSPFv2)\n"
12316 "Non-main Kernel Routing Table\n"
12317 "Instance ID/Table ID\n")
12319 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
12320 bgp_redistribute_ipv4_ospf_rmap_cmd
,
12321 "redistribute <ospf|table> (1-65535) route-map WORD",
12322 "Redistribute information from another routing protocol\n"
12323 "Open Shortest Path First (OSPFv2)\n"
12324 "Non-main Kernel Routing Table\n"
12325 "Instance ID/Table ID\n"
12326 "Route map reference\n"
12327 "Pointer to route-map entries\n")
12329 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12330 int idx_ospf_table
= 1;
12331 int idx_number
= 2;
12333 struct bgp_redist
*red
;
12334 unsigned short instance
;
12337 struct route_map
*route_map
=
12338 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12340 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12341 protocol
= ZEBRA_ROUTE_OSPF
;
12343 protocol
= ZEBRA_ROUTE_TABLE
;
12345 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12346 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12348 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12349 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12352 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
12353 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
12354 "redistribute <ospf|table> (1-65535) route-map WORD",
12355 "Redistribute information from another routing protocol\n"
12356 "Open Shortest Path First (OSPFv2)\n"
12357 "Non-main Kernel Routing Table\n"
12358 "Instance ID/Table ID\n"
12359 "Route map reference\n"
12360 "Pointer to route-map entries\n")
12362 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
12363 bgp_redistribute_ipv4_ospf_metric_cmd
,
12364 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12365 "Redistribute information from another routing protocol\n"
12366 "Open Shortest Path First (OSPFv2)\n"
12367 "Non-main Kernel Routing Table\n"
12368 "Instance ID/Table ID\n"
12369 "Metric for redistributed routes\n"
12370 "Default metric\n")
12372 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12373 int idx_ospf_table
= 1;
12374 int idx_number
= 2;
12375 int idx_number_2
= 4;
12377 struct bgp_redist
*red
;
12378 unsigned short instance
;
12382 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12383 protocol
= ZEBRA_ROUTE_OSPF
;
12385 protocol
= ZEBRA_ROUTE_TABLE
;
12387 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12388 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12390 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12391 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12393 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12396 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
12397 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
12398 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12399 "Redistribute information from another routing protocol\n"
12400 "Open Shortest Path First (OSPFv2)\n"
12401 "Non-main Kernel Routing Table\n"
12402 "Instance ID/Table ID\n"
12403 "Metric for redistributed routes\n"
12404 "Default metric\n")
12406 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
12407 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
12408 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12409 "Redistribute information from another routing protocol\n"
12410 "Open Shortest Path First (OSPFv2)\n"
12411 "Non-main Kernel Routing Table\n"
12412 "Instance ID/Table ID\n"
12413 "Route map reference\n"
12414 "Pointer to route-map entries\n"
12415 "Metric for redistributed routes\n"
12416 "Default metric\n")
12418 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12419 int idx_ospf_table
= 1;
12420 int idx_number
= 2;
12422 int idx_number_2
= 6;
12424 struct bgp_redist
*red
;
12425 unsigned short instance
;
12428 struct route_map
*route_map
=
12429 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12431 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12432 protocol
= ZEBRA_ROUTE_OSPF
;
12434 protocol
= ZEBRA_ROUTE_TABLE
;
12436 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12437 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12439 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12441 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12442 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12444 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12448 bgp_redistribute_ipv4_ospf_rmap_metric
,
12449 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
12450 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12451 "Redistribute information from another routing protocol\n"
12452 "Open Shortest Path First (OSPFv2)\n"
12453 "Non-main Kernel Routing Table\n"
12454 "Instance ID/Table ID\n"
12455 "Route map reference\n"
12456 "Pointer to route-map entries\n"
12457 "Metric for redistributed routes\n"
12458 "Default metric\n")
12460 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
12461 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
12462 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12463 "Redistribute information from another routing protocol\n"
12464 "Open Shortest Path First (OSPFv2)\n"
12465 "Non-main Kernel Routing Table\n"
12466 "Instance ID/Table ID\n"
12467 "Metric for redistributed routes\n"
12469 "Route map reference\n"
12470 "Pointer to route-map entries\n")
12472 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12473 int idx_ospf_table
= 1;
12474 int idx_number
= 2;
12475 int idx_number_2
= 4;
12478 struct bgp_redist
*red
;
12479 unsigned short instance
;
12482 struct route_map
*route_map
=
12483 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12485 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12486 protocol
= ZEBRA_ROUTE_OSPF
;
12488 protocol
= ZEBRA_ROUTE_TABLE
;
12490 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12491 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12493 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12494 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12497 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12498 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12502 bgp_redistribute_ipv4_ospf_metric_rmap
,
12503 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
12504 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12505 "Redistribute information from another routing protocol\n"
12506 "Open Shortest Path First (OSPFv2)\n"
12507 "Non-main Kernel Routing Table\n"
12508 "Instance ID/Table ID\n"
12509 "Metric for redistributed routes\n"
12511 "Route map reference\n"
12512 "Pointer to route-map entries\n")
12514 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12515 no_bgp_redistribute_ipv4_ospf_cmd
,
12516 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
12518 "Redistribute information from another routing protocol\n"
12519 "Open Shortest Path First (OSPFv2)\n"
12520 "Non-main Kernel Routing Table\n"
12521 "Instance ID/Table ID\n"
12522 "Metric for redistributed routes\n"
12524 "Route map reference\n"
12525 "Pointer to route-map entries\n")
12527 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12528 int idx_ospf_table
= 2;
12529 int idx_number
= 3;
12530 unsigned short instance
;
12533 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12534 protocol
= ZEBRA_ROUTE_OSPF
;
12536 protocol
= ZEBRA_ROUTE_TABLE
;
12538 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12539 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12543 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12544 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
12546 "Redistribute information from another routing protocol\n"
12547 "Open Shortest Path First (OSPFv2)\n"
12548 "Non-main Kernel Routing Table\n"
12549 "Instance ID/Table ID\n"
12550 "Metric for redistributed routes\n"
12552 "Route map reference\n"
12553 "Pointer to route-map entries\n")
12555 DEFUN (no_bgp_redistribute_ipv4
,
12556 no_bgp_redistribute_ipv4_cmd
,
12557 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
12559 "Redistribute information from another routing protocol\n"
12560 FRR_IP_REDIST_HELP_STR_BGPD
12561 "Metric for redistributed routes\n"
12563 "Route map reference\n"
12564 "Pointer to route-map entries\n")
12566 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12567 int idx_protocol
= 2;
12570 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12572 vty_out(vty
, "%% Invalid route type\n");
12573 return CMD_WARNING_CONFIG_FAILED
;
12575 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12579 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12580 "no redistribute " FRR_IP_REDIST_STR_BGPD
12581 " [{metric (0-4294967295)|route-map WORD}]",
12583 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12584 "Metric for redistributed routes\n"
12586 "Route map reference\n"
12587 "Pointer to route-map entries\n")
12589 DEFUN (bgp_redistribute_ipv6
,
12590 bgp_redistribute_ipv6_cmd
,
12591 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12592 "Redistribute information from another routing protocol\n"
12593 FRR_IP6_REDIST_HELP_STR_BGPD
)
12595 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12596 int idx_protocol
= 1;
12599 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12601 vty_out(vty
, "%% Invalid route type\n");
12602 return CMD_WARNING_CONFIG_FAILED
;
12605 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12606 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12609 DEFUN (bgp_redistribute_ipv6_rmap
,
12610 bgp_redistribute_ipv6_rmap_cmd
,
12611 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12612 "Redistribute information from another routing protocol\n"
12613 FRR_IP6_REDIST_HELP_STR_BGPD
12614 "Route map reference\n"
12615 "Pointer to route-map entries\n")
12617 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12618 int idx_protocol
= 1;
12621 struct bgp_redist
*red
;
12623 struct route_map
*route_map
=
12624 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12626 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12628 vty_out(vty
, "%% Invalid route type\n");
12629 return CMD_WARNING_CONFIG_FAILED
;
12632 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12634 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12635 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12638 DEFUN (bgp_redistribute_ipv6_metric
,
12639 bgp_redistribute_ipv6_metric_cmd
,
12640 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12641 "Redistribute information from another routing protocol\n"
12642 FRR_IP6_REDIST_HELP_STR_BGPD
12643 "Metric for redistributed routes\n"
12644 "Default metric\n")
12646 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12647 int idx_protocol
= 1;
12648 int idx_number
= 3;
12651 struct bgp_redist
*red
;
12654 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12656 vty_out(vty
, "%% Invalid route type\n");
12657 return CMD_WARNING_CONFIG_FAILED
;
12659 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12661 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12662 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12663 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12666 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12667 bgp_redistribute_ipv6_rmap_metric_cmd
,
12668 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12669 "Redistribute information from another routing protocol\n"
12670 FRR_IP6_REDIST_HELP_STR_BGPD
12671 "Route map reference\n"
12672 "Pointer to route-map entries\n"
12673 "Metric for redistributed routes\n"
12674 "Default metric\n")
12676 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12677 int idx_protocol
= 1;
12679 int idx_number
= 5;
12682 struct bgp_redist
*red
;
12684 struct route_map
*route_map
=
12685 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12687 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12689 vty_out(vty
, "%% Invalid route type\n");
12690 return CMD_WARNING_CONFIG_FAILED
;
12692 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12694 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12696 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12697 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12699 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12702 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12703 bgp_redistribute_ipv6_metric_rmap_cmd
,
12704 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12705 "Redistribute information from another routing protocol\n"
12706 FRR_IP6_REDIST_HELP_STR_BGPD
12707 "Metric for redistributed routes\n"
12709 "Route map reference\n"
12710 "Pointer to route-map entries\n")
12712 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12713 int idx_protocol
= 1;
12714 int idx_number
= 3;
12718 struct bgp_redist
*red
;
12720 struct route_map
*route_map
=
12721 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12723 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12725 vty_out(vty
, "%% Invalid route type\n");
12726 return CMD_WARNING_CONFIG_FAILED
;
12728 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12730 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12731 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12734 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12735 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12738 DEFUN (no_bgp_redistribute_ipv6
,
12739 no_bgp_redistribute_ipv6_cmd
,
12740 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
12742 "Redistribute information from another routing protocol\n"
12743 FRR_IP6_REDIST_HELP_STR_BGPD
12744 "Metric for redistributed routes\n"
12746 "Route map reference\n"
12747 "Pointer to route-map entries\n")
12749 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12750 int idx_protocol
= 2;
12753 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12755 vty_out(vty
, "%% Invalid route type\n");
12756 return CMD_WARNING_CONFIG_FAILED
;
12759 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12762 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12767 /* Unicast redistribution only. */
12768 if (safi
!= SAFI_UNICAST
)
12771 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12772 /* Redistribute BGP does not make sense. */
12773 if (i
!= ZEBRA_ROUTE_BGP
) {
12774 struct list
*red_list
;
12775 struct listnode
*node
;
12776 struct bgp_redist
*red
;
12778 red_list
= bgp
->redist
[afi
][i
];
12782 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12783 /* "redistribute" configuration. */
12784 vty_out(vty
, " redistribute %s",
12785 zebra_route_string(i
));
12787 vty_out(vty
, " %d", red
->instance
);
12788 if (red
->redist_metric_flag
)
12789 vty_out(vty
, " metric %u",
12790 red
->redist_metric
);
12791 if (red
->rmap
.name
)
12792 vty_out(vty
, " route-map %s",
12794 vty_out(vty
, "\n");
12800 /* This is part of the address-family block (unicast only) */
12801 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12806 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12807 if (listcount(bgp
->vpn_policy
[afi
].import_vrf
))
12808 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12809 bgp
->vpn_policy
[afi
]
12810 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12812 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
12813 bgp
->vpn_policy
[afi
]
12814 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12816 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12817 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12818 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12819 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12822 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12823 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12825 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12828 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12829 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12830 bgp
->vpn_policy
[afi
].tovpn_label
);
12833 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12834 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12835 char buf
[RD_ADDRSTRLEN
];
12836 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12837 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12840 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12841 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12843 char buf
[PREFIX_STRLEN
];
12844 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12845 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12848 vty_out(vty
, "%*snexthop vpn export %s\n",
12852 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12853 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12855 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12856 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12858 char *b
= ecommunity_ecom2str(
12859 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12860 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12861 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12862 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12864 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12865 char *b
= ecommunity_ecom2str(
12866 bgp
->vpn_policy
[afi
]
12867 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12868 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12869 ECOMMUNITY_ROUTE_TARGET
);
12870 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12871 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12873 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12874 char *b
= ecommunity_ecom2str(
12875 bgp
->vpn_policy
[afi
]
12876 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12877 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12878 ECOMMUNITY_ROUTE_TARGET
);
12879 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12880 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12884 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12885 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12886 bgp
->vpn_policy
[afi
]
12887 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12889 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12890 char *b
= ecommunity_ecom2str(
12891 bgp
->vpn_policy
[afi
]
12892 .import_redirect_rtlist
,
12893 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12894 ECOMMUNITY_ROUTE_TARGET
);
12896 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12897 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12902 /* BGP node structure. */
12903 static struct cmd_node bgp_node
= {
12904 BGP_NODE
, "%s(config-router)# ", 1,
12907 static struct cmd_node bgp_ipv4_unicast_node
= {
12908 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12911 static struct cmd_node bgp_ipv4_multicast_node
= {
12912 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12915 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12916 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12919 static struct cmd_node bgp_ipv6_unicast_node
= {
12920 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12923 static struct cmd_node bgp_ipv6_multicast_node
= {
12924 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12927 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12928 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12931 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12932 "%s(config-router-af)# ", 1};
12934 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12935 "%s(config-router-af-vpnv6)# ", 1};
12937 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12938 "%s(config-router-evpn)# ", 1};
12940 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12941 "%s(config-router-af-vni)# ", 1};
12943 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12944 "%s(config-router-af)# ", 1};
12946 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12947 "%s(config-router-af-vpnv6)# ", 1};
12949 static void community_list_vty(void);
12951 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12955 struct listnode
*lnbgp
, *lnpeer
;
12957 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12958 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12959 /* only provide suggestions on the appropriate input
12961 * they'll otherwise show up multiple times */
12962 enum cmd_token_type match_type
;
12963 char *name
= peer
->host
;
12965 if (peer
->conf_if
) {
12966 match_type
= VARIABLE_TKN
;
12967 name
= peer
->conf_if
;
12968 } else if (strchr(peer
->host
, ':'))
12969 match_type
= IPV6_TKN
;
12971 match_type
= IPV4_TKN
;
12973 if (token
->type
!= match_type
)
12976 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12981 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12982 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12983 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12984 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12985 {.completions
= NULL
}};
12987 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12990 struct peer_group
*group
;
12991 struct listnode
*lnbgp
, *lnpeer
;
12993 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12994 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12995 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
13000 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
13001 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
13002 {.completions
= NULL
} };
13004 void bgp_vty_init(void)
13006 cmd_variable_handler_register(bgp_var_neighbor
);
13007 cmd_variable_handler_register(bgp_var_peergroup
);
13009 /* Install bgp top node. */
13010 install_node(&bgp_node
, bgp_config_write
);
13011 install_node(&bgp_ipv4_unicast_node
, NULL
);
13012 install_node(&bgp_ipv4_multicast_node
, NULL
);
13013 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
13014 install_node(&bgp_ipv6_unicast_node
, NULL
);
13015 install_node(&bgp_ipv6_multicast_node
, NULL
);
13016 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
13017 install_node(&bgp_vpnv4_node
, NULL
);
13018 install_node(&bgp_vpnv6_node
, NULL
);
13019 install_node(&bgp_evpn_node
, NULL
);
13020 install_node(&bgp_evpn_vni_node
, NULL
);
13021 install_node(&bgp_flowspecv4_node
, NULL
);
13022 install_node(&bgp_flowspecv6_node
, NULL
);
13024 /* Install default VTY commands to new nodes. */
13025 install_default(BGP_NODE
);
13026 install_default(BGP_IPV4_NODE
);
13027 install_default(BGP_IPV4M_NODE
);
13028 install_default(BGP_IPV4L_NODE
);
13029 install_default(BGP_IPV6_NODE
);
13030 install_default(BGP_IPV6M_NODE
);
13031 install_default(BGP_IPV6L_NODE
);
13032 install_default(BGP_VPNV4_NODE
);
13033 install_default(BGP_VPNV6_NODE
);
13034 install_default(BGP_FLOWSPECV4_NODE
);
13035 install_default(BGP_FLOWSPECV6_NODE
);
13036 install_default(BGP_EVPN_NODE
);
13037 install_default(BGP_EVPN_VNI_NODE
);
13039 /* "bgp local-mac" hidden commands. */
13040 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
13041 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
13043 /* bgp route-map delay-timer commands. */
13044 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
13045 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
13047 /* Dummy commands (Currently not supported) */
13048 install_element(BGP_NODE
, &no_synchronization_cmd
);
13049 install_element(BGP_NODE
, &no_auto_summary_cmd
);
13051 /* "router bgp" commands. */
13052 install_element(CONFIG_NODE
, &router_bgp_cmd
);
13054 /* "no router bgp" commands. */
13055 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
13057 /* "bgp router-id" commands. */
13058 install_element(BGP_NODE
, &bgp_router_id_cmd
);
13059 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
13061 /* "bgp cluster-id" commands. */
13062 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
13063 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
13065 /* "bgp confederation" commands. */
13066 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
13067 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
13069 /* "bgp confederation peers" commands. */
13070 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
13071 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
13073 /* bgp max-med command */
13074 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
13075 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
13076 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
13077 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
13078 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
13080 /* bgp disable-ebgp-connected-nh-check */
13081 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
13082 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
13084 /* bgp update-delay command */
13085 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
13086 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
13087 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
13089 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
13090 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
13092 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
13093 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
13095 /* "maximum-paths" commands. */
13096 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
13097 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
13098 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
13099 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
13100 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
13101 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
13102 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
13103 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
13104 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
13105 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
13106 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
13107 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
13108 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
13109 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
13110 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
13112 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
13113 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
13114 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
13115 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
13116 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
13118 /* "timers bgp" commands. */
13119 install_element(BGP_NODE
, &bgp_timers_cmd
);
13120 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
13122 /* route-map delay-timer commands - per instance for backwards compat.
13124 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
13125 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
13127 /* "bgp client-to-client reflection" commands */
13128 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
13129 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
13131 /* "bgp always-compare-med" commands */
13132 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
13133 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
13135 /* bgp ebgp-requires-policy */
13136 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
13137 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
13139 /* "bgp deterministic-med" commands */
13140 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
13141 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
13143 /* "bgp graceful-restart" commands */
13144 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
13145 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
13146 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
13147 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
13148 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
13149 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
13151 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
13152 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
13154 /* "bgp graceful-shutdown" commands */
13155 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
13156 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
13158 /* "bgp fast-external-failover" commands */
13159 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
13160 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
13162 /* "bgp bestpath compare-routerid" commands */
13163 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
13164 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
13166 /* "bgp bestpath as-path ignore" commands */
13167 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
13168 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
13170 /* "bgp bestpath as-path confed" commands */
13171 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
13172 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
13174 /* "bgp bestpath as-path multipath-relax" commands */
13175 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
13176 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
13178 /* "bgp log-neighbor-changes" commands */
13179 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
13180 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
13182 /* "bgp bestpath med" commands */
13183 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
13184 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
13186 /* "no bgp default ipv4-unicast" commands. */
13187 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
13188 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
13190 /* "bgp network import-check" commands. */
13191 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
13192 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
13193 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
13195 /* "bgp default local-preference" commands. */
13196 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
13197 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
13199 /* bgp default show-hostname */
13200 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
13201 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
13203 /* "bgp default subgroup-pkt-queue-max" commands. */
13204 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
13205 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
13207 /* bgp ibgp-allow-policy-mods command */
13208 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
13209 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
13211 /* "bgp listen limit" commands. */
13212 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
13213 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
13215 /* "bgp listen range" commands. */
13216 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
13217 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
13219 /* "bgp default shutdown" command */
13220 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
13222 /* "neighbor remote-as" commands. */
13223 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
13224 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
13225 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
13226 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
13227 install_element(BGP_NODE
,
13228 &neighbor_interface_v6only_config_remote_as_cmd
);
13229 install_element(BGP_NODE
, &no_neighbor_cmd
);
13230 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
13232 /* "neighbor peer-group" commands. */
13233 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
13234 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
13235 install_element(BGP_NODE
,
13236 &no_neighbor_interface_peer_group_remote_as_cmd
);
13238 /* "neighbor local-as" commands. */
13239 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
13240 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
13241 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
13242 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
13244 /* "neighbor solo" commands. */
13245 install_element(BGP_NODE
, &neighbor_solo_cmd
);
13246 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
13248 /* "neighbor password" commands. */
13249 install_element(BGP_NODE
, &neighbor_password_cmd
);
13250 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
13252 /* "neighbor activate" commands. */
13253 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
13254 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
13255 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
13256 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
13257 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
13258 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
13259 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
13260 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
13261 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
13262 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
13263 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
13264 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
13266 /* "no neighbor activate" commands. */
13267 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
13268 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
13269 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
13270 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
13271 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
13272 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
13273 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
13274 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
13275 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
13276 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
13277 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
13278 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
13280 /* "neighbor peer-group" set commands. */
13281 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
13282 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13283 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13284 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13285 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13286 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13287 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13288 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13289 install_element(BGP_FLOWSPECV4_NODE
,
13290 &neighbor_set_peer_group_hidden_cmd
);
13291 install_element(BGP_FLOWSPECV6_NODE
,
13292 &neighbor_set_peer_group_hidden_cmd
);
13294 /* "no neighbor peer-group unset" commands. */
13295 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
13296 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13297 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13298 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13299 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13300 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13301 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13302 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13303 install_element(BGP_FLOWSPECV4_NODE
,
13304 &no_neighbor_set_peer_group_hidden_cmd
);
13305 install_element(BGP_FLOWSPECV6_NODE
,
13306 &no_neighbor_set_peer_group_hidden_cmd
);
13308 /* "neighbor softreconfiguration inbound" commands.*/
13309 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
13310 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
13311 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13312 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13313 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13314 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13315 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13316 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13317 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13318 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13319 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13320 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13321 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13322 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13323 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13324 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13325 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13326 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13327 install_element(BGP_FLOWSPECV4_NODE
,
13328 &neighbor_soft_reconfiguration_cmd
);
13329 install_element(BGP_FLOWSPECV4_NODE
,
13330 &no_neighbor_soft_reconfiguration_cmd
);
13331 install_element(BGP_FLOWSPECV6_NODE
,
13332 &neighbor_soft_reconfiguration_cmd
);
13333 install_element(BGP_FLOWSPECV6_NODE
,
13334 &no_neighbor_soft_reconfiguration_cmd
);
13335 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
13336 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13338 /* "neighbor attribute-unchanged" commands. */
13339 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
13340 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
13341 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
13342 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13343 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
13344 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13345 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
13346 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13347 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
13348 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13349 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
13350 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13351 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
13352 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13353 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
13354 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13355 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
13356 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13358 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
13359 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
13361 /* "nexthop-local unchanged" commands */
13362 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
13363 install_element(BGP_IPV6_NODE
,
13364 &no_neighbor_nexthop_local_unchanged_cmd
);
13366 /* "neighbor next-hop-self" commands. */
13367 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
13368 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
13369 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
13370 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13371 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
13372 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
13373 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
13374 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
13375 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
13376 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13377 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
13378 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
13379 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
13380 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
13381 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
13382 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13383 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
13384 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13385 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
13386 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
13388 /* "neighbor next-hop-self force" commands. */
13389 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
13390 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
13391 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13392 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
13393 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13394 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13395 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13396 install_element(BGP_IPV4_NODE
,
13397 &no_neighbor_nexthop_self_all_hidden_cmd
);
13398 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
13399 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13400 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13401 install_element(BGP_IPV4M_NODE
,
13402 &no_neighbor_nexthop_self_all_hidden_cmd
);
13403 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
13404 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13405 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13406 install_element(BGP_IPV4L_NODE
,
13407 &no_neighbor_nexthop_self_all_hidden_cmd
);
13408 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13409 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13410 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13411 install_element(BGP_IPV6_NODE
,
13412 &no_neighbor_nexthop_self_all_hidden_cmd
);
13413 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
13414 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13415 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13416 install_element(BGP_IPV6M_NODE
,
13417 &no_neighbor_nexthop_self_all_hidden_cmd
);
13418 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
13419 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13420 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13421 install_element(BGP_IPV6L_NODE
,
13422 &no_neighbor_nexthop_self_all_hidden_cmd
);
13423 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13424 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13425 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13426 install_element(BGP_VPNV4_NODE
,
13427 &no_neighbor_nexthop_self_all_hidden_cmd
);
13428 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13429 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13430 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13431 install_element(BGP_VPNV6_NODE
,
13432 &no_neighbor_nexthop_self_all_hidden_cmd
);
13434 /* "neighbor as-override" commands. */
13435 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
13436 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
13437 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
13438 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
13439 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
13440 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
13441 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
13442 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
13443 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
13444 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
13445 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
13446 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
13447 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
13448 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
13449 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
13450 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
13451 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
13452 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
13454 /* "neighbor remove-private-AS" commands. */
13455 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
13456 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
13457 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
13458 install_element(BGP_NODE
,
13459 &no_neighbor_remove_private_as_all_hidden_cmd
);
13460 install_element(BGP_NODE
,
13461 &neighbor_remove_private_as_replace_as_hidden_cmd
);
13462 install_element(BGP_NODE
,
13463 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
13464 install_element(BGP_NODE
,
13465 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13468 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13469 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
13470 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13471 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13472 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13473 install_element(BGP_IPV4_NODE
,
13474 &neighbor_remove_private_as_replace_as_cmd
);
13475 install_element(BGP_IPV4_NODE
,
13476 &no_neighbor_remove_private_as_replace_as_cmd
);
13477 install_element(BGP_IPV4_NODE
,
13478 &neighbor_remove_private_as_all_replace_as_cmd
);
13479 install_element(BGP_IPV4_NODE
,
13480 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13481 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
13482 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
13483 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
13484 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13485 install_element(BGP_IPV4M_NODE
,
13486 &neighbor_remove_private_as_replace_as_cmd
);
13487 install_element(BGP_IPV4M_NODE
,
13488 &no_neighbor_remove_private_as_replace_as_cmd
);
13489 install_element(BGP_IPV4M_NODE
,
13490 &neighbor_remove_private_as_all_replace_as_cmd
);
13491 install_element(BGP_IPV4M_NODE
,
13492 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13493 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
13494 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
13495 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
13496 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13497 install_element(BGP_IPV4L_NODE
,
13498 &neighbor_remove_private_as_replace_as_cmd
);
13499 install_element(BGP_IPV4L_NODE
,
13500 &no_neighbor_remove_private_as_replace_as_cmd
);
13501 install_element(BGP_IPV4L_NODE
,
13502 &neighbor_remove_private_as_all_replace_as_cmd
);
13503 install_element(BGP_IPV4L_NODE
,
13504 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13505 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
13506 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13507 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13508 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13509 install_element(BGP_IPV6_NODE
,
13510 &neighbor_remove_private_as_replace_as_cmd
);
13511 install_element(BGP_IPV6_NODE
,
13512 &no_neighbor_remove_private_as_replace_as_cmd
);
13513 install_element(BGP_IPV6_NODE
,
13514 &neighbor_remove_private_as_all_replace_as_cmd
);
13515 install_element(BGP_IPV6_NODE
,
13516 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13517 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
13518 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
13519 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
13520 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13521 install_element(BGP_IPV6M_NODE
,
13522 &neighbor_remove_private_as_replace_as_cmd
);
13523 install_element(BGP_IPV6M_NODE
,
13524 &no_neighbor_remove_private_as_replace_as_cmd
);
13525 install_element(BGP_IPV6M_NODE
,
13526 &neighbor_remove_private_as_all_replace_as_cmd
);
13527 install_element(BGP_IPV6M_NODE
,
13528 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13529 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
13530 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
13531 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
13532 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13533 install_element(BGP_IPV6L_NODE
,
13534 &neighbor_remove_private_as_replace_as_cmd
);
13535 install_element(BGP_IPV6L_NODE
,
13536 &no_neighbor_remove_private_as_replace_as_cmd
);
13537 install_element(BGP_IPV6L_NODE
,
13538 &neighbor_remove_private_as_all_replace_as_cmd
);
13539 install_element(BGP_IPV6L_NODE
,
13540 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13541 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
13542 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13543 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13544 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13545 install_element(BGP_VPNV4_NODE
,
13546 &neighbor_remove_private_as_replace_as_cmd
);
13547 install_element(BGP_VPNV4_NODE
,
13548 &no_neighbor_remove_private_as_replace_as_cmd
);
13549 install_element(BGP_VPNV4_NODE
,
13550 &neighbor_remove_private_as_all_replace_as_cmd
);
13551 install_element(BGP_VPNV4_NODE
,
13552 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13553 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
13554 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13555 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13556 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13557 install_element(BGP_VPNV6_NODE
,
13558 &neighbor_remove_private_as_replace_as_cmd
);
13559 install_element(BGP_VPNV6_NODE
,
13560 &no_neighbor_remove_private_as_replace_as_cmd
);
13561 install_element(BGP_VPNV6_NODE
,
13562 &neighbor_remove_private_as_all_replace_as_cmd
);
13563 install_element(BGP_VPNV6_NODE
,
13564 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13566 /* "neighbor send-community" commands.*/
13567 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
13568 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
13569 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
13570 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
13571 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
13572 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
13573 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
13574 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
13575 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
13576 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
13577 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
13578 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
13579 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
13580 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
13581 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
13582 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
13583 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
13584 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
13585 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
13586 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
13587 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
13588 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
13589 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
13590 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
13591 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
13592 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
13593 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
13594 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
13595 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
13596 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
13597 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
13598 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
13599 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
13600 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
13601 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
13602 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
13604 /* "neighbor route-reflector" commands.*/
13605 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
13606 install_element(BGP_NODE
,
13607 &no_neighbor_route_reflector_client_hidden_cmd
);
13608 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
13609 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
13610 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
13611 install_element(BGP_IPV4M_NODE
,
13612 &no_neighbor_route_reflector_client_cmd
);
13613 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
13614 install_element(BGP_IPV4L_NODE
,
13615 &no_neighbor_route_reflector_client_cmd
);
13616 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
13617 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
13618 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
13619 install_element(BGP_IPV6M_NODE
,
13620 &no_neighbor_route_reflector_client_cmd
);
13621 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
13622 install_element(BGP_IPV6L_NODE
,
13623 &no_neighbor_route_reflector_client_cmd
);
13624 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
13625 install_element(BGP_VPNV4_NODE
,
13626 &no_neighbor_route_reflector_client_cmd
);
13627 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
13628 install_element(BGP_VPNV6_NODE
,
13629 &no_neighbor_route_reflector_client_cmd
);
13630 install_element(BGP_FLOWSPECV4_NODE
,
13631 &neighbor_route_reflector_client_cmd
);
13632 install_element(BGP_FLOWSPECV4_NODE
,
13633 &no_neighbor_route_reflector_client_cmd
);
13634 install_element(BGP_FLOWSPECV6_NODE
,
13635 &neighbor_route_reflector_client_cmd
);
13636 install_element(BGP_FLOWSPECV6_NODE
,
13637 &no_neighbor_route_reflector_client_cmd
);
13638 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
13639 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
13641 /* "neighbor route-server" commands.*/
13642 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
13643 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
13644 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
13645 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
13646 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
13647 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
13648 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
13649 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
13650 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
13651 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
13652 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
13653 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
13654 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
13655 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
13656 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
13657 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
13658 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
13659 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
13660 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
13661 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
13662 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
13663 install_element(BGP_FLOWSPECV4_NODE
,
13664 &no_neighbor_route_server_client_cmd
);
13665 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
13666 install_element(BGP_FLOWSPECV6_NODE
,
13667 &no_neighbor_route_server_client_cmd
);
13669 /* "neighbor addpath-tx-all-paths" commands.*/
13670 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
13671 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
13672 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13673 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13674 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13675 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13676 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13677 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13678 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13679 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13680 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13681 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13682 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13683 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13684 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13685 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13686 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13687 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13689 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
13690 install_element(BGP_NODE
,
13691 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13692 install_element(BGP_NODE
,
13693 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13694 install_element(BGP_IPV4_NODE
,
13695 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13696 install_element(BGP_IPV4_NODE
,
13697 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13698 install_element(BGP_IPV4M_NODE
,
13699 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13700 install_element(BGP_IPV4M_NODE
,
13701 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13702 install_element(BGP_IPV4L_NODE
,
13703 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13704 install_element(BGP_IPV4L_NODE
,
13705 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13706 install_element(BGP_IPV6_NODE
,
13707 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13708 install_element(BGP_IPV6_NODE
,
13709 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13710 install_element(BGP_IPV6M_NODE
,
13711 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13712 install_element(BGP_IPV6M_NODE
,
13713 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13714 install_element(BGP_IPV6L_NODE
,
13715 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13716 install_element(BGP_IPV6L_NODE
,
13717 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13718 install_element(BGP_VPNV4_NODE
,
13719 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13720 install_element(BGP_VPNV4_NODE
,
13721 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13722 install_element(BGP_VPNV6_NODE
,
13723 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13724 install_element(BGP_VPNV6_NODE
,
13725 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13727 /* "neighbor sender-as-path-loop-detection" commands. */
13728 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
13729 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
13731 /* "neighbor passive" commands. */
13732 install_element(BGP_NODE
, &neighbor_passive_cmd
);
13733 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13736 /* "neighbor shutdown" commands. */
13737 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13738 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13739 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13740 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13742 /* "neighbor capability extended-nexthop" commands.*/
13743 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13744 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13746 /* "neighbor capability orf prefix-list" commands.*/
13747 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13748 install_element(BGP_NODE
,
13749 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13750 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13751 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13752 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13753 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13754 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13755 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13756 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13757 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13758 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13759 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13760 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13761 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13763 /* "neighbor capability dynamic" commands.*/
13764 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13765 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13767 /* "neighbor dont-capability-negotiate" commands. */
13768 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13769 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13771 /* "neighbor ebgp-multihop" commands. */
13772 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13773 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13774 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13776 /* "neighbor disable-connected-check" commands. */
13777 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13778 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13780 /* "neighbor enforce-first-as" commands. */
13781 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13782 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13784 /* "neighbor description" commands. */
13785 install_element(BGP_NODE
, &neighbor_description_cmd
);
13786 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13787 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13789 /* "neighbor update-source" commands. "*/
13790 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13791 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13793 /* "neighbor default-originate" commands. */
13794 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13795 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13796 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13797 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13798 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13799 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13800 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13801 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13802 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13803 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13804 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13805 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13806 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13807 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13808 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13809 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13810 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13811 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13812 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13813 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13814 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13816 /* "neighbor port" commands. */
13817 install_element(BGP_NODE
, &neighbor_port_cmd
);
13818 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13820 /* "neighbor weight" commands. */
13821 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13822 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13824 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13825 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13826 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13827 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13828 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13829 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13830 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13831 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13832 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13833 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13834 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13835 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13836 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13837 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13838 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13839 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13841 /* "neighbor override-capability" commands. */
13842 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13843 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13845 /* "neighbor strict-capability-match" commands. */
13846 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13847 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13849 /* "neighbor timers" commands. */
13850 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13851 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13853 /* "neighbor timers connect" commands. */
13854 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13855 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13857 /* "neighbor advertisement-interval" commands. */
13858 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13859 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13861 /* "neighbor interface" commands. */
13862 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13863 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13865 /* "neighbor distribute" commands. */
13866 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13867 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13868 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13869 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13870 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13871 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13872 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13873 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13874 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13875 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13876 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13877 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13878 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13879 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13880 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13881 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13882 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13883 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13885 /* "neighbor prefix-list" commands. */
13886 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13887 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13888 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13889 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13890 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13891 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13892 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13893 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13894 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13895 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13896 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13897 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13898 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13899 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13900 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13901 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13902 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13903 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13904 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13905 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13906 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13907 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13909 /* "neighbor filter-list" commands. */
13910 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13911 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13912 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13913 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13914 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13915 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13916 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13917 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13918 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13919 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13920 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13921 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13922 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13923 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13924 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13925 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13926 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13927 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13928 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13929 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13930 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13931 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13933 /* "neighbor route-map" commands. */
13934 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13935 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13936 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13937 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13938 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13939 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13940 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13941 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13942 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13943 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13944 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13945 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13946 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13947 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13948 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13949 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13950 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13951 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13952 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13953 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13954 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13955 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13956 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13957 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13959 /* "neighbor unsuppress-map" commands. */
13960 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13961 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13962 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13963 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13964 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13965 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13966 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13967 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13968 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13969 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13970 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13971 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13972 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13973 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13974 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13975 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13976 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13977 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13979 /* "neighbor maximum-prefix" commands. */
13980 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13981 install_element(BGP_NODE
,
13982 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13983 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13984 install_element(BGP_NODE
,
13985 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13986 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13987 install_element(BGP_NODE
,
13988 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13989 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13990 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13991 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13992 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13993 install_element(BGP_IPV4_NODE
,
13994 &neighbor_maximum_prefix_threshold_warning_cmd
);
13995 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13996 install_element(BGP_IPV4_NODE
,
13997 &neighbor_maximum_prefix_threshold_restart_cmd
);
13998 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13999 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
14000 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14001 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14002 install_element(BGP_IPV4M_NODE
,
14003 &neighbor_maximum_prefix_threshold_warning_cmd
);
14004 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14005 install_element(BGP_IPV4M_NODE
,
14006 &neighbor_maximum_prefix_threshold_restart_cmd
);
14007 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
14008 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
14009 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14010 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14011 install_element(BGP_IPV4L_NODE
,
14012 &neighbor_maximum_prefix_threshold_warning_cmd
);
14013 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14014 install_element(BGP_IPV4L_NODE
,
14015 &neighbor_maximum_prefix_threshold_restart_cmd
);
14016 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
14017 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
14018 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14019 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14020 install_element(BGP_IPV6_NODE
,
14021 &neighbor_maximum_prefix_threshold_warning_cmd
);
14022 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14023 install_element(BGP_IPV6_NODE
,
14024 &neighbor_maximum_prefix_threshold_restart_cmd
);
14025 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
14026 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
14027 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14028 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14029 install_element(BGP_IPV6M_NODE
,
14030 &neighbor_maximum_prefix_threshold_warning_cmd
);
14031 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14032 install_element(BGP_IPV6M_NODE
,
14033 &neighbor_maximum_prefix_threshold_restart_cmd
);
14034 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
14035 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
14036 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14037 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14038 install_element(BGP_IPV6L_NODE
,
14039 &neighbor_maximum_prefix_threshold_warning_cmd
);
14040 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14041 install_element(BGP_IPV6L_NODE
,
14042 &neighbor_maximum_prefix_threshold_restart_cmd
);
14043 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
14044 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
14045 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14046 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14047 install_element(BGP_VPNV4_NODE
,
14048 &neighbor_maximum_prefix_threshold_warning_cmd
);
14049 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14050 install_element(BGP_VPNV4_NODE
,
14051 &neighbor_maximum_prefix_threshold_restart_cmd
);
14052 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
14053 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
14054 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14055 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14056 install_element(BGP_VPNV6_NODE
,
14057 &neighbor_maximum_prefix_threshold_warning_cmd
);
14058 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14059 install_element(BGP_VPNV6_NODE
,
14060 &neighbor_maximum_prefix_threshold_restart_cmd
);
14061 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
14063 /* "neighbor allowas-in" */
14064 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
14065 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
14066 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
14067 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
14068 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
14069 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
14070 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
14071 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
14072 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
14073 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
14074 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
14075 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
14076 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
14077 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
14078 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
14079 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
14080 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
14081 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
14082 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
14083 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
14085 /* address-family commands. */
14086 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
14087 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
14088 #ifdef KEEP_OLD_VPN_COMMANDS
14089 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
14090 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
14091 #endif /* KEEP_OLD_VPN_COMMANDS */
14093 install_element(BGP_NODE
, &address_family_evpn_cmd
);
14095 /* "exit-address-family" command. */
14096 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
14097 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
14098 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
14099 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
14100 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
14101 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
14102 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
14103 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
14104 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
14105 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
14106 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
14108 /* "clear ip bgp commands" */
14109 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
14111 /* clear ip bgp prefix */
14112 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
14113 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
14114 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
14116 /* "show [ip] bgp summary" commands. */
14117 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
14118 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
14119 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
14120 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
14121 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
14122 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
14123 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
14125 /* "show [ip] bgp neighbors" commands. */
14126 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
14128 /* "show [ip] bgp peer-group" commands. */
14129 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
14131 /* "show [ip] bgp paths" commands. */
14132 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
14134 /* "show [ip] bgp community" commands. */
14135 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
14137 /* "show ip bgp large-community" commands. */
14138 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
14139 /* "show [ip] bgp attribute-info" commands. */
14140 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
14141 /* "show [ip] bgp route-leak" command */
14142 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
14144 /* "redistribute" commands. */
14145 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
14146 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
14147 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
14148 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
14149 install_element(BGP_NODE
,
14150 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
14151 install_element(BGP_NODE
,
14152 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
14153 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
14154 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
14155 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
14156 install_element(BGP_NODE
,
14157 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
14158 install_element(BGP_NODE
,
14159 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
14160 install_element(BGP_NODE
,
14161 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
14162 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
14163 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
14164 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
14165 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
14166 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
14167 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
14168 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
14169 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
14170 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
14171 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
14172 install_element(BGP_IPV4_NODE
,
14173 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
14174 install_element(BGP_IPV4_NODE
,
14175 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
14176 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
14177 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
14178 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
14179 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
14180 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
14181 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
14183 /* import|export vpn [route-map WORD] */
14184 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
14185 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
14187 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
14188 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
14190 /* ttl_security commands */
14191 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
14192 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
14194 /* "show [ip] bgp memory" commands. */
14195 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
14197 /* "show bgp martian next-hop" */
14198 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
14200 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
14202 /* "show [ip] bgp views" commands. */
14203 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
14205 /* "show [ip] bgp vrfs" commands. */
14206 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
14208 /* Community-list. */
14209 community_list_vty();
14211 /* vpn-policy commands */
14212 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
14213 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
14214 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
14215 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
14216 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
14217 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
14218 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
14219 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
14220 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
14221 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
14222 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
14223 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
14225 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
14226 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
14228 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
14229 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
14230 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
14231 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
14232 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
14233 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
14234 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
14235 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
14236 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14237 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14238 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
14239 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
14242 #include "memory.h"
14243 #include "bgp_regex.h"
14244 #include "bgp_clist.h"
14245 #include "bgp_ecommunity.h"
14247 /* VTY functions. */
14249 /* Direction value to string conversion. */
14250 static const char *community_direct_str(int direct
)
14253 case COMMUNITY_DENY
:
14255 case COMMUNITY_PERMIT
:
14262 /* Display error string. */
14263 static void community_list_perror(struct vty
*vty
, int ret
)
14266 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
14267 vty_out(vty
, "%% Can't find community-list\n");
14269 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
14270 vty_out(vty
, "%% Malformed community-list value\n");
14272 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
14274 "%% Community name conflict, previously defined as standard community\n");
14276 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
14278 "%% Community name conflict, previously defined as expanded community\n");
14283 /* "community-list" keyword help string. */
14284 #define COMMUNITY_LIST_STR "Add a community list entry\n"
14286 /*community-list standard */
14287 DEFUN (community_list_standard
,
14288 bgp_community_list_standard_cmd
,
14289 "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14292 "Community list number (standard)\n"
14293 "Add an standard community-list entry\n"
14294 "Community list name\n"
14295 "Specify community to reject\n"
14296 "Specify community to accept\n"
14299 char *cl_name_or_number
= NULL
;
14301 int style
= COMMUNITY_LIST_STANDARD
;
14304 argv_find(argv
, argc
, "(1-99)", &idx
);
14305 argv_find(argv
, argc
, "WORD", &idx
);
14306 cl_name_or_number
= argv
[idx
]->arg
;
14307 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14309 argv_find(argv
, argc
, "AA:NN", &idx
);
14310 char *str
= argv_concat(argv
, argc
, idx
);
14312 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14315 XFREE(MTYPE_TMP
, str
);
14318 /* Display error string. */
14319 community_list_perror(vty
, ret
);
14320 return CMD_WARNING_CONFIG_FAILED
;
14323 return CMD_SUCCESS
;
14326 DEFUN (no_community_list_standard_all
,
14327 no_bgp_community_list_standard_all_cmd
,
14328 "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14332 "Community list number (standard)\n"
14333 "Add an standard community-list entry\n"
14334 "Community list name\n"
14335 "Specify community to reject\n"
14336 "Specify community to accept\n"
14339 char *cl_name_or_number
= NULL
;
14342 int style
= COMMUNITY_LIST_STANDARD
;
14346 argv_find(argv
, argc
, "permit", &idx
);
14347 argv_find(argv
, argc
, "deny", &idx
);
14350 direct
= argv_find(argv
, argc
, "permit", &idx
)
14355 argv_find(argv
, argc
, "AA:NN", &idx
);
14356 str
= argv_concat(argv
, argc
, idx
);
14360 argv_find(argv
, argc
, "(1-99)", &idx
);
14361 argv_find(argv
, argc
, "WORD", &idx
);
14362 cl_name_or_number
= argv
[idx
]->arg
;
14364 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14367 XFREE(MTYPE_TMP
, str
);
14370 community_list_perror(vty
, ret
);
14371 return CMD_WARNING_CONFIG_FAILED
;
14374 return CMD_SUCCESS
;
14377 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
14378 "no bgp community-list <(1-99)|standard WORD>",
14379 NO_STR BGP_STR COMMUNITY_LIST_STR
14380 "Community list number (standard)\n"
14381 "Add an standard community-list entry\n"
14382 "Community list name\n")
14384 /*community-list expanded */
14385 DEFUN (community_list_expanded_all
,
14386 bgp_community_list_expanded_all_cmd
,
14387 "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14390 "Community list number (expanded)\n"
14391 "Add an expanded community-list entry\n"
14392 "Community list name\n"
14393 "Specify community to reject\n"
14394 "Specify community to accept\n"
14397 char *cl_name_or_number
= NULL
;
14399 int style
= COMMUNITY_LIST_EXPANDED
;
14403 argv_find(argv
, argc
, "(100-500)", &idx
);
14404 argv_find(argv
, argc
, "WORD", &idx
);
14405 cl_name_or_number
= argv
[idx
]->arg
;
14406 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14408 argv_find(argv
, argc
, "AA:NN", &idx
);
14409 char *str
= argv_concat(argv
, argc
, idx
);
14411 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14414 XFREE(MTYPE_TMP
, str
);
14417 /* Display error string. */
14418 community_list_perror(vty
, ret
);
14419 return CMD_WARNING_CONFIG_FAILED
;
14422 return CMD_SUCCESS
;
14425 DEFUN (no_community_list_expanded_all
,
14426 no_bgp_community_list_expanded_all_cmd
,
14427 "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14431 "Community list number (expanded)\n"
14432 "Add an expanded community-list entry\n"
14433 "Community list name\n"
14434 "Specify community to reject\n"
14435 "Specify community to accept\n"
14438 char *cl_name_or_number
= NULL
;
14441 int style
= COMMUNITY_LIST_EXPANDED
;
14445 argv_find(argv
, argc
, "permit", &idx
);
14446 argv_find(argv
, argc
, "deny", &idx
);
14449 direct
= argv_find(argv
, argc
, "permit", &idx
)
14454 argv_find(argv
, argc
, "AA:NN", &idx
);
14455 str
= argv_concat(argv
, argc
, idx
);
14459 argv_find(argv
, argc
, "(100-500)", &idx
);
14460 argv_find(argv
, argc
, "WORD", &idx
);
14461 cl_name_or_number
= argv
[idx
]->arg
;
14463 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14466 XFREE(MTYPE_TMP
, str
);
14469 community_list_perror(vty
, ret
);
14470 return CMD_WARNING_CONFIG_FAILED
;
14473 return CMD_SUCCESS
;
14476 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
14477 "no bgp community-list <(100-500)|expanded WORD>",
14478 NO_STR IP_STR COMMUNITY_LIST_STR
14479 "Community list number (expanded)\n"
14480 "Add an expanded community-list entry\n"
14481 "Community list name\n")
14483 /* Return configuration string of community-list entry. */
14484 static const char *community_list_config_str(struct community_entry
*entry
)
14491 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
14492 str
= community_str(entry
->u
.com
, false);
14493 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
14494 str
= lcommunity_str(entry
->u
.lcom
, false);
14496 str
= entry
->config
;
14501 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
14503 struct community_entry
*entry
;
14505 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14506 if (entry
== list
->head
) {
14507 if (all_digit(list
->name
))
14508 vty_out(vty
, "Community %s list %s\n",
14509 entry
->style
== COMMUNITY_LIST_STANDARD
14511 : "(expanded) access",
14514 vty_out(vty
, "Named Community %s list %s\n",
14515 entry
->style
== COMMUNITY_LIST_STANDARD
14521 vty_out(vty
, " %s\n",
14522 community_direct_str(entry
->direct
));
14524 vty_out(vty
, " %s %s\n",
14525 community_direct_str(entry
->direct
),
14526 community_list_config_str(entry
));
14530 DEFUN (show_community_list
,
14531 show_bgp_community_list_cmd
,
14532 "show bgp community-list",
14535 "List community-list\n")
14537 struct community_list
*list
;
14538 struct community_list_master
*cm
;
14540 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14542 return CMD_SUCCESS
;
14544 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14545 community_list_show(vty
, list
);
14547 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14548 community_list_show(vty
, list
);
14550 return CMD_SUCCESS
;
14553 DEFUN (show_community_list_arg
,
14554 show_bgp_community_list_arg_cmd
,
14555 "show bgp community-list <(1-500)|WORD> detail",
14558 "List community-list\n"
14559 "Community-list number\n"
14560 "Community-list name\n"
14561 "Detailed information on community-list\n")
14563 int idx_comm_list
= 3;
14564 struct community_list
*list
;
14566 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
14567 COMMUNITY_LIST_MASTER
);
14569 vty_out(vty
, "%% Can't find community-list\n");
14570 return CMD_WARNING
;
14573 community_list_show(vty
, list
);
14575 return CMD_SUCCESS
;
14579 * Large Community code.
14581 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
14582 struct cmd_token
**argv
, int style
,
14583 int reject_all_digit_name
)
14591 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14594 /* All digit name check. */
14596 argv_find(argv
, argc
, "WORD", &idx
);
14597 argv_find(argv
, argc
, "(1-99)", &idx
);
14598 argv_find(argv
, argc
, "(100-500)", &idx
);
14599 cl_name
= argv
[idx
]->arg
;
14600 if (reject_all_digit_name
&& all_digit(cl_name
)) {
14601 vty_out(vty
, "%% Community name cannot have all digits\n");
14602 return CMD_WARNING_CONFIG_FAILED
;
14606 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
14607 argv_find(argv
, argc
, "LINE", &idx
);
14608 /* Concat community string argument. */
14610 str
= argv_concat(argv
, argc
, idx
);
14614 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
14616 /* Free temporary community list string allocated by
14618 XFREE(MTYPE_TMP
, str
);
14621 community_list_perror(vty
, ret
);
14622 return CMD_WARNING_CONFIG_FAILED
;
14624 return CMD_SUCCESS
;
14627 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
14628 struct cmd_token
**argv
, int style
)
14635 argv_find(argv
, argc
, "permit", &idx
);
14636 argv_find(argv
, argc
, "deny", &idx
);
14639 /* Check the list direct. */
14640 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
14641 direct
= COMMUNITY_PERMIT
;
14643 direct
= COMMUNITY_DENY
;
14646 argv_find(argv
, argc
, "LINE", &idx
);
14647 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
14648 /* Concat community string argument. */
14649 str
= argv_concat(argv
, argc
, idx
);
14653 argv_find(argv
, argc
, "(1-99)", &idx
);
14654 argv_find(argv
, argc
, "(100-500)", &idx
);
14655 argv_find(argv
, argc
, "WORD", &idx
);
14657 /* Unset community list. */
14658 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
14661 /* Free temporary community list string allocated by
14663 XFREE(MTYPE_TMP
, str
);
14666 community_list_perror(vty
, ret
);
14667 return CMD_WARNING_CONFIG_FAILED
;
14670 return CMD_SUCCESS
;
14673 /* "large-community-list" keyword help string. */
14674 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
14675 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
14677 DEFUN (lcommunity_list_standard
,
14678 bgp_lcommunity_list_standard_cmd
,
14679 "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...",
14681 LCOMMUNITY_LIST_STR
14682 "Large Community list number (standard)\n"
14683 "Specify large community to reject\n"
14684 "Specify large community to accept\n"
14685 LCOMMUNITY_VAL_STR
)
14687 return lcommunity_list_set_vty(vty
, argc
, argv
,
14688 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14691 DEFUN (lcommunity_list_expanded
,
14692 bgp_lcommunity_list_expanded_cmd
,
14693 "bgp large-community-list (100-500) <deny|permit> LINE...",
14695 LCOMMUNITY_LIST_STR
14696 "Large Community list number (expanded)\n"
14697 "Specify large community to reject\n"
14698 "Specify large community to accept\n"
14699 "An ordered list as a regular-expression\n")
14701 return lcommunity_list_set_vty(vty
, argc
, argv
,
14702 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
14705 DEFUN (lcommunity_list_name_standard
,
14706 bgp_lcommunity_list_name_standard_cmd
,
14707 "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
14709 LCOMMUNITY_LIST_STR
14710 "Specify standard large-community-list\n"
14711 "Large Community list name\n"
14712 "Specify large community to reject\n"
14713 "Specify large community to accept\n"
14714 LCOMMUNITY_VAL_STR
)
14716 return lcommunity_list_set_vty(vty
, argc
, argv
,
14717 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14720 DEFUN (lcommunity_list_name_expanded
,
14721 bgp_lcommunity_list_name_expanded_cmd
,
14722 "bgp large-community-list expanded WORD <deny|permit> LINE...",
14724 LCOMMUNITY_LIST_STR
14725 "Specify expanded large-community-list\n"
14726 "Large Community list name\n"
14727 "Specify large community to reject\n"
14728 "Specify large community to accept\n"
14729 "An ordered list as a regular-expression\n")
14731 return lcommunity_list_set_vty(vty
, argc
, argv
,
14732 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
14735 DEFUN (no_lcommunity_list_standard_all
,
14736 no_bgp_lcommunity_list_standard_all_cmd
,
14737 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
14740 LCOMMUNITY_LIST_STR
14741 "Large Community list number (standard)\n"
14742 "Large Community list number (expanded)\n"
14743 "Large Community list name\n")
14745 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14746 LARGE_COMMUNITY_LIST_STANDARD
);
14749 DEFUN (no_lcommunity_list_name_expanded_all
,
14750 no_bgp_lcommunity_list_name_expanded_all_cmd
,
14751 "no bgp large-community-list expanded WORD",
14754 LCOMMUNITY_LIST_STR
14755 "Specify expanded large-community-list\n"
14756 "Large Community list name\n")
14758 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14759 LARGE_COMMUNITY_LIST_EXPANDED
);
14762 DEFUN (no_lcommunity_list_standard
,
14763 no_bgp_lcommunity_list_standard_cmd
,
14764 "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
14767 LCOMMUNITY_LIST_STR
14768 "Large Community list number (standard)\n"
14769 "Specify large community to reject\n"
14770 "Specify large community to accept\n"
14771 LCOMMUNITY_VAL_STR
)
14773 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14774 LARGE_COMMUNITY_LIST_STANDARD
);
14777 DEFUN (no_lcommunity_list_expanded
,
14778 no_bgp_lcommunity_list_expanded_cmd
,
14779 "no bgp large-community-list (100-500) <deny|permit> LINE...",
14782 LCOMMUNITY_LIST_STR
14783 "Large Community list number (expanded)\n"
14784 "Specify large community to reject\n"
14785 "Specify large community to accept\n"
14786 "An ordered list as a regular-expression\n")
14788 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14789 LARGE_COMMUNITY_LIST_EXPANDED
);
14792 DEFUN (no_lcommunity_list_name_standard
,
14793 no_bgp_lcommunity_list_name_standard_cmd
,
14794 "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
14797 LCOMMUNITY_LIST_STR
14798 "Specify standard large-community-list\n"
14799 "Large Community list name\n"
14800 "Specify large community to reject\n"
14801 "Specify large community to accept\n"
14802 LCOMMUNITY_VAL_STR
)
14804 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14805 LARGE_COMMUNITY_LIST_STANDARD
);
14808 DEFUN (no_lcommunity_list_name_expanded
,
14809 no_bgp_lcommunity_list_name_expanded_cmd
,
14810 "no bgp large-community-list expanded WORD <deny|permit> LINE...",
14813 LCOMMUNITY_LIST_STR
14814 "Specify expanded large-community-list\n"
14815 "Large community list name\n"
14816 "Specify large community to reject\n"
14817 "Specify large community to accept\n"
14818 "An ordered list as a regular-expression\n")
14820 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14821 LARGE_COMMUNITY_LIST_EXPANDED
);
14824 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14826 struct community_entry
*entry
;
14828 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14829 if (entry
== list
->head
) {
14830 if (all_digit(list
->name
))
14831 vty_out(vty
, "Large community %s list %s\n",
14833 LARGE_COMMUNITY_LIST_STANDARD
14835 : "(expanded) access",
14839 "Named large community %s list %s\n",
14841 LARGE_COMMUNITY_LIST_STANDARD
14847 vty_out(vty
, " %s\n",
14848 community_direct_str(entry
->direct
));
14850 vty_out(vty
, " %s %s\n",
14851 community_direct_str(entry
->direct
),
14852 community_list_config_str(entry
));
14856 DEFUN (show_lcommunity_list
,
14857 show_bgp_lcommunity_list_cmd
,
14858 "show bgp large-community-list",
14861 "List large-community list\n")
14863 struct community_list
*list
;
14864 struct community_list_master
*cm
;
14866 cm
= community_list_master_lookup(bgp_clist
,
14867 LARGE_COMMUNITY_LIST_MASTER
);
14869 return CMD_SUCCESS
;
14871 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14872 lcommunity_list_show(vty
, list
);
14874 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14875 lcommunity_list_show(vty
, list
);
14877 return CMD_SUCCESS
;
14880 DEFUN (show_lcommunity_list_arg
,
14881 show_bgp_lcommunity_list_arg_cmd
,
14882 "show bgp large-community-list <(1-500)|WORD> detail",
14885 "List large-community list\n"
14886 "Large-community-list number\n"
14887 "Large-community-list name\n"
14888 "Detailed information on large-community-list\n")
14890 struct community_list
*list
;
14892 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
14893 LARGE_COMMUNITY_LIST_MASTER
);
14895 vty_out(vty
, "%% Can't find large-community-list\n");
14896 return CMD_WARNING
;
14899 lcommunity_list_show(vty
, list
);
14901 return CMD_SUCCESS
;
14904 /* "extcommunity-list" keyword help string. */
14905 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
14906 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
14908 DEFUN (extcommunity_list_standard
,
14909 bgp_extcommunity_list_standard_cmd
,
14910 "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14912 EXTCOMMUNITY_LIST_STR
14913 "Extended Community list number (standard)\n"
14914 "Specify standard extcommunity-list\n"
14915 "Community list name\n"
14916 "Specify community to reject\n"
14917 "Specify community to accept\n"
14918 EXTCOMMUNITY_VAL_STR
)
14920 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14922 char *cl_number_or_name
= NULL
;
14926 argv_find(argv
, argc
, "(1-99)", &idx
);
14927 argv_find(argv
, argc
, "WORD", &idx
);
14928 cl_number_or_name
= argv
[idx
]->arg
;
14929 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14931 argv_find(argv
, argc
, "AA:NN", &idx
);
14932 char *str
= argv_concat(argv
, argc
, idx
);
14934 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14937 XFREE(MTYPE_TMP
, str
);
14940 community_list_perror(vty
, ret
);
14941 return CMD_WARNING_CONFIG_FAILED
;
14944 return CMD_SUCCESS
;
14947 DEFUN (extcommunity_list_name_expanded
,
14948 bgp_extcommunity_list_name_expanded_cmd
,
14949 "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14951 EXTCOMMUNITY_LIST_STR
14952 "Extended Community list number (expanded)\n"
14953 "Specify expanded extcommunity-list\n"
14954 "Extended Community list name\n"
14955 "Specify community to reject\n"
14956 "Specify community to accept\n"
14957 "An ordered list as a regular-expression\n")
14959 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
14961 char *cl_number_or_name
= NULL
;
14964 argv_find(argv
, argc
, "(100-500)", &idx
);
14965 argv_find(argv
, argc
, "WORD", &idx
);
14966 cl_number_or_name
= argv
[idx
]->arg
;
14967 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14969 argv_find(argv
, argc
, "LINE", &idx
);
14970 char *str
= argv_concat(argv
, argc
, idx
);
14972 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14975 XFREE(MTYPE_TMP
, str
);
14978 community_list_perror(vty
, ret
);
14979 return CMD_WARNING_CONFIG_FAILED
;
14982 return CMD_SUCCESS
;
14985 DEFUN (no_extcommunity_list_standard_all
,
14986 no_bgp_extcommunity_list_standard_all_cmd
,
14987 "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14990 EXTCOMMUNITY_LIST_STR
14991 "Extended Community list number (standard)\n"
14992 "Specify standard extcommunity-list\n"
14993 "Community list name\n"
14994 "Specify community to reject\n"
14995 "Specify community to accept\n"
14996 EXTCOMMUNITY_VAL_STR
)
14998 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15000 char *cl_number_or_name
= NULL
;
15004 argv_find(argv
, argc
, "permit", &idx
);
15005 argv_find(argv
, argc
, "deny", &idx
);
15008 direct
= argv_find(argv
, argc
, "permit", &idx
)
15013 argv_find(argv
, argc
, "AA:NN", &idx
);
15014 str
= argv_concat(argv
, argc
, idx
);
15018 argv_find(argv
, argc
, "(1-99)", &idx
);
15019 argv_find(argv
, argc
, "WORD", &idx
);
15020 cl_number_or_name
= argv
[idx
]->arg
;
15022 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15025 XFREE(MTYPE_TMP
, str
);
15028 community_list_perror(vty
, ret
);
15029 return CMD_WARNING_CONFIG_FAILED
;
15032 return CMD_SUCCESS
;
15035 ALIAS(no_extcommunity_list_standard_all
,
15036 no_bgp_extcommunity_list_standard_all_list_cmd
,
15037 "no bgp extcommunity-list <(1-99)|standard WORD>",
15038 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15039 "Extended Community list number (standard)\n"
15040 "Specify standard extcommunity-list\n"
15041 "Community list name\n")
15043 DEFUN (no_extcommunity_list_expanded_all
,
15044 no_bgp_extcommunity_list_expanded_all_cmd
,
15045 "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15048 EXTCOMMUNITY_LIST_STR
15049 "Extended Community list number (expanded)\n"
15050 "Specify expanded extcommunity-list\n"
15051 "Extended Community list name\n"
15052 "Specify community to reject\n"
15053 "Specify community to accept\n"
15054 "An ordered list as a regular-expression\n")
15056 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15058 char *cl_number_or_name
= NULL
;
15062 argv_find(argv
, argc
, "permit", &idx
);
15063 argv_find(argv
, argc
, "deny", &idx
);
15066 direct
= argv_find(argv
, argc
, "permit", &idx
)
15071 argv_find(argv
, argc
, "LINE", &idx
);
15072 str
= argv_concat(argv
, argc
, idx
);
15076 argv_find(argv
, argc
, "(100-500)", &idx
);
15077 argv_find(argv
, argc
, "WORD", &idx
);
15078 cl_number_or_name
= argv
[idx
]->arg
;
15080 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15083 XFREE(MTYPE_TMP
, str
);
15086 community_list_perror(vty
, ret
);
15087 return CMD_WARNING_CONFIG_FAILED
;
15090 return CMD_SUCCESS
;
15093 ALIAS(no_extcommunity_list_expanded_all
,
15094 no_bgp_extcommunity_list_expanded_all_list_cmd
,
15095 "no bgp extcommunity-list <(100-500)|expanded WORD>",
15096 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15097 "Extended Community list number (expanded)\n"
15098 "Specify expanded extcommunity-list\n"
15099 "Extended Community list name\n")
15101 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
15103 struct community_entry
*entry
;
15105 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15106 if (entry
== list
->head
) {
15107 if (all_digit(list
->name
))
15108 vty_out(vty
, "Extended community %s list %s\n",
15109 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15111 : "(expanded) access",
15115 "Named extended community %s list %s\n",
15116 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15122 vty_out(vty
, " %s\n",
15123 community_direct_str(entry
->direct
));
15125 vty_out(vty
, " %s %s\n",
15126 community_direct_str(entry
->direct
),
15127 community_list_config_str(entry
));
15131 DEFUN (show_extcommunity_list
,
15132 show_bgp_extcommunity_list_cmd
,
15133 "show bgp extcommunity-list",
15136 "List extended-community list\n")
15138 struct community_list
*list
;
15139 struct community_list_master
*cm
;
15141 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15143 return CMD_SUCCESS
;
15145 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15146 extcommunity_list_show(vty
, list
);
15148 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15149 extcommunity_list_show(vty
, list
);
15151 return CMD_SUCCESS
;
15154 DEFUN (show_extcommunity_list_arg
,
15155 show_bgp_extcommunity_list_arg_cmd
,
15156 "show bgp extcommunity-list <(1-500)|WORD> detail",
15159 "List extended-community list\n"
15160 "Extcommunity-list number\n"
15161 "Extcommunity-list name\n"
15162 "Detailed information on extcommunity-list\n")
15164 int idx_comm_list
= 3;
15165 struct community_list
*list
;
15167 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
15168 EXTCOMMUNITY_LIST_MASTER
);
15170 vty_out(vty
, "%% Can't find extcommunity-list\n");
15171 return CMD_WARNING
;
15174 extcommunity_list_show(vty
, list
);
15176 return CMD_SUCCESS
;
15179 /* Display community-list and extcommunity-list configuration. */
15180 static int community_list_config_write(struct vty
*vty
)
15182 struct community_list
*list
;
15183 struct community_entry
*entry
;
15184 struct community_list_master
*cm
;
15187 /* Community-list. */
15188 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
15190 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15191 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15192 vty_out(vty
, "bgp community-list %s %s %s\n", list
->name
,
15193 community_direct_str(entry
->direct
),
15194 community_list_config_str(entry
));
15197 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15198 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15199 vty_out(vty
, "bgp community-list %s %s %s %s\n",
15200 entry
->style
== COMMUNITY_LIST_STANDARD
15203 list
->name
, community_direct_str(entry
->direct
),
15204 community_list_config_str(entry
));
15208 /* Extcommunity-list. */
15209 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15211 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15212 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15213 vty_out(vty
, "bgp extcommunity-list %s %s %s\n",
15214 list
->name
, community_direct_str(entry
->direct
),
15215 community_list_config_str(entry
));
15218 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15219 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15220 vty_out(vty
, "bgp extcommunity-list %s %s %s %s\n",
15221 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15224 list
->name
, community_direct_str(entry
->direct
),
15225 community_list_config_str(entry
));
15230 /* lcommunity-list. */
15231 cm
= community_list_master_lookup(bgp_clist
,
15232 LARGE_COMMUNITY_LIST_MASTER
);
15234 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15235 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15236 vty_out(vty
, "bgp large-community-list %s %s %s\n",
15237 list
->name
, community_direct_str(entry
->direct
),
15238 community_list_config_str(entry
));
15241 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15242 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15243 vty_out(vty
, "bgp large-community-list %s %s %s %s\n",
15244 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
15247 list
->name
, community_direct_str(entry
->direct
),
15248 community_list_config_str(entry
));
15255 static struct cmd_node community_list_node
= {
15256 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
15259 static void community_list_vty(void)
15261 install_node(&community_list_node
, community_list_config_write
);
15263 /* Community-list. */
15264 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
15265 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
15266 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
15267 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
15268 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
15269 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
15270 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
15271 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
15273 /* Extcommunity-list. */
15274 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
15275 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
15276 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
15277 install_element(CONFIG_NODE
,
15278 &no_bgp_extcommunity_list_standard_all_list_cmd
);
15279 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
15280 install_element(CONFIG_NODE
,
15281 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
15282 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
15283 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
15285 /* Large Community List */
15286 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
15287 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
15288 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
15289 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
15290 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_all_cmd
);
15291 install_element(CONFIG_NODE
,
15292 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
15293 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
15294 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
15295 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
15296 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
15297 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
15298 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);