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
);
3199 peer_notify_unconfig(peer
);
3204 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3206 peer_group_notify_unconfig(group
);
3207 peer_group_delete(group
);
3209 vty_out(vty
, "%% Create the peer-group first\n");
3210 return CMD_WARNING_CONFIG_FAILED
;
3213 peer
= peer_lookup(bgp
, &su
);
3215 if (peer_dynamic_neighbor(peer
)) {
3217 "%% Operation not allowed on a dynamic neighbor\n");
3218 return CMD_WARNING_CONFIG_FAILED
;
3221 other
= peer
->doppelganger
;
3222 peer_notify_unconfig(peer
);
3224 if (other
&& other
->status
!= Deleted
) {
3225 peer_notify_unconfig(other
);
3234 DEFUN (no_neighbor_interface_config
,
3235 no_neighbor_interface_config_cmd
,
3236 "no neighbor WORD interface [v6only] [peer-group PGNAME] [remote-as <(1-4294967295)|internal|external>]",
3240 "Configure BGP on interface\n"
3241 "Enable BGP with v6 link-local only\n"
3242 "Member of the peer-group\n"
3244 "Specify a BGP neighbor\n"
3246 "Internal BGP peer\n"
3247 "External BGP peer\n")
3249 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3253 /* look up for neighbor by interface name config. */
3254 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3256 /* Request zebra to terminate IPv6 RAs on this interface. */
3258 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3259 peer_notify_unconfig(peer
);
3262 vty_out(vty
, "%% Create the bgp interface first\n");
3263 return CMD_WARNING_CONFIG_FAILED
;
3268 DEFUN (no_neighbor_peer_group
,
3269 no_neighbor_peer_group_cmd
,
3270 "no neighbor WORD peer-group",
3274 "Configure peer-group\n")
3276 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3278 struct peer_group
*group
;
3280 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3282 peer_group_notify_unconfig(group
);
3283 peer_group_delete(group
);
3285 vty_out(vty
, "%% Create the peer-group first\n");
3286 return CMD_WARNING_CONFIG_FAILED
;
3291 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3292 no_neighbor_interface_peer_group_remote_as_cmd
,
3293 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3296 "Interface name or neighbor tag\n"
3297 "Specify a BGP neighbor\n"
3299 "Internal BGP peer\n"
3300 "External BGP peer\n")
3302 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3304 struct peer_group
*group
;
3307 /* look up for neighbor by interface name config. */
3308 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3310 peer_as_change(peer
, 0, AS_UNSPECIFIED
);
3314 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3316 peer_group_remote_as_delete(group
);
3318 vty_out(vty
, "%% Create the peer-group or interface first\n");
3319 return CMD_WARNING_CONFIG_FAILED
;
3324 DEFUN (neighbor_local_as
,
3325 neighbor_local_as_cmd
,
3326 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3329 "Specify a local-as number\n"
3330 "AS number used as local AS\n")
3338 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3340 return CMD_WARNING_CONFIG_FAILED
;
3342 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3343 ret
= peer_local_as_set(peer
, as
, 0, 0);
3344 return bgp_vty_return(vty
, ret
);
3347 DEFUN (neighbor_local_as_no_prepend
,
3348 neighbor_local_as_no_prepend_cmd
,
3349 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3352 "Specify a local-as number\n"
3353 "AS number used as local AS\n"
3354 "Do not prepend local-as to updates from ebgp peers\n")
3362 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3364 return CMD_WARNING_CONFIG_FAILED
;
3366 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3367 ret
= peer_local_as_set(peer
, as
, 1, 0);
3368 return bgp_vty_return(vty
, ret
);
3371 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3372 neighbor_local_as_no_prepend_replace_as_cmd
,
3373 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3376 "Specify a local-as number\n"
3377 "AS number used as local AS\n"
3378 "Do not prepend local-as to updates from ebgp peers\n"
3379 "Do not prepend local-as to updates from ibgp peers\n")
3387 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3389 return CMD_WARNING_CONFIG_FAILED
;
3391 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3392 ret
= peer_local_as_set(peer
, as
, 1, 1);
3393 return bgp_vty_return(vty
, ret
);
3396 DEFUN (no_neighbor_local_as
,
3397 no_neighbor_local_as_cmd
,
3398 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3402 "Specify a local-as number\n"
3403 "AS number used as local AS\n"
3404 "Do not prepend local-as to updates from ebgp peers\n"
3405 "Do not prepend local-as to updates from ibgp peers\n")
3411 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3413 return CMD_WARNING_CONFIG_FAILED
;
3415 ret
= peer_local_as_unset(peer
);
3416 return bgp_vty_return(vty
, ret
);
3420 DEFUN (neighbor_solo
,
3422 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3425 "Solo peer - part of its own update group\n")
3431 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3433 return CMD_WARNING_CONFIG_FAILED
;
3435 ret
= update_group_adjust_soloness(peer
, 1);
3436 return bgp_vty_return(vty
, ret
);
3439 DEFUN (no_neighbor_solo
,
3440 no_neighbor_solo_cmd
,
3441 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3445 "Solo peer - part of its own update group\n")
3451 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3453 return CMD_WARNING_CONFIG_FAILED
;
3455 ret
= update_group_adjust_soloness(peer
, 0);
3456 return bgp_vty_return(vty
, ret
);
3459 DEFUN (neighbor_password
,
3460 neighbor_password_cmd
,
3461 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3472 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3474 return CMD_WARNING_CONFIG_FAILED
;
3476 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3477 return bgp_vty_return(vty
, ret
);
3480 DEFUN (no_neighbor_password
,
3481 no_neighbor_password_cmd
,
3482 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3493 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3495 return CMD_WARNING_CONFIG_FAILED
;
3497 ret
= peer_password_unset(peer
);
3498 return bgp_vty_return(vty
, ret
);
3501 DEFUN (neighbor_activate
,
3502 neighbor_activate_cmd
,
3503 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3506 "Enable the Address Family for this Neighbor\n")
3512 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3514 return CMD_WARNING_CONFIG_FAILED
;
3516 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3517 return bgp_vty_return(vty
, ret
);
3520 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3521 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3522 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3523 "Enable the Address Family for this Neighbor\n")
3525 DEFUN (no_neighbor_activate
,
3526 no_neighbor_activate_cmd
,
3527 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3531 "Enable the Address Family for this Neighbor\n")
3538 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3540 return CMD_WARNING_CONFIG_FAILED
;
3542 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3543 return bgp_vty_return(vty
, ret
);
3546 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3547 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3548 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3549 "Enable the Address Family for this Neighbor\n")
3551 DEFUN (neighbor_set_peer_group
,
3552 neighbor_set_peer_group_cmd
,
3553 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3556 "Member of the peer-group\n"
3557 "Peer-group name\n")
3559 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3566 struct peer_group
*group
;
3568 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3570 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3572 vty_out(vty
, "%% Malformed address or name: %s\n",
3573 argv
[idx_peer
]->arg
);
3574 return CMD_WARNING_CONFIG_FAILED
;
3577 if (peer_address_self_check(bgp
, &su
)) {
3579 "%% Can not configure the local system as neighbor\n");
3580 return CMD_WARNING_CONFIG_FAILED
;
3583 /* Disallow for dynamic neighbor. */
3584 peer
= peer_lookup(bgp
, &su
);
3585 if (peer
&& peer_dynamic_neighbor(peer
)) {
3587 "%% Operation not allowed on a dynamic neighbor\n");
3588 return CMD_WARNING_CONFIG_FAILED
;
3592 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3594 vty_out(vty
, "%% Configure the peer-group first\n");
3595 return CMD_WARNING_CONFIG_FAILED
;
3598 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3600 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3602 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3604 return CMD_WARNING_CONFIG_FAILED
;
3607 return bgp_vty_return(vty
, ret
);
3610 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3611 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3612 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3613 "Member of the peer-group\n"
3614 "Peer-group name\n")
3616 DEFUN (no_neighbor_set_peer_group
,
3617 no_neighbor_set_peer_group_cmd
,
3618 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3622 "Member of the peer-group\n"
3623 "Peer-group name\n")
3625 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3630 struct peer_group
*group
;
3632 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3634 return CMD_WARNING_CONFIG_FAILED
;
3636 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3638 vty_out(vty
, "%% Configure the peer-group first\n");
3639 return CMD_WARNING_CONFIG_FAILED
;
3642 peer_notify_unconfig(peer
);
3643 ret
= peer_delete(peer
);
3645 return bgp_vty_return(vty
, ret
);
3648 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3649 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group PGNAME",
3650 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3651 "Member of the peer-group\n"
3652 "Peer-group name\n")
3654 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3655 uint32_t flag
, int set
)
3660 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3662 return CMD_WARNING_CONFIG_FAILED
;
3665 * If 'neighbor <interface>', then this is for directly connected peers,
3666 * we should not accept disable-connected-check.
3668 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3670 "%s is directly connected peer, cannot accept disable-"
3671 "connected-check\n",
3673 return CMD_WARNING_CONFIG_FAILED
;
3676 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3677 peer_tx_shutdown_message_unset(peer
);
3680 ret
= peer_flag_set(peer
, flag
);
3682 ret
= peer_flag_unset(peer
, flag
);
3684 return bgp_vty_return(vty
, ret
);
3687 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3689 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3692 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3695 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3698 /* neighbor passive. */
3699 DEFUN (neighbor_passive
,
3700 neighbor_passive_cmd
,
3701 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3704 "Don't send open messages to this neighbor\n")
3707 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3710 DEFUN (no_neighbor_passive
,
3711 no_neighbor_passive_cmd
,
3712 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3716 "Don't send open messages to this neighbor\n")
3719 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3722 /* neighbor shutdown. */
3723 DEFUN (neighbor_shutdown_msg
,
3724 neighbor_shutdown_msg_cmd
,
3725 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3728 "Administratively shut down this neighbor\n"
3729 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3730 "Shutdown message\n")
3736 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3740 return CMD_WARNING_CONFIG_FAILED
;
3741 message
= argv_concat(argv
, argc
, 4);
3742 peer_tx_shutdown_message_set(peer
, message
);
3743 XFREE(MTYPE_TMP
, message
);
3746 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3749 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3750 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3751 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3752 "Administratively shut down this neighbor\n")
3754 DEFUN (no_neighbor_shutdown_msg
,
3755 no_neighbor_shutdown_msg_cmd
,
3756 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3760 "Administratively shut down this neighbor\n"
3761 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3762 "Shutdown message\n")
3766 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3767 PEER_FLAG_SHUTDOWN
);
3770 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3771 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3772 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3773 "Administratively shut down this neighbor\n")
3775 /* neighbor capability dynamic. */
3776 DEFUN (neighbor_capability_dynamic
,
3777 neighbor_capability_dynamic_cmd
,
3778 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3781 "Advertise capability to the peer\n"
3782 "Advertise dynamic capability to this neighbor\n")
3785 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3786 PEER_FLAG_DYNAMIC_CAPABILITY
);
3789 DEFUN (no_neighbor_capability_dynamic
,
3790 no_neighbor_capability_dynamic_cmd
,
3791 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3795 "Advertise capability to the peer\n"
3796 "Advertise dynamic capability to this neighbor\n")
3799 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3800 PEER_FLAG_DYNAMIC_CAPABILITY
);
3803 /* neighbor dont-capability-negotiate */
3804 DEFUN (neighbor_dont_capability_negotiate
,
3805 neighbor_dont_capability_negotiate_cmd
,
3806 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3809 "Do not perform capability negotiation\n")
3812 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3813 PEER_FLAG_DONT_CAPABILITY
);
3816 DEFUN (no_neighbor_dont_capability_negotiate
,
3817 no_neighbor_dont_capability_negotiate_cmd
,
3818 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3822 "Do not perform capability negotiation\n")
3825 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3826 PEER_FLAG_DONT_CAPABILITY
);
3829 /* neighbor capability extended next hop encoding */
3830 DEFUN (neighbor_capability_enhe
,
3831 neighbor_capability_enhe_cmd
,
3832 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3835 "Advertise capability to the peer\n"
3836 "Advertise extended next-hop capability to the peer\n")
3839 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3840 PEER_FLAG_CAPABILITY_ENHE
);
3843 DEFUN (no_neighbor_capability_enhe
,
3844 no_neighbor_capability_enhe_cmd
,
3845 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3849 "Advertise capability to the peer\n"
3850 "Advertise extended next-hop capability to the peer\n")
3853 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3854 PEER_FLAG_CAPABILITY_ENHE
);
3857 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3858 afi_t afi
, safi_t safi
, uint32_t flag
,
3864 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3866 return CMD_WARNING_CONFIG_FAILED
;
3869 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3871 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3873 return bgp_vty_return(vty
, ret
);
3876 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3877 afi_t afi
, safi_t safi
, uint32_t flag
)
3879 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3882 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3883 afi_t afi
, safi_t safi
, uint32_t flag
)
3885 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3888 /* neighbor capability orf prefix-list. */
3889 DEFUN (neighbor_capability_orf_prefix
,
3890 neighbor_capability_orf_prefix_cmd
,
3891 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3894 "Advertise capability to the peer\n"
3895 "Advertise ORF capability to the peer\n"
3896 "Advertise prefixlist ORF capability to this neighbor\n"
3897 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3898 "Capability to RECEIVE the ORF from this neighbor\n"
3899 "Capability to SEND the ORF to this neighbor\n")
3902 int idx_send_recv
= 5;
3905 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3906 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3907 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3908 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3909 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3910 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3912 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3913 return CMD_WARNING_CONFIG_FAILED
;
3916 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3917 bgp_node_safi(vty
), flag
);
3921 neighbor_capability_orf_prefix
,
3922 neighbor_capability_orf_prefix_hidden_cmd
,
3923 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3924 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3925 "Advertise capability to the peer\n"
3926 "Advertise ORF capability to the peer\n"
3927 "Advertise prefixlist ORF capability to this neighbor\n"
3928 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3929 "Capability to RECEIVE the ORF from this neighbor\n"
3930 "Capability to SEND the ORF to this neighbor\n")
3932 DEFUN (no_neighbor_capability_orf_prefix
,
3933 no_neighbor_capability_orf_prefix_cmd
,
3934 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3938 "Advertise capability to the peer\n"
3939 "Advertise ORF capability to the peer\n"
3940 "Advertise prefixlist ORF capability to this neighbor\n"
3941 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3942 "Capability to RECEIVE the ORF from this neighbor\n"
3943 "Capability to SEND the ORF to this neighbor\n")
3946 int idx_send_recv
= 6;
3949 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3950 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3951 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3952 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3953 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3954 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3956 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3957 return CMD_WARNING_CONFIG_FAILED
;
3960 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3961 bgp_node_afi(vty
), bgp_node_safi(vty
),
3966 no_neighbor_capability_orf_prefix
,
3967 no_neighbor_capability_orf_prefix_hidden_cmd
,
3968 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3969 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3970 "Advertise capability to the peer\n"
3971 "Advertise ORF capability to the peer\n"
3972 "Advertise prefixlist ORF capability to this neighbor\n"
3973 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3974 "Capability to RECEIVE the ORF from this neighbor\n"
3975 "Capability to SEND the ORF to this neighbor\n")
3977 /* neighbor next-hop-self. */
3978 DEFUN (neighbor_nexthop_self
,
3979 neighbor_nexthop_self_cmd
,
3980 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3983 "Disable the next hop calculation for this neighbor\n")
3986 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3987 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3990 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3991 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3992 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3993 "Disable the next hop calculation for this neighbor\n")
3995 /* neighbor next-hop-self. */
3996 DEFUN (neighbor_nexthop_self_force
,
3997 neighbor_nexthop_self_force_cmd
,
3998 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4001 "Disable the next hop calculation for this neighbor\n"
4002 "Set the next hop to self for reflected routes\n")
4005 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4007 PEER_FLAG_FORCE_NEXTHOP_SELF
);
4010 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
4011 neighbor_nexthop_self_force_hidden_cmd
,
4012 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4013 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4014 "Disable the next hop calculation for this neighbor\n"
4015 "Set the next hop to self for reflected routes\n")
4017 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
4018 neighbor_nexthop_self_all_hidden_cmd
,
4019 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
4020 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4021 "Disable the next hop calculation for this neighbor\n"
4022 "Set the next hop to self for reflected routes\n")
4024 DEFUN (no_neighbor_nexthop_self
,
4025 no_neighbor_nexthop_self_cmd
,
4026 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4030 "Disable the next hop calculation for this neighbor\n")
4033 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4034 bgp_node_afi(vty
), bgp_node_safi(vty
),
4035 PEER_FLAG_NEXTHOP_SELF
);
4038 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
4039 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
4040 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4041 "Disable the next hop calculation for this neighbor\n")
4043 DEFUN (no_neighbor_nexthop_self_force
,
4044 no_neighbor_nexthop_self_force_cmd
,
4045 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4049 "Disable the next hop calculation for this neighbor\n"
4050 "Set the next hop to self for reflected routes\n")
4053 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4054 bgp_node_afi(vty
), bgp_node_safi(vty
),
4055 PEER_FLAG_FORCE_NEXTHOP_SELF
);
4058 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4059 no_neighbor_nexthop_self_force_hidden_cmd
,
4060 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
4061 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4062 "Disable the next hop calculation for this neighbor\n"
4063 "Set the next hop to self for reflected routes\n")
4065 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
4066 no_neighbor_nexthop_self_all_hidden_cmd
,
4067 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self all",
4068 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4069 "Disable the next hop calculation for this neighbor\n"
4070 "Set the next hop to self for reflected routes\n")
4072 /* neighbor as-override */
4073 DEFUN (neighbor_as_override
,
4074 neighbor_as_override_cmd
,
4075 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4078 "Override ASNs in outbound updates if aspath equals remote-as\n")
4081 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4082 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
4085 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
4086 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4087 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4088 "Override ASNs in outbound updates if aspath equals remote-as\n")
4090 DEFUN (no_neighbor_as_override
,
4091 no_neighbor_as_override_cmd
,
4092 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4096 "Override ASNs in outbound updates if aspath equals remote-as\n")
4099 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4100 bgp_node_afi(vty
), bgp_node_safi(vty
),
4101 PEER_FLAG_AS_OVERRIDE
);
4104 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
4105 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
4106 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4107 "Override ASNs in outbound updates if aspath equals remote-as\n")
4109 /* neighbor remove-private-AS. */
4110 DEFUN (neighbor_remove_private_as
,
4111 neighbor_remove_private_as_cmd
,
4112 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4115 "Remove private ASNs in outbound updates\n")
4118 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4120 PEER_FLAG_REMOVE_PRIVATE_AS
);
4123 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
4124 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4125 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4126 "Remove private ASNs in outbound updates\n")
4128 DEFUN (neighbor_remove_private_as_all
,
4129 neighbor_remove_private_as_all_cmd
,
4130 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4133 "Remove private ASNs in outbound updates\n"
4134 "Apply to all AS numbers\n")
4137 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4139 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4142 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
4143 neighbor_remove_private_as_all_hidden_cmd
,
4144 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4145 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4146 "Remove private ASNs in outbound updates\n"
4147 "Apply to all AS numbers")
4149 DEFUN (neighbor_remove_private_as_replace_as
,
4150 neighbor_remove_private_as_replace_as_cmd
,
4151 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4154 "Remove private ASNs in outbound updates\n"
4155 "Replace private ASNs with our ASN in outbound updates\n")
4158 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4160 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4163 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
4164 neighbor_remove_private_as_replace_as_hidden_cmd
,
4165 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4166 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4167 "Remove private ASNs in outbound updates\n"
4168 "Replace private ASNs with our ASN in outbound updates\n")
4170 DEFUN (neighbor_remove_private_as_all_replace_as
,
4171 neighbor_remove_private_as_all_replace_as_cmd
,
4172 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4175 "Remove private ASNs in outbound updates\n"
4176 "Apply to all AS numbers\n"
4177 "Replace private ASNs with our ASN in outbound updates\n")
4180 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4182 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4186 neighbor_remove_private_as_all_replace_as
,
4187 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4188 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4189 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4190 "Remove private ASNs in outbound updates\n"
4191 "Apply to all AS numbers\n"
4192 "Replace private ASNs with our ASN in outbound updates\n")
4194 DEFUN (no_neighbor_remove_private_as
,
4195 no_neighbor_remove_private_as_cmd
,
4196 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4200 "Remove private ASNs in outbound updates\n")
4203 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4204 bgp_node_afi(vty
), bgp_node_safi(vty
),
4205 PEER_FLAG_REMOVE_PRIVATE_AS
);
4208 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4209 no_neighbor_remove_private_as_hidden_cmd
,
4210 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4211 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4212 "Remove private ASNs in outbound updates\n")
4214 DEFUN (no_neighbor_remove_private_as_all
,
4215 no_neighbor_remove_private_as_all_cmd
,
4216 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4220 "Remove private ASNs in outbound updates\n"
4221 "Apply to all AS numbers\n")
4224 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4225 bgp_node_afi(vty
), bgp_node_safi(vty
),
4226 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4229 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4230 no_neighbor_remove_private_as_all_hidden_cmd
,
4231 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4232 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4233 "Remove private ASNs in outbound updates\n"
4234 "Apply to all AS numbers\n")
4236 DEFUN (no_neighbor_remove_private_as_replace_as
,
4237 no_neighbor_remove_private_as_replace_as_cmd
,
4238 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4242 "Remove private ASNs in outbound updates\n"
4243 "Replace private ASNs with our ASN in outbound updates\n")
4246 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4247 bgp_node_afi(vty
), bgp_node_safi(vty
),
4248 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4251 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4252 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4253 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4254 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4255 "Remove private ASNs in outbound updates\n"
4256 "Replace private ASNs with our ASN in outbound updates\n")
4258 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4259 no_neighbor_remove_private_as_all_replace_as_cmd
,
4260 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4264 "Remove private ASNs in outbound updates\n"
4265 "Apply to all AS numbers\n"
4266 "Replace private ASNs with our ASN in outbound updates\n")
4269 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4270 bgp_node_afi(vty
), bgp_node_safi(vty
),
4271 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4275 no_neighbor_remove_private_as_all_replace_as
,
4276 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4277 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4278 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4279 "Remove private ASNs in outbound updates\n"
4280 "Apply to all AS numbers\n"
4281 "Replace private ASNs with our ASN in outbound updates\n")
4284 /* neighbor send-community. */
4285 DEFUN (neighbor_send_community
,
4286 neighbor_send_community_cmd
,
4287 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4290 "Send Community attribute to this neighbor\n")
4294 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4296 PEER_FLAG_SEND_COMMUNITY
);
4299 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4300 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4301 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4302 "Send Community attribute to this neighbor\n")
4304 DEFUN (no_neighbor_send_community
,
4305 no_neighbor_send_community_cmd
,
4306 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4310 "Send Community attribute to this neighbor\n")
4314 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4315 bgp_node_afi(vty
), bgp_node_safi(vty
),
4316 PEER_FLAG_SEND_COMMUNITY
);
4319 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4320 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4321 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4322 "Send Community attribute to this neighbor\n")
4324 /* neighbor send-community extended. */
4325 DEFUN (neighbor_send_community_type
,
4326 neighbor_send_community_type_cmd
,
4327 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4330 "Send Community attribute to this neighbor\n"
4331 "Send Standard and Extended Community attributes\n"
4332 "Send Standard, Large and Extended Community attributes\n"
4333 "Send Extended Community attributes\n"
4334 "Send Standard Community attributes\n"
4335 "Send Large Community attributes\n")
4339 const char *type
= argv
[argc
- 1]->text
;
4341 if (strmatch(type
, "standard")) {
4342 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4343 } else if (strmatch(type
, "extended")) {
4344 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4345 } else if (strmatch(type
, "large")) {
4346 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4347 } else if (strmatch(type
, "both")) {
4348 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4349 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4350 } else { /* if (strmatch(type, "all")) */
4351 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4352 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4353 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4356 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4357 bgp_node_safi(vty
), flag
);
4361 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4362 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4363 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4364 "Send Community attribute to this neighbor\n"
4365 "Send Standard and Extended Community attributes\n"
4366 "Send Standard, Large and Extended Community attributes\n"
4367 "Send Extended Community attributes\n"
4368 "Send Standard Community attributes\n"
4369 "Send Large Community attributes\n")
4371 DEFUN (no_neighbor_send_community_type
,
4372 no_neighbor_send_community_type_cmd
,
4373 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4377 "Send Community attribute to this neighbor\n"
4378 "Send Standard and Extended Community attributes\n"
4379 "Send Standard, Large and Extended Community attributes\n"
4380 "Send Extended Community attributes\n"
4381 "Send Standard Community attributes\n"
4382 "Send Large Community attributes\n")
4386 const char *type
= argv
[argc
- 1]->text
;
4388 if (strmatch(type
, "standard")) {
4389 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4390 } else if (strmatch(type
, "extended")) {
4391 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4392 } else if (strmatch(type
, "large")) {
4393 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4394 } else if (strmatch(type
, "both")) {
4395 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4396 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4397 } else { /* if (strmatch(type, "all")) */
4398 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4399 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4400 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4403 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4404 bgp_node_afi(vty
), bgp_node_safi(vty
),
4409 no_neighbor_send_community_type
,
4410 no_neighbor_send_community_type_hidden_cmd
,
4411 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4412 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4413 "Send Community attribute to this neighbor\n"
4414 "Send Standard and Extended Community attributes\n"
4415 "Send Standard, Large and Extended Community attributes\n"
4416 "Send Extended Community attributes\n"
4417 "Send Standard Community attributes\n"
4418 "Send Large Community attributes\n")
4420 /* neighbor soft-reconfig. */
4421 DEFUN (neighbor_soft_reconfiguration
,
4422 neighbor_soft_reconfiguration_cmd
,
4423 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4426 "Per neighbor soft reconfiguration\n"
4427 "Allow inbound soft reconfiguration for this neighbor\n")
4430 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4432 PEER_FLAG_SOFT_RECONFIG
);
4435 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4436 neighbor_soft_reconfiguration_hidden_cmd
,
4437 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4438 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4439 "Per neighbor soft reconfiguration\n"
4440 "Allow inbound soft reconfiguration for this neighbor\n")
4442 DEFUN (no_neighbor_soft_reconfiguration
,
4443 no_neighbor_soft_reconfiguration_cmd
,
4444 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4448 "Per neighbor soft reconfiguration\n"
4449 "Allow inbound soft reconfiguration for this neighbor\n")
4452 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4453 bgp_node_afi(vty
), bgp_node_safi(vty
),
4454 PEER_FLAG_SOFT_RECONFIG
);
4457 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4458 no_neighbor_soft_reconfiguration_hidden_cmd
,
4459 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4460 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4461 "Per neighbor soft reconfiguration\n"
4462 "Allow inbound soft reconfiguration for this neighbor\n")
4464 DEFUN (neighbor_route_reflector_client
,
4465 neighbor_route_reflector_client_cmd
,
4466 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4469 "Configure a neighbor as Route Reflector client\n")
4475 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4477 return CMD_WARNING_CONFIG_FAILED
;
4479 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4481 PEER_FLAG_REFLECTOR_CLIENT
);
4484 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4485 neighbor_route_reflector_client_hidden_cmd
,
4486 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4487 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4488 "Configure a neighbor as Route Reflector client\n")
4490 DEFUN (no_neighbor_route_reflector_client
,
4491 no_neighbor_route_reflector_client_cmd
,
4492 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4496 "Configure a neighbor as Route Reflector client\n")
4499 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4500 bgp_node_afi(vty
), bgp_node_safi(vty
),
4501 PEER_FLAG_REFLECTOR_CLIENT
);
4504 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4505 no_neighbor_route_reflector_client_hidden_cmd
,
4506 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4507 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4508 "Configure a neighbor as Route Reflector client\n")
4510 /* neighbor route-server-client. */
4511 DEFUN (neighbor_route_server_client
,
4512 neighbor_route_server_client_cmd
,
4513 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4516 "Configure a neighbor as Route Server client\n")
4521 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4523 return CMD_WARNING_CONFIG_FAILED
;
4524 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4526 PEER_FLAG_RSERVER_CLIENT
);
4529 ALIAS_HIDDEN(neighbor_route_server_client
,
4530 neighbor_route_server_client_hidden_cmd
,
4531 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4532 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4533 "Configure a neighbor as Route Server client\n")
4535 DEFUN (no_neighbor_route_server_client
,
4536 no_neighbor_route_server_client_cmd
,
4537 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4541 "Configure a neighbor as Route Server client\n")
4544 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4545 bgp_node_afi(vty
), bgp_node_safi(vty
),
4546 PEER_FLAG_RSERVER_CLIENT
);
4549 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4550 no_neighbor_route_server_client_hidden_cmd
,
4551 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4552 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4553 "Configure a neighbor as Route Server client\n")
4555 DEFUN (neighbor_nexthop_local_unchanged
,
4556 neighbor_nexthop_local_unchanged_cmd
,
4557 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4560 "Configure treatment of outgoing link-local nexthop attribute\n"
4561 "Leave link-local nexthop unchanged for this peer\n")
4564 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4566 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4569 DEFUN (no_neighbor_nexthop_local_unchanged
,
4570 no_neighbor_nexthop_local_unchanged_cmd
,
4571 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4575 "Configure treatment of outgoing link-local-nexthop attribute\n"
4576 "Leave link-local nexthop unchanged for this peer\n")
4579 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4580 bgp_node_afi(vty
), bgp_node_safi(vty
),
4581 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4584 DEFUN (neighbor_attr_unchanged
,
4585 neighbor_attr_unchanged_cmd
,
4586 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4589 "BGP attribute is propagated unchanged to this neighbor\n"
4590 "As-path attribute\n"
4591 "Nexthop attribute\n"
4595 char *peer_str
= argv
[1]->arg
;
4598 afi_t afi
= bgp_node_afi(vty
);
4599 safi_t safi
= bgp_node_safi(vty
);
4601 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4603 return CMD_WARNING_CONFIG_FAILED
;
4605 if (argv_find(argv
, argc
, "as-path", &idx
))
4606 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4608 if (argv_find(argv
, argc
, "next-hop", &idx
))
4609 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4611 if (argv_find(argv
, argc
, "med", &idx
))
4612 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4614 /* no flags means all of them! */
4616 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4617 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4618 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4620 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4621 && peer_af_flag_check(peer
, afi
, safi
,
4622 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4623 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4624 PEER_FLAG_AS_PATH_UNCHANGED
);
4627 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4628 && peer_af_flag_check(peer
, afi
, safi
,
4629 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4630 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4631 PEER_FLAG_NEXTHOP_UNCHANGED
);
4634 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4635 && peer_af_flag_check(peer
, afi
, safi
,
4636 PEER_FLAG_MED_UNCHANGED
)) {
4637 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4638 PEER_FLAG_MED_UNCHANGED
);
4642 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4646 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4647 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4648 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4649 "BGP attribute is propagated unchanged to this neighbor\n"
4650 "As-path attribute\n"
4651 "Nexthop attribute\n"
4654 DEFUN (no_neighbor_attr_unchanged
,
4655 no_neighbor_attr_unchanged_cmd
,
4656 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4660 "BGP attribute is propagated unchanged to this neighbor\n"
4661 "As-path attribute\n"
4662 "Nexthop attribute\n"
4666 char *peer
= argv
[2]->arg
;
4669 if (argv_find(argv
, argc
, "as-path", &idx
))
4670 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4672 if (argv_find(argv
, argc
, "next-hop", &idx
))
4673 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4675 if (argv_find(argv
, argc
, "med", &idx
))
4676 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4678 if (!flags
) // no flags means all of them!
4680 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4681 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4682 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4685 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4686 bgp_node_safi(vty
), flags
);
4690 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4691 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4692 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4693 "BGP attribute is propagated unchanged to this neighbor\n"
4694 "As-path attribute\n"
4695 "Nexthop attribute\n"
4698 /* EBGP multihop configuration. */
4699 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4700 const char *ttl_str
)
4705 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4707 return CMD_WARNING_CONFIG_FAILED
;
4710 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4715 ttl
= strtoul(ttl_str
, NULL
, 10);
4717 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4720 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4724 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4726 return CMD_WARNING_CONFIG_FAILED
;
4728 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4731 /* neighbor ebgp-multihop. */
4732 DEFUN (neighbor_ebgp_multihop
,
4733 neighbor_ebgp_multihop_cmd
,
4734 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4737 "Allow EBGP neighbors not on directly connected networks\n")
4740 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4743 DEFUN (neighbor_ebgp_multihop_ttl
,
4744 neighbor_ebgp_multihop_ttl_cmd
,
4745 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4748 "Allow EBGP neighbors not on directly connected networks\n"
4749 "maximum hop count\n")
4753 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4754 argv
[idx_number
]->arg
);
4757 DEFUN (no_neighbor_ebgp_multihop
,
4758 no_neighbor_ebgp_multihop_cmd
,
4759 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4763 "Allow EBGP neighbors not on directly connected networks\n"
4764 "maximum hop count\n")
4767 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4771 /* disable-connected-check */
4772 DEFUN (neighbor_disable_connected_check
,
4773 neighbor_disable_connected_check_cmd
,
4774 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4777 "one-hop away EBGP peer using loopback address\n"
4778 "Enforce EBGP neighbors perform multihop\n")
4781 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4782 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4785 DEFUN (no_neighbor_disable_connected_check
,
4786 no_neighbor_disable_connected_check_cmd
,
4787 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4791 "one-hop away EBGP peer using loopback address\n"
4792 "Enforce EBGP neighbors perform multihop\n")
4795 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4796 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4800 /* enforce-first-as */
4801 DEFUN (neighbor_enforce_first_as
,
4802 neighbor_enforce_first_as_cmd
,
4803 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4806 "Enforce the first AS for EBGP routes\n")
4810 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4811 PEER_FLAG_ENFORCE_FIRST_AS
);
4814 DEFUN (no_neighbor_enforce_first_as
,
4815 no_neighbor_enforce_first_as_cmd
,
4816 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4820 "Enforce the first AS for EBGP routes\n")
4824 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4825 PEER_FLAG_ENFORCE_FIRST_AS
);
4829 DEFUN (neighbor_description
,
4830 neighbor_description_cmd
,
4831 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4834 "Neighbor specific description\n"
4835 "Up to 80 characters describing this neighbor\n")
4842 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4844 return CMD_WARNING_CONFIG_FAILED
;
4846 str
= argv_concat(argv
, argc
, idx_line
);
4848 peer_description_set(peer
, str
);
4850 XFREE(MTYPE_TMP
, str
);
4855 DEFUN (no_neighbor_description
,
4856 no_neighbor_description_cmd
,
4857 "no neighbor <A.B.C.D|X:X::X:X|WORD> description",
4861 "Neighbor specific description\n")
4866 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4868 return CMD_WARNING_CONFIG_FAILED
;
4870 peer_description_unset(peer
);
4875 ALIAS(no_neighbor_description
, no_neighbor_description_comment_cmd
,
4876 "no neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4877 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4878 "Neighbor specific description\n"
4879 "Up to 80 characters describing this neighbor\n")
4881 /* Neighbor update-source. */
4882 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4883 const char *source_str
)
4889 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4891 return CMD_WARNING_CONFIG_FAILED
;
4897 if (str2sockunion(source_str
, &su
) == 0)
4898 peer_update_source_addr_set(peer
, &su
);
4900 if (str2prefix(source_str
, &p
)) {
4902 "%% Invalid update-source, remove prefix length \n");
4903 return CMD_WARNING_CONFIG_FAILED
;
4905 peer_update_source_if_set(peer
, source_str
);
4908 peer_update_source_unset(peer
);
4913 #define BGP_UPDATE_SOURCE_HELP_STR \
4916 "Interface name (requires zebra to be running)\n"
4918 DEFUN (neighbor_update_source
,
4919 neighbor_update_source_cmd
,
4920 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4923 "Source of routing updates\n"
4924 BGP_UPDATE_SOURCE_HELP_STR
)
4928 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4929 argv
[idx_peer_2
]->arg
);
4932 DEFUN (no_neighbor_update_source
,
4933 no_neighbor_update_source_cmd
,
4934 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4938 "Source of routing updates\n"
4939 BGP_UPDATE_SOURCE_HELP_STR
)
4942 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4945 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4946 afi_t afi
, safi_t safi
,
4947 const char *rmap
, int set
)
4951 struct route_map
*route_map
= NULL
;
4953 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4955 return CMD_WARNING_CONFIG_FAILED
;
4959 route_map
= route_map_lookup_warn_noexist(vty
, rmap
);
4960 ret
= peer_default_originate_set(peer
, afi
, safi
,
4963 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4965 return bgp_vty_return(vty
, ret
);
4968 /* neighbor default-originate. */
4969 DEFUN (neighbor_default_originate
,
4970 neighbor_default_originate_cmd
,
4971 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4974 "Originate default route to this neighbor\n")
4977 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4979 bgp_node_safi(vty
), NULL
, 1);
4982 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4983 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4984 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4985 "Originate default route to this neighbor\n")
4987 DEFUN (neighbor_default_originate_rmap
,
4988 neighbor_default_originate_rmap_cmd
,
4989 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4992 "Originate default route to this neighbor\n"
4993 "Route-map to specify criteria to originate default\n"
4998 return peer_default_originate_set_vty(
4999 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5000 argv
[idx_word
]->arg
, 1);
5004 neighbor_default_originate_rmap
,
5005 neighbor_default_originate_rmap_hidden_cmd
,
5006 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
5007 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5008 "Originate default route to this neighbor\n"
5009 "Route-map to specify criteria to originate default\n"
5012 DEFUN (no_neighbor_default_originate
,
5013 no_neighbor_default_originate_cmd
,
5014 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
5018 "Originate default route to this neighbor\n"
5019 "Route-map to specify criteria to originate default\n"
5023 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
5025 bgp_node_safi(vty
), NULL
, 0);
5029 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
5030 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
5031 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5032 "Originate default route to this neighbor\n"
5033 "Route-map to specify criteria to originate default\n"
5037 /* Set neighbor's BGP port. */
5038 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
5039 const char *port_str
)
5045 peer
= peer_lookup_vty(vty
, ip_str
);
5047 return CMD_WARNING_CONFIG_FAILED
;
5050 sp
= getservbyname("bgp", "tcp");
5051 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
5053 port
= strtoul(port_str
, NULL
, 10);
5056 peer_port_set(peer
, port
);
5061 /* Set specified peer's BGP port. */
5062 DEFUN (neighbor_port
,
5064 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
5067 "Neighbor's BGP port\n"
5068 "TCP port number\n")
5072 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
5073 argv
[idx_number
]->arg
);
5076 DEFUN (no_neighbor_port
,
5077 no_neighbor_port_cmd
,
5078 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
5082 "Neighbor's BGP port\n"
5083 "TCP port number\n")
5086 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
5090 /* neighbor weight. */
5091 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5092 safi_t safi
, const char *weight_str
)
5096 unsigned long weight
;
5098 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5100 return CMD_WARNING_CONFIG_FAILED
;
5102 weight
= strtoul(weight_str
, NULL
, 10);
5104 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
5105 return bgp_vty_return(vty
, ret
);
5108 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5114 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5116 return CMD_WARNING_CONFIG_FAILED
;
5118 ret
= peer_weight_unset(peer
, afi
, safi
);
5119 return bgp_vty_return(vty
, ret
);
5122 DEFUN (neighbor_weight
,
5123 neighbor_weight_cmd
,
5124 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5127 "Set default weight for routes from this neighbor\n"
5132 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5133 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
5136 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
5137 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
5138 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5139 "Set default weight for routes from this neighbor\n"
5142 DEFUN (no_neighbor_weight
,
5143 no_neighbor_weight_cmd
,
5144 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5148 "Set default weight for routes from this neighbor\n"
5152 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
5153 bgp_node_afi(vty
), bgp_node_safi(vty
));
5156 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
5157 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
5158 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5159 "Set default weight for routes from this neighbor\n"
5163 /* Override capability negotiation. */
5164 DEFUN (neighbor_override_capability
,
5165 neighbor_override_capability_cmd
,
5166 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5169 "Override capability negotiation result\n")
5172 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5173 PEER_FLAG_OVERRIDE_CAPABILITY
);
5176 DEFUN (no_neighbor_override_capability
,
5177 no_neighbor_override_capability_cmd
,
5178 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
5182 "Override capability negotiation result\n")
5185 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5186 PEER_FLAG_OVERRIDE_CAPABILITY
);
5189 DEFUN (neighbor_strict_capability
,
5190 neighbor_strict_capability_cmd
,
5191 "neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5194 "Strict capability negotiation match\n")
5198 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
5199 PEER_FLAG_STRICT_CAP_MATCH
);
5202 DEFUN (no_neighbor_strict_capability
,
5203 no_neighbor_strict_capability_cmd
,
5204 "no neighbor <A.B.C.D|X:X::X:X|WORD> strict-capability-match",
5208 "Strict capability negotiation match\n")
5212 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
5213 PEER_FLAG_STRICT_CAP_MATCH
);
5216 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5217 const char *keep_str
, const char *hold_str
)
5224 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5226 return CMD_WARNING_CONFIG_FAILED
;
5228 keepalive
= strtoul(keep_str
, NULL
, 10);
5229 holdtime
= strtoul(hold_str
, NULL
, 10);
5231 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5233 return bgp_vty_return(vty
, ret
);
5236 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5241 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5243 return CMD_WARNING_CONFIG_FAILED
;
5245 ret
= peer_timers_unset(peer
);
5247 return bgp_vty_return(vty
, ret
);
5250 DEFUN (neighbor_timers
,
5251 neighbor_timers_cmd
,
5252 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5255 "BGP per neighbor timers\n"
5256 "Keepalive interval\n"
5261 int idx_number_2
= 4;
5262 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5263 argv
[idx_number
]->arg
,
5264 argv
[idx_number_2
]->arg
);
5267 DEFUN (no_neighbor_timers
,
5268 no_neighbor_timers_cmd
,
5269 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5273 "BGP per neighbor timers\n"
5274 "Keepalive interval\n"
5278 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5282 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5283 const char *time_str
)
5289 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5291 return CMD_WARNING_CONFIG_FAILED
;
5293 connect
= strtoul(time_str
, NULL
, 10);
5295 ret
= peer_timers_connect_set(peer
, connect
);
5297 return bgp_vty_return(vty
, ret
);
5300 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5305 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5307 return CMD_WARNING_CONFIG_FAILED
;
5309 ret
= peer_timers_connect_unset(peer
);
5311 return bgp_vty_return(vty
, ret
);
5314 DEFUN (neighbor_timers_connect
,
5315 neighbor_timers_connect_cmd
,
5316 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5319 "BGP per neighbor timers\n"
5320 "BGP connect timer\n"
5325 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5326 argv
[idx_number
]->arg
);
5329 DEFUN (no_neighbor_timers_connect
,
5330 no_neighbor_timers_connect_cmd
,
5331 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5335 "BGP per neighbor timers\n"
5336 "BGP connect timer\n"
5340 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5344 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5345 const char *time_str
, int set
)
5349 uint32_t routeadv
= 0;
5351 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5353 return CMD_WARNING_CONFIG_FAILED
;
5356 routeadv
= strtoul(time_str
, NULL
, 10);
5359 ret
= peer_advertise_interval_set(peer
, routeadv
);
5361 ret
= peer_advertise_interval_unset(peer
);
5363 return bgp_vty_return(vty
, ret
);
5366 DEFUN (neighbor_advertise_interval
,
5367 neighbor_advertise_interval_cmd
,
5368 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5371 "Minimum interval between sending BGP routing updates\n"
5372 "time in seconds\n")
5376 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5377 argv
[idx_number
]->arg
, 1);
5380 DEFUN (no_neighbor_advertise_interval
,
5381 no_neighbor_advertise_interval_cmd
,
5382 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5386 "Minimum interval between sending BGP routing updates\n"
5387 "time in seconds\n")
5390 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5394 /* Time to wait before processing route-map updates */
5395 DEFUN (bgp_set_route_map_delay_timer
,
5396 bgp_set_route_map_delay_timer_cmd
,
5397 "bgp route-map delay-timer (0-600)",
5399 "BGP route-map delay timer\n"
5400 "Time in secs to wait before processing route-map changes\n"
5401 "0 disables the timer, no route updates happen when route-maps change\n")
5404 uint32_t rmap_delay_timer
;
5406 if (argv
[idx_number
]->arg
) {
5407 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5408 bm
->rmap_update_timer
= rmap_delay_timer
;
5410 /* if the dynamic update handling is being disabled, and a timer
5412 * running, stop the timer and act as if the timer has already
5415 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5416 BGP_TIMER_OFF(bm
->t_rmap_update
);
5417 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5422 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5423 return CMD_WARNING_CONFIG_FAILED
;
5427 DEFUN (no_bgp_set_route_map_delay_timer
,
5428 no_bgp_set_route_map_delay_timer_cmd
,
5429 "no bgp route-map delay-timer [(0-600)]",
5432 "Default BGP route-map delay timer\n"
5433 "Reset to default time to wait for processing route-map changes\n"
5434 "0 disables the timer, no route updates happen when route-maps change\n")
5437 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5443 /* neighbor interface */
5444 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5449 peer
= peer_lookup_vty(vty
, ip_str
);
5450 if (!peer
|| peer
->conf_if
) {
5451 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5452 return CMD_WARNING_CONFIG_FAILED
;
5456 peer_interface_set(peer
, str
);
5458 peer_interface_unset(peer
);
5463 DEFUN (neighbor_interface
,
5464 neighbor_interface_cmd
,
5465 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5473 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5476 DEFUN (no_neighbor_interface
,
5477 no_neighbor_interface_cmd
,
5478 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5486 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5489 DEFUN (neighbor_distribute_list
,
5490 neighbor_distribute_list_cmd
,
5491 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5494 "Filter updates to/from this neighbor\n"
5495 "IP access-list number\n"
5496 "IP access-list number (expanded range)\n"
5497 "IP Access-list name\n"
5498 "Filter incoming updates\n"
5499 "Filter outgoing updates\n")
5506 const char *pstr
= argv
[idx_peer
]->arg
;
5507 const char *acl
= argv
[idx_acl
]->arg
;
5508 const char *inout
= argv
[argc
- 1]->text
;
5510 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5512 return CMD_WARNING_CONFIG_FAILED
;
5514 /* Check filter direction. */
5515 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5516 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5519 return bgp_vty_return(vty
, ret
);
5523 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5524 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5525 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5526 "Filter updates to/from this neighbor\n"
5527 "IP access-list number\n"
5528 "IP access-list number (expanded range)\n"
5529 "IP Access-list name\n"
5530 "Filter incoming updates\n"
5531 "Filter outgoing updates\n")
5533 DEFUN (no_neighbor_distribute_list
,
5534 no_neighbor_distribute_list_cmd
,
5535 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5539 "Filter updates to/from this neighbor\n"
5540 "IP access-list number\n"
5541 "IP access-list number (expanded range)\n"
5542 "IP Access-list name\n"
5543 "Filter incoming updates\n"
5544 "Filter outgoing updates\n")
5550 const char *pstr
= argv
[idx_peer
]->arg
;
5551 const char *inout
= argv
[argc
- 1]->text
;
5553 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5555 return CMD_WARNING_CONFIG_FAILED
;
5557 /* Check filter direction. */
5558 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5559 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5562 return bgp_vty_return(vty
, ret
);
5566 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5567 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5568 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5569 "Filter updates to/from this neighbor\n"
5570 "IP access-list number\n"
5571 "IP access-list number (expanded range)\n"
5572 "IP Access-list name\n"
5573 "Filter incoming updates\n"
5574 "Filter outgoing updates\n")
5576 /* Set prefix list to the peer. */
5577 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5578 afi_t afi
, safi_t safi
,
5579 const char *name_str
,
5580 const char *direct_str
)
5583 int direct
= FILTER_IN
;
5586 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5588 return CMD_WARNING_CONFIG_FAILED
;
5590 /* Check filter direction. */
5591 if (strncmp(direct_str
, "i", 1) == 0)
5593 else if (strncmp(direct_str
, "o", 1) == 0)
5594 direct
= FILTER_OUT
;
5596 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5598 return bgp_vty_return(vty
, ret
);
5601 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5602 afi_t afi
, safi_t safi
,
5603 const char *direct_str
)
5607 int direct
= FILTER_IN
;
5609 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5611 return CMD_WARNING_CONFIG_FAILED
;
5613 /* Check filter direction. */
5614 if (strncmp(direct_str
, "i", 1) == 0)
5616 else if (strncmp(direct_str
, "o", 1) == 0)
5617 direct
= FILTER_OUT
;
5619 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5621 return bgp_vty_return(vty
, ret
);
5624 DEFUN (neighbor_prefix_list
,
5625 neighbor_prefix_list_cmd
,
5626 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5629 "Filter updates to/from this neighbor\n"
5630 "Name of a prefix list\n"
5631 "Filter incoming updates\n"
5632 "Filter outgoing updates\n")
5637 return peer_prefix_list_set_vty(
5638 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5639 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5642 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5643 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5644 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5645 "Filter updates to/from this neighbor\n"
5646 "Name of a prefix list\n"
5647 "Filter incoming updates\n"
5648 "Filter outgoing updates\n")
5650 DEFUN (no_neighbor_prefix_list
,
5651 no_neighbor_prefix_list_cmd
,
5652 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5656 "Filter updates to/from this neighbor\n"
5657 "Name of a prefix list\n"
5658 "Filter incoming updates\n"
5659 "Filter outgoing updates\n")
5663 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5664 bgp_node_afi(vty
), bgp_node_safi(vty
),
5665 argv
[idx_in_out
]->arg
);
5668 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5669 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5670 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5671 "Filter updates to/from this neighbor\n"
5672 "Name of a prefix list\n"
5673 "Filter incoming updates\n"
5674 "Filter outgoing updates\n")
5676 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5677 safi_t safi
, const char *name_str
,
5678 const char *direct_str
)
5682 int direct
= FILTER_IN
;
5684 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5686 return CMD_WARNING_CONFIG_FAILED
;
5688 /* Check filter direction. */
5689 if (strncmp(direct_str
, "i", 1) == 0)
5691 else if (strncmp(direct_str
, "o", 1) == 0)
5692 direct
= FILTER_OUT
;
5694 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5696 return bgp_vty_return(vty
, ret
);
5699 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5700 safi_t safi
, const char *direct_str
)
5704 int direct
= FILTER_IN
;
5706 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5708 return CMD_WARNING_CONFIG_FAILED
;
5710 /* Check filter direction. */
5711 if (strncmp(direct_str
, "i", 1) == 0)
5713 else if (strncmp(direct_str
, "o", 1) == 0)
5714 direct
= FILTER_OUT
;
5716 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5718 return bgp_vty_return(vty
, ret
);
5721 DEFUN (neighbor_filter_list
,
5722 neighbor_filter_list_cmd
,
5723 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5726 "Establish BGP filters\n"
5727 "AS path access-list name\n"
5728 "Filter incoming routes\n"
5729 "Filter outgoing routes\n")
5734 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5735 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5736 argv
[idx_in_out
]->arg
);
5739 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5740 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5741 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5742 "Establish BGP filters\n"
5743 "AS path access-list name\n"
5744 "Filter incoming routes\n"
5745 "Filter outgoing routes\n")
5747 DEFUN (no_neighbor_filter_list
,
5748 no_neighbor_filter_list_cmd
,
5749 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5753 "Establish BGP filters\n"
5754 "AS path access-list name\n"
5755 "Filter incoming routes\n"
5756 "Filter outgoing routes\n")
5760 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5761 bgp_node_afi(vty
), bgp_node_safi(vty
),
5762 argv
[idx_in_out
]->arg
);
5765 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5766 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5767 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5768 "Establish BGP filters\n"
5769 "AS path access-list name\n"
5770 "Filter incoming routes\n"
5771 "Filter outgoing routes\n")
5773 /* Set route-map to the peer. */
5774 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5775 afi_t afi
, safi_t safi
, const char *name_str
,
5776 const char *direct_str
)
5780 int direct
= RMAP_IN
;
5781 struct route_map
*route_map
;
5783 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5785 return CMD_WARNING_CONFIG_FAILED
;
5787 /* Check filter direction. */
5788 if (strncmp(direct_str
, "in", 2) == 0)
5790 else if (strncmp(direct_str
, "o", 1) == 0)
5793 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5794 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
, route_map
);
5796 return bgp_vty_return(vty
, ret
);
5799 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5800 afi_t afi
, safi_t safi
,
5801 const char *direct_str
)
5805 int direct
= RMAP_IN
;
5807 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5809 return CMD_WARNING_CONFIG_FAILED
;
5811 /* Check filter direction. */
5812 if (strncmp(direct_str
, "in", 2) == 0)
5814 else if (strncmp(direct_str
, "o", 1) == 0)
5817 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5819 return bgp_vty_return(vty
, ret
);
5822 DEFUN (neighbor_route_map
,
5823 neighbor_route_map_cmd
,
5824 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5827 "Apply route map to neighbor\n"
5828 "Name of route map\n"
5829 "Apply map to incoming routes\n"
5830 "Apply map to outbound routes\n")
5835 return peer_route_map_set_vty(
5836 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5837 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5840 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5841 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5842 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5843 "Apply route map to neighbor\n"
5844 "Name of route map\n"
5845 "Apply map to incoming routes\n"
5846 "Apply map to outbound routes\n")
5848 DEFUN (no_neighbor_route_map
,
5849 no_neighbor_route_map_cmd
,
5850 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5854 "Apply route map to neighbor\n"
5855 "Name of route map\n"
5856 "Apply map to incoming routes\n"
5857 "Apply map to outbound routes\n")
5861 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5862 bgp_node_afi(vty
), bgp_node_safi(vty
),
5863 argv
[idx_in_out
]->arg
);
5866 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5867 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5868 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5869 "Apply route map to neighbor\n"
5870 "Name of route map\n"
5871 "Apply map to incoming routes\n"
5872 "Apply map to outbound routes\n")
5874 /* Set unsuppress-map to the peer. */
5875 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5876 afi_t afi
, safi_t safi
,
5877 const char *name_str
)
5881 struct route_map
*route_map
;
5883 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5885 return CMD_WARNING_CONFIG_FAILED
;
5887 route_map
= route_map_lookup_warn_noexist(vty
, name_str
);
5888 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
, route_map
);
5890 return bgp_vty_return(vty
, ret
);
5893 /* Unset route-map from the peer. */
5894 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5895 afi_t afi
, safi_t safi
)
5900 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5902 return CMD_WARNING_CONFIG_FAILED
;
5904 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5906 return bgp_vty_return(vty
, ret
);
5909 DEFUN (neighbor_unsuppress_map
,
5910 neighbor_unsuppress_map_cmd
,
5911 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5914 "Route-map to selectively unsuppress suppressed routes\n"
5915 "Name of route map\n")
5919 return peer_unsuppress_map_set_vty(
5920 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5921 argv
[idx_word
]->arg
);
5924 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5925 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5926 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5927 "Route-map to selectively unsuppress suppressed routes\n"
5928 "Name of route map\n")
5930 DEFUN (no_neighbor_unsuppress_map
,
5931 no_neighbor_unsuppress_map_cmd
,
5932 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5936 "Route-map to selectively unsuppress suppressed routes\n"
5937 "Name of route map\n")
5940 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5942 bgp_node_safi(vty
));
5945 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5946 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5947 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5948 "Route-map to selectively unsuppress suppressed routes\n"
5949 "Name of route map\n")
5951 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5952 afi_t afi
, safi_t safi
,
5953 const char *num_str
,
5954 const char *threshold_str
, int warning
,
5955 const char *restart_str
)
5963 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5965 return CMD_WARNING_CONFIG_FAILED
;
5967 max
= strtoul(num_str
, NULL
, 10);
5969 threshold
= atoi(threshold_str
);
5971 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5974 restart
= atoi(restart_str
);
5978 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5981 return bgp_vty_return(vty
, ret
);
5984 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5985 afi_t afi
, safi_t safi
)
5990 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5992 return CMD_WARNING_CONFIG_FAILED
;
5994 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5996 return bgp_vty_return(vty
, ret
);
5999 /* Maximum number of prefix configuration. prefix count is different
6000 for each peer configuration. So this configuration can be set for
6001 each peer configuration. */
6002 DEFUN (neighbor_maximum_prefix
,
6003 neighbor_maximum_prefix_cmd
,
6004 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
6007 "Maximum number of prefix accept from this peer\n"
6008 "maximum no. of prefix limit\n")
6012 return peer_maximum_prefix_set_vty(
6013 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6014 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
6017 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
6018 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
6019 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6020 "Maximum number of prefix accept from this peer\n"
6021 "maximum no. of prefix limit\n")
6023 DEFUN (neighbor_maximum_prefix_threshold
,
6024 neighbor_maximum_prefix_threshold_cmd
,
6025 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
6028 "Maximum number of prefix accept from this peer\n"
6029 "maximum no. of prefix limit\n"
6030 "Threshold value (%) at which to generate a warning msg\n")
6034 int idx_number_2
= 4;
6035 return peer_maximum_prefix_set_vty(
6036 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6037 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
6041 neighbor_maximum_prefix_threshold
,
6042 neighbor_maximum_prefix_threshold_hidden_cmd
,
6043 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
6044 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6045 "Maximum number of prefix accept from this peer\n"
6046 "maximum no. of prefix limit\n"
6047 "Threshold value (%) at which to generate a warning msg\n")
6049 DEFUN (neighbor_maximum_prefix_warning
,
6050 neighbor_maximum_prefix_warning_cmd
,
6051 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6054 "Maximum number of prefix accept from this peer\n"
6055 "maximum no. of prefix limit\n"
6056 "Only give warning message when limit is exceeded\n")
6060 return peer_maximum_prefix_set_vty(
6061 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6062 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
6066 neighbor_maximum_prefix_warning
,
6067 neighbor_maximum_prefix_warning_hidden_cmd
,
6068 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
6069 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6070 "Maximum number of prefix accept from this peer\n"
6071 "maximum no. of prefix limit\n"
6072 "Only give warning message when limit is exceeded\n")
6074 DEFUN (neighbor_maximum_prefix_threshold_warning
,
6075 neighbor_maximum_prefix_threshold_warning_cmd
,
6076 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6079 "Maximum number of prefix accept from this peer\n"
6080 "maximum no. of prefix limit\n"
6081 "Threshold value (%) at which to generate a warning msg\n"
6082 "Only give warning message when limit is exceeded\n")
6086 int idx_number_2
= 4;
6087 return peer_maximum_prefix_set_vty(
6088 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6089 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
6093 neighbor_maximum_prefix_threshold_warning
,
6094 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
6095 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
6096 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6097 "Maximum number of prefix accept from this peer\n"
6098 "maximum no. of prefix limit\n"
6099 "Threshold value (%) at which to generate a warning msg\n"
6100 "Only give warning message when limit is exceeded\n")
6102 DEFUN (neighbor_maximum_prefix_restart
,
6103 neighbor_maximum_prefix_restart_cmd
,
6104 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6107 "Maximum number of prefix accept from this peer\n"
6108 "maximum no. of prefix limit\n"
6109 "Restart bgp connection after limit is exceeded\n"
6110 "Restart interval in minutes\n")
6114 int idx_number_2
= 5;
6115 return peer_maximum_prefix_set_vty(
6116 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6117 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
6121 neighbor_maximum_prefix_restart
,
6122 neighbor_maximum_prefix_restart_hidden_cmd
,
6123 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
6124 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6125 "Maximum number of prefix accept from this peer\n"
6126 "maximum no. of prefix limit\n"
6127 "Restart bgp connection after limit is exceeded\n"
6128 "Restart interval in minutes\n")
6130 DEFUN (neighbor_maximum_prefix_threshold_restart
,
6131 neighbor_maximum_prefix_threshold_restart_cmd
,
6132 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6135 "Maximum number of prefixes to accept from this peer\n"
6136 "maximum no. of prefix limit\n"
6137 "Threshold value (%) at which to generate a warning msg\n"
6138 "Restart bgp connection after limit is exceeded\n"
6139 "Restart interval in minutes\n")
6143 int idx_number_2
= 4;
6144 int idx_number_3
= 6;
6145 return peer_maximum_prefix_set_vty(
6146 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6147 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
6148 argv
[idx_number_3
]->arg
);
6152 neighbor_maximum_prefix_threshold_restart
,
6153 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
6154 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
6155 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6156 "Maximum number of prefixes to accept from this peer\n"
6157 "maximum no. of prefix limit\n"
6158 "Threshold value (%) at which to generate a warning msg\n"
6159 "Restart bgp connection after limit is exceeded\n"
6160 "Restart interval in minutes\n")
6162 DEFUN (no_neighbor_maximum_prefix
,
6163 no_neighbor_maximum_prefix_cmd
,
6164 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6168 "Maximum number of prefixes to accept from this peer\n"
6169 "maximum no. of prefix limit\n"
6170 "Threshold value (%) at which to generate a warning msg\n"
6171 "Restart bgp connection after limit is exceeded\n"
6172 "Restart interval in minutes\n"
6173 "Only give warning message when limit is exceeded\n")
6176 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
6178 bgp_node_safi(vty
));
6182 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
6183 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
6184 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6185 "Maximum number of prefixes to accept from this peer\n"
6186 "maximum no. of prefix limit\n"
6187 "Threshold value (%) at which to generate a warning msg\n"
6188 "Restart bgp connection after limit is exceeded\n"
6189 "Restart interval in minutes\n"
6190 "Only give warning message when limit is exceeded\n")
6193 /* "neighbor allowas-in" */
6194 DEFUN (neighbor_allowas_in
,
6195 neighbor_allowas_in_cmd
,
6196 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6199 "Accept as-path with my AS present in it\n"
6200 "Number of occurrences of AS number\n"
6201 "Only accept my AS in the as-path if the route was originated in my AS\n")
6204 int idx_number_origin
= 3;
6210 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6212 return CMD_WARNING_CONFIG_FAILED
;
6214 if (argc
<= idx_number_origin
)
6217 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6220 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6223 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6226 return bgp_vty_return(vty
, ret
);
6230 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6231 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6232 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6233 "Accept as-path with my AS present in it\n"
6234 "Number of occurrences of AS number\n"
6235 "Only accept my AS in the as-path if the route was originated in my AS\n")
6237 DEFUN (no_neighbor_allowas_in
,
6238 no_neighbor_allowas_in_cmd
,
6239 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6243 "allow local ASN appears in aspath attribute\n"
6244 "Number of occurrences of AS number\n"
6245 "Only accept my AS in the as-path if the route was originated in my AS\n")
6251 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6253 return CMD_WARNING_CONFIG_FAILED
;
6255 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6256 bgp_node_safi(vty
));
6258 return bgp_vty_return(vty
, ret
);
6262 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6263 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6264 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6265 "allow local ASN appears in aspath attribute\n"
6266 "Number of occurrences of AS number\n"
6267 "Only accept my AS in the as-path if the route was originated in my AS\n")
6269 DEFUN (neighbor_ttl_security
,
6270 neighbor_ttl_security_cmd
,
6271 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6274 "BGP ttl-security parameters\n"
6275 "Specify the maximum number of hops to the BGP peer\n"
6276 "Number of hops to BGP peer\n")
6283 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6285 return CMD_WARNING_CONFIG_FAILED
;
6287 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6290 * If 'neighbor swpX', then this is for directly connected peers,
6291 * we should not accept a ttl-security hops value greater than 1.
6293 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6295 "%s is directly connected peer, hops cannot exceed 1\n",
6296 argv
[idx_peer
]->arg
);
6297 return CMD_WARNING_CONFIG_FAILED
;
6300 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6303 DEFUN (no_neighbor_ttl_security
,
6304 no_neighbor_ttl_security_cmd
,
6305 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6309 "BGP ttl-security parameters\n"
6310 "Specify the maximum number of hops to the BGP peer\n"
6311 "Number of hops to BGP peer\n")
6316 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6318 return CMD_WARNING_CONFIG_FAILED
;
6320 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6323 DEFUN (neighbor_addpath_tx_all_paths
,
6324 neighbor_addpath_tx_all_paths_cmd
,
6325 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6328 "Use addpath to advertise all paths to a neighbor\n")
6333 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6335 return CMD_WARNING_CONFIG_FAILED
;
6337 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6342 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6343 neighbor_addpath_tx_all_paths_hidden_cmd
,
6344 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6345 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6346 "Use addpath to advertise all paths to a neighbor\n")
6348 DEFUN (no_neighbor_addpath_tx_all_paths
,
6349 no_neighbor_addpath_tx_all_paths_cmd
,
6350 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6354 "Use addpath to advertise all paths to a neighbor\n")
6359 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6361 return CMD_WARNING_CONFIG_FAILED
;
6363 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6364 != BGP_ADDPATH_ALL
) {
6366 "%% Peer not currently configured to transmit all paths.");
6367 return CMD_WARNING_CONFIG_FAILED
;
6370 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6376 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6377 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6378 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6379 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6380 "Use addpath to advertise all paths to a neighbor\n")
6382 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6383 neighbor_addpath_tx_bestpath_per_as_cmd
,
6384 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6387 "Use addpath to advertise the bestpath per each neighboring AS\n")
6392 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6394 return CMD_WARNING_CONFIG_FAILED
;
6396 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6397 BGP_ADDPATH_BEST_PER_AS
);
6402 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6403 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6404 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6405 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6406 "Use addpath to advertise the bestpath per each neighboring AS\n")
6408 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6409 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6410 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6414 "Use addpath to advertise the bestpath per each neighboring AS\n")
6419 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6421 return CMD_WARNING_CONFIG_FAILED
;
6423 if (peer
->addpath_type
[bgp_node_afi(vty
)][bgp_node_safi(vty
)]
6424 != BGP_ADDPATH_BEST_PER_AS
) {
6426 "%% Peer not currently configured to transmit all best path per as.");
6427 return CMD_WARNING_CONFIG_FAILED
;
6430 bgp_addpath_set_peer_type(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6436 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6437 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6438 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6439 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6440 "Use addpath to advertise the bestpath per each neighboring AS\n")
6443 neighbor_aspath_loop_detection
, neighbor_aspath_loop_detection_cmd
,
6444 "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
6447 "Detect AS loops before sending to neighbor\n")
6451 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
6453 return CMD_WARNING_CONFIG_FAILED
;
6455 peer
->as_path_loop_detection
= true;
6461 no_neighbor_aspath_loop_detection
,
6462 no_neighbor_aspath_loop_detection_cmd
,
6463 "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
6467 "Detect AS loops before sending to neighbor\n")
6471 peer
= peer_and_group_lookup_vty(vty
, neighbor
);
6473 return CMD_WARNING_CONFIG_FAILED
;
6475 peer
->as_path_loop_detection
= false;
6480 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6481 struct ecommunity
**list
)
6483 struct ecommunity
*ecom
= NULL
;
6484 struct ecommunity
*ecomadd
;
6486 for (; argc
; --argc
, ++argv
) {
6488 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6489 ECOMMUNITY_ROUTE_TARGET
, 0);
6491 vty_out(vty
, "Malformed community-list value\n");
6493 ecommunity_free(&ecom
);
6494 return CMD_WARNING_CONFIG_FAILED
;
6498 ecommunity_merge(ecom
, ecomadd
);
6499 ecommunity_free(&ecomadd
);
6506 ecommunity_free(&*list
);
6514 * v2vimport is true if we are handling a `import vrf ...` command
6516 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6520 switch (vty
->node
) {
6529 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6534 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6535 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6536 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6537 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6539 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6543 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6544 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6545 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6546 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6548 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6555 DEFPY (af_rd_vpn_export
,
6556 af_rd_vpn_export_cmd
,
6557 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6559 "Specify route distinguisher\n"
6560 "Between current address-family and vpn\n"
6561 "For routes leaked from current address-family to vpn\n"
6562 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6564 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6565 struct prefix_rd prd
;
6571 if (argv_find(argv
, argc
, "no", &idx
))
6575 ret
= str2prefix_rd(rd_str
, &prd
);
6577 vty_out(vty
, "%% Malformed rd\n");
6578 return CMD_WARNING_CONFIG_FAILED
;
6582 afi
= vpn_policy_getafi(vty
, bgp
, false);
6584 return CMD_WARNING_CONFIG_FAILED
;
6587 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6589 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6590 bgp_get_default(), bgp
);
6593 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6594 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6595 BGP_VPN_POLICY_TOVPN_RD_SET
);
6597 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6598 BGP_VPN_POLICY_TOVPN_RD_SET
);
6601 /* post-change: re-export vpn routes */
6602 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6603 bgp_get_default(), bgp
);
6608 ALIAS (af_rd_vpn_export
,
6609 af_no_rd_vpn_export_cmd
,
6612 "Specify route distinguisher\n"
6613 "Between current address-family and vpn\n"
6614 "For routes leaked from current address-family to vpn\n")
6616 DEFPY (af_label_vpn_export
,
6617 af_label_vpn_export_cmd
,
6618 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6620 "label value for VRF\n"
6621 "Between current address-family and vpn\n"
6622 "For routes leaked from current address-family to vpn\n"
6623 "Label Value <0-1048575>\n"
6624 "Automatically assign a label\n")
6626 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6627 mpls_label_t label
= MPLS_LABEL_NONE
;
6632 if (argv_find(argv
, argc
, "no", &idx
))
6635 /* If "no ...", squash trailing parameter */
6641 label
= label_val
; /* parser should force unsigned */
6644 afi
= vpn_policy_getafi(vty
, bgp
, false);
6646 return CMD_WARNING_CONFIG_FAILED
;
6649 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6650 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6655 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6657 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6658 bgp_get_default(), bgp
);
6660 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6661 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6663 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6666 * label has previously been automatically
6667 * assigned by labelpool: release it
6669 * NB if tovpn_label == MPLS_LABEL_NONE it
6670 * means the automatic assignment is in flight
6671 * and therefore the labelpool callback must
6672 * detect that the auto label is not needed.
6675 bgp_lp_release(LP_TYPE_VRF
,
6676 &bgp
->vpn_policy
[afi
],
6677 bgp
->vpn_policy
[afi
].tovpn_label
);
6679 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6680 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6683 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6685 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6686 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6687 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6688 vpn_leak_label_callback
);
6691 /* post-change: re-export vpn routes */
6692 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6693 bgp_get_default(), bgp
);
6698 ALIAS (af_label_vpn_export
,
6699 af_no_label_vpn_export_cmd
,
6700 "no label vpn export",
6702 "label value for VRF\n"
6703 "Between current address-family and vpn\n"
6704 "For routes leaked from current address-family to vpn\n")
6706 DEFPY (af_nexthop_vpn_export
,
6707 af_nexthop_vpn_export_cmd
,
6708 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6710 "Specify next hop to use for VRF advertised prefixes\n"
6711 "Between current address-family and vpn\n"
6712 "For routes leaked from current address-family to vpn\n"
6716 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6722 if (argv_find(argv
, argc
, "no", &idx
))
6726 if (!sockunion2hostprefix(nexthop_str
, &p
))
6727 return CMD_WARNING_CONFIG_FAILED
;
6730 afi
= vpn_policy_getafi(vty
, bgp
, false);
6732 return CMD_WARNING_CONFIG_FAILED
;
6735 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6737 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6738 bgp_get_default(), bgp
);
6741 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6742 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6743 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6745 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6746 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6749 /* post-change: re-export vpn routes */
6750 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6751 bgp_get_default(), bgp
);
6756 ALIAS (af_nexthop_vpn_export
,
6757 af_no_nexthop_vpn_export_cmd
,
6758 "no nexthop vpn export",
6760 "Specify next hop to use for VRF advertised prefixes\n"
6761 "Between current address-family and vpn\n"
6762 "For routes leaked from current address-family to vpn\n")
6764 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6766 if (!strcmp(dstr
, "import")) {
6767 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6768 } else if (!strcmp(dstr
, "export")) {
6769 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6770 } else if (!strcmp(dstr
, "both")) {
6771 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6772 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6774 vty_out(vty
, "%% direction parse error\n");
6775 return CMD_WARNING_CONFIG_FAILED
;
6780 DEFPY (af_rt_vpn_imexport
,
6781 af_rt_vpn_imexport_cmd
,
6782 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6784 "Specify route target list\n"
6785 "Specify route target list\n"
6786 "Between current address-family and vpn\n"
6787 "For routes leaked from vpn to current address-family: match any\n"
6788 "For routes leaked from current address-family to vpn: set\n"
6789 "both import: match any and export: set\n"
6790 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6792 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6794 struct ecommunity
*ecom
= NULL
;
6795 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6796 vpn_policy_direction_t dir
;
6801 if (argv_find(argv
, argc
, "no", &idx
))
6804 afi
= vpn_policy_getafi(vty
, bgp
, false);
6806 return CMD_WARNING_CONFIG_FAILED
;
6808 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6809 if (ret
!= CMD_SUCCESS
)
6813 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6814 vty_out(vty
, "%% Missing RTLIST\n");
6815 return CMD_WARNING_CONFIG_FAILED
;
6817 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6818 if (ret
!= CMD_SUCCESS
) {
6823 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6827 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6830 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6832 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6833 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6834 ecommunity_dup(ecom
);
6836 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6838 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6839 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6842 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6846 ecommunity_free(&ecom
);
6851 ALIAS (af_rt_vpn_imexport
,
6852 af_no_rt_vpn_imexport_cmd
,
6853 "no <rt|route-target> vpn <import|export|both>$direction_str",
6855 "Specify route target list\n"
6856 "Specify route target list\n"
6857 "Between current address-family and vpn\n"
6858 "For routes leaked from vpn to current address-family\n"
6859 "For routes leaked from current address-family to vpn\n"
6860 "both import and export\n")
6862 DEFPY (af_route_map_vpn_imexport
,
6863 af_route_map_vpn_imexport_cmd
,
6864 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6865 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6867 "Specify route map\n"
6868 "Between current address-family and vpn\n"
6869 "For routes leaked from vpn to current address-family\n"
6870 "For routes leaked from current address-family to vpn\n"
6871 "name of route-map\n")
6873 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6875 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6876 vpn_policy_direction_t dir
;
6881 if (argv_find(argv
, argc
, "no", &idx
))
6884 afi
= vpn_policy_getafi(vty
, bgp
, false);
6886 return CMD_WARNING_CONFIG_FAILED
;
6888 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6889 if (ret
!= CMD_SUCCESS
)
6892 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6896 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6899 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6900 XFREE(MTYPE_ROUTE_MAP_NAME
,
6901 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6902 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6903 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6904 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6905 route_map_lookup_warn_noexist(vty
, rmap_str
);
6906 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6909 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6910 XFREE(MTYPE_ROUTE_MAP_NAME
,
6911 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6912 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6913 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6916 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6922 ALIAS (af_route_map_vpn_imexport
,
6923 af_no_route_map_vpn_imexport_cmd
,
6924 "no route-map vpn <import|export>$direction_str",
6926 "Specify route map\n"
6927 "Between current address-family and vpn\n"
6928 "For routes leaked from vpn to current address-family\n"
6929 "For routes leaked from current address-family to vpn\n")
6931 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6932 "[no] import vrf route-map RMAP$rmap_str",
6934 "Import routes from another VRF\n"
6935 "Vrf routes being filtered\n"
6936 "Specify route map\n"
6937 "name of route-map\n")
6939 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6940 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6944 struct bgp
*bgp_default
;
6946 if (argv_find(argv
, argc
, "no", &idx
))
6949 afi
= vpn_policy_getafi(vty
, bgp
, true);
6951 return CMD_WARNING_CONFIG_FAILED
;
6953 bgp_default
= bgp_get_default();
6958 /* Auto-create assuming the same AS */
6959 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6960 BGP_INSTANCE_TYPE_DEFAULT
);
6964 "VRF default is not configured as a bgp instance\n");
6969 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6972 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6973 XFREE(MTYPE_ROUTE_MAP_NAME
,
6974 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6975 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6976 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6977 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6978 route_map_lookup_warn_noexist(vty
, rmap_str
);
6979 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6982 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6983 XFREE(MTYPE_ROUTE_MAP_NAME
,
6984 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6985 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6986 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6989 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6994 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6995 "no import vrf route-map",
6997 "Import routes from another VRF\n"
6998 "Vrf routes being filtered\n"
6999 "Specify route map\n")
7001 DEFPY(bgp_imexport_vrf
, bgp_imexport_vrf_cmd
,
7002 "[no] import vrf VIEWVRFNAME$import_name",
7004 "Import routes from another VRF\n"
7005 "VRF to import from\n"
7006 "The name of the VRF\n")
7008 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7009 struct listnode
*node
;
7010 struct bgp
*vrf_bgp
, *bgp_default
;
7013 bool remove
= false;
7016 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
7020 if (import_name
== NULL
) {
7021 vty_out(vty
, "%% Missing import name\n");
7025 if (argv_find(argv
, argc
, "no", &idx
))
7028 afi
= vpn_policy_getafi(vty
, bgp
, true);
7030 return CMD_WARNING_CONFIG_FAILED
;
7032 safi
= bgp_node_safi(vty
);
7034 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
7035 && (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0))
7036 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
7037 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
7038 remove
? "unimport" : "import", import_name
);
7042 bgp_default
= bgp_get_default();
7044 /* Auto-create assuming the same AS */
7045 ret
= bgp_get(&bgp_default
, &as
, NULL
,
7046 BGP_INSTANCE_TYPE_DEFAULT
);
7050 "VRF default is not configured as a bgp instance\n");
7055 vrf_bgp
= bgp_lookup_by_name(import_name
);
7057 if (strcmp(import_name
, VRF_DEFAULT_NAME
) == 0)
7058 vrf_bgp
= bgp_default
;
7060 /* Auto-create assuming the same AS */
7061 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
7065 "VRF %s is not configured as a bgp instance\n",
7072 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
7074 /* Already importing from "import_vrf"? */
7075 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
7077 if (strcmp(vname
, import_name
) == 0)
7081 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
7087 /* This command is valid only in a bgp vrf instance or the default instance */
7088 DEFPY (bgp_imexport_vpn
,
7089 bgp_imexport_vpn_cmd
,
7090 "[no] <import|export>$direction_str vpn",
7092 "Import routes to this address-family\n"
7093 "Export routes from this address-family\n"
7094 "to/from default instance VPN RIB\n")
7096 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7103 vpn_policy_direction_t dir
;
7105 if (argv_find(argv
, argc
, "no", &idx
))
7108 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
7109 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
7111 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
7112 return CMD_WARNING_CONFIG_FAILED
;
7115 afi
= bgp_node_afi(vty
);
7116 safi
= bgp_node_safi(vty
);
7117 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
7118 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
7119 return CMD_WARNING_CONFIG_FAILED
;
7122 if (!strcmp(direction_str
, "import")) {
7123 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
7124 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
7125 } else if (!strcmp(direction_str
, "export")) {
7126 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
7127 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
7129 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
7130 return CMD_WARNING_CONFIG_FAILED
;
7133 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7136 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7137 if (!previous_state
) {
7138 /* trigger export current vrf */
7139 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
7142 if (previous_state
) {
7143 /* trigger un-export current vrf */
7144 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
7146 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
7152 DEFPY (af_routetarget_import
,
7153 af_routetarget_import_cmd
,
7154 "[no] <rt|route-target> redirect import RTLIST...",
7156 "Specify route target list\n"
7157 "Specify route target list\n"
7158 "Flow-spec redirect type route target\n"
7159 "Import routes to this address-family\n"
7160 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
7162 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7164 struct ecommunity
*ecom
= NULL
;
7169 if (argv_find(argv
, argc
, "no", &idx
))
7172 afi
= vpn_policy_getafi(vty
, bgp
, false);
7174 return CMD_WARNING_CONFIG_FAILED
;
7177 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
7178 vty_out(vty
, "%% Missing RTLIST\n");
7179 return CMD_WARNING_CONFIG_FAILED
;
7181 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
7182 if (ret
!= CMD_SUCCESS
)
7187 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7188 ecommunity_free(&bgp
->vpn_policy
[afi
]
7189 .import_redirect_rtlist
);
7190 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
7191 ecommunity_dup(ecom
);
7193 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
7194 ecommunity_free(&bgp
->vpn_policy
[afi
]
7195 .import_redirect_rtlist
);
7196 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
7200 ecommunity_free(&ecom
);
7205 DEFUN_NOSH (address_family_ipv4_safi
,
7206 address_family_ipv4_safi_cmd
,
7207 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7208 "Enter Address Family command mode\n"
7210 BGP_SAFI_WITH_LABEL_HELP_STR
)
7214 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7215 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7216 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7217 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7218 && safi
!= SAFI_EVPN
) {
7220 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7221 return CMD_WARNING_CONFIG_FAILED
;
7223 vty
->node
= bgp_node_type(AFI_IP
, safi
);
7225 vty
->node
= BGP_IPV4_NODE
;
7230 DEFUN_NOSH (address_family_ipv6_safi
,
7231 address_family_ipv6_safi_cmd
,
7232 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
7233 "Enter Address Family command mode\n"
7235 BGP_SAFI_WITH_LABEL_HELP_STR
)
7238 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7239 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
7240 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
7241 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
7242 && safi
!= SAFI_EVPN
) {
7244 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
7245 return CMD_WARNING_CONFIG_FAILED
;
7247 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
7249 vty
->node
= BGP_IPV6_NODE
;
7254 #ifdef KEEP_OLD_VPN_COMMANDS
7255 DEFUN_NOSH (address_family_vpnv4
,
7256 address_family_vpnv4_cmd
,
7257 "address-family vpnv4 [unicast]",
7258 "Enter Address Family command mode\n"
7260 "Address Family modifier\n")
7262 vty
->node
= BGP_VPNV4_NODE
;
7266 DEFUN_NOSH (address_family_vpnv6
,
7267 address_family_vpnv6_cmd
,
7268 "address-family vpnv6 [unicast]",
7269 "Enter Address Family command mode\n"
7271 "Address Family modifier\n")
7273 vty
->node
= BGP_VPNV6_NODE
;
7276 #endif /* KEEP_OLD_VPN_COMMANDS */
7278 DEFUN_NOSH (address_family_evpn
,
7279 address_family_evpn_cmd
,
7280 "address-family l2vpn evpn",
7281 "Enter Address Family command mode\n"
7283 "Address Family modifier\n")
7285 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7286 vty
->node
= BGP_EVPN_NODE
;
7290 DEFUN_NOSH (exit_address_family
,
7291 exit_address_family_cmd
,
7292 "exit-address-family",
7293 "Exit from Address Family configuration mode\n")
7295 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7296 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7297 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7298 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7299 || vty
->node
== BGP_EVPN_NODE
7300 || vty
->node
== BGP_FLOWSPECV4_NODE
7301 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7302 vty
->node
= BGP_NODE
;
7306 /* Recalculate bestpath and re-advertise a prefix */
7307 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7308 const char *ip_str
, afi_t afi
, safi_t safi
,
7309 struct prefix_rd
*prd
)
7312 struct prefix match
;
7313 struct bgp_node
*rn
;
7314 struct bgp_node
*rm
;
7316 struct bgp_table
*table
;
7317 struct bgp_table
*rib
;
7319 /* BGP structure lookup. */
7321 bgp
= bgp_lookup_by_name(view_name
);
7323 vty_out(vty
, "%% Can't find BGP instance %s\n",
7328 bgp
= bgp_get_default();
7330 vty_out(vty
, "%% No BGP process is configured\n");
7335 /* Check IP address argument. */
7336 ret
= str2prefix(ip_str
, &match
);
7338 vty_out(vty
, "%% address is malformed\n");
7342 match
.family
= afi2family(afi
);
7343 rib
= bgp
->rib
[afi
][safi
];
7345 if (safi
== SAFI_MPLS_VPN
) {
7346 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7347 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7350 table
= bgp_node_get_bgp_table_info(rn
);
7351 if (table
!= NULL
) {
7353 if ((rm
= bgp_node_match(table
, &match
))
7356 == match
.prefixlen
) {
7358 BGP_NODE_USER_CLEAR
);
7359 bgp_process(bgp
, rm
, afi
, safi
);
7361 bgp_unlock_node(rm
);
7366 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7367 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7368 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7369 bgp_process(bgp
, rn
, afi
, safi
);
7371 bgp_unlock_node(rn
);
7378 /* one clear bgp command to rule them all */
7379 DEFUN (clear_ip_bgp_all
,
7380 clear_ip_bgp_all_cmd
,
7381 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6|l2vpn> [<unicast|multicast|vpn|labeled-unicast|flowspec|evpn>]] <*|A.B.C.D$neighbor|X:X::X:X$neighbor|WORD$neighbor|(1-4294967295)|external|peer-group PGNAME> [<soft [<in|out>]|in [prefix-filter]|out>]",
7385 BGP_INSTANCE_HELP_STR
7388 BGP_SAFI_WITH_LABEL_HELP_STR
7389 "Address Family modifier\n"
7391 "BGP IPv4 neighbor to clear\n"
7392 "BGP IPv6 neighbor to clear\n"
7393 "BGP neighbor on interface to clear\n"
7394 "Clear peers with the AS number\n"
7395 "Clear all external peers\n"
7396 "Clear all members of peer-group\n"
7397 "BGP peer-group name\n"
7402 "Push out prefix-list ORF and do inbound soft reconfig\n"
7407 afi_t afi
= AFI_UNSPEC
;
7408 safi_t safi
= SAFI_UNSPEC
;
7409 enum clear_sort clr_sort
= clear_peer
;
7410 enum bgp_clear_type clr_type
;
7411 char *clr_arg
= NULL
;
7415 /* clear [ip] bgp */
7416 if (argv_find(argv
, argc
, "ip", &idx
))
7419 /* [<vrf> VIEWVRFNAME] */
7420 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7421 vrf
= argv
[idx
+ 1]->arg
;
7423 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7425 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7426 /* [<view> VIEWVRFNAME] */
7427 vrf
= argv
[idx
+ 1]->arg
;
7430 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7431 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7432 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7434 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group PGNAME> */
7435 if (argv_find(argv
, argc
, "*", &idx
)) {
7436 clr_sort
= clear_all
;
7437 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7438 clr_sort
= clear_peer
;
7439 clr_arg
= argv
[idx
]->arg
;
7440 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7441 clr_sort
= clear_peer
;
7442 clr_arg
= argv
[idx
]->arg
;
7443 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7444 clr_sort
= clear_group
;
7446 clr_arg
= argv
[idx
]->arg
;
7447 } else if (argv_find(argv
, argc
, "PGNAME", &idx
)) {
7448 clr_sort
= clear_peer
;
7449 clr_arg
= argv
[idx
]->arg
;
7450 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7451 clr_sort
= clear_peer
;
7452 clr_arg
= argv
[idx
]->arg
;
7453 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7454 clr_sort
= clear_as
;
7455 clr_arg
= argv
[idx
]->arg
;
7456 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7457 clr_sort
= clear_external
;
7460 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7461 if (argv_find(argv
, argc
, "soft", &idx
)) {
7462 if (argv_find(argv
, argc
, "in", &idx
)
7463 || argv_find(argv
, argc
, "out", &idx
))
7464 clr_type
= strmatch(argv
[idx
]->text
, "in")
7466 : BGP_CLEAR_SOFT_OUT
;
7468 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7469 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7470 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7471 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7472 : BGP_CLEAR_SOFT_IN
;
7473 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7474 clr_type
= BGP_CLEAR_SOFT_OUT
;
7476 clr_type
= BGP_CLEAR_SOFT_NONE
;
7478 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7481 DEFUN (clear_ip_bgp_prefix
,
7482 clear_ip_bgp_prefix_cmd
,
7483 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7487 BGP_INSTANCE_HELP_STR
7488 "Clear bestpath and re-advertise\n"
7492 char *prefix
= NULL
;
7496 /* [<view|vrf> VIEWVRFNAME] */
7497 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7498 vrf
= argv
[idx
+ 1]->arg
;
7500 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
7502 } else if (argv_find(argv
, argc
, "view", &idx
)) {
7503 /* [<view> VIEWVRFNAME] */
7504 vrf
= argv
[idx
+ 1]->arg
;
7508 prefix
= argv
[argc
- 1]->arg
;
7510 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7513 DEFUN (clear_bgp_ipv6_safi_prefix
,
7514 clear_bgp_ipv6_safi_prefix_cmd
,
7515 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7521 "Clear bestpath and re-advertise\n"
7525 int idx_ipv6_prefix
= 0;
7526 safi_t safi
= SAFI_UNICAST
;
7527 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7528 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7530 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7531 return bgp_clear_prefix(
7532 vty
, NULL
, prefix
, AFI_IP6
,
7536 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7537 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7538 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7542 BGP_INSTANCE_HELP_STR
7545 "Clear bestpath and re-advertise\n"
7549 int idx_vrfview
= 0;
7550 int idx_ipv6_prefix
= 0;
7551 safi_t safi
= SAFI_UNICAST
;
7552 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7553 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7554 char *vrfview
= NULL
;
7556 /* [<view|vrf> VIEWVRFNAME] */
7557 if (argv_find(argv
, argc
, "vrf", &idx_vrfview
)) {
7558 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7559 if (vrfview
&& strmatch(vrfview
, VRF_DEFAULT_NAME
))
7561 } else if (argv_find(argv
, argc
, "view", &idx_vrfview
)) {
7562 /* [<view> VIEWVRFNAME] */
7563 vrfview
= argv
[idx_vrfview
+ 1]->arg
;
7565 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7567 return bgp_clear_prefix(
7568 vty
, vrfview
, prefix
,
7569 AFI_IP6
, safi
, NULL
);
7572 DEFUN (show_bgp_views
,
7574 "show [ip] bgp views",
7578 "Show the defined BGP views\n")
7580 struct list
*inst
= bm
->bgp
;
7581 struct listnode
*node
;
7584 vty_out(vty
, "Defined BGP views:\n");
7585 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7587 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7589 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7596 DEFUN (show_bgp_vrfs
,
7598 "show [ip] bgp vrfs [json]",
7605 char buf
[ETHER_ADDR_STRLEN
];
7606 struct list
*inst
= bm
->bgp
;
7607 struct listnode
*node
;
7609 bool uj
= use_json(argc
, argv
);
7610 json_object
*json
= NULL
;
7611 json_object
*json_vrfs
= NULL
;
7615 json
= json_object_new_object();
7616 json_vrfs
= json_object_new_object();
7619 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7620 const char *name
, *type
;
7622 struct listnode
*node2
, *nnode2
;
7623 int peers_cfg
, peers_estb
;
7624 json_object
*json_vrf
= NULL
;
7627 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7631 if (!uj
&& count
== 1) {
7633 "%4s %-5s %-16s %9s %10s %-37s\n",
7634 "Type", "Id", "routerId", "#PeersVfg",
7635 "#PeersEstb", "Name");
7636 vty_out(vty
, "%11s %-16s %-21s %-6s\n", " ",
7637 "L3-VNI", "RouterMAC", "Interface");
7640 peers_cfg
= peers_estb
= 0;
7642 json_vrf
= json_object_new_object();
7645 for (ALL_LIST_ELEMENTS(bgp
->peer
, node2
, nnode2
, peer
)) {
7646 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7649 if (peer
->status
== Established
)
7653 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7654 name
= VRF_DEFAULT_NAME
;
7663 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7665 : (int64_t)bgp
->vrf_id
;
7666 json_object_string_add(json_vrf
, "type", type
);
7667 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7668 json_object_string_add(json_vrf
, "routerId",
7669 inet_ntoa(bgp
->router_id
));
7670 json_object_int_add(json_vrf
, "numConfiguredPeers",
7672 json_object_int_add(json_vrf
, "numEstablishedPeers",
7675 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7676 json_object_string_add(
7678 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7679 json_object_string_add(json_vrf
, "interface",
7680 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
7682 json_object_object_add(json_vrfs
, name
, json_vrf
);
7685 "%4s %-5d %-16s %-9u %-10u %-37s\n",
7687 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7689 inet_ntoa(bgp
->router_id
), peers_cfg
,
7691 vty_out(vty
,"%11s %-16u %-21s %-20s\n", " ",
7693 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)),
7694 ifindex2ifname(bgp
->l3vni_svi_ifindex
,
7700 json_object_object_add(json
, "vrfs", json_vrfs
);
7702 json_object_int_add(json
, "totalVrfs", count
);
7704 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7705 json
, JSON_C_TO_STRING_PRETTY
));
7706 json_object_free(json
);
7710 "\nTotal number of VRFs (including default): %d\n",
7717 DEFUN (show_bgp_mac_hash
,
7718 show_bgp_mac_hash_cmd
,
7719 "show bgp mac hash",
7723 "Mac Address database\n")
7725 bgp_mac_dump_table(vty
);
7730 static void show_tip_entry(struct hash_bucket
*bucket
, void *args
)
7732 struct vty
*vty
= (struct vty
*)args
;
7733 struct tip_addr
*tip
= (struct tip_addr
*)bucket
->data
;
7735 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7739 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7741 vty_out(vty
, "self nexthop database:\n");
7742 bgp_nexthop_show_address_hash(vty
, bgp
);
7744 vty_out(vty
, "Tunnel-ip database:\n");
7745 hash_iterate(bgp
->tip_hash
,
7746 (void (*)(struct hash_bucket
*, void *))show_tip_entry
,
7750 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7751 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7752 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7753 "martian next-hops\n"
7754 "martian next-hop database\n")
7756 struct bgp
*bgp
= NULL
;
7760 /* [<vrf> VIEWVRFNAME] */
7761 if (argv_find(argv
, argc
, "vrf", &idx
)) {
7762 name
= argv
[idx
+ 1]->arg
;
7763 if (name
&& strmatch(name
, VRF_DEFAULT_NAME
))
7765 } else if (argv_find(argv
, argc
, "view", &idx
))
7766 /* [<view> VIEWVRFNAME] */
7767 name
= argv
[idx
+ 1]->arg
;
7769 bgp
= bgp_lookup_by_name(name
);
7771 bgp
= bgp_get_default();
7774 vty_out(vty
, "%% No BGP process is configured\n");
7777 bgp_show_martian_nexthops(vty
, bgp
);
7782 DEFUN (show_bgp_memory
,
7783 show_bgp_memory_cmd
,
7784 "show [ip] bgp memory",
7788 "Global BGP memory statistics\n")
7790 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7791 unsigned long count
;
7793 /* RIB related usage stats */
7794 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7795 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7796 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7797 count
* sizeof(struct bgp_node
)));
7799 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7800 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7801 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7802 count
* sizeof(struct bgp_path_info
)));
7803 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7804 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7807 memstrbuf
, sizeof(memstrbuf
),
7808 count
* sizeof(struct bgp_path_info_extra
)));
7810 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7811 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7812 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7813 count
* sizeof(struct bgp_static
)));
7815 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7816 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7817 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7818 count
* sizeof(struct bpacket
)));
7821 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7822 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7823 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7824 count
* sizeof(struct bgp_adj_in
)));
7825 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7826 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7827 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7828 count
* sizeof(struct bgp_adj_out
)));
7830 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7831 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7833 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7834 count
* sizeof(struct bgp_nexthop_cache
)));
7836 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7837 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7839 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7840 count
* sizeof(struct bgp_damp_info
)));
7843 count
= attr_count();
7844 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7845 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7846 count
* sizeof(struct attr
)));
7848 if ((count
= attr_unknown_count()))
7849 vty_out(vty
, "%ld unknown attributes\n", count
);
7851 /* AS_PATH attributes */
7852 count
= aspath_count();
7853 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7854 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7855 count
* sizeof(struct aspath
)));
7857 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7858 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7859 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7860 count
* sizeof(struct assegment
)));
7862 /* Other attributes */
7863 if ((count
= community_count()))
7864 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7865 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7866 count
* sizeof(struct community
)));
7867 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7868 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7869 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7870 count
* sizeof(struct ecommunity
)));
7871 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7873 "%ld BGP large-community entries, using %s of memory\n",
7874 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7875 count
* sizeof(struct lcommunity
)));
7877 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7878 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7879 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7880 count
* sizeof(struct cluster_list
)));
7882 /* Peer related usage */
7883 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7884 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7885 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7886 count
* sizeof(struct peer
)));
7888 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7889 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7890 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7891 count
* sizeof(struct peer_group
)));
7894 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7895 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7896 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7897 count
* sizeof(regex_t
)));
7901 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7903 json_object
*bestpath
= json_object_new_object();
7905 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7906 json_object_string_add(bestpath
, "asPath", "ignore");
7908 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7909 json_object_string_add(bestpath
, "asPath", "confed");
7911 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7912 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7913 json_object_string_add(bestpath
, "multiPathRelax",
7916 json_object_string_add(bestpath
, "multiPathRelax",
7919 json_object_string_add(bestpath
, "multiPathRelax", "false");
7921 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7922 json_object_string_add(bestpath
, "compareRouterId", "true");
7923 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7924 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7925 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7926 json_object_string_add(bestpath
, "med", "confed");
7927 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7928 json_object_string_add(bestpath
, "med",
7929 "missing-as-worst");
7931 json_object_string_add(bestpath
, "med", "true");
7934 json_object_object_add(json
, "bestPath", bestpath
);
7937 /* Print the error code/subcode for why the peer is down */
7938 static void bgp_show_peer_reset(struct vty
* vty
, struct peer
*peer
,
7939 json_object
*json_peer
, bool use_json
)
7941 const char *code_str
;
7942 const char *subcode_str
;
7945 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
7946 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
7947 char errorcodesubcode_hexstr
[5];
7948 char errorcodesubcode_str
[256];
7950 code_str
= bgp_notify_code_str(peer
->notify
.code
);
7951 subcode_str
= bgp_notify_subcode_str(
7953 peer
->notify
.subcode
);
7955 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
7956 peer
->notify
.code
, peer
->notify
.subcode
);
7957 json_object_string_add(json_peer
,
7958 "lastErrorCodeSubcode",
7959 errorcodesubcode_hexstr
);
7960 snprintf(errorcodesubcode_str
, 255, "%s%s",
7961 code_str
, subcode_str
);
7962 json_object_string_add(json_peer
,
7963 "lastNotificationReason",
7964 errorcodesubcode_str
);
7965 if (peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
7966 && peer
->notify
.code
== BGP_NOTIFY_CEASE
7967 && (peer
->notify
.subcode
7968 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
7969 || peer
->notify
.subcode
7970 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
7971 && peer
->notify
.length
) {
7973 const char *msg_str
;
7975 msg_str
= bgp_notify_admin_message(
7976 msgbuf
, sizeof(msgbuf
),
7977 (uint8_t *)peer
->notify
.data
,
7978 peer
->notify
.length
);
7980 json_object_string_add(
7982 "lastShutdownDescription",
7987 json_object_string_add(json_peer
, "lastResetDueTo",
7988 peer_down_str
[(int)peer
->last_reset
]);
7989 json_object_int_add(json_peer
, "lastResetCode",
7992 if (peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
7993 || peer
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
7994 code_str
= bgp_notify_code_str(peer
->notify
.code
);
7996 bgp_notify_subcode_str(peer
->notify
.code
,
7997 peer
->notify
.subcode
);
7998 vty_out(vty
, " Notification %s (%s%s)\n",
7999 peer
->last_reset
== PEER_DOWN_NOTIFY_SEND
8002 code_str
, subcode_str
);
8004 vty_out(vty
, " %s\n",
8005 peer_down_str
[(int)peer
->last_reset
]);
8010 static inline bool bgp_has_peer_failed(struct peer
*peer
, afi_t afi
,
8013 return ((peer
->status
!= Established
) ||
8014 !peer
->afc_recv
[afi
][safi
]);
8017 static void bgp_show_failed_summary(struct vty
*vty
, struct bgp
*bgp
,
8018 struct peer
*peer
, json_object
*json_peer
,
8019 int max_neighbor_width
, bool use_json
)
8021 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
8025 if (peer_dynamic_neighbor(peer
))
8026 json_object_boolean_true_add(json_peer
,
8029 json_object_string_add(json_peer
, "hostname",
8032 if (peer
->domainname
)
8033 json_object_string_add(json_peer
, "domainname",
8035 json_object_int_add(json_peer
, "connectionsEstablished",
8037 json_object_int_add(json_peer
, "connectionsDropped",
8039 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8040 use_json
, json_peer
);
8041 if (peer
->status
== Established
)
8042 json_object_string_add(json_peer
, "lastResetDueTo",
8043 "AFI/SAFI Not Negotiated");
8045 bgp_show_peer_reset(NULL
, peer
, json_peer
, true);
8048 dn_flag
[0] = peer_dynamic_neighbor(peer
) ? '*' : '\0';
8050 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8051 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8052 peer
->hostname
, peer
->host
);
8054 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8056 /* pad the neighbor column with spaces */
8057 if (len
< max_neighbor_width
)
8058 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8060 vty_out(vty
, "%7d %7d %8s", peer
->established
,
8062 peer_uptime(peer
->uptime
, timebuf
,
8063 BGP_UPTIME_LEN
, 0, NULL
));
8064 if (peer
->status
== Established
)
8065 vty_out(vty
, " AFI/SAFI Not Negotiated\n");
8067 bgp_show_peer_reset(vty
, peer
, NULL
,
8073 /* Show BGP peer's summary information. */
8074 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
8075 bool show_failed
, bool use_json
)
8078 struct listnode
*node
, *nnode
;
8079 unsigned int count
= 0, dn_count
= 0;
8080 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
8081 char neighbor_buf
[VTY_BUFSIZ
];
8082 int neighbor_col_default_width
= 16;
8083 int len
, failed_count
= 0;
8084 int max_neighbor_width
= 0;
8086 json_object
*json
= NULL
;
8087 json_object
*json_peer
= NULL
;
8088 json_object
*json_peers
= NULL
;
8089 struct peer_af
*paf
;
8091 /* labeled-unicast routes are installed in the unicast table so in order
8093 * display the correct PfxRcd value we must look at SAFI_UNICAST
8096 if (safi
== SAFI_LABELED_UNICAST
)
8097 pfx_rcd_safi
= SAFI_UNICAST
;
8099 pfx_rcd_safi
= safi
;
8102 json
= json_object_new_object();
8103 json_peers
= json_object_new_object();
8104 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8105 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8108 if (peer
->afc
[afi
][safi
]) {
8109 /* See if we have at least a single failed peer */
8110 if (bgp_has_peer_failed(peer
, afi
, safi
))
8114 if (peer_dynamic_neighbor(peer
))
8119 /* Loop over all neighbors that will be displayed to determine
8121 * characters are needed for the Neighbor column
8123 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8124 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8127 if (peer
->afc
[afi
][safi
]) {
8128 memset(dn_flag
, '\0', sizeof(dn_flag
));
8129 if (peer_dynamic_neighbor(peer
))
8133 && bgp_flag_check(bgp
,
8134 BGP_FLAG_SHOW_HOSTNAME
))
8135 sprintf(neighbor_buf
, "%s%s(%s) ",
8136 dn_flag
, peer
->hostname
,
8139 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
8142 len
= strlen(neighbor_buf
);
8144 if (len
> max_neighbor_width
)
8145 max_neighbor_width
= len
;
8147 /* See if we have at least a single failed peer */
8148 if (bgp_has_peer_failed(peer
, afi
, safi
))
8154 /* Originally we displayed the Neighbor column as 16
8155 * characters wide so make that the default
8157 if (max_neighbor_width
< neighbor_col_default_width
)
8158 max_neighbor_width
= neighbor_col_default_width
;
8161 if (show_failed
&& !failed_count
) {
8163 json_object_int_add(json
, "failedPeersCount", 0);
8164 json_object_int_add(json
, "dynamicPeers", dn_count
);
8165 json_object_int_add(json
, "totalPeers", count
);
8167 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8168 json
, JSON_C_TO_STRING_PRETTY
));
8169 json_object_free(json
);
8171 vty_out(vty
, "%% No failed BGP neighbors found\n");
8172 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8177 count
= 0; /* Reset the value as its used again */
8178 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
8179 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
8182 if (!peer
->afc
[afi
][safi
])
8187 char memstrbuf
[MTYPE_MEMSTR_LEN
];
8190 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
8192 : (int64_t)bgp
->vrf_id
;
8194 /* Usage summary and header */
8196 json_object_string_add(
8198 inet_ntoa(bgp
->router_id
));
8199 json_object_int_add(json
, "as", bgp
->as
);
8200 json_object_int_add(json
, "vrfId", vrf_id_ui
);
8201 json_object_string_add(
8204 == BGP_INSTANCE_TYPE_DEFAULT
)
8209 "BGP router identifier %s, local AS number %u vrf-id %d",
8210 inet_ntoa(bgp
->router_id
), bgp
->as
,
8211 bgp
->vrf_id
== VRF_UNKNOWN
8213 : (int)bgp
->vrf_id
);
8217 if (bgp_update_delay_configured(bgp
)) {
8219 json_object_int_add(
8220 json
, "updateDelayLimit",
8221 bgp
->v_update_delay
);
8223 if (bgp
->v_update_delay
8224 != bgp
->v_establish_wait
)
8225 json_object_int_add(
8227 "updateDelayEstablishWait",
8228 bgp
->v_establish_wait
);
8230 if (bgp_update_delay_active(bgp
)) {
8231 json_object_string_add(
8233 "updateDelayFirstNeighbor",
8234 bgp
->update_delay_begin_time
);
8235 json_object_boolean_true_add(
8237 "updateDelayInProgress");
8239 if (bgp
->update_delay_over
) {
8240 json_object_string_add(
8242 "updateDelayFirstNeighbor",
8243 bgp
->update_delay_begin_time
);
8244 json_object_string_add(
8246 "updateDelayBestpathResumed",
8247 bgp
->update_delay_end_time
);
8248 json_object_string_add(
8250 "updateDelayZebraUpdateResume",
8251 bgp
->update_delay_zebra_resume_time
);
8252 json_object_string_add(
8254 "updateDelayPeerUpdateResume",
8255 bgp
->update_delay_peers_resume_time
);
8260 "Read-only mode update-delay limit: %d seconds\n",
8261 bgp
->v_update_delay
);
8262 if (bgp
->v_update_delay
8263 != bgp
->v_establish_wait
)
8265 " Establish wait: %d seconds\n",
8266 bgp
->v_establish_wait
);
8268 if (bgp_update_delay_active(bgp
)) {
8270 " First neighbor established: %s\n",
8271 bgp
->update_delay_begin_time
);
8273 " Delay in progress\n");
8275 if (bgp
->update_delay_over
) {
8277 " First neighbor established: %s\n",
8278 bgp
->update_delay_begin_time
);
8280 " Best-paths resumed: %s\n",
8281 bgp
->update_delay_end_time
);
8283 " zebra update resumed: %s\n",
8284 bgp
->update_delay_zebra_resume_time
);
8286 " peers update resumed: %s\n",
8287 bgp
->update_delay_peers_resume_time
);
8294 if (bgp_maxmed_onstartup_configured(bgp
)
8295 && bgp
->maxmed_active
)
8296 json_object_boolean_true_add(
8297 json
, "maxMedOnStartup");
8298 if (bgp
->v_maxmed_admin
)
8299 json_object_boolean_true_add(
8300 json
, "maxMedAdministrative");
8302 json_object_int_add(
8303 json
, "tableVersion",
8304 bgp_table_version(bgp
->rib
[afi
][safi
]));
8306 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8307 json_object_int_add(json
, "ribCount", ents
);
8308 json_object_int_add(
8310 ents
* sizeof(struct bgp_node
));
8312 ents
= bgp
->af_peer_count
[afi
][safi
];
8313 json_object_int_add(json
, "peerCount", ents
);
8314 json_object_int_add(json
, "peerMemory",
8315 ents
* sizeof(struct peer
));
8317 if ((ents
= listcount(bgp
->group
))) {
8318 json_object_int_add(
8319 json
, "peerGroupCount", ents
);
8320 json_object_int_add(
8321 json
, "peerGroupMemory",
8322 ents
* sizeof(struct
8326 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8327 BGP_CONFIG_DAMPENING
))
8328 json_object_boolean_true_add(
8329 json
, "dampeningEnabled");
8331 if (bgp_maxmed_onstartup_configured(bgp
)
8332 && bgp
->maxmed_active
)
8334 "Max-med on-startup active\n");
8335 if (bgp
->v_maxmed_admin
)
8337 "Max-med administrative active\n");
8339 vty_out(vty
, "BGP table version %" PRIu64
"\n",
8340 bgp_table_version(bgp
->rib
[afi
][safi
]));
8342 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
8344 "RIB entries %ld, using %s of memory\n",
8346 mtype_memstr(memstrbuf
,
8348 ents
* sizeof(struct
8351 /* Peer related usage */
8352 ents
= bgp
->af_peer_count
[afi
][safi
];
8353 vty_out(vty
, "Peers %ld, using %s of memory\n",
8356 memstrbuf
, sizeof(memstrbuf
),
8357 ents
* sizeof(struct peer
)));
8359 if ((ents
= listcount(bgp
->group
)))
8361 "Peer groups %ld, using %s of memory\n",
8366 ents
* sizeof(struct
8369 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
8370 BGP_CONFIG_DAMPENING
))
8371 vty_out(vty
, "Dampening enabled.\n");
8374 /* Subtract 8 here because 'Neighbor' is
8376 vty_out(vty
, "Neighbor");
8377 vty_out(vty
, "%*s", max_neighbor_width
- 8,
8380 vty_out(vty
, "EstdCnt DropCnt ResetTime Reason\n");
8383 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
8388 /* Works for both failed & successful cases */
8389 if (peer_dynamic_neighbor(peer
))
8396 bgp_has_peer_failed(peer
, afi
, safi
)) {
8397 json_peer
= json_object_new_object();
8398 bgp_show_failed_summary(vty
, bgp
, peer
,
8399 json_peer
, 0, use_json
);
8400 } else if (!show_failed
) {
8401 json_peer
= json_object_new_object();
8402 if (peer_dynamic_neighbor(peer
)) {
8403 json_object_boolean_true_add(json_peer
,
8408 json_object_string_add(json_peer
, "hostname",
8411 if (peer
->domainname
)
8412 json_object_string_add(json_peer
, "domainname",
8415 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
8416 json_object_int_add(json_peer
, "version", 4);
8417 json_object_int_add(json_peer
, "msgRcvd",
8418 PEER_TOTAL_RX(peer
));
8419 json_object_int_add(json_peer
, "msgSent",
8420 PEER_TOTAL_TX(peer
));
8422 json_object_int_add(json_peer
, "tableVersion",
8423 peer
->version
[afi
][safi
]);
8424 json_object_int_add(json_peer
, "outq",
8426 json_object_int_add(json_peer
, "inq", 0);
8427 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
8428 use_json
, json_peer
);
8431 * Adding "pfxRcd" field to match with the corresponding
8432 * CLI. "prefixReceivedCount" will be deprecated in
8435 json_object_int_add(json_peer
, "prefixReceivedCount",
8436 peer
->pcount
[afi
][pfx_rcd_safi
]);
8437 json_object_int_add(json_peer
, "pfxRcd",
8438 peer
->pcount
[afi
][pfx_rcd_safi
]);
8440 paf
= peer_af_find(peer
, afi
, pfx_rcd_safi
);
8441 if (paf
&& PAF_SUBGRP(paf
))
8442 json_object_int_add(json_peer
,
8444 (PAF_SUBGRP(paf
))->scount
);
8445 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8446 json_object_string_add(json_peer
, "state",
8448 else if (peer
->afc_recv
[afi
][safi
])
8449 json_object_string_add(
8451 lookup_msg(bgp_status_msg
, peer
->status
,
8453 else if (CHECK_FLAG(peer
->sflags
,
8454 PEER_STATUS_PREFIX_OVERFLOW
))
8455 json_object_string_add(json_peer
, "state",
8458 json_object_string_add(
8460 lookup_msg(bgp_status_msg
, peer
->status
,
8462 json_object_int_add(json_peer
, "connectionsEstablished",
8464 json_object_int_add(json_peer
, "connectionsDropped",
8467 /* Avoid creating empty peer dicts in JSON */
8468 if (json_peer
== NULL
)
8472 json_object_string_add(json_peer
, "idType",
8474 else if (peer
->su
.sa
.sa_family
== AF_INET
)
8475 json_object_string_add(json_peer
, "idType",
8477 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
8478 json_object_string_add(json_peer
, "idType",
8480 json_object_object_add(json_peers
, peer
->host
,
8484 bgp_has_peer_failed(peer
, afi
, safi
)) {
8485 bgp_show_failed_summary(vty
, bgp
, peer
, NULL
,
8488 } else if (!show_failed
) {
8489 memset(dn_flag
, '\0', sizeof(dn_flag
));
8490 if (peer_dynamic_neighbor(peer
)) {
8495 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
8496 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
8497 peer
->hostname
, peer
->host
);
8499 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
8501 /* pad the neighbor column with spaces */
8502 if (len
< max_neighbor_width
)
8503 vty_out(vty
, "%*s", max_neighbor_width
- len
,
8506 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
8507 peer
->as
, PEER_TOTAL_RX(peer
),
8508 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
8509 0, peer
->obuf
->count
,
8510 peer_uptime(peer
->uptime
, timebuf
,
8511 BGP_UPTIME_LEN
, 0, NULL
));
8513 if (peer
->status
== Established
)
8514 if (peer
->afc_recv
[afi
][safi
])
8515 vty_out(vty
, " %12" PRIu32
,
8520 vty_out(vty
, " NoNeg");
8522 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
8523 vty_out(vty
, " Idle (Admin)");
8524 else if (CHECK_FLAG(
8526 PEER_STATUS_PREFIX_OVERFLOW
))
8527 vty_out(vty
, " Idle (PfxCt)");
8529 vty_out(vty
, " %12s",
8530 lookup_msg(bgp_status_msg
,
8531 peer
->status
, NULL
));
8540 json_object_object_add(json
, "peers", json_peers
);
8541 json_object_int_add(json
, "failedPeers", failed_count
);
8542 json_object_int_add(json
, "totalPeers", count
);
8543 json_object_int_add(json
, "dynamicPeers", dn_count
);
8546 bgp_show_bestpath_json(bgp
, json
);
8548 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8549 json
, JSON_C_TO_STRING_PRETTY
));
8550 json_object_free(json
);
8553 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8555 vty_out(vty
, "No %s neighbor is configured\n",
8556 get_afi_safi_str(afi
, safi
, false));
8560 vty_out(vty
, "* - dynamic neighbor\n");
8561 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8562 dn_count
, bgp
->dynamic_neighbors_limit
);
8569 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8570 int safi
, bool show_failed
, bool use_json
)
8573 int afi_wildcard
= (afi
== AFI_MAX
);
8574 int safi_wildcard
= (safi
== SAFI_MAX
);
8575 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8576 bool nbr_output
= false;
8578 if (use_json
&& is_wildcard
)
8579 vty_out(vty
, "{\n");
8581 afi
= 1; /* AFI_IP */
8582 while (afi
< AFI_MAX
) {
8584 safi
= 1; /* SAFI_UNICAST */
8585 while (safi
< SAFI_MAX
) {
8586 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8591 * So limit output to those afi/safi
8593 * actualy have something interesting in
8598 vty_out(vty
, ",\n");
8602 vty_out(vty
, "\"%s\":",
8603 get_afi_safi_str(afi
,
8607 vty_out(vty
, "\n%s Summary:\n",
8608 get_afi_safi_str(afi
,
8613 bgp_show_summary(vty
, bgp
, afi
, safi
, show_failed
,
8625 if (use_json
&& is_wildcard
)
8626 vty_out(vty
, "}\n");
8627 else if (!nbr_output
) {
8629 vty_out(vty
, "{}\n");
8631 vty_out(vty
, "%% No BGP neighbors found\n");
8635 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8636 safi_t safi
, bool show_failed
,
8639 struct listnode
*node
, *nnode
;
8642 bool nbr_output
= false;
8645 vty_out(vty
, "{\n");
8647 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8651 vty_out(vty
, ",\n");
8655 vty_out(vty
, "\"%s\":",
8656 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8660 vty_out(vty
, "\nInstance %s:\n",
8661 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8665 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
8670 vty_out(vty
, "}\n");
8671 else if (!nbr_output
)
8672 vty_out(vty
, "%% BGP instance not found\n");
8675 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8676 safi_t safi
, bool show_failed
, bool use_json
)
8681 if (strmatch(name
, "all")) {
8682 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8687 bgp
= bgp_lookup_by_name(name
);
8691 vty_out(vty
, "{}\n");
8694 "%% BGP instance not found\n");
8698 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
,
8699 show_failed
, use_json
);
8704 bgp
= bgp_get_default();
8707 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, show_failed
,
8711 vty_out(vty
, "{}\n");
8713 vty_out(vty
, "%% BGP instance not found\n");
8720 /* `show [ip] bgp summary' commands. */
8721 DEFUN (show_ip_bgp_summary
,
8722 show_ip_bgp_summary_cmd
,
8723 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [failed] [json]",
8727 BGP_INSTANCE_HELP_STR
8729 BGP_SAFI_WITH_LABEL_HELP_STR
8730 "Summary of BGP neighbor status\n"
8731 "Show only sessions not in Established state\n"
8735 afi_t afi
= AFI_MAX
;
8736 safi_t safi
= SAFI_MAX
;
8737 bool show_failed
= false;
8742 if (argv_find(argv
, argc
, "ip", &idx
))
8744 /* [<vrf> VIEWVRFNAME] */
8745 if (argv_find(argv
, argc
, "vrf", &idx
)) {
8746 vrf
= argv
[idx
+ 1]->arg
;
8747 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
8749 } else if (argv_find(argv
, argc
, "view", &idx
))
8750 /* [<view> VIEWVRFNAME] */
8751 vrf
= argv
[idx
+ 1]->arg
;
8752 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8753 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8754 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8757 if (argv_find(argv
, argc
, "failed", &idx
))
8760 bool uj
= use_json(argc
, argv
);
8762 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, show_failed
, uj
);
8765 const char *get_afi_safi_str(afi_t afi
, safi_t safi
, bool for_json
)
8768 return get_afi_safi_json_str(afi
, safi
);
8770 return get_afi_safi_vty_str(afi
, safi
);
8773 /* Show BGP peer's information. */
8774 enum show_type
{ show_all
, show_peer
, show_ipv4_all
, show_ipv6_all
, show_ipv4_peer
, show_ipv6_peer
};
8776 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8777 afi_t afi
, safi_t safi
,
8778 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8779 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8780 bool use_json
, json_object
*json_pref
)
8783 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8784 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8786 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8787 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8788 json_object_string_add(json_pref
, "sendMode",
8789 "advertisedAndReceived");
8790 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8791 json_object_string_add(json_pref
, "sendMode",
8793 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8794 json_object_string_add(json_pref
, "sendMode",
8797 vty_out(vty
, " Send-mode: ");
8798 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8799 vty_out(vty
, "advertised");
8800 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8801 vty_out(vty
, "%sreceived",
8802 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8811 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8812 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8814 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8815 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8816 json_object_string_add(json_pref
, "recvMode",
8817 "advertisedAndReceived");
8818 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8819 json_object_string_add(json_pref
, "recvMode",
8821 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8822 json_object_string_add(json_pref
, "recvMode",
8825 vty_out(vty
, " Receive-mode: ");
8826 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8827 vty_out(vty
, "advertised");
8828 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8829 vty_out(vty
, "%sreceived",
8830 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8839 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8840 safi_t safi
, bool use_json
,
8841 json_object
*json_neigh
)
8843 struct bgp_filter
*filter
;
8844 struct peer_af
*paf
;
8845 char orf_pfx_name
[BUFSIZ
];
8847 json_object
*json_af
= NULL
;
8848 json_object
*json_prefA
= NULL
;
8849 json_object
*json_prefB
= NULL
;
8850 json_object
*json_addr
= NULL
;
8853 json_addr
= json_object_new_object();
8854 json_af
= json_object_new_object();
8855 filter
= &p
->filter
[afi
][safi
];
8857 if (peer_group_active(p
))
8858 json_object_string_add(json_addr
, "peerGroupMember",
8861 paf
= peer_af_find(p
, afi
, safi
);
8862 if (paf
&& PAF_SUBGRP(paf
)) {
8863 json_object_int_add(json_addr
, "updateGroupId",
8864 PAF_UPDGRP(paf
)->id
);
8865 json_object_int_add(json_addr
, "subGroupId",
8866 PAF_SUBGRP(paf
)->id
);
8867 json_object_int_add(json_addr
, "packetQueueLength",
8868 bpacket_queue_virtual_length(paf
));
8871 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8872 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8873 PEER_CAP_ORF_PREFIX_SM_RCV
)
8874 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8875 PEER_CAP_ORF_PREFIX_RM_ADV
)
8876 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8877 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8878 json_object_int_add(json_af
, "orfType",
8880 json_prefA
= json_object_new_object();
8881 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8882 PEER_CAP_ORF_PREFIX_SM_ADV
,
8883 PEER_CAP_ORF_PREFIX_RM_ADV
,
8884 PEER_CAP_ORF_PREFIX_SM_RCV
,
8885 PEER_CAP_ORF_PREFIX_RM_RCV
,
8886 use_json
, json_prefA
);
8887 json_object_object_add(json_af
, "orfPrefixList",
8891 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8892 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8893 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8894 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8895 PEER_CAP_ORF_PREFIX_RM_ADV
)
8896 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8897 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8898 json_object_int_add(json_af
, "orfOldType",
8899 ORF_TYPE_PREFIX_OLD
);
8900 json_prefB
= json_object_new_object();
8901 bgp_show_peer_afi_orf_cap(
8902 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8903 PEER_CAP_ORF_PREFIX_RM_ADV
,
8904 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8905 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8907 json_object_object_add(json_af
, "orfOldPrefixList",
8911 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8912 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8913 PEER_CAP_ORF_PREFIX_SM_RCV
)
8914 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8915 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8916 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8917 PEER_CAP_ORF_PREFIX_RM_ADV
)
8918 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8919 PEER_CAP_ORF_PREFIX_RM_RCV
)
8920 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8921 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8922 json_object_object_add(json_addr
, "afDependentCap",
8925 json_object_free(json_af
);
8927 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8928 orf_pfx_count
= prefix_bgp_show_prefix_list(
8929 NULL
, afi
, orf_pfx_name
, use_json
);
8931 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8932 PEER_STATUS_ORF_PREFIX_SEND
)
8934 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8935 PEER_STATUS_ORF_PREFIX_SEND
))
8936 json_object_boolean_true_add(json_neigh
,
8939 json_object_int_add(json_addr
, "orfRecvCounter",
8942 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8943 PEER_STATUS_ORF_WAIT_REFRESH
))
8944 json_object_string_add(
8945 json_addr
, "orfFirstUpdate",
8946 "deferredUntilORFOrRouteRefreshRecvd");
8948 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8949 PEER_FLAG_REFLECTOR_CLIENT
))
8950 json_object_boolean_true_add(json_addr
,
8951 "routeReflectorClient");
8952 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8953 PEER_FLAG_RSERVER_CLIENT
))
8954 json_object_boolean_true_add(json_addr
,
8955 "routeServerClient");
8956 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8957 json_object_boolean_true_add(json_addr
,
8958 "inboundSoftConfigPermit");
8960 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8961 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8962 json_object_boolean_true_add(
8964 "privateAsNumsAllReplacedInUpdatesToNbr");
8965 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8966 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8967 json_object_boolean_true_add(
8969 "privateAsNumsReplacedInUpdatesToNbr");
8970 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8971 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8972 json_object_boolean_true_add(
8974 "privateAsNumsAllRemovedInUpdatesToNbr");
8975 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8976 PEER_FLAG_REMOVE_PRIVATE_AS
))
8977 json_object_boolean_true_add(
8979 "privateAsNumsRemovedInUpdatesToNbr");
8981 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
8982 json_object_boolean_true_add(
8984 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
8987 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8988 json_object_string_add(json_addr
,
8989 "overrideASNsInOutboundUpdates",
8990 "ifAspathEqualRemoteAs");
8992 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8993 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8994 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8995 json_object_boolean_true_add(json_addr
,
8996 "routerAlwaysNextHop");
8997 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8998 PEER_FLAG_AS_PATH_UNCHANGED
))
8999 json_object_boolean_true_add(
9000 json_addr
, "unchangedAsPathPropogatedToNbr");
9001 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9002 PEER_FLAG_NEXTHOP_UNCHANGED
))
9003 json_object_boolean_true_add(
9004 json_addr
, "unchangedNextHopPropogatedToNbr");
9005 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
9006 json_object_boolean_true_add(
9007 json_addr
, "unchangedMedPropogatedToNbr");
9008 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
9009 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9010 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
9011 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9012 PEER_FLAG_SEND_COMMUNITY
)
9013 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9014 PEER_FLAG_SEND_EXT_COMMUNITY
))
9015 json_object_string_add(json_addr
,
9016 "commAttriSentToNbr",
9017 "extendedAndStandard");
9018 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9019 PEER_FLAG_SEND_EXT_COMMUNITY
))
9020 json_object_string_add(json_addr
,
9021 "commAttriSentToNbr",
9024 json_object_string_add(json_addr
,
9025 "commAttriSentToNbr",
9028 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9029 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9030 if (p
->default_rmap
[afi
][safi
].name
)
9031 json_object_string_add(
9032 json_addr
, "defaultRouteMap",
9033 p
->default_rmap
[afi
][safi
].name
);
9035 if (paf
&& PAF_SUBGRP(paf
)
9036 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9037 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9038 json_object_boolean_true_add(json_addr
,
9041 json_object_boolean_true_add(json_addr
,
9045 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9046 if (is_evpn_enabled())
9047 json_object_boolean_true_add(
9048 json_addr
, "advertiseAllVnis");
9051 if (filter
->plist
[FILTER_IN
].name
9052 || filter
->dlist
[FILTER_IN
].name
9053 || filter
->aslist
[FILTER_IN
].name
9054 || filter
->map
[RMAP_IN
].name
)
9055 json_object_boolean_true_add(json_addr
,
9056 "inboundPathPolicyConfig");
9057 if (filter
->plist
[FILTER_OUT
].name
9058 || filter
->dlist
[FILTER_OUT
].name
9059 || filter
->aslist
[FILTER_OUT
].name
9060 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9061 json_object_boolean_true_add(
9062 json_addr
, "outboundPathPolicyConfig");
9065 if (filter
->plist
[FILTER_IN
].name
)
9066 json_object_string_add(json_addr
,
9067 "incomingUpdatePrefixFilterList",
9068 filter
->plist
[FILTER_IN
].name
);
9069 if (filter
->plist
[FILTER_OUT
].name
)
9070 json_object_string_add(json_addr
,
9071 "outgoingUpdatePrefixFilterList",
9072 filter
->plist
[FILTER_OUT
].name
);
9074 /* distribute-list */
9075 if (filter
->dlist
[FILTER_IN
].name
)
9076 json_object_string_add(
9077 json_addr
, "incomingUpdateNetworkFilterList",
9078 filter
->dlist
[FILTER_IN
].name
);
9079 if (filter
->dlist
[FILTER_OUT
].name
)
9080 json_object_string_add(
9081 json_addr
, "outgoingUpdateNetworkFilterList",
9082 filter
->dlist
[FILTER_OUT
].name
);
9085 if (filter
->aslist
[FILTER_IN
].name
)
9086 json_object_string_add(json_addr
,
9087 "incomingUpdateAsPathFilterList",
9088 filter
->aslist
[FILTER_IN
].name
);
9089 if (filter
->aslist
[FILTER_OUT
].name
)
9090 json_object_string_add(json_addr
,
9091 "outgoingUpdateAsPathFilterList",
9092 filter
->aslist
[FILTER_OUT
].name
);
9095 if (filter
->map
[RMAP_IN
].name
)
9096 json_object_string_add(
9097 json_addr
, "routeMapForIncomingAdvertisements",
9098 filter
->map
[RMAP_IN
].name
);
9099 if (filter
->map
[RMAP_OUT
].name
)
9100 json_object_string_add(
9101 json_addr
, "routeMapForOutgoingAdvertisements",
9102 filter
->map
[RMAP_OUT
].name
);
9104 /* ebgp-requires-policy (inbound) */
9105 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9106 && !bgp_inbound_policy_exists(p
, filter
))
9107 json_object_string_add(
9108 json_addr
, "inboundEbgpRequiresPolicy",
9109 "Inbound updates discarded due to missing policy");
9111 /* ebgp-requires-policy (outbound) */
9112 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9113 && (!bgp_outbound_policy_exists(p
, filter
)))
9114 json_object_string_add(
9115 json_addr
, "outboundEbgpRequiresPolicy",
9116 "Outbound updates discarded due to missing policy");
9118 /* unsuppress-map */
9119 if (filter
->usmap
.name
)
9120 json_object_string_add(json_addr
,
9121 "selectiveUnsuppressRouteMap",
9122 filter
->usmap
.name
);
9124 /* Receive prefix count */
9125 json_object_int_add(json_addr
, "acceptedPrefixCounter",
9126 p
->pcount
[afi
][safi
]);
9127 if (paf
&& PAF_SUBGRP(paf
))
9128 json_object_int_add(json_addr
, "sentPrefixCounter",
9129 (PAF_SUBGRP(paf
))->scount
);
9131 /* Maximum prefix */
9132 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9133 json_object_int_add(json_addr
, "prefixAllowedMax",
9134 p
->pmax
[afi
][safi
]);
9135 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9136 PEER_FLAG_MAX_PREFIX_WARNING
))
9137 json_object_boolean_true_add(
9138 json_addr
, "prefixAllowedMaxWarning");
9139 json_object_int_add(json_addr
,
9140 "prefixAllowedWarningThresh",
9141 p
->pmax_threshold
[afi
][safi
]);
9142 if (p
->pmax_restart
[afi
][safi
])
9143 json_object_int_add(
9145 "prefixAllowedRestartIntervalMsecs",
9146 p
->pmax_restart
[afi
][safi
] * 60000);
9148 json_object_object_add(json_neigh
, get_afi_safi_str(afi
, safi
, true),
9152 filter
= &p
->filter
[afi
][safi
];
9154 vty_out(vty
, " For address family: %s\n",
9155 get_afi_safi_str(afi
, safi
, false));
9157 if (peer_group_active(p
))
9158 vty_out(vty
, " %s peer-group member\n",
9161 paf
= peer_af_find(p
, afi
, safi
);
9162 if (paf
&& PAF_SUBGRP(paf
)) {
9163 vty_out(vty
, " Update group %" PRIu64
9164 ", subgroup %" PRIu64
"\n",
9165 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
9166 vty_out(vty
, " Packet Queue length %d\n",
9167 bpacket_queue_virtual_length(paf
));
9169 vty_out(vty
, " Not part of any update group\n");
9171 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9172 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9173 PEER_CAP_ORF_PREFIX_SM_RCV
)
9174 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9175 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
9176 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9177 PEER_CAP_ORF_PREFIX_RM_ADV
)
9178 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9179 PEER_CAP_ORF_PREFIX_RM_RCV
)
9180 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9181 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
9182 vty_out(vty
, " AF-dependant capabilities:\n");
9184 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9185 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9186 PEER_CAP_ORF_PREFIX_SM_RCV
)
9187 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9188 PEER_CAP_ORF_PREFIX_RM_ADV
)
9189 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9190 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
9192 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
9194 bgp_show_peer_afi_orf_cap(
9195 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
9196 PEER_CAP_ORF_PREFIX_RM_ADV
,
9197 PEER_CAP_ORF_PREFIX_SM_RCV
,
9198 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
9200 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
9201 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9202 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
9203 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9204 PEER_CAP_ORF_PREFIX_RM_ADV
)
9205 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
9206 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
9208 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
9209 ORF_TYPE_PREFIX_OLD
);
9210 bgp_show_peer_afi_orf_cap(
9211 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
9212 PEER_CAP_ORF_PREFIX_RM_ADV
,
9213 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
9214 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
9217 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
9218 orf_pfx_count
= prefix_bgp_show_prefix_list(
9219 NULL
, afi
, orf_pfx_name
, use_json
);
9221 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9222 PEER_STATUS_ORF_PREFIX_SEND
)
9224 vty_out(vty
, " Outbound Route Filter (ORF):");
9225 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9226 PEER_STATUS_ORF_PREFIX_SEND
))
9227 vty_out(vty
, " sent;");
9229 vty_out(vty
, " received (%d entries)",
9233 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
9234 PEER_STATUS_ORF_WAIT_REFRESH
))
9236 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
9238 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9239 PEER_FLAG_REFLECTOR_CLIENT
))
9240 vty_out(vty
, " Route-Reflector Client\n");
9241 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9242 PEER_FLAG_RSERVER_CLIENT
))
9243 vty_out(vty
, " Route-Server Client\n");
9244 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
9246 " Inbound soft reconfiguration allowed\n");
9248 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9249 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
9251 " Private AS numbers (all) replaced in updates to this neighbor\n");
9252 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9253 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
9255 " Private AS numbers replaced in updates to this neighbor\n");
9256 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9257 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
9259 " Private AS numbers (all) removed in updates to this neighbor\n");
9260 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9261 PEER_FLAG_REMOVE_PRIVATE_AS
))
9263 " Private AS numbers removed in updates to this neighbor\n");
9265 if (p
->addpath_type
[afi
][safi
] != BGP_ADDPATH_NONE
)
9266 vty_out(vty
, " %s\n",
9267 bgp_addpath_names(p
->addpath_type
[afi
][safi
])
9268 ->human_description
);
9270 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
9272 " Override ASNs in outbound updates if aspath equals remote-as\n");
9274 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
9275 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
9276 PEER_FLAG_FORCE_NEXTHOP_SELF
))
9277 vty_out(vty
, " NEXT_HOP is always this router\n");
9278 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9279 PEER_FLAG_AS_PATH_UNCHANGED
))
9281 " AS_PATH is propagated unchanged to this neighbor\n");
9282 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9283 PEER_FLAG_NEXTHOP_UNCHANGED
))
9285 " NEXT_HOP is propagated unchanged to this neighbor\n");
9286 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
9288 " MED is propagated unchanged to this neighbor\n");
9289 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], 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
)) {
9295 " Community attribute sent to this neighbor");
9296 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9297 PEER_FLAG_SEND_COMMUNITY
)
9298 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9299 PEER_FLAG_SEND_EXT_COMMUNITY
)
9300 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
9301 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9302 vty_out(vty
, "(all)\n");
9303 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9304 PEER_FLAG_SEND_LARGE_COMMUNITY
))
9305 vty_out(vty
, "(large)\n");
9306 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9307 PEER_FLAG_SEND_EXT_COMMUNITY
))
9308 vty_out(vty
, "(extended)\n");
9310 vty_out(vty
, "(standard)\n");
9312 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
9313 PEER_FLAG_DEFAULT_ORIGINATE
)) {
9314 vty_out(vty
, " Default information originate,");
9316 if (p
->default_rmap
[afi
][safi
].name
)
9317 vty_out(vty
, " default route-map %s%s,",
9318 p
->default_rmap
[afi
][safi
].map
? "*"
9320 p
->default_rmap
[afi
][safi
].name
);
9321 if (paf
&& PAF_SUBGRP(paf
)
9322 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
9323 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
9324 vty_out(vty
, " default sent\n");
9326 vty_out(vty
, " default not sent\n");
9329 /* advertise-vni-all */
9330 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
9331 if (is_evpn_enabled())
9332 vty_out(vty
, " advertise-all-vni\n");
9335 if (filter
->plist
[FILTER_IN
].name
9336 || filter
->dlist
[FILTER_IN
].name
9337 || filter
->aslist
[FILTER_IN
].name
9338 || filter
->map
[RMAP_IN
].name
)
9339 vty_out(vty
, " Inbound path policy configured\n");
9340 if (filter
->plist
[FILTER_OUT
].name
9341 || filter
->dlist
[FILTER_OUT
].name
9342 || filter
->aslist
[FILTER_OUT
].name
9343 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
9344 vty_out(vty
, " Outbound path policy configured\n");
9347 if (filter
->plist
[FILTER_IN
].name
)
9349 " Incoming update prefix filter list is %s%s\n",
9350 filter
->plist
[FILTER_IN
].plist
? "*" : "",
9351 filter
->plist
[FILTER_IN
].name
);
9352 if (filter
->plist
[FILTER_OUT
].name
)
9354 " Outgoing update prefix filter list is %s%s\n",
9355 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
9356 filter
->plist
[FILTER_OUT
].name
);
9358 /* distribute-list */
9359 if (filter
->dlist
[FILTER_IN
].name
)
9361 " Incoming update network filter list is %s%s\n",
9362 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
9363 filter
->dlist
[FILTER_IN
].name
);
9364 if (filter
->dlist
[FILTER_OUT
].name
)
9366 " Outgoing update network filter list is %s%s\n",
9367 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
9368 filter
->dlist
[FILTER_OUT
].name
);
9371 if (filter
->aslist
[FILTER_IN
].name
)
9373 " Incoming update AS path filter list is %s%s\n",
9374 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
9375 filter
->aslist
[FILTER_IN
].name
);
9376 if (filter
->aslist
[FILTER_OUT
].name
)
9378 " Outgoing update AS path filter list is %s%s\n",
9379 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
9380 filter
->aslist
[FILTER_OUT
].name
);
9383 if (filter
->map
[RMAP_IN
].name
)
9385 " Route map for incoming advertisements is %s%s\n",
9386 filter
->map
[RMAP_IN
].map
? "*" : "",
9387 filter
->map
[RMAP_IN
].name
);
9388 if (filter
->map
[RMAP_OUT
].name
)
9390 " Route map for outgoing advertisements is %s%s\n",
9391 filter
->map
[RMAP_OUT
].map
? "*" : "",
9392 filter
->map
[RMAP_OUT
].name
);
9394 /* ebgp-requires-policy (inbound) */
9395 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9396 && !bgp_inbound_policy_exists(p
, filter
))
9398 " Inbound updates discarded due to missing policy\n");
9400 /* ebgp-requires-policy (outbound) */
9401 if (p
->bgp
->ebgp_requires_policy
== DEFAULT_EBGP_POLICY_ENABLED
9402 && !bgp_outbound_policy_exists(p
, filter
))
9404 " Outbound updates discarded due to missing policy\n");
9406 /* unsuppress-map */
9407 if (filter
->usmap
.name
)
9409 " Route map for selective unsuppress is %s%s\n",
9410 filter
->usmap
.map
? "*" : "",
9411 filter
->usmap
.name
);
9413 /* Receive prefix count */
9414 vty_out(vty
, " %" PRIu32
" accepted prefixes\n",
9415 p
->pcount
[afi
][safi
]);
9417 /* Maximum prefix */
9418 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
9420 " Maximum prefixes allowed %" PRIu32
"%s\n",
9422 CHECK_FLAG(p
->af_flags
[afi
][safi
],
9423 PEER_FLAG_MAX_PREFIX_WARNING
)
9426 vty_out(vty
, " Threshold for warning message %d%%",
9427 p
->pmax_threshold
[afi
][safi
]);
9428 if (p
->pmax_restart
[afi
][safi
])
9429 vty_out(vty
, ", restart interval %d min",
9430 p
->pmax_restart
[afi
][safi
]);
9438 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, bool use_json
,
9442 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
9443 char timebuf
[BGP_UPTIME_LEN
];
9449 json_object
*json_neigh
= NULL
;
9455 json_neigh
= json_object_new_object();
9457 memset(dn_flag
, '\0', sizeof(dn_flag
));
9458 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
9462 if (p
->conf_if
) /* Configured interface name. */
9463 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
9464 BGP_PEER_SU_UNSPEC(p
)
9466 : sockunion2str(&p
->su
, buf
,
9468 else /* Configured IP address. */
9469 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
9474 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
9475 json_object_string_add(json_neigh
, "bgpNeighborAddr",
9477 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
9478 json_object_string_add(
9479 json_neigh
, "bgpNeighborAddr",
9480 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
9482 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
9484 if (p
->change_local_as
)
9485 json_object_int_add(json_neigh
, "localAs",
9486 p
->change_local_as
);
9488 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
9490 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
9491 json_object_boolean_true_add(json_neigh
,
9492 "localAsNoPrepend");
9494 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
9495 json_object_boolean_true_add(json_neigh
,
9496 "localAsReplaceAs");
9498 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
9499 || (p
->as_type
== AS_INTERNAL
))
9500 vty_out(vty
, "remote AS %u, ", p
->as
);
9502 vty_out(vty
, "remote AS Unspecified, ");
9503 vty_out(vty
, "local AS %u%s%s, ",
9504 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
9505 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
9508 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
9512 /* peer type internal or confed-internal */
9513 if ((p
->as
== p
->local_as
) || (p
->as_type
== AS_INTERNAL
)) {
9515 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9516 json_object_boolean_true_add(
9517 json_neigh
, "nbrConfedInternalLink");
9519 json_object_boolean_true_add(json_neigh
,
9522 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9523 vty_out(vty
, "confed-internal link\n");
9525 vty_out(vty
, "internal link\n");
9527 /* peer type external or confed-external */
9528 } else if (p
->as
|| (p
->as_type
== AS_EXTERNAL
)) {
9530 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9531 json_object_boolean_true_add(
9532 json_neigh
, "nbrConfedExternalLink");
9534 json_object_boolean_true_add(json_neigh
,
9537 if (bgp_confederation_peers_check(bgp
, p
->as
))
9538 vty_out(vty
, "confed-external link\n");
9540 vty_out(vty
, "external link\n");
9544 json_object_boolean_true_add(json_neigh
,
9545 "nbrUnspecifiedLink");
9547 vty_out(vty
, "unspecified link\n");
9553 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9555 vty_out(vty
, " Description: %s\n", p
->desc
);
9561 json_object_string_add(json_neigh
, "hostname",
9565 json_object_string_add(json_neigh
, "domainname",
9568 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9569 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9572 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9579 json_object_string_add(json_neigh
, "peerGroup",
9583 struct prefix prefix
, *range
= NULL
;
9585 sockunion2hostprefix(&(p
->su
), &prefix
);
9586 range
= peer_group_lookup_dynamic_neighbor_range(
9590 prefix2str(range
, buf1
, sizeof(buf1
));
9591 json_object_string_add(
9593 "peerSubnetRangeGroup", buf1
);
9598 " Member of peer-group %s for session parameters\n",
9602 struct prefix prefix
, *range
= NULL
;
9604 sockunion2hostprefix(&(p
->su
), &prefix
);
9605 range
= peer_group_lookup_dynamic_neighbor_range(
9609 prefix2str(range
, buf1
, sizeof(buf1
));
9611 " Belongs to the subnet range group: %s\n",
9619 /* Administrative shutdown. */
9620 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9621 json_object_boolean_true_add(json_neigh
,
9625 json_object_int_add(json_neigh
, "bgpVersion", 4);
9626 json_object_string_add(
9627 json_neigh
, "remoteRouterId",
9628 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9629 json_object_string_add(
9630 json_neigh
, "localRouterId",
9631 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9635 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9636 && bgp_confederation_peers_check(bgp
, p
->as
))
9637 json_object_boolean_true_add(json_neigh
,
9641 json_object_string_add(
9642 json_neigh
, "bgpState",
9643 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9645 if (p
->status
== Established
) {
9648 uptime
= bgp_clock();
9649 uptime
-= p
->uptime
;
9650 epoch_tbuf
= time(NULL
) - uptime
;
9652 #if CONFDATE > 20200101
9654 "bgpTimerUp should be deprecated and can be removed now");
9657 * bgpTimerUp was miliseconds that was accurate
9658 * up to 1 day, then the value returned
9659 * became garbage. So in order to provide
9660 * some level of backwards compatability,
9661 * we still provde the data, but now
9662 * we are returning the correct value
9663 * and also adding a new bgpTimerUpMsec
9664 * which will allow us to deprecate
9667 json_object_int_add(json_neigh
, "bgpTimerUp",
9669 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9671 json_object_string_add(json_neigh
, "bgpTimerUpString",
9672 peer_uptime(p
->uptime
, timebuf
,
9675 json_object_int_add(json_neigh
,
9676 "bgpTimerUpEstablishedEpoch",
9680 else if (p
->status
== Active
) {
9681 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9682 json_object_string_add(json_neigh
, "bgpStateIs",
9684 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9685 json_object_string_add(json_neigh
, "bgpStateIs",
9693 uptime
= bgp_clock();
9694 uptime
-= p
->readtime
;
9695 tm
= gmtime(&uptime
);
9696 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9697 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9698 + (tm
->tm_hour
* 3600000));
9700 uptime
= bgp_clock();
9701 uptime
-= p
->last_write
;
9702 tm
= gmtime(&uptime
);
9703 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9704 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9705 + (tm
->tm_hour
* 3600000));
9707 uptime
= bgp_clock();
9708 uptime
-= p
->update_time
;
9709 tm
= gmtime(&uptime
);
9710 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9711 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9712 + (tm
->tm_hour
* 3600000));
9714 /* Configured timer values. */
9715 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9716 p
->v_holdtime
* 1000);
9717 json_object_int_add(json_neigh
,
9718 "bgpTimerKeepAliveIntervalMsecs",
9719 p
->v_keepalive
* 1000);
9720 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9721 json_object_int_add(json_neigh
,
9722 "bgpTimerConfiguredHoldTimeMsecs",
9723 p
->holdtime
* 1000);
9724 json_object_int_add(
9726 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9727 p
->keepalive
* 1000);
9728 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9729 || (bgp
->default_keepalive
9730 != BGP_DEFAULT_KEEPALIVE
)) {
9731 json_object_int_add(json_neigh
,
9732 "bgpTimerConfiguredHoldTimeMsecs",
9733 bgp
->default_holdtime
);
9734 json_object_int_add(
9736 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9737 bgp
->default_keepalive
);
9740 /* Administrative shutdown. */
9741 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9742 vty_out(vty
, " Administratively shut down\n");
9745 vty_out(vty
, " BGP version 4");
9746 vty_out(vty
, ", remote router ID %s",
9747 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9748 vty_out(vty
, ", local router ID %s\n",
9749 inet_ntop(AF_INET
, &bgp
->router_id
, buf1
,
9753 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9754 && bgp_confederation_peers_check(bgp
, p
->as
))
9756 " Neighbor under common administration\n");
9759 vty_out(vty
, " BGP state = %s",
9760 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9762 if (p
->status
== Established
)
9763 vty_out(vty
, ", up for %8s",
9764 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9767 else if (p
->status
== Active
) {
9768 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9769 vty_out(vty
, " (passive)");
9770 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9771 vty_out(vty
, " (NSF passive)");
9776 vty_out(vty
, " Last read %s",
9777 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9779 vty_out(vty
, ", Last write %s\n",
9780 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9783 /* Configured timer values. */
9785 " Hold time is %d, keepalive interval is %d seconds\n",
9786 p
->v_holdtime
, p
->v_keepalive
);
9787 if (CHECK_FLAG(p
->flags
, PEER_FLAG_TIMER
)) {
9788 vty_out(vty
, " Configured hold time is %d",
9790 vty_out(vty
, ", keepalive interval is %d seconds\n",
9792 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9793 || (bgp
->default_keepalive
9794 != BGP_DEFAULT_KEEPALIVE
)) {
9795 vty_out(vty
, " Configured hold time is %d",
9796 bgp
->default_holdtime
);
9797 vty_out(vty
, ", keepalive interval is %d seconds\n",
9798 bgp
->default_keepalive
);
9802 if (p
->status
== Established
) {
9803 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9804 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9805 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9806 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9807 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9808 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9809 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9810 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9811 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9812 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9813 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9814 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9815 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9816 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9817 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9818 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9819 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9820 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9821 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9822 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9824 json_object
*json_cap
= NULL
;
9826 json_cap
= json_object_new_object();
9829 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9830 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9831 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9832 && CHECK_FLAG(p
->cap
,
9834 json_object_string_add(
9835 json_cap
, "4byteAs",
9836 "advertisedAndReceived");
9837 else if (CHECK_FLAG(p
->cap
,
9839 json_object_string_add(
9840 json_cap
, "4byteAs",
9842 else if (CHECK_FLAG(p
->cap
,
9844 json_object_string_add(
9845 json_cap
, "4byteAs",
9850 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9851 || CHECK_FLAG(p
->cap
,
9852 PEER_CAP_ADDPATH_ADV
)) {
9853 json_object
*json_add
= NULL
;
9854 const char *print_store
;
9856 json_add
= json_object_new_object();
9858 FOREACH_AFI_SAFI (afi
, safi
) {
9859 json_object
*json_sub
= NULL
;
9861 json_object_new_object();
9862 print_store
= get_afi_safi_str(
9868 PEER_CAP_ADDPATH_AF_TX_ADV
)
9872 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9877 PEER_CAP_ADDPATH_AF_TX_ADV
)
9882 PEER_CAP_ADDPATH_AF_TX_RCV
))
9883 json_object_boolean_true_add(
9885 "txAdvertisedAndReceived");
9891 PEER_CAP_ADDPATH_AF_TX_ADV
))
9892 json_object_boolean_true_add(
9900 PEER_CAP_ADDPATH_AF_TX_RCV
))
9901 json_object_boolean_true_add(
9909 PEER_CAP_ADDPATH_AF_RX_ADV
)
9913 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9918 PEER_CAP_ADDPATH_AF_RX_ADV
)
9923 PEER_CAP_ADDPATH_AF_RX_RCV
))
9924 json_object_boolean_true_add(
9926 "rxAdvertisedAndReceived");
9932 PEER_CAP_ADDPATH_AF_RX_ADV
))
9933 json_object_boolean_true_add(
9941 PEER_CAP_ADDPATH_AF_RX_RCV
))
9942 json_object_boolean_true_add(
9950 PEER_CAP_ADDPATH_AF_TX_ADV
)
9954 PEER_CAP_ADDPATH_AF_TX_RCV
)
9958 PEER_CAP_ADDPATH_AF_RX_ADV
)
9962 PEER_CAP_ADDPATH_AF_RX_RCV
))
9963 json_object_object_add(
9972 json_object_object_add(
9973 json_cap
, "addPath", json_add
);
9977 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9978 || CHECK_FLAG(p
->cap
,
9979 PEER_CAP_DYNAMIC_ADV
)) {
9980 if (CHECK_FLAG(p
->cap
,
9981 PEER_CAP_DYNAMIC_ADV
)
9982 && CHECK_FLAG(p
->cap
,
9983 PEER_CAP_DYNAMIC_RCV
))
9984 json_object_string_add(
9985 json_cap
, "dynamic",
9986 "advertisedAndReceived");
9987 else if (CHECK_FLAG(
9989 PEER_CAP_DYNAMIC_ADV
))
9990 json_object_string_add(
9991 json_cap
, "dynamic",
9993 else if (CHECK_FLAG(
9995 PEER_CAP_DYNAMIC_RCV
))
9996 json_object_string_add(
9997 json_cap
, "dynamic",
10001 /* Extended nexthop */
10002 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10003 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10004 json_object
*json_nxt
= NULL
;
10005 const char *print_store
;
10008 if (CHECK_FLAG(p
->cap
,
10010 && CHECK_FLAG(p
->cap
,
10011 PEER_CAP_ENHE_RCV
))
10012 json_object_string_add(
10015 "advertisedAndReceived");
10016 else if (CHECK_FLAG(p
->cap
,
10017 PEER_CAP_ENHE_ADV
))
10018 json_object_string_add(
10022 else if (CHECK_FLAG(p
->cap
,
10023 PEER_CAP_ENHE_RCV
))
10024 json_object_string_add(
10029 if (CHECK_FLAG(p
->cap
,
10030 PEER_CAP_ENHE_RCV
)) {
10032 json_object_new_object();
10034 for (safi
= SAFI_UNICAST
;
10035 safi
< SAFI_MAX
; safi
++) {
10040 PEER_CAP_ENHE_AF_RCV
)) {
10041 print_store
= get_afi_safi_str(
10044 json_object_string_add(
10047 "recieved"); /* misspelled for compatibility */
10050 json_object_object_add(
10052 "extendedNexthopFamililesByPeer",
10057 /* Route Refresh */
10058 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10059 || CHECK_FLAG(p
->cap
,
10060 PEER_CAP_REFRESH_NEW_RCV
)
10061 || CHECK_FLAG(p
->cap
,
10062 PEER_CAP_REFRESH_OLD_RCV
)) {
10063 if (CHECK_FLAG(p
->cap
,
10064 PEER_CAP_REFRESH_ADV
)
10067 PEER_CAP_REFRESH_NEW_RCV
)
10070 PEER_CAP_REFRESH_OLD_RCV
))) {
10073 PEER_CAP_REFRESH_OLD_RCV
)
10076 PEER_CAP_REFRESH_NEW_RCV
))
10077 json_object_string_add(
10080 "advertisedAndReceivedOldNew");
10084 PEER_CAP_REFRESH_OLD_RCV
))
10085 json_object_string_add(
10088 "advertisedAndReceivedOld");
10090 json_object_string_add(
10093 "advertisedAndReceivedNew");
10098 PEER_CAP_REFRESH_ADV
))
10099 json_object_string_add(
10106 PEER_CAP_REFRESH_NEW_RCV
)
10109 PEER_CAP_REFRESH_OLD_RCV
))
10110 json_object_string_add(
10116 /* Multiprotocol Extensions */
10117 json_object
*json_multi
= NULL
;
10118 json_multi
= json_object_new_object();
10120 FOREACH_AFI_SAFI (afi
, safi
) {
10121 if (p
->afc_adv
[afi
][safi
]
10122 || p
->afc_recv
[afi
][safi
]) {
10123 json_object
*json_exten
= NULL
;
10125 json_object_new_object();
10127 if (p
->afc_adv
[afi
][safi
]
10128 && p
->afc_recv
[afi
][safi
])
10129 json_object_boolean_true_add(
10131 "advertisedAndReceived");
10132 else if (p
->afc_adv
[afi
][safi
])
10133 json_object_boolean_true_add(
10136 else if (p
->afc_recv
[afi
][safi
])
10137 json_object_boolean_true_add(
10141 json_object_object_add(
10143 get_afi_safi_str(afi
,
10149 json_object_object_add(
10150 json_cap
, "multiprotocolExtensions",
10153 /* Hostname capabilities */
10154 json_object
*json_hname
= NULL
;
10156 json_hname
= json_object_new_object();
10158 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10159 json_object_string_add(
10160 json_hname
, "advHostName",
10161 bgp
->peer_self
->hostname
10165 json_object_string_add(
10166 json_hname
, "advDomainName",
10167 bgp
->peer_self
->domainname
10174 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10175 json_object_string_add(
10176 json_hname
, "rcvHostName",
10177 p
->hostname
? p
->hostname
10179 json_object_string_add(
10180 json_hname
, "rcvDomainName",
10181 p
->domainname
? p
->domainname
10185 json_object_object_add(json_cap
, "hostName",
10188 /* Gracefull Restart */
10189 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10190 || CHECK_FLAG(p
->cap
,
10191 PEER_CAP_RESTART_ADV
)) {
10192 if (CHECK_FLAG(p
->cap
,
10193 PEER_CAP_RESTART_ADV
)
10194 && CHECK_FLAG(p
->cap
,
10195 PEER_CAP_RESTART_RCV
))
10196 json_object_string_add(
10199 "advertisedAndReceived");
10200 else if (CHECK_FLAG(
10202 PEER_CAP_RESTART_ADV
))
10203 json_object_string_add(
10205 "gracefulRestartCapability",
10207 else if (CHECK_FLAG(
10209 PEER_CAP_RESTART_RCV
))
10210 json_object_string_add(
10212 "gracefulRestartCapability",
10215 if (CHECK_FLAG(p
->cap
,
10216 PEER_CAP_RESTART_RCV
)) {
10217 int restart_af_count
= 0;
10218 json_object
*json_restart
=
10221 json_object_new_object();
10223 json_object_int_add(
10225 "gracefulRestartRemoteTimerMsecs",
10226 p
->v_gr_restart
* 1000);
10228 FOREACH_AFI_SAFI (afi
, safi
) {
10233 PEER_CAP_RESTART_AF_RCV
)) {
10238 json_object_new_object();
10244 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
10245 json_object_boolean_true_add(
10248 restart_af_count
++;
10249 json_object_object_add(
10258 if (!restart_af_count
) {
10259 json_object_string_add(
10261 "addressFamiliesByPeer",
10266 json_object_object_add(
10268 "addressFamiliesByPeer",
10272 json_object_object_add(json_neigh
,
10273 "neighborCapabilities",
10276 vty_out(vty
, " Neighbor capabilities:\n");
10279 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
10280 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
10281 vty_out(vty
, " 4 Byte AS:");
10282 if (CHECK_FLAG(p
->cap
,
10284 vty_out(vty
, " advertised");
10285 if (CHECK_FLAG(p
->cap
,
10287 vty_out(vty
, " %sreceived",
10293 vty_out(vty
, "\n");
10297 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
10298 || CHECK_FLAG(p
->cap
,
10299 PEER_CAP_ADDPATH_ADV
)) {
10300 vty_out(vty
, " AddPath:\n");
10302 FOREACH_AFI_SAFI (afi
, safi
) {
10306 PEER_CAP_ADDPATH_AF_TX_ADV
)
10310 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
10322 PEER_CAP_ADDPATH_AF_TX_ADV
))
10334 PEER_CAP_ADDPATH_AF_TX_RCV
))
10341 PEER_CAP_ADDPATH_AF_TX_ADV
)
10345 vty_out(vty
, "\n");
10351 PEER_CAP_ADDPATH_AF_RX_ADV
)
10355 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
10367 PEER_CAP_ADDPATH_AF_RX_ADV
))
10379 PEER_CAP_ADDPATH_AF_RX_RCV
))
10386 PEER_CAP_ADDPATH_AF_RX_ADV
)
10390 vty_out(vty
, "\n");
10396 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
10397 || CHECK_FLAG(p
->cap
,
10398 PEER_CAP_DYNAMIC_ADV
)) {
10399 vty_out(vty
, " Dynamic:");
10400 if (CHECK_FLAG(p
->cap
,
10401 PEER_CAP_DYNAMIC_ADV
))
10402 vty_out(vty
, " advertised");
10403 if (CHECK_FLAG(p
->cap
,
10404 PEER_CAP_DYNAMIC_RCV
))
10405 vty_out(vty
, " %sreceived",
10408 PEER_CAP_DYNAMIC_ADV
)
10411 vty_out(vty
, "\n");
10414 /* Extended nexthop */
10415 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
10416 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
10417 vty_out(vty
, " Extended nexthop:");
10418 if (CHECK_FLAG(p
->cap
,
10419 PEER_CAP_ENHE_ADV
))
10420 vty_out(vty
, " advertised");
10421 if (CHECK_FLAG(p
->cap
,
10422 PEER_CAP_ENHE_RCV
))
10423 vty_out(vty
, " %sreceived",
10429 vty_out(vty
, "\n");
10431 if (CHECK_FLAG(p
->cap
,
10432 PEER_CAP_ENHE_RCV
)) {
10434 " Address families by peer:\n ");
10435 for (safi
= SAFI_UNICAST
;
10436 safi
< SAFI_MAX
; safi
++)
10441 PEER_CAP_ENHE_AF_RCV
))
10451 /* Route Refresh */
10452 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
10453 || CHECK_FLAG(p
->cap
,
10454 PEER_CAP_REFRESH_NEW_RCV
)
10455 || CHECK_FLAG(p
->cap
,
10456 PEER_CAP_REFRESH_OLD_RCV
)) {
10457 vty_out(vty
, " Route refresh:");
10458 if (CHECK_FLAG(p
->cap
,
10459 PEER_CAP_REFRESH_ADV
))
10460 vty_out(vty
, " advertised");
10461 if (CHECK_FLAG(p
->cap
,
10462 PEER_CAP_REFRESH_NEW_RCV
)
10465 PEER_CAP_REFRESH_OLD_RCV
))
10466 vty_out(vty
, " %sreceived(%s)",
10469 PEER_CAP_REFRESH_ADV
)
10474 PEER_CAP_REFRESH_OLD_RCV
)
10477 PEER_CAP_REFRESH_NEW_RCV
))
10481 PEER_CAP_REFRESH_OLD_RCV
)
10485 vty_out(vty
, "\n");
10488 /* Multiprotocol Extensions */
10489 FOREACH_AFI_SAFI (afi
, safi
)
10490 if (p
->afc_adv
[afi
][safi
]
10491 || p
->afc_recv
[afi
][safi
]) {
10493 " Address Family %s:",
10498 if (p
->afc_adv
[afi
][safi
])
10501 if (p
->afc_recv
[afi
][safi
])
10508 vty_out(vty
, "\n");
10511 /* Hostname capability */
10512 vty_out(vty
, " Hostname Capability:");
10514 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
10516 " advertised (name: %s,domain name: %s)",
10517 bgp
->peer_self
->hostname
10521 bgp
->peer_self
->domainname
10526 vty_out(vty
, " not advertised");
10529 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
10531 " received (name: %s,domain name: %s)",
10532 p
->hostname
? p
->hostname
10534 p
->domainname
? p
->domainname
10537 vty_out(vty
, " not received");
10540 vty_out(vty
, "\n");
10542 /* Gracefull Restart */
10543 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10544 || CHECK_FLAG(p
->cap
,
10545 PEER_CAP_RESTART_ADV
)) {
10547 " Graceful Restart Capabilty:");
10548 if (CHECK_FLAG(p
->cap
,
10549 PEER_CAP_RESTART_ADV
))
10550 vty_out(vty
, " advertised");
10551 if (CHECK_FLAG(p
->cap
,
10552 PEER_CAP_RESTART_RCV
))
10553 vty_out(vty
, " %sreceived",
10556 PEER_CAP_RESTART_ADV
)
10559 vty_out(vty
, "\n");
10561 if (CHECK_FLAG(p
->cap
,
10562 PEER_CAP_RESTART_RCV
)) {
10563 int restart_af_count
= 0;
10566 " Remote Restart timer is %d seconds\n",
10569 " Address families by peer:\n ");
10571 FOREACH_AFI_SAFI (afi
, safi
)
10576 PEER_CAP_RESTART_AF_RCV
)) {
10590 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10592 : "not preserved");
10593 restart_af_count
++;
10595 if (!restart_af_count
)
10596 vty_out(vty
, "none");
10597 vty_out(vty
, "\n");
10604 /* graceful restart information */
10605 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10606 || p
->t_gr_stale
) {
10607 json_object
*json_grace
= NULL
;
10608 json_object
*json_grace_send
= NULL
;
10609 json_object
*json_grace_recv
= NULL
;
10610 int eor_send_af_count
= 0;
10611 int eor_receive_af_count
= 0;
10614 json_grace
= json_object_new_object();
10615 json_grace_send
= json_object_new_object();
10616 json_grace_recv
= json_object_new_object();
10618 if (p
->status
== Established
) {
10619 FOREACH_AFI_SAFI (afi
, safi
) {
10620 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10621 PEER_STATUS_EOR_SEND
)) {
10622 json_object_boolean_true_add(
10624 get_afi_safi_str(afi
,
10627 eor_send_af_count
++;
10630 FOREACH_AFI_SAFI (afi
, safi
) {
10632 p
->af_sflags
[afi
][safi
],
10633 PEER_STATUS_EOR_RECEIVED
)) {
10634 json_object_boolean_true_add(
10636 get_afi_safi_str(afi
,
10639 eor_receive_af_count
++;
10644 json_object_object_add(json_grace
, "endOfRibSend",
10646 json_object_object_add(json_grace
, "endOfRibRecv",
10649 if (p
->t_gr_restart
)
10650 json_object_int_add(json_grace
,
10651 "gracefulRestartTimerMsecs",
10652 thread_timer_remain_second(
10657 json_object_int_add(
10659 "gracefulStalepathTimerMsecs",
10660 thread_timer_remain_second(
10664 json_object_object_add(
10665 json_neigh
, "gracefulRestartInfo", json_grace
);
10667 vty_out(vty
, " Graceful restart information:\n");
10668 if (p
->status
== Established
) {
10669 vty_out(vty
, " End-of-RIB send: ");
10670 FOREACH_AFI_SAFI (afi
, safi
) {
10671 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10672 PEER_STATUS_EOR_SEND
)) {
10673 vty_out(vty
, "%s%s",
10674 eor_send_af_count
? ", "
10676 get_afi_safi_str(afi
,
10679 eor_send_af_count
++;
10682 vty_out(vty
, "\n");
10683 vty_out(vty
, " End-of-RIB received: ");
10684 FOREACH_AFI_SAFI (afi
, safi
) {
10686 p
->af_sflags
[afi
][safi
],
10687 PEER_STATUS_EOR_RECEIVED
)) {
10688 vty_out(vty
, "%s%s",
10689 eor_receive_af_count
10692 get_afi_safi_str(afi
,
10695 eor_receive_af_count
++;
10698 vty_out(vty
, "\n");
10701 if (p
->t_gr_restart
)
10703 " The remaining time of restart timer is %ld\n",
10704 thread_timer_remain_second(
10709 " The remaining time of stalepath timer is %ld\n",
10710 thread_timer_remain_second(
10715 json_object
*json_stat
= NULL
;
10716 json_stat
= json_object_new_object();
10717 /* Packet counts. */
10718 json_object_int_add(json_stat
, "depthInq", 0);
10719 json_object_int_add(json_stat
, "depthOutq",
10720 (unsigned long)p
->obuf
->count
);
10721 json_object_int_add(json_stat
, "opensSent",
10722 atomic_load_explicit(&p
->open_out
,
10723 memory_order_relaxed
));
10724 json_object_int_add(json_stat
, "opensRecv",
10725 atomic_load_explicit(&p
->open_in
,
10726 memory_order_relaxed
));
10727 json_object_int_add(json_stat
, "notificationsSent",
10728 atomic_load_explicit(&p
->notify_out
,
10729 memory_order_relaxed
));
10730 json_object_int_add(json_stat
, "notificationsRecv",
10731 atomic_load_explicit(&p
->notify_in
,
10732 memory_order_relaxed
));
10733 json_object_int_add(json_stat
, "updatesSent",
10734 atomic_load_explicit(&p
->update_out
,
10735 memory_order_relaxed
));
10736 json_object_int_add(json_stat
, "updatesRecv",
10737 atomic_load_explicit(&p
->update_in
,
10738 memory_order_relaxed
));
10739 json_object_int_add(json_stat
, "keepalivesSent",
10740 atomic_load_explicit(&p
->keepalive_out
,
10741 memory_order_relaxed
));
10742 json_object_int_add(json_stat
, "keepalivesRecv",
10743 atomic_load_explicit(&p
->keepalive_in
,
10744 memory_order_relaxed
));
10745 json_object_int_add(json_stat
, "routeRefreshSent",
10746 atomic_load_explicit(&p
->refresh_out
,
10747 memory_order_relaxed
));
10748 json_object_int_add(json_stat
, "routeRefreshRecv",
10749 atomic_load_explicit(&p
->refresh_in
,
10750 memory_order_relaxed
));
10751 json_object_int_add(json_stat
, "capabilitySent",
10752 atomic_load_explicit(&p
->dynamic_cap_out
,
10753 memory_order_relaxed
));
10754 json_object_int_add(json_stat
, "capabilityRecv",
10755 atomic_load_explicit(&p
->dynamic_cap_in
,
10756 memory_order_relaxed
));
10757 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10758 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10759 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10761 /* Packet counts. */
10762 vty_out(vty
, " Message statistics:\n");
10763 vty_out(vty
, " Inq depth is 0\n");
10764 vty_out(vty
, " Outq depth is %lu\n",
10765 (unsigned long)p
->obuf
->count
);
10766 vty_out(vty
, " Sent Rcvd\n");
10767 vty_out(vty
, " Opens: %10d %10d\n",
10768 atomic_load_explicit(&p
->open_out
,
10769 memory_order_relaxed
),
10770 atomic_load_explicit(&p
->open_in
,
10771 memory_order_relaxed
));
10772 vty_out(vty
, " Notifications: %10d %10d\n",
10773 atomic_load_explicit(&p
->notify_out
,
10774 memory_order_relaxed
),
10775 atomic_load_explicit(&p
->notify_in
,
10776 memory_order_relaxed
));
10777 vty_out(vty
, " Updates: %10d %10d\n",
10778 atomic_load_explicit(&p
->update_out
,
10779 memory_order_relaxed
),
10780 atomic_load_explicit(&p
->update_in
,
10781 memory_order_relaxed
));
10782 vty_out(vty
, " Keepalives: %10d %10d\n",
10783 atomic_load_explicit(&p
->keepalive_out
,
10784 memory_order_relaxed
),
10785 atomic_load_explicit(&p
->keepalive_in
,
10786 memory_order_relaxed
));
10787 vty_out(vty
, " Route Refresh: %10d %10d\n",
10788 atomic_load_explicit(&p
->refresh_out
,
10789 memory_order_relaxed
),
10790 atomic_load_explicit(&p
->refresh_in
,
10791 memory_order_relaxed
));
10792 vty_out(vty
, " Capability: %10d %10d\n",
10793 atomic_load_explicit(&p
->dynamic_cap_out
,
10794 memory_order_relaxed
),
10795 atomic_load_explicit(&p
->dynamic_cap_in
,
10796 memory_order_relaxed
));
10797 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10802 /* advertisement-interval */
10803 json_object_int_add(json_neigh
,
10804 "minBtwnAdvertisementRunsTimerMsecs",
10805 p
->v_routeadv
* 1000);
10807 /* Update-source. */
10808 if (p
->update_if
|| p
->update_source
) {
10810 json_object_string_add(json_neigh
,
10813 else if (p
->update_source
)
10814 json_object_string_add(
10815 json_neigh
, "updateSource",
10816 sockunion2str(p
->update_source
, buf1
,
10820 /* advertisement-interval */
10822 " Minimum time between advertisement runs is %d seconds\n",
10825 /* Update-source. */
10826 if (p
->update_if
|| p
->update_source
) {
10827 vty_out(vty
, " Update source is ");
10829 vty_out(vty
, "%s", p
->update_if
);
10830 else if (p
->update_source
)
10832 sockunion2str(p
->update_source
, buf1
,
10834 vty_out(vty
, "\n");
10837 vty_out(vty
, "\n");
10840 /* Address Family Information */
10841 json_object
*json_hold
= NULL
;
10844 json_hold
= json_object_new_object();
10846 FOREACH_AFI_SAFI (afi
, safi
)
10847 if (p
->afc
[afi
][safi
])
10848 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10852 json_object_object_add(json_neigh
, "addressFamilyInfo",
10854 json_object_int_add(json_neigh
, "connectionsEstablished",
10856 json_object_int_add(json_neigh
, "connectionsDropped",
10859 vty_out(vty
, " Connections established %d; dropped %d\n",
10860 p
->established
, p
->dropped
);
10862 if (!p
->last_reset
) {
10864 json_object_string_add(json_neigh
, "lastReset",
10867 vty_out(vty
, " Last reset never\n");
10873 uptime
= bgp_clock();
10874 uptime
-= p
->resettime
;
10875 tm
= gmtime(&uptime
);
10876 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10877 (tm
->tm_sec
* 1000)
10878 + (tm
->tm_min
* 60000)
10879 + (tm
->tm_hour
* 3600000));
10880 bgp_show_peer_reset(NULL
, p
, json_neigh
, true);
10882 vty_out(vty
, " Last reset %s, ",
10883 peer_uptime(p
->resettime
, timebuf
,
10884 BGP_UPTIME_LEN
, 0, NULL
));
10886 bgp_show_peer_reset(vty
, p
, NULL
, false);
10887 if (p
->last_reset_cause_size
) {
10888 msg
= p
->last_reset_cause
;
10890 " Message received that caused BGP to send a NOTIFICATION:\n ");
10891 for (i
= 1; i
<= p
->last_reset_cause_size
;
10893 vty_out(vty
, "%02X", *msg
++);
10895 if (i
!= p
->last_reset_cause_size
) {
10897 vty_out(vty
, "\n ");
10898 } else if (i
% 4 == 0) {
10903 vty_out(vty
, "\n");
10908 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10910 json_object_boolean_true_add(json_neigh
,
10911 "prefixesConfigExceedMax");
10914 " Peer had exceeded the max. no. of prefixes configured.\n");
10916 if (p
->t_pmax_restart
) {
10918 json_object_boolean_true_add(
10919 json_neigh
, "reducePrefixNumFrom");
10920 json_object_int_add(json_neigh
,
10921 "restartInTimerMsec",
10922 thread_timer_remain_second(
10927 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10928 p
->host
, thread_timer_remain_second(
10929 p
->t_pmax_restart
));
10932 json_object_boolean_true_add(
10934 "reducePrefixNumAndClearIpBgp");
10937 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10942 /* EBGP Multihop and GTSM */
10943 if (p
->sort
!= BGP_PEER_IBGP
) {
10945 if (p
->gtsm_hops
> 0)
10946 json_object_int_add(json_neigh
,
10947 "externalBgpNbrMaxHopsAway",
10949 else if (p
->ttl
> BGP_DEFAULT_TTL
)
10950 json_object_int_add(json_neigh
,
10951 "externalBgpNbrMaxHopsAway",
10954 if (p
->gtsm_hops
> 0)
10956 " External BGP neighbor may be up to %d hops away.\n",
10958 else if (p
->ttl
> BGP_DEFAULT_TTL
)
10960 " External BGP neighbor may be up to %d hops away.\n",
10964 if (p
->gtsm_hops
> 0) {
10966 json_object_int_add(json_neigh
,
10967 "internalBgpNbrMaxHopsAway",
10971 " Internal BGP neighbor may be up to %d hops away.\n",
10976 /* Local address. */
10979 json_object_string_add(json_neigh
, "hostLocal",
10980 sockunion2str(p
->su_local
, buf1
,
10982 json_object_int_add(json_neigh
, "portLocal",
10983 ntohs(p
->su_local
->sin
.sin_port
));
10985 vty_out(vty
, "Local host: %s, Local port: %d\n",
10986 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10987 ntohs(p
->su_local
->sin
.sin_port
));
10990 /* Remote address. */
10991 if (p
->su_remote
) {
10993 json_object_string_add(json_neigh
, "hostForeign",
10994 sockunion2str(p
->su_remote
, buf1
,
10996 json_object_int_add(json_neigh
, "portForeign",
10997 ntohs(p
->su_remote
->sin
.sin_port
));
10999 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
11000 sockunion2str(p
->su_remote
, buf1
,
11002 ntohs(p
->su_remote
->sin
.sin_port
));
11005 /* Nexthop display. */
11008 json_object_string_add(json_neigh
, "nexthop",
11010 &p
->nexthop
.v4
, buf1
,
11012 json_object_string_add(json_neigh
, "nexthopGlobal",
11013 inet_ntop(AF_INET6
,
11014 &p
->nexthop
.v6_global
,
11015 buf1
, sizeof(buf1
)));
11016 json_object_string_add(json_neigh
, "nexthopLocal",
11017 inet_ntop(AF_INET6
,
11018 &p
->nexthop
.v6_local
,
11019 buf1
, sizeof(buf1
)));
11020 if (p
->shared_network
)
11021 json_object_string_add(json_neigh
,
11025 json_object_string_add(json_neigh
,
11027 "nonSharedNetwork");
11029 vty_out(vty
, "Nexthop: %s\n",
11030 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
11032 vty_out(vty
, "Nexthop global: %s\n",
11033 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
11035 vty_out(vty
, "Nexthop local: %s\n",
11036 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
11038 vty_out(vty
, "BGP connection: %s\n",
11039 p
->shared_network
? "shared network"
11040 : "non shared network");
11044 /* Timer information. */
11046 json_object_int_add(json_neigh
, "connectRetryTimer",
11048 if (p
->status
== Established
&& p
->rtt
)
11049 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
11052 json_object_int_add(
11053 json_neigh
, "nextStartTimerDueInMsecs",
11054 thread_timer_remain_second(p
->t_start
) * 1000);
11056 json_object_int_add(
11057 json_neigh
, "nextConnectTimerDueInMsecs",
11058 thread_timer_remain_second(p
->t_connect
)
11060 if (p
->t_routeadv
) {
11061 json_object_int_add(json_neigh
, "mraiInterval",
11063 json_object_int_add(
11064 json_neigh
, "mraiTimerExpireInMsecs",
11065 thread_timer_remain_second(p
->t_routeadv
)
11069 json_object_int_add(json_neigh
, "authenticationEnabled",
11073 json_object_string_add(json_neigh
, "readThread", "on");
11075 json_object_string_add(json_neigh
, "readThread", "off");
11077 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
11078 json_object_string_add(json_neigh
, "writeThread", "on");
11080 json_object_string_add(json_neigh
, "writeThread",
11083 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
11085 if (p
->status
== Established
&& p
->rtt
)
11086 vty_out(vty
, "Estimated round trip time: %d ms\n",
11089 vty_out(vty
, "Next start timer due in %ld seconds\n",
11090 thread_timer_remain_second(p
->t_start
));
11092 vty_out(vty
, "Next connect timer due in %ld seconds\n",
11093 thread_timer_remain_second(p
->t_connect
));
11096 "MRAI (interval %u) timer expires in %ld seconds\n",
11098 thread_timer_remain_second(p
->t_routeadv
));
11100 vty_out(vty
, "Peer Authentication Enabled\n");
11102 vty_out(vty
, "Read thread: %s Write thread: %s FD used: %d\n",
11103 p
->t_read
? "on" : "off",
11104 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
11109 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
11110 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
11111 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
11114 vty_out(vty
, "\n");
11116 /* BFD information. */
11117 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
11120 if (p
->conf_if
) /* Configured interface name. */
11121 json_object_object_add(json
, p
->conf_if
, json_neigh
);
11122 else /* Configured IP address. */
11123 json_object_object_add(json
, p
->host
, json_neigh
);
11127 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
11128 enum show_type type
, union sockunion
*su
,
11129 const char *conf_if
, bool use_json
,
11132 struct listnode
*node
, *nnode
;
11135 bool nbr_output
= false;
11136 afi_t afi
= AFI_MAX
;
11137 safi_t safi
= SAFI_MAX
;
11139 if (type
== show_ipv4_peer
|| type
== show_ipv4_all
) {
11141 } else if (type
== show_ipv6_peer
|| type
== show_ipv6_all
) {
11145 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
11146 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
11151 bgp_show_peer(vty
, peer
, use_json
, json
);
11157 && !strcmp(peer
->conf_if
, conf_if
))
11159 && !strcmp(peer
->hostname
, conf_if
))) {
11161 bgp_show_peer(vty
, peer
, use_json
,
11165 if (sockunion_same(&peer
->su
, su
)) {
11167 bgp_show_peer(vty
, peer
, use_json
,
11172 case show_ipv4_peer
:
11173 case show_ipv6_peer
:
11174 FOREACH_SAFI (safi
) {
11175 if (peer
->afc
[afi
][safi
]) {
11178 && !strcmp(peer
->conf_if
, conf_if
))
11180 && !strcmp(peer
->hostname
, conf_if
))) {
11182 bgp_show_peer(vty
, peer
, use_json
,
11187 if (sockunion_same(&peer
->su
, su
)) {
11189 bgp_show_peer(vty
, peer
, use_json
,
11197 case show_ipv4_all
:
11198 case show_ipv6_all
:
11199 FOREACH_SAFI (safi
) {
11200 if (peer
->afc
[afi
][safi
]) {
11201 bgp_show_peer(vty
, peer
, use_json
, json
);
11210 if ((type
== show_peer
|| type
== show_ipv4_peer
||
11211 type
== show_ipv6_peer
) && !find
) {
11213 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
11215 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
11218 if (type
!= show_peer
&& type
!= show_ipv4_peer
&&
11219 type
!= show_ipv6_peer
&& !nbr_output
&& !use_json
)
11220 vty_out(vty
, "%% No BGP neighbors found\n");
11223 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
11224 json
, JSON_C_TO_STRING_PRETTY
));
11226 vty_out(vty
, "\n");
11229 return CMD_SUCCESS
;
11232 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
11233 enum show_type type
,
11234 const char *ip_str
,
11237 struct listnode
*node
, *nnode
;
11239 union sockunion su
;
11240 json_object
*json
= NULL
;
11241 int ret
, is_first
= 1;
11242 bool nbr_output
= false;
11245 vty_out(vty
, "{\n");
11247 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11250 if (!(json
= json_object_new_object())) {
11252 EC_BGP_JSON_MEM_ERROR
,
11253 "Unable to allocate memory for JSON object");
11255 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
11259 json_object_int_add(json
, "vrfId",
11260 (bgp
->vrf_id
== VRF_UNKNOWN
)
11262 : (int64_t)bgp
->vrf_id
);
11263 json_object_string_add(
11265 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11270 vty_out(vty
, ",\n");
11274 vty_out(vty
, "\"%s\":",
11275 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11279 vty_out(vty
, "\nInstance %s:\n",
11280 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11285 if (type
== show_peer
|| type
== show_ipv4_peer
||
11286 type
== show_ipv6_peer
) {
11287 ret
= str2sockunion(ip_str
, &su
);
11289 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11292 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11295 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
,
11298 json_object_free(json
);
11302 vty_out(vty
, "}\n");
11303 json_object_free(json
);
11305 else if (!nbr_output
)
11306 vty_out(vty
, "%% BGP instance not found\n");
11309 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
11310 enum show_type type
, const char *ip_str
,
11315 union sockunion su
;
11316 json_object
*json
= NULL
;
11319 if (strmatch(name
, "all")) {
11320 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
11322 return CMD_SUCCESS
;
11324 bgp
= bgp_lookup_by_name(name
);
11327 json
= json_object_new_object();
11328 vty_out(vty
, "%s\n",
11329 json_object_to_json_string_ext(
11331 JSON_C_TO_STRING_PRETTY
));
11332 json_object_free(json
);
11335 "%% BGP instance not found\n");
11337 return CMD_WARNING
;
11341 bgp
= bgp_get_default();
11345 json
= json_object_new_object();
11347 ret
= str2sockunion(ip_str
, &su
);
11349 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
11352 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
11355 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
11358 json_object_free(json
);
11361 vty_out(vty
, "{}\n");
11363 vty_out(vty
, "%% BGP instance not found\n");
11366 return CMD_SUCCESS
;
11369 /* "show [ip] bgp neighbors" commands. */
11370 DEFUN (show_ip_bgp_neighbors
,
11371 show_ip_bgp_neighbors_cmd
,
11372 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
11376 BGP_INSTANCE_HELP_STR
11379 "Detailed information on TCP and BGP neighbor connections\n"
11380 "Neighbor to display information about\n"
11381 "Neighbor to display information about\n"
11382 "Neighbor on BGP configured interface\n"
11386 char *sh_arg
= NULL
;
11387 enum show_type sh_type
;
11388 afi_t afi
= AFI_MAX
;
11390 bool uj
= use_json(argc
, argv
);
11394 /* [<vrf> VIEWVRFNAME] */
11395 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11396 vrf
= argv
[idx
+ 1]->arg
;
11397 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11399 } else if (argv_find(argv
, argc
, "view", &idx
))
11400 /* [<view> VIEWVRFNAME] */
11401 vrf
= argv
[idx
+ 1]->arg
;
11405 if (argv_find(argv
, argc
, "ipv4", &idx
)) {
11406 sh_type
= show_ipv4_all
;
11408 } else if (argv_find(argv
, argc
, "ipv6", &idx
)) {
11409 sh_type
= show_ipv6_all
;
11412 sh_type
= show_all
;
11415 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
11416 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
11417 || argv_find(argv
, argc
, "WORD", &idx
)) {
11418 sh_type
= show_peer
;
11419 sh_arg
= argv
[idx
]->arg
;
11422 if (sh_type
== show_peer
&& afi
== AFI_IP
) {
11423 sh_type
= show_ipv4_peer
;
11424 } else if (sh_type
== show_peer
&& afi
== AFI_IP6
) {
11425 sh_type
= show_ipv6_peer
;
11428 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
11431 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
11432 paths' and `show ip mbgp paths'. Those functions results are the
11434 DEFUN (show_ip_bgp_paths
,
11435 show_ip_bgp_paths_cmd
,
11436 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
11441 "Path information\n")
11443 vty_out(vty
, "Address Refcnt Path\n");
11444 aspath_print_all_vty(vty
);
11445 return CMD_SUCCESS
;
11450 static void community_show_all_iterator(struct hash_bucket
*bucket
,
11453 struct community
*com
;
11455 com
= (struct community
*)bucket
->data
;
11456 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
11457 community_str(com
, false));
11460 /* Show BGP's community internal data. */
11461 DEFUN (show_ip_bgp_community_info
,
11462 show_ip_bgp_community_info_cmd
,
11463 "show [ip] bgp community-info",
11467 "List all bgp community information\n")
11469 vty_out(vty
, "Address Refcnt Community\n");
11471 hash_iterate(community_hash(),
11472 (void (*)(struct hash_bucket
*,
11473 void *))community_show_all_iterator
,
11476 return CMD_SUCCESS
;
11479 static void lcommunity_show_all_iterator(struct hash_bucket
*bucket
,
11482 struct lcommunity
*lcom
;
11484 lcom
= (struct lcommunity
*)bucket
->data
;
11485 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
11486 lcommunity_str(lcom
, false));
11489 /* Show BGP's community internal data. */
11490 DEFUN (show_ip_bgp_lcommunity_info
,
11491 show_ip_bgp_lcommunity_info_cmd
,
11492 "show ip bgp large-community-info",
11496 "List all bgp large-community information\n")
11498 vty_out(vty
, "Address Refcnt Large-community\n");
11500 hash_iterate(lcommunity_hash(),
11501 (void (*)(struct hash_bucket
*,
11502 void *))lcommunity_show_all_iterator
,
11505 return CMD_SUCCESS
;
11509 DEFUN (show_ip_bgp_attr_info
,
11510 show_ip_bgp_attr_info_cmd
,
11511 "show [ip] bgp attribute-info",
11515 "List all bgp attribute information\n")
11517 attr_show_all(vty
);
11518 return CMD_SUCCESS
;
11521 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
11522 afi_t afi
, safi_t safi
,
11523 bool use_json
, json_object
*json
)
11526 struct listnode
*node
;
11528 char buf1
[INET6_ADDRSTRLEN
];
11530 vpn_policy_direction_t dir
;
11533 json_object
*json_import_vrfs
= NULL
;
11534 json_object
*json_export_vrfs
= NULL
;
11536 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11539 vty_out(vty
, "%s\n",
11540 json_object_to_json_string_ext(
11542 JSON_C_TO_STRING_PRETTY
));
11543 json_object_free(json
);
11545 return CMD_WARNING
;
11548 /* Provide context for the block */
11549 json_object_string_add(json
, "vrf", name
? name
: "default");
11550 json_object_string_add(json
, "afiSafi",
11551 get_afi_safi_str(afi
, safi
, true));
11553 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11554 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
11555 json_object_string_add(json
, "importFromVrfs", "none");
11556 json_object_string_add(json
, "importRts", "none");
11558 json_import_vrfs
= json_object_new_array();
11560 for (ALL_LIST_ELEMENTS_RO(
11561 bgp
->vpn_policy
[afi
].import_vrf
,
11563 json_object_array_add(json_import_vrfs
,
11564 json_object_new_string(vname
));
11566 json_object_object_add(json
, "importFromVrfs",
11568 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11569 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11570 ecom_str
= ecommunity_ecom2str(
11571 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11572 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11573 json_object_string_add(json
, "importRts",
11575 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11577 json_object_string_add(json
, "importRts",
11581 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11582 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11583 json_object_string_add(json
, "exportToVrfs", "none");
11584 json_object_string_add(json
, "routeDistinguisher",
11586 json_object_string_add(json
, "exportRts", "none");
11588 json_export_vrfs
= json_object_new_array();
11590 for (ALL_LIST_ELEMENTS_RO(
11591 bgp
->vpn_policy
[afi
].export_vrf
,
11593 json_object_array_add(json_export_vrfs
,
11594 json_object_new_string(vname
));
11595 json_object_object_add(json
, "exportToVrfs",
11597 json_object_string_add(json
, "routeDistinguisher",
11598 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11599 buf1
, RD_ADDRSTRLEN
));
11601 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11602 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11603 ecom_str
= ecommunity_ecom2str(
11604 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11605 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11606 json_object_string_add(json
, "exportRts",
11608 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11610 json_object_string_add(json
, "exportRts",
11615 vty_out(vty
, "%s\n",
11616 json_object_to_json_string_ext(json
,
11617 JSON_C_TO_STRING_PRETTY
));
11618 json_object_free(json
);
11621 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11624 vty_out(vty
, "%% No such BGP instance exist\n");
11625 return CMD_WARNING
;
11628 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11629 BGP_CONFIG_VRF_TO_VRF_IMPORT
))
11631 "This VRF is not importing %s routes from any other VRF\n",
11632 get_afi_safi_str(afi
, safi
, false));
11635 "This VRF is importing %s routes from the following VRFs:\n",
11636 get_afi_safi_str(afi
, safi
, false));
11638 for (ALL_LIST_ELEMENTS_RO(
11639 bgp
->vpn_policy
[afi
].import_vrf
,
11641 vty_out(vty
, " %s\n", vname
);
11643 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11645 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11646 ecom_str
= ecommunity_ecom2str(
11647 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11648 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11649 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11651 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11653 vty_out(vty
, "Import RT(s):\n");
11656 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11657 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
11659 "This VRF is not exporting %s routes to any other VRF\n",
11660 get_afi_safi_str(afi
, safi
, false));
11663 "This VRF is exporting %s routes to the following VRFs:\n",
11664 get_afi_safi_str(afi
, safi
, false));
11666 for (ALL_LIST_ELEMENTS_RO(
11667 bgp
->vpn_policy
[afi
].export_vrf
,
11669 vty_out(vty
, " %s\n", vname
);
11671 vty_out(vty
, "RD: %s\n",
11672 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11673 buf1
, RD_ADDRSTRLEN
));
11675 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11676 if (bgp
->vpn_policy
[afi
].rtlist
[dir
]) {
11677 ecom_str
= ecommunity_ecom2str(
11678 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11679 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11680 vty_out(vty
, "Export RT: %s\n", ecom_str
);
11681 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11683 vty_out(vty
, "Import RT(s):\n");
11687 return CMD_SUCCESS
;
11690 static int bgp_show_all_instance_route_leak_vty(struct vty
*vty
, afi_t afi
,
11691 safi_t safi
, bool use_json
)
11693 struct listnode
*node
, *nnode
;
11695 char *vrf_name
= NULL
;
11696 json_object
*json
= NULL
;
11697 json_object
*json_vrf
= NULL
;
11698 json_object
*json_vrfs
= NULL
;
11701 json
= json_object_new_object();
11702 json_vrfs
= json_object_new_object();
11705 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11707 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
)
11708 vrf_name
= bgp
->name
;
11711 json_vrf
= json_object_new_object();
11713 vty_out(vty
, "\nInstance %s:\n",
11714 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11715 ? VRF_DEFAULT_NAME
: bgp
->name
);
11717 bgp_show_route_leak_vty(vty
, vrf_name
, afi
, safi
, 0, json_vrf
);
11719 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11720 json_object_object_add(json_vrfs
,
11721 VRF_DEFAULT_NAME
, json_vrf
);
11723 json_object_object_add(json_vrfs
, vrf_name
,
11729 json_object_object_add(json
, "vrfs", json_vrfs
);
11730 vty_out(vty
, "%s\n", json_object_to_json_string_ext(json
,
11731 JSON_C_TO_STRING_PRETTY
));
11732 json_object_free(json
);
11735 return CMD_SUCCESS
;
11738 /* "show [ip] bgp route-leak" command. */
11739 DEFUN (show_ip_bgp_route_leak
,
11740 show_ip_bgp_route_leak_cmd
,
11741 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak [json]",
11745 BGP_INSTANCE_HELP_STR
11748 "Route leaking information\n"
11752 afi_t afi
= AFI_MAX
;
11753 safi_t safi
= SAFI_MAX
;
11755 bool uj
= use_json(argc
, argv
);
11757 json_object
*json
= NULL
;
11759 /* show [ip] bgp */
11760 if (argv_find(argv
, argc
, "ip", &idx
)) {
11762 safi
= SAFI_UNICAST
;
11764 /* [vrf VIEWVRFNAME] */
11765 if (argv_find(argv
, argc
, "view", &idx
)) {
11767 "%% This command is not applicable to BGP views\n");
11768 return CMD_WARNING
;
11771 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11772 vrf
= argv
[idx
+ 1]->arg
;
11773 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11776 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11777 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11778 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11781 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11783 "%% This command is applicable only for unicast ipv4|ipv6\n");
11784 return CMD_WARNING
;
11787 if (vrf
&& strmatch(vrf
, "all"))
11788 return bgp_show_all_instance_route_leak_vty(vty
, afi
, safi
, uj
);
11791 json
= json_object_new_object();
11793 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
, uj
, json
);
11796 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11799 struct listnode
*node
, *nnode
;
11802 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11803 vty_out(vty
, "\nInstance %s:\n",
11804 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11807 update_group_show(bgp
, afi
, safi
, vty
, 0);
11811 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11812 int safi
, uint64_t subgrp_id
)
11817 if (strmatch(name
, "all")) {
11818 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11819 return CMD_SUCCESS
;
11821 bgp
= bgp_lookup_by_name(name
);
11824 bgp
= bgp_get_default();
11828 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11829 return CMD_SUCCESS
;
11832 DEFUN (show_ip_bgp_updgrps
,
11833 show_ip_bgp_updgrps_cmd
,
11834 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11838 BGP_INSTANCE_HELP_STR
11840 BGP_SAFI_WITH_LABEL_HELP_STR
11841 "Detailed info about dynamic update groups\n"
11842 "Specific subgroup to display detailed info for\n")
11845 afi_t afi
= AFI_IP6
;
11846 safi_t safi
= SAFI_UNICAST
;
11847 uint64_t subgrp_id
= 0;
11851 /* show [ip] bgp */
11852 if (argv_find(argv
, argc
, "ip", &idx
))
11854 /* [<vrf> VIEWVRFNAME] */
11855 if (argv_find(argv
, argc
, "vrf", &idx
)) {
11856 vrf
= argv
[idx
+ 1]->arg
;
11857 if (vrf
&& strmatch(vrf
, VRF_DEFAULT_NAME
))
11859 } else if (argv_find(argv
, argc
, "view", &idx
))
11860 /* [<view> VIEWVRFNAME] */
11861 vrf
= argv
[idx
+ 1]->arg
;
11862 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11863 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11864 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11867 /* get subgroup id, if provided */
11869 if (argv
[idx
]->type
== VARIABLE_TKN
)
11870 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11872 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11875 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11876 show_bgp_instance_all_ipv6_updgrps_cmd
,
11877 "show [ip] bgp <view|vrf> all update-groups",
11881 BGP_INSTANCE_ALL_HELP_STR
11882 "Detailed info about dynamic update groups\n")
11884 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11885 return CMD_SUCCESS
;
11888 DEFUN (show_bgp_l2vpn_evpn_updgrps
,
11889 show_bgp_l2vpn_evpn_updgrps_cmd
,
11890 "show [ip] bgp l2vpn evpn update-groups",
11894 "l2vpn address family\n"
11895 "evpn sub-address family\n"
11896 "Detailed info about dynamic update groups\n")
11899 uint64_t subgrp_id
= 0;
11901 bgp_show_update_groups(vty
, vrf
, AFI_L2VPN
, SAFI_EVPN
, subgrp_id
);
11902 return CMD_SUCCESS
;
11905 DEFUN (show_bgp_updgrps_stats
,
11906 show_bgp_updgrps_stats_cmd
,
11907 "show [ip] bgp update-groups statistics",
11911 "Detailed info about dynamic update groups\n"
11916 bgp
= bgp_get_default();
11918 update_group_show_stats(bgp
, vty
);
11920 return CMD_SUCCESS
;
11923 DEFUN (show_bgp_instance_updgrps_stats
,
11924 show_bgp_instance_updgrps_stats_cmd
,
11925 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11929 BGP_INSTANCE_HELP_STR
11930 "Detailed info about dynamic update groups\n"
11936 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11938 update_group_show_stats(bgp
, vty
);
11940 return CMD_SUCCESS
;
11943 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11944 afi_t afi
, safi_t safi
,
11945 const char *what
, uint64_t subgrp_id
)
11950 bgp
= bgp_lookup_by_name(name
);
11952 bgp
= bgp_get_default();
11955 if (!strcmp(what
, "advertise-queue"))
11956 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11958 else if (!strcmp(what
, "advertised-routes"))
11959 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11961 else if (!strcmp(what
, "packet-queue"))
11962 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11967 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11968 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11969 "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",
11970 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11972 "Detailed info about dynamic update groups\n"
11973 "Specific subgroup to display info for\n"
11974 "Advertisement queue\n"
11975 "Announced routes\n"
11978 uint64_t subgrp_id
= 0;
11982 subgrp_id
= strtoull(sgid
, NULL
, 10);
11987 afiz
= bgp_vty_afi_from_str(afi
);
11991 afiz
= bgp_vty_afi_from_str(afi
);
11992 if (afiz
!= AFI_IP
)
11994 "%% Cannot specify both 'ip' and 'ipv6'\n");
11995 return CMD_WARNING
;
11998 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
12000 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
12001 return CMD_SUCCESS
;
12004 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
12006 struct listnode
*node
, *nnode
;
12007 struct prefix
*range
;
12010 char buf
[PREFIX2STR_BUFFER
];
12013 const char *peer_status
;
12014 const char *af_str
;
12019 conf
= group
->conf
;
12021 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
12022 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
12023 group
->name
, conf
->as
);
12024 } else if (conf
->as_type
== AS_INTERNAL
) {
12025 vty_out(vty
, "\nBGP peer-group %s, remote AS %" PRIu32
"\n",
12026 group
->name
, group
->bgp
->as
);
12028 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
12031 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
12032 vty_out(vty
, " Peer-group type is internal\n");
12034 vty_out(vty
, " Peer-group type is external\n");
12036 /* Display AFs configured. */
12037 vty_out(vty
, " Configured address-families:");
12038 FOREACH_AFI_SAFI (afi
, safi
) {
12039 if (conf
->afc
[afi
][safi
]) {
12041 vty_out(vty
, " %s;", get_afi_safi_str(afi
, safi
, false));
12045 vty_out(vty
, " none\n");
12047 vty_out(vty
, "\n");
12049 /* Display listen ranges (for dynamic neighbors), if any */
12050 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
12053 else if (afi
== AFI_IP6
)
12057 lr_count
= listcount(group
->listen_range
[afi
]);
12059 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
12063 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
12065 prefix2str(range
, buf
, sizeof(buf
));
12066 vty_out(vty
, " %s\n", buf
);
12071 /* Display group members and their status */
12072 if (listcount(group
->peer
)) {
12073 vty_out(vty
, " Peer-group members:\n");
12074 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
12075 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
12076 peer_status
= "Idle (Admin)";
12077 else if (CHECK_FLAG(peer
->sflags
,
12078 PEER_STATUS_PREFIX_OVERFLOW
))
12079 peer_status
= "Idle (PfxCt)";
12081 peer_status
= lookup_msg(bgp_status_msg
,
12082 peer
->status
, NULL
);
12084 dynamic
= peer_dynamic_neighbor(peer
);
12085 vty_out(vty
, " %s %s %s \n", peer
->host
,
12086 dynamic
? "(dynamic)" : "", peer_status
);
12090 return CMD_SUCCESS
;
12093 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
12094 const char *group_name
)
12097 struct listnode
*node
, *nnode
;
12098 struct peer_group
*group
;
12099 bool found
= false;
12101 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
12104 vty_out(vty
, "%% BGP instance not found\n");
12105 return CMD_WARNING
;
12108 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
12110 if (strmatch(group
->name
, group_name
)) {
12111 bgp_show_one_peer_group(vty
, group
);
12116 bgp_show_one_peer_group(vty
, group
);
12120 if (group_name
&& !found
)
12121 vty_out(vty
, "%% No such peer-group\n");
12123 return CMD_SUCCESS
;
12126 DEFUN (show_ip_bgp_peer_groups
,
12127 show_ip_bgp_peer_groups_cmd
,
12128 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
12132 BGP_INSTANCE_HELP_STR
12133 "Detailed information on BGP peer groups\n"
12134 "Peer group name\n")
12139 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
12141 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
12143 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
12147 /* Redistribute VTY commands. */
12149 DEFUN (bgp_redistribute_ipv4
,
12150 bgp_redistribute_ipv4_cmd
,
12151 "redistribute " FRR_IP_REDIST_STR_BGPD
,
12152 "Redistribute information from another routing protocol\n"
12153 FRR_IP_REDIST_HELP_STR_BGPD
)
12155 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12156 int idx_protocol
= 1;
12159 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12161 vty_out(vty
, "%% Invalid route type\n");
12162 return CMD_WARNING_CONFIG_FAILED
;
12165 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12166 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, false);
12170 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
12171 "redistribute " FRR_IP_REDIST_STR_BGPD
,
12172 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
12174 DEFUN (bgp_redistribute_ipv4_rmap
,
12175 bgp_redistribute_ipv4_rmap_cmd
,
12176 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
12177 "Redistribute information from another routing protocol\n"
12178 FRR_IP_REDIST_HELP_STR_BGPD
12179 "Route map reference\n"
12180 "Pointer to route-map entries\n")
12182 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12183 int idx_protocol
= 1;
12186 struct bgp_redist
*red
;
12188 struct route_map
*route_map
= route_map_lookup_warn_noexist(
12189 vty
, argv
[idx_word
]->arg
);
12191 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12193 vty_out(vty
, "%% Invalid route type\n");
12194 return CMD_WARNING_CONFIG_FAILED
;
12197 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12199 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12200 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12204 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
12205 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
12206 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12207 "Route map reference\n"
12208 "Pointer to route-map entries\n")
12210 DEFUN (bgp_redistribute_ipv4_metric
,
12211 bgp_redistribute_ipv4_metric_cmd
,
12212 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12213 "Redistribute information from another routing protocol\n"
12214 FRR_IP_REDIST_HELP_STR_BGPD
12215 "Metric for redistributed routes\n"
12216 "Default metric\n")
12218 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12219 int idx_protocol
= 1;
12220 int idx_number
= 3;
12223 struct bgp_redist
*red
;
12226 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12228 vty_out(vty
, "%% Invalid route type\n");
12229 return CMD_WARNING_CONFIG_FAILED
;
12231 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12233 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12234 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12235 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12239 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
12240 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
12241 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12242 "Metric for redistributed routes\n"
12243 "Default metric\n")
12245 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
12246 bgp_redistribute_ipv4_rmap_metric_cmd
,
12247 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12248 "Redistribute information from another routing protocol\n"
12249 FRR_IP_REDIST_HELP_STR_BGPD
12250 "Route map reference\n"
12251 "Pointer to route-map entries\n"
12252 "Metric for redistributed routes\n"
12253 "Default metric\n")
12255 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12256 int idx_protocol
= 1;
12258 int idx_number
= 5;
12261 struct bgp_redist
*red
;
12263 struct route_map
*route_map
=
12264 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12266 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12268 vty_out(vty
, "%% Invalid route type\n");
12269 return CMD_WARNING_CONFIG_FAILED
;
12271 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12273 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12275 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12276 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12277 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12281 bgp_redistribute_ipv4_rmap_metric
,
12282 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
12283 "redistribute " FRR_IP_REDIST_STR_BGPD
12284 " route-map WORD metric (0-4294967295)",
12285 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12286 "Route map reference\n"
12287 "Pointer to route-map entries\n"
12288 "Metric for redistributed routes\n"
12289 "Default metric\n")
12291 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
12292 bgp_redistribute_ipv4_metric_rmap_cmd
,
12293 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12294 "Redistribute information from another routing protocol\n"
12295 FRR_IP_REDIST_HELP_STR_BGPD
12296 "Metric for redistributed routes\n"
12298 "Route map reference\n"
12299 "Pointer to route-map entries\n")
12301 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12302 int idx_protocol
= 1;
12303 int idx_number
= 3;
12307 struct bgp_redist
*red
;
12309 struct route_map
*route_map
=
12310 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12312 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12314 vty_out(vty
, "%% Invalid route type\n");
12315 return CMD_WARNING_CONFIG_FAILED
;
12317 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12319 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
12320 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
12322 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12323 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0, changed
);
12327 bgp_redistribute_ipv4_metric_rmap
,
12328 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
12329 "redistribute " FRR_IP_REDIST_STR_BGPD
12330 " metric (0-4294967295) route-map WORD",
12331 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12332 "Metric for redistributed routes\n"
12334 "Route map reference\n"
12335 "Pointer to route-map entries\n")
12337 DEFUN (bgp_redistribute_ipv4_ospf
,
12338 bgp_redistribute_ipv4_ospf_cmd
,
12339 "redistribute <ospf|table> (1-65535)",
12340 "Redistribute information from another routing protocol\n"
12341 "Open Shortest Path First (OSPFv2)\n"
12342 "Non-main Kernel Routing Table\n"
12343 "Instance ID/Table ID\n")
12345 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12346 int idx_ospf_table
= 1;
12347 int idx_number
= 2;
12348 unsigned short instance
;
12349 unsigned short protocol
;
12351 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12353 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12354 protocol
= ZEBRA_ROUTE_OSPF
;
12356 protocol
= ZEBRA_ROUTE_TABLE
;
12358 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12359 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, false);
12362 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
12363 "redistribute <ospf|table> (1-65535)",
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")
12369 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
12370 bgp_redistribute_ipv4_ospf_rmap_cmd
,
12371 "redistribute <ospf|table> (1-65535) route-map WORD",
12372 "Redistribute information from another routing protocol\n"
12373 "Open Shortest Path First (OSPFv2)\n"
12374 "Non-main Kernel Routing Table\n"
12375 "Instance ID/Table ID\n"
12376 "Route map reference\n"
12377 "Pointer to route-map entries\n")
12379 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12380 int idx_ospf_table
= 1;
12381 int idx_number
= 2;
12383 struct bgp_redist
*red
;
12384 unsigned short instance
;
12387 struct route_map
*route_map
=
12388 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12390 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12391 protocol
= ZEBRA_ROUTE_OSPF
;
12393 protocol
= ZEBRA_ROUTE_TABLE
;
12395 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12396 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12398 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12399 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12402 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
12403 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
12404 "redistribute <ospf|table> (1-65535) route-map WORD",
12405 "Redistribute information from another routing protocol\n"
12406 "Open Shortest Path First (OSPFv2)\n"
12407 "Non-main Kernel Routing Table\n"
12408 "Instance ID/Table ID\n"
12409 "Route map reference\n"
12410 "Pointer to route-map entries\n")
12412 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
12413 bgp_redistribute_ipv4_ospf_metric_cmd
,
12414 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12415 "Redistribute information from another routing protocol\n"
12416 "Open Shortest Path First (OSPFv2)\n"
12417 "Non-main Kernel Routing Table\n"
12418 "Instance ID/Table ID\n"
12419 "Metric for redistributed routes\n"
12420 "Default metric\n")
12422 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12423 int idx_ospf_table
= 1;
12424 int idx_number
= 2;
12425 int idx_number_2
= 4;
12427 struct bgp_redist
*red
;
12428 unsigned short instance
;
12432 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12433 protocol
= ZEBRA_ROUTE_OSPF
;
12435 protocol
= ZEBRA_ROUTE_TABLE
;
12437 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12438 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12440 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12441 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12443 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12446 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
12447 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
12448 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
12449 "Redistribute information from another routing protocol\n"
12450 "Open Shortest Path First (OSPFv2)\n"
12451 "Non-main Kernel Routing Table\n"
12452 "Instance ID/Table ID\n"
12453 "Metric for redistributed routes\n"
12454 "Default metric\n")
12456 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
12457 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
12458 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12459 "Redistribute information from another routing protocol\n"
12460 "Open Shortest Path First (OSPFv2)\n"
12461 "Non-main Kernel Routing Table\n"
12462 "Instance ID/Table ID\n"
12463 "Route map reference\n"
12464 "Pointer to route-map entries\n"
12465 "Metric for redistributed routes\n"
12466 "Default metric\n")
12468 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12469 int idx_ospf_table
= 1;
12470 int idx_number
= 2;
12472 int idx_number_2
= 6;
12474 struct bgp_redist
*red
;
12475 unsigned short instance
;
12478 struct route_map
*route_map
=
12479 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12481 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12482 protocol
= ZEBRA_ROUTE_OSPF
;
12484 protocol
= ZEBRA_ROUTE_TABLE
;
12486 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12487 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12489 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12491 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12492 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12494 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12498 bgp_redistribute_ipv4_ospf_rmap_metric
,
12499 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
12500 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
12501 "Redistribute information from another routing protocol\n"
12502 "Open Shortest Path First (OSPFv2)\n"
12503 "Non-main Kernel Routing Table\n"
12504 "Instance ID/Table ID\n"
12505 "Route map reference\n"
12506 "Pointer to route-map entries\n"
12507 "Metric for redistributed routes\n"
12508 "Default metric\n")
12510 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
12511 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
12512 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12513 "Redistribute information from another routing protocol\n"
12514 "Open Shortest Path First (OSPFv2)\n"
12515 "Non-main Kernel Routing Table\n"
12516 "Instance ID/Table ID\n"
12517 "Metric for redistributed routes\n"
12519 "Route map reference\n"
12520 "Pointer to route-map entries\n")
12522 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12523 int idx_ospf_table
= 1;
12524 int idx_number
= 2;
12525 int idx_number_2
= 4;
12528 struct bgp_redist
*red
;
12529 unsigned short instance
;
12532 struct route_map
*route_map
=
12533 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12535 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12536 protocol
= ZEBRA_ROUTE_OSPF
;
12538 protocol
= ZEBRA_ROUTE_TABLE
;
12540 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12541 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
12543 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
12544 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
,
12547 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12548 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
, changed
);
12552 bgp_redistribute_ipv4_ospf_metric_rmap
,
12553 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
12554 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
12555 "Redistribute information from another routing protocol\n"
12556 "Open Shortest Path First (OSPFv2)\n"
12557 "Non-main Kernel Routing Table\n"
12558 "Instance ID/Table ID\n"
12559 "Metric for redistributed routes\n"
12561 "Route map reference\n"
12562 "Pointer to route-map entries\n")
12564 DEFUN (no_bgp_redistribute_ipv4_ospf
,
12565 no_bgp_redistribute_ipv4_ospf_cmd
,
12566 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
12568 "Redistribute information from another routing protocol\n"
12569 "Open Shortest Path First (OSPFv2)\n"
12570 "Non-main Kernel Routing Table\n"
12571 "Instance ID/Table ID\n"
12572 "Metric for redistributed routes\n"
12574 "Route map reference\n"
12575 "Pointer to route-map entries\n")
12577 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12578 int idx_ospf_table
= 2;
12579 int idx_number
= 3;
12580 unsigned short instance
;
12583 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
12584 protocol
= ZEBRA_ROUTE_OSPF
;
12586 protocol
= ZEBRA_ROUTE_TABLE
;
12588 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12589 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
12593 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
12594 "no redistribute <ospf|table> (1-65535) [{metric (0-4294967295)|route-map WORD}]",
12596 "Redistribute information from another routing protocol\n"
12597 "Open Shortest Path First (OSPFv2)\n"
12598 "Non-main Kernel Routing Table\n"
12599 "Instance ID/Table ID\n"
12600 "Metric for redistributed routes\n"
12602 "Route map reference\n"
12603 "Pointer to route-map entries\n")
12605 DEFUN (no_bgp_redistribute_ipv4
,
12606 no_bgp_redistribute_ipv4_cmd
,
12607 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
12609 "Redistribute information from another routing protocol\n"
12610 FRR_IP_REDIST_HELP_STR_BGPD
12611 "Metric for redistributed routes\n"
12613 "Route map reference\n"
12614 "Pointer to route-map entries\n")
12616 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12617 int idx_protocol
= 2;
12620 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
12622 vty_out(vty
, "%% Invalid route type\n");
12623 return CMD_WARNING_CONFIG_FAILED
;
12625 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
12629 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
12630 "no redistribute " FRR_IP_REDIST_STR_BGPD
12631 " [{metric (0-4294967295)|route-map WORD}]",
12633 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
12634 "Metric for redistributed routes\n"
12636 "Route map reference\n"
12637 "Pointer to route-map entries\n")
12639 DEFUN (bgp_redistribute_ipv6
,
12640 bgp_redistribute_ipv6_cmd
,
12641 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
12642 "Redistribute information from another routing protocol\n"
12643 FRR_IP6_REDIST_HELP_STR_BGPD
)
12645 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12646 int idx_protocol
= 1;
12649 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12651 vty_out(vty
, "%% Invalid route type\n");
12652 return CMD_WARNING_CONFIG_FAILED
;
12655 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12656 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, false);
12659 DEFUN (bgp_redistribute_ipv6_rmap
,
12660 bgp_redistribute_ipv6_rmap_cmd
,
12661 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
12662 "Redistribute information from another routing protocol\n"
12663 FRR_IP6_REDIST_HELP_STR_BGPD
12664 "Route map reference\n"
12665 "Pointer to route-map entries\n")
12667 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12668 int idx_protocol
= 1;
12671 struct bgp_redist
*red
;
12673 struct route_map
*route_map
=
12674 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12676 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12678 vty_out(vty
, "%% Invalid route type\n");
12679 return CMD_WARNING_CONFIG_FAILED
;
12682 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12684 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12685 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12688 DEFUN (bgp_redistribute_ipv6_metric
,
12689 bgp_redistribute_ipv6_metric_cmd
,
12690 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
12691 "Redistribute information from another routing protocol\n"
12692 FRR_IP6_REDIST_HELP_STR_BGPD
12693 "Metric for redistributed routes\n"
12694 "Default metric\n")
12696 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12697 int idx_protocol
= 1;
12698 int idx_number
= 3;
12701 struct bgp_redist
*red
;
12704 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12706 vty_out(vty
, "%% Invalid route type\n");
12707 return CMD_WARNING_CONFIG_FAILED
;
12709 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12711 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12712 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
12713 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12716 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
12717 bgp_redistribute_ipv6_rmap_metric_cmd
,
12718 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
12719 "Redistribute information from another routing protocol\n"
12720 FRR_IP6_REDIST_HELP_STR_BGPD
12721 "Route map reference\n"
12722 "Pointer to route-map entries\n"
12723 "Metric for redistributed routes\n"
12724 "Default metric\n")
12726 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12727 int idx_protocol
= 1;
12729 int idx_number
= 5;
12732 struct bgp_redist
*red
;
12734 struct route_map
*route_map
=
12735 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12737 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12739 vty_out(vty
, "%% Invalid route type\n");
12740 return CMD_WARNING_CONFIG_FAILED
;
12742 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12744 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12746 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12747 changed
|= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
,
12749 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12752 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
12753 bgp_redistribute_ipv6_metric_rmap_cmd
,
12754 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
12755 "Redistribute information from another routing protocol\n"
12756 FRR_IP6_REDIST_HELP_STR_BGPD
12757 "Metric for redistributed routes\n"
12759 "Route map reference\n"
12760 "Pointer to route-map entries\n")
12762 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12763 int idx_protocol
= 1;
12764 int idx_number
= 3;
12768 struct bgp_redist
*red
;
12770 struct route_map
*route_map
=
12771 route_map_lookup_warn_noexist(vty
, argv
[idx_word
]->arg
);
12773 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12775 vty_out(vty
, "%% Invalid route type\n");
12776 return CMD_WARNING_CONFIG_FAILED
;
12778 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12780 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12781 changed
= bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
,
12784 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
, route_map
);
12785 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0, changed
);
12788 DEFUN (no_bgp_redistribute_ipv6
,
12789 no_bgp_redistribute_ipv6_cmd
,
12790 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [{metric (0-4294967295)|route-map WORD}]",
12792 "Redistribute information from another routing protocol\n"
12793 FRR_IP6_REDIST_HELP_STR_BGPD
12794 "Metric for redistributed routes\n"
12796 "Route map reference\n"
12797 "Pointer to route-map entries\n")
12799 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12800 int idx_protocol
= 2;
12803 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12805 vty_out(vty
, "%% Invalid route type\n");
12806 return CMD_WARNING_CONFIG_FAILED
;
12809 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12812 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12817 /* Unicast redistribution only. */
12818 if (safi
!= SAFI_UNICAST
)
12821 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12822 /* Redistribute BGP does not make sense. */
12823 if (i
!= ZEBRA_ROUTE_BGP
) {
12824 struct list
*red_list
;
12825 struct listnode
*node
;
12826 struct bgp_redist
*red
;
12828 red_list
= bgp
->redist
[afi
][i
];
12832 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12833 /* "redistribute" configuration. */
12834 vty_out(vty
, " redistribute %s",
12835 zebra_route_string(i
));
12837 vty_out(vty
, " %d", red
->instance
);
12838 if (red
->redist_metric_flag
)
12839 vty_out(vty
, " metric %u",
12840 red
->redist_metric
);
12841 if (red
->rmap
.name
)
12842 vty_out(vty
, " route-map %s",
12844 vty_out(vty
, "\n");
12850 /* This is part of the address-family block (unicast only) */
12851 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12856 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12857 if (listcount(bgp
->vpn_policy
[afi
].import_vrf
))
12858 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12859 bgp
->vpn_policy
[afi
]
12860 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12862 vty_out(vty
, "%*sroute-map vpn import %s\n", indent
, "",
12863 bgp
->vpn_policy
[afi
]
12864 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12866 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12867 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12868 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12869 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12872 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12873 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12875 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12878 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12879 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12880 bgp
->vpn_policy
[afi
].tovpn_label
);
12883 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12884 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12885 char buf
[RD_ADDRSTRLEN
];
12886 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12887 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12890 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12891 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12893 char buf
[PREFIX_STRLEN
];
12894 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12895 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12898 vty_out(vty
, "%*snexthop vpn export %s\n",
12902 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12903 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12905 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12906 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12908 char *b
= ecommunity_ecom2str(
12909 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12910 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12911 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12912 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12914 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12915 char *b
= ecommunity_ecom2str(
12916 bgp
->vpn_policy
[afi
]
12917 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12918 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12919 ECOMMUNITY_ROUTE_TARGET
);
12920 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12921 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12923 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12924 char *b
= ecommunity_ecom2str(
12925 bgp
->vpn_policy
[afi
]
12926 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12927 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12928 ECOMMUNITY_ROUTE_TARGET
);
12929 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12930 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12934 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12935 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12936 bgp
->vpn_policy
[afi
]
12937 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12939 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12940 char *b
= ecommunity_ecom2str(
12941 bgp
->vpn_policy
[afi
]
12942 .import_redirect_rtlist
,
12943 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12944 ECOMMUNITY_ROUTE_TARGET
);
12946 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12947 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12952 /* BGP node structure. */
12953 static struct cmd_node bgp_node
= {
12954 BGP_NODE
, "%s(config-router)# ", 1,
12957 static struct cmd_node bgp_ipv4_unicast_node
= {
12958 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12961 static struct cmd_node bgp_ipv4_multicast_node
= {
12962 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12965 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12966 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12969 static struct cmd_node bgp_ipv6_unicast_node
= {
12970 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12973 static struct cmd_node bgp_ipv6_multicast_node
= {
12974 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12977 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12978 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12981 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12982 "%s(config-router-af)# ", 1};
12984 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12985 "%s(config-router-af-vpnv6)# ", 1};
12987 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12988 "%s(config-router-evpn)# ", 1};
12990 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12991 "%s(config-router-af-vni)# ", 1};
12993 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12994 "%s(config-router-af)# ", 1};
12996 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12997 "%s(config-router-af-vpnv6)# ", 1};
12999 static void community_list_vty(void);
13001 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
13005 struct listnode
*lnbgp
, *lnpeer
;
13007 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
13008 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
13009 /* only provide suggestions on the appropriate input
13011 * they'll otherwise show up multiple times */
13012 enum cmd_token_type match_type
;
13013 char *name
= peer
->host
;
13015 if (peer
->conf_if
) {
13016 match_type
= VARIABLE_TKN
;
13017 name
= peer
->conf_if
;
13018 } else if (strchr(peer
->host
, ':'))
13019 match_type
= IPV6_TKN
;
13021 match_type
= IPV4_TKN
;
13023 if (token
->type
!= match_type
)
13026 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
13031 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
13032 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
13033 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
13034 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
13035 {.completions
= NULL
}};
13037 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
13040 struct peer_group
*group
;
13041 struct listnode
*lnbgp
, *lnpeer
;
13043 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
13044 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
13045 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
13050 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
13051 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
13052 {.completions
= NULL
} };
13054 void bgp_vty_init(void)
13056 cmd_variable_handler_register(bgp_var_neighbor
);
13057 cmd_variable_handler_register(bgp_var_peergroup
);
13059 /* Install bgp top node. */
13060 install_node(&bgp_node
, bgp_config_write
);
13061 install_node(&bgp_ipv4_unicast_node
, NULL
);
13062 install_node(&bgp_ipv4_multicast_node
, NULL
);
13063 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
13064 install_node(&bgp_ipv6_unicast_node
, NULL
);
13065 install_node(&bgp_ipv6_multicast_node
, NULL
);
13066 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
13067 install_node(&bgp_vpnv4_node
, NULL
);
13068 install_node(&bgp_vpnv6_node
, NULL
);
13069 install_node(&bgp_evpn_node
, NULL
);
13070 install_node(&bgp_evpn_vni_node
, NULL
);
13071 install_node(&bgp_flowspecv4_node
, NULL
);
13072 install_node(&bgp_flowspecv6_node
, NULL
);
13074 /* Install default VTY commands to new nodes. */
13075 install_default(BGP_NODE
);
13076 install_default(BGP_IPV4_NODE
);
13077 install_default(BGP_IPV4M_NODE
);
13078 install_default(BGP_IPV4L_NODE
);
13079 install_default(BGP_IPV6_NODE
);
13080 install_default(BGP_IPV6M_NODE
);
13081 install_default(BGP_IPV6L_NODE
);
13082 install_default(BGP_VPNV4_NODE
);
13083 install_default(BGP_VPNV6_NODE
);
13084 install_default(BGP_FLOWSPECV4_NODE
);
13085 install_default(BGP_FLOWSPECV6_NODE
);
13086 install_default(BGP_EVPN_NODE
);
13087 install_default(BGP_EVPN_VNI_NODE
);
13089 /* "bgp local-mac" hidden commands. */
13090 install_element(CONFIG_NODE
, &bgp_local_mac_cmd
);
13091 install_element(CONFIG_NODE
, &no_bgp_local_mac_cmd
);
13093 /* bgp route-map delay-timer commands. */
13094 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
13095 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
13097 /* Dummy commands (Currently not supported) */
13098 install_element(BGP_NODE
, &no_synchronization_cmd
);
13099 install_element(BGP_NODE
, &no_auto_summary_cmd
);
13101 /* "router bgp" commands. */
13102 install_element(CONFIG_NODE
, &router_bgp_cmd
);
13104 /* "no router bgp" commands. */
13105 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
13107 /* "bgp router-id" commands. */
13108 install_element(BGP_NODE
, &bgp_router_id_cmd
);
13109 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
13111 /* "bgp cluster-id" commands. */
13112 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
13113 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
13115 /* "bgp confederation" commands. */
13116 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
13117 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
13119 /* "bgp confederation peers" commands. */
13120 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
13121 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
13123 /* bgp max-med command */
13124 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
13125 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
13126 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
13127 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
13128 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
13130 /* bgp disable-ebgp-connected-nh-check */
13131 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
13132 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
13134 /* bgp update-delay command */
13135 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
13136 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
13137 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
13139 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
13140 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
13142 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
13143 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
13145 /* "maximum-paths" commands. */
13146 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
13147 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
13148 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
13149 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
13150 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
13151 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
13152 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
13153 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
13154 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
13155 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
13156 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
13157 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
13158 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
13159 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
13160 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
13162 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
13163 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
13164 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
13165 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
13166 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
13168 /* "timers bgp" commands. */
13169 install_element(BGP_NODE
, &bgp_timers_cmd
);
13170 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
13172 /* route-map delay-timer commands - per instance for backwards compat.
13174 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
13175 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
13177 /* "bgp client-to-client reflection" commands */
13178 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
13179 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
13181 /* "bgp always-compare-med" commands */
13182 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
13183 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
13185 /* bgp ebgp-requires-policy */
13186 install_element(BGP_NODE
, &bgp_ebgp_requires_policy_cmd
);
13187 install_element(BGP_NODE
, &no_bgp_ebgp_requires_policy_cmd
);
13189 /* bgp reject-as-sets */
13190 install_element(BGP_NODE
, &bgp_reject_as_sets_cmd
);
13191 install_element(BGP_NODE
, &no_bgp_reject_as_sets_cmd
);
13193 /* "bgp deterministic-med" commands */
13194 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
13195 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
13197 /* "bgp graceful-restart" commands */
13198 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
13199 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
13200 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
13201 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
13202 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
13203 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
13205 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
13206 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
13208 /* "bgp graceful-shutdown" commands */
13209 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
13210 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
13212 /* "bgp fast-external-failover" commands */
13213 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
13214 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
13216 /* "bgp bestpath compare-routerid" commands */
13217 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
13218 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
13220 /* "bgp bestpath as-path ignore" commands */
13221 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
13222 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
13224 /* "bgp bestpath as-path confed" commands */
13225 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
13226 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
13228 /* "bgp bestpath as-path multipath-relax" commands */
13229 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
13230 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
13232 /* "bgp log-neighbor-changes" commands */
13233 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
13234 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
13236 /* "bgp bestpath med" commands */
13237 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
13238 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
13240 /* "no bgp default ipv4-unicast" commands. */
13241 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
13242 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
13244 /* "bgp network import-check" commands. */
13245 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
13246 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
13247 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
13249 /* "bgp default local-preference" commands. */
13250 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
13251 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
13253 /* bgp default show-hostname */
13254 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
13255 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
13257 /* "bgp default subgroup-pkt-queue-max" commands. */
13258 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
13259 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
13261 /* bgp ibgp-allow-policy-mods command */
13262 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
13263 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
13265 /* "bgp listen limit" commands. */
13266 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
13267 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
13269 /* "bgp listen range" commands. */
13270 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
13271 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
13273 /* "bgp default shutdown" command */
13274 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
13276 /* "neighbor remote-as" commands. */
13277 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
13278 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
13279 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
13280 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
13281 install_element(BGP_NODE
,
13282 &neighbor_interface_v6only_config_remote_as_cmd
);
13283 install_element(BGP_NODE
, &no_neighbor_cmd
);
13284 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
13286 /* "neighbor peer-group" commands. */
13287 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
13288 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
13289 install_element(BGP_NODE
,
13290 &no_neighbor_interface_peer_group_remote_as_cmd
);
13292 /* "neighbor local-as" commands. */
13293 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
13294 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
13295 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
13296 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
13298 /* "neighbor solo" commands. */
13299 install_element(BGP_NODE
, &neighbor_solo_cmd
);
13300 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
13302 /* "neighbor password" commands. */
13303 install_element(BGP_NODE
, &neighbor_password_cmd
);
13304 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
13306 /* "neighbor activate" commands. */
13307 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
13308 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
13309 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
13310 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
13311 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
13312 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
13313 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
13314 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
13315 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
13316 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
13317 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
13318 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
13320 /* "no neighbor activate" commands. */
13321 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
13322 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
13323 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
13324 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
13325 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
13326 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
13327 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
13328 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
13329 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
13330 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
13331 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
13332 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
13334 /* "neighbor peer-group" set commands. */
13335 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
13336 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13337 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13338 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13339 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13340 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13341 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13342 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
13343 install_element(BGP_FLOWSPECV4_NODE
,
13344 &neighbor_set_peer_group_hidden_cmd
);
13345 install_element(BGP_FLOWSPECV6_NODE
,
13346 &neighbor_set_peer_group_hidden_cmd
);
13348 /* "no neighbor peer-group unset" commands. */
13349 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
13350 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13351 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13352 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13353 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13354 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13355 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13356 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
13357 install_element(BGP_FLOWSPECV4_NODE
,
13358 &no_neighbor_set_peer_group_hidden_cmd
);
13359 install_element(BGP_FLOWSPECV6_NODE
,
13360 &no_neighbor_set_peer_group_hidden_cmd
);
13362 /* "neighbor softreconfiguration inbound" commands.*/
13363 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
13364 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
13365 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13366 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13367 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13368 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13369 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13370 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13371 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13372 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13373 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
13374 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13375 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
13376 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13377 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
13378 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13379 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
13380 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13381 install_element(BGP_FLOWSPECV4_NODE
,
13382 &neighbor_soft_reconfiguration_cmd
);
13383 install_element(BGP_FLOWSPECV4_NODE
,
13384 &no_neighbor_soft_reconfiguration_cmd
);
13385 install_element(BGP_FLOWSPECV6_NODE
,
13386 &neighbor_soft_reconfiguration_cmd
);
13387 install_element(BGP_FLOWSPECV6_NODE
,
13388 &no_neighbor_soft_reconfiguration_cmd
);
13389 install_element(BGP_EVPN_NODE
, &neighbor_soft_reconfiguration_cmd
);
13390 install_element(BGP_EVPN_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
13392 /* "neighbor attribute-unchanged" commands. */
13393 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
13394 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
13395 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
13396 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13397 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
13398 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13399 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
13400 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13401 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
13402 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13403 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
13404 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
13405 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
13406 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
13407 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
13408 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
13409 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
13410 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
13412 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
13413 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
13415 /* "nexthop-local unchanged" commands */
13416 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
13417 install_element(BGP_IPV6_NODE
,
13418 &no_neighbor_nexthop_local_unchanged_cmd
);
13420 /* "neighbor next-hop-self" commands. */
13421 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
13422 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
13423 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
13424 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13425 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
13426 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
13427 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
13428 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
13429 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
13430 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13431 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
13432 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
13433 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
13434 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
13435 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
13436 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
13437 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
13438 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
13439 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
13440 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
13442 /* "neighbor next-hop-self force" commands. */
13443 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
13444 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
13445 install_element(BGP_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13446 install_element(BGP_NODE
, &no_neighbor_nexthop_self_all_hidden_cmd
);
13447 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13448 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13449 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13450 install_element(BGP_IPV4_NODE
,
13451 &no_neighbor_nexthop_self_all_hidden_cmd
);
13452 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
13453 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13454 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13455 install_element(BGP_IPV4M_NODE
,
13456 &no_neighbor_nexthop_self_all_hidden_cmd
);
13457 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
13458 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13459 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13460 install_element(BGP_IPV4L_NODE
,
13461 &no_neighbor_nexthop_self_all_hidden_cmd
);
13462 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13463 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13464 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13465 install_element(BGP_IPV6_NODE
,
13466 &no_neighbor_nexthop_self_all_hidden_cmd
);
13467 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
13468 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13469 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13470 install_element(BGP_IPV6M_NODE
,
13471 &no_neighbor_nexthop_self_all_hidden_cmd
);
13472 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
13473 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13474 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13475 install_element(BGP_IPV6L_NODE
,
13476 &no_neighbor_nexthop_self_all_hidden_cmd
);
13477 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
13478 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13479 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13480 install_element(BGP_VPNV4_NODE
,
13481 &no_neighbor_nexthop_self_all_hidden_cmd
);
13482 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
13483 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
13484 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_all_hidden_cmd
);
13485 install_element(BGP_VPNV6_NODE
,
13486 &no_neighbor_nexthop_self_all_hidden_cmd
);
13488 /* "neighbor as-override" commands. */
13489 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
13490 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
13491 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
13492 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
13493 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
13494 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
13495 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
13496 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
13497 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
13498 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
13499 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
13500 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
13501 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
13502 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
13503 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
13504 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
13505 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
13506 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
13508 /* "neighbor remove-private-AS" commands. */
13509 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
13510 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
13511 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
13512 install_element(BGP_NODE
,
13513 &no_neighbor_remove_private_as_all_hidden_cmd
);
13514 install_element(BGP_NODE
,
13515 &neighbor_remove_private_as_replace_as_hidden_cmd
);
13516 install_element(BGP_NODE
,
13517 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
13518 install_element(BGP_NODE
,
13519 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13522 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
13523 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
13524 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13525 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13526 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13527 install_element(BGP_IPV4_NODE
,
13528 &neighbor_remove_private_as_replace_as_cmd
);
13529 install_element(BGP_IPV4_NODE
,
13530 &no_neighbor_remove_private_as_replace_as_cmd
);
13531 install_element(BGP_IPV4_NODE
,
13532 &neighbor_remove_private_as_all_replace_as_cmd
);
13533 install_element(BGP_IPV4_NODE
,
13534 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13535 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
13536 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
13537 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
13538 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13539 install_element(BGP_IPV4M_NODE
,
13540 &neighbor_remove_private_as_replace_as_cmd
);
13541 install_element(BGP_IPV4M_NODE
,
13542 &no_neighbor_remove_private_as_replace_as_cmd
);
13543 install_element(BGP_IPV4M_NODE
,
13544 &neighbor_remove_private_as_all_replace_as_cmd
);
13545 install_element(BGP_IPV4M_NODE
,
13546 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13547 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
13548 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
13549 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
13550 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13551 install_element(BGP_IPV4L_NODE
,
13552 &neighbor_remove_private_as_replace_as_cmd
);
13553 install_element(BGP_IPV4L_NODE
,
13554 &no_neighbor_remove_private_as_replace_as_cmd
);
13555 install_element(BGP_IPV4L_NODE
,
13556 &neighbor_remove_private_as_all_replace_as_cmd
);
13557 install_element(BGP_IPV4L_NODE
,
13558 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13559 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
13560 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13561 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13562 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13563 install_element(BGP_IPV6_NODE
,
13564 &neighbor_remove_private_as_replace_as_cmd
);
13565 install_element(BGP_IPV6_NODE
,
13566 &no_neighbor_remove_private_as_replace_as_cmd
);
13567 install_element(BGP_IPV6_NODE
,
13568 &neighbor_remove_private_as_all_replace_as_cmd
);
13569 install_element(BGP_IPV6_NODE
,
13570 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13571 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
13572 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
13573 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
13574 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13575 install_element(BGP_IPV6M_NODE
,
13576 &neighbor_remove_private_as_replace_as_cmd
);
13577 install_element(BGP_IPV6M_NODE
,
13578 &no_neighbor_remove_private_as_replace_as_cmd
);
13579 install_element(BGP_IPV6M_NODE
,
13580 &neighbor_remove_private_as_all_replace_as_cmd
);
13581 install_element(BGP_IPV6M_NODE
,
13582 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13583 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
13584 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
13585 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
13586 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13587 install_element(BGP_IPV6L_NODE
,
13588 &neighbor_remove_private_as_replace_as_cmd
);
13589 install_element(BGP_IPV6L_NODE
,
13590 &no_neighbor_remove_private_as_replace_as_cmd
);
13591 install_element(BGP_IPV6L_NODE
,
13592 &neighbor_remove_private_as_all_replace_as_cmd
);
13593 install_element(BGP_IPV6L_NODE
,
13594 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13595 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
13596 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
13597 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
13598 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13599 install_element(BGP_VPNV4_NODE
,
13600 &neighbor_remove_private_as_replace_as_cmd
);
13601 install_element(BGP_VPNV4_NODE
,
13602 &no_neighbor_remove_private_as_replace_as_cmd
);
13603 install_element(BGP_VPNV4_NODE
,
13604 &neighbor_remove_private_as_all_replace_as_cmd
);
13605 install_element(BGP_VPNV4_NODE
,
13606 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13607 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
13608 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
13609 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
13610 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
13611 install_element(BGP_VPNV6_NODE
,
13612 &neighbor_remove_private_as_replace_as_cmd
);
13613 install_element(BGP_VPNV6_NODE
,
13614 &no_neighbor_remove_private_as_replace_as_cmd
);
13615 install_element(BGP_VPNV6_NODE
,
13616 &neighbor_remove_private_as_all_replace_as_cmd
);
13617 install_element(BGP_VPNV6_NODE
,
13618 &no_neighbor_remove_private_as_all_replace_as_cmd
);
13620 /* "neighbor send-community" commands.*/
13621 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
13622 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
13623 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
13624 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
13625 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
13626 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
13627 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
13628 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
13629 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
13630 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
13631 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
13632 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
13633 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
13634 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
13635 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
13636 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
13637 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
13638 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
13639 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
13640 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
13641 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
13642 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
13643 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
13644 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
13645 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
13646 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
13647 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
13648 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
13649 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
13650 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
13651 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
13652 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
13653 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
13654 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
13655 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
13656 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
13658 /* "neighbor route-reflector" commands.*/
13659 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
13660 install_element(BGP_NODE
,
13661 &no_neighbor_route_reflector_client_hidden_cmd
);
13662 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
13663 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
13664 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
13665 install_element(BGP_IPV4M_NODE
,
13666 &no_neighbor_route_reflector_client_cmd
);
13667 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
13668 install_element(BGP_IPV4L_NODE
,
13669 &no_neighbor_route_reflector_client_cmd
);
13670 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
13671 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
13672 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
13673 install_element(BGP_IPV6M_NODE
,
13674 &no_neighbor_route_reflector_client_cmd
);
13675 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
13676 install_element(BGP_IPV6L_NODE
,
13677 &no_neighbor_route_reflector_client_cmd
);
13678 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
13679 install_element(BGP_VPNV4_NODE
,
13680 &no_neighbor_route_reflector_client_cmd
);
13681 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
13682 install_element(BGP_VPNV6_NODE
,
13683 &no_neighbor_route_reflector_client_cmd
);
13684 install_element(BGP_FLOWSPECV4_NODE
,
13685 &neighbor_route_reflector_client_cmd
);
13686 install_element(BGP_FLOWSPECV4_NODE
,
13687 &no_neighbor_route_reflector_client_cmd
);
13688 install_element(BGP_FLOWSPECV6_NODE
,
13689 &neighbor_route_reflector_client_cmd
);
13690 install_element(BGP_FLOWSPECV6_NODE
,
13691 &no_neighbor_route_reflector_client_cmd
);
13692 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
13693 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
13695 /* "neighbor route-server" commands.*/
13696 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
13697 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
13698 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
13699 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
13700 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
13701 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
13702 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
13703 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
13704 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
13705 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
13706 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
13707 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
13708 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
13709 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
13710 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
13711 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
13712 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
13713 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
13714 install_element(BGP_EVPN_NODE
, &neighbor_route_server_client_cmd
);
13715 install_element(BGP_EVPN_NODE
, &no_neighbor_route_server_client_cmd
);
13716 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
13717 install_element(BGP_FLOWSPECV4_NODE
,
13718 &no_neighbor_route_server_client_cmd
);
13719 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
13720 install_element(BGP_FLOWSPECV6_NODE
,
13721 &no_neighbor_route_server_client_cmd
);
13723 /* "neighbor addpath-tx-all-paths" commands.*/
13724 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
13725 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
13726 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13727 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13728 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13729 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13730 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13731 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13732 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13733 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13734 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13735 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13736 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13737 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13738 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13739 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13740 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
13741 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
13743 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
13744 install_element(BGP_NODE
,
13745 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13746 install_element(BGP_NODE
,
13747 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
13748 install_element(BGP_IPV4_NODE
,
13749 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13750 install_element(BGP_IPV4_NODE
,
13751 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13752 install_element(BGP_IPV4M_NODE
,
13753 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13754 install_element(BGP_IPV4M_NODE
,
13755 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13756 install_element(BGP_IPV4L_NODE
,
13757 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13758 install_element(BGP_IPV4L_NODE
,
13759 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13760 install_element(BGP_IPV6_NODE
,
13761 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13762 install_element(BGP_IPV6_NODE
,
13763 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13764 install_element(BGP_IPV6M_NODE
,
13765 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13766 install_element(BGP_IPV6M_NODE
,
13767 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13768 install_element(BGP_IPV6L_NODE
,
13769 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13770 install_element(BGP_IPV6L_NODE
,
13771 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13772 install_element(BGP_VPNV4_NODE
,
13773 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13774 install_element(BGP_VPNV4_NODE
,
13775 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13776 install_element(BGP_VPNV6_NODE
,
13777 &neighbor_addpath_tx_bestpath_per_as_cmd
);
13778 install_element(BGP_VPNV6_NODE
,
13779 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
13781 /* "neighbor sender-as-path-loop-detection" commands. */
13782 install_element(BGP_NODE
, &neighbor_aspath_loop_detection_cmd
);
13783 install_element(BGP_NODE
, &no_neighbor_aspath_loop_detection_cmd
);
13785 /* "neighbor passive" commands. */
13786 install_element(BGP_NODE
, &neighbor_passive_cmd
);
13787 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
13790 /* "neighbor shutdown" commands. */
13791 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
13792 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
13793 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
13794 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
13796 /* "neighbor capability extended-nexthop" commands.*/
13797 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
13798 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
13800 /* "neighbor capability orf prefix-list" commands.*/
13801 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
13802 install_element(BGP_NODE
,
13803 &no_neighbor_capability_orf_prefix_hidden_cmd
);
13804 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
13805 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13806 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13807 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13808 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13809 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13810 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13811 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13812 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13813 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13814 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13815 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13817 /* "neighbor capability dynamic" commands.*/
13818 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13819 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13821 /* "neighbor dont-capability-negotiate" commands. */
13822 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13823 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13825 /* "neighbor ebgp-multihop" commands. */
13826 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13827 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13828 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13830 /* "neighbor disable-connected-check" commands. */
13831 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13832 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13834 /* "neighbor enforce-first-as" commands. */
13835 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13836 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13838 /* "neighbor description" commands. */
13839 install_element(BGP_NODE
, &neighbor_description_cmd
);
13840 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13841 install_element(BGP_NODE
, &no_neighbor_description_comment_cmd
);
13843 /* "neighbor update-source" commands. "*/
13844 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13845 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13847 /* "neighbor default-originate" commands. */
13848 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13849 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13850 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13851 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13852 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13853 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13854 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13855 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13856 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13857 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13858 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13859 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13860 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13861 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13862 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13863 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13864 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13865 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13866 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13867 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13868 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13870 /* "neighbor port" commands. */
13871 install_element(BGP_NODE
, &neighbor_port_cmd
);
13872 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13874 /* "neighbor weight" commands. */
13875 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13876 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13878 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13879 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13880 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13881 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13882 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13883 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13884 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13885 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13886 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13887 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13888 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13889 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13890 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13891 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13892 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13893 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13895 /* "neighbor override-capability" commands. */
13896 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13897 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13899 /* "neighbor strict-capability-match" commands. */
13900 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13901 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13903 /* "neighbor timers" commands. */
13904 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13905 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13907 /* "neighbor timers connect" commands. */
13908 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13909 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13911 /* "neighbor advertisement-interval" commands. */
13912 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13913 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13915 /* "neighbor interface" commands. */
13916 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13917 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13919 /* "neighbor distribute" commands. */
13920 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13921 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13922 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13923 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13924 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13925 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13926 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13927 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13928 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13929 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13930 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13931 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13932 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13933 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13934 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13935 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13936 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13937 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13939 /* "neighbor prefix-list" commands. */
13940 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13941 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13942 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13943 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13944 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13945 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13946 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13947 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13948 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13949 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13950 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13951 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13952 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13953 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13954 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13955 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13956 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13957 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13958 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13959 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13960 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13961 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13963 /* "neighbor filter-list" commands. */
13964 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13965 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13966 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13967 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13968 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13969 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13970 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13971 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13972 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13973 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13974 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13975 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13976 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13977 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13978 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13979 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13980 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13981 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13982 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13983 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13984 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13985 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13987 /* "neighbor route-map" commands. */
13988 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13989 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13990 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13991 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13992 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13993 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13994 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13995 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13996 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13997 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13998 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13999 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
14000 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
14001 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
14002 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
14003 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
14004 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
14005 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
14006 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
14007 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
14008 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
14009 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
14010 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
14011 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
14013 /* "neighbor unsuppress-map" commands. */
14014 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
14015 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
14016 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
14017 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
14018 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
14019 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
14020 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
14021 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
14022 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
14023 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
14024 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
14025 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
14026 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
14027 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
14028 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
14029 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
14030 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
14031 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
14033 /* "neighbor maximum-prefix" commands. */
14034 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
14035 install_element(BGP_NODE
,
14036 &neighbor_maximum_prefix_threshold_hidden_cmd
);
14037 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
14038 install_element(BGP_NODE
,
14039 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
14040 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
14041 install_element(BGP_NODE
,
14042 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
14043 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
14044 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
14045 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14046 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14047 install_element(BGP_IPV4_NODE
,
14048 &neighbor_maximum_prefix_threshold_warning_cmd
);
14049 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14050 install_element(BGP_IPV4_NODE
,
14051 &neighbor_maximum_prefix_threshold_restart_cmd
);
14052 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
14053 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
14054 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14055 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14056 install_element(BGP_IPV4M_NODE
,
14057 &neighbor_maximum_prefix_threshold_warning_cmd
);
14058 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14059 install_element(BGP_IPV4M_NODE
,
14060 &neighbor_maximum_prefix_threshold_restart_cmd
);
14061 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
14062 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
14063 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14064 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14065 install_element(BGP_IPV4L_NODE
,
14066 &neighbor_maximum_prefix_threshold_warning_cmd
);
14067 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14068 install_element(BGP_IPV4L_NODE
,
14069 &neighbor_maximum_prefix_threshold_restart_cmd
);
14070 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
14071 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
14072 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14073 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14074 install_element(BGP_IPV6_NODE
,
14075 &neighbor_maximum_prefix_threshold_warning_cmd
);
14076 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14077 install_element(BGP_IPV6_NODE
,
14078 &neighbor_maximum_prefix_threshold_restart_cmd
);
14079 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
14080 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
14081 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14082 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14083 install_element(BGP_IPV6M_NODE
,
14084 &neighbor_maximum_prefix_threshold_warning_cmd
);
14085 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14086 install_element(BGP_IPV6M_NODE
,
14087 &neighbor_maximum_prefix_threshold_restart_cmd
);
14088 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
14089 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
14090 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14091 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14092 install_element(BGP_IPV6L_NODE
,
14093 &neighbor_maximum_prefix_threshold_warning_cmd
);
14094 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14095 install_element(BGP_IPV6L_NODE
,
14096 &neighbor_maximum_prefix_threshold_restart_cmd
);
14097 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
14098 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
14099 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14100 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14101 install_element(BGP_VPNV4_NODE
,
14102 &neighbor_maximum_prefix_threshold_warning_cmd
);
14103 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14104 install_element(BGP_VPNV4_NODE
,
14105 &neighbor_maximum_prefix_threshold_restart_cmd
);
14106 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
14107 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
14108 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
14109 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
14110 install_element(BGP_VPNV6_NODE
,
14111 &neighbor_maximum_prefix_threshold_warning_cmd
);
14112 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
14113 install_element(BGP_VPNV6_NODE
,
14114 &neighbor_maximum_prefix_threshold_restart_cmd
);
14115 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
14117 /* "neighbor allowas-in" */
14118 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
14119 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
14120 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
14121 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
14122 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
14123 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
14124 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
14125 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
14126 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
14127 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
14128 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
14129 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
14130 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
14131 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
14132 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
14133 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
14134 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
14135 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
14136 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
14137 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
14139 /* address-family commands. */
14140 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
14141 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
14142 #ifdef KEEP_OLD_VPN_COMMANDS
14143 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
14144 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
14145 #endif /* KEEP_OLD_VPN_COMMANDS */
14147 install_element(BGP_NODE
, &address_family_evpn_cmd
);
14149 /* "exit-address-family" command. */
14150 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
14151 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
14152 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
14153 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
14154 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
14155 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
14156 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
14157 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
14158 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
14159 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
14160 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
14162 /* "clear ip bgp commands" */
14163 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
14165 /* clear ip bgp prefix */
14166 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
14167 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
14168 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
14170 /* "show [ip] bgp summary" commands. */
14171 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
14172 install_element(VIEW_NODE
, &show_bgp_l2vpn_evpn_updgrps_cmd
);
14173 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
14174 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
14175 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
14176 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
14177 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
14179 /* "show [ip] bgp neighbors" commands. */
14180 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
14182 /* "show [ip] bgp peer-group" commands. */
14183 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
14185 /* "show [ip] bgp paths" commands. */
14186 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
14188 /* "show [ip] bgp community" commands. */
14189 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
14191 /* "show ip bgp large-community" commands. */
14192 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
14193 /* "show [ip] bgp attribute-info" commands. */
14194 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
14195 /* "show [ip] bgp route-leak" command */
14196 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
14198 /* "redistribute" commands. */
14199 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
14200 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
14201 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
14202 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
14203 install_element(BGP_NODE
,
14204 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
14205 install_element(BGP_NODE
,
14206 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
14207 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
14208 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
14209 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
14210 install_element(BGP_NODE
,
14211 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
14212 install_element(BGP_NODE
,
14213 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
14214 install_element(BGP_NODE
,
14215 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
14216 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
14217 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
14218 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
14219 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
14220 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
14221 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
14222 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
14223 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
14224 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
14225 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
14226 install_element(BGP_IPV4_NODE
,
14227 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
14228 install_element(BGP_IPV4_NODE
,
14229 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
14230 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
14231 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
14232 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
14233 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
14234 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
14235 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
14237 /* import|export vpn [route-map WORD] */
14238 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
14239 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
14241 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
14242 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
14244 /* ttl_security commands */
14245 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
14246 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
14248 /* "show [ip] bgp memory" commands. */
14249 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
14251 /* "show bgp martian next-hop" */
14252 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
14254 install_element(VIEW_NODE
, &show_bgp_mac_hash_cmd
);
14256 /* "show [ip] bgp views" commands. */
14257 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
14259 /* "show [ip] bgp vrfs" commands. */
14260 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
14262 /* Community-list. */
14263 community_list_vty();
14265 /* vpn-policy commands */
14266 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
14267 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
14268 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
14269 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
14270 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
14271 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
14272 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
14273 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
14274 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
14275 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
14276 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
14277 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
14279 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
14280 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
14282 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
14283 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
14284 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
14285 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
14286 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
14287 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
14288 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
14289 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
14290 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14291 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
14292 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
14293 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
14296 #include "memory.h"
14297 #include "bgp_regex.h"
14298 #include "bgp_clist.h"
14299 #include "bgp_ecommunity.h"
14301 /* VTY functions. */
14303 /* Direction value to string conversion. */
14304 static const char *community_direct_str(int direct
)
14307 case COMMUNITY_DENY
:
14309 case COMMUNITY_PERMIT
:
14316 /* Display error string. */
14317 static void community_list_perror(struct vty
*vty
, int ret
)
14320 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
14321 vty_out(vty
, "%% Can't find community-list\n");
14323 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
14324 vty_out(vty
, "%% Malformed community-list value\n");
14326 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
14328 "%% Community name conflict, previously defined as standard community\n");
14330 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
14332 "%% Community name conflict, previously defined as expanded community\n");
14337 /* "community-list" keyword help string. */
14338 #define COMMUNITY_LIST_STR "Add a community list entry\n"
14340 /*community-list standard */
14341 DEFUN (community_list_standard
,
14342 bgp_community_list_standard_cmd
,
14343 "bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14346 "Community list number (standard)\n"
14347 "Add an standard community-list entry\n"
14348 "Community list name\n"
14349 "Specify community to reject\n"
14350 "Specify community to accept\n"
14353 char *cl_name_or_number
= NULL
;
14355 int style
= COMMUNITY_LIST_STANDARD
;
14358 argv_find(argv
, argc
, "(1-99)", &idx
);
14359 argv_find(argv
, argc
, "WORD", &idx
);
14360 cl_name_or_number
= argv
[idx
]->arg
;
14361 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14363 argv_find(argv
, argc
, "AA:NN", &idx
);
14364 char *str
= argv_concat(argv
, argc
, idx
);
14366 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14369 XFREE(MTYPE_TMP
, str
);
14372 /* Display error string. */
14373 community_list_perror(vty
, ret
);
14374 return CMD_WARNING_CONFIG_FAILED
;
14377 return CMD_SUCCESS
;
14380 DEFUN (no_community_list_standard_all
,
14381 no_bgp_community_list_standard_all_cmd
,
14382 "no bgp community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14386 "Community list number (standard)\n"
14387 "Add an standard community-list entry\n"
14388 "Community list name\n"
14389 "Specify community to reject\n"
14390 "Specify community to accept\n"
14393 char *cl_name_or_number
= NULL
;
14396 int style
= COMMUNITY_LIST_STANDARD
;
14400 argv_find(argv
, argc
, "permit", &idx
);
14401 argv_find(argv
, argc
, "deny", &idx
);
14404 direct
= argv_find(argv
, argc
, "permit", &idx
)
14409 argv_find(argv
, argc
, "AA:NN", &idx
);
14410 str
= argv_concat(argv
, argc
, idx
);
14414 argv_find(argv
, argc
, "(1-99)", &idx
);
14415 argv_find(argv
, argc
, "WORD", &idx
);
14416 cl_name_or_number
= argv
[idx
]->arg
;
14418 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14421 XFREE(MTYPE_TMP
, str
);
14424 community_list_perror(vty
, ret
);
14425 return CMD_WARNING_CONFIG_FAILED
;
14428 return CMD_SUCCESS
;
14431 ALIAS(no_community_list_standard_all
, no_bgp_community_list_standard_all_list_cmd
,
14432 "no bgp community-list <(1-99)|standard WORD>",
14433 NO_STR BGP_STR COMMUNITY_LIST_STR
14434 "Community list number (standard)\n"
14435 "Add an standard community-list entry\n"
14436 "Community list name\n")
14438 /*community-list expanded */
14439 DEFUN (community_list_expanded_all
,
14440 bgp_community_list_expanded_all_cmd
,
14441 "bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14444 "Community list number (expanded)\n"
14445 "Add an expanded community-list entry\n"
14446 "Community list name\n"
14447 "Specify community to reject\n"
14448 "Specify community to accept\n"
14451 char *cl_name_or_number
= NULL
;
14453 int style
= COMMUNITY_LIST_EXPANDED
;
14457 argv_find(argv
, argc
, "(100-500)", &idx
);
14458 argv_find(argv
, argc
, "WORD", &idx
);
14459 cl_name_or_number
= argv
[idx
]->arg
;
14460 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14462 argv_find(argv
, argc
, "AA:NN", &idx
);
14463 char *str
= argv_concat(argv
, argc
, idx
);
14465 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
14468 XFREE(MTYPE_TMP
, str
);
14471 /* Display error string. */
14472 community_list_perror(vty
, ret
);
14473 return CMD_WARNING_CONFIG_FAILED
;
14476 return CMD_SUCCESS
;
14479 DEFUN (no_community_list_expanded_all
,
14480 no_bgp_community_list_expanded_all_cmd
,
14481 "no bgp community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
14485 "Community list number (expanded)\n"
14486 "Add an expanded community-list entry\n"
14487 "Community list name\n"
14488 "Specify community to reject\n"
14489 "Specify community to accept\n"
14492 char *cl_name_or_number
= NULL
;
14495 int style
= COMMUNITY_LIST_EXPANDED
;
14499 argv_find(argv
, argc
, "permit", &idx
);
14500 argv_find(argv
, argc
, "deny", &idx
);
14503 direct
= argv_find(argv
, argc
, "permit", &idx
)
14508 argv_find(argv
, argc
, "AA:NN", &idx
);
14509 str
= argv_concat(argv
, argc
, idx
);
14513 argv_find(argv
, argc
, "(100-500)", &idx
);
14514 argv_find(argv
, argc
, "WORD", &idx
);
14515 cl_name_or_number
= argv
[idx
]->arg
;
14517 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
14520 XFREE(MTYPE_TMP
, str
);
14523 community_list_perror(vty
, ret
);
14524 return CMD_WARNING_CONFIG_FAILED
;
14527 return CMD_SUCCESS
;
14530 ALIAS(no_community_list_expanded_all
, no_bgp_community_list_expanded_all_list_cmd
,
14531 "no bgp community-list <(100-500)|expanded WORD>",
14532 NO_STR IP_STR COMMUNITY_LIST_STR
14533 "Community list number (expanded)\n"
14534 "Add an expanded community-list entry\n"
14535 "Community list name\n")
14537 /* Return configuration string of community-list entry. */
14538 static const char *community_list_config_str(struct community_entry
*entry
)
14545 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
14546 str
= community_str(entry
->u
.com
, false);
14547 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
14548 str
= lcommunity_str(entry
->u
.lcom
, false);
14550 str
= entry
->config
;
14555 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
14557 struct community_entry
*entry
;
14559 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14560 if (entry
== list
->head
) {
14561 if (all_digit(list
->name
))
14562 vty_out(vty
, "Community %s list %s\n",
14563 entry
->style
== COMMUNITY_LIST_STANDARD
14565 : "(expanded) access",
14568 vty_out(vty
, "Named Community %s list %s\n",
14569 entry
->style
== COMMUNITY_LIST_STANDARD
14575 vty_out(vty
, " %s\n",
14576 community_direct_str(entry
->direct
));
14578 vty_out(vty
, " %s %s\n",
14579 community_direct_str(entry
->direct
),
14580 community_list_config_str(entry
));
14584 DEFUN (show_community_list
,
14585 show_bgp_community_list_cmd
,
14586 "show bgp community-list",
14589 "List community-list\n")
14591 struct community_list
*list
;
14592 struct community_list_master
*cm
;
14594 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14596 return CMD_SUCCESS
;
14598 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14599 community_list_show(vty
, list
);
14601 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14602 community_list_show(vty
, list
);
14604 return CMD_SUCCESS
;
14607 DEFUN (show_community_list_arg
,
14608 show_bgp_community_list_arg_cmd
,
14609 "show bgp community-list <(1-500)|WORD> detail",
14612 "List community-list\n"
14613 "Community-list number\n"
14614 "Community-list name\n"
14615 "Detailed information on community-list\n")
14617 int idx_comm_list
= 3;
14618 struct community_list
*list
;
14620 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
14621 COMMUNITY_LIST_MASTER
);
14623 vty_out(vty
, "%% Can't find community-list\n");
14624 return CMD_WARNING
;
14627 community_list_show(vty
, list
);
14629 return CMD_SUCCESS
;
14633 * Large Community code.
14635 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
14636 struct cmd_token
**argv
, int style
,
14637 int reject_all_digit_name
)
14645 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14648 /* All digit name check. */
14650 argv_find(argv
, argc
, "WORD", &idx
);
14651 argv_find(argv
, argc
, "(1-99)", &idx
);
14652 argv_find(argv
, argc
, "(100-500)", &idx
);
14653 cl_name
= argv
[idx
]->arg
;
14654 if (reject_all_digit_name
&& all_digit(cl_name
)) {
14655 vty_out(vty
, "%% Community name cannot have all digits\n");
14656 return CMD_WARNING_CONFIG_FAILED
;
14660 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
14661 argv_find(argv
, argc
, "LINE", &idx
);
14662 /* Concat community string argument. */
14664 str
= argv_concat(argv
, argc
, idx
);
14668 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
14670 /* Free temporary community list string allocated by
14672 XFREE(MTYPE_TMP
, str
);
14675 community_list_perror(vty
, ret
);
14676 return CMD_WARNING_CONFIG_FAILED
;
14678 return CMD_SUCCESS
;
14681 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
14682 struct cmd_token
**argv
, int style
)
14689 argv_find(argv
, argc
, "permit", &idx
);
14690 argv_find(argv
, argc
, "deny", &idx
);
14693 /* Check the list direct. */
14694 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
14695 direct
= COMMUNITY_PERMIT
;
14697 direct
= COMMUNITY_DENY
;
14700 argv_find(argv
, argc
, "LINE", &idx
);
14701 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
14702 /* Concat community string argument. */
14703 str
= argv_concat(argv
, argc
, idx
);
14707 argv_find(argv
, argc
, "(1-99)", &idx
);
14708 argv_find(argv
, argc
, "(100-500)", &idx
);
14709 argv_find(argv
, argc
, "WORD", &idx
);
14711 /* Unset community list. */
14712 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
14715 /* Free temporary community list string allocated by
14717 XFREE(MTYPE_TMP
, str
);
14720 community_list_perror(vty
, ret
);
14721 return CMD_WARNING_CONFIG_FAILED
;
14724 return CMD_SUCCESS
;
14727 /* "large-community-list" keyword help string. */
14728 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
14729 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
14731 DEFUN (lcommunity_list_standard
,
14732 bgp_lcommunity_list_standard_cmd
,
14733 "bgp large-community-list (1-99) <deny|permit> AA:BB:CC...",
14735 LCOMMUNITY_LIST_STR
14736 "Large Community list number (standard)\n"
14737 "Specify large community to reject\n"
14738 "Specify large community to accept\n"
14739 LCOMMUNITY_VAL_STR
)
14741 return lcommunity_list_set_vty(vty
, argc
, argv
,
14742 LARGE_COMMUNITY_LIST_STANDARD
, 0);
14745 DEFUN (lcommunity_list_expanded
,
14746 bgp_lcommunity_list_expanded_cmd
,
14747 "bgp large-community-list (100-500) <deny|permit> LINE...",
14749 LCOMMUNITY_LIST_STR
14750 "Large Community list number (expanded)\n"
14751 "Specify large community to reject\n"
14752 "Specify large community to accept\n"
14753 "An ordered list as a regular-expression\n")
14755 return lcommunity_list_set_vty(vty
, argc
, argv
,
14756 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
14759 DEFUN (lcommunity_list_name_standard
,
14760 bgp_lcommunity_list_name_standard_cmd
,
14761 "bgp large-community-list standard WORD <deny|permit> AA:BB:CC...",
14763 LCOMMUNITY_LIST_STR
14764 "Specify standard large-community-list\n"
14765 "Large Community list name\n"
14766 "Specify large community to reject\n"
14767 "Specify large community to accept\n"
14768 LCOMMUNITY_VAL_STR
)
14770 return lcommunity_list_set_vty(vty
, argc
, argv
,
14771 LARGE_COMMUNITY_LIST_STANDARD
, 1);
14774 DEFUN (lcommunity_list_name_expanded
,
14775 bgp_lcommunity_list_name_expanded_cmd
,
14776 "bgp large-community-list expanded WORD <deny|permit> LINE...",
14778 LCOMMUNITY_LIST_STR
14779 "Specify expanded large-community-list\n"
14780 "Large Community list name\n"
14781 "Specify large community to reject\n"
14782 "Specify large community to accept\n"
14783 "An ordered list as a regular-expression\n")
14785 return lcommunity_list_set_vty(vty
, argc
, argv
,
14786 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
14789 DEFUN (no_lcommunity_list_standard_all
,
14790 no_bgp_lcommunity_list_standard_all_cmd
,
14791 "no bgp large-community-list <(1-99)|(100-500)|WORD>",
14794 LCOMMUNITY_LIST_STR
14795 "Large Community list number (standard)\n"
14796 "Large Community list number (expanded)\n"
14797 "Large Community list name\n")
14799 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14800 LARGE_COMMUNITY_LIST_STANDARD
);
14803 DEFUN (no_lcommunity_list_name_expanded_all
,
14804 no_bgp_lcommunity_list_name_expanded_all_cmd
,
14805 "no bgp large-community-list expanded WORD",
14808 LCOMMUNITY_LIST_STR
14809 "Specify expanded large-community-list\n"
14810 "Large Community list name\n")
14812 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14813 LARGE_COMMUNITY_LIST_EXPANDED
);
14816 DEFUN (no_lcommunity_list_standard
,
14817 no_bgp_lcommunity_list_standard_cmd
,
14818 "no bgp large-community-list (1-99) <deny|permit> AA:AA:NN...",
14821 LCOMMUNITY_LIST_STR
14822 "Large Community list number (standard)\n"
14823 "Specify large community to reject\n"
14824 "Specify large community to accept\n"
14825 LCOMMUNITY_VAL_STR
)
14827 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14828 LARGE_COMMUNITY_LIST_STANDARD
);
14831 DEFUN (no_lcommunity_list_expanded
,
14832 no_bgp_lcommunity_list_expanded_cmd
,
14833 "no bgp large-community-list (100-500) <deny|permit> LINE...",
14836 LCOMMUNITY_LIST_STR
14837 "Large Community list number (expanded)\n"
14838 "Specify large community to reject\n"
14839 "Specify large community to accept\n"
14840 "An ordered list as a regular-expression\n")
14842 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14843 LARGE_COMMUNITY_LIST_EXPANDED
);
14846 DEFUN (no_lcommunity_list_name_standard
,
14847 no_bgp_lcommunity_list_name_standard_cmd
,
14848 "no bgp large-community-list standard WORD <deny|permit> AA:AA:NN...",
14851 LCOMMUNITY_LIST_STR
14852 "Specify standard large-community-list\n"
14853 "Large Community list name\n"
14854 "Specify large community to reject\n"
14855 "Specify large community to accept\n"
14856 LCOMMUNITY_VAL_STR
)
14858 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14859 LARGE_COMMUNITY_LIST_STANDARD
);
14862 DEFUN (no_lcommunity_list_name_expanded
,
14863 no_bgp_lcommunity_list_name_expanded_cmd
,
14864 "no bgp large-community-list expanded WORD <deny|permit> LINE...",
14867 LCOMMUNITY_LIST_STR
14868 "Specify expanded large-community-list\n"
14869 "Large community list name\n"
14870 "Specify large community to reject\n"
14871 "Specify large community to accept\n"
14872 "An ordered list as a regular-expression\n")
14874 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14875 LARGE_COMMUNITY_LIST_EXPANDED
);
14878 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14880 struct community_entry
*entry
;
14882 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14883 if (entry
== list
->head
) {
14884 if (all_digit(list
->name
))
14885 vty_out(vty
, "Large community %s list %s\n",
14887 LARGE_COMMUNITY_LIST_STANDARD
14889 : "(expanded) access",
14893 "Named large community %s list %s\n",
14895 LARGE_COMMUNITY_LIST_STANDARD
14901 vty_out(vty
, " %s\n",
14902 community_direct_str(entry
->direct
));
14904 vty_out(vty
, " %s %s\n",
14905 community_direct_str(entry
->direct
),
14906 community_list_config_str(entry
));
14910 DEFUN (show_lcommunity_list
,
14911 show_bgp_lcommunity_list_cmd
,
14912 "show bgp large-community-list",
14915 "List large-community list\n")
14917 struct community_list
*list
;
14918 struct community_list_master
*cm
;
14920 cm
= community_list_master_lookup(bgp_clist
,
14921 LARGE_COMMUNITY_LIST_MASTER
);
14923 return CMD_SUCCESS
;
14925 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14926 lcommunity_list_show(vty
, list
);
14928 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14929 lcommunity_list_show(vty
, list
);
14931 return CMD_SUCCESS
;
14934 DEFUN (show_lcommunity_list_arg
,
14935 show_bgp_lcommunity_list_arg_cmd
,
14936 "show bgp large-community-list <(1-500)|WORD> detail",
14939 "List large-community list\n"
14940 "Large-community-list number\n"
14941 "Large-community-list name\n"
14942 "Detailed information on large-community-list\n")
14944 struct community_list
*list
;
14946 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
, 0,
14947 LARGE_COMMUNITY_LIST_MASTER
);
14949 vty_out(vty
, "%% Can't find large-community-list\n");
14950 return CMD_WARNING
;
14953 lcommunity_list_show(vty
, list
);
14955 return CMD_SUCCESS
;
14958 /* "extcommunity-list" keyword help string. */
14959 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
14960 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
14962 DEFUN (extcommunity_list_standard
,
14963 bgp_extcommunity_list_standard_cmd
,
14964 "bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14966 EXTCOMMUNITY_LIST_STR
14967 "Extended Community list number (standard)\n"
14968 "Specify standard extcommunity-list\n"
14969 "Community list name\n"
14970 "Specify community to reject\n"
14971 "Specify community to accept\n"
14972 EXTCOMMUNITY_VAL_STR
)
14974 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14976 char *cl_number_or_name
= NULL
;
14980 argv_find(argv
, argc
, "(1-99)", &idx
);
14981 argv_find(argv
, argc
, "WORD", &idx
);
14982 cl_number_or_name
= argv
[idx
]->arg
;
14983 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14985 argv_find(argv
, argc
, "AA:NN", &idx
);
14986 char *str
= argv_concat(argv
, argc
, idx
);
14988 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14991 XFREE(MTYPE_TMP
, str
);
14994 community_list_perror(vty
, ret
);
14995 return CMD_WARNING_CONFIG_FAILED
;
14998 return CMD_SUCCESS
;
15001 DEFUN (extcommunity_list_name_expanded
,
15002 bgp_extcommunity_list_name_expanded_cmd
,
15003 "bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15005 EXTCOMMUNITY_LIST_STR
15006 "Extended Community list number (expanded)\n"
15007 "Specify expanded extcommunity-list\n"
15008 "Extended Community list name\n"
15009 "Specify community to reject\n"
15010 "Specify community to accept\n"
15011 "An ordered list as a regular-expression\n")
15013 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15015 char *cl_number_or_name
= NULL
;
15018 argv_find(argv
, argc
, "(100-500)", &idx
);
15019 argv_find(argv
, argc
, "WORD", &idx
);
15020 cl_number_or_name
= argv
[idx
]->arg
;
15021 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
15023 argv_find(argv
, argc
, "LINE", &idx
);
15024 char *str
= argv_concat(argv
, argc
, idx
);
15026 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
15029 XFREE(MTYPE_TMP
, str
);
15032 community_list_perror(vty
, ret
);
15033 return CMD_WARNING_CONFIG_FAILED
;
15036 return CMD_SUCCESS
;
15039 DEFUN (no_extcommunity_list_standard_all
,
15040 no_bgp_extcommunity_list_standard_all_cmd
,
15041 "no bgp extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
15044 EXTCOMMUNITY_LIST_STR
15045 "Extended Community list number (standard)\n"
15046 "Specify standard extcommunity-list\n"
15047 "Community list name\n"
15048 "Specify community to reject\n"
15049 "Specify community to accept\n"
15050 EXTCOMMUNITY_VAL_STR
)
15052 int style
= EXTCOMMUNITY_LIST_STANDARD
;
15054 char *cl_number_or_name
= NULL
;
15058 argv_find(argv
, argc
, "permit", &idx
);
15059 argv_find(argv
, argc
, "deny", &idx
);
15062 direct
= argv_find(argv
, argc
, "permit", &idx
)
15067 argv_find(argv
, argc
, "AA:NN", &idx
);
15068 str
= argv_concat(argv
, argc
, idx
);
15072 argv_find(argv
, argc
, "(1-99)", &idx
);
15073 argv_find(argv
, argc
, "WORD", &idx
);
15074 cl_number_or_name
= argv
[idx
]->arg
;
15076 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15079 XFREE(MTYPE_TMP
, str
);
15082 community_list_perror(vty
, ret
);
15083 return CMD_WARNING_CONFIG_FAILED
;
15086 return CMD_SUCCESS
;
15089 ALIAS(no_extcommunity_list_standard_all
,
15090 no_bgp_extcommunity_list_standard_all_list_cmd
,
15091 "no bgp extcommunity-list <(1-99)|standard WORD>",
15092 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15093 "Extended Community list number (standard)\n"
15094 "Specify standard extcommunity-list\n"
15095 "Community list name\n")
15097 DEFUN (no_extcommunity_list_expanded_all
,
15098 no_bgp_extcommunity_list_expanded_all_cmd
,
15099 "no bgp extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
15102 EXTCOMMUNITY_LIST_STR
15103 "Extended Community list number (expanded)\n"
15104 "Specify expanded extcommunity-list\n"
15105 "Extended Community list name\n"
15106 "Specify community to reject\n"
15107 "Specify community to accept\n"
15108 "An ordered list as a regular-expression\n")
15110 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
15112 char *cl_number_or_name
= NULL
;
15116 argv_find(argv
, argc
, "permit", &idx
);
15117 argv_find(argv
, argc
, "deny", &idx
);
15120 direct
= argv_find(argv
, argc
, "permit", &idx
)
15125 argv_find(argv
, argc
, "LINE", &idx
);
15126 str
= argv_concat(argv
, argc
, idx
);
15130 argv_find(argv
, argc
, "(100-500)", &idx
);
15131 argv_find(argv
, argc
, "WORD", &idx
);
15132 cl_number_or_name
= argv
[idx
]->arg
;
15134 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
15137 XFREE(MTYPE_TMP
, str
);
15140 community_list_perror(vty
, ret
);
15141 return CMD_WARNING_CONFIG_FAILED
;
15144 return CMD_SUCCESS
;
15147 ALIAS(no_extcommunity_list_expanded_all
,
15148 no_bgp_extcommunity_list_expanded_all_list_cmd
,
15149 "no bgp extcommunity-list <(100-500)|expanded WORD>",
15150 NO_STR IP_STR EXTCOMMUNITY_LIST_STR
15151 "Extended Community list number (expanded)\n"
15152 "Specify expanded extcommunity-list\n"
15153 "Extended Community list name\n")
15155 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
15157 struct community_entry
*entry
;
15159 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15160 if (entry
== list
->head
) {
15161 if (all_digit(list
->name
))
15162 vty_out(vty
, "Extended community %s list %s\n",
15163 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15165 : "(expanded) access",
15169 "Named extended community %s list %s\n",
15170 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15176 vty_out(vty
, " %s\n",
15177 community_direct_str(entry
->direct
));
15179 vty_out(vty
, " %s %s\n",
15180 community_direct_str(entry
->direct
),
15181 community_list_config_str(entry
));
15185 DEFUN (show_extcommunity_list
,
15186 show_bgp_extcommunity_list_cmd
,
15187 "show bgp extcommunity-list",
15190 "List extended-community list\n")
15192 struct community_list
*list
;
15193 struct community_list_master
*cm
;
15195 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15197 return CMD_SUCCESS
;
15199 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15200 extcommunity_list_show(vty
, list
);
15202 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15203 extcommunity_list_show(vty
, list
);
15205 return CMD_SUCCESS
;
15208 DEFUN (show_extcommunity_list_arg
,
15209 show_bgp_extcommunity_list_arg_cmd
,
15210 "show bgp extcommunity-list <(1-500)|WORD> detail",
15213 "List extended-community list\n"
15214 "Extcommunity-list number\n"
15215 "Extcommunity-list name\n"
15216 "Detailed information on extcommunity-list\n")
15218 int idx_comm_list
= 3;
15219 struct community_list
*list
;
15221 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
, 0,
15222 EXTCOMMUNITY_LIST_MASTER
);
15224 vty_out(vty
, "%% Can't find extcommunity-list\n");
15225 return CMD_WARNING
;
15228 extcommunity_list_show(vty
, list
);
15230 return CMD_SUCCESS
;
15233 /* Display community-list and extcommunity-list configuration. */
15234 static int community_list_config_write(struct vty
*vty
)
15236 struct community_list
*list
;
15237 struct community_entry
*entry
;
15238 struct community_list_master
*cm
;
15241 /* Community-list. */
15242 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
15244 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15245 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15246 vty_out(vty
, "bgp community-list %s %s %s\n", list
->name
,
15247 community_direct_str(entry
->direct
),
15248 community_list_config_str(entry
));
15251 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15252 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15253 vty_out(vty
, "bgp community-list %s %s %s %s\n",
15254 entry
->style
== COMMUNITY_LIST_STANDARD
15257 list
->name
, community_direct_str(entry
->direct
),
15258 community_list_config_str(entry
));
15262 /* Extcommunity-list. */
15263 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
15265 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15266 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15267 vty_out(vty
, "bgp extcommunity-list %s %s %s\n",
15268 list
->name
, community_direct_str(entry
->direct
),
15269 community_list_config_str(entry
));
15272 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15273 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15274 vty_out(vty
, "bgp extcommunity-list %s %s %s %s\n",
15275 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
15278 list
->name
, community_direct_str(entry
->direct
),
15279 community_list_config_str(entry
));
15284 /* lcommunity-list. */
15285 cm
= community_list_master_lookup(bgp_clist
,
15286 LARGE_COMMUNITY_LIST_MASTER
);
15288 for (list
= cm
->num
.head
; list
; list
= list
->next
)
15289 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15290 vty_out(vty
, "bgp large-community-list %s %s %s\n",
15291 list
->name
, community_direct_str(entry
->direct
),
15292 community_list_config_str(entry
));
15295 for (list
= cm
->str
.head
; list
; list
= list
->next
)
15296 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
15297 vty_out(vty
, "bgp large-community-list %s %s %s %s\n",
15298 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
15301 list
->name
, community_direct_str(entry
->direct
),
15302 community_list_config_str(entry
));
15309 static struct cmd_node community_list_node
= {
15310 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
15313 static void community_list_vty(void)
15315 install_node(&community_list_node
, community_list_config_write
);
15317 /* Community-list. */
15318 install_element(CONFIG_NODE
, &bgp_community_list_standard_cmd
);
15319 install_element(CONFIG_NODE
, &bgp_community_list_expanded_all_cmd
);
15320 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_cmd
);
15321 install_element(CONFIG_NODE
, &no_bgp_community_list_standard_all_list_cmd
);
15322 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_cmd
);
15323 install_element(CONFIG_NODE
, &no_bgp_community_list_expanded_all_list_cmd
);
15324 install_element(VIEW_NODE
, &show_bgp_community_list_cmd
);
15325 install_element(VIEW_NODE
, &show_bgp_community_list_arg_cmd
);
15327 /* Extcommunity-list. */
15328 install_element(CONFIG_NODE
, &bgp_extcommunity_list_standard_cmd
);
15329 install_element(CONFIG_NODE
, &bgp_extcommunity_list_name_expanded_cmd
);
15330 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_standard_all_cmd
);
15331 install_element(CONFIG_NODE
,
15332 &no_bgp_extcommunity_list_standard_all_list_cmd
);
15333 install_element(CONFIG_NODE
, &no_bgp_extcommunity_list_expanded_all_cmd
);
15334 install_element(CONFIG_NODE
,
15335 &no_bgp_extcommunity_list_expanded_all_list_cmd
);
15336 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_cmd
);
15337 install_element(VIEW_NODE
, &show_bgp_extcommunity_list_arg_cmd
);
15339 /* Large Community List */
15340 install_element(CONFIG_NODE
, &bgp_lcommunity_list_standard_cmd
);
15341 install_element(CONFIG_NODE
, &bgp_lcommunity_list_expanded_cmd
);
15342 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_standard_cmd
);
15343 install_element(CONFIG_NODE
, &bgp_lcommunity_list_name_expanded_cmd
);
15344 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_all_cmd
);
15345 install_element(CONFIG_NODE
,
15346 &no_bgp_lcommunity_list_name_expanded_all_cmd
);
15347 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_standard_cmd
);
15348 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_expanded_cmd
);
15349 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_standard_cmd
);
15350 install_element(CONFIG_NODE
, &no_bgp_lcommunity_list_name_expanded_cmd
);
15351 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_cmd
);
15352 install_element(VIEW_NODE
, &show_bgp_lcommunity_list_arg_cmd
);