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
;
1924 DEFUN(bgp_reject_as_sets
, bgp_reject_as_sets_cmd
,
1925 "bgp reject-as-sets",
1926 "BGP specific commands\n"
1927 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
1929 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1930 struct listnode
*node
, *nnode
;
1933 bgp
->reject_as_sets
= BGP_REJECT_AS_SETS_ENABLED
;
1935 /* Reset existing BGP sessions to reject routes
1936 * with aspath containing AS_SET or AS_CONFED_SET.
1938 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1939 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
1940 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
1941 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
1942 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
1949 DEFUN(no_bgp_reject_as_sets
, no_bgp_reject_as_sets_cmd
,
1950 "no bgp reject-as-sets",
1952 "BGP specific commands\n"
1953 "Reject routes with AS_SET or AS_CONFED_SET flag\n")
1955 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1956 struct listnode
*node
, *nnode
;
1959 bgp
->reject_as_sets
= BGP_REJECT_AS_SETS_DISABLED
;
1961 /* Reset existing BGP sessions to reject routes
1962 * with aspath containing AS_SET or AS_CONFED_SET.
1964 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1965 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
1966 peer
->last_reset
= PEER_DOWN_AS_SETS_REJECT
;
1967 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
1968 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
1975 /* "bgp deterministic-med" configuration. */
1976 DEFUN (bgp_deterministic_med
,
1977 bgp_deterministic_med_cmd
,
1978 "bgp deterministic-med",
1979 "BGP specific commands\n"
1980 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1982 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1984 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1985 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1986 bgp_recalculate_all_bestpaths(bgp
);
1992 DEFUN (no_bgp_deterministic_med
,
1993 no_bgp_deterministic_med_cmd
,
1994 "no bgp deterministic-med",
1996 "BGP specific commands\n"
1997 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1999 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2000 int bestpath_per_as_used
;
2004 struct listnode
*node
, *nnode
;
2006 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
2007 bestpath_per_as_used
= 0;
2009 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
2010 FOREACH_AFI_SAFI (afi
, safi
)
2011 if (bgp_addpath_dmed_required(
2012 peer
->addpath_type
[afi
][safi
])) {
2013 bestpath_per_as_used
= 1;
2017 if (bestpath_per_as_used
)
2021 if (bestpath_per_as_used
) {
2023 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
2024 return CMD_WARNING_CONFIG_FAILED
;
2026 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
2027 bgp_recalculate_all_bestpaths(bgp
);
2034 /* "bgp graceful-restart" configuration. */
2035 DEFUN (bgp_graceful_restart
,
2036 bgp_graceful_restart_cmd
,
2037 "bgp graceful-restart",
2038 "BGP specific commands\n"
2039 "Graceful restart capability parameters\n")
2041 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2042 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
2046 DEFUN (no_bgp_graceful_restart
,
2047 no_bgp_graceful_restart_cmd
,
2048 "no bgp graceful-restart",
2050 "BGP specific commands\n"
2051 "Graceful restart capability parameters\n")
2053 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2054 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
2058 DEFUN (bgp_graceful_restart_stalepath_time
,
2059 bgp_graceful_restart_stalepath_time_cmd
,
2060 "bgp graceful-restart stalepath-time (1-4095)",
2061 "BGP specific commands\n"
2062 "Graceful restart capability parameters\n"
2063 "Set the max time to hold onto restarting peer's stale paths\n"
2064 "Delay value (seconds)\n")
2066 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2070 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2071 bgp
->stalepath_time
= stalepath
;
2075 DEFUN (bgp_graceful_restart_restart_time
,
2076 bgp_graceful_restart_restart_time_cmd
,
2077 "bgp graceful-restart restart-time (1-4095)",
2078 "BGP specific commands\n"
2079 "Graceful restart capability parameters\n"
2080 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2081 "Delay value (seconds)\n")
2083 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2087 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2088 bgp
->restart_time
= restart
;
2092 DEFUN (no_bgp_graceful_restart_stalepath_time
,
2093 no_bgp_graceful_restart_stalepath_time_cmd
,
2094 "no bgp graceful-restart stalepath-time [(1-4095)]",
2096 "BGP specific commands\n"
2097 "Graceful restart capability parameters\n"
2098 "Set the max time to hold onto restarting peer's stale paths\n"
2099 "Delay value (seconds)\n")
2101 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2103 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
2107 DEFUN (no_bgp_graceful_restart_restart_time
,
2108 no_bgp_graceful_restart_restart_time_cmd
,
2109 "no bgp graceful-restart restart-time [(1-4095)]",
2111 "BGP specific commands\n"
2112 "Graceful restart capability parameters\n"
2113 "Set the time to wait to delete stale routes before a BGP open message is received\n"
2114 "Delay value (seconds)\n")
2116 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2118 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
2122 DEFUN (bgp_graceful_restart_preserve_fw
,
2123 bgp_graceful_restart_preserve_fw_cmd
,
2124 "bgp graceful-restart preserve-fw-state",
2125 "BGP specific commands\n"
2126 "Graceful restart capability parameters\n"
2127 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
2129 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2130 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2134 DEFUN (no_bgp_graceful_restart_preserve_fw
,
2135 no_bgp_graceful_restart_preserve_fw_cmd
,
2136 "no bgp graceful-restart preserve-fw-state",
2138 "BGP specific commands\n"
2139 "Graceful restart capability parameters\n"
2140 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
2142 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2143 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
2147 /* "bgp graceful-shutdown" configuration */
2148 DEFUN (bgp_graceful_shutdown
,
2149 bgp_graceful_shutdown_cmd
,
2150 "bgp graceful-shutdown",
2152 "Graceful shutdown parameters\n")
2154 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2156 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2157 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2158 bgp_static_redo_import_check(bgp
);
2159 bgp_redistribute_redo(bgp
);
2160 bgp_clear_star_soft_out(vty
, bgp
->name
);
2161 bgp_clear_star_soft_in(vty
, bgp
->name
);
2167 DEFUN (no_bgp_graceful_shutdown
,
2168 no_bgp_graceful_shutdown_cmd
,
2169 "no bgp graceful-shutdown",
2172 "Graceful shutdown parameters\n")
2174 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2176 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
2177 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
2178 bgp_static_redo_import_check(bgp
);
2179 bgp_redistribute_redo(bgp
);
2180 bgp_clear_star_soft_out(vty
, bgp
->name
);
2181 bgp_clear_star_soft_in(vty
, bgp
->name
);
2187 /* "bgp fast-external-failover" configuration. */
2188 DEFUN (bgp_fast_external_failover
,
2189 bgp_fast_external_failover_cmd
,
2190 "bgp fast-external-failover",
2192 "Immediately reset session if a link to a directly connected external peer goes down\n")
2194 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2195 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2199 DEFUN (no_bgp_fast_external_failover
,
2200 no_bgp_fast_external_failover_cmd
,
2201 "no bgp fast-external-failover",
2204 "Immediately reset session if a link to a directly connected external peer goes down\n")
2206 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2207 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2211 /* "bgp bestpath compare-routerid" configuration. */
2212 DEFUN (bgp_bestpath_compare_router_id
,
2213 bgp_bestpath_compare_router_id_cmd
,
2214 "bgp bestpath compare-routerid",
2215 "BGP specific commands\n"
2216 "Change the default bestpath selection\n"
2217 "Compare router-id for identical EBGP paths\n")
2219 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2220 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2221 bgp_recalculate_all_bestpaths(bgp
);
2226 DEFUN (no_bgp_bestpath_compare_router_id
,
2227 no_bgp_bestpath_compare_router_id_cmd
,
2228 "no bgp bestpath compare-routerid",
2230 "BGP specific commands\n"
2231 "Change the default bestpath selection\n"
2232 "Compare router-id for identical EBGP paths\n")
2234 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2235 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2236 bgp_recalculate_all_bestpaths(bgp
);
2241 /* "bgp bestpath as-path ignore" configuration. */
2242 DEFUN (bgp_bestpath_aspath_ignore
,
2243 bgp_bestpath_aspath_ignore_cmd
,
2244 "bgp bestpath as-path ignore",
2245 "BGP specific commands\n"
2246 "Change the default bestpath selection\n"
2247 "AS-path attribute\n"
2248 "Ignore as-path length in selecting a route\n")
2250 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2251 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2252 bgp_recalculate_all_bestpaths(bgp
);
2257 DEFUN (no_bgp_bestpath_aspath_ignore
,
2258 no_bgp_bestpath_aspath_ignore_cmd
,
2259 "no bgp bestpath as-path ignore",
2261 "BGP specific commands\n"
2262 "Change the default bestpath selection\n"
2263 "AS-path attribute\n"
2264 "Ignore as-path length in selecting a route\n")
2266 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2267 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2268 bgp_recalculate_all_bestpaths(bgp
);
2273 /* "bgp bestpath as-path confed" configuration. */
2274 DEFUN (bgp_bestpath_aspath_confed
,
2275 bgp_bestpath_aspath_confed_cmd
,
2276 "bgp bestpath as-path confed",
2277 "BGP specific commands\n"
2278 "Change the default bestpath selection\n"
2279 "AS-path attribute\n"
2280 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2282 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2283 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2284 bgp_recalculate_all_bestpaths(bgp
);
2289 DEFUN (no_bgp_bestpath_aspath_confed
,
2290 no_bgp_bestpath_aspath_confed_cmd
,
2291 "no bgp bestpath as-path confed",
2293 "BGP specific commands\n"
2294 "Change the default bestpath selection\n"
2295 "AS-path attribute\n"
2296 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2298 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2299 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2300 bgp_recalculate_all_bestpaths(bgp
);
2305 /* "bgp bestpath as-path multipath-relax" configuration. */
2306 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2307 bgp_bestpath_aspath_multipath_relax_cmd
,
2308 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2309 "BGP specific commands\n"
2310 "Change the default bestpath selection\n"
2311 "AS-path attribute\n"
2312 "Allow load sharing across routes that have different AS paths (but same length)\n"
2313 "Generate an AS_SET\n"
2314 "Do not generate an AS_SET\n")
2316 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2318 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2320 /* no-as-set is now the default behavior so we can silently
2322 if (argv_find(argv
, argc
, "as-set", &idx
))
2323 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2325 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2327 bgp_recalculate_all_bestpaths(bgp
);
2332 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2333 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2334 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2336 "BGP specific commands\n"
2337 "Change the default bestpath selection\n"
2338 "AS-path attribute\n"
2339 "Allow load sharing across routes that have different AS paths (but same length)\n"
2340 "Generate an AS_SET\n"
2341 "Do not generate an AS_SET\n")
2343 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2344 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2345 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2346 bgp_recalculate_all_bestpaths(bgp
);
2351 /* "bgp log-neighbor-changes" configuration. */
2352 DEFUN (bgp_log_neighbor_changes
,
2353 bgp_log_neighbor_changes_cmd
,
2354 "bgp log-neighbor-changes",
2355 "BGP specific commands\n"
2356 "Log neighbor up/down and reset reason\n")
2358 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2359 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2363 DEFUN (no_bgp_log_neighbor_changes
,
2364 no_bgp_log_neighbor_changes_cmd
,
2365 "no bgp log-neighbor-changes",
2367 "BGP specific commands\n"
2368 "Log neighbor up/down and reset reason\n")
2370 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2371 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2375 /* "bgp bestpath med" configuration. */
2376 DEFUN (bgp_bestpath_med
,
2377 bgp_bestpath_med_cmd
,
2378 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2379 "BGP specific commands\n"
2380 "Change the default bestpath selection\n"
2382 "Compare MED among confederation paths\n"
2383 "Treat missing MED as the least preferred one\n"
2384 "Treat missing MED as the least preferred one\n"
2385 "Compare MED among confederation paths\n")
2387 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2390 if (argv_find(argv
, argc
, "confed", &idx
))
2391 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2393 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2394 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2396 bgp_recalculate_all_bestpaths(bgp
);
2401 DEFUN (no_bgp_bestpath_med
,
2402 no_bgp_bestpath_med_cmd
,
2403 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2405 "BGP specific commands\n"
2406 "Change the default bestpath selection\n"
2408 "Compare MED among confederation paths\n"
2409 "Treat missing MED as the least preferred one\n"
2410 "Treat missing MED as the least preferred one\n"
2411 "Compare MED among confederation paths\n")
2413 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2416 if (argv_find(argv
, argc
, "confed", &idx
))
2417 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2419 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2420 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2422 bgp_recalculate_all_bestpaths(bgp
);
2427 /* "no bgp default ipv4-unicast". */
2428 DEFUN (no_bgp_default_ipv4_unicast
,
2429 no_bgp_default_ipv4_unicast_cmd
,
2430 "no bgp default ipv4-unicast",
2432 "BGP specific commands\n"
2433 "Configure BGP defaults\n"
2434 "Activate ipv4-unicast for a peer by default\n")
2436 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2437 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2441 DEFUN (bgp_default_ipv4_unicast
,
2442 bgp_default_ipv4_unicast_cmd
,
2443 "bgp default ipv4-unicast",
2444 "BGP specific commands\n"
2445 "Configure BGP defaults\n"
2446 "Activate ipv4-unicast for a peer by default\n")
2448 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2449 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2453 /* Display hostname in certain command outputs */
2454 DEFUN (bgp_default_show_hostname
,
2455 bgp_default_show_hostname_cmd
,
2456 "bgp default show-hostname",
2457 "BGP specific commands\n"
2458 "Configure BGP defaults\n"
2459 "Show hostname in certain command outputs\n")
2461 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2462 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2466 DEFUN (no_bgp_default_show_hostname
,
2467 no_bgp_default_show_hostname_cmd
,
2468 "no bgp default show-hostname",
2470 "BGP specific commands\n"
2471 "Configure BGP defaults\n"
2472 "Show hostname in certain command outputs\n")
2474 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2475 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2479 /* "bgp network import-check" configuration. */
2480 DEFUN (bgp_network_import_check
,
2481 bgp_network_import_check_cmd
,
2482 "bgp network import-check",
2483 "BGP specific commands\n"
2484 "BGP network command\n"
2485 "Check BGP network route exists in IGP\n")
2487 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2488 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2489 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2490 bgp_static_redo_import_check(bgp
);
2496 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2497 "bgp network import-check exact",
2498 "BGP specific commands\n"
2499 "BGP network command\n"
2500 "Check BGP network route exists in IGP\n"
2501 "Match route precisely\n")
2503 DEFUN (no_bgp_network_import_check
,
2504 no_bgp_network_import_check_cmd
,
2505 "no bgp network import-check",
2507 "BGP specific commands\n"
2508 "BGP network command\n"
2509 "Check BGP network route exists in IGP\n")
2511 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2512 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2513 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2514 bgp_static_redo_import_check(bgp
);
2520 DEFUN (bgp_default_local_preference
,
2521 bgp_default_local_preference_cmd
,
2522 "bgp default local-preference (0-4294967295)",
2523 "BGP specific commands\n"
2524 "Configure BGP defaults\n"
2525 "local preference (higher=more preferred)\n"
2526 "Configure default local preference value\n")
2528 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2530 uint32_t local_pref
;
2532 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2534 bgp_default_local_preference_set(bgp
, local_pref
);
2535 bgp_clear_star_soft_in(vty
, bgp
->name
);
2540 DEFUN (no_bgp_default_local_preference
,
2541 no_bgp_default_local_preference_cmd
,
2542 "no bgp default local-preference [(0-4294967295)]",
2544 "BGP specific commands\n"
2545 "Configure BGP defaults\n"
2546 "local preference (higher=more preferred)\n"
2547 "Configure default local preference value\n")
2549 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2550 bgp_default_local_preference_unset(bgp
);
2551 bgp_clear_star_soft_in(vty
, bgp
->name
);
2557 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2558 bgp_default_subgroup_pkt_queue_max_cmd
,
2559 "bgp default subgroup-pkt-queue-max (20-100)",
2560 "BGP specific commands\n"
2561 "Configure BGP defaults\n"
2562 "subgroup-pkt-queue-max\n"
2563 "Configure subgroup packet queue max\n")
2565 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2569 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2571 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2576 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2577 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2578 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2580 "BGP specific commands\n"
2581 "Configure BGP defaults\n"
2582 "subgroup-pkt-queue-max\n"
2583 "Configure subgroup packet queue max\n")
2585 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2586 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2591 DEFUN (bgp_rr_allow_outbound_policy
,
2592 bgp_rr_allow_outbound_policy_cmd
,
2593 "bgp route-reflector allow-outbound-policy",
2594 "BGP specific commands\n"
2595 "Allow modifications made by out route-map\n"
2596 "on ibgp neighbors\n")
2598 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2600 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2601 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2602 update_group_announce_rrclients(bgp
);
2603 bgp_clear_star_soft_out(vty
, bgp
->name
);
2609 DEFUN (no_bgp_rr_allow_outbound_policy
,
2610 no_bgp_rr_allow_outbound_policy_cmd
,
2611 "no bgp route-reflector allow-outbound-policy",
2613 "BGP specific commands\n"
2614 "Allow modifications made by out route-map\n"
2615 "on ibgp neighbors\n")
2617 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2619 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2620 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2621 update_group_announce_rrclients(bgp
);
2622 bgp_clear_star_soft_out(vty
, bgp
->name
);
2628 DEFUN (bgp_listen_limit
,
2629 bgp_listen_limit_cmd
,
2630 "bgp listen limit (1-5000)",
2631 "BGP specific commands\n"
2632 "Configure BGP defaults\n"
2633 "maximum number of BGP Dynamic Neighbors that can be created\n"
2634 "Configure Dynamic Neighbors listen limit value\n")
2636 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2640 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2642 bgp_listen_limit_set(bgp
, listen_limit
);
2647 DEFUN (no_bgp_listen_limit
,
2648 no_bgp_listen_limit_cmd
,
2649 "no bgp listen limit [(1-5000)]",
2650 "BGP specific commands\n"
2651 "Configure BGP defaults\n"
2652 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2653 "Configure Dynamic Neighbors listen limit value to default\n"
2654 "Configure Dynamic Neighbors listen limit value\n")
2656 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2657 bgp_listen_limit_unset(bgp
);
2663 * Check if this listen range is already configured. Check for exact
2664 * match or overlap based on input.
2666 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2667 struct prefix
*range
, int exact
)
2669 struct listnode
*node
, *nnode
;
2670 struct listnode
*node1
, *nnode1
;
2671 struct peer_group
*group
;
2676 afi
= family2afi(range
->family
);
2677 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2678 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2681 match
= prefix_same(range
, lr
);
2683 match
= (prefix_match(range
, lr
)
2684 || prefix_match(lr
, range
));
2693 DEFUN (bgp_listen_range
,
2694 bgp_listen_range_cmd
,
2695 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
2696 "BGP specific commands\n"
2697 "Configure BGP dynamic neighbors listen range\n"
2698 "Configure BGP dynamic neighbors listen range\n"
2700 "Member of the peer-group\n"
2701 "Peer-group name\n")
2703 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2704 struct prefix range
;
2705 struct peer_group
*group
, *existing_group
;
2710 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2711 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2712 char *prefix
= argv
[idx
]->arg
;
2713 argv_find(argv
, argc
, "PGNAME", &idx
);
2714 char *peergroup
= argv
[idx
]->arg
;
2716 /* Convert IP prefix string to struct prefix. */
2717 ret
= str2prefix(prefix
, &range
);
2719 vty_out(vty
, "%% Malformed listen range\n");
2720 return CMD_WARNING_CONFIG_FAILED
;
2723 afi
= family2afi(range
.family
);
2725 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2727 "%% Malformed listen range (link-local address)\n");
2728 return CMD_WARNING_CONFIG_FAILED
;
2733 /* Check if same listen range is already configured. */
2734 existing_group
= listen_range_exists(bgp
, &range
, 1);
2735 if (existing_group
) {
2736 if (strcmp(existing_group
->name
, peergroup
) == 0)
2740 "%% Same listen range is attached to peer-group %s\n",
2741 existing_group
->name
);
2742 return CMD_WARNING_CONFIG_FAILED
;
2746 /* Check if an overlapping listen range exists. */
2747 if (listen_range_exists(bgp
, &range
, 0)) {
2749 "%% Listen range overlaps with existing listen range\n");
2750 return CMD_WARNING_CONFIG_FAILED
;
2753 group
= peer_group_lookup(bgp
, peergroup
);
2755 vty_out(vty
, "%% Configure the peer-group first\n");
2756 return CMD_WARNING_CONFIG_FAILED
;
2759 ret
= peer_group_listen_range_add(group
, &range
);
2760 return bgp_vty_return(vty
, ret
);
2763 DEFUN (no_bgp_listen_range
,
2764 no_bgp_listen_range_cmd
,
2765 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group PGNAME",
2767 "BGP specific commands\n"
2768 "Unconfigure BGP dynamic neighbors listen range\n"
2769 "Unconfigure BGP dynamic neighbors listen range\n"
2771 "Member of the peer-group\n"
2772 "Peer-group name\n")
2774 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2775 struct prefix range
;
2776 struct peer_group
*group
;
2781 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2782 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2783 char *prefix
= argv
[idx
]->arg
;
2784 argv_find(argv
, argc
, "WORD", &idx
);
2785 char *peergroup
= argv
[idx
]->arg
;
2787 /* Convert IP prefix string to struct prefix. */
2788 ret
= str2prefix(prefix
, &range
);
2790 vty_out(vty
, "%% Malformed listen range\n");
2791 return CMD_WARNING_CONFIG_FAILED
;
2794 afi
= family2afi(range
.family
);
2796 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2798 "%% Malformed listen range (link-local address)\n");
2799 return CMD_WARNING_CONFIG_FAILED
;
2804 group
= peer_group_lookup(bgp
, peergroup
);
2806 vty_out(vty
, "%% Peer-group does not exist\n");
2807 return CMD_WARNING_CONFIG_FAILED
;
2810 ret
= peer_group_listen_range_del(group
, &range
);
2811 return bgp_vty_return(vty
, ret
);
2814 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2816 struct peer_group
*group
;
2817 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2818 struct prefix
*range
;
2820 char buf
[PREFIX2STR_BUFFER
];
2822 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2823 vty_out(vty
, " bgp listen limit %d\n",
2824 bgp
->dynamic_neighbors_limit
);
2826 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2827 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2828 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2830 prefix2str(range
, buf
, sizeof(buf
));
2832 " bgp listen range %s peer-group %s\n",
2840 DEFUN (bgp_disable_connected_route_check
,
2841 bgp_disable_connected_route_check_cmd
,
2842 "bgp disable-ebgp-connected-route-check",
2843 "BGP specific commands\n"
2844 "Disable checking if nexthop is connected on ebgp sessions\n")
2846 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2847 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2848 bgp_clear_star_soft_in(vty
, bgp
->name
);
2853 DEFUN (no_bgp_disable_connected_route_check
,
2854 no_bgp_disable_connected_route_check_cmd
,
2855 "no bgp disable-ebgp-connected-route-check",
2857 "BGP specific commands\n"
2858 "Disable checking if nexthop is connected on ebgp sessions\n")
2860 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2861 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2862 bgp_clear_star_soft_in(vty
, bgp
->name
);
2868 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2869 const char *as_str
, afi_t afi
, safi_t safi
)
2871 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2874 int as_type
= AS_SPECIFIED
;
2877 if (as_str
[0] == 'i') {
2879 as_type
= AS_INTERNAL
;
2880 } else if (as_str
[0] == 'e') {
2882 as_type
= AS_EXTERNAL
;
2884 /* Get AS number. */
2885 as
= strtoul(as_str
, NULL
, 10);
2888 /* If peer is peer group or interface peer, call proper function. */
2889 ret
= str2sockunion(peer_str
, &su
);
2893 /* Check if existing interface peer */
2894 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
2896 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2899 /* if not interface peer, check peer-group settings */
2900 if (ret
< 0 && !peer
) {
2901 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2904 "%% Create the peer-group or interface first\n");
2905 return CMD_WARNING_CONFIG_FAILED
;
2910 if (peer_address_self_check(bgp
, &su
)) {
2912 "%% Can not configure the local system as neighbor\n");
2913 return CMD_WARNING_CONFIG_FAILED
;
2915 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2918 /* This peer belongs to peer group. */
2920 case BGP_ERR_PEER_GROUP_MEMBER
:
2922 "%% Peer-group member cannot override remote-as of peer-group\n");
2923 return CMD_WARNING_CONFIG_FAILED
;
2924 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2926 "%% Peer-group members must be all internal or all external\n");
2927 return CMD_WARNING_CONFIG_FAILED
;
2929 return bgp_vty_return(vty
, ret
);
2932 DEFUN (bgp_default_shutdown
,
2933 bgp_default_shutdown_cmd
,
2934 "[no] bgp default shutdown",
2937 "Configure BGP defaults\n"
2938 "Apply administrative shutdown to newly configured peers\n")
2940 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2941 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2945 DEFUN (neighbor_remote_as
,
2946 neighbor_remote_as_cmd
,
2947 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2950 "Specify a BGP neighbor\n"
2952 "Internal BGP peer\n"
2953 "External BGP peer\n")
2956 int idx_remote_as
= 3;
2957 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2958 argv
[idx_remote_as
]->arg
, AFI_IP
,
2962 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2963 afi_t afi
, safi_t safi
, int v6only
,
2964 const char *peer_group_name
,
2967 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2969 int as_type
= AS_UNSPECIFIED
;
2971 struct peer_group
*group
;
2975 group
= peer_group_lookup(bgp
, conf_if
);
2978 vty_out(vty
, "%% Name conflict with peer-group \n");
2979 return CMD_WARNING_CONFIG_FAILED
;
2983 if (as_str
[0] == 'i') {
2984 as_type
= AS_INTERNAL
;
2985 } else if (as_str
[0] == 'e') {
2986 as_type
= AS_EXTERNAL
;
2988 /* Get AS number. */
2989 as
= strtoul(as_str
, NULL
, 10);
2990 as_type
= AS_SPECIFIED
;
2994 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2997 ret
= peer_remote_as(bgp
, NULL
, conf_if
, &as
, as_type
,
3000 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
3001 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
3002 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
3003 as_type
, 0, 0, NULL
);
3005 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
3006 as_type
, afi
, safi
, NULL
);
3009 vty_out(vty
, "%% BGP failed to create peer\n");
3010 return CMD_WARNING_CONFIG_FAILED
;
3014 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
3016 /* Request zebra to initiate IPv6 RAs on this interface. We do
3018 * any unnumbered peer in order to not worry about run-time
3020 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
3022 * gets deleted later etc.)
3025 bgp_zebra_initiate_radv(bgp
, peer
);
3028 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
3029 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
3031 peer_flag_set(peer
, PEER_FLAG_IFPEER_V6ONLY
);
3033 peer_flag_unset(peer
, PEER_FLAG_IFPEER_V6ONLY
);
3035 /* v6only flag changed. Reset bgp seesion */
3036 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
3037 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
3038 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
3039 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
3041 bgp_session_reset(peer
);
3044 if (!CHECK_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
)) {
3045 SET_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
);
3046 SET_FLAG(peer
->flags_invert
, PEER_FLAG_CAPABILITY_ENHE
);
3047 SET_FLAG(peer
->flags_override
, PEER_FLAG_CAPABILITY_ENHE
);
3050 if (peer_group_name
) {
3051 group
= peer_group_lookup(bgp
, peer_group_name
);
3053 vty_out(vty
, "%% Configure the peer-group first\n");
3054 return CMD_WARNING_CONFIG_FAILED
;
3057 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3060 return bgp_vty_return(vty
, ret
);
3063 DEFUN (neighbor_interface_config
,
3064 neighbor_interface_config_cmd
,
3065 "neighbor WORD interface [peer-group PGNAME]",
3067 "Interface name or neighbor tag\n"
3068 "Enable BGP on interface\n"
3069 "Member of the peer-group\n"
3070 "Peer-group name\n")
3073 int idx_peer_group_word
= 4;
3075 if (argc
> idx_peer_group_word
)
3076 return peer_conf_interface_get(
3077 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
3078 argv
[idx_peer_group_word
]->arg
, NULL
);
3080 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3081 SAFI_UNICAST
, 0, NULL
, NULL
);
3084 DEFUN (neighbor_interface_config_v6only
,
3085 neighbor_interface_config_v6only_cmd
,
3086 "neighbor WORD interface v6only [peer-group PGNAME]",
3088 "Interface name or neighbor tag\n"
3089 "Enable BGP on interface\n"
3090 "Enable BGP with v6 link-local only\n"
3091 "Member of the peer-group\n"
3092 "Peer-group name\n")
3095 int idx_peer_group_word
= 5;
3097 if (argc
> idx_peer_group_word
)
3098 return peer_conf_interface_get(
3099 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
3100 argv
[idx_peer_group_word
]->arg
, NULL
);
3102 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3103 SAFI_UNICAST
, 1, NULL
, NULL
);
3107 DEFUN (neighbor_interface_config_remote_as
,
3108 neighbor_interface_config_remote_as_cmd
,
3109 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
3111 "Interface name or neighbor tag\n"
3112 "Enable BGP on interface\n"
3113 "Specify a BGP neighbor\n"
3115 "Internal BGP peer\n"
3116 "External BGP peer\n")
3119 int idx_remote_as
= 4;
3120 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3121 SAFI_UNICAST
, 0, NULL
,
3122 argv
[idx_remote_as
]->arg
);
3125 DEFUN (neighbor_interface_v6only_config_remote_as
,
3126 neighbor_interface_v6only_config_remote_as_cmd
,
3127 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
3129 "Interface name or neighbor tag\n"
3130 "Enable BGP with v6 link-local only\n"
3131 "Enable BGP on interface\n"
3132 "Specify a BGP neighbor\n"
3134 "Internal BGP peer\n"
3135 "External BGP peer\n")
3138 int idx_remote_as
= 5;
3139 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
3140 SAFI_UNICAST
, 1, NULL
,
3141 argv
[idx_remote_as
]->arg
);
3144 DEFUN (neighbor_peer_group
,
3145 neighbor_peer_group_cmd
,
3146 "neighbor WORD peer-group",
3148 "Interface name or neighbor tag\n"
3149 "Configure peer-group\n")
3151 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3154 struct peer_group
*group
;
3156 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3158 vty_out(vty
, "%% Name conflict with interface: \n");
3159 return CMD_WARNING_CONFIG_FAILED
;
3162 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
3164 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
3165 return CMD_WARNING_CONFIG_FAILED
;
3173 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
3177 "Specify a BGP neighbor\n"
3179 "Internal BGP peer\n"
3180 "External BGP peer\n")
3182 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3186 struct peer_group
*group
;
3190 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3192 /* look up for neighbor by interface name config. */
3193 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3195 /* Request zebra to terminate IPv6 RAs on this
3198 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3203 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3205 peer_group_delete(group
);
3207 vty_out(vty
, "%% Create the peer-group first\n");
3208 return CMD_WARNING_CONFIG_FAILED
;
3211 peer
= peer_lookup(bgp
, &su
);
3213 if (peer_dynamic_neighbor(peer
)) {
3215 "%% Operation not allowed on a dynamic neighbor\n");
3216 return CMD_WARNING_CONFIG_FAILED
;
3219 other
= peer
->doppelganger
;
3221 if (other
&& other
->status
!= Deleted
)
3229 DEFUN (no_neighbor_interface_config
,
3230 no_neighbor_interface_config_cmd
,
3231 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
3235 "Configure BGP on interface\n"
3236 "Enable BGP with v6 link-local only\n"
3237 "Member of the peer-group\n"
3239 "Specify a BGP neighbor\n"
3241 "Internal BGP peer\n"
3242 "External BGP peer\n")
3244 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3248 /* look up for neighbor by interface name config. */
3249 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3251 /* Request zebra to terminate IPv6 RAs on this interface. */
3253 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3256 vty_out(vty
, "%% Create the bgp interface first\n");
3257 return CMD_WARNING_CONFIG_FAILED
;
3262 DEFUN (no_neighbor_peer_group
,
3263 no_neighbor_peer_group_cmd
,
3264 "no neighbor WORD peer-group",
3268 "Configure peer-group\n")
3270 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3272 struct peer_group
*group
;
3274 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3276 peer_group_delete(group
);
3278 vty_out(vty
, "%% Create the peer-group first\n");
3279 return CMD_WARNING_CONFIG_FAILED
;
3284 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3285 no_neighbor_interface_peer_group_remote_as_cmd
,
3286 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3289 "Interface name or neighbor tag\n"
3290 "Specify a BGP neighbor\n"
3292 "Internal BGP peer\n"
3293 "External BGP peer\n")
3295 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3297 struct peer_group
*group
;
3300 /* look up for neighbor by interface name config. */
3301 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3303 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
3307 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3309 peer_group_remote_as_delete(group
);
3311 vty_out(vty
, "%% Create the peer-group or interface first\n");
3312 return CMD_WARNING_CONFIG_FAILED
;
3317 DEFUN (neighbor_local_as
,
3318 neighbor_local_as_cmd
,
3319 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3322 "Specify a local-as number\n"
3323 "AS number used as local AS\n")
3331 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3333 return CMD_WARNING_CONFIG_FAILED
;
3335 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3336 ret
= peer_local_as_set(peer
, as
, 0, 0);
3337 return bgp_vty_return(vty
, ret
);
3340 DEFUN (neighbor_local_as_no_prepend
,
3341 neighbor_local_as_no_prepend_cmd
,
3342 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3345 "Specify a local-as number\n"
3346 "AS number used as local AS\n"
3347 "Do not prepend local-as to updates from ebgp peers\n")
3355 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3357 return CMD_WARNING_CONFIG_FAILED
;
3359 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3360 ret
= peer_local_as_set(peer
, as
, 1, 0);
3361 return bgp_vty_return(vty
, ret
);
3364 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3365 neighbor_local_as_no_prepend_replace_as_cmd
,
3366 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3369 "Specify a local-as number\n"
3370 "AS number used as local AS\n"
3371 "Do not prepend local-as to updates from ebgp peers\n"
3372 "Do not prepend local-as to updates from ibgp peers\n")
3380 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3382 return CMD_WARNING_CONFIG_FAILED
;
3384 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3385 ret
= peer_local_as_set(peer
, as
, 1, 1);
3386 return bgp_vty_return(vty
, ret
);
3389 DEFUN (no_neighbor_local_as
,
3390 no_neighbor_local_as_cmd
,
3391 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3395 "Specify a local-as number\n"
3396 "AS number used as local AS\n"
3397 "Do not prepend local-as to updates from ebgp peers\n"
3398 "Do not prepend local-as to updates from ibgp peers\n")
3404 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3406 return CMD_WARNING_CONFIG_FAILED
;
3408 ret
= peer_local_as_unset(peer
);
3409 return bgp_vty_return(vty
, ret
);
3413 DEFUN (neighbor_solo
,
3415 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3418 "Solo peer - part of its own update group\n")
3424 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3426 return CMD_WARNING_CONFIG_FAILED
;
3428 ret
= update_group_adjust_soloness(peer
, 1);
3429 return bgp_vty_return(vty
, ret
);
3432 DEFUN (no_neighbor_solo
,
3433 no_neighbor_solo_cmd
,
3434 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3438 "Solo peer - part of its own update group\n")
3444 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3446 return CMD_WARNING_CONFIG_FAILED
;
3448 ret
= update_group_adjust_soloness(peer
, 0);
3449 return bgp_vty_return(vty
, ret
);
3452 DEFUN (neighbor_password
,
3453 neighbor_password_cmd
,
3454 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3465 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3467 return CMD_WARNING_CONFIG_FAILED
;
3469 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3470 return bgp_vty_return(vty
, ret
);
3473 DEFUN (no_neighbor_password
,
3474 no_neighbor_password_cmd
,
3475 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3486 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3488 return CMD_WARNING_CONFIG_FAILED
;
3490 ret
= peer_password_unset(peer
);
3491 return bgp_vty_return(vty
, ret
);
3494 DEFUN (neighbor_activate
,
3495 neighbor_activate_cmd
,
3496 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3499 "Enable the Address Family for this Neighbor\n")
3505 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3507 return CMD_WARNING_CONFIG_FAILED
;
3509 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3510 return bgp_vty_return(vty
, ret
);
3513 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3514 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3515 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3516 "Enable the Address Family for this Neighbor\n")
3518 DEFUN (no_neighbor_activate
,
3519 no_neighbor_activate_cmd
,
3520 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3524 "Enable the Address Family for this Neighbor\n")
3531 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3533 return CMD_WARNING_CONFIG_FAILED
;
3535 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3536 return bgp_vty_return(vty
, ret
);
3539 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3540 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3541 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3542 "Enable the Address Family for this Neighbor\n")
3544 DEFUN (neighbor_set_peer_group
,
3545 neighbor_set_peer_group_cmd
,
3546 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3549 "Member of the peer-group\n"
3550 "Peer-group name\n")
3552 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3559 struct peer_group
*group
;
3561 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3563 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3565 vty_out(vty
, "%% Malformed address or name: %s\n",
3566 argv
[idx_peer
]->arg
);
3567 return CMD_WARNING_CONFIG_FAILED
;
3570 if (peer_address_self_check(bgp
, &su
)) {
3572 "%% Can not configure the local system as neighbor\n");
3573 return CMD_WARNING_CONFIG_FAILED
;
3576 /* Disallow for dynamic neighbor. */
3577 peer
= peer_lookup(bgp
, &su
);
3578 if (peer
&& peer_dynamic_neighbor(peer
)) {
3580 "%% Operation not allowed on a dynamic neighbor\n");
3581 return CMD_WARNING_CONFIG_FAILED
;
3585 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3587 vty_out(vty
, "%% Configure the peer-group first\n");
3588 return CMD_WARNING_CONFIG_FAILED
;
3591 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3593 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3595 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3597 return CMD_WARNING_CONFIG_FAILED
;
3600 return bgp_vty_return(vty
, ret
);
3603 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3604 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3605 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3606 "Member of the peer-group\n"
3607 "Peer-group name\n")
3609 DEFUN (no_neighbor_set_peer_group
,
3610 no_neighbor_set_peer_group_cmd
,
3611 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3615 "Member of the peer-group\n"
3616 "Peer-group name\n")
3618 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3623 struct peer_group
*group
;
3625 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3627 return CMD_WARNING_CONFIG_FAILED
;
3629 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3631 vty_out(vty
, "%% Configure the peer-group first\n");
3632 return CMD_WARNING_CONFIG_FAILED
;
3635 ret
= peer_delete(peer
);
3637 return bgp_vty_return(vty
, ret
);
3640 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3641 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3642 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3643 "Member of the peer-group\n"
3644 "Peer-group name\n")
3646 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3647 uint32_t flag
, int set
)
3652 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3654 return CMD_WARNING_CONFIG_FAILED
;
3657 * If 'neighbor <interface>', then this is for directly connected peers,
3658 * we should not accept disable-connected-check.
3660 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3662 "%s is directly connected peer, cannot accept disable-"
3663 "connected-check\n",
3665 return CMD_WARNING_CONFIG_FAILED
;
3668 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3669 peer_tx_shutdown_message_unset(peer
);
3672 ret
= peer_flag_set(peer
, flag
);
3674 ret
= peer_flag_unset(peer
, flag
);
3676 return bgp_vty_return(vty
, ret
);
3679 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3681 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3684 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3687 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3690 /* neighbor passive. */
3691 DEFUN (neighbor_passive
,
3692 neighbor_passive_cmd
,
3693 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3696 "Don't send open messages to this neighbor\n")
3699 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3702 DEFUN (no_neighbor_passive
,
3703 no_neighbor_passive_cmd
,
3704 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3708 "Don't send open messages to this neighbor\n")
3711 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3714 /* neighbor shutdown. */
3715 DEFUN (neighbor_shutdown_msg
,
3716 neighbor_shutdown_msg_cmd
,
3717 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3720 "Administratively shut down this neighbor\n"
3721 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3722 "Shutdown message\n")
3728 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3732 return CMD_WARNING_CONFIG_FAILED
;
3733 message
= argv_concat(argv
, argc
, 4);
3734 peer_tx_shutdown_message_set(peer
, message
);
3735 XFREE(MTYPE_TMP
, message
);
3738 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3741 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3742 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3743 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3744 "Administratively shut down this neighbor\n")
3746 DEFUN (no_neighbor_shutdown_msg
,
3747 no_neighbor_shutdown_msg_cmd
,
3748 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3752 "Administratively shut down this neighbor\n"
3753 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3754 "Shutdown message\n")
3758 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3759 PEER_FLAG_SHUTDOWN
);
3762 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3763 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3764 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3765 "Administratively shut down this neighbor\n")
3767 /* neighbor capability dynamic. */
3768 DEFUN (neighbor_capability_dynamic
,
3769 neighbor_capability_dynamic_cmd
,
3770 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3773 "Advertise capability to the peer\n"
3774 "Advertise dynamic capability to this neighbor\n")
3777 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3778 PEER_FLAG_DYNAMIC_CAPABILITY
);
3781 DEFUN (no_neighbor_capability_dynamic
,
3782 no_neighbor_capability_dynamic_cmd
,
3783 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3787 "Advertise capability to the peer\n"
3788 "Advertise dynamic capability to this neighbor\n")
3791 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3792 PEER_FLAG_DYNAMIC_CAPABILITY
);
3795 /* neighbor dont-capability-negotiate */
3796 DEFUN (neighbor_dont_capability_negotiate
,
3797 neighbor_dont_capability_negotiate_cmd
,
3798 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3801 "Do not perform capability negotiation\n")
3804 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3805 PEER_FLAG_DONT_CAPABILITY
);
3808 DEFUN (no_neighbor_dont_capability_negotiate
,
3809 no_neighbor_dont_capability_negotiate_cmd
,
3810 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3814 "Do not perform capability negotiation\n")
3817 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3818 PEER_FLAG_DONT_CAPABILITY
);
3821 /* neighbor capability extended next hop encoding */
3822 DEFUN (neighbor_capability_enhe
,
3823 neighbor_capability_enhe_cmd
,
3824 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3827 "Advertise capability to the peer\n"
3828 "Advertise extended next-hop capability to the peer\n")
3831 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3832 PEER_FLAG_CAPABILITY_ENHE
);
3835 DEFUN (no_neighbor_capability_enhe
,
3836 no_neighbor_capability_enhe_cmd
,
3837 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3841 "Advertise capability to the peer\n"
3842 "Advertise extended next-hop capability to the peer\n")
3845 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3846 PEER_FLAG_CAPABILITY_ENHE
);
3849 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3850 afi_t afi
, safi_t safi
, uint32_t flag
,
3856 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3858 return CMD_WARNING_CONFIG_FAILED
;
3861 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3863 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3865 return bgp_vty_return(vty
, ret
);
3868 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3869 afi_t afi
, safi_t safi
, uint32_t flag
)
3871 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3874 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3875 afi_t afi
, safi_t safi
, uint32_t flag
)
3877 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3880 /* neighbor capability orf prefix-list. */
3881 DEFUN (neighbor_capability_orf_prefix
,
3882 neighbor_capability_orf_prefix_cmd
,
3883 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3886 "Advertise capability to the peer\n"
3887 "Advertise ORF capability to the peer\n"
3888 "Advertise prefixlist ORF capability to this neighbor\n"
3889 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3890 "Capability to RECEIVE the ORF from this neighbor\n"
3891 "Capability to SEND the ORF to this neighbor\n")
3894 int idx_send_recv
= 5;
3897 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3898 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3899 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3900 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3901 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3902 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3904 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3905 return CMD_WARNING_CONFIG_FAILED
;
3908 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3909 bgp_node_safi(vty
), flag
);
3913 neighbor_capability_orf_prefix
,
3914 neighbor_capability_orf_prefix_hidden_cmd
,
3915 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3916 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3917 "Advertise capability to the peer\n"
3918 "Advertise ORF capability to the peer\n"
3919 "Advertise prefixlist ORF capability to this neighbor\n"
3920 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3921 "Capability to RECEIVE the ORF from this neighbor\n"
3922 "Capability to SEND the ORF to this neighbor\n")
3924 DEFUN (no_neighbor_capability_orf_prefix
,
3925 no_neighbor_capability_orf_prefix_cmd
,
3926 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3930 "Advertise capability to the peer\n"
3931 "Advertise ORF capability to the peer\n"
3932 "Advertise prefixlist ORF capability to this neighbor\n"
3933 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3934 "Capability to RECEIVE the ORF from this neighbor\n"
3935 "Capability to SEND the ORF to this neighbor\n")
3938 int idx_send_recv
= 6;
3941 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3942 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3943 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3944 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3945 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3946 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3948 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3949 return CMD_WARNING_CONFIG_FAILED
;
3952 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3953 bgp_node_afi(vty
), bgp_node_safi(vty
),
3958 no_neighbor_capability_orf_prefix
,
3959 no_neighbor_capability_orf_prefix_hidden_cmd
,
3960 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3961 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3962 "Advertise capability to the peer\n"
3963 "Advertise ORF capability to the peer\n"
3964 "Advertise prefixlist ORF capability to this neighbor\n"
3965 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3966 "Capability to RECEIVE the ORF from this neighbor\n"
3967 "Capability to SEND the ORF to this neighbor\n")
3969 /* neighbor next-hop-self. */
3970 DEFUN (neighbor_nexthop_self
,
3971 neighbor_nexthop_self_cmd
,
3972 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3975 "Disable the next hop calculation for this neighbor\n")
3978 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3979 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3982 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3983 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3984 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3985 "Disable the next hop calculation for this neighbor\n")
3987 /* neighbor next-hop-self. */
3988 DEFUN (neighbor_nexthop_self_force
,
3989 neighbor_nexthop_self_force_cmd
,
3990 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3993 "Disable the next hop calculation for this neighbor\n"
3994 "Set the next hop to self for reflected routes\n")
3997 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3999 PEER_FLAG_FORCE_NEXTHOP_SELF
);
4002 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
4003 neighbor_nexthop_self_force_hidden_cmd
,
4004 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4005 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4006 "Disable the next hop calculation for this neighbor\n"
4007 "Set the next hop to self for reflected routes\n")
4009 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
4010 neighbor_nexthop_self_all_hidden_cmd
,
4011 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
4012 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4013 "Disable the next hop calculation for this neighbor\n"
4014 "Set the next hop to self for reflected routes\n")
4016 DEFUN (no_neighbor_nexthop_self
,
4017 no_neighbor_nexthop_self_cmd
,
4018 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4022 "Disable the next hop calculation for this neighbor\n")
4025 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4026 bgp_node_afi(vty
), bgp_node_safi(vty
),
4027 PEER_FLAG_NEXTHOP_SELF
);
4030 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
4031 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4032 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4033 "Disable the next hop calculation for this neighbor\n")
4035 DEFUN (no_neighbor_nexthop_self_force
,
4036 no_neighbor_nexthop_self_force_cmd
,
4037 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4041 "Disable the next hop calculation for this neighbor\n"
4042 "Set the next hop to self for reflected routes\n")
4045 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4046 bgp_node_afi(vty
), bgp_node_safi(vty
),
4047 PEER_FLAG_FORCE_NEXTHOP_SELF
);
4050 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4051 no_neighbor_nexthop_self_force_hidden_cmd
,
4052 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4053 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4054 "Disable the next hop calculation for this neighbor\n"
4055 "Set the next hop to self for reflected routes\n")
4057 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4058 no_neighbor_nexthop_self_all_hidden_cmd
,
4059 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
4060 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4061 "Disable the next hop calculation for this neighbor\n"
4062 "Set the next hop to self for reflected routes\n")
4064 /* neighbor as-override */
4065 DEFUN (neighbor_as_override
,
4066 neighbor_as_override_cmd
,
4067 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4070 "Override ASNs in outbound updates if aspath equals remote-as\n")
4073 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4074 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
4077 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
4078 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4079 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4080 "Override ASNs in outbound updates if aspath equals remote-as\n")
4082 DEFUN (no_neighbor_as_override
,
4083 no_neighbor_as_override_cmd
,
4084 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4088 "Override ASNs in outbound updates if aspath equals remote-as\n")
4091 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4092 bgp_node_afi(vty
), bgp_node_safi(vty
),
4093 PEER_FLAG_AS_OVERRIDE
);
4096 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
4097 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4098 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4099 "Override ASNs in outbound updates if aspath equals remote-as\n")
4101 /* neighbor remove-private-AS. */
4102 DEFUN (neighbor_remove_private_as
,
4103 neighbor_remove_private_as_cmd
,
4104 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4107 "Remove private ASNs in outbound updates\n")
4110 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4112 PEER_FLAG_REMOVE_PRIVATE_AS
);
4115 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
4116 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4117 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4118 "Remove private ASNs in outbound updates\n")
4120 DEFUN (neighbor_remove_private_as_all
,
4121 neighbor_remove_private_as_all_cmd
,
4122 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4125 "Remove private ASNs in outbound updates\n"
4126 "Apply to all AS numbers\n")
4129 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4131 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4134 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
4135 neighbor_remove_private_as_all_hidden_cmd
,
4136 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4137 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4138 "Remove private ASNs in outbound updates\n"
4139 "Apply to all AS numbers")
4141 DEFUN (neighbor_remove_private_as_replace_as
,
4142 neighbor_remove_private_as_replace_as_cmd
,
4143 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4146 "Remove private ASNs in outbound updates\n"
4147 "Replace private ASNs with our ASN in outbound updates\n")
4150 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4152 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4155 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
4156 neighbor_remove_private_as_replace_as_hidden_cmd
,
4157 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4158 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4159 "Remove private ASNs in outbound updates\n"
4160 "Replace private ASNs with our ASN in outbound updates\n")
4162 DEFUN (neighbor_remove_private_as_all_replace_as
,
4163 neighbor_remove_private_as_all_replace_as_cmd
,
4164 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4167 "Remove private ASNs in outbound updates\n"
4168 "Apply to all AS numbers\n"
4169 "Replace private ASNs with our ASN in outbound updates\n")
4172 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4174 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4178 neighbor_remove_private_as_all_replace_as
,
4179 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4180 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4181 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4182 "Remove private ASNs in outbound updates\n"
4183 "Apply to all AS numbers\n"
4184 "Replace private ASNs with our ASN in outbound updates\n")
4186 DEFUN (no_neighbor_remove_private_as
,
4187 no_neighbor_remove_private_as_cmd
,
4188 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4192 "Remove private ASNs in outbound updates\n")
4195 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4196 bgp_node_afi(vty
), bgp_node_safi(vty
),
4197 PEER_FLAG_REMOVE_PRIVATE_AS
);
4200 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4201 no_neighbor_remove_private_as_hidden_cmd
,
4202 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4203 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4204 "Remove private ASNs in outbound updates\n")
4206 DEFUN (no_neighbor_remove_private_as_all
,
4207 no_neighbor_remove_private_as_all_cmd
,
4208 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4212 "Remove private ASNs in outbound updates\n"
4213 "Apply to all AS numbers\n")
4216 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4217 bgp_node_afi(vty
), bgp_node_safi(vty
),
4218 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4221 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4222 no_neighbor_remove_private_as_all_hidden_cmd
,
4223 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4224 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4225 "Remove private ASNs in outbound updates\n"
4226 "Apply to all AS numbers\n")
4228 DEFUN (no_neighbor_remove_private_as_replace_as
,
4229 no_neighbor_remove_private_as_replace_as_cmd
,
4230 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4234 "Remove private ASNs in outbound updates\n"
4235 "Replace private ASNs with our ASN in outbound updates\n")
4238 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4239 bgp_node_afi(vty
), bgp_node_safi(vty
),
4240 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4243 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4244 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4245 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4246 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4247 "Remove private ASNs in outbound updates\n"
4248 "Replace private ASNs with our ASN in outbound updates\n")
4250 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4251 no_neighbor_remove_private_as_all_replace_as_cmd
,
4252 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4256 "Remove private ASNs in outbound updates\n"
4257 "Apply to all AS numbers\n"
4258 "Replace private ASNs with our ASN in outbound updates\n")
4261 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4262 bgp_node_afi(vty
), bgp_node_safi(vty
),
4263 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4267 no_neighbor_remove_private_as_all_replace_as
,
4268 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4269 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4270 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4271 "Remove private ASNs in outbound updates\n"
4272 "Apply to all AS numbers\n"
4273 "Replace private ASNs with our ASN in outbound updates\n")
4276 /* neighbor send-community. */
4277 DEFUN (neighbor_send_community
,
4278 neighbor_send_community_cmd
,
4279 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4282 "Send Community attribute to this neighbor\n")
4286 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4288 PEER_FLAG_SEND_COMMUNITY
);
4291 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4292 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4293 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4294 "Send Community attribute to this neighbor\n")
4296 DEFUN (no_neighbor_send_community
,
4297 no_neighbor_send_community_cmd
,
4298 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4302 "Send Community attribute to this neighbor\n")
4306 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4307 bgp_node_afi(vty
), bgp_node_safi(vty
),
4308 PEER_FLAG_SEND_COMMUNITY
);
4311 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4312 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4313 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4314 "Send Community attribute to this neighbor\n")
4316 /* neighbor send-community extended. */
4317 DEFUN (neighbor_send_community_type
,
4318 neighbor_send_community_type_cmd
,
4319 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4322 "Send Community attribute to this neighbor\n"
4323 "Send Standard and Extended Community attributes\n"
4324 "Send Standard, Large and Extended Community attributes\n"
4325 "Send Extended Community attributes\n"
4326 "Send Standard Community attributes\n"
4327 "Send Large Community attributes\n")
4331 const char *type
= argv
[argc
- 1]->text
;
4333 if (strmatch(type
, "standard")) {
4334 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4335 } else if (strmatch(type
, "extended")) {
4336 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4337 } else if (strmatch(type
, "large")) {
4338 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4339 } else if (strmatch(type
, "both")) {
4340 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4341 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4342 } else { /* if (strmatch(type, "all")) */
4343 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4344 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4345 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4348 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4349 bgp_node_safi(vty
), flag
);
4353 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4354 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4355 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4356 "Send Community attribute to this neighbor\n"
4357 "Send Standard and Extended Community attributes\n"
4358 "Send Standard, Large and Extended Community attributes\n"
4359 "Send Extended Community attributes\n"
4360 "Send Standard Community attributes\n"
4361 "Send Large Community attributes\n")
4363 DEFUN (no_neighbor_send_community_type
,
4364 no_neighbor_send_community_type_cmd
,
4365 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4369 "Send Community attribute to this neighbor\n"
4370 "Send Standard and Extended Community attributes\n"
4371 "Send Standard, Large and Extended Community attributes\n"
4372 "Send Extended Community attributes\n"
4373 "Send Standard Community attributes\n"
4374 "Send Large Community attributes\n")
4378 const char *type
= argv
[argc
- 1]->text
;
4380 if (strmatch(type
, "standard")) {
4381 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4382 } else if (strmatch(type
, "extended")) {
4383 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4384 } else if (strmatch(type
, "large")) {
4385 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4386 } else if (strmatch(type
, "both")) {
4387 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4388 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4389 } else { /* if (strmatch(type, "all")) */
4390 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4391 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4392 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4395 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4396 bgp_node_afi(vty
), bgp_node_safi(vty
),
4401 no_neighbor_send_community_type
,
4402 no_neighbor_send_community_type_hidden_cmd
,
4403 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4404 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4405 "Send Community attribute to this neighbor\n"
4406 "Send Standard and Extended Community attributes\n"
4407 "Send Standard, Large and Extended Community attributes\n"
4408 "Send Extended Community attributes\n"
4409 "Send Standard Community attributes\n"
4410 "Send Large Community attributes\n")
4412 /* neighbor soft-reconfig. */
4413 DEFUN (neighbor_soft_reconfiguration
,
4414 neighbor_soft_reconfiguration_cmd
,
4415 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4418 "Per neighbor soft reconfiguration\n"
4419 "Allow inbound soft reconfiguration for this neighbor\n")
4422 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4424 PEER_FLAG_SOFT_RECONFIG
);
4427 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4428 neighbor_soft_reconfiguration_hidden_cmd
,
4429 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4430 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4431 "Per neighbor soft reconfiguration\n"
4432 "Allow inbound soft reconfiguration for this neighbor\n")
4434 DEFUN (no_neighbor_soft_reconfiguration
,
4435 no_neighbor_soft_reconfiguration_cmd
,
4436 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4440 "Per neighbor soft reconfiguration\n"
4441 "Allow inbound soft reconfiguration for this neighbor\n")
4444 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4445 bgp_node_afi(vty
), bgp_node_safi(vty
),
4446 PEER_FLAG_SOFT_RECONFIG
);
4449 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4450 no_neighbor_soft_reconfiguration_hidden_cmd
,
4451 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4452 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4453 "Per neighbor soft reconfiguration\n"
4454 "Allow inbound soft reconfiguration for this neighbor\n")
4456 DEFUN (neighbor_route_reflector_client
,
4457 neighbor_route_reflector_client_cmd
,
4458 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4461 "Configure a neighbor as Route Reflector client\n")
4467 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4469 return CMD_WARNING_CONFIG_FAILED
;
4471 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4473 PEER_FLAG_REFLECTOR_CLIENT
);
4476 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4477 neighbor_route_reflector_client_hidden_cmd
,
4478 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4479 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4480 "Configure a neighbor as Route Reflector client\n")
4482 DEFUN (no_neighbor_route_reflector_client
,
4483 no_neighbor_route_reflector_client_cmd
,
4484 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4488 "Configure a neighbor as Route Reflector client\n")
4491 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4492 bgp_node_afi(vty
), bgp_node_safi(vty
),
4493 PEER_FLAG_REFLECTOR_CLIENT
);
4496 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4497 no_neighbor_route_reflector_client_hidden_cmd
,
4498 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4499 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4500 "Configure a neighbor as Route Reflector client\n")
4502 /* neighbor route-server-client. */
4503 DEFUN (neighbor_route_server_client
,
4504 neighbor_route_server_client_cmd
,
4505 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4508 "Configure a neighbor as Route Server client\n")
4513 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4515 return CMD_WARNING_CONFIG_FAILED
;
4516 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4518 PEER_FLAG_RSERVER_CLIENT
);
4521 ALIAS_HIDDEN(neighbor_route_server_client
,
4522 neighbor_route_server_client_hidden_cmd
,
4523 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4524 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4525 "Configure a neighbor as Route Server client\n")
4527 DEFUN (no_neighbor_route_server_client
,
4528 no_neighbor_route_server_client_cmd
,
4529 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4533 "Configure a neighbor as Route Server client\n")
4536 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4537 bgp_node_afi(vty
), bgp_node_safi(vty
),
4538 PEER_FLAG_RSERVER_CLIENT
);
4541 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4542 no_neighbor_route_server_client_hidden_cmd
,
4543 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4544 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4545 "Configure a neighbor as Route Server client\n")
4547 DEFUN (neighbor_nexthop_local_unchanged
,
4548 neighbor_nexthop_local_unchanged_cmd
,
4549 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4552 "Configure treatment of outgoing link-local nexthop attribute\n"
4553 "Leave link-local nexthop unchanged for this peer\n")
4556 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4558 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4561 DEFUN (no_neighbor_nexthop_local_unchanged
,
4562 no_neighbor_nexthop_local_unchanged_cmd
,
4563 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4567 "Configure treatment of outgoing link-local-nexthop attribute\n"
4568 "Leave link-local nexthop unchanged for this peer\n")
4571 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4572 bgp_node_afi(vty
), bgp_node_safi(vty
),
4573 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4576 DEFUN (neighbor_attr_unchanged
,
4577 neighbor_attr_unchanged_cmd
,
4578 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4581 "BGP attribute is propagated unchanged to this neighbor\n"
4582 "As-path attribute\n"
4583 "Nexthop attribute\n"
4587 char *peer_str
= argv
[1]->arg
;
4590 afi_t afi
= bgp_node_afi(vty
);
4591 safi_t safi
= bgp_node_safi(vty
);
4593 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4595 return CMD_WARNING_CONFIG_FAILED
;
4597 if (argv_find(argv
, argc
, "as-path", &idx
))
4598 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4600 if (argv_find(argv
, argc
, "next-hop", &idx
))
4601 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4603 if (argv_find(argv
, argc
, "med", &idx
))
4604 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4606 /* no flags means all of them! */
4608 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4609 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4610 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4612 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4613 && peer_af_flag_check(peer
, afi
, safi
,
4614 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4615 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4616 PEER_FLAG_AS_PATH_UNCHANGED
);
4619 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4620 && peer_af_flag_check(peer
, afi
, safi
,
4621 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4622 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4623 PEER_FLAG_NEXTHOP_UNCHANGED
);
4626 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4627 && peer_af_flag_check(peer
, afi
, safi
,
4628 PEER_FLAG_MED_UNCHANGED
)) {
4629 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4630 PEER_FLAG_MED_UNCHANGED
);
4634 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4638 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4639 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4640 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4641 "BGP attribute is propagated unchanged to this neighbor\n"
4642 "As-path attribute\n"
4643 "Nexthop attribute\n"
4646 DEFUN (no_neighbor_attr_unchanged
,
4647 no_neighbor_attr_unchanged_cmd
,
4648 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4652 "BGP attribute is propagated unchanged to this neighbor\n"
4653 "As-path attribute\n"
4654 "Nexthop attribute\n"
4658 char *peer
= argv
[2]->arg
;
4661 if (argv_find(argv
, argc
, "as-path", &idx
))
4662 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4664 if (argv_find(argv
, argc
, "next-hop", &idx
))
4665 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4667 if (argv_find(argv
, argc
, "med", &idx
))
4668 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4670 if (!flags
) // no flags means all of them!
4672 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4673 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4674 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4677 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4678 bgp_node_safi(vty
), flags
);
4682 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4683 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4684 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4685 "BGP attribute is propagated unchanged to this neighbor\n"
4686 "As-path attribute\n"
4687 "Nexthop attribute\n"
4690 /* EBGP multihop configuration. */
4691 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4692 const char *ttl_str
)
4697 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4699 return CMD_WARNING_CONFIG_FAILED
;
4702 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4707 ttl
= strtoul(ttl_str
, NULL
, 10);
4709 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4712 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4716 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4718 return CMD_WARNING_CONFIG_FAILED
;
4720 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4723 /* neighbor ebgp-multihop. */
4724 DEFUN (neighbor_ebgp_multihop
,
4725 neighbor_ebgp_multihop_cmd
,
4726 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4729 "Allow EBGP neighbors not on directly connected networks\n")
4732 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4735 DEFUN (neighbor_ebgp_multihop_ttl
,
4736 neighbor_ebgp_multihop_ttl_cmd
,
4737 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4740 "Allow EBGP neighbors not on directly connected networks\n"
4741 "maximum hop count\n")
4745 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4746 argv
[idx_number
]->arg
);
4749 DEFUN (no_neighbor_ebgp_multihop
,
4750 no_neighbor_ebgp_multihop_cmd
,
4751 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4755 "Allow EBGP neighbors not on directly connected networks\n"
4756 "maximum hop count\n")
4759 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4763 /* disable-connected-check */
4764 DEFUN (neighbor_disable_connected_check
,
4765 neighbor_disable_connected_check_cmd
,
4766 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4769 "one-hop away EBGP peer using loopback address\n"
4770 "Enforce EBGP neighbors perform multihop\n")
4773 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4774 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4777 DEFUN (no_neighbor_disable_connected_check
,
4778 no_neighbor_disable_connected_check_cmd
,
4779 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4783 "one-hop away EBGP peer using loopback address\n"
4784 "Enforce EBGP neighbors perform multihop\n")
4787 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4788 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4792 /* enforce-first-as */
4793 DEFUN (neighbor_enforce_first_as
,
4794 neighbor_enforce_first_as_cmd
,
4795 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4798 "Enforce the first AS for EBGP routes\n")
4802 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4803 PEER_FLAG_ENFORCE_FIRST_AS
);
4806 DEFUN (no_neighbor_enforce_first_as
,
4807 no_neighbor_enforce_first_as_cmd
,
4808 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4812 "Enforce the first AS for EBGP routes\n")
4816 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4817 PEER_FLAG_ENFORCE_FIRST_AS
);
4821 DEFUN (neighbor_description
,
4822 neighbor_description_cmd
,
4823 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4826 "Neighbor specific description\n"
4827 "Up to 80 characters describing this neighbor\n")
4834 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4836 return CMD_WARNING_CONFIG_FAILED
;
4838 str
= argv_concat(argv
, argc
, idx_line
);
4840 peer_description_set(peer
, str
);
4842 XFREE(MTYPE_TMP
, str
);
4847 DEFUN (no_neighbor_description
,
4848 no_neighbor_description_cmd
,
4849 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4853 "Neighbor specific description\n")
4858 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4860 return CMD_WARNING_CONFIG_FAILED
;
4862 peer_description_unset(peer
);
4867 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4868 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4869 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4870 "Neighbor specific description\n"
4871 "Up to 80 characters describing this neighbor\n")
4873 /* Neighbor update-source. */
4874 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4875 const char *source_str
)
4881 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4883 return CMD_WARNING_CONFIG_FAILED
;
4889 if (str2sockunion(source_str
, &su
) == 0)
4890 peer_update_source_addr_set(peer
, &su
);
4892 if (str2prefix(source_str
, &p
)) {
4894 "%% Invalid update-source, remove prefix length \n");
4895 return CMD_WARNING_CONFIG_FAILED
;
4897 peer_update_source_if_set(peer
, source_str
);
4900 peer_update_source_unset(peer
);
4905 #define BGP_UPDATE_SOURCE_HELP_STR \
4908 "Interface name (requires zebra to be running)\n"
4910 DEFUN (neighbor_update_source
,
4911 neighbor_update_source_cmd
,
4912 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4915 "Source of routing updates\n"
4916 BGP_UPDATE_SOURCE_HELP_STR
)
4920 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4921 argv
[idx_peer_2
]->arg
);
4924 DEFUN (no_neighbor_update_source
,
4925 no_neighbor_update_source_cmd
,
4926 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4930 "Source of routing updates\n"
4931 BGP_UPDATE_SOURCE_HELP_STR
)
4934 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4937 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4938 afi_t afi
, safi_t safi
,
4939 const char *rmap
, int set
)
4943 struct route_map
*route_map
= NULL
;
4945 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4947 return CMD_WARNING_CONFIG_FAILED
;
4951 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
4952 ret
= peer_default_originate_set(peer
, afi
, safi
,
4955 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4957 return bgp_vty_return(vty
, ret
);
4960 /* neighbor default-originate. */
4961 DEFUN (neighbor_default_originate
,
4962 neighbor_default_originate_cmd
,
4963 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4966 "Originate default route to this neighbor\n")
4969 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4971 bgp_node_safi(vty
), NULL
, 1);
4974 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4975 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4976 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4977 "Originate default route to this neighbor\n")
4979 DEFUN (neighbor_default_originate_rmap
,
4980 neighbor_default_originate_rmap_cmd
,
4981 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4984 "Originate default route to this neighbor\n"
4985 "Route-map to specify criteria to originate default\n"
4990 return peer_default_originate_set_vty(
4991 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4992 argv
[idx_word
]->arg
, 1);
4996 neighbor_default_originate_rmap
,
4997 neighbor_default_originate_rmap_hidden_cmd
,
4998 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4999 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5000 "Originate default route to this neighbor\n"
5001 "Route-map to specify criteria to originate default\n"
5004 DEFUN (no_neighbor_default_originate
,
5005 no_neighbor_default_originate_cmd
,
5006 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
5010 "Originate default route to this neighbor\n"
5011 "Route-map to specify criteria to originate default\n"
5015 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
5017 bgp_node_safi(vty
), NULL
, 0);
5021 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
5022 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
5023 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5024 "Originate default route to this neighbor\n"
5025 "Route-map to specify criteria to originate default\n"
5029 /* Set neighbor's BGP port. */
5030 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
5031 const char *port_str
)
5037 peer
= peer_lookup_vty(vty
, ip_str
);
5039 return CMD_WARNING_CONFIG_FAILED
;
5042 sp
= getservbyname("bgp", "tcp");
5043 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
5045 port
= strtoul(port_str
, NULL
, 10);
5048 peer_port_set(peer
, port
);
5053 /* Set specified peer's BGP port. */
5054 DEFUN (neighbor_port
,
5056 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
5059 "Neighbor's BGP port\n"
5060 "TCP port number\n")
5064 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
5065 argv
[idx_number
]->arg
);
5068 DEFUN (no_neighbor_port
,
5069 no_neighbor_port_cmd
,
5070 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
5074 "Neighbor's BGP port\n"
5075 "TCP port number\n")
5078 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
5082 /* neighbor weight. */
5083 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5084 safi_t safi
, const char *weight_str
)
5088 unsigned long weight
;
5090 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5092 return CMD_WARNING_CONFIG_FAILED
;
5094 weight
= strtoul(weight_str
, NULL
, 10);
5096 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
5097 return bgp_vty_return(vty
, ret
);
5100 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5106 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5108 return CMD_WARNING_CONFIG_FAILED
;
5110 ret
= peer_weight_unset(peer
, afi
, safi
);
5111 return bgp_vty_return(vty
, ret
);
5114 DEFUN (neighbor_weight
,
5115 neighbor_weight_cmd
,
5116 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5119 "Set default weight for routes from this neighbor\n"
5124 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5125 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
5128 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
5129 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5130 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5131 "Set default weight for routes from this neighbor\n"
5134 DEFUN (no_neighbor_weight
,
5135 no_neighbor_weight_cmd
,
5136 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5140 "Set default weight for routes from this neighbor\n"
5144 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
5145 bgp_node_afi(vty
), bgp_node_safi(vty
));
5148 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
5149 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5150 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5151 "Set default weight for routes from this neighbor\n"
5155 /* Override capability negotiation. */
5156 DEFUN (neighbor_override_capability
,
5157 neighbor_override_capability_cmd
,
5158 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5161 "Override capability negotiation result\n")
5164 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5165 PEER_FLAG_OVERRIDE_CAPABILITY
);
5168 DEFUN (no_neighbor_override_capability
,
5169 no_neighbor_override_capability_cmd
,
5170 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5174 "Override capability negotiation result\n")
5177 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5178 PEER_FLAG_OVERRIDE_CAPABILITY
);
5181 DEFUN (neighbor_strict_capability
,
5182 neighbor_strict_capability_cmd
,
5183 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5186 "Strict capability negotiation match\n")
5190 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5191 PEER_FLAG_STRICT_CAP_MATCH
);
5194 DEFUN (no_neighbor_strict_capability
,
5195 no_neighbor_strict_capability_cmd
,
5196 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5200 "Strict capability negotiation match\n")
5204 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5205 PEER_FLAG_STRICT_CAP_MATCH
);
5208 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5209 const char *keep_str
, const char *hold_str
)
5216 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5218 return CMD_WARNING_CONFIG_FAILED
;
5220 keepalive
= strtoul(keep_str
, NULL
, 10);
5221 holdtime
= strtoul(hold_str
, NULL
, 10);
5223 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5225 return bgp_vty_return(vty
, ret
);
5228 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5233 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5235 return CMD_WARNING_CONFIG_FAILED
;
5237 ret
= peer_timers_unset(peer
);
5239 return bgp_vty_return(vty
, ret
);
5242 DEFUN (neighbor_timers
,
5243 neighbor_timers_cmd
,
5244 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5247 "BGP per neighbor timers\n"
5248 "Keepalive interval\n"
5253 int idx_number_2
= 4;
5254 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5255 argv
[idx_number
]->arg
,
5256 argv
[idx_number_2
]->arg
);
5259 DEFUN (no_neighbor_timers
,
5260 no_neighbor_timers_cmd
,
5261 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5265 "BGP per neighbor timers\n"
5266 "Keepalive interval\n"
5270 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5274 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5275 const char *time_str
)
5281 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5283 return CMD_WARNING_CONFIG_FAILED
;
5285 connect
= strtoul(time_str
, NULL
, 10);
5287 ret
= peer_timers_connect_set(peer
, connect
);
5289 return bgp_vty_return(vty
, ret
);
5292 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5297 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5299 return CMD_WARNING_CONFIG_FAILED
;
5301 ret
= peer_timers_connect_unset(peer
);
5303 return bgp_vty_return(vty
, ret
);
5306 DEFUN (neighbor_timers_connect
,
5307 neighbor_timers_connect_cmd
,
5308 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5311 "BGP per neighbor timers\n"
5312 "BGP connect timer\n"
5317 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5318 argv
[idx_number
]->arg
);
5321 DEFUN (no_neighbor_timers_connect
,
5322 no_neighbor_timers_connect_cmd
,
5323 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5327 "BGP per neighbor timers\n"
5328 "BGP connect timer\n"
5332 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5336 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5337 const char *time_str
, int set
)
5341 uint32_t routeadv
= 0;
5343 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5345 return CMD_WARNING_CONFIG_FAILED
;
5348 routeadv
= strtoul(time_str
, NULL
, 10);
5351 ret
= peer_advertise_interval_set(peer
, routeadv
);
5353 ret
= peer_advertise_interval_unset(peer
);
5355 return bgp_vty_return(vty
, ret
);
5358 DEFUN (neighbor_advertise_interval
,
5359 neighbor_advertise_interval_cmd
,
5360 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5363 "Minimum interval between sending BGP routing updates\n"
5364 "time in seconds\n")
5368 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5369 argv
[idx_number
]->arg
, 1);
5372 DEFUN (no_neighbor_advertise_interval
,
5373 no_neighbor_advertise_interval_cmd
,
5374 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5378 "Minimum interval between sending BGP routing updates\n"
5379 "time in seconds\n")
5382 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5386 /* Time to wait before processing route-map updates */
5387 DEFUN (bgp_set_route_map_delay_timer
,
5388 bgp_set_route_map_delay_timer_cmd
,
5389 "bgp route-map delay-timer (0-600)",
5391 "BGP route-map delay timer\n"
5392 "Time in secs to wait before processing route-map changes\n"
5393 "0 disables the timer, no route updates happen when route-maps change\n")
5396 uint32_t rmap_delay_timer
;
5398 if (argv
[idx_number
]->arg
) {
5399 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5400 bm
->rmap_update_timer
= rmap_delay_timer
;
5402 /* if the dynamic update handling is being disabled, and a timer
5404 * running, stop the timer and act as if the timer has already
5407 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5408 BGP_TIMER_OFF(bm
->t_rmap_update
);
5409 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5414 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5415 return CMD_WARNING_CONFIG_FAILED
;
5419 DEFUN (no_bgp_set_route_map_delay_timer
,
5420 no_bgp_set_route_map_delay_timer_cmd
,
5421 "no bgp route-map delay-timer [(0-600)]",
5424 "Default BGP route-map delay timer\n"
5425 "Reset to default time to wait for processing route-map changes\n"
5426 "0 disables the timer, no route updates happen when route-maps change\n")
5429 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5435 /* neighbor interface */
5436 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5441 peer
= peer_lookup_vty(vty
, ip_str
);
5442 if (!peer
|| peer
->conf_if
) {
5443 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5444 return CMD_WARNING_CONFIG_FAILED
;
5448 peer_interface_set(peer
, str
);
5450 peer_interface_unset(peer
);
5455 DEFUN (neighbor_interface
,
5456 neighbor_interface_cmd
,
5457 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5465 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5468 DEFUN (no_neighbor_interface
,
5469 no_neighbor_interface_cmd
,
5470 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5478 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5481 DEFUN (neighbor_distribute_list
,
5482 neighbor_distribute_list_cmd
,
5483 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5486 "Filter updates to/from this neighbor\n"
5487 "IP access-list number\n"
5488 "IP access-list number (expanded range)\n"
5489 "IP Access-list name\n"
5490 "Filter incoming updates\n"
5491 "Filter outgoing updates\n")
5498 const char *pstr
= argv
[idx_peer
]->arg
;
5499 const char *acl
= argv
[idx_acl
]->arg
;
5500 const char *inout
= argv
[argc
- 1]->text
;
5502 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5504 return CMD_WARNING_CONFIG_FAILED
;
5506 /* Check filter direction. */
5507 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5508 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5511 return bgp_vty_return(vty
, ret
);
5515 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5516 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5517 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5518 "Filter updates to/from this neighbor\n"
5519 "IP access-list number\n"
5520 "IP access-list number (expanded range)\n"
5521 "IP Access-list name\n"
5522 "Filter incoming updates\n"
5523 "Filter outgoing updates\n")
5525 DEFUN (no_neighbor_distribute_list
,
5526 no_neighbor_distribute_list_cmd
,
5527 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5531 "Filter updates to/from this neighbor\n"
5532 "IP access-list number\n"
5533 "IP access-list number (expanded range)\n"
5534 "IP Access-list name\n"
5535 "Filter incoming updates\n"
5536 "Filter outgoing updates\n")
5542 const char *pstr
= argv
[idx_peer
]->arg
;
5543 const char *inout
= argv
[argc
- 1]->text
;
5545 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5547 return CMD_WARNING_CONFIG_FAILED
;
5549 /* Check filter direction. */
5550 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5551 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5554 return bgp_vty_return(vty
, ret
);
5558 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5559 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5560 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5561 "Filter updates to/from this neighbor\n"
5562 "IP access-list number\n"
5563 "IP access-list number (expanded range)\n"
5564 "IP Access-list name\n"
5565 "Filter incoming updates\n"
5566 "Filter outgoing updates\n")
5568 /* Set prefix list to the peer. */
5569 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5570 afi_t afi
, safi_t safi
,
5571 const char *name_str
,
5572 const char *direct_str
)
5575 int direct
= FILTER_IN
;
5578 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5580 return CMD_WARNING_CONFIG_FAILED
;
5582 /* Check filter direction. */
5583 if (strncmp(direct_str
, "i", 1) == 0)
5585 else if (strncmp(direct_str
, "o", 1) == 0)
5586 direct
= FILTER_OUT
;
5588 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5590 return bgp_vty_return(vty
, ret
);
5593 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5594 afi_t afi
, safi_t safi
,
5595 const char *direct_str
)
5599 int direct
= FILTER_IN
;
5601 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5603 return CMD_WARNING_CONFIG_FAILED
;
5605 /* Check filter direction. */
5606 if (strncmp(direct_str
, "i", 1) == 0)
5608 else if (strncmp(direct_str
, "o", 1) == 0)
5609 direct
= FILTER_OUT
;
5611 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5613 return bgp_vty_return(vty
, ret
);
5616 DEFUN (neighbor_prefix_list
,
5617 neighbor_prefix_list_cmd
,
5618 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
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")
5629 return peer_prefix_list_set_vty(
5630 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5631 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5634 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5635 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5636 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5637 "Filter updates to/from this neighbor\n"
5638 "Name of a prefix list\n"
5639 "Filter incoming updates\n"
5640 "Filter outgoing updates\n")
5642 DEFUN (no_neighbor_prefix_list
,
5643 no_neighbor_prefix_list_cmd
,
5644 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5648 "Filter updates to/from this neighbor\n"
5649 "Name of a prefix list\n"
5650 "Filter incoming updates\n"
5651 "Filter outgoing updates\n")
5655 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5656 bgp_node_afi(vty
), bgp_node_safi(vty
),
5657 argv
[idx_in_out
]->arg
);
5660 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5661 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5662 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5663 "Filter updates to/from this neighbor\n"
5664 "Name of a prefix list\n"
5665 "Filter incoming updates\n"
5666 "Filter outgoing updates\n")
5668 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5669 safi_t safi
, const char *name_str
,
5670 const char *direct_str
)
5674 int direct
= FILTER_IN
;
5676 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5678 return CMD_WARNING_CONFIG_FAILED
;
5680 /* Check filter direction. */
5681 if (strncmp(direct_str
, "i", 1) == 0)
5683 else if (strncmp(direct_str
, "o", 1) == 0)
5684 direct
= FILTER_OUT
;
5686 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5688 return bgp_vty_return(vty
, ret
);
5691 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5692 safi_t safi
, const char *direct_str
)
5696 int direct
= FILTER_IN
;
5698 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5700 return CMD_WARNING_CONFIG_FAILED
;
5702 /* Check filter direction. */
5703 if (strncmp(direct_str
, "i", 1) == 0)
5705 else if (strncmp(direct_str
, "o", 1) == 0)
5706 direct
= FILTER_OUT
;
5708 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5710 return bgp_vty_return(vty
, ret
);
5713 DEFUN (neighbor_filter_list
,
5714 neighbor_filter_list_cmd
,
5715 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5718 "Establish BGP filters\n"
5719 "AS path access-list name\n"
5720 "Filter incoming routes\n"
5721 "Filter outgoing routes\n")
5726 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5727 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5728 argv
[idx_in_out
]->arg
);
5731 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5732 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5733 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5734 "Establish BGP filters\n"
5735 "AS path access-list name\n"
5736 "Filter incoming routes\n"
5737 "Filter outgoing routes\n")
5739 DEFUN (no_neighbor_filter_list
,
5740 no_neighbor_filter_list_cmd
,
5741 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5745 "Establish BGP filters\n"
5746 "AS path access-list name\n"
5747 "Filter incoming routes\n"
5748 "Filter outgoing routes\n")
5752 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5753 bgp_node_afi(vty
), bgp_node_safi(vty
),
5754 argv
[idx_in_out
]->arg
);
5757 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5758 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5759 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5760 "Establish BGP filters\n"
5761 "AS path access-list name\n"
5762 "Filter incoming routes\n"
5763 "Filter outgoing routes\n")
5765 /* Set route-map to the peer. */
5766 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5767 afi_t afi
, safi_t safi
, const char *name_str
,
5768 const char *direct_str
)
5772 int direct
= RMAP_IN
;
5773 struct route_map
*route_map
;
5775 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5777 return CMD_WARNING_CONFIG_FAILED
;
5779 /* Check filter direction. */
5780 if (strncmp(direct_str
, "in", 2) == 0)
5782 else if (strncmp(direct_str
, "o", 1) == 0)
5785 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5786 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
5788 return bgp_vty_return(vty
, ret
);
5791 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5792 afi_t afi
, safi_t safi
,
5793 const char *direct_str
)
5797 int direct
= RMAP_IN
;
5799 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5801 return CMD_WARNING_CONFIG_FAILED
;
5803 /* Check filter direction. */
5804 if (strncmp(direct_str
, "in", 2) == 0)
5806 else if (strncmp(direct_str
, "o", 1) == 0)
5809 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5811 return bgp_vty_return(vty
, ret
);
5814 DEFUN (neighbor_route_map
,
5815 neighbor_route_map_cmd
,
5816 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
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")
5827 return peer_route_map_set_vty(
5828 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5829 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5832 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5833 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5834 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5835 "Apply route map to neighbor\n"
5836 "Name of route map\n"
5837 "Apply map to incoming routes\n"
5838 "Apply map to outbound routes\n")
5840 DEFUN (no_neighbor_route_map
,
5841 no_neighbor_route_map_cmd
,
5842 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5846 "Apply route map to neighbor\n"
5847 "Name of route map\n"
5848 "Apply map to incoming routes\n"
5849 "Apply map to outbound routes\n")
5853 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5854 bgp_node_afi(vty
), bgp_node_safi(vty
),
5855 argv
[idx_in_out
]->arg
);
5858 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5859 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5860 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5861 "Apply route map to neighbor\n"
5862 "Name of route map\n"
5863 "Apply map to incoming routes\n"
5864 "Apply map to outbound routes\n")
5866 /* Set unsuppress-map to the peer. */
5867 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5868 afi_t afi
, safi_t safi
,
5869 const char *name_str
)
5873 struct route_map
*route_map
;
5875 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5877 return CMD_WARNING_CONFIG_FAILED
;
5879 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5880 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
5882 return bgp_vty_return(vty
, ret
);
5885 /* Unset route-map from the peer. */
5886 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5887 afi_t afi
, safi_t safi
)
5892 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5894 return CMD_WARNING_CONFIG_FAILED
;
5896 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5898 return bgp_vty_return(vty
, ret
);
5901 DEFUN (neighbor_unsuppress_map
,
5902 neighbor_unsuppress_map_cmd
,
5903 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5906 "Route-map to selectively unsuppress suppressed routes\n"
5907 "Name of route map\n")
5911 return peer_unsuppress_map_set_vty(
5912 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5913 argv
[idx_word
]->arg
);
5916 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5917 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5918 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5919 "Route-map to selectively unsuppress suppressed routes\n"
5920 "Name of route map\n")
5922 DEFUN (no_neighbor_unsuppress_map
,
5923 no_neighbor_unsuppress_map_cmd
,
5924 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5928 "Route-map to selectively unsuppress suppressed routes\n"
5929 "Name of route map\n")
5932 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5934 bgp_node_safi(vty
));
5937 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5938 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5939 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5940 "Route-map to selectively unsuppress suppressed routes\n"
5941 "Name of route map\n")
5943 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5944 afi_t afi
, safi_t safi
,
5945 const char *num_str
,
5946 const char *threshold_str
, int warning
,
5947 const char *restart_str
)
5955 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5957 return CMD_WARNING_CONFIG_FAILED
;
5959 max
= strtoul(num_str
, NULL
, 10);
5961 threshold
= atoi(threshold_str
);
5963 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5966 restart
= atoi(restart_str
);
5970 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5973 return bgp_vty_return(vty
, ret
);
5976 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5977 afi_t afi
, safi_t safi
)
5982 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5984 return CMD_WARNING_CONFIG_FAILED
;
5986 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5988 return bgp_vty_return(vty
, ret
);
5991 /* Maximum number of prefix configuration. prefix count is different
5992 for each peer configuration. So this configuration can be set for
5993 each peer configuration. */
5994 DEFUN (neighbor_maximum_prefix
,
5995 neighbor_maximum_prefix_cmd
,
5996 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5999 "Maximum number of prefix accept from this peer\n"
6000 "maximum no. of prefix limit\n")
6004 return peer_maximum_prefix_set_vty(
6005 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6006 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
6009 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
6010 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
6011 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6012 "Maximum number of prefix accept from this peer\n"
6013 "maximum no. of prefix limit\n")
6015 DEFUN (neighbor_maximum_prefix_threshold
,
6016 neighbor_maximum_prefix_threshold_cmd
,
6017 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
6020 "Maximum number of prefix accept from this peer\n"
6021 "maximum no. of prefix limit\n"
6022 "Threshold value (%) at which to generate a warning msg\n")
6026 int idx_number_2
= 4;
6027 return peer_maximum_prefix_set_vty(
6028 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6029 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
6033 neighbor_maximum_prefix_threshold
,
6034 neighbor_maximum_prefix_threshold_hidden_cmd
,
6035 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
6036 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6037 "Maximum number of prefix accept from this peer\n"
6038 "maximum no. of prefix limit\n"
6039 "Threshold value (%) at which to generate a warning msg\n")
6041 DEFUN (neighbor_maximum_prefix_warning
,
6042 neighbor_maximum_prefix_warning_cmd
,
6043 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6046 "Maximum number of prefix accept from this peer\n"
6047 "maximum no. of prefix limit\n"
6048 "Only give warning message when limit is exceeded\n")
6052 return peer_maximum_prefix_set_vty(
6053 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6054 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
6058 neighbor_maximum_prefix_warning
,
6059 neighbor_maximum_prefix_warning_hidden_cmd
,
6060 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6061 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6062 "Maximum number of prefix accept from this peer\n"
6063 "maximum no. of prefix limit\n"
6064 "Only give warning message when limit is exceeded\n")
6066 DEFUN (neighbor_maximum_prefix_threshold_warning
,
6067 neighbor_maximum_prefix_threshold_warning_cmd
,
6068 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6071 "Maximum number of prefix accept from this peer\n"
6072 "maximum no. of prefix limit\n"
6073 "Threshold value (%) at which to generate a warning msg\n"
6074 "Only give warning message when limit is exceeded\n")
6078 int idx_number_2
= 4;
6079 return peer_maximum_prefix_set_vty(
6080 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6081 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
6085 neighbor_maximum_prefix_threshold_warning
,
6086 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
6087 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6088 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6089 "Maximum number of prefix accept from this peer\n"
6090 "maximum no. of prefix limit\n"
6091 "Threshold value (%) at which to generate a warning msg\n"
6092 "Only give warning message when limit is exceeded\n")
6094 DEFUN (neighbor_maximum_prefix_restart
,
6095 neighbor_maximum_prefix_restart_cmd
,
6096 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6099 "Maximum number of prefix accept from this peer\n"
6100 "maximum no. of prefix limit\n"
6101 "Restart bgp connection after limit is exceeded\n"
6102 "Restart interval in minutes\n")
6106 int idx_number_2
= 5;
6107 return peer_maximum_prefix_set_vty(
6108 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6109 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
6113 neighbor_maximum_prefix_restart
,
6114 neighbor_maximum_prefix_restart_hidden_cmd
,
6115 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6116 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6117 "Maximum number of prefix accept from this peer\n"
6118 "maximum no. of prefix limit\n"
6119 "Restart bgp connection after limit is exceeded\n"
6120 "Restart interval in minutes\n")
6122 DEFUN (neighbor_maximum_prefix_threshold_restart
,
6123 neighbor_maximum_prefix_threshold_restart_cmd
,
6124 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6127 "Maximum number of prefixes to accept from this peer\n"
6128 "maximum no. of prefix limit\n"
6129 "Threshold value (%) at which to generate a warning msg\n"
6130 "Restart bgp connection after limit is exceeded\n"
6131 "Restart interval in minutes\n")
6135 int idx_number_2
= 4;
6136 int idx_number_3
= 6;
6137 return peer_maximum_prefix_set_vty(
6138 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6139 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
6140 argv
[idx_number_3
]->arg
);
6144 neighbor_maximum_prefix_threshold_restart
,
6145 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
6146 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6147 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6148 "Maximum number of prefixes to accept from this peer\n"
6149 "maximum no. of prefix limit\n"
6150 "Threshold value (%) at which to generate a warning msg\n"
6151 "Restart bgp connection after limit is exceeded\n"
6152 "Restart interval in minutes\n")
6154 DEFUN (no_neighbor_maximum_prefix
,
6155 no_neighbor_maximum_prefix_cmd
,
6156 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6160 "Maximum number of prefixes to accept from this peer\n"
6161 "maximum no. of prefix limit\n"
6162 "Threshold value (%) at which to generate a warning msg\n"
6163 "Restart bgp connection after limit is exceeded\n"
6164 "Restart interval in minutes\n"
6165 "Only give warning message when limit is exceeded\n")
6168 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
6170 bgp_node_safi(vty
));
6174 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
6175 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6176 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6177 "Maximum number of prefixes to accept from this peer\n"
6178 "maximum no. of prefix limit\n"
6179 "Threshold value (%) at which to generate a warning msg\n"
6180 "Restart bgp connection after limit is exceeded\n"
6181 "Restart interval in minutes\n"
6182 "Only give warning message when limit is exceeded\n")
6185 /* "neighbor allowas-in" */
6186 DEFUN (neighbor_allowas_in
,
6187 neighbor_allowas_in_cmd
,
6188 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6191 "Accept as-path with my AS present in it\n"
6192 "Number of occurrences of AS number\n"
6193 "Only accept my AS in the as-path if the route was originated in my AS\n")
6196 int idx_number_origin
= 3;
6202 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6204 return CMD_WARNING_CONFIG_FAILED
;
6206 if (argc
<= idx_number_origin
)
6209 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6212 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6215 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6218 return bgp_vty_return(vty
, ret
);
6222 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6223 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6224 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6225 "Accept as-path with my AS present in it\n"
6226 "Number of occurrences of AS number\n"
6227 "Only accept my AS in the as-path if the route was originated in my AS\n")
6229 DEFUN (no_neighbor_allowas_in
,
6230 no_neighbor_allowas_in_cmd
,
6231 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6235 "allow local ASN appears in aspath attribute\n"
6236 "Number of occurrences of AS number\n"
6237 "Only accept my AS in the as-path if the route was originated in my AS\n")
6243 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6245 return CMD_WARNING_CONFIG_FAILED
;
6247 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6248 bgp_node_safi(vty
));
6250 return bgp_vty_return(vty
, ret
);
6254 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6255 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6256 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6257 "allow local ASN appears in aspath attribute\n"
6258 "Number of occurrences of AS number\n"
6259 "Only accept my AS in the as-path if the route was originated in my AS\n")
6261 DEFUN (neighbor_ttl_security
,
6262 neighbor_ttl_security_cmd
,
6263 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6266 "BGP ttl-security parameters\n"
6267 "Specify the maximum number of hops to the BGP peer\n"
6268 "Number of hops to BGP peer\n")
6275 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6277 return CMD_WARNING_CONFIG_FAILED
;
6279 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6282 * If 'neighbor swpX', then this is for directly connected peers,
6283 * we should not accept a ttl-security hops value greater than 1.
6285 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6287 "%s is directly connected peer, hops cannot exceed 1\n",
6288 argv
[idx_peer
]->arg
);
6289 return CMD_WARNING_CONFIG_FAILED
;
6292 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6295 DEFUN (no_neighbor_ttl_security
,
6296 no_neighbor_ttl_security_cmd
,
6297 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6301 "BGP ttl-security parameters\n"
6302 "Specify the maximum number of hops to the BGP peer\n"
6303 "Number of hops to BGP peer\n")
6308 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6310 return CMD_WARNING_CONFIG_FAILED
;
6312 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6315 DEFUN (neighbor_addpath_tx_all_paths
,
6316 neighbor_addpath_tx_all_paths_cmd
,
6317 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6320 "Use addpath to advertise all paths to a neighbor\n")
6325 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6327 return CMD_WARNING_CONFIG_FAILED
;
6329 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6334 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6335 neighbor_addpath_tx_all_paths_hidden_cmd
,
6336 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6337 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6338 "Use addpath to advertise all paths to a neighbor\n")
6340 DEFUN (no_neighbor_addpath_tx_all_paths
,
6341 no_neighbor_addpath_tx_all_paths_cmd
,
6342 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6346 "Use addpath to advertise all paths to a neighbor\n")
6351 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6353 return CMD_WARNING_CONFIG_FAILED
;
6355 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6356 != BGP_ADDPATH_ALL
) {
6358 "%% Peer not currently configured to transmit all paths.");
6359 return CMD_WARNING_CONFIG_FAILED
;
6362 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6368 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6369 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6370 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6371 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6372 "Use addpath to advertise all paths to a neighbor\n")
6374 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6375 neighbor_addpath_tx_bestpath_per_as_cmd
,
6376 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6379 "Use addpath to advertise the bestpath per each neighboring AS\n")
6384 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6386 return CMD_WARNING_CONFIG_FAILED
;
6388 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6389 BGP_ADDPATH_BEST_PER_AS
);
6394 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6395 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6396 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6397 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6398 "Use addpath to advertise the bestpath per each neighboring AS\n")
6400 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6401 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6402 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6406 "Use addpath to advertise the bestpath per each neighboring AS\n")
6411 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6413 return CMD_WARNING_CONFIG_FAILED
;
6415 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6416 != BGP_ADDPATH_BEST_PER_AS
) {
6418 "%% Peer not currently configured to transmit all best path per as.");
6419 return CMD_WARNING_CONFIG_FAILED
;
6422 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6428 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6429 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6430 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6431 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6432 "Use addpath to advertise the bestpath per each neighboring AS\n")
6435 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
6436 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
6439 "Detect AS loops before sending to neighbor\n")
6443 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
6445 return CMD_WARNING_CONFIG_FAILED
;
6447 peer
->as_path_loop_detection
= true;
6453 no_neighbor_aspath_loop_detection
,
6454 no_neighbor_aspath_loop_detection_cmd
,
6455 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
6459 "Detect AS loops before sending to neighbor\n")
6463 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
6465 return CMD_WARNING_CONFIG_FAILED
;
6467 peer
->as_path_loop_detection
= false;
6472 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6473 struct ecommunity
**list
)
6475 struct ecommunity
*ecom
= NULL
;
6476 struct ecommunity
*ecomadd
;
6478 for (; argc
; --argc
, ++argv
) {
6480 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6481 ECOMMUNITY_ROUTE_TARGET
, 0);
6483 vty_out(vty
, "Malformed community-list value\n");
6485 ecommunity_free(&ecom
);
6486 return CMD_WARNING_CONFIG_FAILED
;
6490 ecommunity_merge(ecom
, ecomadd
);
6491 ecommunity_free(&ecomadd
);
6498 ecommunity_free(&*list
);
6506 * v2vimport is true if we are handling a `import vrf ...` command
6508 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6512 switch (vty
->node
) {
6521 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6526 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6527 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6528 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6529 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6531 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6535 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6536 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6537 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6538 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6540 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6547 DEFPY (af_rd_vpn_export
,
6548 af_rd_vpn_export_cmd
,
6549 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6551 "Specify route distinguisher\n"
6552 "Between current address-family and vpn\n"
6553 "For routes leaked from current address-family to vpn\n"
6554 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6556 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6557 struct prefix_rd prd
;
6563 if (argv_find(argv
, argc
, "no", &idx
))
6567 ret
= str2prefix_rd(rd_str
, &prd
);
6569 vty_out(vty
, "%% Malformed rd\n");
6570 return CMD_WARNING_CONFIG_FAILED
;
6574 afi
= vpn_policy_getafi(vty
, bgp
, false);
6576 return CMD_WARNING_CONFIG_FAILED
;
6579 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6581 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6582 bgp_get_default(), bgp
);
6585 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6586 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6587 BGP_VPN_POLICY_TOVPN_RD_SET
);
6589 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6590 BGP_VPN_POLICY_TOVPN_RD_SET
);
6593 /* post-change: re-export vpn routes */
6594 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6595 bgp_get_default(), bgp
);
6600 ALIAS (af_rd_vpn_export
,
6601 af_no_rd_vpn_export_cmd
,
6604 "Specify route distinguisher\n"
6605 "Between current address-family and vpn\n"
6606 "For routes leaked from current address-family to vpn\n")
6608 DEFPY (af_label_vpn_export
,
6609 af_label_vpn_export_cmd
,
6610 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6612 "label value for VRF\n"
6613 "Between current address-family and vpn\n"
6614 "For routes leaked from current address-family to vpn\n"
6615 "Label Value <0-1048575>\n"
6616 "Automatically assign a label\n")
6618 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6619 mpls_label_t label
= MPLS_LABEL_NONE
;
6624 if (argv_find(argv
, argc
, "no", &idx
))
6627 /* If "no ...", squash trailing parameter */
6633 label
= label_val
; /* parser should force unsigned */
6636 afi
= vpn_policy_getafi(vty
, bgp
, false);
6638 return CMD_WARNING_CONFIG_FAILED
;
6641 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6642 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6647 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6649 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6650 bgp_get_default(), bgp
);
6652 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6653 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6655 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6658 * label has previously been automatically
6659 * assigned by labelpool: release it
6661 * NB if tovpn_label == MPLS_LABEL_NONE it
6662 * means the automatic assignment is in flight
6663 * and therefore the labelpool callback must
6664 * detect that the auto label is not needed.
6667 bgp_lp_release(LP_TYPE_VRF
,
6668 &bgp
->vpn_policy
[afi
],
6669 bgp
->vpn_policy
[afi
].tovpn_label
);
6671 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6672 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6675 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6677 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6678 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6679 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6680 vpn_leak_label_callback
);
6683 /* post-change: re-export vpn routes */
6684 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6685 bgp_get_default(), bgp
);
6690 ALIAS (af_label_vpn_export
,
6691 af_no_label_vpn_export_cmd
,
6692 "no label vpn export",
6694 "label value for VRF\n"
6695 "Between current address-family and vpn\n"
6696 "For routes leaked from current address-family to vpn\n")
6698 DEFPY (af_nexthop_vpn_export
,
6699 af_nexthop_vpn_export_cmd
,
6700 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6702 "Specify next hop to use for VRF advertised prefixes\n"
6703 "Between current address-family and vpn\n"
6704 "For routes leaked from current address-family to vpn\n"
6708 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6714 if (argv_find(argv
, argc
, "no", &idx
))
6718 if (!sockunion2hostprefix(nexthop_str
, &p
))
6719 return CMD_WARNING_CONFIG_FAILED
;
6722 afi
= vpn_policy_getafi(vty
, bgp
, false);
6724 return CMD_WARNING_CONFIG_FAILED
;
6727 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6729 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6730 bgp_get_default(), bgp
);
6733 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6734 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6735 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6737 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6738 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6741 /* post-change: re-export vpn routes */
6742 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6743 bgp_get_default(), bgp
);
6748 ALIAS (af_nexthop_vpn_export
,
6749 af_no_nexthop_vpn_export_cmd
,
6750 "no nexthop vpn export",
6752 "Specify next hop to use for VRF advertised prefixes\n"
6753 "Between current address-family and vpn\n"
6754 "For routes leaked from current address-family to vpn\n")
6756 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6758 if (!strcmp(dstr
, "import")) {
6759 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6760 } else if (!strcmp(dstr
, "export")) {
6761 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6762 } else if (!strcmp(dstr
, "both")) {
6763 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6764 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6766 vty_out(vty
, "%% direction parse error\n");
6767 return CMD_WARNING_CONFIG_FAILED
;
6772 DEFPY (af_rt_vpn_imexport
,
6773 af_rt_vpn_imexport_cmd
,
6774 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6776 "Specify route target list\n"
6777 "Specify route target list\n"
6778 "Between current address-family and vpn\n"
6779 "For routes leaked from vpn to current address-family: match any\n"
6780 "For routes leaked from current address-family to vpn: set\n"
6781 "both import: match any and export: set\n"
6782 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6784 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6786 struct ecommunity
*ecom
= NULL
;
6787 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6788 vpn_policy_direction_t dir
;
6793 if (argv_find(argv
, argc
, "no", &idx
))
6796 afi
= vpn_policy_getafi(vty
, bgp
, false);
6798 return CMD_WARNING_CONFIG_FAILED
;
6800 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6801 if (ret
!= CMD_SUCCESS
)
6805 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6806 vty_out(vty
, "%% Missing RTLIST\n");
6807 return CMD_WARNING_CONFIG_FAILED
;
6809 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6810 if (ret
!= CMD_SUCCESS
) {
6815 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6819 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6822 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6824 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6825 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6826 ecommunity_dup(ecom
);
6828 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6830 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6831 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6834 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6838 ecommunity_free(&ecom
);
6843 ALIAS (af_rt_vpn_imexport
,
6844 af_no_rt_vpn_imexport_cmd
,
6845 "no <rt|route-target> vpn <import|export|both>$direction_str",
6847 "Specify route target list\n"
6848 "Specify route target list\n"
6849 "Between current address-family and vpn\n"
6850 "For routes leaked from vpn to current address-family\n"
6851 "For routes leaked from current address-family to vpn\n"
6852 "both import and export\n")
6854 DEFPY (af_route_map_vpn_imexport
,
6855 af_route_map_vpn_imexport_cmd
,
6856 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6857 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6859 "Specify route map\n"
6860 "Between current address-family and vpn\n"
6861 "For routes leaked from vpn to current address-family\n"
6862 "For routes leaked from current address-family to vpn\n"
6863 "name of route-map\n")
6865 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6867 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6868 vpn_policy_direction_t dir
;
6873 if (argv_find(argv
, argc
, "no", &idx
))
6876 afi
= vpn_policy_getafi(vty
, bgp
, false);
6878 return CMD_WARNING_CONFIG_FAILED
;
6880 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6881 if (ret
!= CMD_SUCCESS
)
6884 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6888 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6891 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6892 XFREE(MTYPE_ROUTE_MAP_NAME
,
6893 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6894 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6895 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6896 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6897 route_map_lookup_warn_noexist(vty
, rmap_str
);
6898 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6901 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6902 XFREE(MTYPE_ROUTE_MAP_NAME
,
6903 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6904 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6905 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6908 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6914 ALIAS (af_route_map_vpn_imexport
,
6915 af_no_route_map_vpn_imexport_cmd
,
6916 "no route-map vpn <import|export>$direction_str",
6918 "Specify route map\n"
6919 "Between current address-family and vpn\n"
6920 "For routes leaked from vpn to current address-family\n"
6921 "For routes leaked from current address-family to vpn\n")
6923 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6924 "[no] import vrf route-map RMAP$rmap_str",
6926 "Import routes from another VRF\n"
6927 "Vrf routes being filtered\n"
6928 "Specify route map\n"
6929 "name of route-map\n")
6931 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6932 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6936 struct bgp
*bgp_default
;
6938 if (argv_find(argv
, argc
, "no", &idx
))
6941 afi
= vpn_policy_getafi(vty
, bgp
, true);
6943 return CMD_WARNING_CONFIG_FAILED
;
6945 bgp_default
= bgp_get_default();
6950 /* Auto-create assuming the same AS */
6951 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6952 BGP_INSTANCE_TYPE_DEFAULT
);
6956 "VRF default is not configured as a bgp instance\n");
6961 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6964 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6965 XFREE(MTYPE_ROUTE_MAP_NAME
,
6966 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6967 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6968 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6969 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6970 route_map_lookup_warn_noexist(vty
, rmap_str
);
6971 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6974 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6975 XFREE(MTYPE_ROUTE_MAP_NAME
,
6976 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6977 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6978 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6981 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6986 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6987 "no import vrf route-map",
6989 "Import routes from another VRF\n"
6990 "Vrf routes being filtered\n"
6991 "Specify route map\n")
6993 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
6994 "[no] import vrf VIEWVRFNAME$import_name",
6996 "Import routes from another VRF\n"
6997 "VRF to import from\n"
6998 "The name of the VRF\n")
7000 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7001 struct listnode
*node
;
7002 struct bgp
*vrf_bgp
, *bgp_default
;
7005 bool remove
= false;
7008 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
7012 if (import_name
== NULL
) {
7013 vty_out(vty
, "%% Missing import name\n");
7017 if (argv_find(argv
, argc
, "no", &idx
))
7020 afi
= vpn_policy_getafi(vty
, bgp
, true);
7022 return CMD_WARNING_CONFIG_FAILED
;
7024 safi
= bgp_node_safi(vty
);
7026 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
7027 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
7028 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
7029 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
7030 remove
? "unimport" : "import", import_name
);
7034 bgp_default
= bgp_get_default();
7036 /* Auto-create assuming the same AS */
7037 ret
= bgp_get(&bgp_default
, &as
, NULL
,
7038 BGP_INSTANCE_TYPE_DEFAULT
);
7042 "VRF default is not configured as a bgp instance\n");
7047 vrf_bgp
= bgp_lookup_by_name(import_name
);
7049 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
7050 vrf_bgp
= bgp_default
;
7052 /* Auto-create assuming the same AS */
7053 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
7057 "VRF %s is not configured as a bgp instance\n",
7064 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
7066 /* Already importing from "import_vrf"? */
7067 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
7069 if (strcmp(vname
, import_name
) == 0)
7073 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
7079 /* This command is valid only in a bgp vrf instance or the default instance */
7080 DEFPY (bgp_imexport_vpn
,
7081 bgp_imexport_vpn_cmd
,
7082 "[no] <import|export>$direction_str vpn",
7084 "Import routes to this address-family\n"
7085 "Export routes from this address-family\n"
7086 "to/from default instance VPN RIB\n")
7088 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7095 vpn_policy_direction_t dir
;
7097 if (argv_find(argv
, argc
, "no", &idx
))
7100 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
7101 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
7103 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
7104 return CMD_WARNING_CONFIG_FAILED
;
7107 afi
= bgp_node_afi(vty
);
7108 safi
= bgp_node_safi(vty
);
7109 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
7110 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
7111 return CMD_WARNING_CONFIG_FAILED
;
7114 if (!strcmp(direction_str
, "import")) {
7115 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
7116 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
7117 } else if (!strcmp(direction_str
, "export")) {
7118 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
7119 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
7121 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
7122 return CMD_WARNING_CONFIG_FAILED
;
7125 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7128 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7129 if (!previous_state
) {
7130 /* trigger export current vrf */
7131 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7134 if (previous_state
) {
7135 /* trigger un-export current vrf */
7136 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7138 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7144 DEFPY (af_routetarget_import
,
7145 af_routetarget_import_cmd
,
7146 "[no] <rt|route-target> redirect import RTLIST...",
7148 "Specify route target list\n"
7149 "Specify route target list\n"
7150 "Flow-spec redirect type route target\n"
7151 "Import routes to this address-family\n"
7152 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
7154 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7156 struct ecommunity
*ecom
= NULL
;
7161 if (argv_find(argv
, argc
, "no", &idx
))
7164 afi
= vpn_policy_getafi(vty
, bgp
, false);
7166 return CMD_WARNING_CONFIG_FAILED
;
7169 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7170 vty_out(vty
, "%% Missing RTLIST\n");
7171 return CMD_WARNING_CONFIG_FAILED
;
7173 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7174 if (ret
!= CMD_SUCCESS
)
7179 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7180 ecommunity_free(&bgp
->vpn_policy
[afi
]
7181 .import_redirect_rtlist
);
7182 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
7183 ecommunity_dup(ecom
);
7185 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7186 ecommunity_free(&bgp
->vpn_policy
[afi
]
7187 .import_redirect_rtlist
);
7188 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
7192 ecommunity_free(&ecom
);
7197 DEFUN_NOSH (address_family_ipv4_safi
,
7198 address_family_ipv4_safi_cmd
,
7199 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7200 "Enter Address Family command mode\n"
7202 BGP_SAFI_WITH_LABEL_HELP_STR
)
7206 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7207 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7208 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7209 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7210 && safi
!= SAFI_EVPN
) {
7212 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7213 return CMD_WARNING_CONFIG_FAILED
;
7215 vty
->node
= bgp_node_type(AFI_IP
, safi
);
7217 vty
->node
= BGP_IPV4_NODE
;
7222 DEFUN_NOSH (address_family_ipv6_safi
,
7223 address_family_ipv6_safi_cmd
,
7224 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7225 "Enter Address Family command mode\n"
7227 BGP_SAFI_WITH_LABEL_HELP_STR
)
7230 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7231 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7232 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7233 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7234 && safi
!= SAFI_EVPN
) {
7236 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7237 return CMD_WARNING_CONFIG_FAILED
;
7239 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
7241 vty
->node
= BGP_IPV6_NODE
;
7246 #ifdef KEEP_OLD_VPN_COMMANDS
7247 DEFUN_NOSH (address_family_vpnv4
,
7248 address_family_vpnv4_cmd
,
7249 "address-family vpnv4 [unicast]",
7250 "Enter Address Family command mode\n"
7252 "Address Family modifier\n")
7254 vty
->node
= BGP_VPNV4_NODE
;
7258 DEFUN_NOSH (address_family_vpnv6
,
7259 address_family_vpnv6_cmd
,
7260 "address-family vpnv6 [unicast]",
7261 "Enter Address Family command mode\n"
7263 "Address Family modifier\n")
7265 vty
->node
= BGP_VPNV6_NODE
;
7268 #endif /* KEEP_OLD_VPN_COMMANDS */
7270 DEFUN_NOSH (address_family_evpn
,
7271 address_family_evpn_cmd
,
7272 "address-family l2vpn evpn",
7273 "Enter Address Family command mode\n"
7275 "Address Family modifier\n")
7277 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7278 vty
->node
= BGP_EVPN_NODE
;
7282 DEFUN_NOSH (exit_address_family
,
7283 exit_address_family_cmd
,
7284 "exit-address-family",
7285 "Exit from Address Family configuration mode\n")
7287 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7288 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7289 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7290 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7291 || vty
->node
== BGP_EVPN_NODE
7292 || vty
->node
== BGP_FLOWSPECV4_NODE
7293 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7294 vty
->node
= BGP_NODE
;
7298 /* Recalculate bestpath and re-advertise a prefix */
7299 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7300 const char *ip_str
, afi_t afi
, safi_t safi
,
7301 struct prefix_rd
*prd
)
7304 struct prefix match
;
7305 struct bgp_node
*rn
;
7306 struct bgp_node
*rm
;
7308 struct bgp_table
*table
;
7309 struct bgp_table
*rib
;
7311 /* BGP structure lookup. */
7313 bgp
= bgp_lookup_by_name(view_name
);
7315 vty_out(vty
, "%% Can't find BGP instance %s\n",
7320 bgp
= bgp_get_default();
7322 vty_out(vty
, "%% No BGP process is configured\n");
7327 /* Check IP address argument. */
7328 ret
= str2prefix(ip_str
, &match
);
7330 vty_out(vty
, "%% address is malformed\n");
7334 match
.family
= afi2family(afi
);
7335 rib
= bgp
->rib
[afi
][safi
];
7337 if (safi
== SAFI_MPLS_VPN
) {
7338 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7339 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7342 table
= bgp_node_get_bgp_table_info(rn
);
7343 if (table
!= NULL
) {
7345 if ((rm
= bgp_node_match(table
, &match
))
7348 == match
.prefixlen
) {
7350 BGP_NODE_USER_CLEAR
);
7351 bgp_process(bgp
, rm
, afi
, safi
);
7353 bgp_unlock_node(rm
);
7358 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7359 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7360 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7361 bgp_process(bgp
, rn
, afi
, safi
);
7363 bgp_unlock_node(rn
);
7370 /* one clear bgp command to rule them all */
7371 DEFUN (clear_ip_bgp_all
,
7372 clear_ip_bgp_all_cmd
,
7373 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out>]",
7377 BGP_INSTANCE_HELP_STR
7380 BGP_SAFI_WITH_LABEL_HELP_STR
7381 "Address Family modifier\n"
7383 "BGP neighbor address to clear\n"
7384 "BGP IPv6 neighbor to clear\n"
7385 "BGP neighbor on interface to clear\n"
7386 "Clear peers with the AS number\n"
7387 "Clear all external peers\n"
7388 "Clear all members of peer-group\n"
7389 "BGP peer-group name\n"
7394 "Push out prefix-list ORF and do inbound soft reconfig\n"
7399 afi_t afi
= AFI_UNSPEC
;
7400 safi_t safi
= SAFI_UNSPEC
;
7401 enum clear_sort clr_sort
= clear_peer
;
7402 enum bgp_clear_type clr_type
;
7403 char *clr_arg
= NULL
;
7407 /* clear [ip] bgp */
7408 if (argv_find(argv
, argc
, "ip", &idx
))
7411 /* [<vrf> VIEWVRFNAME] */
7412 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7413 vrf
= argv
[idx
+ 1]->arg
;
7415 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7417 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7418 /* [<view> VIEWVRFNAME] */
7419 vrf
= argv
[idx
+ 1]->arg
;
7422 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7423 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7424 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7426 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
7427 if (argv_find(argv
, argc
, "*", &idx
)) {
7428 clr_sort
= clear_all
;
7429 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7430 clr_sort
= clear_peer
;
7431 clr_arg
= argv
[idx
]->arg
;
7432 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7433 clr_sort
= clear_peer
;
7434 clr_arg
= argv
[idx
]->arg
;
7435 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7436 clr_sort
= clear_group
;
7438 clr_arg
= argv
[idx
]->arg
;
7439 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
7440 clr_sort
= clear_peer
;
7441 clr_arg
= argv
[idx
]->arg
;
7442 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7443 clr_sort
= clear_peer
;
7444 clr_arg
= argv
[idx
]->arg
;
7445 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7446 clr_sort
= clear_as
;
7447 clr_arg
= argv
[idx
]->arg
;
7448 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7449 clr_sort
= clear_external
;
7452 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7453 if (argv_find(argv
, argc
, "soft", &idx
)) {
7454 if (argv_find(argv
, argc
, "in", &idx
)
7455 || argv_find(argv
, argc
, "out", &idx
))
7456 clr_type
= strmatch(argv
[idx
]->text
, "in")
7458 : BGP_CLEAR_SOFT_OUT
;
7460 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7461 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7462 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7463 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7464 : BGP_CLEAR_SOFT_IN
;
7465 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7466 clr_type
= BGP_CLEAR_SOFT_OUT
;
7468 clr_type
= BGP_CLEAR_SOFT_NONE
;
7470 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7473 DEFUN (clear_ip_bgp_prefix
,
7474 clear_ip_bgp_prefix_cmd
,
7475 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7479 BGP_INSTANCE_HELP_STR
7480 "Clear bestpath and re-advertise\n"
7484 char *prefix
= NULL
;
7488 /* [<view|vrf> VIEWVRFNAME] */
7489 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7490 vrf
= argv
[idx
+ 1]->arg
;
7492 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7494 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7495 /* [<view> VIEWVRFNAME] */
7496 vrf
= argv
[idx
+ 1]->arg
;
7500 prefix
= argv
[argc
- 1]->arg
;
7502 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7505 DEFUN (clear_bgp_ipv6_safi_prefix
,
7506 clear_bgp_ipv6_safi_prefix_cmd
,
7507 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7513 "Clear bestpath and re-advertise\n"
7517 int idx_ipv6_prefix
= 0;
7518 safi_t safi
= SAFI_UNICAST
;
7519 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7520 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7522 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7523 return bgp_clear_prefix(
7524 vty
, NULL
, prefix
, AFI_IP6
,
7528 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7529 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7530 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7534 BGP_INSTANCE_HELP_STR
7537 "Clear bestpath and re-advertise\n"
7541 int idx_vrfview
= 0;
7542 int idx_ipv6_prefix
= 0;
7543 safi_t safi
= SAFI_UNICAST
;
7544 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7545 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7546 char *vrfview
= NULL
;
7548 /* [<view|vrf> VIEWVRFNAME] */
7549 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
7550 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7551 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
7553 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
7554 /* [<view> VIEWVRFNAME] */
7555 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7557 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7559 return bgp_clear_prefix(
7560 vty
, vrfview
, prefix
,
7561 AFI_IP6
, safi
, NULL
);
7564 DEFUN (show_bgp_views
,
7566 "show [ip] bgp views",
7570 "Show the defined BGP views\n")
7572 struct list
*inst
= bm
->bgp
;
7573 struct listnode
*node
;
7576 vty_out(vty
, "Defined BGP views:\n");
7577 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7579 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7581 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7588 DEFUN (show_bgp_vrfs
,
7590 "show [ip] bgp vrfs [json]",
7597 char buf
[ETHER_ADDR_STRLEN
];
7598 struct list
*inst
= bm
->bgp
;
7599 struct listnode
*node
;
7601 bool uj
= use_json(argc
, argv
);
7602 json_object
*json
= NULL
;
7603 json_object
*json_vrfs
= NULL
;
7607 json
= json_object_new_object();
7608 json_vrfs
= json_object_new_object();
7611 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7612 const char *name
, *type
;
7614 struct listnode
*node2
, *nnode2
;
7615 int peers_cfg
, peers_estb
;
7616 json_object
*json_vrf
= NULL
;
7619 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7623 if (!uj
&& count
== 1) {
7625 "%4s %-5s %-16s %9s %10s %-37s\n",
7626 "Type", "Id", "routerId", "#PeersVfg",
7627 "#PeersEstb", "Name");
7628 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
7629 "L3-VNI", "RouterMAC", "Interface");
7632 peers_cfg
= peers_estb
= 0;
7634 json_vrf
= json_object_new_object();
7637 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
7638 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7641 if (peer
->status
== Established
)
7645 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7646 name
= VRF_DEFAULT_NAME
;
7655 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7657 : (int64_t)bgp
->vrf_id
;
7658 json_object_string_add(json_vrf
, "type", type
);
7659 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7660 json_object_string_add(json_vrf
, "routerId",
7661 inet_ntoa(bgp
->router_id
));
7662 json_object_int_add(json_vrf
, "numConfiguredPeers",
7664 json_object_int_add(json_vrf
, "numEstablishedPeers",
7667 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7668 json_object_string_add(
7670 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7671 json_object_string_add(json_vrf
, "interface",
7672 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
7674 json_object_object_add(json_vrfs
, name
, json_vrf
);
7677 "%4s %-5d %-16s %-9u %-10u %-37s\n",
7679 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7681 inet_ntoa(bgp
->router_id
), peers_cfg
,
7683 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
7685 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
7686 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
7692 json_object_object_add(json
, "vrfs", json_vrfs
);
7694 json_object_int_add(json
, "totalVrfs", count
);
7696 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7697 json
, JSON_C_TO_STRING_PRETTY
));
7698 json_object_free(json
);
7702 "\nTotal number of VRFs (including default): %d\n",
7709 DEFUN (show_bgp_mac_hash
,
7710 show_bgp_mac_hash_cmd
,
7711 "show bgp mac hash",
7715 "Mac Address database\n")
7717 bgp_mac_dump_table(vty
);
7722 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
7724 struct vty
*vty
= (struct vty
*)args
;
7725 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
7727 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7731 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7733 vty_out(vty
, "self nexthop database:\n");
7734 bgp_nexthop_show_address_hash(vty
, bgp
);
7736 vty_out(vty
, "Tunnel-ip database:\n");
7737 hash_iterate(bgp
->tip_hash
,
7738 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
7742 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7743 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7744 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7745 "martian next-hops\n"
7746 "martian next-hop database\n")
7748 struct bgp
*bgp
= NULL
;
7752 /* [<vrf> VIEWVRFNAME] */
7753 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7754 name
= argv
[idx
+ 1]->arg
;
7755 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7757 } else if (argv_find(argv
, argc
, "view", &idx
))
7758 /* [<view> VIEWVRFNAME] */
7759 name
= argv
[idx
+ 1]->arg
;
7761 bgp
= bgp_lookup_by_name(name
);
7763 bgp
= bgp_get_default();
7766 vty_out(vty
, "%% No BGP process is configured\n");
7769 bgp_show_martian_nexthops(vty
, bgp
);
7774 DEFUN (show_bgp_memory
,
7775 show_bgp_memory_cmd
,
7776 "show [ip] bgp memory",
7780 "Global BGP memory statistics\n")
7782 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7783 unsigned long count
;
7785 /* RIB related usage stats */
7786 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7787 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7788 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7789 count
* sizeof(struct bgp_node
)));
7791 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7792 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7793 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7794 count
* sizeof(struct bgp_path_info
)));
7795 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7796 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7799 memstrbuf
, sizeof(memstrbuf
),
7800 count
* sizeof(struct bgp_path_info_extra
)));
7802 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7803 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7804 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7805 count
* sizeof(struct bgp_static
)));
7807 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7808 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7809 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7810 count
* sizeof(struct bpacket
)));
7813 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7814 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7815 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7816 count
* sizeof(struct bgp_adj_in
)));
7817 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7818 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7819 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7820 count
* sizeof(struct bgp_adj_out
)));
7822 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7823 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7825 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7826 count
* sizeof(struct bgp_nexthop_cache
)));
7828 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7829 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7831 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7832 count
* sizeof(struct bgp_damp_info
)));
7835 count
= attr_count();
7836 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7837 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7838 count
* sizeof(struct attr
)));
7840 if ((count
= attr_unknown_count()))
7841 vty_out(vty
, "%ld unknown attributes\n", count
);
7843 /* AS_PATH attributes */
7844 count
= aspath_count();
7845 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7846 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7847 count
* sizeof(struct aspath
)));
7849 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7850 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7851 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7852 count
* sizeof(struct assegment
)));
7854 /* Other attributes */
7855 if ((count
= community_count()))
7856 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7857 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7858 count
* sizeof(struct community
)));
7859 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7860 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7861 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7862 count
* sizeof(struct ecommunity
)));
7863 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7865 "%ld BGP large-community entries, using %s of memory\n",
7866 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7867 count
* sizeof(struct lcommunity
)));
7869 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7870 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7871 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7872 count
* sizeof(struct cluster_list
)));
7874 /* Peer related usage */
7875 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7876 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7877 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7878 count
* sizeof(struct peer
)));
7880 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7881 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7882 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7883 count
* sizeof(struct peer_group
)));
7886 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7887 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7888 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7889 count
* sizeof(regex_t
)));
7893 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7895 json_object
*bestpath
= json_object_new_object();
7897 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7898 json_object_string_add(bestpath
, "asPath", "ignore");
7900 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7901 json_object_string_add(bestpath
, "asPath", "confed");
7903 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7904 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7905 json_object_string_add(bestpath
, "multiPathRelax",
7908 json_object_string_add(bestpath
, "multiPathRelax",
7911 json_object_string_add(bestpath
, "multiPathRelax", "false");
7913 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7914 json_object_string_add(bestpath
, "compareRouterId", "true");
7915 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7916 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7917 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7918 json_object_string_add(bestpath
, "med", "confed");
7919 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7920 json_object_string_add(bestpath
, "med",
7921 "missing-as-worst");
7923 json_object_string_add(bestpath
, "med", "true");
7926 json_object_object_add(json
, "bestPath", bestpath
);
7929 /* Print the error code/subcode for why the peer is down */
7930 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
7931 json_object
*json_peer
, bool use_json
)
7933 const char *code_str
;
7934 const char *subcode_str
;
7937 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
7938 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
7939 char errorcodesubcode_hexstr
[5];
7940 char errorcodesubcode_str
[256];
7942 code_str
= bgp_notify_code_str(peer
->notify
.code
);
7943 subcode_str
= bgp_notify_subcode_str(
7945 peer
->notify
.subcode
);
7947 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
7948 peer
->notify
.code
, peer
->notify
.subcode
);
7949 json_object_string_add(json_peer
,
7950 "lastErrorCodeSubcode",
7951 errorcodesubcode_hexstr
);
7952 snprintf(errorcodesubcode_str
, 255, "%s%s",
7953 code_str
, subcode_str
);
7954 json_object_string_add(json_peer
,
7955 "lastNotificationReason",
7956 errorcodesubcode_str
);
7957 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
7958 && peer
->notify
.code
== BGP_NOTIFY_CEASE
7959 && (peer
->notify
.subcode
7960 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
7961 || peer
->notify
.subcode
7962 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
7963 && peer
->notify
.length
) {
7965 const char *msg_str
;
7967 msg_str
= bgp_notify_admin_message(
7968 msgbuf
, sizeof(msgbuf
),
7969 (uint8_t *)peer
->notify
.data
,
7970 peer
->notify
.length
);
7972 json_object_string_add(
7974 "lastShutdownDescription",
7979 json_object_string_add(json_peer
, "lastResetDueTo",
7980 peer_down_str
[(int)peer
->last_reset
]);
7981 json_object_int_add(json_peer
, "lastResetCode",
7984 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
7985 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
7986 code_str
= bgp_notify_code_str(peer
->notify
.code
);
7988 bgp_notify_subcode_str(peer
->notify
.code
,
7989 peer
->notify
.subcode
);
7990 vty_out(vty
, " Notification %s (%s%s)\n",
7991 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
7994 code_str
, subcode_str
);
7996 vty_out(vty
, " %s\n",
7997 peer_down_str
[(int)peer
->last_reset
]);
8002 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
8005 return ((peer
->status
!= Established
) ||
8006 !peer
->afc_recv
[afi
][safi
]);
8009 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
8010 struct peer
*peer
, json_object
*json_peer
,
8011 int max_neighbor_width
, bool use_json
)
8013 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
8017 if (peer_dynamic_neighbor(peer
))
8018 json_object_boolean_true_add(json_peer
,
8021 json_object_string_add(json_peer
, "hostname",
8024 if (peer
->domainname
)
8025 json_object_string_add(json_peer
, "domainname",
8027 json_object_int_add(json_peer
, "connectionsEstablished",
8029 json_object_int_add(json_peer
, "connectionsDropped",
8031 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8032 use_json
, json_peer
);
8033 if (peer
->status
== Established
)
8034 json_object_string_add(json_peer
, "lastResetDueTo",
8035 "AFI/SAFI Not Negotiated");
8037 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
8040 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
8042 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8043 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8044 peer
->hostname
, peer
->host
);
8046 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8048 /* pad the neighbor column with spaces */
8049 if (len
< max_neighbor_width
)
8050 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8052 vty_out(vty
, "%7d %7d %8s", peer
->established
,
8054 peer_uptime(peer
->uptime
, timebuf
,
8055 BGP_UPTIME_LEN
, 0, NULL
));
8056 if (peer
->status
== Established
)
8057 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
8059 bgp_show_peer_reset(vty
, peer
, NULL
,
8065 /* Show BGP peer's summary information. */
8066 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
8067 bool show_failed
, bool use_json
)
8070 struct listnode
*node
, *nnode
;
8071 unsigned int count
= 0, dn_count
= 0;
8072 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
8073 char neighbor_buf
[VTY_BUFSIZ
];
8074 int neighbor_col_default_width
= 16;
8075 int len
, failed_count
= 0;
8076 int max_neighbor_width
= 0;
8078 json_object
*json
= NULL
;
8079 json_object
*json_peer
= NULL
;
8080 json_object
*json_peers
= NULL
;
8081 struct peer_af
*paf
;
8083 /* labeled-unicast routes are installed in the unicast table so in order
8085 * display the correct PfxRcd value we must look at SAFI_UNICAST
8088 if (safi
== SAFI_LABELED_UNICAST
)
8089 pfx_rcd_safi
= SAFI_UNICAST
;
8091 pfx_rcd_safi
= safi
;
8094 json
= json_object_new_object();
8095 json_peers
= json_object_new_object();
8096 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8097 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8100 if (peer
->afc
[afi
][safi
]) {
8101 /* See if we have at least a single failed peer */
8102 if (bgp_has_peer_failed(peer
, afi
, safi
))
8106 if (peer_dynamic_neighbor(peer
))
8111 /* Loop over all neighbors that will be displayed to determine
8113 * characters are needed for the Neighbor column
8115 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8116 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8119 if (peer
->afc
[afi
][safi
]) {
8120 memset(dn_flag
, '\0', sizeof(dn_flag
));
8121 if (peer_dynamic_neighbor(peer
))
8125 && bgp_flag_check(bgp
,
8126 BGP_FLAG_SHOW_HOSTNAME
))
8127 sprintf(neighbor_buf
, "%s%s(%s) ",
8128 dn_flag
, peer
->hostname
,
8131 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
8134 len
= strlen(neighbor_buf
);
8136 if (len
> max_neighbor_width
)
8137 max_neighbor_width
= len
;
8139 /* See if we have at least a single failed peer */
8140 if (bgp_has_peer_failed(peer
, afi
, safi
))
8146 /* Originally we displayed the Neighbor column as 16
8147 * characters wide so make that the default
8149 if (max_neighbor_width
< neighbor_col_default_width
)
8150 max_neighbor_width
= neighbor_col_default_width
;
8153 if (show_failed
&& !failed_count
) {
8155 json_object_int_add(json
, "failedPeersCount", 0);
8156 json_object_int_add(json
, "dynamicPeers", dn_count
);
8157 json_object_int_add(json
, "totalPeers", count
);
8159 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8160 json
, JSON_C_TO_STRING_PRETTY
));
8161 json_object_free(json
);
8163 vty_out(vty
, "%% No failed BGP neighbors found\n");
8164 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8169 count
= 0; /* Reset the value as its used again */
8170 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8171 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8174 if (!peer
->afc
[afi
][safi
])
8179 char memstrbuf
[MTYPE_MEMSTR_LEN
];
8182 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
8184 : (int64_t)bgp
->vrf_id
;
8186 /* Usage summary and header */
8188 json_object_string_add(
8190 inet_ntoa(bgp
->router_id
));
8191 json_object_int_add(json
, "as", bgp
->as
);
8192 json_object_int_add(json
, "vrfId", vrf_id_ui
);
8193 json_object_string_add(
8196 == BGP_INSTANCE_TYPE_DEFAULT
)
8201 "BGP router identifier %s, local AS number %u vrf-id %d",
8202 inet_ntoa(bgp
->router_id
), bgp
->as
,
8203 bgp
->vrf_id
== VRF_UNKNOWN
8205 : (int)bgp
->vrf_id
);
8209 if (bgp_update_delay_configured(bgp
)) {
8211 json_object_int_add(
8212 json
, "updateDelayLimit",
8213 bgp
->v_update_delay
);
8215 if (bgp
->v_update_delay
8216 != bgp
->v_establish_wait
)
8217 json_object_int_add(
8219 "updateDelayEstablishWait",
8220 bgp
->v_establish_wait
);
8222 if (bgp_update_delay_active(bgp
)) {
8223 json_object_string_add(
8225 "updateDelayFirstNeighbor",
8226 bgp
->update_delay_begin_time
);
8227 json_object_boolean_true_add(
8229 "updateDelayInProgress");
8231 if (bgp
->update_delay_over
) {
8232 json_object_string_add(
8234 "updateDelayFirstNeighbor",
8235 bgp
->update_delay_begin_time
);
8236 json_object_string_add(
8238 "updateDelayBestpathResumed",
8239 bgp
->update_delay_end_time
);
8240 json_object_string_add(
8242 "updateDelayZebraUpdateResume",
8243 bgp
->update_delay_zebra_resume_time
);
8244 json_object_string_add(
8246 "updateDelayPeerUpdateResume",
8247 bgp
->update_delay_peers_resume_time
);
8252 "Read-only mode update-delay limit: %d seconds\n",
8253 bgp
->v_update_delay
);
8254 if (bgp
->v_update_delay
8255 != bgp
->v_establish_wait
)
8257 " Establish wait: %d seconds\n",
8258 bgp
->v_establish_wait
);
8260 if (bgp_update_delay_active(bgp
)) {
8262 " First neighbor established: %s\n",
8263 bgp
->update_delay_begin_time
);
8265 " Delay in progress\n");
8267 if (bgp
->update_delay_over
) {
8269 " First neighbor established: %s\n",
8270 bgp
->update_delay_begin_time
);
8272 " Best-paths resumed: %s\n",
8273 bgp
->update_delay_end_time
);
8275 " zebra update resumed: %s\n",
8276 bgp
->update_delay_zebra_resume_time
);
8278 " peers update resumed: %s\n",
8279 bgp
->update_delay_peers_resume_time
);
8286 if (bgp_maxmed_onstartup_configured(bgp
)
8287 && bgp
->maxmed_active
)
8288 json_object_boolean_true_add(
8289 json
, "maxMedOnStartup");
8290 if (bgp
->v_maxmed_admin
)
8291 json_object_boolean_true_add(
8292 json
, "maxMedAdministrative");
8294 json_object_int_add(
8295 json
, "tableVersion",
8296 bgp_table_version(bgp
->rib
[afi
][safi
]));
8298 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8299 json_object_int_add(json
, "ribCount", ents
);
8300 json_object_int_add(
8302 ents
* sizeof(struct bgp_node
));
8304 ents
= bgp
->af_peer_count
[afi
][safi
];
8305 json_object_int_add(json
, "peerCount", ents
);
8306 json_object_int_add(json
, "peerMemory",
8307 ents
* sizeof(struct peer
));
8309 if ((ents
= listcount(bgp
->group
))) {
8310 json_object_int_add(
8311 json
, "peerGroupCount", ents
);
8312 json_object_int_add(
8313 json
, "peerGroupMemory",
8314 ents
* sizeof(struct
8318 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8319 BGP_CONFIG_DAMPENING
))
8320 json_object_boolean_true_add(
8321 json
, "dampeningEnabled");
8323 if (bgp_maxmed_onstartup_configured(bgp
)
8324 && bgp
->maxmed_active
)
8326 "Max-med on-startup active\n");
8327 if (bgp
->v_maxmed_admin
)
8329 "Max-med administrative active\n");
8331 vty_out(vty
, "BGP table version %" PRIu64
"\n",
8332 bgp_table_version(bgp
->rib
[afi
][safi
]));
8334 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8336 "RIB entries %ld, using %s of memory\n",
8338 mtype_memstr(memstrbuf
,
8340 ents
* sizeof(struct
8343 /* Peer related usage */
8344 ents
= bgp
->af_peer_count
[afi
][safi
];
8345 vty_out(vty
, "Peers %ld, using %s of memory\n",
8348 memstrbuf
, sizeof(memstrbuf
),
8349 ents
* sizeof(struct peer
)));
8351 if ((ents
= listcount(bgp
->group
)))
8353 "Peer groups %ld, using %s of memory\n",
8358 ents
* sizeof(struct
8361 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8362 BGP_CONFIG_DAMPENING
))
8363 vty_out(vty
, "Dampening enabled.\n");
8366 /* Subtract 8 here because 'Neighbor' is
8368 vty_out(vty
, "Neighbor");
8369 vty_out(vty
, "%*s", max_neighbor_width
- 8,
8372 vty_out(vty
, "EstdCnt DropCnt ResetTime Reason\n");
8375 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
8380 /* Works for both failed & successful cases */
8381 if (peer_dynamic_neighbor(peer
))
8388 bgp_has_peer_failed(peer
, afi
, safi
)) {
8389 json_peer
= json_object_new_object();
8390 bgp_show_failed_summary(vty
, bgp
, peer
,
8391 json_peer
, 0, use_json
);
8392 } else if (!show_failed
) {
8393 json_peer
= json_object_new_object();
8394 if (peer_dynamic_neighbor(peer
)) {
8395 json_object_boolean_true_add(json_peer
,
8400 json_object_string_add(json_peer
, "hostname",
8403 if (peer
->domainname
)
8404 json_object_string_add(json_peer
, "domainname",
8407 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
8408 json_object_int_add(json_peer
, "version", 4);
8409 json_object_int_add(json_peer
, "msgRcvd",
8410 PEER_TOTAL_RX(peer
));
8411 json_object_int_add(json_peer
, "msgSent",
8412 PEER_TOTAL_TX(peer
));
8414 json_object_int_add(json_peer
, "tableVersion",
8415 peer
->version
[afi
][safi
]);
8416 json_object_int_add(json_peer
, "outq",
8418 json_object_int_add(json_peer
, "inq", 0);
8419 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8420 use_json
, json_peer
);
8423 * Adding "pfxRcd" field to match with the corresponding
8424 * CLI. "prefixReceivedCount" will be deprecated in
8427 json_object_int_add(json_peer
, "prefixReceivedCount",
8428 peer
->pcount
[afi
][pfx_rcd_safi
]);
8429 json_object_int_add(json_peer
, "pfxRcd",
8430 peer
->pcount
[afi
][pfx_rcd_safi
]);
8432 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
8433 if (paf
&& PAF_SUBGRP(paf
))
8434 json_object_int_add(json_peer
,
8436 (PAF_SUBGRP(paf
))->scount
);
8437 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8438 json_object_string_add(json_peer
, "state",
8440 else if (peer
->afc_recv
[afi
][safi
])
8441 json_object_string_add(
8443 lookup_msg(bgp_status_msg
, peer
->status
,
8445 else if (CHECK_FLAG(peer
->sflags
,
8446 PEER_STATUS_PREFIX_OVERFLOW
))
8447 json_object_string_add(json_peer
, "state",
8450 json_object_string_add(
8452 lookup_msg(bgp_status_msg
, peer
->status
,
8454 json_object_int_add(json_peer
, "connectionsEstablished",
8456 json_object_int_add(json_peer
, "connectionsDropped",
8459 /* Avoid creating empty peer dicts in JSON */
8460 if (json_peer
== NULL
)
8464 json_object_string_add(json_peer
, "idType",
8466 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8467 json_object_string_add(json_peer
, "idType",
8469 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8470 json_object_string_add(json_peer
, "idType",
8472 json_object_object_add(json_peers
, peer
->host
,
8476 bgp_has_peer_failed(peer
, afi
, safi
)) {
8477 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
8480 } else if (!show_failed
) {
8481 memset(dn_flag
, '\0', sizeof(dn_flag
));
8482 if (peer_dynamic_neighbor(peer
)) {
8487 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8488 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8489 peer
->hostname
, peer
->host
);
8491 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8493 /* pad the neighbor column with spaces */
8494 if (len
< max_neighbor_width
)
8495 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8498 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8499 peer
->as
, PEER_TOTAL_RX(peer
),
8500 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8501 0, peer
->obuf
->count
,
8502 peer_uptime(peer
->uptime
, timebuf
,
8503 BGP_UPTIME_LEN
, 0, NULL
));
8505 if (peer
->status
== Established
)
8506 if (peer
->afc_recv
[afi
][safi
])
8507 vty_out(vty
, " %12" PRIu32
,
8512 vty_out(vty
, " NoNeg");
8514 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8515 vty_out(vty
, " Idle (Admin)");
8516 else if (CHECK_FLAG(
8518 PEER_STATUS_PREFIX_OVERFLOW
))
8519 vty_out(vty
, " Idle (PfxCt)");
8521 vty_out(vty
, " %12s",
8522 lookup_msg(bgp_status_msg
,
8523 peer
->status
, NULL
));
8532 json_object_object_add(json
, "peers", json_peers
);
8533 json_object_int_add(json
, "failedPeers", failed_count
);
8534 json_object_int_add(json
, "totalPeers", count
);
8535 json_object_int_add(json
, "dynamicPeers", dn_count
);
8538 bgp_show_bestpath_json(bgp
, json
);
8540 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8541 json
, JSON_C_TO_STRING_PRETTY
));
8542 json_object_free(json
);
8545 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8547 vty_out(vty
, "No %s neighbor is configured\n",
8548 get_afi_safi_str(afi
, safi
, false));
8552 vty_out(vty
, "* - dynamic neighbor\n");
8553 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8554 dn_count
, bgp
->dynamic_neighbors_limit
);
8561 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8562 int safi
, bool show_failed
, bool use_json
)
8565 int afi_wildcard
= (afi
== AFI_MAX
);
8566 int safi_wildcard
= (safi
== SAFI_MAX
);
8567 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8568 bool nbr_output
= false;
8570 if (use_json
&& is_wildcard
)
8571 vty_out(vty
, "{\n");
8573 afi
= 1; /* AFI_IP */
8574 while (afi
< AFI_MAX
) {
8576 safi
= 1; /* SAFI_UNICAST */
8577 while (safi
< SAFI_MAX
) {
8578 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8583 * So limit output to those afi/safi
8585 * actualy have something interesting in
8590 vty_out(vty
, ",\n");
8594 vty_out(vty
, "\"%s\":",
8595 get_afi_safi_str(afi
,
8599 vty_out(vty
, "\n%s Summary:\n",
8600 get_afi_safi_str(afi
,
8605 bgp_show_summary(vty
, bgp
, afi
, safi
, show_failed
,
8617 if (use_json
&& is_wildcard
)
8618 vty_out(vty
, "}\n");
8619 else if (!nbr_output
) {
8621 vty_out(vty
, "{}\n");
8623 vty_out(vty
, "%% No BGP neighbors found\n");
8627 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8628 safi_t safi
, bool show_failed
,
8631 struct listnode
*node
, *nnode
;
8634 bool nbr_output
= false;
8637 vty_out(vty
, "{\n");
8639 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8643 vty_out(vty
, ",\n");
8647 vty_out(vty
, "\"%s\":",
8648 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8652 vty_out(vty
, "\nInstance %s:\n",
8653 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8657 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
8662 vty_out(vty
, "}\n");
8663 else if (!nbr_output
)
8664 vty_out(vty
, "%% BGP instance not found\n");
8667 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8668 safi_t safi
, bool show_failed
, bool use_json
)
8673 if (strmatch(name
, "all")) {
8674 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8679 bgp
= bgp_lookup_by_name(name
);
8683 vty_out(vty
, "{}\n");
8686 "%% BGP instance not found\n");
8690 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
,
8691 show_failed
, use_json
);
8696 bgp
= bgp_get_default();
8699 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
8703 vty_out(vty
, "{}\n");
8705 vty_out(vty
, "%% BGP instance not found\n");
8712 /* `show [ip] bgp summary' commands. */
8713 DEFUN (show_ip_bgp_summary
,
8714 show_ip_bgp_summary_cmd
,
8715 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [failed] [json]",
8719 BGP_INSTANCE_HELP_STR
8721 BGP_SAFI_WITH_LABEL_HELP_STR
8722 "Summary of BGP neighbor status\n"
8723 "Show only sessions not in Established state\n"
8727 afi_t afi
= AFI_MAX
;
8728 safi_t safi
= SAFI_MAX
;
8729 bool show_failed
= false;
8734 if (argv_find(argv
, argc
, "ip", &idx
))
8736 /* [<vrf> VIEWVRFNAME] */
8737 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8738 vrf
= argv
[idx
+ 1]->arg
;
8739 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8741 } else if (argv_find(argv
, argc
, "view", &idx
))
8742 /* [<view> VIEWVRFNAME] */
8743 vrf
= argv
[idx
+ 1]->arg
;
8744 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8745 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8746 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8749 if (argv_find(argv
, argc
, "failed", &idx
))
8752 bool uj
= use_json(argc
, argv
);
8754 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, show_failed
, uj
);
8757 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
8760 return get_afi_safi_json_str(afi
, safi
);
8762 return get_afi_safi_vty_str(afi
, safi
);
8765 /* Show BGP peer's information. */
8766 enum show_type
{ show_all
, show_peer
, show_ipv4_all
, show_ipv6_all
, show_ipv4_peer
, show_ipv6_peer
};
8768 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8769 afi_t afi
, safi_t safi
,
8770 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8771 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8772 bool use_json
, json_object
*json_pref
)
8775 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8776 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8778 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8779 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8780 json_object_string_add(json_pref
, "sendMode",
8781 "advertisedAndReceived");
8782 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8783 json_object_string_add(json_pref
, "sendMode",
8785 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8786 json_object_string_add(json_pref
, "sendMode",
8789 vty_out(vty
, " Send-mode: ");
8790 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8791 vty_out(vty
, "advertised");
8792 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8793 vty_out(vty
, "%sreceived",
8794 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8803 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8804 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8806 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8807 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8808 json_object_string_add(json_pref
, "recvMode",
8809 "advertisedAndReceived");
8810 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8811 json_object_string_add(json_pref
, "recvMode",
8813 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8814 json_object_string_add(json_pref
, "recvMode",
8817 vty_out(vty
, " Receive-mode: ");
8818 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8819 vty_out(vty
, "advertised");
8820 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8821 vty_out(vty
, "%sreceived",
8822 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8831 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8832 safi_t safi
, bool use_json
,
8833 json_object
*json_neigh
)
8835 struct bgp_filter
*filter
;
8836 struct peer_af
*paf
;
8837 char orf_pfx_name
[BUFSIZ
];
8839 json_object
*json_af
= NULL
;
8840 json_object
*json_prefA
= NULL
;
8841 json_object
*json_prefB
= NULL
;
8842 json_object
*json_addr
= NULL
;
8845 json_addr
= json_object_new_object();
8846 json_af
= json_object_new_object();
8847 filter
= &p
->filter
[afi
][safi
];
8849 if (peer_group_active(p
))
8850 json_object_string_add(json_addr
, "peerGroupMember",
8853 paf
= peer_af_find(p
, afi
, safi
);
8854 if (paf
&& PAF_SUBGRP(paf
)) {
8855 json_object_int_add(json_addr
, "updateGroupId",
8856 PAF_UPDGRP(paf
)->id
);
8857 json_object_int_add(json_addr
, "subGroupId",
8858 PAF_SUBGRP(paf
)->id
);
8859 json_object_int_add(json_addr
, "packetQueueLength",
8860 bpacket_queue_virtual_length(paf
));
8863 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8864 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8865 PEER_CAP_ORF_PREFIX_SM_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 json_object_int_add(json_af
, "orfType",
8872 json_prefA
= json_object_new_object();
8873 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8874 PEER_CAP_ORF_PREFIX_SM_ADV
,
8875 PEER_CAP_ORF_PREFIX_RM_ADV
,
8876 PEER_CAP_ORF_PREFIX_SM_RCV
,
8877 PEER_CAP_ORF_PREFIX_RM_RCV
,
8878 use_json
, json_prefA
);
8879 json_object_object_add(json_af
, "orfPrefixList",
8883 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8884 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8885 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8886 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8887 PEER_CAP_ORF_PREFIX_RM_ADV
)
8888 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8889 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8890 json_object_int_add(json_af
, "orfOldType",
8891 ORF_TYPE_PREFIX_OLD
);
8892 json_prefB
= json_object_new_object();
8893 bgp_show_peer_afi_orf_cap(
8894 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8895 PEER_CAP_ORF_PREFIX_RM_ADV
,
8896 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8897 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8899 json_object_object_add(json_af
, "orfOldPrefixList",
8903 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8904 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8905 PEER_CAP_ORF_PREFIX_SM_RCV
)
8906 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8907 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8908 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8909 PEER_CAP_ORF_PREFIX_RM_ADV
)
8910 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8911 PEER_CAP_ORF_PREFIX_RM_RCV
)
8912 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8913 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8914 json_object_object_add(json_addr
, "afDependentCap",
8917 json_object_free(json_af
);
8919 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8920 orf_pfx_count
= prefix_bgp_show_prefix_list(
8921 NULL
, afi
, orf_pfx_name
, use_json
);
8923 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8924 PEER_STATUS_ORF_PREFIX_SEND
)
8926 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8927 PEER_STATUS_ORF_PREFIX_SEND
))
8928 json_object_boolean_true_add(json_neigh
,
8931 json_object_int_add(json_addr
, "orfRecvCounter",
8934 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8935 PEER_STATUS_ORF_WAIT_REFRESH
))
8936 json_object_string_add(
8937 json_addr
, "orfFirstUpdate",
8938 "deferredUntilORFOrRouteRefreshRecvd");
8940 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8941 PEER_FLAG_REFLECTOR_CLIENT
))
8942 json_object_boolean_true_add(json_addr
,
8943 "routeReflectorClient");
8944 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8945 PEER_FLAG_RSERVER_CLIENT
))
8946 json_object_boolean_true_add(json_addr
,
8947 "routeServerClient");
8948 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8949 json_object_boolean_true_add(json_addr
,
8950 "inboundSoftConfigPermit");
8952 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8953 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8954 json_object_boolean_true_add(
8956 "privateAsNumsAllReplacedInUpdatesToNbr");
8957 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8958 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8959 json_object_boolean_true_add(
8961 "privateAsNumsReplacedInUpdatesToNbr");
8962 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8963 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8964 json_object_boolean_true_add(
8966 "privateAsNumsAllRemovedInUpdatesToNbr");
8967 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8968 PEER_FLAG_REMOVE_PRIVATE_AS
))
8969 json_object_boolean_true_add(
8971 "privateAsNumsRemovedInUpdatesToNbr");
8973 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8974 json_object_boolean_true_add(
8976 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8979 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8980 json_object_string_add(json_addr
,
8981 "overrideASNsInOutboundUpdates",
8982 "ifAspathEqualRemoteAs");
8984 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8985 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8986 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8987 json_object_boolean_true_add(json_addr
,
8988 "routerAlwaysNextHop");
8989 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8990 PEER_FLAG_AS_PATH_UNCHANGED
))
8991 json_object_boolean_true_add(
8992 json_addr
, "unchangedAsPathPropogatedToNbr");
8993 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8994 PEER_FLAG_NEXTHOP_UNCHANGED
))
8995 json_object_boolean_true_add(
8996 json_addr
, "unchangedNextHopPropogatedToNbr");
8997 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8998 json_object_boolean_true_add(
8999 json_addr
, "unchangedMedPropogatedToNbr");
9000 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
9001 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9002 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
9003 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9004 PEER_FLAG_SEND_COMMUNITY
)
9005 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9006 PEER_FLAG_SEND_EXT_COMMUNITY
))
9007 json_object_string_add(json_addr
,
9008 "commAttriSentToNbr",
9009 "extendedAndStandard");
9010 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9011 PEER_FLAG_SEND_EXT_COMMUNITY
))
9012 json_object_string_add(json_addr
,
9013 "commAttriSentToNbr",
9016 json_object_string_add(json_addr
,
9017 "commAttriSentToNbr",
9020 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9021 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9022 if (p
->default_rmap
[afi
][safi
].name
)
9023 json_object_string_add(
9024 json_addr
, "defaultRouteMap",
9025 p
->default_rmap
[afi
][safi
].name
);
9027 if (paf
&& PAF_SUBGRP(paf
)
9028 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9029 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9030 json_object_boolean_true_add(json_addr
,
9033 json_object_boolean_true_add(json_addr
,
9037 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9038 if (is_evpn_enabled())
9039 json_object_boolean_true_add(
9040 json_addr
, "advertiseAllVnis");
9043 if (filter
->plist
[FILTER_IN
].name
9044 || filter
->dlist
[FILTER_IN
].name
9045 || filter
->aslist
[FILTER_IN
].name
9046 || filter
->map
[RMAP_IN
].name
)
9047 json_object_boolean_true_add(json_addr
,
9048 "inboundPathPolicyConfig");
9049 if (filter
->plist
[FILTER_OUT
].name
9050 || filter
->dlist
[FILTER_OUT
].name
9051 || filter
->aslist
[FILTER_OUT
].name
9052 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9053 json_object_boolean_true_add(
9054 json_addr
, "outboundPathPolicyConfig");
9057 if (filter
->plist
[FILTER_IN
].name
)
9058 json_object_string_add(json_addr
,
9059 "incomingUpdatePrefixFilterList",
9060 filter
->plist
[FILTER_IN
].name
);
9061 if (filter
->plist
[FILTER_OUT
].name
)
9062 json_object_string_add(json_addr
,
9063 "outgoingUpdatePrefixFilterList",
9064 filter
->plist
[FILTER_OUT
].name
);
9066 /* distribute-list */
9067 if (filter
->dlist
[FILTER_IN
].name
)
9068 json_object_string_add(
9069 json_addr
, "incomingUpdateNetworkFilterList",
9070 filter
->dlist
[FILTER_IN
].name
);
9071 if (filter
->dlist
[FILTER_OUT
].name
)
9072 json_object_string_add(
9073 json_addr
, "outgoingUpdateNetworkFilterList",
9074 filter
->dlist
[FILTER_OUT
].name
);
9077 if (filter
->aslist
[FILTER_IN
].name
)
9078 json_object_string_add(json_addr
,
9079 "incomingUpdateAsPathFilterList",
9080 filter
->aslist
[FILTER_IN
].name
);
9081 if (filter
->aslist
[FILTER_OUT
].name
)
9082 json_object_string_add(json_addr
,
9083 "outgoingUpdateAsPathFilterList",
9084 filter
->aslist
[FILTER_OUT
].name
);
9087 if (filter
->map
[RMAP_IN
].name
)
9088 json_object_string_add(
9089 json_addr
, "routeMapForIncomingAdvertisements",
9090 filter
->map
[RMAP_IN
].name
);
9091 if (filter
->map
[RMAP_OUT
].name
)
9092 json_object_string_add(
9093 json_addr
, "routeMapForOutgoingAdvertisements",
9094 filter
->map
[RMAP_OUT
].name
);
9096 /* ebgp-requires-policy (inbound) */
9097 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9098 && !bgp_inbound_policy_exists(p
, filter
))
9099 json_object_string_add(
9100 json_addr
, "inboundEbgpRequiresPolicy",
9101 "Inbound updates discarded due to missing policy");
9103 /* ebgp-requires-policy (outbound) */
9104 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9105 && (!bgp_outbound_policy_exists(p
, filter
)))
9106 json_object_string_add(
9107 json_addr
, "outboundEbgpRequiresPolicy",
9108 "Outbound updates discarded due to missing policy");
9110 /* unsuppress-map */
9111 if (filter
->usmap
.name
)
9112 json_object_string_add(json_addr
,
9113 "selectiveUnsuppressRouteMap",
9114 filter
->usmap
.name
);
9116 /* Receive prefix count */
9117 json_object_int_add(json_addr
, "acceptedPrefixCounter",
9118 p
->pcount
[afi
][safi
]);
9119 if (paf
&& PAF_SUBGRP(paf
))
9120 json_object_int_add(json_addr
, "sentPrefixCounter",
9121 (PAF_SUBGRP(paf
))->scount
);
9123 /* Maximum prefix */
9124 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9125 json_object_int_add(json_addr
, "prefixAllowedMax",
9126 p
->pmax
[afi
][safi
]);
9127 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9128 PEER_FLAG_MAX_PREFIX_WARNING
))
9129 json_object_boolean_true_add(
9130 json_addr
, "prefixAllowedMaxWarning");
9131 json_object_int_add(json_addr
,
9132 "prefixAllowedWarningThresh",
9133 p
->pmax_threshold
[afi
][safi
]);
9134 if (p
->pmax_restart
[afi
][safi
])
9135 json_object_int_add(
9137 "prefixAllowedRestartIntervalMsecs",
9138 p
->pmax_restart
[afi
][safi
] * 60000);
9140 json_object_object_add(json_neigh
, get_afi_safi_str(afi
, safi
, true),
9144 filter
= &p
->filter
[afi
][safi
];
9146 vty_out(vty
, " For address family: %s\n",
9147 get_afi_safi_str(afi
, safi
, false));
9149 if (peer_group_active(p
))
9150 vty_out(vty
, " %s peer-group member\n",
9153 paf
= peer_af_find(p
, afi
, safi
);
9154 if (paf
&& PAF_SUBGRP(paf
)) {
9155 vty_out(vty
, " Update group %" PRIu64
9156 ", subgroup %" PRIu64
"\n",
9157 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
9158 vty_out(vty
, " Packet Queue length %d\n",
9159 bpacket_queue_virtual_length(paf
));
9161 vty_out(vty
, " Not part of any update group\n");
9163 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9164 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9165 PEER_CAP_ORF_PREFIX_SM_RCV
)
9166 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9167 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
9168 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9169 PEER_CAP_ORF_PREFIX_RM_ADV
)
9170 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9171 PEER_CAP_ORF_PREFIX_RM_RCV
)
9172 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9173 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
9174 vty_out(vty
, " AF-dependant capabilities:\n");
9176 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9177 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9178 PEER_CAP_ORF_PREFIX_SM_RCV
)
9179 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9180 PEER_CAP_ORF_PREFIX_RM_ADV
)
9181 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9182 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
9184 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
9186 bgp_show_peer_afi_orf_cap(
9187 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
9188 PEER_CAP_ORF_PREFIX_RM_ADV
,
9189 PEER_CAP_ORF_PREFIX_SM_RCV
,
9190 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
9192 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9193 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9194 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
9195 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9196 PEER_CAP_ORF_PREFIX_RM_ADV
)
9197 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9198 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
9200 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
9201 ORF_TYPE_PREFIX_OLD
);
9202 bgp_show_peer_afi_orf_cap(
9203 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
9204 PEER_CAP_ORF_PREFIX_RM_ADV
,
9205 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
9206 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
9209 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
9210 orf_pfx_count
= prefix_bgp_show_prefix_list(
9211 NULL
, afi
, orf_pfx_name
, use_json
);
9213 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9214 PEER_STATUS_ORF_PREFIX_SEND
)
9216 vty_out(vty
, " Outbound Route Filter (ORF):");
9217 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9218 PEER_STATUS_ORF_PREFIX_SEND
))
9219 vty_out(vty
, " sent;");
9221 vty_out(vty
, " received (%d entries)",
9225 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9226 PEER_STATUS_ORF_WAIT_REFRESH
))
9228 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
9230 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9231 PEER_FLAG_REFLECTOR_CLIENT
))
9232 vty_out(vty
, " Route-Reflector Client\n");
9233 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9234 PEER_FLAG_RSERVER_CLIENT
))
9235 vty_out(vty
, " Route-Server Client\n");
9236 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9238 " Inbound soft reconfiguration allowed\n");
9240 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9241 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
9243 " Private AS numbers (all) replaced in updates to this neighbor\n");
9244 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9245 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
9247 " Private AS numbers replaced in updates to this neighbor\n");
9248 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9249 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
9251 " Private AS numbers (all) removed in updates to this neighbor\n");
9252 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9253 PEER_FLAG_REMOVE_PRIVATE_AS
))
9255 " Private AS numbers removed in updates to this neighbor\n");
9257 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
9258 vty_out(vty
, " %s\n",
9259 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
9260 ->human_description
);
9262 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
9264 " Override ASNs in outbound updates if aspath equals remote-as\n");
9266 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
9267 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9268 PEER_FLAG_FORCE_NEXTHOP_SELF
))
9269 vty_out(vty
, " NEXT_HOP is always this router\n");
9270 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9271 PEER_FLAG_AS_PATH_UNCHANGED
))
9273 " AS_PATH is propagated unchanged to this neighbor\n");
9274 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9275 PEER_FLAG_NEXTHOP_UNCHANGED
))
9277 " NEXT_HOP is propagated unchanged to this neighbor\n");
9278 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
9280 " MED is propagated unchanged to this neighbor\n");
9281 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
9282 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9283 PEER_FLAG_SEND_EXT_COMMUNITY
)
9284 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9285 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
9287 " Community attribute sent to this neighbor");
9288 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9289 PEER_FLAG_SEND_COMMUNITY
)
9290 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9291 PEER_FLAG_SEND_EXT_COMMUNITY
)
9292 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9293 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9294 vty_out(vty
, "(all)\n");
9295 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9296 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9297 vty_out(vty
, "(large)\n");
9298 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9299 PEER_FLAG_SEND_EXT_COMMUNITY
))
9300 vty_out(vty
, "(extended)\n");
9302 vty_out(vty
, "(standard)\n");
9304 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9305 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9306 vty_out(vty
, " Default information originate,");
9308 if (p
->default_rmap
[afi
][safi
].name
)
9309 vty_out(vty
, " default route-map %s%s,",
9310 p
->default_rmap
[afi
][safi
].map
? "*"
9312 p
->default_rmap
[afi
][safi
].name
);
9313 if (paf
&& PAF_SUBGRP(paf
)
9314 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9315 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9316 vty_out(vty
, " default sent\n");
9318 vty_out(vty
, " default not sent\n");
9321 /* advertise-vni-all */
9322 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9323 if (is_evpn_enabled())
9324 vty_out(vty
, " advertise-all-vni\n");
9327 if (filter
->plist
[FILTER_IN
].name
9328 || filter
->dlist
[FILTER_IN
].name
9329 || filter
->aslist
[FILTER_IN
].name
9330 || filter
->map
[RMAP_IN
].name
)
9331 vty_out(vty
, " Inbound path policy configured\n");
9332 if (filter
->plist
[FILTER_OUT
].name
9333 || filter
->dlist
[FILTER_OUT
].name
9334 || filter
->aslist
[FILTER_OUT
].name
9335 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9336 vty_out(vty
, " Outbound path policy configured\n");
9339 if (filter
->plist
[FILTER_IN
].name
)
9341 " Incoming update prefix filter list is %s%s\n",
9342 filter
->plist
[FILTER_IN
].plist
? "*" : "",
9343 filter
->plist
[FILTER_IN
].name
);
9344 if (filter
->plist
[FILTER_OUT
].name
)
9346 " Outgoing update prefix filter list is %s%s\n",
9347 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
9348 filter
->plist
[FILTER_OUT
].name
);
9350 /* distribute-list */
9351 if (filter
->dlist
[FILTER_IN
].name
)
9353 " Incoming update network filter list is %s%s\n",
9354 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
9355 filter
->dlist
[FILTER_IN
].name
);
9356 if (filter
->dlist
[FILTER_OUT
].name
)
9358 " Outgoing update network filter list is %s%s\n",
9359 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
9360 filter
->dlist
[FILTER_OUT
].name
);
9363 if (filter
->aslist
[FILTER_IN
].name
)
9365 " Incoming update AS path filter list is %s%s\n",
9366 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
9367 filter
->aslist
[FILTER_IN
].name
);
9368 if (filter
->aslist
[FILTER_OUT
].name
)
9370 " Outgoing update AS path filter list is %s%s\n",
9371 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
9372 filter
->aslist
[FILTER_OUT
].name
);
9375 if (filter
->map
[RMAP_IN
].name
)
9377 " Route map for incoming advertisements is %s%s\n",
9378 filter
->map
[RMAP_IN
].map
? "*" : "",
9379 filter
->map
[RMAP_IN
].name
);
9380 if (filter
->map
[RMAP_OUT
].name
)
9382 " Route map for outgoing advertisements is %s%s\n",
9383 filter
->map
[RMAP_OUT
].map
? "*" : "",
9384 filter
->map
[RMAP_OUT
].name
);
9386 /* ebgp-requires-policy (inbound) */
9387 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9388 && !bgp_inbound_policy_exists(p
, filter
))
9390 " Inbound updates discarded due to missing policy\n");
9392 /* ebgp-requires-policy (outbound) */
9393 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9394 && !bgp_outbound_policy_exists(p
, filter
))
9396 " Outbound updates discarded due to missing policy\n");
9398 /* unsuppress-map */
9399 if (filter
->usmap
.name
)
9401 " Route map for selective unsuppress is %s%s\n",
9402 filter
->usmap
.map
? "*" : "",
9403 filter
->usmap
.name
);
9405 /* Receive prefix count */
9406 vty_out(vty
, " %" PRIu32
" accepted prefixes\n",
9407 p
->pcount
[afi
][safi
]);
9409 /* Maximum prefix */
9410 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9412 " Maximum prefixes allowed %" PRIu32
"%s\n",
9414 CHECK_FLAG(p
->af_flags
[afi
][safi
],
9415 PEER_FLAG_MAX_PREFIX_WARNING
)
9418 vty_out(vty
, " Threshold for warning message %d%%",
9419 p
->pmax_threshold
[afi
][safi
]);
9420 if (p
->pmax_restart
[afi
][safi
])
9421 vty_out(vty
, ", restart interval %d min",
9422 p
->pmax_restart
[afi
][safi
]);
9430 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
9434 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
9435 char timebuf
[BGP_UPTIME_LEN
];
9441 json_object
*json_neigh
= NULL
;
9447 json_neigh
= json_object_new_object();
9449 memset(dn_flag
, '\0', sizeof(dn_flag
));
9450 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9454 if (p
->conf_if
) /* Configured interface name. */
9455 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9456 BGP_PEER_SU_UNSPEC(p
)
9458 : sockunion2str(&p
->su
, buf
,
9460 else /* Configured IP address. */
9461 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9466 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9467 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9469 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9470 json_object_string_add(
9471 json_neigh
, "bgpNeighborAddr",
9472 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9474 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9476 if (p
->change_local_as
)
9477 json_object_int_add(json_neigh
, "localAs",
9478 p
->change_local_as
);
9480 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9482 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9483 json_object_boolean_true_add(json_neigh
,
9484 "localAsNoPrepend");
9486 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9487 json_object_boolean_true_add(json_neigh
,
9488 "localAsReplaceAs");
9490 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9491 || (p
->as_type
== AS_INTERNAL
))
9492 vty_out(vty
, "remote AS %u, ", p
->as
);
9494 vty_out(vty
, "remote AS Unspecified, ");
9495 vty_out(vty
, "local AS %u%s%s, ",
9496 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9497 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9500 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9504 /* peer type internal or confed-internal */
9505 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
9507 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9508 json_object_boolean_true_add(
9509 json_neigh
, "nbrConfedInternalLink");
9511 json_object_boolean_true_add(json_neigh
,
9514 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9515 vty_out(vty
, "confed-internal link\n");
9517 vty_out(vty
, "internal link\n");
9519 /* peer type external or confed-external */
9520 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
9522 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9523 json_object_boolean_true_add(
9524 json_neigh
, "nbrConfedExternalLink");
9526 json_object_boolean_true_add(json_neigh
,
9529 if (bgp_confederation_peers_check(bgp
, p
->as
))
9530 vty_out(vty
, "confed-external link\n");
9532 vty_out(vty
, "external link\n");
9536 json_object_boolean_true_add(json_neigh
,
9537 "nbrUnspecifiedLink");
9539 vty_out(vty
, "unspecified link\n");
9545 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9547 vty_out(vty
, " Description: %s\n", p
->desc
);
9553 json_object_string_add(json_neigh
, "hostname",
9557 json_object_string_add(json_neigh
, "domainname",
9560 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9561 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9564 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9571 json_object_string_add(json_neigh
, "peerGroup",
9575 struct prefix prefix
, *range
= NULL
;
9577 sockunion2hostprefix(&(p
->su
), &prefix
);
9578 range
= peer_group_lookup_dynamic_neighbor_range(
9582 prefix2str(range
, buf1
, sizeof(buf1
));
9583 json_object_string_add(
9585 "peerSubnetRangeGroup", buf1
);
9590 " Member of peer-group %s for session parameters\n",
9594 struct prefix prefix
, *range
= NULL
;
9596 sockunion2hostprefix(&(p
->su
), &prefix
);
9597 range
= peer_group_lookup_dynamic_neighbor_range(
9601 prefix2str(range
, buf1
, sizeof(buf1
));
9603 " Belongs to the subnet range group: %s\n",
9611 /* Administrative shutdown. */
9612 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9613 json_object_boolean_true_add(json_neigh
,
9617 json_object_int_add(json_neigh
, "bgpVersion", 4);
9618 json_object_string_add(
9619 json_neigh
, "remoteRouterId",
9620 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9621 json_object_string_add(
9622 json_neigh
, "localRouterId",
9623 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9627 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9628 && bgp_confederation_peers_check(bgp
, p
->as
))
9629 json_object_boolean_true_add(json_neigh
,
9633 json_object_string_add(
9634 json_neigh
, "bgpState",
9635 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9637 if (p
->status
== Established
) {
9640 uptime
= bgp_clock();
9641 uptime
-= p
->uptime
;
9642 epoch_tbuf
= time(NULL
) - uptime
;
9644 #if CONFDATE > 20200101
9646 "bgpTimerUp should be deprecated and can be removed now");
9649 * bgpTimerUp was miliseconds that was accurate
9650 * up to 1 day, then the value returned
9651 * became garbage. So in order to provide
9652 * some level of backwards compatability,
9653 * we still provde the data, but now
9654 * we are returning the correct value
9655 * and also adding a new bgpTimerUpMsec
9656 * which will allow us to deprecate
9659 json_object_int_add(json_neigh
, "bgpTimerUp",
9661 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9663 json_object_string_add(json_neigh
, "bgpTimerUpString",
9664 peer_uptime(p
->uptime
, timebuf
,
9667 json_object_int_add(json_neigh
,
9668 "bgpTimerUpEstablishedEpoch",
9672 else if (p
->status
== Active
) {
9673 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9674 json_object_string_add(json_neigh
, "bgpStateIs",
9676 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9677 json_object_string_add(json_neigh
, "bgpStateIs",
9685 uptime
= bgp_clock();
9686 uptime
-= p
->readtime
;
9687 tm
= gmtime(&uptime
);
9688 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9689 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9690 + (tm
->tm_hour
* 3600000));
9692 uptime
= bgp_clock();
9693 uptime
-= p
->last_write
;
9694 tm
= gmtime(&uptime
);
9695 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9696 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9697 + (tm
->tm_hour
* 3600000));
9699 uptime
= bgp_clock();
9700 uptime
-= p
->update_time
;
9701 tm
= gmtime(&uptime
);
9702 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9703 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9704 + (tm
->tm_hour
* 3600000));
9706 /* Configured timer values. */
9707 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9708 p
->v_holdtime
* 1000);
9709 json_object_int_add(json_neigh
,
9710 "bgpTimerKeepAliveIntervalMsecs",
9711 p
->v_keepalive
* 1000);
9712 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9713 json_object_int_add(json_neigh
,
9714 "bgpTimerConfiguredHoldTimeMsecs",
9715 p
->holdtime
* 1000);
9716 json_object_int_add(
9718 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9719 p
->keepalive
* 1000);
9720 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9721 || (bgp
->default_keepalive
9722 != BGP_DEFAULT_KEEPALIVE
)) {
9723 json_object_int_add(json_neigh
,
9724 "bgpTimerConfiguredHoldTimeMsecs",
9725 bgp
->default_holdtime
);
9726 json_object_int_add(
9728 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9729 bgp
->default_keepalive
);
9732 /* Administrative shutdown. */
9733 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9734 vty_out(vty
, " Administratively shut down\n");
9737 vty_out(vty
, " BGP version 4");
9738 vty_out(vty
, ", remote router ID %s",
9739 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9740 vty_out(vty
, ", local router ID %s\n",
9741 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9745 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9746 && bgp_confederation_peers_check(bgp
, p
->as
))
9748 " Neighbor under common administration\n");
9751 vty_out(vty
, " BGP state = %s",
9752 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9754 if (p
->status
== Established
)
9755 vty_out(vty
, ", up for %8s",
9756 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9759 else if (p
->status
== Active
) {
9760 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9761 vty_out(vty
, " (passive)");
9762 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9763 vty_out(vty
, " (NSF passive)");
9768 vty_out(vty
, " Last read %s",
9769 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9771 vty_out(vty
, ", Last write %s\n",
9772 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9775 /* Configured timer values. */
9777 " Hold time is %d, keepalive interval is %d seconds\n",
9778 p
->v_holdtime
, p
->v_keepalive
);
9779 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9780 vty_out(vty
, " Configured hold time is %d",
9782 vty_out(vty
, ", keepalive interval is %d seconds\n",
9784 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9785 || (bgp
->default_keepalive
9786 != BGP_DEFAULT_KEEPALIVE
)) {
9787 vty_out(vty
, " Configured hold time is %d",
9788 bgp
->default_holdtime
);
9789 vty_out(vty
, ", keepalive interval is %d seconds\n",
9790 bgp
->default_keepalive
);
9794 if (p
->status
== Established
) {
9795 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9796 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9797 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9798 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9799 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9800 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9801 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9802 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9803 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9804 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9805 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9806 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9807 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9808 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9809 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9810 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9811 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9812 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9813 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9814 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9816 json_object
*json_cap
= NULL
;
9818 json_cap
= json_object_new_object();
9821 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9822 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9823 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9824 && CHECK_FLAG(p
->cap
,
9826 json_object_string_add(
9827 json_cap
, "4byteAs",
9828 "advertisedAndReceived");
9829 else if (CHECK_FLAG(p
->cap
,
9831 json_object_string_add(
9832 json_cap
, "4byteAs",
9834 else if (CHECK_FLAG(p
->cap
,
9836 json_object_string_add(
9837 json_cap
, "4byteAs",
9842 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9843 || CHECK_FLAG(p
->cap
,
9844 PEER_CAP_ADDPATH_ADV
)) {
9845 json_object
*json_add
= NULL
;
9846 const char *print_store
;
9848 json_add
= json_object_new_object();
9850 FOREACH_AFI_SAFI (afi
, safi
) {
9851 json_object
*json_sub
= NULL
;
9853 json_object_new_object();
9854 print_store
= get_afi_safi_str(
9860 PEER_CAP_ADDPATH_AF_TX_ADV
)
9864 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9869 PEER_CAP_ADDPATH_AF_TX_ADV
)
9874 PEER_CAP_ADDPATH_AF_TX_RCV
))
9875 json_object_boolean_true_add(
9877 "txAdvertisedAndReceived");
9883 PEER_CAP_ADDPATH_AF_TX_ADV
))
9884 json_object_boolean_true_add(
9892 PEER_CAP_ADDPATH_AF_TX_RCV
))
9893 json_object_boolean_true_add(
9901 PEER_CAP_ADDPATH_AF_RX_ADV
)
9905 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9910 PEER_CAP_ADDPATH_AF_RX_ADV
)
9915 PEER_CAP_ADDPATH_AF_RX_RCV
))
9916 json_object_boolean_true_add(
9918 "rxAdvertisedAndReceived");
9924 PEER_CAP_ADDPATH_AF_RX_ADV
))
9925 json_object_boolean_true_add(
9933 PEER_CAP_ADDPATH_AF_RX_RCV
))
9934 json_object_boolean_true_add(
9942 PEER_CAP_ADDPATH_AF_TX_ADV
)
9946 PEER_CAP_ADDPATH_AF_TX_RCV
)
9950 PEER_CAP_ADDPATH_AF_RX_ADV
)
9954 PEER_CAP_ADDPATH_AF_RX_RCV
))
9955 json_object_object_add(
9964 json_object_object_add(
9965 json_cap
, "addPath", json_add
);
9969 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9970 || CHECK_FLAG(p
->cap
,
9971 PEER_CAP_DYNAMIC_ADV
)) {
9972 if (CHECK_FLAG(p
->cap
,
9973 PEER_CAP_DYNAMIC_ADV
)
9974 && CHECK_FLAG(p
->cap
,
9975 PEER_CAP_DYNAMIC_RCV
))
9976 json_object_string_add(
9977 json_cap
, "dynamic",
9978 "advertisedAndReceived");
9979 else if (CHECK_FLAG(
9981 PEER_CAP_DYNAMIC_ADV
))
9982 json_object_string_add(
9983 json_cap
, "dynamic",
9985 else if (CHECK_FLAG(
9987 PEER_CAP_DYNAMIC_RCV
))
9988 json_object_string_add(
9989 json_cap
, "dynamic",
9993 /* Extended nexthop */
9994 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9995 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9996 json_object
*json_nxt
= NULL
;
9997 const char *print_store
;
10000 if (CHECK_FLAG(p
->cap
,
10002 && CHECK_FLAG(p
->cap
,
10003 PEER_CAP_ENHE_RCV
))
10004 json_object_string_add(
10007 "advertisedAndReceived");
10008 else if (CHECK_FLAG(p
->cap
,
10009 PEER_CAP_ENHE_ADV
))
10010 json_object_string_add(
10014 else if (CHECK_FLAG(p
->cap
,
10015 PEER_CAP_ENHE_RCV
))
10016 json_object_string_add(
10021 if (CHECK_FLAG(p
->cap
,
10022 PEER_CAP_ENHE_RCV
)) {
10024 json_object_new_object();
10026 for (safi
= SAFI_UNICAST
;
10027 safi
< SAFI_MAX
; safi
++) {
10032 PEER_CAP_ENHE_AF_RCV
)) {
10033 print_store
= get_afi_safi_str(
10036 json_object_string_add(
10039 "recieved"); /* misspelled for compatibility */
10042 json_object_object_add(
10044 "extendedNexthopFamililesByPeer",
10049 /* Route Refresh */
10050 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10051 || CHECK_FLAG(p
->cap
,
10052 PEER_CAP_REFRESH_NEW_RCV
)
10053 || CHECK_FLAG(p
->cap
,
10054 PEER_CAP_REFRESH_OLD_RCV
)) {
10055 if (CHECK_FLAG(p
->cap
,
10056 PEER_CAP_REFRESH_ADV
)
10059 PEER_CAP_REFRESH_NEW_RCV
)
10062 PEER_CAP_REFRESH_OLD_RCV
))) {
10065 PEER_CAP_REFRESH_OLD_RCV
)
10068 PEER_CAP_REFRESH_NEW_RCV
))
10069 json_object_string_add(
10072 "advertisedAndReceivedOldNew");
10076 PEER_CAP_REFRESH_OLD_RCV
))
10077 json_object_string_add(
10080 "advertisedAndReceivedOld");
10082 json_object_string_add(
10085 "advertisedAndReceivedNew");
10090 PEER_CAP_REFRESH_ADV
))
10091 json_object_string_add(
10098 PEER_CAP_REFRESH_NEW_RCV
)
10101 PEER_CAP_REFRESH_OLD_RCV
))
10102 json_object_string_add(
10108 /* Multiprotocol Extensions */
10109 json_object
*json_multi
= NULL
;
10110 json_multi
= json_object_new_object();
10112 FOREACH_AFI_SAFI (afi
, safi
) {
10113 if (p
->afc_adv
[afi
][safi
]
10114 || p
->afc_recv
[afi
][safi
]) {
10115 json_object
*json_exten
= NULL
;
10117 json_object_new_object();
10119 if (p
->afc_adv
[afi
][safi
]
10120 && p
->afc_recv
[afi
][safi
])
10121 json_object_boolean_true_add(
10123 "advertisedAndReceived");
10124 else if (p
->afc_adv
[afi
][safi
])
10125 json_object_boolean_true_add(
10128 else if (p
->afc_recv
[afi
][safi
])
10129 json_object_boolean_true_add(
10133 json_object_object_add(
10135 get_afi_safi_str(afi
,
10141 json_object_object_add(
10142 json_cap
, "multiprotocolExtensions",
10145 /* Hostname capabilities */
10146 json_object
*json_hname
= NULL
;
10148 json_hname
= json_object_new_object();
10150 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10151 json_object_string_add(
10152 json_hname
, "advHostName",
10153 bgp
->peer_self
->hostname
10157 json_object_string_add(
10158 json_hname
, "advDomainName",
10159 bgp
->peer_self
->domainname
10166 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10167 json_object_string_add(
10168 json_hname
, "rcvHostName",
10169 p
->hostname
? p
->hostname
10171 json_object_string_add(
10172 json_hname
, "rcvDomainName",
10173 p
->domainname
? p
->domainname
10177 json_object_object_add(json_cap
, "hostName",
10180 /* Gracefull Restart */
10181 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10182 || CHECK_FLAG(p
->cap
,
10183 PEER_CAP_RESTART_ADV
)) {
10184 if (CHECK_FLAG(p
->cap
,
10185 PEER_CAP_RESTART_ADV
)
10186 && CHECK_FLAG(p
->cap
,
10187 PEER_CAP_RESTART_RCV
))
10188 json_object_string_add(
10191 "advertisedAndReceived");
10192 else if (CHECK_FLAG(
10194 PEER_CAP_RESTART_ADV
))
10195 json_object_string_add(
10197 "gracefulRestartCapability",
10199 else if (CHECK_FLAG(
10201 PEER_CAP_RESTART_RCV
))
10202 json_object_string_add(
10204 "gracefulRestartCapability",
10207 if (CHECK_FLAG(p
->cap
,
10208 PEER_CAP_RESTART_RCV
)) {
10209 int restart_af_count
= 0;
10210 json_object
*json_restart
=
10213 json_object_new_object();
10215 json_object_int_add(
10217 "gracefulRestartRemoteTimerMsecs",
10218 p
->v_gr_restart
* 1000);
10220 FOREACH_AFI_SAFI (afi
, safi
) {
10225 PEER_CAP_RESTART_AF_RCV
)) {
10230 json_object_new_object();
10236 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
10237 json_object_boolean_true_add(
10240 restart_af_count
++;
10241 json_object_object_add(
10250 if (!restart_af_count
) {
10251 json_object_string_add(
10253 "addressFamiliesByPeer",
10258 json_object_object_add(
10260 "addressFamiliesByPeer",
10264 json_object_object_add(json_neigh
,
10265 "neighborCapabilities",
10268 vty_out(vty
, " Neighbor capabilities:\n");
10271 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
10272 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
10273 vty_out(vty
, " 4 Byte AS:");
10274 if (CHECK_FLAG(p
->cap
,
10276 vty_out(vty
, " advertised");
10277 if (CHECK_FLAG(p
->cap
,
10279 vty_out(vty
, " %sreceived",
10285 vty_out(vty
, "\n");
10289 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
10290 || CHECK_FLAG(p
->cap
,
10291 PEER_CAP_ADDPATH_ADV
)) {
10292 vty_out(vty
, " AddPath:\n");
10294 FOREACH_AFI_SAFI (afi
, safi
) {
10298 PEER_CAP_ADDPATH_AF_TX_ADV
)
10302 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
10314 PEER_CAP_ADDPATH_AF_TX_ADV
))
10326 PEER_CAP_ADDPATH_AF_TX_RCV
))
10333 PEER_CAP_ADDPATH_AF_TX_ADV
)
10337 vty_out(vty
, "\n");
10343 PEER_CAP_ADDPATH_AF_RX_ADV
)
10347 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
10359 PEER_CAP_ADDPATH_AF_RX_ADV
))
10371 PEER_CAP_ADDPATH_AF_RX_RCV
))
10378 PEER_CAP_ADDPATH_AF_RX_ADV
)
10382 vty_out(vty
, "\n");
10388 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10389 || CHECK_FLAG(p
->cap
,
10390 PEER_CAP_DYNAMIC_ADV
)) {
10391 vty_out(vty
, " Dynamic:");
10392 if (CHECK_FLAG(p
->cap
,
10393 PEER_CAP_DYNAMIC_ADV
))
10394 vty_out(vty
, " advertised");
10395 if (CHECK_FLAG(p
->cap
,
10396 PEER_CAP_DYNAMIC_RCV
))
10397 vty_out(vty
, " %sreceived",
10400 PEER_CAP_DYNAMIC_ADV
)
10403 vty_out(vty
, "\n");
10406 /* Extended nexthop */
10407 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10408 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10409 vty_out(vty
, " Extended nexthop:");
10410 if (CHECK_FLAG(p
->cap
,
10411 PEER_CAP_ENHE_ADV
))
10412 vty_out(vty
, " advertised");
10413 if (CHECK_FLAG(p
->cap
,
10414 PEER_CAP_ENHE_RCV
))
10415 vty_out(vty
, " %sreceived",
10421 vty_out(vty
, "\n");
10423 if (CHECK_FLAG(p
->cap
,
10424 PEER_CAP_ENHE_RCV
)) {
10426 " Address families by peer:\n ");
10427 for (safi
= SAFI_UNICAST
;
10428 safi
< SAFI_MAX
; safi
++)
10433 PEER_CAP_ENHE_AF_RCV
))
10443 /* Route Refresh */
10444 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10445 || CHECK_FLAG(p
->cap
,
10446 PEER_CAP_REFRESH_NEW_RCV
)
10447 || CHECK_FLAG(p
->cap
,
10448 PEER_CAP_REFRESH_OLD_RCV
)) {
10449 vty_out(vty
, " Route refresh:");
10450 if (CHECK_FLAG(p
->cap
,
10451 PEER_CAP_REFRESH_ADV
))
10452 vty_out(vty
, " advertised");
10453 if (CHECK_FLAG(p
->cap
,
10454 PEER_CAP_REFRESH_NEW_RCV
)
10457 PEER_CAP_REFRESH_OLD_RCV
))
10458 vty_out(vty
, " %sreceived(%s)",
10461 PEER_CAP_REFRESH_ADV
)
10466 PEER_CAP_REFRESH_OLD_RCV
)
10469 PEER_CAP_REFRESH_NEW_RCV
))
10473 PEER_CAP_REFRESH_OLD_RCV
)
10477 vty_out(vty
, "\n");
10480 /* Multiprotocol Extensions */
10481 FOREACH_AFI_SAFI (afi
, safi
)
10482 if (p
->afc_adv
[afi
][safi
]
10483 || p
->afc_recv
[afi
][safi
]) {
10485 " Address Family %s:",
10490 if (p
->afc_adv
[afi
][safi
])
10493 if (p
->afc_recv
[afi
][safi
])
10500 vty_out(vty
, "\n");
10503 /* Hostname capability */
10504 vty_out(vty
, " Hostname Capability:");
10506 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10508 " advertised (name: %s,domain name: %s)",
10509 bgp
->peer_self
->hostname
10513 bgp
->peer_self
->domainname
10518 vty_out(vty
, " not advertised");
10521 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10523 " received (name: %s,domain name: %s)",
10524 p
->hostname
? p
->hostname
10526 p
->domainname
? p
->domainname
10529 vty_out(vty
, " not received");
10532 vty_out(vty
, "\n");
10534 /* Gracefull Restart */
10535 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10536 || CHECK_FLAG(p
->cap
,
10537 PEER_CAP_RESTART_ADV
)) {
10539 " Graceful Restart Capabilty:");
10540 if (CHECK_FLAG(p
->cap
,
10541 PEER_CAP_RESTART_ADV
))
10542 vty_out(vty
, " advertised");
10543 if (CHECK_FLAG(p
->cap
,
10544 PEER_CAP_RESTART_RCV
))
10545 vty_out(vty
, " %sreceived",
10548 PEER_CAP_RESTART_ADV
)
10551 vty_out(vty
, "\n");
10553 if (CHECK_FLAG(p
->cap
,
10554 PEER_CAP_RESTART_RCV
)) {
10555 int restart_af_count
= 0;
10558 " Remote Restart timer is %d seconds\n",
10561 " Address families by peer:\n ");
10563 FOREACH_AFI_SAFI (afi
, safi
)
10568 PEER_CAP_RESTART_AF_RCV
)) {
10582 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10584 : "not preserved");
10585 restart_af_count
++;
10587 if (!restart_af_count
)
10588 vty_out(vty
, "none");
10589 vty_out(vty
, "\n");
10596 /* graceful restart information */
10597 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10598 || p
->t_gr_stale
) {
10599 json_object
*json_grace
= NULL
;
10600 json_object
*json_grace_send
= NULL
;
10601 json_object
*json_grace_recv
= NULL
;
10602 int eor_send_af_count
= 0;
10603 int eor_receive_af_count
= 0;
10606 json_grace
= json_object_new_object();
10607 json_grace_send
= json_object_new_object();
10608 json_grace_recv
= json_object_new_object();
10610 if (p
->status
== Established
) {
10611 FOREACH_AFI_SAFI (afi
, safi
) {
10612 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10613 PEER_STATUS_EOR_SEND
)) {
10614 json_object_boolean_true_add(
10616 get_afi_safi_str(afi
,
10619 eor_send_af_count
++;
10622 FOREACH_AFI_SAFI (afi
, safi
) {
10624 p
->af_sflags
[afi
][safi
],
10625 PEER_STATUS_EOR_RECEIVED
)) {
10626 json_object_boolean_true_add(
10628 get_afi_safi_str(afi
,
10631 eor_receive_af_count
++;
10636 json_object_object_add(json_grace
, "endOfRibSend",
10638 json_object_object_add(json_grace
, "endOfRibRecv",
10641 if (p
->t_gr_restart
)
10642 json_object_int_add(json_grace
,
10643 "gracefulRestartTimerMsecs",
10644 thread_timer_remain_second(
10649 json_object_int_add(
10651 "gracefulStalepathTimerMsecs",
10652 thread_timer_remain_second(
10656 json_object_object_add(
10657 json_neigh
, "gracefulRestartInfo", json_grace
);
10659 vty_out(vty
, " Graceful restart information:\n");
10660 if (p
->status
== Established
) {
10661 vty_out(vty
, " End-of-RIB send: ");
10662 FOREACH_AFI_SAFI (afi
, safi
) {
10663 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10664 PEER_STATUS_EOR_SEND
)) {
10665 vty_out(vty
, "%s%s",
10666 eor_send_af_count
? ", "
10668 get_afi_safi_str(afi
,
10671 eor_send_af_count
++;
10674 vty_out(vty
, "\n");
10675 vty_out(vty
, " End-of-RIB received: ");
10676 FOREACH_AFI_SAFI (afi
, safi
) {
10678 p
->af_sflags
[afi
][safi
],
10679 PEER_STATUS_EOR_RECEIVED
)) {
10680 vty_out(vty
, "%s%s",
10681 eor_receive_af_count
10684 get_afi_safi_str(afi
,
10687 eor_receive_af_count
++;
10690 vty_out(vty
, "\n");
10693 if (p
->t_gr_restart
)
10695 " The remaining time of restart timer is %ld\n",
10696 thread_timer_remain_second(
10701 " The remaining time of stalepath timer is %ld\n",
10702 thread_timer_remain_second(
10707 json_object
*json_stat
= NULL
;
10708 json_stat
= json_object_new_object();
10709 /* Packet counts. */
10710 json_object_int_add(json_stat
, "depthInq", 0);
10711 json_object_int_add(json_stat
, "depthOutq",
10712 (unsigned long)p
->obuf
->count
);
10713 json_object_int_add(json_stat
, "opensSent",
10714 atomic_load_explicit(&p
->open_out
,
10715 memory_order_relaxed
));
10716 json_object_int_add(json_stat
, "opensRecv",
10717 atomic_load_explicit(&p
->open_in
,
10718 memory_order_relaxed
));
10719 json_object_int_add(json_stat
, "notificationsSent",
10720 atomic_load_explicit(&p
->notify_out
,
10721 memory_order_relaxed
));
10722 json_object_int_add(json_stat
, "notificationsRecv",
10723 atomic_load_explicit(&p
->notify_in
,
10724 memory_order_relaxed
));
10725 json_object_int_add(json_stat
, "updatesSent",
10726 atomic_load_explicit(&p
->update_out
,
10727 memory_order_relaxed
));
10728 json_object_int_add(json_stat
, "updatesRecv",
10729 atomic_load_explicit(&p
->update_in
,
10730 memory_order_relaxed
));
10731 json_object_int_add(json_stat
, "keepalivesSent",
10732 atomic_load_explicit(&p
->keepalive_out
,
10733 memory_order_relaxed
));
10734 json_object_int_add(json_stat
, "keepalivesRecv",
10735 atomic_load_explicit(&p
->keepalive_in
,
10736 memory_order_relaxed
));
10737 json_object_int_add(json_stat
, "routeRefreshSent",
10738 atomic_load_explicit(&p
->refresh_out
,
10739 memory_order_relaxed
));
10740 json_object_int_add(json_stat
, "routeRefreshRecv",
10741 atomic_load_explicit(&p
->refresh_in
,
10742 memory_order_relaxed
));
10743 json_object_int_add(json_stat
, "capabilitySent",
10744 atomic_load_explicit(&p
->dynamic_cap_out
,
10745 memory_order_relaxed
));
10746 json_object_int_add(json_stat
, "capabilityRecv",
10747 atomic_load_explicit(&p
->dynamic_cap_in
,
10748 memory_order_relaxed
));
10749 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10750 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10751 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10753 /* Packet counts. */
10754 vty_out(vty
, " Message statistics:\n");
10755 vty_out(vty
, " Inq depth is 0\n");
10756 vty_out(vty
, " Outq depth is %lu\n",
10757 (unsigned long)p
->obuf
->count
);
10758 vty_out(vty
, " Sent Rcvd\n");
10759 vty_out(vty
, " Opens: %10d %10d\n",
10760 atomic_load_explicit(&p
->open_out
,
10761 memory_order_relaxed
),
10762 atomic_load_explicit(&p
->open_in
,
10763 memory_order_relaxed
));
10764 vty_out(vty
, " Notifications: %10d %10d\n",
10765 atomic_load_explicit(&p
->notify_out
,
10766 memory_order_relaxed
),
10767 atomic_load_explicit(&p
->notify_in
,
10768 memory_order_relaxed
));
10769 vty_out(vty
, " Updates: %10d %10d\n",
10770 atomic_load_explicit(&p
->update_out
,
10771 memory_order_relaxed
),
10772 atomic_load_explicit(&p
->update_in
,
10773 memory_order_relaxed
));
10774 vty_out(vty
, " Keepalives: %10d %10d\n",
10775 atomic_load_explicit(&p
->keepalive_out
,
10776 memory_order_relaxed
),
10777 atomic_load_explicit(&p
->keepalive_in
,
10778 memory_order_relaxed
));
10779 vty_out(vty
, " Route Refresh: %10d %10d\n",
10780 atomic_load_explicit(&p
->refresh_out
,
10781 memory_order_relaxed
),
10782 atomic_load_explicit(&p
->refresh_in
,
10783 memory_order_relaxed
));
10784 vty_out(vty
, " Capability: %10d %10d\n",
10785 atomic_load_explicit(&p
->dynamic_cap_out
,
10786 memory_order_relaxed
),
10787 atomic_load_explicit(&p
->dynamic_cap_in
,
10788 memory_order_relaxed
));
10789 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10794 /* advertisement-interval */
10795 json_object_int_add(json_neigh
,
10796 "minBtwnAdvertisementRunsTimerMsecs",
10797 p
->v_routeadv
* 1000);
10799 /* Update-source. */
10800 if (p
->update_if
|| p
->update_source
) {
10802 json_object_string_add(json_neigh
,
10805 else if (p
->update_source
)
10806 json_object_string_add(
10807 json_neigh
, "updateSource",
10808 sockunion2str(p
->update_source
, buf1
,
10812 /* advertisement-interval */
10814 " Minimum time between advertisement runs is %d seconds\n",
10817 /* Update-source. */
10818 if (p
->update_if
|| p
->update_source
) {
10819 vty_out(vty
, " Update source is ");
10821 vty_out(vty
, "%s", p
->update_if
);
10822 else if (p
->update_source
)
10824 sockunion2str(p
->update_source
, buf1
,
10826 vty_out(vty
, "\n");
10829 vty_out(vty
, "\n");
10832 /* Address Family Information */
10833 json_object
*json_hold
= NULL
;
10836 json_hold
= json_object_new_object();
10838 FOREACH_AFI_SAFI (afi
, safi
)
10839 if (p
->afc
[afi
][safi
])
10840 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10844 json_object_object_add(json_neigh
, "addressFamilyInfo",
10846 json_object_int_add(json_neigh
, "connectionsEstablished",
10848 json_object_int_add(json_neigh
, "connectionsDropped",
10851 vty_out(vty
, " Connections established %d; dropped %d\n",
10852 p
->established
, p
->dropped
);
10854 if (!p
->last_reset
) {
10856 json_object_string_add(json_neigh
, "lastReset",
10859 vty_out(vty
, " Last reset never\n");
10865 uptime
= bgp_clock();
10866 uptime
-= p
->resettime
;
10867 tm
= gmtime(&uptime
);
10868 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10869 (tm
->tm_sec
* 1000)
10870 + (tm
->tm_min
* 60000)
10871 + (tm
->tm_hour
* 3600000));
10872 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
10874 vty_out(vty
, " Last reset %s, ",
10875 peer_uptime(p
->resettime
, timebuf
,
10876 BGP_UPTIME_LEN
, 0, NULL
));
10878 bgp_show_peer_reset(vty
, p
, NULL
, false);
10879 if (p
->last_reset_cause_size
) {
10880 msg
= p
->last_reset_cause
;
10882 " Message received that caused BGP to send a NOTIFICATION:\n ");
10883 for (i
= 1; i
<= p
->last_reset_cause_size
;
10885 vty_out(vty
, "%02X", *msg
++);
10887 if (i
!= p
->last_reset_cause_size
) {
10889 vty_out(vty
, "\n ");
10890 } else if (i
% 4 == 0) {
10895 vty_out(vty
, "\n");
10900 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10902 json_object_boolean_true_add(json_neigh
,
10903 "prefixesConfigExceedMax");
10906 " Peer had exceeded the max. no. of prefixes configured.\n");
10908 if (p
->t_pmax_restart
) {
10910 json_object_boolean_true_add(
10911 json_neigh
, "reducePrefixNumFrom");
10912 json_object_int_add(json_neigh
,
10913 "restartInTimerMsec",
10914 thread_timer_remain_second(
10919 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10920 p
->host
, thread_timer_remain_second(
10921 p
->t_pmax_restart
));
10924 json_object_boolean_true_add(
10926 "reducePrefixNumAndClearIpBgp");
10929 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10934 /* EBGP Multihop and GTSM */
10935 if (p
->sort
!= BGP_PEER_IBGP
) {
10937 if (p
->gtsm_hops
> 0)
10938 json_object_int_add(json_neigh
,
10939 "externalBgpNbrMaxHopsAway",
10941 else if (p
->ttl
> 1)
10942 json_object_int_add(json_neigh
,
10943 "externalBgpNbrMaxHopsAway",
10946 if (p
->gtsm_hops
> 0)
10948 " External BGP neighbor may be up to %d hops away.\n",
10950 else if (p
->ttl
> 1)
10952 " External BGP neighbor may be up to %d hops away.\n",
10956 if (p
->gtsm_hops
> 0) {
10958 json_object_int_add(json_neigh
,
10959 "internalBgpNbrMaxHopsAway",
10963 " Internal BGP neighbor may be up to %d hops away.\n",
10968 /* Local address. */
10971 json_object_string_add(json_neigh
, "hostLocal",
10972 sockunion2str(p
->su_local
, buf1
,
10974 json_object_int_add(json_neigh
, "portLocal",
10975 ntohs(p
->su_local
->sin
.sin_port
));
10977 vty_out(vty
, "Local host: %s, Local port: %d\n",
10978 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10979 ntohs(p
->su_local
->sin
.sin_port
));
10982 /* Remote address. */
10983 if (p
->su_remote
) {
10985 json_object_string_add(json_neigh
, "hostForeign",
10986 sockunion2str(p
->su_remote
, buf1
,
10988 json_object_int_add(json_neigh
, "portForeign",
10989 ntohs(p
->su_remote
->sin
.sin_port
));
10991 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10992 sockunion2str(p
->su_remote
, buf1
,
10994 ntohs(p
->su_remote
->sin
.sin_port
));
10997 /* Nexthop display. */
11000 json_object_string_add(json_neigh
, "nexthop",
11002 &p
->nexthop
.v4
, buf1
,
11004 json_object_string_add(json_neigh
, "nexthopGlobal",
11005 inet_ntop(AF_INET6
,
11006 &p
->nexthop
.v6_global
,
11007 buf1
, sizeof(buf1
)));
11008 json_object_string_add(json_neigh
, "nexthopLocal",
11009 inet_ntop(AF_INET6
,
11010 &p
->nexthop
.v6_local
,
11011 buf1
, sizeof(buf1
)));
11012 if (p
->shared_network
)
11013 json_object_string_add(json_neigh
,
11017 json_object_string_add(json_neigh
,
11019 "nonSharedNetwork");
11021 vty_out(vty
, "Nexthop: %s\n",
11022 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
11024 vty_out(vty
, "Nexthop global: %s\n",
11025 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
11027 vty_out(vty
, "Nexthop local: %s\n",
11028 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
11030 vty_out(vty
, "BGP connection: %s\n",
11031 p
->shared_network
? "shared network"
11032 : "non shared network");
11036 /* Timer information. */
11038 json_object_int_add(json_neigh
, "connectRetryTimer",
11040 if (p
->status
== Established
&& p
->rtt
)
11041 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
11044 json_object_int_add(
11045 json_neigh
, "nextStartTimerDueInMsecs",
11046 thread_timer_remain_second(p
->t_start
) * 1000);
11048 json_object_int_add(
11049 json_neigh
, "nextConnectTimerDueInMsecs",
11050 thread_timer_remain_second(p
->t_connect
)
11052 if (p
->t_routeadv
) {
11053 json_object_int_add(json_neigh
, "mraiInterval",
11055 json_object_int_add(
11056 json_neigh
, "mraiTimerExpireInMsecs",
11057 thread_timer_remain_second(p
->t_routeadv
)
11061 json_object_int_add(json_neigh
, "authenticationEnabled",
11065 json_object_string_add(json_neigh
, "readThread", "on");
11067 json_object_string_add(json_neigh
, "readThread", "off");
11069 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
11070 json_object_string_add(json_neigh
, "writeThread", "on");
11072 json_object_string_add(json_neigh
, "writeThread",
11075 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
11077 if (p
->status
== Established
&& p
->rtt
)
11078 vty_out(vty
, "Estimated round trip time: %d ms\n",
11081 vty_out(vty
, "Next start timer due in %ld seconds\n",
11082 thread_timer_remain_second(p
->t_start
));
11084 vty_out(vty
, "Next connect timer due in %ld seconds\n",
11085 thread_timer_remain_second(p
->t_connect
));
11088 "MRAI (interval %u) timer expires in %ld seconds\n",
11090 thread_timer_remain_second(p
->t_routeadv
));
11092 vty_out(vty
, "Peer Authentication Enabled\n");
11094 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
11095 p
->t_read
? "on" : "off",
11096 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
11101 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
11102 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
11103 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
11106 vty_out(vty
, "\n");
11108 /* BFD information. */
11109 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
11112 if (p
->conf_if
) /* Configured interface name. */
11113 json_object_object_add(json
, p
->conf_if
, json_neigh
);
11114 else /* Configured IP address. */
11115 json_object_object_add(json
, p
->host
, json_neigh
);
11119 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
11120 enum show_type type
, union sockunion
*su
,
11121 const char *conf_if
, bool use_json
,
11124 struct listnode
*node
, *nnode
;
11127 bool nbr_output
= false;
11128 afi_t afi
= AFI_MAX
;
11129 safi_t safi
= SAFI_MAX
;
11131 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
11133 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
11137 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11138 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11143 bgp_show_peer(vty
, peer
, use_json
, json
);
11149 && !strcmp(peer
->conf_if
, conf_if
))
11151 && !strcmp(peer
->hostname
, conf_if
))) {
11153 bgp_show_peer(vty
, peer
, use_json
,
11157 if (sockunion_same(&peer
->su
, su
)) {
11159 bgp_show_peer(vty
, peer
, use_json
,
11164 case show_ipv4_peer
:
11165 case show_ipv6_peer
:
11166 FOREACH_SAFI (safi
) {
11167 if (peer
->afc
[afi
][safi
]) {
11170 && !strcmp(peer
->conf_if
, conf_if
))
11172 && !strcmp(peer
->hostname
, conf_if
))) {
11174 bgp_show_peer(vty
, peer
, use_json
,
11179 if (sockunion_same(&peer
->su
, su
)) {
11181 bgp_show_peer(vty
, peer
, use_json
,
11189 case show_ipv4_all
:
11190 case show_ipv6_all
:
11191 FOREACH_SAFI (safi
) {
11192 if (peer
->afc
[afi
][safi
]) {
11193 bgp_show_peer(vty
, peer
, use_json
, json
);
11202 if ((type
== show_peer
|| type
== show_ipv4_peer
||
11203 type
== show_ipv6_peer
) && !find
) {
11205 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
11207 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
11210 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
11211 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
11212 vty_out(vty
, "%% No BGP neighbors found\n");
11215 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11216 json
, JSON_C_TO_STRING_PRETTY
));
11218 vty_out(vty
, "\n");
11221 return CMD_SUCCESS
;
11224 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
11225 enum show_type type
,
11226 const char *ip_str
,
11229 struct listnode
*node
, *nnode
;
11231 union sockunion su
;
11232 json_object
*json
= NULL
;
11233 int ret
, is_first
= 1;
11234 bool nbr_output
= false;
11237 vty_out(vty
, "{\n");
11239 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11242 if (!(json
= json_object_new_object())) {
11244 EC_BGP_JSON_MEM_ERROR
,
11245 "Unable to allocate memory for JSON object");
11247 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
11251 json_object_int_add(json
, "vrfId",
11252 (bgp
->vrf_id
== VRF_UNKNOWN
)
11254 : (int64_t)bgp
->vrf_id
);
11255 json_object_string_add(
11257 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11262 vty_out(vty
, ",\n");
11266 vty_out(vty
, "\"%s\":",
11267 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11271 vty_out(vty
, "\nInstance %s:\n",
11272 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11277 if (type
== show_peer
|| type
== show_ipv4_peer
||
11278 type
== show_ipv6_peer
) {
11279 ret
= str2sockunion(ip_str
, &su
);
11281 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11284 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11287 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
11290 json_object_free(json
);
11294 vty_out(vty
, "}\n");
11295 json_object_free(json
);
11297 else if (!nbr_output
)
11298 vty_out(vty
, "%% BGP instance not found\n");
11301 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
11302 enum show_type type
, const char *ip_str
,
11307 union sockunion su
;
11308 json_object
*json
= NULL
;
11311 if (strmatch(name
, "all")) {
11312 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
11314 return CMD_SUCCESS
;
11316 bgp
= bgp_lookup_by_name(name
);
11319 json
= json_object_new_object();
11320 vty_out(vty
, "%s\n",
11321 json_object_to_json_string_ext(
11323 JSON_C_TO_STRING_PRETTY
));
11324 json_object_free(json
);
11327 "%% BGP instance not found\n");
11329 return CMD_WARNING
;
11333 bgp
= bgp_get_default();
11337 json
= json_object_new_object();
11339 ret
= str2sockunion(ip_str
, &su
);
11341 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11344 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11347 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
11350 json_object_free(json
);
11353 vty_out(vty
, "{}\n");
11355 vty_out(vty
, "%% BGP instance not found\n");
11358 return CMD_SUCCESS
;
11361 /* "show [ip] bgp neighbors" commands. */
11362 DEFUN (show_ip_bgp_neighbors
,
11363 show_ip_bgp_neighbors_cmd
,
11364 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
11368 BGP_INSTANCE_HELP_STR
11371 "Detailed information on TCP and BGP neighbor connections\n"
11372 "Neighbor to display information about\n"
11373 "Neighbor to display information about\n"
11374 "Neighbor on BGP configured interface\n"
11378 char *sh_arg
= NULL
;
11379 enum show_type sh_type
;
11380 afi_t afi
= AFI_MAX
;
11382 bool uj
= use_json(argc
, argv
);
11386 /* [<vrf> VIEWVRFNAME] */
11387 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11388 vrf
= argv
[idx
+ 1]->arg
;
11389 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11391 } else if (argv_find(argv
, argc
, "view", &idx
))
11392 /* [<view> VIEWVRFNAME] */
11393 vrf
= argv
[idx
+ 1]->arg
;
11397 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
11398 sh_type
= show_ipv4_all
;
11400 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
11401 sh_type
= show_ipv6_all
;
11404 sh_type
= show_all
;
11407 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
11408 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
11409 || argv_find(argv
, argc
, "WORD", &idx
)) {
11410 sh_type
= show_peer
;
11411 sh_arg
= argv
[idx
]->arg
;
11414 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
11415 sh_type
= show_ipv4_peer
;
11416 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
11417 sh_type
= show_ipv6_peer
;
11420 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
11423 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
11424 paths' and `show ip mbgp paths'. Those functions results are the
11426 DEFUN (show_ip_bgp_paths
,
11427 show_ip_bgp_paths_cmd
,
11428 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
11433 "Path information\n")
11435 vty_out(vty
, "Address Refcnt Path\n");
11436 aspath_print_all_vty(vty
);
11437 return CMD_SUCCESS
;
11442 static void community_show_all_iterator(struct hash_bucket
*bucket
,
11445 struct community
*com
;
11447 com
= (struct community
*)bucket
->data
;
11448 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
11449 community_str(com
, false));
11452 /* Show BGP's community internal data. */
11453 DEFUN (show_ip_bgp_community_info
,
11454 show_ip_bgp_community_info_cmd
,
11455 "show [ip] bgp community-info",
11459 "List all bgp community information\n")
11461 vty_out(vty
, "Address Refcnt Community\n");
11463 hash_iterate(community_hash(),
11464 (void (*)(struct hash_bucket
*,
11465 void *))community_show_all_iterator
,
11468 return CMD_SUCCESS
;
11471 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
11474 struct lcommunity
*lcom
;
11476 lcom
= (struct lcommunity
*)bucket
->data
;
11477 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11478 lcommunity_str(lcom
, false));
11481 /* Show BGP's community internal data. */
11482 DEFUN (show_ip_bgp_lcommunity_info
,
11483 show_ip_bgp_lcommunity_info_cmd
,
11484 "show ip bgp large-community-info",
11488 "List all bgp large-community information\n")
11490 vty_out(vty
, "Address Refcnt Large-community\n");
11492 hash_iterate(lcommunity_hash(),
11493 (void (*)(struct hash_bucket
*,
11494 void *))lcommunity_show_all_iterator
,
11497 return CMD_SUCCESS
;
11501 DEFUN (show_ip_bgp_attr_info
,
11502 show_ip_bgp_attr_info_cmd
,
11503 "show [ip] bgp attribute-info",
11507 "List all bgp attribute information\n")
11509 attr_show_all(vty
);
11510 return CMD_SUCCESS
;
11513 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
11514 afi_t afi
, safi_t safi
,
11515 bool use_json
, json_object
*json
)
11518 struct listnode
*node
;
11520 char buf1
[INET6_ADDRSTRLEN
];
11522 vpn_policy_direction_t dir
;
11525 json_object
*json_import_vrfs
= NULL
;
11526 json_object
*json_export_vrfs
= NULL
;
11528 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11531 vty_out(vty
, "%s\n",
11532 json_object_to_json_string_ext(
11534 JSON_C_TO_STRING_PRETTY
));
11535 json_object_free(json
);
11537 return CMD_WARNING
;
11540 /* Provide context for the block */
11541 json_object_string_add(json
, "vrf", name
? name
: "default");
11542 json_object_string_add(json
, "afiSafi",
11543 get_afi_safi_str(afi
, safi
, true));
11545 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11546 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11547 json_object_string_add(json
, "importFromVrfs", "none");
11548 json_object_string_add(json
, "importRts", "none");
11550 json_import_vrfs
= json_object_new_array();
11552 for (ALL_LIST_ELEMENTS_RO(
11553 bgp
->vpn_policy
[afi
].import_vrf
,
11555 json_object_array_add(json_import_vrfs
,
11556 json_object_new_string(vname
));
11558 json_object_object_add(json
, "importFromVrfs",
11560 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11561 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11562 ecom_str
= ecommunity_ecom2str(
11563 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11564 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11565 json_object_string_add(json
, "importRts",
11567 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11569 json_object_string_add(json
, "importRts",
11573 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11574 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11575 json_object_string_add(json
, "exportToVrfs", "none");
11576 json_object_string_add(json
, "routeDistinguisher",
11578 json_object_string_add(json
, "exportRts", "none");
11580 json_export_vrfs
= json_object_new_array();
11582 for (ALL_LIST_ELEMENTS_RO(
11583 bgp
->vpn_policy
[afi
].export_vrf
,
11585 json_object_array_add(json_export_vrfs
,
11586 json_object_new_string(vname
));
11587 json_object_object_add(json
, "exportToVrfs",
11589 json_object_string_add(json
, "routeDistinguisher",
11590 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11591 buf1
, RD_ADDRSTRLEN
));
11593 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11594 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11595 ecom_str
= ecommunity_ecom2str(
11596 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11597 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11598 json_object_string_add(json
, "exportRts",
11600 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11602 json_object_string_add(json
, "exportRts",
11607 vty_out(vty
, "%s\n",
11608 json_object_to_json_string_ext(json
,
11609 JSON_C_TO_STRING_PRETTY
));
11610 json_object_free(json
);
11613 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11616 vty_out(vty
, "%% No such BGP instance exist\n");
11617 return CMD_WARNING
;
11620 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11621 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11623 "This VRF is not importing %s routes from any other VRF\n",
11624 get_afi_safi_str(afi
, safi
, false));
11627 "This VRF is importing %s routes from the following VRFs:\n",
11628 get_afi_safi_str(afi
, safi
, false));
11630 for (ALL_LIST_ELEMENTS_RO(
11631 bgp
->vpn_policy
[afi
].import_vrf
,
11633 vty_out(vty
, " %s\n", vname
);
11635 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11637 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11638 ecom_str
= ecommunity_ecom2str(
11639 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11640 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11641 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11643 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11645 vty_out(vty
, "Import RT(s):\n");
11648 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11649 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11651 "This VRF is not exporting %s routes to any other VRF\n",
11652 get_afi_safi_str(afi
, safi
, false));
11655 "This VRF is exporting %s routes to the following VRFs:\n",
11656 get_afi_safi_str(afi
, safi
, false));
11658 for (ALL_LIST_ELEMENTS_RO(
11659 bgp
->vpn_policy
[afi
].export_vrf
,
11661 vty_out(vty
, " %s\n", vname
);
11663 vty_out(vty
, "RD: %s\n",
11664 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11665 buf1
, RD_ADDRSTRLEN
));
11667 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11668 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11669 ecom_str
= ecommunity_ecom2str(
11670 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11671 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11672 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11673 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11675 vty_out(vty
, "Import RT(s):\n");
11679 return CMD_SUCCESS
;
11682 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
11683 safi_t safi
, bool use_json
)
11685 struct listnode
*node
, *nnode
;
11687 char *vrf_name
= NULL
;
11688 json_object
*json
= NULL
;
11689 json_object
*json_vrf
= NULL
;
11690 json_object
*json_vrfs
= NULL
;
11693 json
= json_object_new_object();
11694 json_vrfs
= json_object_new_object();
11697 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11699 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
11700 vrf_name
= bgp
->name
;
11703 json_vrf
= json_object_new_object();
11705 vty_out(vty
, "\nInstance %s:\n",
11706 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11707 ? VRF_DEFAULT_NAME
: bgp
->name
);
11709 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
11711 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11712 json_object_object_add(json_vrfs
,
11713 VRF_DEFAULT_NAME
, json_vrf
);
11715 json_object_object_add(json_vrfs
, vrf_name
,
11721 json_object_object_add(json
, "vrfs", json_vrfs
);
11722 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
11723 JSON_C_TO_STRING_PRETTY
));
11724 json_object_free(json
);
11727 return CMD_SUCCESS
;
11730 /* "show [ip] bgp route-leak" command. */
11731 DEFUN (show_ip_bgp_route_leak
,
11732 show_ip_bgp_route_leak_cmd
,
11733 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11737 BGP_INSTANCE_HELP_STR
11740 "Route leaking information\n"
11744 afi_t afi
= AFI_MAX
;
11745 safi_t safi
= SAFI_MAX
;
11747 bool uj
= use_json(argc
, argv
);
11749 json_object
*json
= NULL
;
11751 /* show [ip] bgp */
11752 if (argv_find(argv
, argc
, "ip", &idx
)) {
11754 safi
= SAFI_UNICAST
;
11756 /* [vrf VIEWVRFNAME] */
11757 if (argv_find(argv
, argc
, "view", &idx
)) {
11759 "%% This command is not applicable to BGP views\n");
11760 return CMD_WARNING
;
11763 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11764 vrf
= argv
[idx
+ 1]->arg
;
11765 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11768 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11769 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11770 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11773 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11775 "%% This command is applicable only for unicast ipv4|ipv6\n");
11776 return CMD_WARNING
;
11779 if (vrf
&& strmatch(vrf
, "all"))
11780 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
11783 json
= json_object_new_object();
11785 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
11788 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11791 struct listnode
*node
, *nnode
;
11794 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11795 vty_out(vty
, "\nInstance %s:\n",
11796 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11799 update_group_show(bgp
, afi
, safi
, vty
, 0);
11803 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11804 int safi
, uint64_t subgrp_id
)
11809 if (strmatch(name
, "all")) {
11810 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11811 return CMD_SUCCESS
;
11813 bgp
= bgp_lookup_by_name(name
);
11816 bgp
= bgp_get_default();
11820 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11821 return CMD_SUCCESS
;
11824 DEFUN (show_ip_bgp_updgrps
,
11825 show_ip_bgp_updgrps_cmd
,
11826 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11830 BGP_INSTANCE_HELP_STR
11832 BGP_SAFI_WITH_LABEL_HELP_STR
11833 "Detailed info about dynamic update groups\n"
11834 "Specific subgroup to display detailed info for\n")
11837 afi_t afi
= AFI_IP6
;
11838 safi_t safi
= SAFI_UNICAST
;
11839 uint64_t subgrp_id
= 0;
11843 /* show [ip] bgp */
11844 if (argv_find(argv
, argc
, "ip", &idx
))
11846 /* [<vrf> VIEWVRFNAME] */
11847 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11848 vrf
= argv
[idx
+ 1]->arg
;
11849 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11851 } else if (argv_find(argv
, argc
, "view", &idx
))
11852 /* [<view> VIEWVRFNAME] */
11853 vrf
= argv
[idx
+ 1]->arg
;
11854 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11855 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11856 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11859 /* get subgroup id, if provided */
11861 if (argv
[idx
]->type
== VARIABLE_TKN
)
11862 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11864 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11867 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11868 show_bgp_instance_all_ipv6_updgrps_cmd
,
11869 "show [ip] bgp <view|vrf> all update-groups",
11873 BGP_INSTANCE_ALL_HELP_STR
11874 "Detailed info about dynamic update groups\n")
11876 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11877 return CMD_SUCCESS
;
11880 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
11881 show_bgp_l2vpn_evpn_updgrps_cmd
,
11882 "show [ip] bgp l2vpn evpn update-groups",
11886 "l2vpn address family\n"
11887 "evpn sub-address family\n"
11888 "Detailed info about dynamic update groups\n")
11891 uint64_t subgrp_id
= 0;
11893 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
11894 return CMD_SUCCESS
;
11897 DEFUN (show_bgp_updgrps_stats
,
11898 show_bgp_updgrps_stats_cmd
,
11899 "show [ip] bgp update-groups statistics",
11903 "Detailed info about dynamic update groups\n"
11908 bgp
= bgp_get_default();
11910 update_group_show_stats(bgp
, vty
);
11912 return CMD_SUCCESS
;
11915 DEFUN (show_bgp_instance_updgrps_stats
,
11916 show_bgp_instance_updgrps_stats_cmd
,
11917 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11921 BGP_INSTANCE_HELP_STR
11922 "Detailed info about dynamic update groups\n"
11928 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11930 update_group_show_stats(bgp
, vty
);
11932 return CMD_SUCCESS
;
11935 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11936 afi_t afi
, safi_t safi
,
11937 const char *what
, uint64_t subgrp_id
)
11942 bgp
= bgp_lookup_by_name(name
);
11944 bgp
= bgp_get_default();
11947 if (!strcmp(what
, "advertise-queue"))
11948 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11950 else if (!strcmp(what
, "advertised-routes"))
11951 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11953 else if (!strcmp(what
, "packet-queue"))
11954 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11959 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11960 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11961 "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",
11962 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11964 "Detailed info about dynamic update groups\n"
11965 "Specific subgroup to display info for\n"
11966 "Advertisement queue\n"
11967 "Announced routes\n"
11970 uint64_t subgrp_id
= 0;
11974 subgrp_id
= strtoull(sgid
, NULL
, 10);
11979 afiz
= bgp_vty_afi_from_str(afi
);
11983 afiz
= bgp_vty_afi_from_str(afi
);
11984 if (afiz
!= AFI_IP
)
11986 "%% Cannot specify both 'ip' and 'ipv6'\n");
11987 return CMD_WARNING
;
11990 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11992 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11993 return CMD_SUCCESS
;
11996 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11998 struct listnode
*node
, *nnode
;
11999 struct prefix
*range
;
12002 char buf
[PREFIX2STR_BUFFER
];
12005 const char *peer_status
;
12006 const char *af_str
;
12011 conf
= group
->conf
;
12013 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
12014 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
12015 group
->name
, conf
->as
);
12016 } else if (conf
->as_type
== AS_INTERNAL
) {
12017 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
12018 group
->name
, group
->bgp
->as
);
12020 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
12023 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
12024 vty_out(vty
, " Peer-group type is internal\n");
12026 vty_out(vty
, " Peer-group type is external\n");
12028 /* Display AFs configured. */
12029 vty_out(vty
, " Configured address-families:");
12030 FOREACH_AFI_SAFI (afi
, safi
) {
12031 if (conf
->afc
[afi
][safi
]) {
12033 vty_out(vty
, " %s;", get_afi_safi_str(afi
, safi
, false));
12037 vty_out(vty
, " none\n");
12039 vty_out(vty
, "\n");
12041 /* Display listen ranges (for dynamic neighbors), if any */
12042 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
12045 else if (afi
== AFI_IP6
)
12049 lr_count
= listcount(group
->listen_range
[afi
]);
12051 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
12055 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
12057 prefix2str(range
, buf
, sizeof(buf
));
12058 vty_out(vty
, " %s\n", buf
);
12063 /* Display group members and their status */
12064 if (listcount(group
->peer
)) {
12065 vty_out(vty
, " Peer-group members:\n");
12066 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
12067 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
12068 peer_status
= "Idle (Admin)";
12069 else if (CHECK_FLAG(peer
->sflags
,
12070 PEER_STATUS_PREFIX_OVERFLOW
))
12071 peer_status
= "Idle (PfxCt)";
12073 peer_status
= lookup_msg(bgp_status_msg
,
12074 peer
->status
, NULL
);
12076 dynamic
= peer_dynamic_neighbor(peer
);
12077 vty_out(vty
, " %s %s %s \n", peer
->host
,
12078 dynamic
? "(dynamic)" : "", peer_status
);
12082 return CMD_SUCCESS
;
12085 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
12086 const char *group_name
)
12089 struct listnode
*node
, *nnode
;
12090 struct peer_group
*group
;
12091 bool found
= false;
12093 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
12096 vty_out(vty
, "%% BGP instance not found\n");
12097 return CMD_WARNING
;
12100 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
12102 if (strmatch(group
->name
, group_name
)) {
12103 bgp_show_one_peer_group(vty
, group
);
12108 bgp_show_one_peer_group(vty
, group
);
12112 if (group_name
&& !found
)
12113 vty_out(vty
, "%% No such peer-group\n");
12115 return CMD_SUCCESS
;
12118 DEFUN (show_ip_bgp_peer_groups
,
12119 show_ip_bgp_peer_groups_cmd
,
12120 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
12124 BGP_INSTANCE_HELP_STR
12125 "Detailed information on BGP peer groups\n"
12126 "Peer group name\n")
12131 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
12133 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
12135 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
12139 /* Redistribute VTY commands. */
12141 DEFUN (bgp_redistribute_ipv4
,
12142 bgp_redistribute_ipv4_cmd
,
12143 "redistribute " FRR_IP_REDIST_STR_BGPD
,
12144 "Redistribute information from another routing protocol\n"
12145 FRR_IP_REDIST_HELP_STR_BGPD
)
12147 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12148 int idx_protocol
= 1;
12151 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12153 vty_out(vty
, "%% Invalid route type\n");
12154 return CMD_WARNING_CONFIG_FAILED
;
12157 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12158 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
12162 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
12163 "redistribute " FRR_IP_REDIST_STR_BGPD
,
12164 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
12166 DEFUN (bgp_redistribute_ipv4_rmap
,
12167 bgp_redistribute_ipv4_rmap_cmd
,
12168 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
12169 "Redistribute information from another routing protocol\n"
12170 FRR_IP_REDIST_HELP_STR_BGPD
12171 "Route map reference\n"
12172 "Pointer to route-map entries\n")
12174 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12175 int idx_protocol
= 1;
12178 struct bgp_redist
*red
;
12180 struct route_map
*route_map
= route_map_lookup_warn_noexist(
12181 vty
, argv
[idx_word
]->arg
);
12183 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12185 vty_out(vty
, "%% Invalid route type\n");
12186 return CMD_WARNING_CONFIG_FAILED
;
12189 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12191 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12192 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12196 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
12197 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
12198 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12199 "Route map reference\n"
12200 "Pointer to route-map entries\n")
12202 DEFUN (bgp_redistribute_ipv4_metric
,
12203 bgp_redistribute_ipv4_metric_cmd
,
12204 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12205 "Redistribute information from another routing protocol\n"
12206 FRR_IP_REDIST_HELP_STR_BGPD
12207 "Metric for redistributed routes\n"
12208 "Default metric\n")
12210 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12211 int idx_protocol
= 1;
12212 int idx_number
= 3;
12215 struct bgp_redist
*red
;
12218 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12220 vty_out(vty
, "%% Invalid route type\n");
12221 return CMD_WARNING_CONFIG_FAILED
;
12223 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12225 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
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_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
12232 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12233 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12234 "Metric for redistributed routes\n"
12235 "Default metric\n")
12237 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
12238 bgp_redistribute_ipv4_rmap_metric_cmd
,
12239 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12240 "Redistribute information from another routing protocol\n"
12241 FRR_IP_REDIST_HELP_STR_BGPD
12242 "Route map reference\n"
12243 "Pointer to route-map entries\n"
12244 "Metric for redistributed routes\n"
12245 "Default metric\n")
12247 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12248 int idx_protocol
= 1;
12250 int idx_number
= 5;
12253 struct bgp_redist
*red
;
12255 struct route_map
*route_map
=
12256 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12258 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12260 vty_out(vty
, "%% Invalid route type\n");
12261 return CMD_WARNING_CONFIG_FAILED
;
12263 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12265 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12267 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12268 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12269 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12273 bgp_redistribute_ipv4_rmap_metric
,
12274 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
12275 "redistribute " FRR_IP_REDIST_STR_BGPD
12276 " route-map WORD metric (0-4294967295)",
12277 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12278 "Route map reference\n"
12279 "Pointer to route-map entries\n"
12280 "Metric for redistributed routes\n"
12281 "Default metric\n")
12283 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
12284 bgp_redistribute_ipv4_metric_rmap_cmd
,
12285 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12286 "Redistribute information from another routing protocol\n"
12287 FRR_IP_REDIST_HELP_STR_BGPD
12288 "Metric for redistributed routes\n"
12290 "Route map reference\n"
12291 "Pointer to route-map entries\n")
12293 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12294 int idx_protocol
= 1;
12295 int idx_number
= 3;
12299 struct bgp_redist
*red
;
12301 struct route_map
*route_map
=
12302 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12304 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12306 vty_out(vty
, "%% Invalid route type\n");
12307 return CMD_WARNING_CONFIG_FAILED
;
12309 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12311 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12312 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12314 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12315 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12319 bgp_redistribute_ipv4_metric_rmap
,
12320 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
12321 "redistribute " FRR_IP_REDIST_STR_BGPD
12322 " metric (0-4294967295) route-map WORD",
12323 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12324 "Metric for redistributed routes\n"
12326 "Route map reference\n"
12327 "Pointer to route-map entries\n")
12329 DEFUN (bgp_redistribute_ipv4_ospf
,
12330 bgp_redistribute_ipv4_ospf_cmd
,
12331 "redistribute <ospf|table> (1-65535)",
12332 "Redistribute information from another routing protocol\n"
12333 "Open Shortest Path First (OSPFv2)\n"
12334 "Non-main Kernel Routing Table\n"
12335 "Instance ID/Table ID\n")
12337 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12338 int idx_ospf_table
= 1;
12339 int idx_number
= 2;
12340 unsigned short instance
;
12341 unsigned short protocol
;
12343 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12345 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12346 protocol
= ZEBRA_ROUTE_OSPF
;
12348 protocol
= ZEBRA_ROUTE_TABLE
;
12350 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12351 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
12354 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
12355 "redistribute <ospf|table> (1-65535)",
12356 "Redistribute information from another routing protocol\n"
12357 "Open Shortest Path First (OSPFv2)\n"
12358 "Non-main Kernel Routing Table\n"
12359 "Instance ID/Table ID\n")
12361 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
12362 bgp_redistribute_ipv4_ospf_rmap_cmd
,
12363 "redistribute <ospf|table> (1-65535) route-map WORD",
12364 "Redistribute information from another routing protocol\n"
12365 "Open Shortest Path First (OSPFv2)\n"
12366 "Non-main Kernel Routing Table\n"
12367 "Instance ID/Table ID\n"
12368 "Route map reference\n"
12369 "Pointer to route-map entries\n")
12371 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12372 int idx_ospf_table
= 1;
12373 int idx_number
= 2;
12375 struct bgp_redist
*red
;
12376 unsigned short instance
;
12379 struct route_map
*route_map
=
12380 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
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 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12390 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12391 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12394 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
12395 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
12396 "redistribute <ospf|table> (1-65535) route-map WORD",
12397 "Redistribute information from another routing protocol\n"
12398 "Open Shortest Path First (OSPFv2)\n"
12399 "Non-main Kernel Routing Table\n"
12400 "Instance ID/Table ID\n"
12401 "Route map reference\n"
12402 "Pointer to route-map entries\n")
12404 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
12405 bgp_redistribute_ipv4_ospf_metric_cmd
,
12406 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12407 "Redistribute information from another routing protocol\n"
12408 "Open Shortest Path First (OSPFv2)\n"
12409 "Non-main Kernel Routing Table\n"
12410 "Instance ID/Table ID\n"
12411 "Metric for redistributed routes\n"
12412 "Default metric\n")
12414 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12415 int idx_ospf_table
= 1;
12416 int idx_number
= 2;
12417 int idx_number_2
= 4;
12419 struct bgp_redist
*red
;
12420 unsigned short instance
;
12424 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12425 protocol
= ZEBRA_ROUTE_OSPF
;
12427 protocol
= ZEBRA_ROUTE_TABLE
;
12429 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12430 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12432 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12433 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12435 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12438 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
12439 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
12440 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12441 "Redistribute information from another routing protocol\n"
12442 "Open Shortest Path First (OSPFv2)\n"
12443 "Non-main Kernel Routing Table\n"
12444 "Instance ID/Table ID\n"
12445 "Metric for redistributed routes\n"
12446 "Default metric\n")
12448 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
12449 bgp_redistribute_ipv4_ospf_rmap_metric_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 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12461 int idx_ospf_table
= 1;
12462 int idx_number
= 2;
12464 int idx_number_2
= 6;
12466 struct bgp_redist
*red
;
12467 unsigned short instance
;
12470 struct route_map
*route_map
=
12471 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12473 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12474 protocol
= ZEBRA_ROUTE_OSPF
;
12476 protocol
= ZEBRA_ROUTE_TABLE
;
12478 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12479 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12481 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12483 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12484 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12486 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12490 bgp_redistribute_ipv4_ospf_rmap_metric
,
12491 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
12492 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12493 "Redistribute information from another routing protocol\n"
12494 "Open Shortest Path First (OSPFv2)\n"
12495 "Non-main Kernel Routing Table\n"
12496 "Instance ID/Table ID\n"
12497 "Route map reference\n"
12498 "Pointer to route-map entries\n"
12499 "Metric for redistributed routes\n"
12500 "Default metric\n")
12502 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
12503 bgp_redistribute_ipv4_ospf_metric_rmap_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 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12515 int idx_ospf_table
= 1;
12516 int idx_number
= 2;
12517 int idx_number_2
= 4;
12520 struct bgp_redist
*red
;
12521 unsigned short instance
;
12524 struct route_map
*route_map
=
12525 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12527 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12528 protocol
= ZEBRA_ROUTE_OSPF
;
12530 protocol
= ZEBRA_ROUTE_TABLE
;
12532 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12533 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12535 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12536 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12539 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12540 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12544 bgp_redistribute_ipv4_ospf_metric_rmap
,
12545 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
12546 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12547 "Redistribute information from another routing protocol\n"
12548 "Open Shortest Path First (OSPFv2)\n"
12549 "Non-main Kernel Routing Table\n"
12550 "Instance ID/Table ID\n"
12551 "Metric for redistributed routes\n"
12553 "Route map reference\n"
12554 "Pointer to route-map entries\n")
12556 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12557 no_bgp_redistribute_ipv4_ospf_cmd
,
12558 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
12560 "Redistribute information from another routing protocol\n"
12561 "Open Shortest Path First (OSPFv2)\n"
12562 "Non-main Kernel Routing Table\n"
12563 "Instance ID/Table ID\n"
12564 "Metric for redistributed routes\n"
12566 "Route map reference\n"
12567 "Pointer to route-map entries\n")
12569 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12570 int idx_ospf_table
= 2;
12571 int idx_number
= 3;
12572 unsigned short instance
;
12575 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12576 protocol
= ZEBRA_ROUTE_OSPF
;
12578 protocol
= ZEBRA_ROUTE_TABLE
;
12580 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12581 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12585 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12586 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
12588 "Redistribute information from another routing protocol\n"
12589 "Open Shortest Path First (OSPFv2)\n"
12590 "Non-main Kernel Routing Table\n"
12591 "Instance ID/Table ID\n"
12592 "Metric for redistributed routes\n"
12594 "Route map reference\n"
12595 "Pointer to route-map entries\n")
12597 DEFUN (no_bgp_redistribute_ipv4
,
12598 no_bgp_redistribute_ipv4_cmd
,
12599 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
12601 "Redistribute information from another routing protocol\n"
12602 FRR_IP_REDIST_HELP_STR_BGPD
12603 "Metric for redistributed routes\n"
12605 "Route map reference\n"
12606 "Pointer to route-map entries\n")
12608 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12609 int idx_protocol
= 2;
12612 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12614 vty_out(vty
, "%% Invalid route type\n");
12615 return CMD_WARNING_CONFIG_FAILED
;
12617 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12621 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12622 "no redistribute " FRR_IP_REDIST_STR_BGPD
12623 " [{metric (0-4294967295)|route-map WORD}]",
12625 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12626 "Metric for redistributed routes\n"
12628 "Route map reference\n"
12629 "Pointer to route-map entries\n")
12631 DEFUN (bgp_redistribute_ipv6
,
12632 bgp_redistribute_ipv6_cmd
,
12633 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12634 "Redistribute information from another routing protocol\n"
12635 FRR_IP6_REDIST_HELP_STR_BGPD
)
12637 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12638 int idx_protocol
= 1;
12641 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12643 vty_out(vty
, "%% Invalid route type\n");
12644 return CMD_WARNING_CONFIG_FAILED
;
12647 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12648 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12651 DEFUN (bgp_redistribute_ipv6_rmap
,
12652 bgp_redistribute_ipv6_rmap_cmd
,
12653 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12654 "Redistribute information from another routing protocol\n"
12655 FRR_IP6_REDIST_HELP_STR_BGPD
12656 "Route map reference\n"
12657 "Pointer to route-map entries\n")
12659 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12660 int idx_protocol
= 1;
12663 struct bgp_redist
*red
;
12665 struct route_map
*route_map
=
12666 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12668 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12670 vty_out(vty
, "%% Invalid route type\n");
12671 return CMD_WARNING_CONFIG_FAILED
;
12674 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12676 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12677 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12680 DEFUN (bgp_redistribute_ipv6_metric
,
12681 bgp_redistribute_ipv6_metric_cmd
,
12682 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12683 "Redistribute information from another routing protocol\n"
12684 FRR_IP6_REDIST_HELP_STR_BGPD
12685 "Metric for redistributed routes\n"
12686 "Default metric\n")
12688 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12689 int idx_protocol
= 1;
12690 int idx_number
= 3;
12693 struct bgp_redist
*red
;
12696 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12698 vty_out(vty
, "%% Invalid route type\n");
12699 return CMD_WARNING_CONFIG_FAILED
;
12701 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12703 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12704 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12705 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12708 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12709 bgp_redistribute_ipv6_rmap_metric_cmd
,
12710 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12711 "Redistribute information from another routing protocol\n"
12712 FRR_IP6_REDIST_HELP_STR_BGPD
12713 "Route map reference\n"
12714 "Pointer to route-map entries\n"
12715 "Metric for redistributed routes\n"
12716 "Default metric\n")
12718 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12719 int idx_protocol
= 1;
12721 int idx_number
= 5;
12724 struct bgp_redist
*red
;
12726 struct route_map
*route_map
=
12727 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12729 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12731 vty_out(vty
, "%% Invalid route type\n");
12732 return CMD_WARNING_CONFIG_FAILED
;
12734 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12736 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12738 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12739 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12741 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12744 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12745 bgp_redistribute_ipv6_metric_rmap_cmd
,
12746 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12747 "Redistribute information from another routing protocol\n"
12748 FRR_IP6_REDIST_HELP_STR_BGPD
12749 "Metric for redistributed routes\n"
12751 "Route map reference\n"
12752 "Pointer to route-map entries\n")
12754 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12755 int idx_protocol
= 1;
12756 int idx_number
= 3;
12760 struct bgp_redist
*red
;
12762 struct route_map
*route_map
=
12763 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12765 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12767 vty_out(vty
, "%% Invalid route type\n");
12768 return CMD_WARNING_CONFIG_FAILED
;
12770 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12772 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12773 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12776 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12777 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12780 DEFUN (no_bgp_redistribute_ipv6
,
12781 no_bgp_redistribute_ipv6_cmd
,
12782 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
12784 "Redistribute information from another routing protocol\n"
12785 FRR_IP6_REDIST_HELP_STR_BGPD
12786 "Metric for redistributed routes\n"
12788 "Route map reference\n"
12789 "Pointer to route-map entries\n")
12791 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12792 int idx_protocol
= 2;
12795 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12797 vty_out(vty
, "%% Invalid route type\n");
12798 return CMD_WARNING_CONFIG_FAILED
;
12801 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12804 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12809 /* Unicast redistribution only. */
12810 if (safi
!= SAFI_UNICAST
)
12813 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12814 /* Redistribute BGP does not make sense. */
12815 if (i
!= ZEBRA_ROUTE_BGP
) {
12816 struct list
*red_list
;
12817 struct listnode
*node
;
12818 struct bgp_redist
*red
;
12820 red_list
= bgp
->redist
[afi
][i
];
12824 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12825 /* "redistribute" configuration. */
12826 vty_out(vty
, " redistribute %s",
12827 zebra_route_string(i
));
12829 vty_out(vty
, " %d", red
->instance
);
12830 if (red
->redist_metric_flag
)
12831 vty_out(vty
, " metric %u",
12832 red
->redist_metric
);
12833 if (red
->rmap
.name
)
12834 vty_out(vty
, " route-map %s",
12836 vty_out(vty
, "\n");
12842 /* This is part of the address-family block (unicast only) */
12843 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12848 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12849 if (listcount(bgp
->vpn_policy
[afi
].import_vrf
))
12850 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12851 bgp
->vpn_policy
[afi
]
12852 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12854 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
12855 bgp
->vpn_policy
[afi
]
12856 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12858 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12859 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12860 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12861 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12864 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12865 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12867 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12870 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12871 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12872 bgp
->vpn_policy
[afi
].tovpn_label
);
12875 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12876 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12877 char buf
[RD_ADDRSTRLEN
];
12878 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12879 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12882 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12883 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12885 char buf
[PREFIX_STRLEN
];
12886 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12887 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12890 vty_out(vty
, "%*snexthop vpn export %s\n",
12894 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12895 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12897 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12898 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12900 char *b
= ecommunity_ecom2str(
12901 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12902 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12903 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12904 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12906 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12907 char *b
= ecommunity_ecom2str(
12908 bgp
->vpn_policy
[afi
]
12909 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12910 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12911 ECOMMUNITY_ROUTE_TARGET
);
12912 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12913 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12915 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12916 char *b
= ecommunity_ecom2str(
12917 bgp
->vpn_policy
[afi
]
12918 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12919 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12920 ECOMMUNITY_ROUTE_TARGET
);
12921 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12922 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12926 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12927 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12928 bgp
->vpn_policy
[afi
]
12929 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12931 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12932 char *b
= ecommunity_ecom2str(
12933 bgp
->vpn_policy
[afi
]
12934 .import_redirect_rtlist
,
12935 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12936 ECOMMUNITY_ROUTE_TARGET
);
12938 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12939 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12944 /* BGP node structure. */
12945 static struct cmd_node bgp_node
= {
12946 BGP_NODE
, "%s(config-router)# ", 1,
12949 static struct cmd_node bgp_ipv4_unicast_node
= {
12950 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12953 static struct cmd_node bgp_ipv4_multicast_node
= {
12954 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12957 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12958 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12961 static struct cmd_node bgp_ipv6_unicast_node
= {
12962 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12965 static struct cmd_node bgp_ipv6_multicast_node
= {
12966 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12969 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12970 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12973 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12974 "%s(config-router-af)# ", 1};
12976 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12977 "%s(config-router-af-vpnv6)# ", 1};
12979 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12980 "%s(config-router-evpn)# ", 1};
12982 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12983 "%s(config-router-af-vni)# ", 1};
12985 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12986 "%s(config-router-af)# ", 1};
12988 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12989 "%s(config-router-af-vpnv6)# ", 1};
12991 static void community_list_vty(void);
12993 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12997 struct listnode
*lnbgp
, *lnpeer
;
12999 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
13000 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
13001 /* only provide suggestions on the appropriate input
13003 * they'll otherwise show up multiple times */
13004 enum cmd_token_type match_type
;
13005 char *name
= peer
->host
;
13007 if (peer
->conf_if
) {
13008 match_type
= VARIABLE_TKN
;
13009 name
= peer
->conf_if
;
13010 } else if (strchr(peer
->host
, ':'))
13011 match_type
= IPV6_TKN
;
13013 match_type
= IPV4_TKN
;
13015 if (token
->type
!= match_type
)
13018 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
13023 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
13024 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
13025 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
13026 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
13027 {.completions
= NULL
}};
13029 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
13032 struct peer_group
*group
;
13033 struct listnode
*lnbgp
, *lnpeer
;
13035 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
13036 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
13037 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
13042 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
13043 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
13044 {.completions
= NULL
} };
13046 void bgp_vty_init(void)
13048 cmd_variable_handler_register(bgp_var_neighbor
);
13049 cmd_variable_handler_register(bgp_var_peergroup
);
13051 /* Install bgp top node. */
13052 install_node(&bgp_node
, bgp_config_write
);
13053 install_node(&bgp_ipv4_unicast_node
, NULL
);
13054 install_node(&bgp_ipv4_multicast_node
, NULL
);
13055 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
13056 install_node(&bgp_ipv6_unicast_node
, NULL
);
13057 install_node(&bgp_ipv6_multicast_node
, NULL
);
13058 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
13059 install_node(&bgp_vpnv4_node
, NULL
);
13060 install_node(&bgp_vpnv6_node
, NULL
);
13061 install_node(&bgp_evpn_node
, NULL
);
13062 install_node(&bgp_evpn_vni_node
, NULL
);
13063 install_node(&bgp_flowspecv4_node
, NULL
);
13064 install_node(&bgp_flowspecv6_node
, NULL
);
13066 /* Install default VTY commands to new nodes. */
13067 install_default(BGP_NODE
);
13068 install_default(BGP_IPV4_NODE
);
13069 install_default(BGP_IPV4M_NODE
);
13070 install_default(BGP_IPV4L_NODE
);
13071 install_default(BGP_IPV6_NODE
);
13072 install_default(BGP_IPV6M_NODE
);
13073 install_default(BGP_IPV6L_NODE
);
13074 install_default(BGP_VPNV4_NODE
);
13075 install_default(BGP_VPNV6_NODE
);
13076 install_default(BGP_FLOWSPECV4_NODE
);
13077 install_default(BGP_FLOWSPECV6_NODE
);
13078 install_default(BGP_EVPN_NODE
);
13079 install_default(BGP_EVPN_VNI_NODE
);
13081 /* "bgp local-mac" hidden commands. */
13082 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
13083 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
13085 /* bgp route-map delay-timer commands. */
13086 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
13087 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
13089 /* Dummy commands (Currently not supported) */
13090 install_element(BGP_NODE
, &no_synchronization_cmd
);
13091 install_element(BGP_NODE
, &no_auto_summary_cmd
);
13093 /* "router bgp" commands. */
13094 install_element(CONFIG_NODE
, &router_bgp_cmd
);
13096 /* "no router bgp" commands. */
13097 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
13099 /* "bgp router-id" commands. */
13100 install_element(BGP_NODE
, &bgp_router_id_cmd
);
13101 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
13103 /* "bgp cluster-id" commands. */
13104 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
13105 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
13107 /* "bgp confederation" commands. */
13108 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
13109 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
13111 /* "bgp confederation peers" commands. */
13112 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
13113 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
13115 /* bgp max-med command */
13116 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
13117 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
13118 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
13119 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
13120 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
13122 /* bgp disable-ebgp-connected-nh-check */
13123 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
13124 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
13126 /* bgp update-delay command */
13127 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
13128 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
13129 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
13131 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
13132 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
13134 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
13135 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
13137 /* "maximum-paths" commands. */
13138 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
13139 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
13140 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
13141 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
13142 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
13143 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
13144 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
13145 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
13146 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
13147 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
13148 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
13149 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
13150 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
13151 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
13152 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
13154 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
13155 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
13156 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
13157 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
13158 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
13160 /* "timers bgp" commands. */
13161 install_element(BGP_NODE
, &bgp_timers_cmd
);
13162 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
13164 /* route-map delay-timer commands - per instance for backwards compat.
13166 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
13167 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
13169 /* "bgp client-to-client reflection" commands */
13170 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
13171 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
13173 /* "bgp always-compare-med" commands */
13174 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
13175 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
13177 /* bgp ebgp-requires-policy */
13178 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
13179 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
13181 /* bgp reject-as-sets */
13182 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
13183 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
13185 /* "bgp deterministic-med" commands */
13186 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
13187 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
13189 /* "bgp graceful-restart" commands */
13190 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
13191 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
13192 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
13193 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
13194 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
13195 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
13197 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
13198 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
13200 /* "bgp graceful-shutdown" commands */
13201 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
13202 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
13204 /* "bgp fast-external-failover" commands */
13205 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
13206 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
13208 /* "bgp bestpath compare-routerid" commands */
13209 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
13210 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
13212 /* "bgp bestpath as-path ignore" commands */
13213 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
13214 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
13216 /* "bgp bestpath as-path confed" commands */
13217 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
13218 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
13220 /* "bgp bestpath as-path multipath-relax" commands */
13221 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
13222 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
13224 /* "bgp log-neighbor-changes" commands */
13225 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
13226 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
13228 /* "bgp bestpath med" commands */
13229 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
13230 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
13232 /* "no bgp default ipv4-unicast" commands. */
13233 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
13234 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
13236 /* "bgp network import-check" commands. */
13237 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
13238 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
13239 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
13241 /* "bgp default local-preference" commands. */
13242 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
13243 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
13245 /* bgp default show-hostname */
13246 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
13247 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
13249 /* "bgp default subgroup-pkt-queue-max" commands. */
13250 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
13251 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
13253 /* bgp ibgp-allow-policy-mods command */
13254 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
13255 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
13257 /* "bgp listen limit" commands. */
13258 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
13259 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
13261 /* "bgp listen range" commands. */
13262 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
13263 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
13265 /* "bgp default shutdown" command */
13266 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
13268 /* "neighbor remote-as" commands. */
13269 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
13270 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
13271 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
13272 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
13273 install_element(BGP_NODE
,
13274 &neighbor_interface_v6only_config_remote_as_cmd
);
13275 install_element(BGP_NODE
, &no_neighbor_cmd
);
13276 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
13278 /* "neighbor peer-group" commands. */
13279 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
13280 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
13281 install_element(BGP_NODE
,
13282 &no_neighbor_interface_peer_group_remote_as_cmd
);
13284 /* "neighbor local-as" commands. */
13285 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
13286 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
13287 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
13288 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
13290 /* "neighbor solo" commands. */
13291 install_element(BGP_NODE
, &neighbor_solo_cmd
);
13292 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
13294 /* "neighbor password" commands. */
13295 install_element(BGP_NODE
, &neighbor_password_cmd
);
13296 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
13298 /* "neighbor activate" commands. */
13299 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
13300 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
13301 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
13302 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
13303 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
13304 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
13305 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
13306 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
13307 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
13308 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
13309 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
13310 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
13312 /* "no neighbor activate" commands. */
13313 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
13314 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
13315 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
13316 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
13317 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
13318 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
13319 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
13320 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
13321 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
13322 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
13323 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
13324 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
13326 /* "neighbor peer-group" set commands. */
13327 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
13328 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13329 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13330 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13331 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13332 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13333 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13334 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13335 install_element(BGP_FLOWSPECV4_NODE
,
13336 &neighbor_set_peer_group_hidden_cmd
);
13337 install_element(BGP_FLOWSPECV6_NODE
,
13338 &neighbor_set_peer_group_hidden_cmd
);
13340 /* "no neighbor peer-group unset" commands. */
13341 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
13342 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13343 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13344 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13345 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13346 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13347 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13348 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13349 install_element(BGP_FLOWSPECV4_NODE
,
13350 &no_neighbor_set_peer_group_hidden_cmd
);
13351 install_element(BGP_FLOWSPECV6_NODE
,
13352 &no_neighbor_set_peer_group_hidden_cmd
);
13354 /* "neighbor softreconfiguration inbound" commands.*/
13355 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
13356 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
13357 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13358 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13359 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13360 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13361 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13362 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13363 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13364 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13365 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13366 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13367 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13368 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13369 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13370 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13371 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13372 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13373 install_element(BGP_FLOWSPECV4_NODE
,
13374 &neighbor_soft_reconfiguration_cmd
);
13375 install_element(BGP_FLOWSPECV4_NODE
,
13376 &no_neighbor_soft_reconfiguration_cmd
);
13377 install_element(BGP_FLOWSPECV6_NODE
,
13378 &neighbor_soft_reconfiguration_cmd
);
13379 install_element(BGP_FLOWSPECV6_NODE
,
13380 &no_neighbor_soft_reconfiguration_cmd
);
13381 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
13382 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13384 /* "neighbor attribute-unchanged" commands. */
13385 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
13386 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
13387 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
13388 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13389 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
13390 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13391 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
13392 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13393 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
13394 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13395 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
13396 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13397 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
13398 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13399 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
13400 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13401 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
13402 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13404 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
13405 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
13407 /* "nexthop-local unchanged" commands */
13408 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
13409 install_element(BGP_IPV6_NODE
,
13410 &no_neighbor_nexthop_local_unchanged_cmd
);
13412 /* "neighbor next-hop-self" commands. */
13413 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
13414 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
13415 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
13416 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13417 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
13418 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
13419 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
13420 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
13421 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
13422 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13423 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
13424 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
13425 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
13426 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
13427 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
13428 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13429 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
13430 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13431 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
13432 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
13434 /* "neighbor next-hop-self force" commands. */
13435 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
13436 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
13437 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13438 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
13439 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13440 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13441 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13442 install_element(BGP_IPV4_NODE
,
13443 &no_neighbor_nexthop_self_all_hidden_cmd
);
13444 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
13445 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13446 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13447 install_element(BGP_IPV4M_NODE
,
13448 &no_neighbor_nexthop_self_all_hidden_cmd
);
13449 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
13450 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13451 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13452 install_element(BGP_IPV4L_NODE
,
13453 &no_neighbor_nexthop_self_all_hidden_cmd
);
13454 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13455 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13456 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13457 install_element(BGP_IPV6_NODE
,
13458 &no_neighbor_nexthop_self_all_hidden_cmd
);
13459 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
13460 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13461 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13462 install_element(BGP_IPV6M_NODE
,
13463 &no_neighbor_nexthop_self_all_hidden_cmd
);
13464 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
13465 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13466 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13467 install_element(BGP_IPV6L_NODE
,
13468 &no_neighbor_nexthop_self_all_hidden_cmd
);
13469 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13470 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13471 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13472 install_element(BGP_VPNV4_NODE
,
13473 &no_neighbor_nexthop_self_all_hidden_cmd
);
13474 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13475 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13476 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13477 install_element(BGP_VPNV6_NODE
,
13478 &no_neighbor_nexthop_self_all_hidden_cmd
);
13480 /* "neighbor as-override" commands. */
13481 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
13482 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
13483 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
13484 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
13485 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
13486 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
13487 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
13488 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
13489 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
13490 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
13491 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
13492 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
13493 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
13494 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
13495 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
13496 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
13497 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
13498 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
13500 /* "neighbor remove-private-AS" commands. */
13501 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
13502 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
13503 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
13504 install_element(BGP_NODE
,
13505 &no_neighbor_remove_private_as_all_hidden_cmd
);
13506 install_element(BGP_NODE
,
13507 &neighbor_remove_private_as_replace_as_hidden_cmd
);
13508 install_element(BGP_NODE
,
13509 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
13510 install_element(BGP_NODE
,
13511 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13514 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13515 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
13516 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13517 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13518 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13519 install_element(BGP_IPV4_NODE
,
13520 &neighbor_remove_private_as_replace_as_cmd
);
13521 install_element(BGP_IPV4_NODE
,
13522 &no_neighbor_remove_private_as_replace_as_cmd
);
13523 install_element(BGP_IPV4_NODE
,
13524 &neighbor_remove_private_as_all_replace_as_cmd
);
13525 install_element(BGP_IPV4_NODE
,
13526 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13527 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
13528 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
13529 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
13530 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13531 install_element(BGP_IPV4M_NODE
,
13532 &neighbor_remove_private_as_replace_as_cmd
);
13533 install_element(BGP_IPV4M_NODE
,
13534 &no_neighbor_remove_private_as_replace_as_cmd
);
13535 install_element(BGP_IPV4M_NODE
,
13536 &neighbor_remove_private_as_all_replace_as_cmd
);
13537 install_element(BGP_IPV4M_NODE
,
13538 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13539 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
13540 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
13541 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
13542 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13543 install_element(BGP_IPV4L_NODE
,
13544 &neighbor_remove_private_as_replace_as_cmd
);
13545 install_element(BGP_IPV4L_NODE
,
13546 &no_neighbor_remove_private_as_replace_as_cmd
);
13547 install_element(BGP_IPV4L_NODE
,
13548 &neighbor_remove_private_as_all_replace_as_cmd
);
13549 install_element(BGP_IPV4L_NODE
,
13550 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13551 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
13552 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13553 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13554 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13555 install_element(BGP_IPV6_NODE
,
13556 &neighbor_remove_private_as_replace_as_cmd
);
13557 install_element(BGP_IPV6_NODE
,
13558 &no_neighbor_remove_private_as_replace_as_cmd
);
13559 install_element(BGP_IPV6_NODE
,
13560 &neighbor_remove_private_as_all_replace_as_cmd
);
13561 install_element(BGP_IPV6_NODE
,
13562 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13563 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
13564 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
13565 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
13566 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13567 install_element(BGP_IPV6M_NODE
,
13568 &neighbor_remove_private_as_replace_as_cmd
);
13569 install_element(BGP_IPV6M_NODE
,
13570 &no_neighbor_remove_private_as_replace_as_cmd
);
13571 install_element(BGP_IPV6M_NODE
,
13572 &neighbor_remove_private_as_all_replace_as_cmd
);
13573 install_element(BGP_IPV6M_NODE
,
13574 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13575 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
13576 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
13577 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
13578 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13579 install_element(BGP_IPV6L_NODE
,
13580 &neighbor_remove_private_as_replace_as_cmd
);
13581 install_element(BGP_IPV6L_NODE
,
13582 &no_neighbor_remove_private_as_replace_as_cmd
);
13583 install_element(BGP_IPV6L_NODE
,
13584 &neighbor_remove_private_as_all_replace_as_cmd
);
13585 install_element(BGP_IPV6L_NODE
,
13586 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13587 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
13588 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13589 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13590 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13591 install_element(BGP_VPNV4_NODE
,
13592 &neighbor_remove_private_as_replace_as_cmd
);
13593 install_element(BGP_VPNV4_NODE
,
13594 &no_neighbor_remove_private_as_replace_as_cmd
);
13595 install_element(BGP_VPNV4_NODE
,
13596 &neighbor_remove_private_as_all_replace_as_cmd
);
13597 install_element(BGP_VPNV4_NODE
,
13598 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13599 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
13600 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13601 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13602 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13603 install_element(BGP_VPNV6_NODE
,
13604 &neighbor_remove_private_as_replace_as_cmd
);
13605 install_element(BGP_VPNV6_NODE
,
13606 &no_neighbor_remove_private_as_replace_as_cmd
);
13607 install_element(BGP_VPNV6_NODE
,
13608 &neighbor_remove_private_as_all_replace_as_cmd
);
13609 install_element(BGP_VPNV6_NODE
,
13610 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13612 /* "neighbor send-community" commands.*/
13613 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
13614 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
13615 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
13616 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
13617 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
13618 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
13619 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
13620 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
13621 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
13622 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
13623 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
13624 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
13625 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
13626 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
13627 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
13628 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
13629 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
13630 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
13631 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
13632 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
13633 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
13634 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
13635 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
13636 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
13637 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
13638 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
13639 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
13640 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
13641 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
13642 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
13643 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
13644 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
13645 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
13646 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
13647 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
13648 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
13650 /* "neighbor route-reflector" commands.*/
13651 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
13652 install_element(BGP_NODE
,
13653 &no_neighbor_route_reflector_client_hidden_cmd
);
13654 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
13655 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
13656 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
13657 install_element(BGP_IPV4M_NODE
,
13658 &no_neighbor_route_reflector_client_cmd
);
13659 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
13660 install_element(BGP_IPV4L_NODE
,
13661 &no_neighbor_route_reflector_client_cmd
);
13662 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
13663 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
13664 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
13665 install_element(BGP_IPV6M_NODE
,
13666 &no_neighbor_route_reflector_client_cmd
);
13667 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
13668 install_element(BGP_IPV6L_NODE
,
13669 &no_neighbor_route_reflector_client_cmd
);
13670 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
13671 install_element(BGP_VPNV4_NODE
,
13672 &no_neighbor_route_reflector_client_cmd
);
13673 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
13674 install_element(BGP_VPNV6_NODE
,
13675 &no_neighbor_route_reflector_client_cmd
);
13676 install_element(BGP_FLOWSPECV4_NODE
,
13677 &neighbor_route_reflector_client_cmd
);
13678 install_element(BGP_FLOWSPECV4_NODE
,
13679 &no_neighbor_route_reflector_client_cmd
);
13680 install_element(BGP_FLOWSPECV6_NODE
,
13681 &neighbor_route_reflector_client_cmd
);
13682 install_element(BGP_FLOWSPECV6_NODE
,
13683 &no_neighbor_route_reflector_client_cmd
);
13684 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
13685 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
13687 /* "neighbor route-server" commands.*/
13688 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
13689 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
13690 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
13691 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
13692 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
13693 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
13694 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
13695 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
13696 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
13697 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
13698 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
13699 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
13700 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
13701 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
13702 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
13703 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
13704 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
13705 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
13706 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
13707 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
13708 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
13709 install_element(BGP_FLOWSPECV4_NODE
,
13710 &no_neighbor_route_server_client_cmd
);
13711 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
13712 install_element(BGP_FLOWSPECV6_NODE
,
13713 &no_neighbor_route_server_client_cmd
);
13715 /* "neighbor addpath-tx-all-paths" commands.*/
13716 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
13717 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
13718 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13719 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13720 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13721 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13722 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13723 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13724 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13725 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13726 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13727 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13728 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13729 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13730 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13731 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13732 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13733 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13735 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
13736 install_element(BGP_NODE
,
13737 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13738 install_element(BGP_NODE
,
13739 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13740 install_element(BGP_IPV4_NODE
,
13741 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13742 install_element(BGP_IPV4_NODE
,
13743 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13744 install_element(BGP_IPV4M_NODE
,
13745 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13746 install_element(BGP_IPV4M_NODE
,
13747 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13748 install_element(BGP_IPV4L_NODE
,
13749 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13750 install_element(BGP_IPV4L_NODE
,
13751 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13752 install_element(BGP_IPV6_NODE
,
13753 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13754 install_element(BGP_IPV6_NODE
,
13755 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13756 install_element(BGP_IPV6M_NODE
,
13757 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13758 install_element(BGP_IPV6M_NODE
,
13759 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13760 install_element(BGP_IPV6L_NODE
,
13761 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13762 install_element(BGP_IPV6L_NODE
,
13763 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13764 install_element(BGP_VPNV4_NODE
,
13765 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13766 install_element(BGP_VPNV4_NODE
,
13767 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13768 install_element(BGP_VPNV6_NODE
,
13769 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13770 install_element(BGP_VPNV6_NODE
,
13771 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13773 /* "neighbor sender-as-path-loop-detection" commands. */
13774 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
13775 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
13777 /* "neighbor passive" commands. */
13778 install_element(BGP_NODE
, &neighbor_passive_cmd
);
13779 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13782 /* "neighbor shutdown" commands. */
13783 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13784 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13785 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13786 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13788 /* "neighbor capability extended-nexthop" commands.*/
13789 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13790 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13792 /* "neighbor capability orf prefix-list" commands.*/
13793 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13794 install_element(BGP_NODE
,
13795 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13796 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13797 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13798 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13799 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13800 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13801 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13802 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13803 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13804 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13805 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13806 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13807 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13809 /* "neighbor capability dynamic" commands.*/
13810 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13811 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13813 /* "neighbor dont-capability-negotiate" commands. */
13814 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13815 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13817 /* "neighbor ebgp-multihop" commands. */
13818 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13819 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13820 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13822 /* "neighbor disable-connected-check" commands. */
13823 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13824 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13826 /* "neighbor enforce-first-as" commands. */
13827 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13828 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13830 /* "neighbor description" commands. */
13831 install_element(BGP_NODE
, &neighbor_description_cmd
);
13832 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13833 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13835 /* "neighbor update-source" commands. "*/
13836 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13837 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13839 /* "neighbor default-originate" commands. */
13840 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13841 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13842 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13843 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13844 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13845 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13846 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13847 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13848 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13849 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13850 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13851 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13852 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13853 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13854 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13855 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13856 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13857 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13858 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13859 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13860 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13862 /* "neighbor port" commands. */
13863 install_element(BGP_NODE
, &neighbor_port_cmd
);
13864 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13866 /* "neighbor weight" commands. */
13867 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13868 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13870 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13871 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13872 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13873 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13874 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13875 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13876 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13877 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13878 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13879 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13880 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13881 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13882 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13883 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13884 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13885 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13887 /* "neighbor override-capability" commands. */
13888 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13889 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13891 /* "neighbor strict-capability-match" commands. */
13892 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13893 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13895 /* "neighbor timers" commands. */
13896 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13897 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13899 /* "neighbor timers connect" commands. */
13900 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13901 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13903 /* "neighbor advertisement-interval" commands. */
13904 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13905 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13907 /* "neighbor interface" commands. */
13908 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13909 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13911 /* "neighbor distribute" commands. */
13912 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13913 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13914 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13915 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13916 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13917 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13918 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13919 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13920 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13921 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13922 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13923 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13924 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13925 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13926 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13927 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13928 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13929 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13931 /* "neighbor prefix-list" commands. */
13932 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13933 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13934 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13935 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13936 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13937 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13938 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13939 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13940 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13941 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13942 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13943 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13944 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13945 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13946 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13947 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13948 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13949 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13950 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13951 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13952 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13953 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13955 /* "neighbor filter-list" commands. */
13956 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13957 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13958 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13959 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13960 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13961 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13962 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13963 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13964 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13965 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13966 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13967 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13968 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13969 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13970 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13971 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13972 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13973 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13974 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13975 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13976 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13977 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13979 /* "neighbor route-map" commands. */
13980 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13981 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13982 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13983 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13984 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13985 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13986 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13987 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13988 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13989 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13990 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13991 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13992 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13993 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13994 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13995 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13996 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13997 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13998 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13999 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
14000 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
14001 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
14002 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
14003 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
14005 /* "neighbor unsuppress-map" commands. */
14006 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
14007 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
14008 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
14009 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
14010 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
14011 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
14012 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
14013 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
14014 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
14015 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
14016 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
14017 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
14018 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
14019 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
14020 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
14021 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
14022 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
14023 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
14025 /* "neighbor maximum-prefix" commands. */
14026 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
14027 install_element(BGP_NODE
,
14028 &neighbor_maximum_prefix_threshold_hidden_cmd
);
14029 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
14030 install_element(BGP_NODE
,
14031 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
14032 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
14033 install_element(BGP_NODE
,
14034 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
14035 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
14036 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
14037 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14038 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14039 install_element(BGP_IPV4_NODE
,
14040 &neighbor_maximum_prefix_threshold_warning_cmd
);
14041 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14042 install_element(BGP_IPV4_NODE
,
14043 &neighbor_maximum_prefix_threshold_restart_cmd
);
14044 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
14045 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
14046 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14047 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14048 install_element(BGP_IPV4M_NODE
,
14049 &neighbor_maximum_prefix_threshold_warning_cmd
);
14050 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14051 install_element(BGP_IPV4M_NODE
,
14052 &neighbor_maximum_prefix_threshold_restart_cmd
);
14053 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
14054 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
14055 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14056 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14057 install_element(BGP_IPV4L_NODE
,
14058 &neighbor_maximum_prefix_threshold_warning_cmd
);
14059 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14060 install_element(BGP_IPV4L_NODE
,
14061 &neighbor_maximum_prefix_threshold_restart_cmd
);
14062 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
14063 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
14064 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14065 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14066 install_element(BGP_IPV6_NODE
,
14067 &neighbor_maximum_prefix_threshold_warning_cmd
);
14068 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14069 install_element(BGP_IPV6_NODE
,
14070 &neighbor_maximum_prefix_threshold_restart_cmd
);
14071 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
14072 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
14073 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14074 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14075 install_element(BGP_IPV6M_NODE
,
14076 &neighbor_maximum_prefix_threshold_warning_cmd
);
14077 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14078 install_element(BGP_IPV6M_NODE
,
14079 &neighbor_maximum_prefix_threshold_restart_cmd
);
14080 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
14081 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
14082 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14083 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14084 install_element(BGP_IPV6L_NODE
,
14085 &neighbor_maximum_prefix_threshold_warning_cmd
);
14086 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14087 install_element(BGP_IPV6L_NODE
,
14088 &neighbor_maximum_prefix_threshold_restart_cmd
);
14089 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
14090 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
14091 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14092 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14093 install_element(BGP_VPNV4_NODE
,
14094 &neighbor_maximum_prefix_threshold_warning_cmd
);
14095 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14096 install_element(BGP_VPNV4_NODE
,
14097 &neighbor_maximum_prefix_threshold_restart_cmd
);
14098 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
14099 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
14100 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14101 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14102 install_element(BGP_VPNV6_NODE
,
14103 &neighbor_maximum_prefix_threshold_warning_cmd
);
14104 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14105 install_element(BGP_VPNV6_NODE
,
14106 &neighbor_maximum_prefix_threshold_restart_cmd
);
14107 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
14109 /* "neighbor allowas-in" */
14110 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
14111 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
14112 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
14113 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
14114 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
14115 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
14116 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
14117 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
14118 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
14119 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
14120 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
14121 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
14122 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
14123 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
14124 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
14125 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
14126 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
14127 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
14128 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
14129 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
14131 /* address-family commands. */
14132 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
14133 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
14134 #ifdef KEEP_OLD_VPN_COMMANDS
14135 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
14136 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
14137 #endif /* KEEP_OLD_VPN_COMMANDS */
14139 install_element(BGP_NODE
, &address_family_evpn_cmd
);
14141 /* "exit-address-family" command. */
14142 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
14143 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
14144 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
14145 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
14146 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
14147 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
14148 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
14149 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
14150 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
14151 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
14152 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
14154 /* "clear ip bgp commands" */
14155 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
14157 /* clear ip bgp prefix */
14158 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
14159 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
14160 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
14162 /* "show [ip] bgp summary" commands. */
14163 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
14164 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
14165 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
14166 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
14167 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
14168 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
14169 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
14171 /* "show [ip] bgp neighbors" commands. */
14172 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
14174 /* "show [ip] bgp peer-group" commands. */
14175 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
14177 /* "show [ip] bgp paths" commands. */
14178 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
14180 /* "show [ip] bgp community" commands. */
14181 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
14183 /* "show ip bgp large-community" commands. */
14184 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
14185 /* "show [ip] bgp attribute-info" commands. */
14186 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
14187 /* "show [ip] bgp route-leak" command */
14188 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
14190 /* "redistribute" commands. */
14191 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
14192 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
14193 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
14194 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
14195 install_element(BGP_NODE
,
14196 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
14197 install_element(BGP_NODE
,
14198 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
14199 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
14200 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
14201 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
14202 install_element(BGP_NODE
,
14203 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
14204 install_element(BGP_NODE
,
14205 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
14206 install_element(BGP_NODE
,
14207 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
14208 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
14209 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
14210 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
14211 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
14212 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
14213 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
14214 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
14215 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
14216 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
14217 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
14218 install_element(BGP_IPV4_NODE
,
14219 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
14220 install_element(BGP_IPV4_NODE
,
14221 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
14222 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
14223 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
14224 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
14225 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
14226 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
14227 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
14229 /* import|export vpn [route-map WORD] */
14230 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
14231 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
14233 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
14234 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
14236 /* ttl_security commands */
14237 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
14238 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
14240 /* "show [ip] bgp memory" commands. */
14241 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
14243 /* "show bgp martian next-hop" */
14244 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
14246 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
14248 /* "show [ip] bgp views" commands. */
14249 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
14251 /* "show [ip] bgp vrfs" commands. */
14252 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
14254 /* Community-list. */
14255 community_list_vty();
14257 /* vpn-policy commands */
14258 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
14259 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
14260 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
14261 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
14262 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
14263 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
14264 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
14265 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
14266 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
14267 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
14268 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
14269 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
14271 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
14272 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
14274 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
14275 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
14276 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
14277 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
14278 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
14279 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
14280 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
14281 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
14282 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14283 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14284 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
14285 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
14288 #include "memory.h"
14289 #include "bgp_regex.h"
14290 #include "bgp_clist.h"
14291 #include "bgp_ecommunity.h"
14293 /* VTY functions. */
14295 /* Direction value to string conversion. */
14296 static const char *community_direct_str(int direct
)
14299 case COMMUNITY_DENY
:
14301 case COMMUNITY_PERMIT
:
14308 /* Display error string. */
14309 static void community_list_perror(struct vty
*vty
, int ret
)
14312 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
14313 vty_out(vty
, "%% Can't find community-list\n");
14315 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
14316 vty_out(vty
, "%% Malformed community-list value\n");
14318 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
14320 "%% Community name conflict, previously defined as standard community\n");
14322 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
14324 "%% Community name conflict, previously defined as expanded community\n");
14329 /* "community-list" keyword help string. */
14330 #define COMMUNITY_LIST_STR "Add a community list entry\n"
14332 /*community-list standard */
14333 DEFUN (community_list_standard
,
14334 bgp_community_list_standard_cmd
,
14335 "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14338 "Community list number (standard)\n"
14339 "Add an standard community-list entry\n"
14340 "Community list name\n"
14341 "Specify community to reject\n"
14342 "Specify community to accept\n"
14345 char *cl_name_or_number
= NULL
;
14347 int style
= COMMUNITY_LIST_STANDARD
;
14350 argv_find(argv
, argc
, "(1-99)", &idx
);
14351 argv_find(argv
, argc
, "WORD", &idx
);
14352 cl_name_or_number
= argv
[idx
]->arg
;
14353 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14355 argv_find(argv
, argc
, "AA:NN", &idx
);
14356 char *str
= argv_concat(argv
, argc
, idx
);
14358 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14361 XFREE(MTYPE_TMP
, str
);
14364 /* Display error string. */
14365 community_list_perror(vty
, ret
);
14366 return CMD_WARNING_CONFIG_FAILED
;
14369 return CMD_SUCCESS
;
14372 DEFUN (no_community_list_standard_all
,
14373 no_bgp_community_list_standard_all_cmd
,
14374 "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14378 "Community list number (standard)\n"
14379 "Add an standard community-list entry\n"
14380 "Community list name\n"
14381 "Specify community to reject\n"
14382 "Specify community to accept\n"
14385 char *cl_name_or_number
= NULL
;
14388 int style
= COMMUNITY_LIST_STANDARD
;
14392 argv_find(argv
, argc
, "permit", &idx
);
14393 argv_find(argv
, argc
, "deny", &idx
);
14396 direct
= argv_find(argv
, argc
, "permit", &idx
)
14401 argv_find(argv
, argc
, "AA:NN", &idx
);
14402 str
= argv_concat(argv
, argc
, idx
);
14406 argv_find(argv
, argc
, "(1-99)", &idx
);
14407 argv_find(argv
, argc
, "WORD", &idx
);
14408 cl_name_or_number
= argv
[idx
]->arg
;
14410 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14413 XFREE(MTYPE_TMP
, str
);
14416 community_list_perror(vty
, ret
);
14417 return CMD_WARNING_CONFIG_FAILED
;
14420 return CMD_SUCCESS
;
14423 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
14424 "no bgp community-list <(1-99)|standard WORD>",
14425 NO_STR BGP_STR COMMUNITY_LIST_STR
14426 "Community list number (standard)\n"
14427 "Add an standard community-list entry\n"
14428 "Community list name\n")
14430 /*community-list expanded */
14431 DEFUN (community_list_expanded_all
,
14432 bgp_community_list_expanded_all_cmd
,
14433 "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14436 "Community list number (expanded)\n"
14437 "Add an expanded community-list entry\n"
14438 "Community list name\n"
14439 "Specify community to reject\n"
14440 "Specify community to accept\n"
14443 char *cl_name_or_number
= NULL
;
14445 int style
= COMMUNITY_LIST_EXPANDED
;
14449 argv_find(argv
, argc
, "(100-500)", &idx
);
14450 argv_find(argv
, argc
, "WORD", &idx
);
14451 cl_name_or_number
= argv
[idx
]->arg
;
14452 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14454 argv_find(argv
, argc
, "AA:NN", &idx
);
14455 char *str
= argv_concat(argv
, argc
, idx
);
14457 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14460 XFREE(MTYPE_TMP
, str
);
14463 /* Display error string. */
14464 community_list_perror(vty
, ret
);
14465 return CMD_WARNING_CONFIG_FAILED
;
14468 return CMD_SUCCESS
;
14471 DEFUN (no_community_list_expanded_all
,
14472 no_bgp_community_list_expanded_all_cmd
,
14473 "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14477 "Community list number (expanded)\n"
14478 "Add an expanded community-list entry\n"
14479 "Community list name\n"
14480 "Specify community to reject\n"
14481 "Specify community to accept\n"
14484 char *cl_name_or_number
= NULL
;
14487 int style
= COMMUNITY_LIST_EXPANDED
;
14491 argv_find(argv
, argc
, "permit", &idx
);
14492 argv_find(argv
, argc
, "deny", &idx
);
14495 direct
= argv_find(argv
, argc
, "permit", &idx
)
14500 argv_find(argv
, argc
, "AA:NN", &idx
);
14501 str
= argv_concat(argv
, argc
, idx
);
14505 argv_find(argv
, argc
, "(100-500)", &idx
);
14506 argv_find(argv
, argc
, "WORD", &idx
);
14507 cl_name_or_number
= argv
[idx
]->arg
;
14509 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14512 XFREE(MTYPE_TMP
, str
);
14515 community_list_perror(vty
, ret
);
14516 return CMD_WARNING_CONFIG_FAILED
;
14519 return CMD_SUCCESS
;
14522 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
14523 "no bgp community-list <(100-500)|expanded WORD>",
14524 NO_STR IP_STR COMMUNITY_LIST_STR
14525 "Community list number (expanded)\n"
14526 "Add an expanded community-list entry\n"
14527 "Community list name\n")
14529 /* Return configuration string of community-list entry. */
14530 static const char *community_list_config_str(struct community_entry
*entry
)
14537 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
14538 str
= community_str(entry
->u
.com
, false);
14539 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
14540 str
= lcommunity_str(entry
->u
.lcom
, false);
14542 str
= entry
->config
;
14547 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
14549 struct community_entry
*entry
;
14551 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14552 if (entry
== list
->head
) {
14553 if (all_digit(list
->name
))
14554 vty_out(vty
, "Community %s list %s\n",
14555 entry
->style
== COMMUNITY_LIST_STANDARD
14557 : "(expanded) access",
14560 vty_out(vty
, "Named Community %s list %s\n",
14561 entry
->style
== COMMUNITY_LIST_STANDARD
14567 vty_out(vty
, " %s\n",
14568 community_direct_str(entry
->direct
));
14570 vty_out(vty
, " %s %s\n",
14571 community_direct_str(entry
->direct
),
14572 community_list_config_str(entry
));
14576 DEFUN (show_community_list
,
14577 show_bgp_community_list_cmd
,
14578 "show bgp community-list",
14581 "List community-list\n")
14583 struct community_list
*list
;
14584 struct community_list_master
*cm
;
14586 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14588 return CMD_SUCCESS
;
14590 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14591 community_list_show(vty
, list
);
14593 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14594 community_list_show(vty
, list
);
14596 return CMD_SUCCESS
;
14599 DEFUN (show_community_list_arg
,
14600 show_bgp_community_list_arg_cmd
,
14601 "show bgp community-list <(1-500)|WORD> detail",
14604 "List community-list\n"
14605 "Community-list number\n"
14606 "Community-list name\n"
14607 "Detailed information on community-list\n")
14609 int idx_comm_list
= 3;
14610 struct community_list
*list
;
14612 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
14613 COMMUNITY_LIST_MASTER
);
14615 vty_out(vty
, "%% Can't find community-list\n");
14616 return CMD_WARNING
;
14619 community_list_show(vty
, list
);
14621 return CMD_SUCCESS
;
14625 * Large Community code.
14627 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
14628 struct cmd_token
**argv
, int style
,
14629 int reject_all_digit_name
)
14637 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14640 /* All digit name check. */
14642 argv_find(argv
, argc
, "WORD", &idx
);
14643 argv_find(argv
, argc
, "(1-99)", &idx
);
14644 argv_find(argv
, argc
, "(100-500)", &idx
);
14645 cl_name
= argv
[idx
]->arg
;
14646 if (reject_all_digit_name
&& all_digit(cl_name
)) {
14647 vty_out(vty
, "%% Community name cannot have all digits\n");
14648 return CMD_WARNING_CONFIG_FAILED
;
14652 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
14653 argv_find(argv
, argc
, "LINE", &idx
);
14654 /* Concat community string argument. */
14656 str
= argv_concat(argv
, argc
, idx
);
14660 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
14662 /* Free temporary community list string allocated by
14664 XFREE(MTYPE_TMP
, str
);
14667 community_list_perror(vty
, ret
);
14668 return CMD_WARNING_CONFIG_FAILED
;
14670 return CMD_SUCCESS
;
14673 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
14674 struct cmd_token
**argv
, int style
)
14681 argv_find(argv
, argc
, "permit", &idx
);
14682 argv_find(argv
, argc
, "deny", &idx
);
14685 /* Check the list direct. */
14686 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
14687 direct
= COMMUNITY_PERMIT
;
14689 direct
= COMMUNITY_DENY
;
14692 argv_find(argv
, argc
, "LINE", &idx
);
14693 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
14694 /* Concat community string argument. */
14695 str
= argv_concat(argv
, argc
, idx
);
14699 argv_find(argv
, argc
, "(1-99)", &idx
);
14700 argv_find(argv
, argc
, "(100-500)", &idx
);
14701 argv_find(argv
, argc
, "WORD", &idx
);
14703 /* Unset community list. */
14704 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
14707 /* Free temporary community list string allocated by
14709 XFREE(MTYPE_TMP
, str
);
14712 community_list_perror(vty
, ret
);
14713 return CMD_WARNING_CONFIG_FAILED
;
14716 return CMD_SUCCESS
;
14719 /* "large-community-list" keyword help string. */
14720 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
14721 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
14723 DEFUN (lcommunity_list_standard
,
14724 bgp_lcommunity_list_standard_cmd
,
14725 "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...",
14727 LCOMMUNITY_LIST_STR
14728 "Large Community list number (standard)\n"
14729 "Specify large community to reject\n"
14730 "Specify large community to accept\n"
14731 LCOMMUNITY_VAL_STR
)
14733 return lcommunity_list_set_vty(vty
, argc
, argv
,
14734 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14737 DEFUN (lcommunity_list_expanded
,
14738 bgp_lcommunity_list_expanded_cmd
,
14739 "bgp large-community-list (100-500) <deny|permit> LINE...",
14741 LCOMMUNITY_LIST_STR
14742 "Large Community list number (expanded)\n"
14743 "Specify large community to reject\n"
14744 "Specify large community to accept\n"
14745 "An ordered list as a regular-expression\n")
14747 return lcommunity_list_set_vty(vty
, argc
, argv
,
14748 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
14751 DEFUN (lcommunity_list_name_standard
,
14752 bgp_lcommunity_list_name_standard_cmd
,
14753 "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
14755 LCOMMUNITY_LIST_STR
14756 "Specify standard large-community-list\n"
14757 "Large Community list name\n"
14758 "Specify large community to reject\n"
14759 "Specify large community to accept\n"
14760 LCOMMUNITY_VAL_STR
)
14762 return lcommunity_list_set_vty(vty
, argc
, argv
,
14763 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14766 DEFUN (lcommunity_list_name_expanded
,
14767 bgp_lcommunity_list_name_expanded_cmd
,
14768 "bgp large-community-list expanded WORD <deny|permit> LINE...",
14770 LCOMMUNITY_LIST_STR
14771 "Specify expanded large-community-list\n"
14772 "Large Community list name\n"
14773 "Specify large community to reject\n"
14774 "Specify large community to accept\n"
14775 "An ordered list as a regular-expression\n")
14777 return lcommunity_list_set_vty(vty
, argc
, argv
,
14778 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
14781 DEFUN (no_lcommunity_list_standard_all
,
14782 no_bgp_lcommunity_list_standard_all_cmd
,
14783 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
14786 LCOMMUNITY_LIST_STR
14787 "Large Community list number (standard)\n"
14788 "Large Community list number (expanded)\n"
14789 "Large Community list name\n")
14791 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14792 LARGE_COMMUNITY_LIST_STANDARD
);
14795 DEFUN (no_lcommunity_list_name_expanded_all
,
14796 no_bgp_lcommunity_list_name_expanded_all_cmd
,
14797 "no bgp large-community-list expanded WORD",
14800 LCOMMUNITY_LIST_STR
14801 "Specify expanded large-community-list\n"
14802 "Large Community list name\n")
14804 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14805 LARGE_COMMUNITY_LIST_EXPANDED
);
14808 DEFUN (no_lcommunity_list_standard
,
14809 no_bgp_lcommunity_list_standard_cmd
,
14810 "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
14813 LCOMMUNITY_LIST_STR
14814 "Large Community list number (standard)\n"
14815 "Specify large community to reject\n"
14816 "Specify large community to accept\n"
14817 LCOMMUNITY_VAL_STR
)
14819 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14820 LARGE_COMMUNITY_LIST_STANDARD
);
14823 DEFUN (no_lcommunity_list_expanded
,
14824 no_bgp_lcommunity_list_expanded_cmd
,
14825 "no bgp large-community-list (100-500) <deny|permit> LINE...",
14828 LCOMMUNITY_LIST_STR
14829 "Large Community list number (expanded)\n"
14830 "Specify large community to reject\n"
14831 "Specify large community to accept\n"
14832 "An ordered list as a regular-expression\n")
14834 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14835 LARGE_COMMUNITY_LIST_EXPANDED
);
14838 DEFUN (no_lcommunity_list_name_standard
,
14839 no_bgp_lcommunity_list_name_standard_cmd
,
14840 "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
14843 LCOMMUNITY_LIST_STR
14844 "Specify standard large-community-list\n"
14845 "Large Community list name\n"
14846 "Specify large community to reject\n"
14847 "Specify large community to accept\n"
14848 LCOMMUNITY_VAL_STR
)
14850 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14851 LARGE_COMMUNITY_LIST_STANDARD
);
14854 DEFUN (no_lcommunity_list_name_expanded
,
14855 no_bgp_lcommunity_list_name_expanded_cmd
,
14856 "no bgp large-community-list expanded WORD <deny|permit> LINE...",
14859 LCOMMUNITY_LIST_STR
14860 "Specify expanded large-community-list\n"
14861 "Large community list name\n"
14862 "Specify large community to reject\n"
14863 "Specify large community to accept\n"
14864 "An ordered list as a regular-expression\n")
14866 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14867 LARGE_COMMUNITY_LIST_EXPANDED
);
14870 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14872 struct community_entry
*entry
;
14874 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14875 if (entry
== list
->head
) {
14876 if (all_digit(list
->name
))
14877 vty_out(vty
, "Large community %s list %s\n",
14879 LARGE_COMMUNITY_LIST_STANDARD
14881 : "(expanded) access",
14885 "Named large community %s list %s\n",
14887 LARGE_COMMUNITY_LIST_STANDARD
14893 vty_out(vty
, " %s\n",
14894 community_direct_str(entry
->direct
));
14896 vty_out(vty
, " %s %s\n",
14897 community_direct_str(entry
->direct
),
14898 community_list_config_str(entry
));
14902 DEFUN (show_lcommunity_list
,
14903 show_bgp_lcommunity_list_cmd
,
14904 "show bgp large-community-list",
14907 "List large-community list\n")
14909 struct community_list
*list
;
14910 struct community_list_master
*cm
;
14912 cm
= community_list_master_lookup(bgp_clist
,
14913 LARGE_COMMUNITY_LIST_MASTER
);
14915 return CMD_SUCCESS
;
14917 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14918 lcommunity_list_show(vty
, list
);
14920 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14921 lcommunity_list_show(vty
, list
);
14923 return CMD_SUCCESS
;
14926 DEFUN (show_lcommunity_list_arg
,
14927 show_bgp_lcommunity_list_arg_cmd
,
14928 "show bgp large-community-list <(1-500)|WORD> detail",
14931 "List large-community list\n"
14932 "Large-community-list number\n"
14933 "Large-community-list name\n"
14934 "Detailed information on large-community-list\n")
14936 struct community_list
*list
;
14938 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
14939 LARGE_COMMUNITY_LIST_MASTER
);
14941 vty_out(vty
, "%% Can't find large-community-list\n");
14942 return CMD_WARNING
;
14945 lcommunity_list_show(vty
, list
);
14947 return CMD_SUCCESS
;
14950 /* "extcommunity-list" keyword help string. */
14951 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
14952 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
14954 DEFUN (extcommunity_list_standard
,
14955 bgp_extcommunity_list_standard_cmd
,
14956 "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14958 EXTCOMMUNITY_LIST_STR
14959 "Extended Community list number (standard)\n"
14960 "Specify standard extcommunity-list\n"
14961 "Community list name\n"
14962 "Specify community to reject\n"
14963 "Specify community to accept\n"
14964 EXTCOMMUNITY_VAL_STR
)
14966 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14968 char *cl_number_or_name
= NULL
;
14972 argv_find(argv
, argc
, "(1-99)", &idx
);
14973 argv_find(argv
, argc
, "WORD", &idx
);
14974 cl_number_or_name
= argv
[idx
]->arg
;
14975 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14977 argv_find(argv
, argc
, "AA:NN", &idx
);
14978 char *str
= argv_concat(argv
, argc
, idx
);
14980 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14983 XFREE(MTYPE_TMP
, str
);
14986 community_list_perror(vty
, ret
);
14987 return CMD_WARNING_CONFIG_FAILED
;
14990 return CMD_SUCCESS
;
14993 DEFUN (extcommunity_list_name_expanded
,
14994 bgp_extcommunity_list_name_expanded_cmd
,
14995 "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14997 EXTCOMMUNITY_LIST_STR
14998 "Extended Community list number (expanded)\n"
14999 "Specify expanded extcommunity-list\n"
15000 "Extended Community list name\n"
15001 "Specify community to reject\n"
15002 "Specify community to accept\n"
15003 "An ordered list as a regular-expression\n")
15005 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15007 char *cl_number_or_name
= NULL
;
15010 argv_find(argv
, argc
, "(100-500)", &idx
);
15011 argv_find(argv
, argc
, "WORD", &idx
);
15012 cl_number_or_name
= argv
[idx
]->arg
;
15013 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15015 argv_find(argv
, argc
, "LINE", &idx
);
15016 char *str
= argv_concat(argv
, argc
, idx
);
15018 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15021 XFREE(MTYPE_TMP
, str
);
15024 community_list_perror(vty
, ret
);
15025 return CMD_WARNING_CONFIG_FAILED
;
15028 return CMD_SUCCESS
;
15031 DEFUN (no_extcommunity_list_standard_all
,
15032 no_bgp_extcommunity_list_standard_all_cmd
,
15033 "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15036 EXTCOMMUNITY_LIST_STR
15037 "Extended Community list number (standard)\n"
15038 "Specify standard extcommunity-list\n"
15039 "Community list name\n"
15040 "Specify community to reject\n"
15041 "Specify community to accept\n"
15042 EXTCOMMUNITY_VAL_STR
)
15044 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15046 char *cl_number_or_name
= NULL
;
15050 argv_find(argv
, argc
, "permit", &idx
);
15051 argv_find(argv
, argc
, "deny", &idx
);
15054 direct
= argv_find(argv
, argc
, "permit", &idx
)
15059 argv_find(argv
, argc
, "AA:NN", &idx
);
15060 str
= argv_concat(argv
, argc
, idx
);
15064 argv_find(argv
, argc
, "(1-99)", &idx
);
15065 argv_find(argv
, argc
, "WORD", &idx
);
15066 cl_number_or_name
= argv
[idx
]->arg
;
15068 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15071 XFREE(MTYPE_TMP
, str
);
15074 community_list_perror(vty
, ret
);
15075 return CMD_WARNING_CONFIG_FAILED
;
15078 return CMD_SUCCESS
;
15081 ALIAS(no_extcommunity_list_standard_all
,
15082 no_bgp_extcommunity_list_standard_all_list_cmd
,
15083 "no bgp extcommunity-list <(1-99)|standard WORD>",
15084 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15085 "Extended Community list number (standard)\n"
15086 "Specify standard extcommunity-list\n"
15087 "Community list name\n")
15089 DEFUN (no_extcommunity_list_expanded_all
,
15090 no_bgp_extcommunity_list_expanded_all_cmd
,
15091 "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15094 EXTCOMMUNITY_LIST_STR
15095 "Extended Community list number (expanded)\n"
15096 "Specify expanded extcommunity-list\n"
15097 "Extended Community list name\n"
15098 "Specify community to reject\n"
15099 "Specify community to accept\n"
15100 "An ordered list as a regular-expression\n")
15102 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15104 char *cl_number_or_name
= NULL
;
15108 argv_find(argv
, argc
, "permit", &idx
);
15109 argv_find(argv
, argc
, "deny", &idx
);
15112 direct
= argv_find(argv
, argc
, "permit", &idx
)
15117 argv_find(argv
, argc
, "LINE", &idx
);
15118 str
= argv_concat(argv
, argc
, idx
);
15122 argv_find(argv
, argc
, "(100-500)", &idx
);
15123 argv_find(argv
, argc
, "WORD", &idx
);
15124 cl_number_or_name
= argv
[idx
]->arg
;
15126 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15129 XFREE(MTYPE_TMP
, str
);
15132 community_list_perror(vty
, ret
);
15133 return CMD_WARNING_CONFIG_FAILED
;
15136 return CMD_SUCCESS
;
15139 ALIAS(no_extcommunity_list_expanded_all
,
15140 no_bgp_extcommunity_list_expanded_all_list_cmd
,
15141 "no bgp extcommunity-list <(100-500)|expanded WORD>",
15142 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15143 "Extended Community list number (expanded)\n"
15144 "Specify expanded extcommunity-list\n"
15145 "Extended Community list name\n")
15147 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
15149 struct community_entry
*entry
;
15151 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15152 if (entry
== list
->head
) {
15153 if (all_digit(list
->name
))
15154 vty_out(vty
, "Extended community %s list %s\n",
15155 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15157 : "(expanded) access",
15161 "Named extended community %s list %s\n",
15162 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15168 vty_out(vty
, " %s\n",
15169 community_direct_str(entry
->direct
));
15171 vty_out(vty
, " %s %s\n",
15172 community_direct_str(entry
->direct
),
15173 community_list_config_str(entry
));
15177 DEFUN (show_extcommunity_list
,
15178 show_bgp_extcommunity_list_cmd
,
15179 "show bgp extcommunity-list",
15182 "List extended-community list\n")
15184 struct community_list
*list
;
15185 struct community_list_master
*cm
;
15187 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15189 return CMD_SUCCESS
;
15191 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15192 extcommunity_list_show(vty
, list
);
15194 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15195 extcommunity_list_show(vty
, list
);
15197 return CMD_SUCCESS
;
15200 DEFUN (show_extcommunity_list_arg
,
15201 show_bgp_extcommunity_list_arg_cmd
,
15202 "show bgp extcommunity-list <(1-500)|WORD> detail",
15205 "List extended-community list\n"
15206 "Extcommunity-list number\n"
15207 "Extcommunity-list name\n"
15208 "Detailed information on extcommunity-list\n")
15210 int idx_comm_list
= 3;
15211 struct community_list
*list
;
15213 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
15214 EXTCOMMUNITY_LIST_MASTER
);
15216 vty_out(vty
, "%% Can't find extcommunity-list\n");
15217 return CMD_WARNING
;
15220 extcommunity_list_show(vty
, list
);
15222 return CMD_SUCCESS
;
15225 /* Display community-list and extcommunity-list configuration. */
15226 static int community_list_config_write(struct vty
*vty
)
15228 struct community_list
*list
;
15229 struct community_entry
*entry
;
15230 struct community_list_master
*cm
;
15233 /* Community-list. */
15234 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
15236 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15237 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15238 vty_out(vty
, "bgp community-list %s %s %s\n", list
->name
,
15239 community_direct_str(entry
->direct
),
15240 community_list_config_str(entry
));
15243 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15244 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15245 vty_out(vty
, "bgp community-list %s %s %s %s\n",
15246 entry
->style
== COMMUNITY_LIST_STANDARD
15249 list
->name
, community_direct_str(entry
->direct
),
15250 community_list_config_str(entry
));
15254 /* Extcommunity-list. */
15255 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15257 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15258 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15259 vty_out(vty
, "bgp extcommunity-list %s %s %s\n",
15260 list
->name
, community_direct_str(entry
->direct
),
15261 community_list_config_str(entry
));
15264 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15265 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15266 vty_out(vty
, "bgp extcommunity-list %s %s %s %s\n",
15267 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15270 list
->name
, community_direct_str(entry
->direct
),
15271 community_list_config_str(entry
));
15276 /* lcommunity-list. */
15277 cm
= community_list_master_lookup(bgp_clist
,
15278 LARGE_COMMUNITY_LIST_MASTER
);
15280 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15281 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15282 vty_out(vty
, "bgp large-community-list %s %s %s\n",
15283 list
->name
, community_direct_str(entry
->direct
),
15284 community_list_config_str(entry
));
15287 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15288 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15289 vty_out(vty
, "bgp large-community-list %s %s %s %s\n",
15290 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
15293 list
->name
, community_direct_str(entry
->direct
),
15294 community_list_config_str(entry
));
15301 static struct cmd_node community_list_node
= {
15302 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
15305 static void community_list_vty(void)
15307 install_node(&community_list_node
, community_list_config_write
);
15309 /* Community-list. */
15310 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
15311 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
15312 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
15313 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
15314 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
15315 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
15316 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
15317 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
15319 /* Extcommunity-list. */
15320 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
15321 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
15322 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
15323 install_element(CONFIG_NODE
,
15324 &no_bgp_extcommunity_list_standard_all_list_cmd
);
15325 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
15326 install_element(CONFIG_NODE
,
15327 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
15328 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
15329 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
15331 /* Large Community List */
15332 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
15333 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
15334 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
15335 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
15336 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_all_cmd
);
15337 install_element(CONFIG_NODE
,
15338 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
15339 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
15340 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
15341 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
15342 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
15343 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
15344 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);