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
33 #include "memory_vty.h"
38 #include "bgpd/bgpd.h"
39 #include "bgpd/bgp_advertise.h"
40 #include "bgpd/bgp_attr.h"
41 #include "bgpd/bgp_aspath.h"
42 #include "bgpd/bgp_community.h"
43 #include "bgpd/bgp_ecommunity.h"
44 #include "bgpd/bgp_lcommunity.h"
45 #include "bgpd/bgp_damp.h"
46 #include "bgpd/bgp_debug.h"
47 #include "bgpd/bgp_fsm.h"
48 #include "bgpd/bgp_nexthop.h"
49 #include "bgpd/bgp_open.h"
50 #include "bgpd/bgp_regex.h"
51 #include "bgpd/bgp_route.h"
52 #include "bgpd/bgp_mplsvpn.h"
53 #include "bgpd/bgp_zebra.h"
54 #include "bgpd/bgp_table.h"
55 #include "bgpd/bgp_vty.h"
56 #include "bgpd/bgp_mpath.h"
57 #include "bgpd/bgp_packet.h"
58 #include "bgpd/bgp_updgrp.h"
59 #include "bgpd/bgp_bfd.h"
60 #include "bgpd/bgp_io.h"
61 #include "bgpd/bgp_evpn.h"
63 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
64 struct prefix
*range
, int exact
);
66 static enum node_type
bgp_node_type(afi_t afi
, safi_t safi
)
75 return BGP_IPV4M_NODE
;
77 case SAFI_LABELED_UNICAST
:
78 return BGP_IPV4L_NODE
;
81 return BGP_VPNV4_NODE
;
84 return BGP_FLOWSPECV4_NODE
;
97 return BGP_IPV6M_NODE
;
99 case SAFI_LABELED_UNICAST
:
100 return BGP_IPV6L_NODE
;
103 return BGP_VPNV6_NODE
;
106 return BGP_FLOWSPECV6_NODE
;
109 return BGP_IPV4_NODE
;
114 return BGP_EVPN_NODE
;
117 // We should never be here but to clarify the switch statement..
118 return BGP_IPV4_NODE
;
122 // Impossible to happen
123 return BGP_IPV4_NODE
;
126 /* Utility function to get address family from current node. */
127 afi_t
bgp_node_afi(struct vty
*vty
)
135 case BGP_FLOWSPECV6_NODE
:
148 /* Utility function to get subsequent address family from current
150 safi_t
bgp_node_safi(struct vty
*vty
)
156 safi
= SAFI_MPLS_VPN
;
160 safi
= SAFI_MULTICAST
;
167 safi
= SAFI_LABELED_UNICAST
;
169 case BGP_FLOWSPECV4_NODE
:
170 case BGP_FLOWSPECV6_NODE
:
171 safi
= SAFI_FLOWSPEC
;
181 * Converts an AFI in string form to afi_t
183 * @param afi string, one of
186 * @return the corresponding afi_t
188 afi_t
bgp_vty_afi_from_str(const char *afi_str
)
190 afi_t afi
= AFI_MAX
; /* unknown */
191 if (strmatch(afi_str
, "ipv4"))
193 else if (strmatch(afi_str
, "ipv6"))
198 int argv_find_and_parse_afi(struct cmd_token
**argv
, int argc
, int *index
,
202 if (argv_find(argv
, argc
, "ipv4", index
)) {
206 } else if (argv_find(argv
, argc
, "ipv6", index
)) {
214 /* supports <unicast|multicast|vpn|labeled-unicast> */
215 safi_t
bgp_vty_safi_from_str(const char *safi_str
)
217 safi_t safi
= SAFI_MAX
; /* unknown */
218 if (strmatch(safi_str
, "multicast"))
219 safi
= SAFI_MULTICAST
;
220 else if (strmatch(safi_str
, "unicast"))
222 else if (strmatch(safi_str
, "vpn"))
223 safi
= SAFI_MPLS_VPN
;
224 else if (strmatch(safi_str
, "labeled-unicast"))
225 safi
= SAFI_LABELED_UNICAST
;
226 else if (strmatch(safi_str
, "flowspec"))
227 safi
= SAFI_FLOWSPEC
;
231 int argv_find_and_parse_safi(struct cmd_token
**argv
, int argc
, int *index
,
235 if (argv_find(argv
, argc
, "unicast", index
)) {
238 *safi
= SAFI_UNICAST
;
239 } else if (argv_find(argv
, argc
, "multicast", index
)) {
242 *safi
= SAFI_MULTICAST
;
243 } else if (argv_find(argv
, argc
, "labeled-unicast", index
)) {
246 *safi
= SAFI_LABELED_UNICAST
;
247 } else if (argv_find(argv
, argc
, "vpn", index
)) {
250 *safi
= SAFI_MPLS_VPN
;
251 } else if (argv_find(argv
, argc
, "flowspec", index
)) {
254 *safi
= SAFI_FLOWSPEC
;
260 * bgp_vty_find_and_parse_afi_safi_bgp
262 * For a given 'show ...' command, correctly parse the afi/safi/bgp out from it
263 * This function *assumes* that the calling function pre-sets the afi/safi/bgp
264 * to appropriate values for the calling function. This is to allow the
265 * calling function to make decisions appropriate for the show command
266 * that is being parsed.
268 * The show commands are generally of the form:
269 * "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>
270 * [<unicast|multicast|vpn|labeled-unicast>]] ..."
272 * Since we use argv_find if the show command in particular doesn't have:
274 * [<view|vrf> VIEWVRFNAME]
275 * [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]]
276 * The command parsing should still be ok.
278 * vty -> The vty for the command so we can output some useful data in
279 * the event of a parse error in the vrf.
280 * argv -> The command tokens
281 * argc -> How many command tokens we have
282 * idx -> The current place in the command, generally should be 0 for this
284 * afi -> The parsed afi if it was included in the show command, returned here
285 * safi -> The parsed safi if it was included in the show command, returned here
286 * bgp -> Pointer to the bgp data structure we need to fill in.
288 * The function returns the correct location in the parse tree for the
291 * Returns 0 for failure to parse correctly, else the idx position of where
292 * it found the last token.
294 int bgp_vty_find_and_parse_afi_safi_bgp(struct vty
*vty
,
295 struct cmd_token
**argv
, int argc
,
296 int *idx
, afi_t
*afi
, safi_t
*safi
,
299 char *vrf_name
= NULL
;
305 if (argv_find(argv
, argc
, "ip", idx
))
308 if (argv_find(argv
, argc
, "view", idx
)
309 || argv_find(argv
, argc
, "vrf", idx
)) {
310 vrf_name
= argv
[*idx
+ 1]->arg
;
312 if (strmatch(vrf_name
, "all"))
315 *bgp
= bgp_lookup_by_name(vrf_name
);
318 "View/Vrf specified is unknown: %s\n",
325 *bgp
= bgp_get_default();
327 vty_out(vty
, "Unable to find default BGP instance\n");
333 if (argv_find_and_parse_afi(argv
, argc
, idx
, afi
))
334 argv_find_and_parse_safi(argv
, argc
, idx
, safi
);
340 static int peer_address_self_check(struct bgp
*bgp
, union sockunion
*su
)
342 struct interface
*ifp
= NULL
;
344 if (su
->sa
.sa_family
== AF_INET
)
345 ifp
= if_lookup_by_ipv4_exact(&su
->sin
.sin_addr
, bgp
->vrf_id
);
346 else if (su
->sa
.sa_family
== AF_INET6
)
347 ifp
= if_lookup_by_ipv6_exact(&su
->sin6
.sin6_addr
,
348 su
->sin6
.sin6_scope_id
,
357 /* Utility function for looking up peer from VTY. */
358 /* This is used only for configuration, so disallow if attempted on
359 * a dynamic neighbor.
361 static struct peer
*peer_lookup_vty(struct vty
*vty
, const char *ip_str
)
363 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
372 ret
= str2sockunion(ip_str
, &su
);
374 peer
= peer_lookup_by_conf_if(bgp
, ip_str
);
376 if ((peer
= peer_lookup_by_hostname(bgp
, ip_str
))
379 "%% Malformed address or name: %s\n",
385 peer
= peer_lookup(bgp
, &su
);
388 "%% Specify remote-as or peer-group commands first\n");
391 if (peer_dynamic_neighbor(peer
)) {
393 "%% Operation not allowed on a dynamic neighbor\n");
400 /* Utility function for looking up peer or peer group. */
401 /* This is used only for configuration, so disallow if attempted on
402 * a dynamic neighbor.
404 struct peer
*peer_and_group_lookup_vty(struct vty
*vty
, const char *peer_str
)
406 struct bgp
*bgp
= VTY_GET_CONTEXT(bgp
);
409 struct peer
*peer
= NULL
;
410 struct peer_group
*group
= NULL
;
416 ret
= str2sockunion(peer_str
, &su
);
418 /* IP address, locate peer. */
419 peer
= peer_lookup(bgp
, &su
);
421 /* Not IP, could match either peer configured on interface or a
423 peer
= peer_lookup_by_conf_if(bgp
, peer_str
);
425 group
= peer_group_lookup(bgp
, peer_str
);
429 if (peer_dynamic_neighbor(peer
)) {
431 "%% Operation not allowed on a dynamic neighbor\n");
441 vty_out(vty
, "%% Specify remote-as or peer-group commands first\n");
446 int bgp_vty_return(struct vty
*vty
, int ret
)
448 const char *str
= NULL
;
451 case BGP_ERR_INVALID_VALUE
:
452 str
= "Invalid value";
454 case BGP_ERR_INVALID_FLAG
:
455 str
= "Invalid flag";
457 case BGP_ERR_PEER_GROUP_SHUTDOWN
:
458 str
= "Peer-group has been shutdown. Activate the peer-group first";
460 case BGP_ERR_PEER_FLAG_CONFLICT
:
461 str
= "Can't set override-capability and strict-capability-match at the same time";
463 case BGP_ERR_PEER_GROUP_NO_REMOTE_AS
:
464 str
= "Specify remote-as or peer-group remote AS first";
466 case BGP_ERR_PEER_GROUP_CANT_CHANGE
:
467 str
= "Cannot change the peer-group. Deconfigure first";
469 case BGP_ERR_PEER_GROUP_MISMATCH
:
470 str
= "Peer is not a member of this peer-group";
472 case BGP_ERR_PEER_FILTER_CONFLICT
:
473 str
= "Prefix/distribute list can not co-exist";
475 case BGP_ERR_NOT_INTERNAL_PEER
:
476 str
= "Invalid command. Not an internal neighbor";
478 case BGP_ERR_REMOVE_PRIVATE_AS
:
479 str
= "remove-private-AS cannot be configured for IBGP peers";
481 case BGP_ERR_LOCAL_AS_ALLOWED_ONLY_FOR_EBGP
:
482 str
= "Local-AS allowed only for EBGP peers";
484 case BGP_ERR_CANNOT_HAVE_LOCAL_AS_SAME_AS
:
485 str
= "Cannot have local-as same as BGP AS number";
487 case BGP_ERR_TCPSIG_FAILED
:
488 str
= "Error while applying TCP-Sig to session(s)";
490 case BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK
:
491 str
= "ebgp-multihop and ttl-security cannot be configured together";
493 case BGP_ERR_NO_IBGP_WITH_TTLHACK
:
494 str
= "ttl-security only allowed for EBGP peers";
496 case BGP_ERR_AS_OVERRIDE
:
497 str
= "as-override cannot be configured for IBGP peers";
499 case BGP_ERR_INVALID_DYNAMIC_NEIGHBORS_LIMIT
:
500 str
= "Invalid limit for number of dynamic neighbors";
502 case BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_EXISTS
:
503 str
= "Dynamic neighbor listen range already exists";
505 case BGP_ERR_INVALID_FOR_DYNAMIC_PEER
:
506 str
= "Operation not allowed on a dynamic neighbor";
508 case BGP_ERR_INVALID_FOR_DIRECT_PEER
:
509 str
= "Operation not allowed on a directly connected neighbor";
511 case BGP_ERR_PEER_SAFI_CONFLICT
:
512 str
= "Cannot activate peer for both 'ipv4 unicast' and 'ipv4 labeled-unicast'";
516 vty_out(vty
, "%% %s\n", str
);
517 return CMD_WARNING_CONFIG_FAILED
;
522 /* BGP clear sort. */
531 static void bgp_clear_vty_error(struct vty
*vty
, struct peer
*peer
, afi_t afi
,
532 safi_t safi
, int error
)
535 case BGP_ERR_AF_UNCONFIGURED
:
537 "%%BGP: Enable %s address family for the neighbor %s\n",
538 afi_safi_print(afi
, safi
), peer
->host
);
540 case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED
:
542 "%%BGP: Inbound soft reconfig for %s not possible as it\n has neither refresh capability, nor inbound soft reconfig\n",
550 /* `clear ip bgp' functions. */
551 static int bgp_clear(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
, safi_t safi
,
552 enum clear_sort sort
, enum bgp_clear_type stype
,
558 struct listnode
*node
, *nnode
;
560 /* Clear all neighbors. */
562 * Pass along pointer to next node to peer_clear() when walking all
563 * nodes on the BGP instance as that may get freed if it is a
566 if (sort
== clear_all
) {
567 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
568 if (!peer
->afc
[afi
][safi
])
571 if (stype
== BGP_CLEAR_SOFT_NONE
)
572 ret
= peer_clear(peer
, &nnode
);
574 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
577 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
582 /* This is to apply read-only mode on this clear. */
583 if (stype
== BGP_CLEAR_SOFT_NONE
)
584 bgp
->update_delay_over
= 0;
587 vty_out(vty
, "%%BGP: No %s peer configured",
588 afi_safi_print(afi
, safi
));
593 /* Clear specified neighbor. */
594 if (sort
== clear_peer
) {
597 /* Make sockunion for lookup. */
598 ret
= str2sockunion(arg
, &su
);
600 peer
= peer_lookup_by_conf_if(bgp
, arg
);
602 peer
= peer_lookup_by_hostname(bgp
, arg
);
605 "Malformed address or name: %s\n",
611 peer
= peer_lookup(bgp
, &su
);
614 "%%BGP: Unknown neighbor - \"%s\"\n",
620 if (!peer
->afc
[afi
][safi
])
621 ret
= BGP_ERR_AF_UNCONFIGURED
;
622 else if (stype
== BGP_CLEAR_SOFT_NONE
)
623 ret
= peer_clear(peer
, NULL
);
625 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
628 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
633 /* Clear all neighbors belonging to a specific peer-group. */
634 if (sort
== clear_group
) {
635 struct peer_group
*group
;
637 group
= peer_group_lookup(bgp
, arg
);
639 vty_out(vty
, "%%BGP: No such peer-group %s\n", arg
);
643 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
644 if (!peer
->afc
[afi
][safi
])
647 if (stype
== BGP_CLEAR_SOFT_NONE
)
648 ret
= peer_clear(peer
, NULL
);
650 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
653 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
660 "%%BGP: No %s peer belonging to peer-group %s is configured\n",
661 afi_safi_print(afi
, safi
), arg
);
666 /* Clear all external (eBGP) neighbors. */
667 if (sort
== clear_external
) {
668 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
669 if (peer
->sort
== BGP_PEER_IBGP
)
672 if (!peer
->afc
[afi
][safi
])
675 if (stype
== BGP_CLEAR_SOFT_NONE
)
676 ret
= peer_clear(peer
, &nnode
);
678 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
681 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
688 "%%BGP: No external %s peer is configured\n",
689 afi_safi_print(afi
, safi
));
694 /* Clear all neighbors belonging to a specific AS. */
695 if (sort
== clear_as
) {
696 as_t as
= strtoul(arg
, NULL
, 10);
698 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
702 if (!peer
->afc
[afi
][safi
])
703 ret
= BGP_ERR_AF_UNCONFIGURED
;
704 else if (stype
== BGP_CLEAR_SOFT_NONE
)
705 ret
= peer_clear(peer
, &nnode
);
707 ret
= peer_clear_soft(peer
, afi
, safi
, stype
);
710 bgp_clear_vty_error(vty
, peer
, afi
, safi
, ret
);
717 "%%BGP: No %s peer is configured with AS %s\n",
718 afi_safi_print(afi
, safi
), arg
);
726 static int bgp_clear_vty(struct vty
*vty
, const char *name
, afi_t afi
,
727 safi_t safi
, enum clear_sort sort
,
728 enum bgp_clear_type stype
, const char *arg
)
732 /* BGP structure lookup. */
734 bgp
= bgp_lookup_by_name(name
);
736 vty_out(vty
, "Can't find BGP instance %s\n", name
);
740 bgp
= bgp_get_default();
742 vty_out(vty
, "No BGP process is configured\n");
747 return bgp_clear(vty
, bgp
, afi
, safi
, sort
, stype
, arg
);
750 /* clear soft inbound */
751 static void bgp_clear_star_soft_in(struct vty
*vty
, const char *name
)
753 bgp_clear_vty(vty
, name
, AFI_IP
, SAFI_UNICAST
, clear_all
,
754 BGP_CLEAR_SOFT_IN
, NULL
);
755 bgp_clear_vty(vty
, name
, AFI_IP6
, SAFI_UNICAST
, clear_all
,
756 BGP_CLEAR_SOFT_IN
, NULL
);
759 /* clear soft outbound */
760 static void bgp_clear_star_soft_out(struct vty
*vty
, const char *name
)
762 bgp_clear_vty(vty
, name
, AFI_IP
, SAFI_UNICAST
, clear_all
,
763 BGP_CLEAR_SOFT_OUT
, NULL
);
764 bgp_clear_vty(vty
, name
, AFI_IP6
, SAFI_UNICAST
, clear_all
,
765 BGP_CLEAR_SOFT_OUT
, NULL
);
769 #ifndef VTYSH_EXTRACT_PL
770 #include "bgpd/bgp_vty_clippy.c"
773 /* BGP global configuration. */
774 #if defined(VERSION_TYPE_DEV) && (CONFDATE > 20190601)
775 CPP_NOTICE("bgpd: time to remove deprecated bgp multiple-instance")
776 CPP_NOTICE("This includes BGP_OPT_MULTIPLE_INSTANCE")
778 DEFUN_HIDDEN (bgp_multiple_instance_func
,
779 bgp_multiple_instance_cmd
,
780 "bgp multiple-instance",
782 "Enable bgp multiple instance\n")
784 bgp_option_set(BGP_OPT_MULTIPLE_INSTANCE
);
788 DEFUN_HIDDEN (no_bgp_multiple_instance
,
789 no_bgp_multiple_instance_cmd
,
790 "no bgp multiple-instance",
793 "BGP multiple instance\n")
797 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
798 vty_out(vty
, "if you are using this please let the developers know\n");
799 zlog_warn("Deprecated option: `bgp multiple-instance` being used");
800 ret
= bgp_option_unset(BGP_OPT_MULTIPLE_INSTANCE
);
802 vty_out(vty
, "%% There are more than two BGP instances\n");
803 return CMD_WARNING_CONFIG_FAILED
;
808 #if defined(VERSION_TYPE_DEV) && (CONFDATE > 20190601)
809 CPP_NOTICE("bgpd: time to remove deprecated cli bgp config-type cisco")
810 CPP_NOTICE("This includes BGP_OPT_CISCO_CONFIG")
812 DEFUN_HIDDEN (bgp_config_type
,
814 "bgp config-type <cisco|zebra>",
816 "Configuration type\n"
821 if (argv_find(argv
, argc
, "cisco", &idx
)) {
822 vty_out(vty
, "This config option is deprecated, and is scheduled for removal.\n");
823 vty_out(vty
, "if you are using this please let the developers know!\n");
824 zlog_warn("Deprecated option: `bgp config-type cisco` being used");
825 bgp_option_set(BGP_OPT_CONFIG_CISCO
);
827 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
832 DEFUN_HIDDEN (no_bgp_config_type
,
833 no_bgp_config_type_cmd
,
834 "no bgp config-type [<cisco|zebra>]",
837 "Display configuration type\n"
841 bgp_option_unset(BGP_OPT_CONFIG_CISCO
);
846 DEFUN (no_synchronization
,
847 no_synchronization_cmd
,
848 "no synchronization",
850 "Perform IGP synchronization\n")
855 DEFUN (no_auto_summary
,
859 "Enable automatic network number summarization\n")
864 /* "router bgp" commands. */
865 DEFUN_NOSH (router_bgp
,
867 "router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
871 BGP_INSTANCE_HELP_STR
)
874 int idx_view_vrf
= 3;
879 const char *name
= NULL
;
880 enum bgp_instance_type inst_type
;
882 // "router bgp" without an ASN
884 // Pending: Make VRF option available for ASN less config
885 bgp
= bgp_get_default();
888 vty_out(vty
, "%% No BGP process is configured\n");
889 return CMD_WARNING_CONFIG_FAILED
;
892 if (listcount(bm
->bgp
) > 1) {
893 vty_out(vty
, "%% Please specify ASN and VRF\n");
894 return CMD_WARNING_CONFIG_FAILED
;
900 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
902 inst_type
= BGP_INSTANCE_TYPE_DEFAULT
;
904 name
= argv
[idx_vrf
]->arg
;
906 if (!strcmp(argv
[idx_view_vrf
]->text
, "vrf"))
907 inst_type
= BGP_INSTANCE_TYPE_VRF
;
908 else if (!strcmp(argv
[idx_view_vrf
]->text
, "view"))
909 inst_type
= BGP_INSTANCE_TYPE_VIEW
;
912 ret
= bgp_get(&bgp
, &as
, name
, inst_type
);
914 case BGP_ERR_MULTIPLE_INSTANCE_NOT_SET
:
916 "Please specify 'bgp multiple-instance' first\n");
917 return CMD_WARNING_CONFIG_FAILED
;
918 case BGP_ERR_AS_MISMATCH
:
919 vty_out(vty
, "BGP is already running; AS is %u\n", as
);
920 return CMD_WARNING_CONFIG_FAILED
;
921 case BGP_ERR_INSTANCE_MISMATCH
:
923 "BGP instance name and AS number mismatch\n");
925 "BGP instance is already running; AS is %u\n",
927 return CMD_WARNING_CONFIG_FAILED
;
930 /* Pending: handle when user tries to change a view to vrf n vv.
934 /* unset the auto created flag as the user config is now present */
935 UNSET_FLAG(bgp
->vrf_flags
, BGP_VRF_AUTO
);
936 VTY_PUSH_CONTEXT(BGP_NODE
, bgp
);
941 /* "no router bgp" commands. */
942 DEFUN (no_router_bgp
,
944 "no router bgp [(1-4294967295) [<view|vrf> VIEWVRFNAME]]",
949 BGP_INSTANCE_HELP_STR
)
955 const char *name
= NULL
;
957 // "no router bgp" without an ASN
959 // Pending: Make VRF option available for ASN less config
960 bgp
= bgp_get_default();
963 vty_out(vty
, "%% No BGP process is configured\n");
964 return CMD_WARNING_CONFIG_FAILED
;
967 if (listcount(bm
->bgp
) > 1) {
968 vty_out(vty
, "%% Please specify ASN and VRF\n");
969 return CMD_WARNING_CONFIG_FAILED
;
973 vty_out(vty
, "%% Please unconfigure l3vni %u",
975 return CMD_WARNING_CONFIG_FAILED
;
978 as
= strtoul(argv
[idx_asn
]->arg
, NULL
, 10);
981 name
= argv
[idx_vrf
]->arg
;
983 /* Lookup bgp structure. */
984 bgp
= bgp_lookup(as
, name
);
986 vty_out(vty
, "%% Can't find BGP instance\n");
987 return CMD_WARNING_CONFIG_FAILED
;
991 vty_out(vty
, "%% Please unconfigure l3vni %u",
993 return CMD_WARNING_CONFIG_FAILED
;
1003 /* BGP router-id. */
1005 DEFPY (bgp_router_id
,
1007 "bgp router-id A.B.C.D",
1009 "Override configured router identifier\n"
1010 "Manually configured router identifier\n")
1012 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1013 bgp_router_id_static_set(bgp
, router_id
);
1017 DEFPY (no_bgp_router_id
,
1018 no_bgp_router_id_cmd
,
1019 "no bgp router-id [A.B.C.D]",
1022 "Override configured router identifier\n"
1023 "Manually configured router identifier\n")
1025 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1027 if (router_id_str
) {
1028 if (!IPV4_ADDR_SAME(&bgp
->router_id_static
, &router_id
)) {
1029 vty_out(vty
, "%% BGP router-id doesn't match\n");
1030 return CMD_WARNING_CONFIG_FAILED
;
1034 router_id
.s_addr
= 0;
1035 bgp_router_id_static_set(bgp
, router_id
);
1041 /* BGP Cluster ID. */
1042 DEFUN (bgp_cluster_id
,
1044 "bgp cluster-id <A.B.C.D|(1-4294967295)>",
1046 "Configure Route-Reflector Cluster-id\n"
1047 "Route-Reflector Cluster-id in IP address format\n"
1048 "Route-Reflector Cluster-id as 32 bit quantity\n")
1050 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1053 struct in_addr cluster
;
1055 ret
= inet_aton(argv
[idx_ipv4
]->arg
, &cluster
);
1057 vty_out(vty
, "%% Malformed bgp cluster identifier\n");
1058 return CMD_WARNING_CONFIG_FAILED
;
1061 bgp_cluster_id_set(bgp
, &cluster
);
1062 bgp_clear_star_soft_out(vty
, bgp
->name
);
1067 DEFUN (no_bgp_cluster_id
,
1068 no_bgp_cluster_id_cmd
,
1069 "no bgp cluster-id [<A.B.C.D|(1-4294967295)>]",
1072 "Configure Route-Reflector Cluster-id\n"
1073 "Route-Reflector Cluster-id in IP address format\n"
1074 "Route-Reflector Cluster-id as 32 bit quantity\n")
1076 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1077 bgp_cluster_id_unset(bgp
);
1078 bgp_clear_star_soft_out(vty
, bgp
->name
);
1083 DEFUN (bgp_confederation_identifier
,
1084 bgp_confederation_identifier_cmd
,
1085 "bgp confederation identifier (1-4294967295)",
1086 "BGP specific commands\n"
1087 "AS confederation parameters\n"
1089 "Set routing domain confederation AS\n")
1091 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1095 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1097 bgp_confederation_id_set(bgp
, as
);
1102 DEFUN (no_bgp_confederation_identifier
,
1103 no_bgp_confederation_identifier_cmd
,
1104 "no bgp confederation identifier [(1-4294967295)]",
1106 "BGP specific commands\n"
1107 "AS confederation parameters\n"
1109 "Set routing domain confederation AS\n")
1111 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1112 bgp_confederation_id_unset(bgp
);
1117 DEFUN (bgp_confederation_peers
,
1118 bgp_confederation_peers_cmd
,
1119 "bgp confederation peers (1-4294967295)...",
1120 "BGP specific commands\n"
1121 "AS confederation parameters\n"
1122 "Peer ASs in BGP confederation\n"
1125 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1130 for (i
= idx_asn
; i
< argc
; i
++) {
1131 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1133 if (bgp
->as
== as
) {
1135 "%% Local member-AS not allowed in confed peer list\n");
1139 bgp_confederation_peers_add(bgp
, as
);
1144 DEFUN (no_bgp_confederation_peers
,
1145 no_bgp_confederation_peers_cmd
,
1146 "no bgp confederation peers (1-4294967295)...",
1148 "BGP specific commands\n"
1149 "AS confederation parameters\n"
1150 "Peer ASs in BGP confederation\n"
1153 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1158 for (i
= idx_asn
; i
< argc
; i
++) {
1159 as
= strtoul(argv
[i
]->arg
, NULL
, 10);
1161 bgp_confederation_peers_remove(bgp
, as
);
1167 * Central routine for maximum-paths configuration.
1168 * @peer_type: BGP_PEER_EBGP or BGP_PEER_IBGP
1169 * @set: 1 for setting values, 0 for removing the max-paths config.
1171 static int bgp_maxpaths_config_vty(struct vty
*vty
, int peer_type
,
1172 const char *mpaths
, uint16_t options
,
1175 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1176 uint16_t maxpaths
= 0;
1181 afi
= bgp_node_afi(vty
);
1182 safi
= bgp_node_safi(vty
);
1185 maxpaths
= strtol(mpaths
, NULL
, 10);
1186 if (maxpaths
> multipath_num
) {
1188 "%% Maxpaths Specified: %d is > than multipath num specified on bgp command line %d",
1189 maxpaths
, multipath_num
);
1190 return CMD_WARNING_CONFIG_FAILED
;
1192 ret
= bgp_maximum_paths_set(bgp
, afi
, safi
, peer_type
, maxpaths
,
1195 ret
= bgp_maximum_paths_unset(bgp
, afi
, safi
, peer_type
);
1199 "%% Failed to %sset maximum-paths %s %u for afi %u, safi %u\n",
1200 (set
== 1) ? "" : "un",
1201 (peer_type
== BGP_PEER_EBGP
) ? "ebgp" : "ibgp",
1202 maxpaths
, afi
, safi
);
1203 return CMD_WARNING_CONFIG_FAILED
;
1206 bgp_recalculate_all_bestpaths(bgp
);
1211 DEFUN (bgp_maxmed_admin
,
1212 bgp_maxmed_admin_cmd
,
1213 "bgp max-med administrative ",
1215 "Advertise routes with max-med\n"
1216 "Administratively applied, for an indefinite period\n")
1218 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1220 bgp
->v_maxmed_admin
= 1;
1221 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1223 bgp_maxmed_update(bgp
);
1228 DEFUN (bgp_maxmed_admin_medv
,
1229 bgp_maxmed_admin_medv_cmd
,
1230 "bgp max-med administrative (0-4294967295)",
1232 "Advertise routes with max-med\n"
1233 "Administratively applied, for an indefinite period\n"
1234 "Max MED value to be used\n")
1236 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1239 bgp
->v_maxmed_admin
= 1;
1240 bgp
->maxmed_admin_value
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1242 bgp_maxmed_update(bgp
);
1247 DEFUN (no_bgp_maxmed_admin
,
1248 no_bgp_maxmed_admin_cmd
,
1249 "no bgp max-med administrative [(0-4294967295)]",
1252 "Advertise routes with max-med\n"
1253 "Administratively applied, for an indefinite period\n"
1254 "Max MED value to be used\n")
1256 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1257 bgp
->v_maxmed_admin
= BGP_MAXMED_ADMIN_UNCONFIGURED
;
1258 bgp
->maxmed_admin_value
= BGP_MAXMED_VALUE_DEFAULT
;
1259 bgp_maxmed_update(bgp
);
1264 DEFUN (bgp_maxmed_onstartup
,
1265 bgp_maxmed_onstartup_cmd
,
1266 "bgp max-med on-startup (5-86400) [(0-4294967295)]",
1268 "Advertise routes with max-med\n"
1269 "Effective on a startup\n"
1270 "Time (seconds) period for max-med\n"
1271 "Max MED value to be used\n")
1273 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1276 argv_find(argv
, argc
, "(5-86400)", &idx
);
1277 bgp
->v_maxmed_onstartup
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1278 if (argv_find(argv
, argc
, "(0-4294967295)", &idx
))
1279 bgp
->maxmed_onstartup_value
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1281 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1283 bgp_maxmed_update(bgp
);
1288 DEFUN (no_bgp_maxmed_onstartup
,
1289 no_bgp_maxmed_onstartup_cmd
,
1290 "no bgp max-med on-startup [(5-86400) [(0-4294967295)]]",
1293 "Advertise routes with max-med\n"
1294 "Effective on a startup\n"
1295 "Time (seconds) period for max-med\n"
1296 "Max MED value to be used\n")
1298 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1300 /* Cancel max-med onstartup if its on */
1301 if (bgp
->t_maxmed_onstartup
) {
1302 THREAD_TIMER_OFF(bgp
->t_maxmed_onstartup
);
1303 bgp
->maxmed_onstartup_over
= 1;
1306 bgp
->v_maxmed_onstartup
= BGP_MAXMED_ONSTARTUP_UNCONFIGURED
;
1307 bgp
->maxmed_onstartup_value
= BGP_MAXMED_VALUE_DEFAULT
;
1309 bgp_maxmed_update(bgp
);
1314 static int bgp_update_delay_config_vty(struct vty
*vty
, const char *delay
,
1317 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1318 uint16_t update_delay
;
1319 uint16_t establish_wait
;
1321 update_delay
= strtoul(delay
, NULL
, 10);
1323 if (!wait
) /* update-delay <delay> */
1325 bgp
->v_update_delay
= update_delay
;
1326 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1330 /* update-delay <delay> <establish-wait> */
1331 establish_wait
= atoi(wait
);
1332 if (update_delay
< establish_wait
) {
1334 "%%Failed: update-delay less than the establish-wait!\n");
1335 return CMD_WARNING_CONFIG_FAILED
;
1338 bgp
->v_update_delay
= update_delay
;
1339 bgp
->v_establish_wait
= establish_wait
;
1344 static int bgp_update_delay_deconfig_vty(struct vty
*vty
)
1346 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1348 bgp
->v_update_delay
= BGP_UPDATE_DELAY_DEF
;
1349 bgp
->v_establish_wait
= bgp
->v_update_delay
;
1354 void bgp_config_write_update_delay(struct vty
*vty
, struct bgp
*bgp
)
1356 if (bgp
->v_update_delay
!= BGP_UPDATE_DELAY_DEF
) {
1357 vty_out(vty
, " update-delay %d", bgp
->v_update_delay
);
1358 if (bgp
->v_update_delay
!= bgp
->v_establish_wait
)
1359 vty_out(vty
, " %d", bgp
->v_establish_wait
);
1365 /* Update-delay configuration */
1366 DEFUN (bgp_update_delay
,
1367 bgp_update_delay_cmd
,
1368 "update-delay (0-3600)",
1369 "Force initial delay for best-path and updates\n"
1373 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
, NULL
);
1376 DEFUN (bgp_update_delay_establish_wait
,
1377 bgp_update_delay_establish_wait_cmd
,
1378 "update-delay (0-3600) (1-3600)",
1379 "Force initial delay for best-path and updates\n"
1384 int idx_number_2
= 2;
1385 return bgp_update_delay_config_vty(vty
, argv
[idx_number
]->arg
,
1386 argv
[idx_number_2
]->arg
);
1389 /* Update-delay deconfiguration */
1390 DEFUN (no_bgp_update_delay
,
1391 no_bgp_update_delay_cmd
,
1392 "no update-delay [(0-3600) [(1-3600)]]",
1394 "Force initial delay for best-path and updates\n"
1398 return bgp_update_delay_deconfig_vty(vty
);
1402 static int bgp_wpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1405 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1408 uint32_t quanta
= strtoul(num
, NULL
, 10);
1409 atomic_store_explicit(&bgp
->wpkt_quanta
, quanta
,
1410 memory_order_relaxed
);
1412 atomic_store_explicit(&bgp
->wpkt_quanta
, BGP_WRITE_PACKET_MAX
,
1413 memory_order_relaxed
);
1419 static int bgp_rpkt_quanta_config_vty(struct vty
*vty
, const char *num
,
1422 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1425 uint32_t quanta
= strtoul(num
, NULL
, 10);
1426 atomic_store_explicit(&bgp
->rpkt_quanta
, quanta
,
1427 memory_order_relaxed
);
1429 atomic_store_explicit(&bgp
->rpkt_quanta
, BGP_READ_PACKET_MAX
,
1430 memory_order_relaxed
);
1436 void bgp_config_write_wpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1439 atomic_load_explicit(&bgp
->wpkt_quanta
, memory_order_relaxed
);
1440 if (quanta
!= BGP_WRITE_PACKET_MAX
)
1441 vty_out(vty
, " write-quanta %d\n", quanta
);
1444 void bgp_config_write_rpkt_quanta(struct vty
*vty
, struct bgp
*bgp
)
1447 atomic_load_explicit(&bgp
->rpkt_quanta
, memory_order_relaxed
);
1448 if (quanta
!= BGP_READ_PACKET_MAX
)
1449 vty_out(vty
, " read-quanta %d\n", quanta
);
1452 /* Packet quanta configuration */
1453 DEFUN (bgp_wpkt_quanta
,
1454 bgp_wpkt_quanta_cmd
,
1455 "write-quanta (1-10)",
1456 "How many packets to write to peer socket per run\n"
1457 "Number of packets\n")
1460 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1463 DEFUN (no_bgp_wpkt_quanta
,
1464 no_bgp_wpkt_quanta_cmd
,
1465 "no write-quanta (1-10)",
1467 "How many packets to write to peer socket per I/O cycle\n"
1468 "Number of packets\n")
1471 return bgp_wpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1474 DEFUN (bgp_rpkt_quanta
,
1475 bgp_rpkt_quanta_cmd
,
1476 "read-quanta (1-10)",
1477 "How many packets to read from peer socket per I/O cycle\n"
1478 "Number of packets\n")
1481 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 1);
1484 DEFUN (no_bgp_rpkt_quanta
,
1485 no_bgp_rpkt_quanta_cmd
,
1486 "no read-quanta (1-10)",
1488 "How many packets to read from peer socket per I/O cycle\n"
1489 "Number of packets\n")
1492 return bgp_rpkt_quanta_config_vty(vty
, argv
[idx_number
]->arg
, 0);
1495 void bgp_config_write_coalesce_time(struct vty
*vty
, struct bgp
*bgp
)
1497 if (!bgp
->heuristic_coalesce
)
1498 vty_out(vty
, " coalesce-time %u\n", bgp
->coalesce_time
);
1502 DEFUN (bgp_coalesce_time
,
1503 bgp_coalesce_time_cmd
,
1504 "coalesce-time (0-4294967295)",
1505 "Subgroup coalesce timer\n"
1506 "Subgroup coalesce timer value (in ms)\n")
1508 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1511 argv_find(argv
, argc
, "(0-4294967295)", &idx
);
1512 bgp
->heuristic_coalesce
= false;
1513 bgp
->coalesce_time
= strtoul(argv
[idx
]->arg
, NULL
, 10);
1517 DEFUN (no_bgp_coalesce_time
,
1518 no_bgp_coalesce_time_cmd
,
1519 "no coalesce-time (0-4294967295)",
1521 "Subgroup coalesce timer\n"
1522 "Subgroup coalesce timer value (in ms)\n")
1524 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1526 bgp
->heuristic_coalesce
= true;
1527 bgp
->coalesce_time
= BGP_DEFAULT_SUBGROUP_COALESCE_TIME
;
1531 /* Maximum-paths configuration */
1532 DEFUN (bgp_maxpaths
,
1534 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1535 "Forward packets over multiple paths\n"
1536 "Number of paths\n")
1539 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
,
1540 argv
[idx_number
]->arg
, 0, 1);
1543 ALIAS_HIDDEN(bgp_maxpaths
, bgp_maxpaths_hidden_cmd
,
1544 "maximum-paths " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1545 "Forward packets over multiple paths\n"
1546 "Number of paths\n")
1548 DEFUN (bgp_maxpaths_ibgp
,
1549 bgp_maxpaths_ibgp_cmd
,
1550 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1551 "Forward packets over multiple paths\n"
1553 "Number of paths\n")
1556 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
,
1557 argv
[idx_number
]->arg
, 0, 1);
1560 ALIAS_HIDDEN(bgp_maxpaths_ibgp
, bgp_maxpaths_ibgp_hidden_cmd
,
1561 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
),
1562 "Forward packets over multiple paths\n"
1564 "Number of paths\n")
1566 DEFUN (bgp_maxpaths_ibgp_cluster
,
1567 bgp_maxpaths_ibgp_cluster_cmd
,
1568 "maximum-paths ibgp " CMD_RANGE_STR(1, MULTIPATH_NUM
) " equal-cluster-length",
1569 "Forward packets over multiple paths\n"
1572 "Match the cluster length\n")
1575 return bgp_maxpaths_config_vty(
1576 vty
, BGP_PEER_IBGP
, argv
[idx_number
]->arg
,
1577 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
, 1);
1580 ALIAS_HIDDEN(bgp_maxpaths_ibgp_cluster
, bgp_maxpaths_ibgp_cluster_hidden_cmd
,
1581 "maximum-paths ibgp " CMD_RANGE_STR(
1582 1, MULTIPATH_NUM
) " equal-cluster-length",
1583 "Forward packets over multiple paths\n"
1586 "Match the cluster length\n")
1588 DEFUN (no_bgp_maxpaths
,
1589 no_bgp_maxpaths_cmd
,
1590 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]",
1592 "Forward packets over multiple paths\n"
1593 "Number of paths\n")
1595 return bgp_maxpaths_config_vty(vty
, BGP_PEER_EBGP
, NULL
, 0, 0);
1598 ALIAS_HIDDEN(no_bgp_maxpaths
, no_bgp_maxpaths_hidden_cmd
,
1599 "no maximum-paths [" CMD_RANGE_STR(1, MULTIPATH_NUM
) "]", NO_STR
1600 "Forward packets over multiple paths\n"
1601 "Number of paths\n")
1603 DEFUN (no_bgp_maxpaths_ibgp
,
1604 no_bgp_maxpaths_ibgp_cmd
,
1605 "no maximum-paths ibgp [" CMD_RANGE_STR(1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1607 "Forward packets over multiple paths\n"
1610 "Match the cluster length\n")
1612 return bgp_maxpaths_config_vty(vty
, BGP_PEER_IBGP
, NULL
, 0, 0);
1615 ALIAS_HIDDEN(no_bgp_maxpaths_ibgp
, no_bgp_maxpaths_ibgp_hidden_cmd
,
1616 "no maximum-paths ibgp [" CMD_RANGE_STR(
1617 1, MULTIPATH_NUM
) " [equal-cluster-length]]",
1619 "Forward packets over multiple paths\n"
1622 "Match the cluster length\n")
1624 void bgp_config_write_maxpaths(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
1627 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
!= MULTIPATH_NUM
) {
1628 vty_out(vty
, " maximum-paths %d\n",
1629 bgp
->maxpaths
[afi
][safi
].maxpaths_ebgp
);
1632 if (bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
!= MULTIPATH_NUM
) {
1633 vty_out(vty
, " maximum-paths ibgp %d",
1634 bgp
->maxpaths
[afi
][safi
].maxpaths_ibgp
);
1635 if (CHECK_FLAG(bgp
->maxpaths
[afi
][safi
].ibgp_flags
,
1636 BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN
))
1637 vty_out(vty
, " equal-cluster-length");
1646 "timers bgp (0-65535) (0-65535)",
1647 "Adjust routing timers\n"
1649 "Keepalive interval\n"
1652 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1654 int idx_number_2
= 3;
1655 unsigned long keepalive
= 0;
1656 unsigned long holdtime
= 0;
1658 keepalive
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1659 holdtime
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
1661 /* Holdtime value check. */
1662 if (holdtime
< 3 && holdtime
!= 0) {
1664 "%% hold time value must be either 0 or greater than 3\n");
1665 return CMD_WARNING_CONFIG_FAILED
;
1668 bgp_timers_set(bgp
, keepalive
, holdtime
);
1673 DEFUN (no_bgp_timers
,
1675 "no timers bgp [(0-65535) (0-65535)]",
1677 "Adjust routing timers\n"
1679 "Keepalive interval\n"
1682 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1683 bgp_timers_unset(bgp
);
1689 DEFUN (bgp_client_to_client_reflection
,
1690 bgp_client_to_client_reflection_cmd
,
1691 "bgp client-to-client reflection",
1692 "BGP specific commands\n"
1693 "Configure client to client route reflection\n"
1694 "reflection of routes allowed\n")
1696 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1697 bgp_flag_unset(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1698 bgp_clear_star_soft_out(vty
, bgp
->name
);
1703 DEFUN (no_bgp_client_to_client_reflection
,
1704 no_bgp_client_to_client_reflection_cmd
,
1705 "no bgp client-to-client reflection",
1707 "BGP specific commands\n"
1708 "Configure client to client route reflection\n"
1709 "reflection of routes allowed\n")
1711 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1712 bgp_flag_set(bgp
, BGP_FLAG_NO_CLIENT_TO_CLIENT
);
1713 bgp_clear_star_soft_out(vty
, bgp
->name
);
1718 /* "bgp always-compare-med" configuration. */
1719 DEFUN (bgp_always_compare_med
,
1720 bgp_always_compare_med_cmd
,
1721 "bgp always-compare-med",
1722 "BGP specific commands\n"
1723 "Allow comparing MED from different neighbors\n")
1725 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1726 bgp_flag_set(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1727 bgp_recalculate_all_bestpaths(bgp
);
1732 DEFUN (no_bgp_always_compare_med
,
1733 no_bgp_always_compare_med_cmd
,
1734 "no bgp always-compare-med",
1736 "BGP specific commands\n"
1737 "Allow comparing MED from different neighbors\n")
1739 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1740 bgp_flag_unset(bgp
, BGP_FLAG_ALWAYS_COMPARE_MED
);
1741 bgp_recalculate_all_bestpaths(bgp
);
1746 /* "bgp deterministic-med" configuration. */
1747 DEFUN (bgp_deterministic_med
,
1748 bgp_deterministic_med_cmd
,
1749 "bgp deterministic-med",
1750 "BGP specific commands\n"
1751 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1753 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1755 if (!bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1756 bgp_flag_set(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1757 bgp_recalculate_all_bestpaths(bgp
);
1763 DEFUN (no_bgp_deterministic_med
,
1764 no_bgp_deterministic_med_cmd
,
1765 "no bgp deterministic-med",
1767 "BGP specific commands\n"
1768 "Pick the best-MED path among paths advertised from the neighboring AS\n")
1770 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1771 int bestpath_per_as_used
;
1775 struct listnode
*node
, *nnode
;
1777 if (bgp_flag_check(bgp
, BGP_FLAG_DETERMINISTIC_MED
)) {
1778 bestpath_per_as_used
= 0;
1780 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
1781 FOREACH_AFI_SAFI (afi
, safi
)
1783 peer
->af_flags
[afi
][safi
],
1784 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
)) {
1785 bestpath_per_as_used
= 1;
1789 if (bestpath_per_as_used
)
1793 if (bestpath_per_as_used
) {
1795 "bgp deterministic-med cannot be disabled while addpath-tx-bestpath-per-AS is in use\n");
1796 return CMD_WARNING_CONFIG_FAILED
;
1798 bgp_flag_unset(bgp
, BGP_FLAG_DETERMINISTIC_MED
);
1799 bgp_recalculate_all_bestpaths(bgp
);
1806 /* "bgp graceful-restart" configuration. */
1807 DEFUN (bgp_graceful_restart
,
1808 bgp_graceful_restart_cmd
,
1809 "bgp graceful-restart",
1810 "BGP specific commands\n"
1811 "Graceful restart capability parameters\n")
1813 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1814 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1818 DEFUN (no_bgp_graceful_restart
,
1819 no_bgp_graceful_restart_cmd
,
1820 "no bgp graceful-restart",
1822 "BGP specific commands\n"
1823 "Graceful restart capability parameters\n")
1825 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1826 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_RESTART
);
1830 DEFUN (bgp_graceful_restart_stalepath_time
,
1831 bgp_graceful_restart_stalepath_time_cmd
,
1832 "bgp graceful-restart stalepath-time (1-3600)",
1833 "BGP specific commands\n"
1834 "Graceful restart capability parameters\n"
1835 "Set the max time to hold onto restarting peer's stale paths\n"
1836 "Delay value (seconds)\n")
1838 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1842 stalepath
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1843 bgp
->stalepath_time
= stalepath
;
1847 DEFUN (bgp_graceful_restart_restart_time
,
1848 bgp_graceful_restart_restart_time_cmd
,
1849 "bgp graceful-restart restart-time (1-3600)",
1850 "BGP specific commands\n"
1851 "Graceful restart capability parameters\n"
1852 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1853 "Delay value (seconds)\n")
1855 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1859 restart
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
1860 bgp
->restart_time
= restart
;
1864 DEFUN (no_bgp_graceful_restart_stalepath_time
,
1865 no_bgp_graceful_restart_stalepath_time_cmd
,
1866 "no bgp graceful-restart stalepath-time [(1-3600)]",
1868 "BGP specific commands\n"
1869 "Graceful restart capability parameters\n"
1870 "Set the max time to hold onto restarting peer's stale paths\n"
1871 "Delay value (seconds)\n")
1873 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1875 bgp
->stalepath_time
= BGP_DEFAULT_STALEPATH_TIME
;
1879 DEFUN (no_bgp_graceful_restart_restart_time
,
1880 no_bgp_graceful_restart_restart_time_cmd
,
1881 "no bgp graceful-restart restart-time [(1-3600)]",
1883 "BGP specific commands\n"
1884 "Graceful restart capability parameters\n"
1885 "Set the time to wait to delete stale routes before a BGP open message is received\n"
1886 "Delay value (seconds)\n")
1888 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1890 bgp
->restart_time
= BGP_DEFAULT_RESTART_TIME
;
1894 DEFUN (bgp_graceful_restart_preserve_fw
,
1895 bgp_graceful_restart_preserve_fw_cmd
,
1896 "bgp graceful-restart preserve-fw-state",
1897 "BGP specific commands\n"
1898 "Graceful restart capability parameters\n"
1899 "Sets F-bit indication that fib is preserved while doing Graceful Restart\n")
1901 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1902 bgp_flag_set(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
1906 DEFUN (no_bgp_graceful_restart_preserve_fw
,
1907 no_bgp_graceful_restart_preserve_fw_cmd
,
1908 "no bgp graceful-restart preserve-fw-state",
1910 "BGP specific commands\n"
1911 "Graceful restart capability parameters\n"
1912 "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n")
1914 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1915 bgp_flag_unset(bgp
, BGP_FLAG_GR_PRESERVE_FWD
);
1919 static void bgp_redistribute_redo(struct bgp
*bgp
)
1923 struct list
*red_list
;
1924 struct listnode
*node
;
1925 struct bgp_redist
*red
;
1927 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
1928 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
1930 red_list
= bgp
->redist
[afi
][i
];
1934 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
1935 bgp_redistribute_resend(bgp
, afi
, i
,
1942 /* "bgp graceful-shutdown" configuration */
1943 DEFUN (bgp_graceful_shutdown
,
1944 bgp_graceful_shutdown_cmd
,
1945 "bgp graceful-shutdown",
1947 "Graceful shutdown parameters\n")
1949 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1951 if (!bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
1952 bgp_flag_set(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
1953 bgp_static_redo_import_check(bgp
);
1954 bgp_redistribute_redo(bgp
);
1955 bgp_clear_star_soft_out(vty
, bgp
->name
);
1956 bgp_clear_star_soft_in(vty
, bgp
->name
);
1962 DEFUN (no_bgp_graceful_shutdown
,
1963 no_bgp_graceful_shutdown_cmd
,
1964 "no bgp graceful-shutdown",
1967 "Graceful shutdown parameters\n")
1969 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1971 if (bgp_flag_check(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
)) {
1972 bgp_flag_unset(bgp
, BGP_FLAG_GRACEFUL_SHUTDOWN
);
1973 bgp_static_redo_import_check(bgp
);
1974 bgp_redistribute_redo(bgp
);
1975 bgp_clear_star_soft_out(vty
, bgp
->name
);
1976 bgp_clear_star_soft_in(vty
, bgp
->name
);
1982 /* "bgp fast-external-failover" configuration. */
1983 DEFUN (bgp_fast_external_failover
,
1984 bgp_fast_external_failover_cmd
,
1985 "bgp fast-external-failover",
1987 "Immediately reset session if a link to a directly connected external peer goes down\n")
1989 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
1990 bgp_flag_unset(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
1994 DEFUN (no_bgp_fast_external_failover
,
1995 no_bgp_fast_external_failover_cmd
,
1996 "no bgp fast-external-failover",
1999 "Immediately reset session if a link to a directly connected external peer goes down\n")
2001 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2002 bgp_flag_set(bgp
, BGP_FLAG_NO_FAST_EXT_FAILOVER
);
2006 /* "bgp enforce-first-as" configuration. */
2007 #if defined(VERSION_TYPE_DEV) && CONFDATE > 20180517
2008 CPP_NOTICE("bgpd: remove deprecated '[no] bgp enforce-first-as' commands")
2011 DEFUN_DEPRECATED (bgp_enforce_first_as
,
2012 bgp_enforce_first_as_cmd
,
2013 "bgp enforce-first-as",
2015 "Enforce the first AS for EBGP routes\n")
2017 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2018 bgp_flag_set(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2023 DEFUN_DEPRECATED (no_bgp_enforce_first_as
,
2024 no_bgp_enforce_first_as_cmd
,
2025 "no bgp enforce-first-as",
2028 "Enforce the first AS for EBGP routes\n")
2030 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2031 bgp_flag_unset(bgp
, BGP_FLAG_ENFORCE_FIRST_AS
);
2036 /* "bgp bestpath compare-routerid" configuration. */
2037 DEFUN (bgp_bestpath_compare_router_id
,
2038 bgp_bestpath_compare_router_id_cmd
,
2039 "bgp bestpath compare-routerid",
2040 "BGP specific commands\n"
2041 "Change the default bestpath selection\n"
2042 "Compare router-id for identical EBGP paths\n")
2044 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2045 bgp_flag_set(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2046 bgp_recalculate_all_bestpaths(bgp
);
2051 DEFUN (no_bgp_bestpath_compare_router_id
,
2052 no_bgp_bestpath_compare_router_id_cmd
,
2053 "no bgp bestpath compare-routerid",
2055 "BGP specific commands\n"
2056 "Change the default bestpath selection\n"
2057 "Compare router-id for identical EBGP paths\n")
2059 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2060 bgp_flag_unset(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
);
2061 bgp_recalculate_all_bestpaths(bgp
);
2066 /* "bgp bestpath as-path ignore" configuration. */
2067 DEFUN (bgp_bestpath_aspath_ignore
,
2068 bgp_bestpath_aspath_ignore_cmd
,
2069 "bgp bestpath as-path ignore",
2070 "BGP specific commands\n"
2071 "Change the default bestpath selection\n"
2072 "AS-path attribute\n"
2073 "Ignore as-path length in selecting a route\n")
2075 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2076 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2077 bgp_recalculate_all_bestpaths(bgp
);
2082 DEFUN (no_bgp_bestpath_aspath_ignore
,
2083 no_bgp_bestpath_aspath_ignore_cmd
,
2084 "no bgp bestpath as-path ignore",
2086 "BGP specific commands\n"
2087 "Change the default bestpath selection\n"
2088 "AS-path attribute\n"
2089 "Ignore as-path length in selecting a route\n")
2091 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2092 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_IGNORE
);
2093 bgp_recalculate_all_bestpaths(bgp
);
2098 /* "bgp bestpath as-path confed" configuration. */
2099 DEFUN (bgp_bestpath_aspath_confed
,
2100 bgp_bestpath_aspath_confed_cmd
,
2101 "bgp bestpath as-path confed",
2102 "BGP specific commands\n"
2103 "Change the default bestpath selection\n"
2104 "AS-path attribute\n"
2105 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2107 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2108 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_CONFED
);
2109 bgp_recalculate_all_bestpaths(bgp
);
2114 DEFUN (no_bgp_bestpath_aspath_confed
,
2115 no_bgp_bestpath_aspath_confed_cmd
,
2116 "no bgp bestpath as-path confed",
2118 "BGP specific commands\n"
2119 "Change the default bestpath selection\n"
2120 "AS-path attribute\n"
2121 "Compare path lengths including confederation sets & sequences in selecting a route\n")
2123 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2124 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_CONFED
);
2125 bgp_recalculate_all_bestpaths(bgp
);
2130 /* "bgp bestpath as-path multipath-relax" configuration. */
2131 DEFUN (bgp_bestpath_aspath_multipath_relax
,
2132 bgp_bestpath_aspath_multipath_relax_cmd
,
2133 "bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2134 "BGP specific commands\n"
2135 "Change the default bestpath selection\n"
2136 "AS-path attribute\n"
2137 "Allow load sharing across routes that have different AS paths (but same length)\n"
2138 "Generate an AS_SET\n"
2139 "Do not generate an AS_SET\n")
2141 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2143 bgp_flag_set(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2145 /* no-as-set is now the default behavior so we can silently
2147 if (argv_find(argv
, argc
, "as-set", &idx
))
2148 bgp_flag_set(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2150 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2152 bgp_recalculate_all_bestpaths(bgp
);
2157 DEFUN (no_bgp_bestpath_aspath_multipath_relax
,
2158 no_bgp_bestpath_aspath_multipath_relax_cmd
,
2159 "no bgp bestpath as-path multipath-relax [<as-set|no-as-set>]",
2161 "BGP specific commands\n"
2162 "Change the default bestpath selection\n"
2163 "AS-path attribute\n"
2164 "Allow load sharing across routes that have different AS paths (but same length)\n"
2165 "Generate an AS_SET\n"
2166 "Do not generate an AS_SET\n")
2168 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2169 bgp_flag_unset(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
);
2170 bgp_flag_unset(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
);
2171 bgp_recalculate_all_bestpaths(bgp
);
2176 /* "bgp log-neighbor-changes" configuration. */
2177 DEFUN (bgp_log_neighbor_changes
,
2178 bgp_log_neighbor_changes_cmd
,
2179 "bgp log-neighbor-changes",
2180 "BGP specific commands\n"
2181 "Log neighbor up/down and reset reason\n")
2183 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2184 bgp_flag_set(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2188 DEFUN (no_bgp_log_neighbor_changes
,
2189 no_bgp_log_neighbor_changes_cmd
,
2190 "no bgp log-neighbor-changes",
2192 "BGP specific commands\n"
2193 "Log neighbor up/down and reset reason\n")
2195 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2196 bgp_flag_unset(bgp
, BGP_FLAG_LOG_NEIGHBOR_CHANGES
);
2200 /* "bgp bestpath med" configuration. */
2201 DEFUN (bgp_bestpath_med
,
2202 bgp_bestpath_med_cmd
,
2203 "bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2204 "BGP specific commands\n"
2205 "Change the default bestpath selection\n"
2207 "Compare MED among confederation paths\n"
2208 "Treat missing MED as the least preferred one\n"
2209 "Treat missing MED as the least preferred one\n"
2210 "Compare MED among confederation paths\n")
2212 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2215 if (argv_find(argv
, argc
, "confed", &idx
))
2216 bgp_flag_set(bgp
, BGP_FLAG_MED_CONFED
);
2218 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2219 bgp_flag_set(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2221 bgp_recalculate_all_bestpaths(bgp
);
2226 DEFUN (no_bgp_bestpath_med
,
2227 no_bgp_bestpath_med_cmd
,
2228 "no bgp bestpath med <confed [missing-as-worst]|missing-as-worst [confed]>",
2230 "BGP specific commands\n"
2231 "Change the default bestpath selection\n"
2233 "Compare MED among confederation paths\n"
2234 "Treat missing MED as the least preferred one\n"
2235 "Treat missing MED as the least preferred one\n"
2236 "Compare MED among confederation paths\n")
2238 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2241 if (argv_find(argv
, argc
, "confed", &idx
))
2242 bgp_flag_unset(bgp
, BGP_FLAG_MED_CONFED
);
2244 if (argv_find(argv
, argc
, "missing-as-worst", &idx
))
2245 bgp_flag_unset(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
);
2247 bgp_recalculate_all_bestpaths(bgp
);
2252 /* "no bgp default ipv4-unicast". */
2253 DEFUN (no_bgp_default_ipv4_unicast
,
2254 no_bgp_default_ipv4_unicast_cmd
,
2255 "no bgp default ipv4-unicast",
2257 "BGP specific commands\n"
2258 "Configure BGP defaults\n"
2259 "Activate ipv4-unicast for a peer by default\n")
2261 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2262 bgp_flag_set(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2266 DEFUN (bgp_default_ipv4_unicast
,
2267 bgp_default_ipv4_unicast_cmd
,
2268 "bgp default ipv4-unicast",
2269 "BGP specific commands\n"
2270 "Configure BGP defaults\n"
2271 "Activate ipv4-unicast for a peer by default\n")
2273 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2274 bgp_flag_unset(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
);
2278 /* Display hostname in certain command outputs */
2279 DEFUN (bgp_default_show_hostname
,
2280 bgp_default_show_hostname_cmd
,
2281 "bgp default show-hostname",
2282 "BGP specific commands\n"
2283 "Configure BGP defaults\n"
2284 "Show hostname in certain command ouputs\n")
2286 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2287 bgp_flag_set(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2291 DEFUN (no_bgp_default_show_hostname
,
2292 no_bgp_default_show_hostname_cmd
,
2293 "no bgp default show-hostname",
2295 "BGP specific commands\n"
2296 "Configure BGP defaults\n"
2297 "Show hostname in certain command ouputs\n")
2299 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2300 bgp_flag_unset(bgp
, BGP_FLAG_SHOW_HOSTNAME
);
2304 /* "bgp network import-check" configuration. */
2305 DEFUN (bgp_network_import_check
,
2306 bgp_network_import_check_cmd
,
2307 "bgp network import-check",
2308 "BGP specific commands\n"
2309 "BGP network command\n"
2310 "Check BGP network route exists in IGP\n")
2312 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2313 if (!bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2314 bgp_flag_set(bgp
, BGP_FLAG_IMPORT_CHECK
);
2315 bgp_static_redo_import_check(bgp
);
2321 ALIAS_HIDDEN(bgp_network_import_check
, bgp_network_import_check_exact_cmd
,
2322 "bgp network import-check exact",
2323 "BGP specific commands\n"
2324 "BGP network command\n"
2325 "Check BGP network route exists in IGP\n"
2326 "Match route precisely\n")
2328 DEFUN (no_bgp_network_import_check
,
2329 no_bgp_network_import_check_cmd
,
2330 "no bgp network import-check",
2332 "BGP specific commands\n"
2333 "BGP network command\n"
2334 "Check BGP network route exists in IGP\n")
2336 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2337 if (bgp_flag_check(bgp
, BGP_FLAG_IMPORT_CHECK
)) {
2338 bgp_flag_unset(bgp
, BGP_FLAG_IMPORT_CHECK
);
2339 bgp_static_redo_import_check(bgp
);
2345 DEFUN (bgp_default_local_preference
,
2346 bgp_default_local_preference_cmd
,
2347 "bgp default local-preference (0-4294967295)",
2348 "BGP specific commands\n"
2349 "Configure BGP defaults\n"
2350 "local preference (higher=more preferred)\n"
2351 "Configure default local preference value\n")
2353 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2355 uint32_t local_pref
;
2357 local_pref
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2359 bgp_default_local_preference_set(bgp
, local_pref
);
2360 bgp_clear_star_soft_in(vty
, bgp
->name
);
2365 DEFUN (no_bgp_default_local_preference
,
2366 no_bgp_default_local_preference_cmd
,
2367 "no bgp default local-preference [(0-4294967295)]",
2369 "BGP specific commands\n"
2370 "Configure BGP defaults\n"
2371 "local preference (higher=more preferred)\n"
2372 "Configure default local preference value\n")
2374 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2375 bgp_default_local_preference_unset(bgp
);
2376 bgp_clear_star_soft_in(vty
, bgp
->name
);
2382 DEFUN (bgp_default_subgroup_pkt_queue_max
,
2383 bgp_default_subgroup_pkt_queue_max_cmd
,
2384 "bgp default subgroup-pkt-queue-max (20-100)",
2385 "BGP specific commands\n"
2386 "Configure BGP defaults\n"
2387 "subgroup-pkt-queue-max\n"
2388 "Configure subgroup packet queue max\n")
2390 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2394 max_size
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2396 bgp_default_subgroup_pkt_queue_max_set(bgp
, max_size
);
2401 DEFUN (no_bgp_default_subgroup_pkt_queue_max
,
2402 no_bgp_default_subgroup_pkt_queue_max_cmd
,
2403 "no bgp default subgroup-pkt-queue-max [(20-100)]",
2405 "BGP specific commands\n"
2406 "Configure BGP defaults\n"
2407 "subgroup-pkt-queue-max\n"
2408 "Configure subgroup packet queue max\n")
2410 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2411 bgp_default_subgroup_pkt_queue_max_unset(bgp
);
2416 DEFUN (bgp_rr_allow_outbound_policy
,
2417 bgp_rr_allow_outbound_policy_cmd
,
2418 "bgp route-reflector allow-outbound-policy",
2419 "BGP specific commands\n"
2420 "Allow modifications made by out route-map\n"
2421 "on ibgp neighbors\n")
2423 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2425 if (!bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2426 bgp_flag_set(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2427 update_group_announce_rrclients(bgp
);
2428 bgp_clear_star_soft_out(vty
, bgp
->name
);
2434 DEFUN (no_bgp_rr_allow_outbound_policy
,
2435 no_bgp_rr_allow_outbound_policy_cmd
,
2436 "no bgp route-reflector allow-outbound-policy",
2438 "BGP specific commands\n"
2439 "Allow modifications made by out route-map\n"
2440 "on ibgp neighbors\n")
2442 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2444 if (bgp_flag_check(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
)) {
2445 bgp_flag_unset(bgp
, BGP_FLAG_RR_ALLOW_OUTBOUND_POLICY
);
2446 update_group_announce_rrclients(bgp
);
2447 bgp_clear_star_soft_out(vty
, bgp
->name
);
2453 DEFUN (bgp_listen_limit
,
2454 bgp_listen_limit_cmd
,
2455 "bgp listen limit (1-5000)",
2456 "BGP specific commands\n"
2457 "Configure BGP defaults\n"
2458 "maximum number of BGP Dynamic Neighbors that can be created\n"
2459 "Configure Dynamic Neighbors listen limit value\n")
2461 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2465 listen_limit
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
2467 bgp_listen_limit_set(bgp
, listen_limit
);
2472 DEFUN (no_bgp_listen_limit
,
2473 no_bgp_listen_limit_cmd
,
2474 "no bgp listen limit [(1-5000)]",
2475 "BGP specific commands\n"
2476 "Configure BGP defaults\n"
2477 "unset maximum number of BGP Dynamic Neighbors that can be created\n"
2478 "Configure Dynamic Neighbors listen limit value to default\n"
2479 "Configure Dynamic Neighbors listen limit value\n")
2481 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2482 bgp_listen_limit_unset(bgp
);
2488 * Check if this listen range is already configured. Check for exact
2489 * match or overlap based on input.
2491 static struct peer_group
*listen_range_exists(struct bgp
*bgp
,
2492 struct prefix
*range
, int exact
)
2494 struct listnode
*node
, *nnode
;
2495 struct listnode
*node1
, *nnode1
;
2496 struct peer_group
*group
;
2501 afi
= family2afi(range
->family
);
2502 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2503 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node1
, nnode1
,
2506 match
= prefix_same(range
, lr
);
2508 match
= (prefix_match(range
, lr
)
2509 || prefix_match(lr
, range
));
2518 DEFUN (bgp_listen_range
,
2519 bgp_listen_range_cmd
,
2520 "bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2521 "BGP specific commands\n"
2522 "Configure BGP dynamic neighbors listen range\n"
2523 "Configure BGP dynamic neighbors listen range\n"
2525 "Member of the peer-group\n"
2526 "Peer-group name\n")
2528 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2529 struct prefix range
;
2530 struct peer_group
*group
, *existing_group
;
2535 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2536 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2537 char *prefix
= argv
[idx
]->arg
;
2538 argv_find(argv
, argc
, "WORD", &idx
);
2539 char *peergroup
= argv
[idx
]->arg
;
2541 /* Convert IP prefix string to struct prefix. */
2542 ret
= str2prefix(prefix
, &range
);
2544 vty_out(vty
, "%% Malformed listen range\n");
2545 return CMD_WARNING_CONFIG_FAILED
;
2548 afi
= family2afi(range
.family
);
2550 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2552 "%% Malformed listen range (link-local address)\n");
2553 return CMD_WARNING_CONFIG_FAILED
;
2558 /* Check if same listen range is already configured. */
2559 existing_group
= listen_range_exists(bgp
, &range
, 1);
2560 if (existing_group
) {
2561 if (strcmp(existing_group
->name
, peergroup
) == 0)
2565 "%% Same listen range is attached to peer-group %s\n",
2566 existing_group
->name
);
2567 return CMD_WARNING_CONFIG_FAILED
;
2571 /* Check if an overlapping listen range exists. */
2572 if (listen_range_exists(bgp
, &range
, 0)) {
2574 "%% Listen range overlaps with existing listen range\n");
2575 return CMD_WARNING_CONFIG_FAILED
;
2578 group
= peer_group_lookup(bgp
, peergroup
);
2580 vty_out(vty
, "%% Configure the peer-group first\n");
2581 return CMD_WARNING_CONFIG_FAILED
;
2584 ret
= peer_group_listen_range_add(group
, &range
);
2585 return bgp_vty_return(vty
, ret
);
2588 DEFUN (no_bgp_listen_range
,
2589 no_bgp_listen_range_cmd
,
2590 "no bgp listen range <A.B.C.D/M|X:X::X:X/M> peer-group WORD",
2592 "BGP specific commands\n"
2593 "Unconfigure BGP dynamic neighbors listen range\n"
2594 "Unconfigure BGP dynamic neighbors listen range\n"
2596 "Member of the peer-group\n"
2597 "Peer-group name\n")
2599 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2600 struct prefix range
;
2601 struct peer_group
*group
;
2606 argv_find(argv
, argc
, "A.B.C.D/M", &idx
);
2607 argv_find(argv
, argc
, "X:X::X:X/M", &idx
);
2608 char *prefix
= argv
[idx
]->arg
;
2609 argv_find(argv
, argc
, "WORD", &idx
);
2610 char *peergroup
= argv
[idx
]->arg
;
2612 /* Convert IP prefix string to struct prefix. */
2613 ret
= str2prefix(prefix
, &range
);
2615 vty_out(vty
, "%% Malformed listen range\n");
2616 return CMD_WARNING_CONFIG_FAILED
;
2619 afi
= family2afi(range
.family
);
2621 if (afi
== AFI_IP6
&& IN6_IS_ADDR_LINKLOCAL(&range
.u
.prefix6
)) {
2623 "%% Malformed listen range (link-local address)\n");
2624 return CMD_WARNING_CONFIG_FAILED
;
2629 group
= peer_group_lookup(bgp
, peergroup
);
2631 vty_out(vty
, "%% Peer-group does not exist\n");
2632 return CMD_WARNING_CONFIG_FAILED
;
2635 ret
= peer_group_listen_range_del(group
, &range
);
2636 return bgp_vty_return(vty
, ret
);
2639 void bgp_config_write_listen(struct vty
*vty
, struct bgp
*bgp
)
2641 struct peer_group
*group
;
2642 struct listnode
*node
, *nnode
, *rnode
, *nrnode
;
2643 struct prefix
*range
;
2645 char buf
[PREFIX2STR_BUFFER
];
2647 if (bgp
->dynamic_neighbors_limit
!= BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT
)
2648 vty_out(vty
, " bgp listen limit %d\n",
2649 bgp
->dynamic_neighbors_limit
);
2651 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
2652 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
2653 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], rnode
,
2655 prefix2str(range
, buf
, sizeof(buf
));
2657 " bgp listen range %s peer-group %s\n",
2665 DEFUN (bgp_disable_connected_route_check
,
2666 bgp_disable_connected_route_check_cmd
,
2667 "bgp disable-ebgp-connected-route-check",
2668 "BGP specific commands\n"
2669 "Disable checking if nexthop is connected on ebgp sessions\n")
2671 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2672 bgp_flag_set(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2673 bgp_clear_star_soft_in(vty
, bgp
->name
);
2678 DEFUN (no_bgp_disable_connected_route_check
,
2679 no_bgp_disable_connected_route_check_cmd
,
2680 "no bgp disable-ebgp-connected-route-check",
2682 "BGP specific commands\n"
2683 "Disable checking if nexthop is connected on ebgp sessions\n")
2685 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2686 bgp_flag_unset(bgp
, BGP_FLAG_DISABLE_NH_CONNECTED_CHK
);
2687 bgp_clear_star_soft_in(vty
, bgp
->name
);
2693 static int peer_remote_as_vty(struct vty
*vty
, const char *peer_str
,
2694 const char *as_str
, afi_t afi
, safi_t safi
)
2696 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2699 int as_type
= AS_SPECIFIED
;
2702 if (as_str
[0] == 'i') {
2704 as_type
= AS_INTERNAL
;
2705 } else if (as_str
[0] == 'e') {
2707 as_type
= AS_EXTERNAL
;
2709 /* Get AS number. */
2710 as
= strtoul(as_str
, NULL
, 10);
2713 /* If peer is peer group, call proper function. */
2714 ret
= str2sockunion(peer_str
, &su
);
2716 /* Check for peer by interface */
2717 ret
= peer_remote_as(bgp
, NULL
, peer_str
, &as
, as_type
, afi
,
2720 ret
= peer_group_remote_as(bgp
, peer_str
, &as
, as_type
);
2723 "%% Create the peer-group or interface first\n");
2724 return CMD_WARNING_CONFIG_FAILED
;
2729 if (peer_address_self_check(bgp
, &su
)) {
2731 "%% Can not configure the local system as neighbor\n");
2732 return CMD_WARNING_CONFIG_FAILED
;
2734 ret
= peer_remote_as(bgp
, &su
, NULL
, &as
, as_type
, afi
, safi
);
2737 /* This peer belongs to peer group. */
2739 case BGP_ERR_PEER_GROUP_MEMBER
:
2741 "%% Peer-group AS %u. Cannot configure remote-as for member\n",
2743 return CMD_WARNING_CONFIG_FAILED
;
2744 case BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
:
2746 "%% The AS# can not be changed from %u to %s, peer-group members must be all internal or all external\n",
2748 return CMD_WARNING_CONFIG_FAILED
;
2750 return bgp_vty_return(vty
, ret
);
2753 DEFUN (bgp_default_shutdown
,
2754 bgp_default_shutdown_cmd
,
2755 "[no] bgp default shutdown",
2758 "Configure BGP defaults\n"
2759 "Apply administrative shutdown to newly configured peers\n")
2761 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2762 bgp
->autoshutdown
= !strmatch(argv
[0]->text
, "no");
2766 DEFUN (neighbor_remote_as
,
2767 neighbor_remote_as_cmd
,
2768 "neighbor <A.B.C.D|X:X::X:X|WORD> remote-as <(1-4294967295)|internal|external>",
2771 "Specify a BGP neighbor\n"
2773 "Internal BGP peer\n"
2774 "External BGP peer\n")
2777 int idx_remote_as
= 3;
2778 return peer_remote_as_vty(vty
, argv
[idx_peer
]->arg
,
2779 argv
[idx_remote_as
]->arg
, AFI_IP
,
2783 static int peer_conf_interface_get(struct vty
*vty
, const char *conf_if
,
2784 afi_t afi
, safi_t safi
, int v6only
,
2785 const char *peer_group_name
,
2788 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2790 int as_type
= AS_UNSPECIFIED
;
2792 struct peer_group
*group
;
2796 group
= peer_group_lookup(bgp
, conf_if
);
2799 vty_out(vty
, "%% Name conflict with peer-group \n");
2800 return CMD_WARNING_CONFIG_FAILED
;
2804 if (as_str
[0] == 'i') {
2805 as_type
= AS_INTERNAL
;
2806 } else if (as_str
[0] == 'e') {
2807 as_type
= AS_EXTERNAL
;
2809 /* Get AS number. */
2810 as
= strtoul(as_str
, NULL
, 10);
2811 as_type
= AS_SPECIFIED
;
2815 peer
= peer_lookup_by_conf_if(bgp
, conf_if
);
2818 ret
= peer_remote_as(bgp
, &su
, conf_if
, &as
, as_type
,
2821 if (bgp_flag_check(bgp
, BGP_FLAG_NO_DEFAULT_IPV4
)
2822 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2823 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2824 as_type
, 0, 0, NULL
);
2826 peer
= peer_create(NULL
, conf_if
, bgp
, bgp
->as
, as
,
2827 as_type
, afi
, safi
, NULL
);
2830 vty_out(vty
, "%% BGP failed to create peer\n");
2831 return CMD_WARNING_CONFIG_FAILED
;
2835 SET_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
);
2837 /* Request zebra to initiate IPv6 RAs on this interface. We do
2839 * any unnumbered peer in order to not worry about run-time
2841 * (e.g., peering is initially IPv4, but the IPv4 /30 or /31
2843 * gets deleted later etc.)
2846 bgp_zebra_initiate_radv(bgp
, peer
);
2849 if ((v6only
&& !CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))
2850 || (!v6only
&& CHECK_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
))) {
2852 SET_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
);
2854 UNSET_FLAG(peer
->flags
, PEER_FLAG_IFPEER_V6ONLY
);
2856 /* v6only flag changed. Reset bgp seesion */
2857 if (BGP_IS_VALID_STATE_FOR_NOTIF(peer
->status
)) {
2858 peer
->last_reset
= PEER_DOWN_V6ONLY_CHANGE
;
2859 bgp_notify_send(peer
, BGP_NOTIFY_CEASE
,
2860 BGP_NOTIFY_CEASE_CONFIG_CHANGE
);
2862 bgp_session_reset(peer
);
2865 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CAPABILITY_ENHE
))
2866 peer_flag_set(peer
, PEER_FLAG_CAPABILITY_ENHE
);
2868 if (peer_group_name
) {
2869 group
= peer_group_lookup(bgp
, peer_group_name
);
2871 vty_out(vty
, "%% Configure the peer-group first\n");
2872 return CMD_WARNING_CONFIG_FAILED
;
2875 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
2878 return bgp_vty_return(vty
, ret
);
2881 DEFUN (neighbor_interface_config
,
2882 neighbor_interface_config_cmd
,
2883 "neighbor WORD interface [peer-group WORD]",
2885 "Interface name or neighbor tag\n"
2886 "Enable BGP on interface\n"
2887 "Member of the peer-group\n"
2888 "Peer-group name\n")
2891 int idx_peer_group_word
= 4;
2893 if (argc
> idx_peer_group_word
)
2894 return peer_conf_interface_get(
2895 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 0,
2896 argv
[idx_peer_group_word
]->arg
, NULL
);
2898 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2899 SAFI_UNICAST
, 0, NULL
, NULL
);
2902 DEFUN (neighbor_interface_config_v6only
,
2903 neighbor_interface_config_v6only_cmd
,
2904 "neighbor WORD interface v6only [peer-group WORD]",
2906 "Interface name or neighbor tag\n"
2907 "Enable BGP on interface\n"
2908 "Enable BGP with v6 link-local only\n"
2909 "Member of the peer-group\n"
2910 "Peer-group name\n")
2913 int idx_peer_group_word
= 5;
2915 if (argc
> idx_peer_group_word
)
2916 return peer_conf_interface_get(
2917 vty
, argv
[idx_word
]->arg
, AFI_IP
, SAFI_UNICAST
, 1,
2918 argv
[idx_peer_group_word
]->arg
, NULL
);
2920 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2921 SAFI_UNICAST
, 1, NULL
, NULL
);
2925 DEFUN (neighbor_interface_config_remote_as
,
2926 neighbor_interface_config_remote_as_cmd
,
2927 "neighbor WORD interface remote-as <(1-4294967295)|internal|external>",
2929 "Interface name or neighbor tag\n"
2930 "Enable BGP on interface\n"
2931 "Specify a BGP neighbor\n"
2933 "Internal BGP peer\n"
2934 "External BGP peer\n")
2937 int idx_remote_as
= 4;
2938 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2939 SAFI_UNICAST
, 0, NULL
,
2940 argv
[idx_remote_as
]->arg
);
2943 DEFUN (neighbor_interface_v6only_config_remote_as
,
2944 neighbor_interface_v6only_config_remote_as_cmd
,
2945 "neighbor WORD interface v6only remote-as <(1-4294967295)|internal|external>",
2947 "Interface name or neighbor tag\n"
2948 "Enable BGP with v6 link-local only\n"
2949 "Enable BGP on interface\n"
2950 "Specify a BGP neighbor\n"
2952 "Internal BGP peer\n"
2953 "External BGP peer\n")
2956 int idx_remote_as
= 5;
2957 return peer_conf_interface_get(vty
, argv
[idx_word
]->arg
, AFI_IP
,
2958 SAFI_UNICAST
, 1, NULL
,
2959 argv
[idx_remote_as
]->arg
);
2962 DEFUN (neighbor_peer_group
,
2963 neighbor_peer_group_cmd
,
2964 "neighbor WORD peer-group",
2966 "Interface name or neighbor tag\n"
2967 "Configure peer-group\n")
2969 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
2972 struct peer_group
*group
;
2974 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
2976 vty_out(vty
, "%% Name conflict with interface: \n");
2977 return CMD_WARNING_CONFIG_FAILED
;
2980 group
= peer_group_get(bgp
, argv
[idx_word
]->arg
);
2982 vty_out(vty
, "%% BGP failed to find or create peer-group\n");
2983 return CMD_WARNING_CONFIG_FAILED
;
2991 "no neighbor <WORD|<A.B.C.D|X:X::X:X> [remote-as <(1-4294967295)|internal|external>]>",
2995 "Specify a BGP neighbor\n"
2997 "Internal BGP peer\n"
2998 "External BGP peer\n")
3000 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3004 struct peer_group
*group
;
3008 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3010 /* look up for neighbor by interface name config. */
3011 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3013 /* Request zebra to terminate IPv6 RAs on this
3016 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3021 group
= peer_group_lookup(bgp
, argv
[idx_peer
]->arg
);
3023 peer_group_delete(group
);
3025 vty_out(vty
, "%% Create the peer-group first\n");
3026 return CMD_WARNING_CONFIG_FAILED
;
3029 peer
= peer_lookup(bgp
, &su
);
3031 if (peer_dynamic_neighbor(peer
)) {
3033 "%% Operation not allowed on a dynamic neighbor\n");
3034 return CMD_WARNING_CONFIG_FAILED
;
3037 other
= peer
->doppelganger
;
3039 if (other
&& other
->status
!= Deleted
)
3047 DEFUN (no_neighbor_interface_config
,
3048 no_neighbor_interface_config_cmd
,
3049 "no neighbor WORD interface [v6only] [peer-group WORD] [remote-as <(1-4294967295)|internal|external>]",
3053 "Configure BGP on interface\n"
3054 "Enable BGP with v6 link-local only\n"
3055 "Member of the peer-group\n"
3057 "Specify a BGP neighbor\n"
3059 "Internal BGP peer\n"
3060 "External BGP peer\n")
3062 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3066 /* look up for neighbor by interface name config. */
3067 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3069 /* Request zebra to terminate IPv6 RAs on this interface. */
3071 bgp_zebra_terminate_radv(peer
->bgp
, peer
);
3074 vty_out(vty
, "%% Create the bgp interface first\n");
3075 return CMD_WARNING_CONFIG_FAILED
;
3080 DEFUN (no_neighbor_peer_group
,
3081 no_neighbor_peer_group_cmd
,
3082 "no neighbor WORD peer-group",
3086 "Configure peer-group\n")
3088 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3090 struct peer_group
*group
;
3092 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3094 peer_group_delete(group
);
3096 vty_out(vty
, "%% Create the peer-group first\n");
3097 return CMD_WARNING_CONFIG_FAILED
;
3102 DEFUN (no_neighbor_interface_peer_group_remote_as
,
3103 no_neighbor_interface_peer_group_remote_as_cmd
,
3104 "no neighbor WORD remote-as <(1-4294967295)|internal|external>",
3107 "Interface name or neighbor tag\n"
3108 "Specify a BGP neighbor\n"
3110 "Internal BGP peer\n"
3111 "External BGP peer\n")
3113 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3115 struct peer_group
*group
;
3118 /* look up for neighbor by interface name config. */
3119 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_word
]->arg
);
3121 peer_as_change(peer
, 0, AS_SPECIFIED
);
3125 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3127 peer_group_remote_as_delete(group
);
3129 vty_out(vty
, "%% Create the peer-group or interface first\n");
3130 return CMD_WARNING_CONFIG_FAILED
;
3135 DEFUN (neighbor_local_as
,
3136 neighbor_local_as_cmd
,
3137 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295)",
3140 "Specify a local-as number\n"
3141 "AS number used as local AS\n")
3149 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3151 return CMD_WARNING_CONFIG_FAILED
;
3153 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3154 ret
= peer_local_as_set(peer
, as
, 0, 0);
3155 return bgp_vty_return(vty
, ret
);
3158 DEFUN (neighbor_local_as_no_prepend
,
3159 neighbor_local_as_no_prepend_cmd
,
3160 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend",
3163 "Specify a local-as number\n"
3164 "AS number used as local AS\n"
3165 "Do not prepend local-as to updates from ebgp peers\n")
3173 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3175 return CMD_WARNING_CONFIG_FAILED
;
3177 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3178 ret
= peer_local_as_set(peer
, as
, 1, 0);
3179 return bgp_vty_return(vty
, ret
);
3182 DEFUN (neighbor_local_as_no_prepend_replace_as
,
3183 neighbor_local_as_no_prepend_replace_as_cmd
,
3184 "neighbor <A.B.C.D|X:X::X:X|WORD> local-as (1-4294967295) no-prepend replace-as",
3187 "Specify a local-as number\n"
3188 "AS number used as local AS\n"
3189 "Do not prepend local-as to updates from ebgp peers\n"
3190 "Do not prepend local-as to updates from ibgp peers\n")
3198 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3200 return CMD_WARNING_CONFIG_FAILED
;
3202 as
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
3203 ret
= peer_local_as_set(peer
, as
, 1, 1);
3204 return bgp_vty_return(vty
, ret
);
3207 DEFUN (no_neighbor_local_as
,
3208 no_neighbor_local_as_cmd
,
3209 "no neighbor <A.B.C.D|X:X::X:X|WORD> local-as [(1-4294967295) [no-prepend [replace-as]]]",
3213 "Specify a local-as number\n"
3214 "AS number used as local AS\n"
3215 "Do not prepend local-as to updates from ebgp peers\n"
3216 "Do not prepend local-as to updates from ibgp peers\n")
3222 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3224 return CMD_WARNING_CONFIG_FAILED
;
3226 ret
= peer_local_as_unset(peer
);
3227 return bgp_vty_return(vty
, ret
);
3231 DEFUN (neighbor_solo
,
3233 "neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3236 "Solo peer - part of its own update group\n")
3242 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3244 return CMD_WARNING_CONFIG_FAILED
;
3246 ret
= update_group_adjust_soloness(peer
, 1);
3247 return bgp_vty_return(vty
, ret
);
3250 DEFUN (no_neighbor_solo
,
3251 no_neighbor_solo_cmd
,
3252 "no neighbor <A.B.C.D|X:X::X:X|WORD> solo",
3256 "Solo peer - part of its own update group\n")
3262 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3264 return CMD_WARNING_CONFIG_FAILED
;
3266 ret
= update_group_adjust_soloness(peer
, 0);
3267 return bgp_vty_return(vty
, ret
);
3270 DEFUN (neighbor_password
,
3271 neighbor_password_cmd
,
3272 "neighbor <A.B.C.D|X:X::X:X|WORD> password LINE",
3283 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3285 return CMD_WARNING_CONFIG_FAILED
;
3287 ret
= peer_password_set(peer
, argv
[idx_line
]->arg
);
3288 return bgp_vty_return(vty
, ret
);
3291 DEFUN (no_neighbor_password
,
3292 no_neighbor_password_cmd
,
3293 "no neighbor <A.B.C.D|X:X::X:X|WORD> password [LINE]",
3304 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3306 return CMD_WARNING_CONFIG_FAILED
;
3308 ret
= peer_password_unset(peer
);
3309 return bgp_vty_return(vty
, ret
);
3312 DEFUN (neighbor_activate
,
3313 neighbor_activate_cmd
,
3314 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3317 "Enable the Address Family for this Neighbor\n")
3323 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3325 return CMD_WARNING_CONFIG_FAILED
;
3327 ret
= peer_activate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3328 return bgp_vty_return(vty
, ret
);
3331 ALIAS_HIDDEN(neighbor_activate
, neighbor_activate_hidden_cmd
,
3332 "neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3333 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3334 "Enable the Address Family for this Neighbor\n")
3336 DEFUN (no_neighbor_activate
,
3337 no_neighbor_activate_cmd
,
3338 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3342 "Enable the Address Family for this Neighbor\n")
3349 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3351 return CMD_WARNING_CONFIG_FAILED
;
3353 ret
= peer_deactivate(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
));
3354 return bgp_vty_return(vty
, ret
);
3357 ALIAS_HIDDEN(no_neighbor_activate
, no_neighbor_activate_hidden_cmd
,
3358 "no neighbor <A.B.C.D|X:X::X:X|WORD> activate",
3359 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3360 "Enable the Address Family for this Neighbor\n")
3362 DEFUN (neighbor_set_peer_group
,
3363 neighbor_set_peer_group_cmd
,
3364 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3367 "Member of the peer-group\n"
3368 "Peer-group name\n")
3370 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3377 struct peer_group
*group
;
3381 ret
= str2sockunion(argv
[idx_peer
]->arg
, &su
);
3383 peer
= peer_lookup_by_conf_if(bgp
, argv
[idx_peer
]->arg
);
3385 vty_out(vty
, "%% Malformed address or name: %s\n",
3386 argv
[idx_peer
]->arg
);
3387 return CMD_WARNING_CONFIG_FAILED
;
3390 if (peer_address_self_check(bgp
, &su
)) {
3392 "%% Can not configure the local system as neighbor\n");
3393 return CMD_WARNING_CONFIG_FAILED
;
3396 /* Disallow for dynamic neighbor. */
3397 peer
= peer_lookup(bgp
, &su
);
3398 if (peer
&& peer_dynamic_neighbor(peer
)) {
3400 "%% Operation not allowed on a dynamic neighbor\n");
3401 return CMD_WARNING_CONFIG_FAILED
;
3405 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3407 vty_out(vty
, "%% Configure the peer-group first\n");
3408 return CMD_WARNING_CONFIG_FAILED
;
3411 ret
= peer_group_bind(bgp
, &su
, peer
, group
, &as
);
3413 if (ret
== BGP_ERR_PEER_GROUP_PEER_TYPE_DIFFERENT
) {
3415 "%% Peer with AS %u cannot be in this peer-group, members must be all internal or all external\n",
3417 return CMD_WARNING_CONFIG_FAILED
;
3420 return bgp_vty_return(vty
, ret
);
3423 ALIAS_HIDDEN(neighbor_set_peer_group
, neighbor_set_peer_group_hidden_cmd
,
3424 "neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3425 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3426 "Member of the peer-group\n"
3427 "Peer-group name\n")
3429 DEFUN (no_neighbor_set_peer_group
,
3430 no_neighbor_set_peer_group_cmd
,
3431 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3435 "Member of the peer-group\n"
3436 "Peer-group name\n")
3438 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
3443 struct peer_group
*group
;
3445 peer
= peer_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3447 return CMD_WARNING_CONFIG_FAILED
;
3449 group
= peer_group_lookup(bgp
, argv
[idx_word
]->arg
);
3451 vty_out(vty
, "%% Configure the peer-group first\n");
3452 return CMD_WARNING_CONFIG_FAILED
;
3455 ret
= peer_delete(peer
);
3457 return bgp_vty_return(vty
, ret
);
3460 ALIAS_HIDDEN(no_neighbor_set_peer_group
, no_neighbor_set_peer_group_hidden_cmd
,
3461 "no neighbor <A.B.C.D|X:X::X:X|WORD> peer-group WORD",
3462 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3463 "Member of the peer-group\n"
3464 "Peer-group name\n")
3466 static int peer_flag_modify_vty(struct vty
*vty
, const char *ip_str
,
3467 uint32_t flag
, int set
)
3472 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
3474 return CMD_WARNING_CONFIG_FAILED
;
3477 * If 'neighbor <interface>', then this is for directly connected peers,
3478 * we should not accept disable-connected-check.
3480 if (peer
->conf_if
&& (flag
== PEER_FLAG_DISABLE_CONNECTED_CHECK
)) {
3482 "%s is directly connected peer, cannot accept disable-"
3483 "connected-check\n",
3485 return CMD_WARNING_CONFIG_FAILED
;
3488 if (!set
&& flag
== PEER_FLAG_SHUTDOWN
)
3489 peer_tx_shutdown_message_unset(peer
);
3492 ret
= peer_flag_set(peer
, flag
);
3494 ret
= peer_flag_unset(peer
, flag
);
3496 return bgp_vty_return(vty
, ret
);
3499 static int peer_flag_set_vty(struct vty
*vty
, const char *ip_str
, uint32_t flag
)
3501 return peer_flag_modify_vty(vty
, ip_str
, flag
, 1);
3504 static int peer_flag_unset_vty(struct vty
*vty
, const char *ip_str
,
3507 return peer_flag_modify_vty(vty
, ip_str
, flag
, 0);
3510 /* neighbor passive. */
3511 DEFUN (neighbor_passive
,
3512 neighbor_passive_cmd
,
3513 "neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3516 "Don't send open messages to this neighbor\n")
3519 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3522 DEFUN (no_neighbor_passive
,
3523 no_neighbor_passive_cmd
,
3524 "no neighbor <A.B.C.D|X:X::X:X|WORD> passive",
3528 "Don't send open messages to this neighbor\n")
3531 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_PASSIVE
);
3534 /* neighbor shutdown. */
3535 DEFUN (neighbor_shutdown_msg
,
3536 neighbor_shutdown_msg_cmd
,
3537 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3540 "Administratively shut down this neighbor\n"
3541 "Add a shutdown message (draft-ietf-idr-shutdown-06)\n"
3542 "Shutdown message\n")
3548 peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
3552 return CMD_WARNING_CONFIG_FAILED
;
3553 message
= argv_concat(argv
, argc
, 4);
3554 peer_tx_shutdown_message_set(peer
, message
);
3555 XFREE(MTYPE_TMP
, message
);
3558 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
, PEER_FLAG_SHUTDOWN
);
3561 ALIAS(neighbor_shutdown_msg
, neighbor_shutdown_cmd
,
3562 "neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3563 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3564 "Administratively shut down this neighbor\n")
3566 DEFUN (no_neighbor_shutdown_msg
,
3567 no_neighbor_shutdown_msg_cmd
,
3568 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown message MSG...",
3572 "Administratively shut down this neighbor\n"
3573 "Remove a shutdown message (draft-ietf-idr-shutdown-06)\n"
3574 "Shutdown message\n")
3578 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3579 PEER_FLAG_SHUTDOWN
);
3582 ALIAS(no_neighbor_shutdown_msg
, no_neighbor_shutdown_cmd
,
3583 "no neighbor <A.B.C.D|X:X::X:X|WORD> shutdown",
3584 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3585 "Administratively shut down this neighbor\n")
3587 /* neighbor capability dynamic. */
3588 DEFUN (neighbor_capability_dynamic
,
3589 neighbor_capability_dynamic_cmd
,
3590 "neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3593 "Advertise capability to the peer\n"
3594 "Advertise dynamic capability to this neighbor\n")
3597 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3598 PEER_FLAG_DYNAMIC_CAPABILITY
);
3601 DEFUN (no_neighbor_capability_dynamic
,
3602 no_neighbor_capability_dynamic_cmd
,
3603 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability dynamic",
3607 "Advertise capability to the peer\n"
3608 "Advertise dynamic capability to this neighbor\n")
3611 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3612 PEER_FLAG_DYNAMIC_CAPABILITY
);
3615 /* neighbor dont-capability-negotiate */
3616 DEFUN (neighbor_dont_capability_negotiate
,
3617 neighbor_dont_capability_negotiate_cmd
,
3618 "neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3621 "Do not perform capability negotiation\n")
3624 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3625 PEER_FLAG_DONT_CAPABILITY
);
3628 DEFUN (no_neighbor_dont_capability_negotiate
,
3629 no_neighbor_dont_capability_negotiate_cmd
,
3630 "no neighbor <A.B.C.D|X:X::X:X|WORD> dont-capability-negotiate",
3634 "Do not perform capability negotiation\n")
3637 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3638 PEER_FLAG_DONT_CAPABILITY
);
3641 /* neighbor capability extended next hop encoding */
3642 DEFUN (neighbor_capability_enhe
,
3643 neighbor_capability_enhe_cmd
,
3644 "neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3647 "Advertise capability to the peer\n"
3648 "Advertise extended next-hop capability to the peer\n")
3651 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
3652 PEER_FLAG_CAPABILITY_ENHE
);
3655 DEFUN (no_neighbor_capability_enhe
,
3656 no_neighbor_capability_enhe_cmd
,
3657 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability extended-nexthop",
3661 "Advertise capability to the peer\n"
3662 "Advertise extended next-hop capability to the peer\n")
3665 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3666 PEER_FLAG_CAPABILITY_ENHE
);
3669 static int peer_af_flag_modify_vty(struct vty
*vty
, const char *peer_str
,
3670 afi_t afi
, safi_t safi
, uint32_t flag
,
3676 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
3678 return CMD_WARNING_CONFIG_FAILED
;
3681 ret
= peer_af_flag_set(peer
, afi
, safi
, flag
);
3683 ret
= peer_af_flag_unset(peer
, afi
, safi
, flag
);
3685 return bgp_vty_return(vty
, ret
);
3688 static int peer_af_flag_set_vty(struct vty
*vty
, const char *peer_str
,
3689 afi_t afi
, safi_t safi
, uint32_t flag
)
3691 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 1);
3694 static int peer_af_flag_unset_vty(struct vty
*vty
, const char *peer_str
,
3695 afi_t afi
, safi_t safi
, uint32_t flag
)
3697 return peer_af_flag_modify_vty(vty
, peer_str
, afi
, safi
, flag
, 0);
3700 /* neighbor capability orf prefix-list. */
3701 DEFUN (neighbor_capability_orf_prefix
,
3702 neighbor_capability_orf_prefix_cmd
,
3703 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3706 "Advertise capability to the peer\n"
3707 "Advertise ORF capability to the peer\n"
3708 "Advertise prefixlist ORF capability to this neighbor\n"
3709 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3710 "Capability to RECEIVE the ORF from this neighbor\n"
3711 "Capability to SEND the ORF to this neighbor\n")
3714 int idx_send_recv
= 5;
3717 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3718 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3719 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3720 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3721 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3722 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3724 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3725 return CMD_WARNING_CONFIG_FAILED
;
3728 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3729 bgp_node_safi(vty
), flag
);
3733 neighbor_capability_orf_prefix
,
3734 neighbor_capability_orf_prefix_hidden_cmd
,
3735 "neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3736 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3737 "Advertise capability to the peer\n"
3738 "Advertise ORF capability to the peer\n"
3739 "Advertise prefixlist ORF capability to this neighbor\n"
3740 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3741 "Capability to RECEIVE the ORF from this neighbor\n"
3742 "Capability to SEND the ORF to this neighbor\n")
3744 DEFUN (no_neighbor_capability_orf_prefix
,
3745 no_neighbor_capability_orf_prefix_cmd
,
3746 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3750 "Advertise capability to the peer\n"
3751 "Advertise ORF capability to the peer\n"
3752 "Advertise prefixlist ORF capability to this neighbor\n"
3753 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3754 "Capability to RECEIVE the ORF from this neighbor\n"
3755 "Capability to SEND the ORF to this neighbor\n")
3758 int idx_send_recv
= 6;
3761 if (strmatch(argv
[idx_send_recv
]->text
, "send"))
3762 flag
= PEER_FLAG_ORF_PREFIX_SM
;
3763 else if (strmatch(argv
[idx_send_recv
]->text
, "receive"))
3764 flag
= PEER_FLAG_ORF_PREFIX_RM
;
3765 else if (strmatch(argv
[idx_send_recv
]->text
, "both"))
3766 flag
= PEER_FLAG_ORF_PREFIX_SM
| PEER_FLAG_ORF_PREFIX_RM
;
3768 vty_out(vty
, "%% BGP invalid orf prefix-list option\n");
3769 return CMD_WARNING_CONFIG_FAILED
;
3772 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3773 bgp_node_afi(vty
), bgp_node_safi(vty
),
3778 no_neighbor_capability_orf_prefix
,
3779 no_neighbor_capability_orf_prefix_hidden_cmd
,
3780 "no neighbor <A.B.C.D|X:X::X:X|WORD> capability orf prefix-list <both|send|receive>",
3781 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3782 "Advertise capability to the peer\n"
3783 "Advertise ORF capability to the peer\n"
3784 "Advertise prefixlist ORF capability to this neighbor\n"
3785 "Capability to SEND and RECEIVE the ORF to/from this neighbor\n"
3786 "Capability to RECEIVE the ORF from this neighbor\n"
3787 "Capability to SEND the ORF to this neighbor\n")
3789 /* neighbor next-hop-self. */
3790 DEFUN (neighbor_nexthop_self
,
3791 neighbor_nexthop_self_cmd
,
3792 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3795 "Disable the next hop calculation for this neighbor\n")
3798 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3799 bgp_node_safi(vty
), PEER_FLAG_NEXTHOP_SELF
);
3802 ALIAS_HIDDEN(neighbor_nexthop_self
, neighbor_nexthop_self_hidden_cmd
,
3803 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3804 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3805 "Disable the next hop calculation for this neighbor\n")
3807 /* neighbor next-hop-self. */
3808 DEFUN (neighbor_nexthop_self_force
,
3809 neighbor_nexthop_self_force_cmd
,
3810 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3813 "Disable the next hop calculation for this neighbor\n"
3814 "Set the next hop to self for reflected routes\n")
3817 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3819 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3822 ALIAS_HIDDEN(neighbor_nexthop_self_force
,
3823 neighbor_nexthop_self_force_hidden_cmd
,
3824 "neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3825 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3826 "Disable the next hop calculation for this neighbor\n"
3827 "Set the next hop to self for reflected routes\n")
3829 DEFUN (no_neighbor_nexthop_self
,
3830 no_neighbor_nexthop_self_cmd
,
3831 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3835 "Disable the next hop calculation for this neighbor\n")
3838 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3839 bgp_node_afi(vty
), bgp_node_safi(vty
),
3840 PEER_FLAG_NEXTHOP_SELF
);
3843 ALIAS_HIDDEN(no_neighbor_nexthop_self
, no_neighbor_nexthop_self_hidden_cmd
,
3844 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self",
3845 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3846 "Disable the next hop calculation for this neighbor\n")
3848 DEFUN (no_neighbor_nexthop_self_force
,
3849 no_neighbor_nexthop_self_force_cmd
,
3850 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3854 "Disable the next hop calculation for this neighbor\n"
3855 "Set the next hop to self for reflected routes\n")
3858 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3859 bgp_node_afi(vty
), bgp_node_safi(vty
),
3860 PEER_FLAG_FORCE_NEXTHOP_SELF
);
3863 ALIAS_HIDDEN(no_neighbor_nexthop_self_force
,
3864 no_neighbor_nexthop_self_force_hidden_cmd
,
3865 "no neighbor <A.B.C.D|X:X::X:X|WORD> next-hop-self force",
3866 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3867 "Disable the next hop calculation for this neighbor\n"
3868 "Set the next hop to self for reflected routes\n")
3870 /* neighbor as-override */
3871 DEFUN (neighbor_as_override
,
3872 neighbor_as_override_cmd
,
3873 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3876 "Override ASNs in outbound updates if aspath equals remote-as\n")
3879 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3880 bgp_node_safi(vty
), PEER_FLAG_AS_OVERRIDE
);
3883 ALIAS_HIDDEN(neighbor_as_override
, neighbor_as_override_hidden_cmd
,
3884 "neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3885 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3886 "Override ASNs in outbound updates if aspath equals remote-as\n")
3888 DEFUN (no_neighbor_as_override
,
3889 no_neighbor_as_override_cmd
,
3890 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3894 "Override ASNs in outbound updates if aspath equals remote-as\n")
3897 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
3898 bgp_node_afi(vty
), bgp_node_safi(vty
),
3899 PEER_FLAG_AS_OVERRIDE
);
3902 ALIAS_HIDDEN(no_neighbor_as_override
, no_neighbor_as_override_hidden_cmd
,
3903 "no neighbor <A.B.C.D|X:X::X:X|WORD> as-override",
3904 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3905 "Override ASNs in outbound updates if aspath equals remote-as\n")
3907 /* neighbor remove-private-AS. */
3908 DEFUN (neighbor_remove_private_as
,
3909 neighbor_remove_private_as_cmd
,
3910 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3913 "Remove private ASNs in outbound updates\n")
3916 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3918 PEER_FLAG_REMOVE_PRIVATE_AS
);
3921 ALIAS_HIDDEN(neighbor_remove_private_as
, neighbor_remove_private_as_hidden_cmd
,
3922 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3923 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3924 "Remove private ASNs in outbound updates\n")
3926 DEFUN (neighbor_remove_private_as_all
,
3927 neighbor_remove_private_as_all_cmd
,
3928 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3931 "Remove private ASNs in outbound updates\n"
3932 "Apply to all AS numbers\n")
3935 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3937 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
3940 ALIAS_HIDDEN(neighbor_remove_private_as_all
,
3941 neighbor_remove_private_as_all_hidden_cmd
,
3942 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
3943 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3944 "Remove private ASNs in outbound updates\n"
3945 "Apply to all AS numbers")
3947 DEFUN (neighbor_remove_private_as_replace_as
,
3948 neighbor_remove_private_as_replace_as_cmd
,
3949 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3952 "Remove private ASNs in outbound updates\n"
3953 "Replace private ASNs with our ASN in outbound updates\n")
3956 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3958 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
3961 ALIAS_HIDDEN(neighbor_remove_private_as_replace_as
,
3962 neighbor_remove_private_as_replace_as_hidden_cmd
,
3963 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
3964 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3965 "Remove private ASNs in outbound updates\n"
3966 "Replace private ASNs with our ASN in outbound updates\n")
3968 DEFUN (neighbor_remove_private_as_all_replace_as
,
3969 neighbor_remove_private_as_all_replace_as_cmd
,
3970 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3973 "Remove private ASNs in outbound updates\n"
3974 "Apply to all AS numbers\n"
3975 "Replace private ASNs with our ASN in outbound updates\n")
3978 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
3980 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
3984 neighbor_remove_private_as_all_replace_as
,
3985 neighbor_remove_private_as_all_replace_as_hidden_cmd
,
3986 "neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
3987 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
3988 "Remove private ASNs in outbound updates\n"
3989 "Apply to all AS numbers\n"
3990 "Replace private ASNs with our ASN in outbound updates\n")
3992 DEFUN (no_neighbor_remove_private_as
,
3993 no_neighbor_remove_private_as_cmd
,
3994 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
3998 "Remove private ASNs in outbound updates\n")
4001 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4002 bgp_node_afi(vty
), bgp_node_safi(vty
),
4003 PEER_FLAG_REMOVE_PRIVATE_AS
);
4006 ALIAS_HIDDEN(no_neighbor_remove_private_as
,
4007 no_neighbor_remove_private_as_hidden_cmd
,
4008 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS",
4009 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4010 "Remove private ASNs in outbound updates\n")
4012 DEFUN (no_neighbor_remove_private_as_all
,
4013 no_neighbor_remove_private_as_all_cmd
,
4014 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4018 "Remove private ASNs in outbound updates\n"
4019 "Apply to all AS numbers\n")
4022 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4023 bgp_node_afi(vty
), bgp_node_safi(vty
),
4024 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
);
4027 ALIAS_HIDDEN(no_neighbor_remove_private_as_all
,
4028 no_neighbor_remove_private_as_all_hidden_cmd
,
4029 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all",
4030 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4031 "Remove private ASNs in outbound updates\n"
4032 "Apply to all AS numbers\n")
4034 DEFUN (no_neighbor_remove_private_as_replace_as
,
4035 no_neighbor_remove_private_as_replace_as_cmd
,
4036 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4040 "Remove private ASNs in outbound updates\n"
4041 "Replace private ASNs with our ASN in outbound updates\n")
4044 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4045 bgp_node_afi(vty
), bgp_node_safi(vty
),
4046 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
);
4049 ALIAS_HIDDEN(no_neighbor_remove_private_as_replace_as
,
4050 no_neighbor_remove_private_as_replace_as_hidden_cmd
,
4051 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS replace-AS",
4052 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4053 "Remove private ASNs in outbound updates\n"
4054 "Replace private ASNs with our ASN in outbound updates\n")
4056 DEFUN (no_neighbor_remove_private_as_all_replace_as
,
4057 no_neighbor_remove_private_as_all_replace_as_cmd
,
4058 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4062 "Remove private ASNs in outbound updates\n"
4063 "Apply to all AS numbers\n"
4064 "Replace private ASNs with our ASN in outbound updates\n")
4067 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4068 bgp_node_afi(vty
), bgp_node_safi(vty
),
4069 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
);
4073 no_neighbor_remove_private_as_all_replace_as
,
4074 no_neighbor_remove_private_as_all_replace_as_hidden_cmd
,
4075 "no neighbor <A.B.C.D|X:X::X:X|WORD> remove-private-AS all replace-AS",
4076 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4077 "Remove private ASNs in outbound updates\n"
4078 "Apply to all AS numbers\n"
4079 "Replace private ASNs with our ASN in outbound updates\n")
4082 /* neighbor send-community. */
4083 DEFUN (neighbor_send_community
,
4084 neighbor_send_community_cmd
,
4085 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4088 "Send Community attribute to this neighbor\n")
4092 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4094 PEER_FLAG_SEND_COMMUNITY
);
4097 ALIAS_HIDDEN(neighbor_send_community
, neighbor_send_community_hidden_cmd
,
4098 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4099 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4100 "Send Community attribute to this neighbor\n")
4102 DEFUN (no_neighbor_send_community
,
4103 no_neighbor_send_community_cmd
,
4104 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4108 "Send Community attribute to this neighbor\n")
4112 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4113 bgp_node_afi(vty
), bgp_node_safi(vty
),
4114 PEER_FLAG_SEND_COMMUNITY
);
4117 ALIAS_HIDDEN(no_neighbor_send_community
, no_neighbor_send_community_hidden_cmd
,
4118 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community",
4119 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4120 "Send Community attribute to this neighbor\n")
4122 /* neighbor send-community extended. */
4123 DEFUN (neighbor_send_community_type
,
4124 neighbor_send_community_type_cmd
,
4125 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4128 "Send Community attribute to this neighbor\n"
4129 "Send Standard and Extended Community attributes\n"
4130 "Send Standard, Large and Extended Community attributes\n"
4131 "Send Extended Community attributes\n"
4132 "Send Standard Community attributes\n"
4133 "Send Large Community attributes\n")
4137 const char *type
= argv
[argc
- 1]->text
;
4139 if (strmatch(type
, "standard")) {
4140 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4141 } else if (strmatch(type
, "extended")) {
4142 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4143 } else if (strmatch(type
, "large")) {
4144 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4145 } else if (strmatch(type
, "both")) {
4146 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4147 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4148 } else { /* if (strmatch(type, "all")) */
4149 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4150 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4151 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4154 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4155 bgp_node_safi(vty
), flag
);
4159 neighbor_send_community_type
, neighbor_send_community_type_hidden_cmd
,
4160 "neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4161 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4162 "Send Community attribute to this neighbor\n"
4163 "Send Standard and Extended Community attributes\n"
4164 "Send Standard, Large and Extended Community attributes\n"
4165 "Send Extended Community attributes\n"
4166 "Send Standard Community attributes\n"
4167 "Send Large Community attributes\n")
4169 DEFUN (no_neighbor_send_community_type
,
4170 no_neighbor_send_community_type_cmd
,
4171 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4175 "Send Community attribute to this neighbor\n"
4176 "Send Standard and Extended Community attributes\n"
4177 "Send Standard, Large and Extended Community attributes\n"
4178 "Send Extended Community attributes\n"
4179 "Send Standard Community attributes\n"
4180 "Send Large Community attributes\n")
4184 const char *type
= argv
[argc
- 1]->text
;
4186 if (strmatch(type
, "standard")) {
4187 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4188 } else if (strmatch(type
, "extended")) {
4189 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4190 } else if (strmatch(type
, "large")) {
4191 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4192 } else if (strmatch(type
, "both")) {
4193 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4194 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4195 } else { /* if (strmatch(type, "all")) */
4196 SET_FLAG(flag
, PEER_FLAG_SEND_COMMUNITY
);
4197 SET_FLAG(flag
, PEER_FLAG_SEND_EXT_COMMUNITY
);
4198 SET_FLAG(flag
, PEER_FLAG_SEND_LARGE_COMMUNITY
);
4201 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4202 bgp_node_afi(vty
), bgp_node_safi(vty
),
4207 no_neighbor_send_community_type
,
4208 no_neighbor_send_community_type_hidden_cmd
,
4209 "no neighbor <A.B.C.D|X:X::X:X|WORD> send-community <both|all|extended|standard|large>",
4210 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4211 "Send Community attribute to this neighbor\n"
4212 "Send Standard and Extended Community attributes\n"
4213 "Send Standard, Large and Extended Community attributes\n"
4214 "Send Extended Community attributes\n"
4215 "Send Standard Community attributes\n"
4216 "Send Large Community attributes\n")
4218 /* neighbor soft-reconfig. */
4219 DEFUN (neighbor_soft_reconfiguration
,
4220 neighbor_soft_reconfiguration_cmd
,
4221 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4224 "Per neighbor soft reconfiguration\n"
4225 "Allow inbound soft reconfiguration for this neighbor\n")
4228 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4230 PEER_FLAG_SOFT_RECONFIG
);
4233 ALIAS_HIDDEN(neighbor_soft_reconfiguration
,
4234 neighbor_soft_reconfiguration_hidden_cmd
,
4235 "neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4236 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4237 "Per neighbor soft reconfiguration\n"
4238 "Allow inbound soft reconfiguration for this neighbor\n")
4240 DEFUN (no_neighbor_soft_reconfiguration
,
4241 no_neighbor_soft_reconfiguration_cmd
,
4242 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4246 "Per neighbor soft reconfiguration\n"
4247 "Allow inbound soft reconfiguration for this neighbor\n")
4250 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4251 bgp_node_afi(vty
), bgp_node_safi(vty
),
4252 PEER_FLAG_SOFT_RECONFIG
);
4255 ALIAS_HIDDEN(no_neighbor_soft_reconfiguration
,
4256 no_neighbor_soft_reconfiguration_hidden_cmd
,
4257 "no neighbor <A.B.C.D|X:X::X:X|WORD> soft-reconfiguration inbound",
4258 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4259 "Per neighbor soft reconfiguration\n"
4260 "Allow inbound soft reconfiguration for this neighbor\n")
4262 DEFUN (neighbor_route_reflector_client
,
4263 neighbor_route_reflector_client_cmd
,
4264 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4267 "Configure a neighbor as Route Reflector client\n")
4273 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4275 return CMD_WARNING_CONFIG_FAILED
;
4277 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4279 PEER_FLAG_REFLECTOR_CLIENT
);
4282 ALIAS_HIDDEN(neighbor_route_reflector_client
,
4283 neighbor_route_reflector_client_hidden_cmd
,
4284 "neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4285 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4286 "Configure a neighbor as Route Reflector client\n")
4288 DEFUN (no_neighbor_route_reflector_client
,
4289 no_neighbor_route_reflector_client_cmd
,
4290 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4294 "Configure a neighbor as Route Reflector client\n")
4297 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4298 bgp_node_afi(vty
), bgp_node_safi(vty
),
4299 PEER_FLAG_REFLECTOR_CLIENT
);
4302 ALIAS_HIDDEN(no_neighbor_route_reflector_client
,
4303 no_neighbor_route_reflector_client_hidden_cmd
,
4304 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-reflector-client",
4305 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4306 "Configure a neighbor as Route Reflector client\n")
4308 /* neighbor route-server-client. */
4309 DEFUN (neighbor_route_server_client
,
4310 neighbor_route_server_client_cmd
,
4311 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4314 "Configure a neighbor as Route Server client\n")
4319 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4321 return CMD_WARNING_CONFIG_FAILED
;
4322 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4324 PEER_FLAG_RSERVER_CLIENT
);
4327 ALIAS_HIDDEN(neighbor_route_server_client
,
4328 neighbor_route_server_client_hidden_cmd
,
4329 "neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4330 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4331 "Configure a neighbor as Route Server client\n")
4333 DEFUN (no_neighbor_route_server_client
,
4334 no_neighbor_route_server_client_cmd
,
4335 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4339 "Configure a neighbor as Route Server client\n")
4342 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4343 bgp_node_afi(vty
), bgp_node_safi(vty
),
4344 PEER_FLAG_RSERVER_CLIENT
);
4347 ALIAS_HIDDEN(no_neighbor_route_server_client
,
4348 no_neighbor_route_server_client_hidden_cmd
,
4349 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-server-client",
4350 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4351 "Configure a neighbor as Route Server client\n")
4353 DEFUN (neighbor_nexthop_local_unchanged
,
4354 neighbor_nexthop_local_unchanged_cmd
,
4355 "neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4358 "Configure treatment of outgoing link-local nexthop attribute\n"
4359 "Leave link-local nexthop unchanged for this peer\n")
4362 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4364 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4367 DEFUN (no_neighbor_nexthop_local_unchanged
,
4368 no_neighbor_nexthop_local_unchanged_cmd
,
4369 "no neighbor <A.B.C.D|X:X::X:X|WORD> nexthop-local unchanged",
4373 "Configure treatment of outgoing link-local-nexthop attribute\n"
4374 "Leave link-local nexthop unchanged for this peer\n")
4377 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4378 bgp_node_afi(vty
), bgp_node_safi(vty
),
4379 PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED
);
4382 DEFUN (neighbor_attr_unchanged
,
4383 neighbor_attr_unchanged_cmd
,
4384 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4387 "BGP attribute is propagated unchanged to this neighbor\n"
4388 "As-path attribute\n"
4389 "Nexthop attribute\n"
4393 char *peer_str
= argv
[1]->arg
;
4396 afi_t afi
= bgp_node_afi(vty
);
4397 safi_t safi
= bgp_node_safi(vty
);
4399 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4401 return CMD_WARNING_CONFIG_FAILED
;
4403 if (argv_find(argv
, argc
, "as-path", &idx
))
4404 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4406 if (argv_find(argv
, argc
, "next-hop", &idx
))
4407 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4409 if (argv_find(argv
, argc
, "med", &idx
))
4410 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4412 /* no flags means all of them! */
4414 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4415 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4416 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4418 if (!CHECK_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
)
4419 && peer_af_flag_check(peer
, afi
, safi
,
4420 PEER_FLAG_AS_PATH_UNCHANGED
)) {
4421 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4422 PEER_FLAG_AS_PATH_UNCHANGED
);
4425 if (!CHECK_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
)
4426 && peer_af_flag_check(peer
, afi
, safi
,
4427 PEER_FLAG_NEXTHOP_UNCHANGED
)) {
4428 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4429 PEER_FLAG_NEXTHOP_UNCHANGED
);
4432 if (!CHECK_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
)
4433 && peer_af_flag_check(peer
, afi
, safi
,
4434 PEER_FLAG_MED_UNCHANGED
)) {
4435 peer_af_flag_unset_vty(vty
, peer_str
, afi
, safi
,
4436 PEER_FLAG_MED_UNCHANGED
);
4440 return peer_af_flag_set_vty(vty
, peer_str
, afi
, safi
, flags
);
4444 neighbor_attr_unchanged
, neighbor_attr_unchanged_hidden_cmd
,
4445 "neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4446 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4447 "BGP attribute is propagated unchanged to this neighbor\n"
4448 "As-path attribute\n"
4449 "Nexthop attribute\n"
4452 DEFUN (no_neighbor_attr_unchanged
,
4453 no_neighbor_attr_unchanged_cmd
,
4454 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4458 "BGP attribute is propagated unchanged to this neighbor\n"
4459 "As-path attribute\n"
4460 "Nexthop attribute\n"
4464 char *peer
= argv
[2]->arg
;
4467 if (argv_find(argv
, argc
, "as-path", &idx
))
4468 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4470 if (argv_find(argv
, argc
, "next-hop", &idx
))
4471 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4473 if (argv_find(argv
, argc
, "med", &idx
))
4474 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4476 if (!flags
) // no flags means all of them!
4478 SET_FLAG(flags
, PEER_FLAG_AS_PATH_UNCHANGED
);
4479 SET_FLAG(flags
, PEER_FLAG_NEXTHOP_UNCHANGED
);
4480 SET_FLAG(flags
, PEER_FLAG_MED_UNCHANGED
);
4483 return peer_af_flag_unset_vty(vty
, peer
, bgp_node_afi(vty
),
4484 bgp_node_safi(vty
), flags
);
4488 no_neighbor_attr_unchanged
, no_neighbor_attr_unchanged_hidden_cmd
,
4489 "no neighbor <A.B.C.D|X:X::X:X|WORD> attribute-unchanged [{as-path|next-hop|med}]",
4490 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4491 "BGP attribute is propagated unchanged to this neighbor\n"
4492 "As-path attribute\n"
4493 "Nexthop attribute\n"
4496 /* EBGP multihop configuration. */
4497 static int peer_ebgp_multihop_set_vty(struct vty
*vty
, const char *ip_str
,
4498 const char *ttl_str
)
4503 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4505 return CMD_WARNING_CONFIG_FAILED
;
4508 return bgp_vty_return(vty
, BGP_ERR_INVALID_FOR_DIRECT_PEER
);
4513 ttl
= strtoul(ttl_str
, NULL
, 10);
4515 return bgp_vty_return(vty
, peer_ebgp_multihop_set(peer
, ttl
));
4518 static int peer_ebgp_multihop_unset_vty(struct vty
*vty
, const char *ip_str
)
4522 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4524 return CMD_WARNING_CONFIG_FAILED
;
4526 return bgp_vty_return(vty
, peer_ebgp_multihop_unset(peer
));
4529 /* neighbor ebgp-multihop. */
4530 DEFUN (neighbor_ebgp_multihop
,
4531 neighbor_ebgp_multihop_cmd
,
4532 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop",
4535 "Allow EBGP neighbors not on directly connected networks\n")
4538 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4541 DEFUN (neighbor_ebgp_multihop_ttl
,
4542 neighbor_ebgp_multihop_ttl_cmd
,
4543 "neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop (1-255)",
4546 "Allow EBGP neighbors not on directly connected networks\n"
4547 "maximum hop count\n")
4551 return peer_ebgp_multihop_set_vty(vty
, argv
[idx_peer
]->arg
,
4552 argv
[idx_number
]->arg
);
4555 DEFUN (no_neighbor_ebgp_multihop
,
4556 no_neighbor_ebgp_multihop_cmd
,
4557 "no neighbor <A.B.C.D|X:X::X:X|WORD> ebgp-multihop [(1-255)]",
4561 "Allow EBGP neighbors not on directly connected networks\n"
4562 "maximum hop count\n")
4565 return peer_ebgp_multihop_unset_vty(vty
, argv
[idx_peer
]->arg
);
4569 /* disable-connected-check */
4570 DEFUN (neighbor_disable_connected_check
,
4571 neighbor_disable_connected_check_cmd
,
4572 "neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4575 "one-hop away EBGP peer using loopback address\n"
4576 "Enforce EBGP neighbors perform multihop\n")
4579 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4580 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4583 DEFUN (no_neighbor_disable_connected_check
,
4584 no_neighbor_disable_connected_check_cmd
,
4585 "no neighbor <A.B.C.D|X:X::X:X|WORD> <disable-connected-check|enforce-multihop>",
4589 "one-hop away EBGP peer using loopback address\n"
4590 "Enforce EBGP neighbors perform multihop\n")
4593 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4594 PEER_FLAG_DISABLE_CONNECTED_CHECK
);
4598 /* enforce-first-as */
4599 DEFUN (neighbor_enforce_first_as
,
4600 neighbor_enforce_first_as_cmd
,
4601 "neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4604 "Enforce the first AS for EBGP routes\n")
4608 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4609 PEER_FLAG_ENFORCE_FIRST_AS
);
4612 DEFUN (no_neighbor_enforce_first_as
,
4613 no_neighbor_enforce_first_as_cmd
,
4614 "no neighbor <A.B.C.D|X:X::X:X|WORD> enforce-first-as",
4618 "Enforce the first AS for EBGP routes\n")
4622 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4623 PEER_FLAG_ENFORCE_FIRST_AS
);
4627 DEFUN (neighbor_description
,
4628 neighbor_description_cmd
,
4629 "neighbor <A.B.C.D|X:X::X:X|WORD> description LINE...",
4632 "Neighbor specific description\n"
4633 "Up to 80 characters describing this neighbor\n")
4640 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4642 return CMD_WARNING_CONFIG_FAILED
;
4644 str
= argv_concat(argv
, argc
, idx_line
);
4646 peer_description_set(peer
, str
);
4648 XFREE(MTYPE_TMP
, str
);
4653 DEFUN (no_neighbor_description
,
4654 no_neighbor_description_cmd
,
4655 "no neighbor <A.B.C.D|X:X::X:X|WORD> description [LINE]",
4659 "Neighbor specific description\n"
4660 "Up to 80 characters describing this neighbor\n")
4665 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
4667 return CMD_WARNING_CONFIG_FAILED
;
4669 peer_description_unset(peer
);
4675 /* Neighbor update-source. */
4676 static int peer_update_source_vty(struct vty
*vty
, const char *peer_str
,
4677 const char *source_str
)
4682 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4684 return CMD_WARNING_CONFIG_FAILED
;
4691 int ret
= str2sockunion(source_str
, &su
);
4694 peer_update_source_addr_set(peer
, &su
);
4696 if (str2prefix(source_str
, &p
)) {
4698 "%% Invalid update-source, remove prefix length \n");
4699 return CMD_WARNING_CONFIG_FAILED
;
4701 peer_update_source_if_set(peer
, source_str
);
4704 peer_update_source_unset(peer
);
4709 #define BGP_UPDATE_SOURCE_HELP_STR \
4712 "Interface name (requires zebra to be running)\n"
4714 DEFUN (neighbor_update_source
,
4715 neighbor_update_source_cmd
,
4716 "neighbor <A.B.C.D|X:X::X:X|WORD> update-source <A.B.C.D|X:X::X:X|WORD>",
4719 "Source of routing updates\n"
4720 BGP_UPDATE_SOURCE_HELP_STR
)
4724 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
,
4725 argv
[idx_peer_2
]->arg
);
4728 DEFUN (no_neighbor_update_source
,
4729 no_neighbor_update_source_cmd
,
4730 "no neighbor <A.B.C.D|X:X::X:X|WORD> update-source [<A.B.C.D|X:X::X:X|WORD>]",
4734 "Source of routing updates\n"
4735 BGP_UPDATE_SOURCE_HELP_STR
)
4738 return peer_update_source_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
4741 static int peer_default_originate_set_vty(struct vty
*vty
, const char *peer_str
,
4742 afi_t afi
, safi_t safi
,
4743 const char *rmap
, int set
)
4748 peer
= peer_and_group_lookup_vty(vty
, peer_str
);
4750 return CMD_WARNING_CONFIG_FAILED
;
4753 ret
= peer_default_originate_set(peer
, afi
, safi
, rmap
);
4755 ret
= peer_default_originate_unset(peer
, afi
, safi
);
4757 return bgp_vty_return(vty
, ret
);
4760 /* neighbor default-originate. */
4761 DEFUN (neighbor_default_originate
,
4762 neighbor_default_originate_cmd
,
4763 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4766 "Originate default route to this neighbor\n")
4769 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4771 bgp_node_safi(vty
), NULL
, 1);
4774 ALIAS_HIDDEN(neighbor_default_originate
, neighbor_default_originate_hidden_cmd
,
4775 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate",
4776 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4777 "Originate default route to this neighbor\n")
4779 DEFUN (neighbor_default_originate_rmap
,
4780 neighbor_default_originate_rmap_cmd
,
4781 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4784 "Originate default route to this neighbor\n"
4785 "Route-map to specify criteria to originate default\n"
4790 return peer_default_originate_set_vty(
4791 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
4792 argv
[idx_word
]->arg
, 1);
4796 neighbor_default_originate_rmap
,
4797 neighbor_default_originate_rmap_hidden_cmd
,
4798 "neighbor <A.B.C.D|X:X::X:X|WORD> default-originate route-map WORD",
4799 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4800 "Originate default route to this neighbor\n"
4801 "Route-map to specify criteria to originate default\n"
4804 DEFUN (no_neighbor_default_originate
,
4805 no_neighbor_default_originate_cmd
,
4806 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4810 "Originate default route to this neighbor\n"
4811 "Route-map to specify criteria to originate default\n"
4815 return peer_default_originate_set_vty(vty
, argv
[idx_peer
]->arg
,
4817 bgp_node_safi(vty
), NULL
, 0);
4821 no_neighbor_default_originate
, no_neighbor_default_originate_hidden_cmd
,
4822 "no neighbor <A.B.C.D|X:X::X:X|WORD> default-originate [route-map WORD]",
4823 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4824 "Originate default route to this neighbor\n"
4825 "Route-map to specify criteria to originate default\n"
4829 /* Set neighbor's BGP port. */
4830 static int peer_port_vty(struct vty
*vty
, const char *ip_str
, int afi
,
4831 const char *port_str
)
4837 peer
= peer_lookup_vty(vty
, ip_str
);
4839 return CMD_WARNING_CONFIG_FAILED
;
4842 sp
= getservbyname("bgp", "tcp");
4843 port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
4845 port
= strtoul(port_str
, NULL
, 10);
4848 peer_port_set(peer
, port
);
4853 /* Set specified peer's BGP port. */
4854 DEFUN (neighbor_port
,
4856 "neighbor <A.B.C.D|X:X::X:X> port (0-65535)",
4859 "Neighbor's BGP port\n"
4860 "TCP port number\n")
4864 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
,
4865 argv
[idx_number
]->arg
);
4868 DEFUN (no_neighbor_port
,
4869 no_neighbor_port_cmd
,
4870 "no neighbor <A.B.C.D|X:X::X:X> port [(0-65535)]",
4874 "Neighbor's BGP port\n"
4875 "TCP port number\n")
4878 return peer_port_vty(vty
, argv
[idx_ip
]->arg
, AFI_IP
, NULL
);
4882 /* neighbor weight. */
4883 static int peer_weight_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4884 safi_t safi
, const char *weight_str
)
4888 unsigned long weight
;
4890 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4892 return CMD_WARNING_CONFIG_FAILED
;
4894 weight
= strtoul(weight_str
, NULL
, 10);
4896 ret
= peer_weight_set(peer
, afi
, safi
, weight
);
4897 return bgp_vty_return(vty
, ret
);
4900 static int peer_weight_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
4906 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
4908 return CMD_WARNING_CONFIG_FAILED
;
4910 ret
= peer_weight_unset(peer
, afi
, safi
);
4911 return bgp_vty_return(vty
, ret
);
4914 DEFUN (neighbor_weight
,
4915 neighbor_weight_cmd
,
4916 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4919 "Set default weight for routes from this neighbor\n"
4924 return peer_weight_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
4925 bgp_node_safi(vty
), argv
[idx_number
]->arg
);
4928 ALIAS_HIDDEN(neighbor_weight
, neighbor_weight_hidden_cmd
,
4929 "neighbor <A.B.C.D|X:X::X:X|WORD> weight (0-65535)",
4930 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4931 "Set default weight for routes from this neighbor\n"
4934 DEFUN (no_neighbor_weight
,
4935 no_neighbor_weight_cmd
,
4936 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4940 "Set default weight for routes from this neighbor\n"
4944 return peer_weight_unset_vty(vty
, argv
[idx_peer
]->arg
,
4945 bgp_node_afi(vty
), bgp_node_safi(vty
));
4948 ALIAS_HIDDEN(no_neighbor_weight
, no_neighbor_weight_hidden_cmd
,
4949 "no neighbor <A.B.C.D|X:X::X:X|WORD> weight [(0-65535)]",
4950 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
4951 "Set default weight for routes from this neighbor\n"
4955 /* Override capability negotiation. */
4956 DEFUN (neighbor_override_capability
,
4957 neighbor_override_capability_cmd
,
4958 "neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4961 "Override capability negotiation result\n")
4964 return peer_flag_set_vty(vty
, argv
[idx_peer
]->arg
,
4965 PEER_FLAG_OVERRIDE_CAPABILITY
);
4968 DEFUN (no_neighbor_override_capability
,
4969 no_neighbor_override_capability_cmd
,
4970 "no neighbor <A.B.C.D|X:X::X:X|WORD> override-capability",
4974 "Override capability negotiation result\n")
4977 return peer_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
4978 PEER_FLAG_OVERRIDE_CAPABILITY
);
4981 DEFUN (neighbor_strict_capability
,
4982 neighbor_strict_capability_cmd
,
4983 "neighbor <A.B.C.D|X:X::X:X> strict-capability-match",
4986 "Strict capability negotiation match\n")
4989 return peer_flag_set_vty(vty
, argv
[idx_ip
]->arg
,
4990 PEER_FLAG_STRICT_CAP_MATCH
);
4993 DEFUN (no_neighbor_strict_capability
,
4994 no_neighbor_strict_capability_cmd
,
4995 "no neighbor <A.B.C.D|X:X::X:X> strict-capability-match",
4999 "Strict capability negotiation match\n")
5002 return peer_flag_unset_vty(vty
, argv
[idx_ip
]->arg
,
5003 PEER_FLAG_STRICT_CAP_MATCH
);
5006 static int peer_timers_set_vty(struct vty
*vty
, const char *ip_str
,
5007 const char *keep_str
, const char *hold_str
)
5014 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5016 return CMD_WARNING_CONFIG_FAILED
;
5018 keepalive
= strtoul(keep_str
, NULL
, 10);
5019 holdtime
= strtoul(hold_str
, NULL
, 10);
5021 ret
= peer_timers_set(peer
, keepalive
, holdtime
);
5023 return bgp_vty_return(vty
, ret
);
5026 static int peer_timers_unset_vty(struct vty
*vty
, const char *ip_str
)
5031 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5033 return CMD_WARNING_CONFIG_FAILED
;
5035 ret
= peer_timers_unset(peer
);
5037 return bgp_vty_return(vty
, ret
);
5040 DEFUN (neighbor_timers
,
5041 neighbor_timers_cmd
,
5042 "neighbor <A.B.C.D|X:X::X:X|WORD> timers (0-65535) (0-65535)",
5045 "BGP per neighbor timers\n"
5046 "Keepalive interval\n"
5051 int idx_number_2
= 4;
5052 return peer_timers_set_vty(vty
, argv
[idx_peer
]->arg
,
5053 argv
[idx_number
]->arg
,
5054 argv
[idx_number_2
]->arg
);
5057 DEFUN (no_neighbor_timers
,
5058 no_neighbor_timers_cmd
,
5059 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers [(0-65535) (0-65535)]",
5063 "BGP per neighbor timers\n"
5064 "Keepalive interval\n"
5068 return peer_timers_unset_vty(vty
, argv
[idx_peer
]->arg
);
5072 static int peer_timers_connect_set_vty(struct vty
*vty
, const char *ip_str
,
5073 const char *time_str
)
5079 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5081 return CMD_WARNING_CONFIG_FAILED
;
5083 connect
= strtoul(time_str
, NULL
, 10);
5085 ret
= peer_timers_connect_set(peer
, connect
);
5087 return bgp_vty_return(vty
, ret
);
5090 static int peer_timers_connect_unset_vty(struct vty
*vty
, const char *ip_str
)
5095 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5097 return CMD_WARNING_CONFIG_FAILED
;
5099 ret
= peer_timers_connect_unset(peer
);
5101 return bgp_vty_return(vty
, ret
);
5104 DEFUN (neighbor_timers_connect
,
5105 neighbor_timers_connect_cmd
,
5106 "neighbor <A.B.C.D|X:X::X:X|WORD> timers connect (1-65535)",
5109 "BGP per neighbor timers\n"
5110 "BGP connect timer\n"
5115 return peer_timers_connect_set_vty(vty
, argv
[idx_peer
]->arg
,
5116 argv
[idx_number
]->arg
);
5119 DEFUN (no_neighbor_timers_connect
,
5120 no_neighbor_timers_connect_cmd
,
5121 "no neighbor <A.B.C.D|X:X::X:X|WORD> timers connect [(1-65535)]",
5125 "BGP per neighbor timers\n"
5126 "BGP connect timer\n"
5130 return peer_timers_connect_unset_vty(vty
, argv
[idx_peer
]->arg
);
5134 static int peer_advertise_interval_vty(struct vty
*vty
, const char *ip_str
,
5135 const char *time_str
, int set
)
5139 uint32_t routeadv
= 0;
5141 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5143 return CMD_WARNING_CONFIG_FAILED
;
5146 routeadv
= strtoul(time_str
, NULL
, 10);
5149 ret
= peer_advertise_interval_set(peer
, routeadv
);
5151 ret
= peer_advertise_interval_unset(peer
);
5153 return bgp_vty_return(vty
, ret
);
5156 DEFUN (neighbor_advertise_interval
,
5157 neighbor_advertise_interval_cmd
,
5158 "neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval (0-600)",
5161 "Minimum interval between sending BGP routing updates\n"
5162 "time in seconds\n")
5166 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
,
5167 argv
[idx_number
]->arg
, 1);
5170 DEFUN (no_neighbor_advertise_interval
,
5171 no_neighbor_advertise_interval_cmd
,
5172 "no neighbor <A.B.C.D|X:X::X:X|WORD> advertisement-interval [(0-600)]",
5176 "Minimum interval between sending BGP routing updates\n"
5177 "time in seconds\n")
5180 return peer_advertise_interval_vty(vty
, argv
[idx_peer
]->arg
, NULL
, 0);
5184 /* Time to wait before processing route-map updates */
5185 DEFUN (bgp_set_route_map_delay_timer
,
5186 bgp_set_route_map_delay_timer_cmd
,
5187 "bgp route-map delay-timer (0-600)",
5189 "BGP route-map delay timer\n"
5190 "Time in secs to wait before processing route-map changes\n"
5191 "0 disables the timer, no route updates happen when route-maps change\n")
5194 uint32_t rmap_delay_timer
;
5196 if (argv
[idx_number
]->arg
) {
5197 rmap_delay_timer
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
5198 bm
->rmap_update_timer
= rmap_delay_timer
;
5200 /* if the dynamic update handling is being disabled, and a timer
5202 * running, stop the timer and act as if the timer has already
5205 if (!rmap_delay_timer
&& bm
->t_rmap_update
) {
5206 BGP_TIMER_OFF(bm
->t_rmap_update
);
5207 thread_execute(bm
->master
, bgp_route_map_update_timer
,
5212 vty_out(vty
, "%% BGP invalid route-map delay-timer\n");
5213 return CMD_WARNING_CONFIG_FAILED
;
5217 DEFUN (no_bgp_set_route_map_delay_timer
,
5218 no_bgp_set_route_map_delay_timer_cmd
,
5219 "no bgp route-map delay-timer [(0-600)]",
5222 "Default BGP route-map delay timer\n"
5223 "Reset to default time to wait for processing route-map changes\n"
5224 "0 disables the timer, no route updates happen when route-maps change\n")
5227 bm
->rmap_update_timer
= RMAP_DEFAULT_UPDATE_TIMER
;
5233 /* neighbor interface */
5234 static int peer_interface_vty(struct vty
*vty
, const char *ip_str
,
5239 peer
= peer_lookup_vty(vty
, ip_str
);
5240 if (!peer
|| peer
->conf_if
) {
5241 vty_out(vty
, "%% BGP invalid peer %s\n", ip_str
);
5242 return CMD_WARNING_CONFIG_FAILED
;
5246 peer_interface_set(peer
, str
);
5248 peer_interface_unset(peer
);
5253 DEFUN (neighbor_interface
,
5254 neighbor_interface_cmd
,
5255 "neighbor <A.B.C.D|X:X::X:X> interface WORD",
5263 return peer_interface_vty(vty
, argv
[idx_ip
]->arg
, argv
[idx_word
]->arg
);
5266 DEFUN (no_neighbor_interface
,
5267 no_neighbor_interface_cmd
,
5268 "no neighbor <A.B.C.D|X:X::X:X|WORD> interface WORD",
5276 return peer_interface_vty(vty
, argv
[idx_peer
]->arg
, NULL
);
5279 DEFUN (neighbor_distribute_list
,
5280 neighbor_distribute_list_cmd
,
5281 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5284 "Filter updates to/from this neighbor\n"
5285 "IP access-list number\n"
5286 "IP access-list number (expanded range)\n"
5287 "IP Access-list name\n"
5288 "Filter incoming updates\n"
5289 "Filter outgoing updates\n")
5296 const char *pstr
= argv
[idx_peer
]->arg
;
5297 const char *acl
= argv
[idx_acl
]->arg
;
5298 const char *inout
= argv
[argc
- 1]->text
;
5300 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5302 return CMD_WARNING_CONFIG_FAILED
;
5304 /* Check filter direction. */
5305 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5306 ret
= peer_distribute_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5309 return bgp_vty_return(vty
, ret
);
5313 neighbor_distribute_list
, neighbor_distribute_list_hidden_cmd
,
5314 "neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5315 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5316 "Filter updates to/from this neighbor\n"
5317 "IP access-list number\n"
5318 "IP access-list number (expanded range)\n"
5319 "IP Access-list name\n"
5320 "Filter incoming updates\n"
5321 "Filter outgoing updates\n")
5323 DEFUN (no_neighbor_distribute_list
,
5324 no_neighbor_distribute_list_cmd
,
5325 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5329 "Filter updates to/from this neighbor\n"
5330 "IP access-list number\n"
5331 "IP access-list number (expanded range)\n"
5332 "IP Access-list name\n"
5333 "Filter incoming updates\n"
5334 "Filter outgoing updates\n")
5340 const char *pstr
= argv
[idx_peer
]->arg
;
5341 const char *inout
= argv
[argc
- 1]->text
;
5343 peer
= peer_and_group_lookup_vty(vty
, pstr
);
5345 return CMD_WARNING_CONFIG_FAILED
;
5347 /* Check filter direction. */
5348 direct
= strmatch(inout
, "in") ? FILTER_IN
: FILTER_OUT
;
5349 ret
= peer_distribute_unset(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5352 return bgp_vty_return(vty
, ret
);
5356 no_neighbor_distribute_list
, no_neighbor_distribute_list_hidden_cmd
,
5357 "no neighbor <A.B.C.D|X:X::X:X|WORD> distribute-list <(1-199)|(1300-2699)|WORD> <in|out>",
5358 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5359 "Filter updates to/from this neighbor\n"
5360 "IP access-list number\n"
5361 "IP access-list number (expanded range)\n"
5362 "IP Access-list name\n"
5363 "Filter incoming updates\n"
5364 "Filter outgoing updates\n")
5366 /* Set prefix list to the peer. */
5367 static int peer_prefix_list_set_vty(struct vty
*vty
, const char *ip_str
,
5368 afi_t afi
, safi_t safi
,
5369 const char *name_str
,
5370 const char *direct_str
)
5373 int direct
= FILTER_IN
;
5376 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5378 return CMD_WARNING_CONFIG_FAILED
;
5380 /* Check filter direction. */
5381 if (strncmp(direct_str
, "i", 1) == 0)
5383 else if (strncmp(direct_str
, "o", 1) == 0)
5384 direct
= FILTER_OUT
;
5386 ret
= peer_prefix_list_set(peer
, afi
, safi
, direct
, name_str
);
5388 return bgp_vty_return(vty
, ret
);
5391 static int peer_prefix_list_unset_vty(struct vty
*vty
, const char *ip_str
,
5392 afi_t afi
, safi_t safi
,
5393 const char *direct_str
)
5397 int direct
= FILTER_IN
;
5399 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5401 return CMD_WARNING_CONFIG_FAILED
;
5403 /* Check filter direction. */
5404 if (strncmp(direct_str
, "i", 1) == 0)
5406 else if (strncmp(direct_str
, "o", 1) == 0)
5407 direct
= FILTER_OUT
;
5409 ret
= peer_prefix_list_unset(peer
, afi
, safi
, direct
);
5411 return bgp_vty_return(vty
, ret
);
5414 DEFUN (neighbor_prefix_list
,
5415 neighbor_prefix_list_cmd
,
5416 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5419 "Filter updates to/from this neighbor\n"
5420 "Name of a prefix list\n"
5421 "Filter incoming updates\n"
5422 "Filter outgoing updates\n")
5427 return peer_prefix_list_set_vty(
5428 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5429 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5432 ALIAS_HIDDEN(neighbor_prefix_list
, neighbor_prefix_list_hidden_cmd
,
5433 "neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5434 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5435 "Filter updates to/from this neighbor\n"
5436 "Name of a prefix list\n"
5437 "Filter incoming updates\n"
5438 "Filter outgoing updates\n")
5440 DEFUN (no_neighbor_prefix_list
,
5441 no_neighbor_prefix_list_cmd
,
5442 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5446 "Filter updates to/from this neighbor\n"
5447 "Name of a prefix list\n"
5448 "Filter incoming updates\n"
5449 "Filter outgoing updates\n")
5453 return peer_prefix_list_unset_vty(vty
, argv
[idx_peer
]->arg
,
5454 bgp_node_afi(vty
), bgp_node_safi(vty
),
5455 argv
[idx_in_out
]->arg
);
5458 ALIAS_HIDDEN(no_neighbor_prefix_list
, no_neighbor_prefix_list_hidden_cmd
,
5459 "no neighbor <A.B.C.D|X:X::X:X|WORD> prefix-list WORD <in|out>",
5460 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5461 "Filter updates to/from this neighbor\n"
5462 "Name of a prefix list\n"
5463 "Filter incoming updates\n"
5464 "Filter outgoing updates\n")
5466 static int peer_aslist_set_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5467 safi_t safi
, const char *name_str
,
5468 const char *direct_str
)
5472 int direct
= FILTER_IN
;
5474 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5476 return CMD_WARNING_CONFIG_FAILED
;
5478 /* Check filter direction. */
5479 if (strncmp(direct_str
, "i", 1) == 0)
5481 else if (strncmp(direct_str
, "o", 1) == 0)
5482 direct
= FILTER_OUT
;
5484 ret
= peer_aslist_set(peer
, afi
, safi
, direct
, name_str
);
5486 return bgp_vty_return(vty
, ret
);
5489 static int peer_aslist_unset_vty(struct vty
*vty
, const char *ip_str
, afi_t afi
,
5490 safi_t safi
, const char *direct_str
)
5494 int direct
= FILTER_IN
;
5496 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5498 return CMD_WARNING_CONFIG_FAILED
;
5500 /* Check filter direction. */
5501 if (strncmp(direct_str
, "i", 1) == 0)
5503 else if (strncmp(direct_str
, "o", 1) == 0)
5504 direct
= FILTER_OUT
;
5506 ret
= peer_aslist_unset(peer
, afi
, safi
, direct
);
5508 return bgp_vty_return(vty
, ret
);
5511 DEFUN (neighbor_filter_list
,
5512 neighbor_filter_list_cmd
,
5513 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5516 "Establish BGP filters\n"
5517 "AS path access-list name\n"
5518 "Filter incoming routes\n"
5519 "Filter outgoing routes\n")
5524 return peer_aslist_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
5525 bgp_node_safi(vty
), argv
[idx_word
]->arg
,
5526 argv
[idx_in_out
]->arg
);
5529 ALIAS_HIDDEN(neighbor_filter_list
, neighbor_filter_list_hidden_cmd
,
5530 "neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5531 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5532 "Establish BGP filters\n"
5533 "AS path access-list name\n"
5534 "Filter incoming routes\n"
5535 "Filter outgoing routes\n")
5537 DEFUN (no_neighbor_filter_list
,
5538 no_neighbor_filter_list_cmd
,
5539 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5543 "Establish BGP filters\n"
5544 "AS path access-list name\n"
5545 "Filter incoming routes\n"
5546 "Filter outgoing routes\n")
5550 return peer_aslist_unset_vty(vty
, argv
[idx_peer
]->arg
,
5551 bgp_node_afi(vty
), bgp_node_safi(vty
),
5552 argv
[idx_in_out
]->arg
);
5555 ALIAS_HIDDEN(no_neighbor_filter_list
, no_neighbor_filter_list_hidden_cmd
,
5556 "no neighbor <A.B.C.D|X:X::X:X|WORD> filter-list WORD <in|out>",
5557 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5558 "Establish BGP filters\n"
5559 "AS path access-list name\n"
5560 "Filter incoming routes\n"
5561 "Filter outgoing routes\n")
5563 /* Set route-map to the peer. */
5564 static int peer_route_map_set_vty(struct vty
*vty
, const char *ip_str
,
5565 afi_t afi
, safi_t safi
, const char *name_str
,
5566 const char *direct_str
)
5570 int direct
= RMAP_IN
;
5572 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5574 return CMD_WARNING_CONFIG_FAILED
;
5576 /* Check filter direction. */
5577 if (strncmp(direct_str
, "in", 2) == 0)
5579 else if (strncmp(direct_str
, "o", 1) == 0)
5582 ret
= peer_route_map_set(peer
, afi
, safi
, direct
, name_str
);
5584 return bgp_vty_return(vty
, ret
);
5587 static int peer_route_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5588 afi_t afi
, safi_t safi
,
5589 const char *direct_str
)
5593 int direct
= RMAP_IN
;
5595 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5597 return CMD_WARNING_CONFIG_FAILED
;
5599 /* Check filter direction. */
5600 if (strncmp(direct_str
, "in", 2) == 0)
5602 else if (strncmp(direct_str
, "o", 1) == 0)
5605 ret
= peer_route_map_unset(peer
, afi
, safi
, direct
);
5607 return bgp_vty_return(vty
, ret
);
5610 DEFUN (neighbor_route_map
,
5611 neighbor_route_map_cmd
,
5612 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5615 "Apply route map to neighbor\n"
5616 "Name of route map\n"
5617 "Apply map to incoming routes\n"
5618 "Apply map to outbound routes\n")
5623 return peer_route_map_set_vty(
5624 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5625 argv
[idx_word
]->arg
, argv
[idx_in_out
]->arg
);
5628 ALIAS_HIDDEN(neighbor_route_map
, neighbor_route_map_hidden_cmd
,
5629 "neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5630 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5631 "Apply route map to neighbor\n"
5632 "Name of route map\n"
5633 "Apply map to incoming routes\n"
5634 "Apply map to outbound routes\n")
5636 DEFUN (no_neighbor_route_map
,
5637 no_neighbor_route_map_cmd
,
5638 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5642 "Apply route map to neighbor\n"
5643 "Name of route map\n"
5644 "Apply map to incoming routes\n"
5645 "Apply map to outbound routes\n")
5649 return peer_route_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5650 bgp_node_afi(vty
), bgp_node_safi(vty
),
5651 argv
[idx_in_out
]->arg
);
5654 ALIAS_HIDDEN(no_neighbor_route_map
, no_neighbor_route_map_hidden_cmd
,
5655 "no neighbor <A.B.C.D|X:X::X:X|WORD> route-map WORD <in|out>",
5656 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5657 "Apply route map to neighbor\n"
5658 "Name of route map\n"
5659 "Apply map to incoming routes\n"
5660 "Apply map to outbound routes\n")
5662 /* Set unsuppress-map to the peer. */
5663 static int peer_unsuppress_map_set_vty(struct vty
*vty
, const char *ip_str
,
5664 afi_t afi
, safi_t safi
,
5665 const char *name_str
)
5670 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5672 return CMD_WARNING_CONFIG_FAILED
;
5674 ret
= peer_unsuppress_map_set(peer
, afi
, safi
, name_str
);
5676 return bgp_vty_return(vty
, ret
);
5679 /* Unset route-map from the peer. */
5680 static int peer_unsuppress_map_unset_vty(struct vty
*vty
, const char *ip_str
,
5681 afi_t afi
, safi_t safi
)
5686 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5688 return CMD_WARNING_CONFIG_FAILED
;
5690 ret
= peer_unsuppress_map_unset(peer
, afi
, safi
);
5692 return bgp_vty_return(vty
, ret
);
5695 DEFUN (neighbor_unsuppress_map
,
5696 neighbor_unsuppress_map_cmd
,
5697 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5700 "Route-map to selectively unsuppress suppressed routes\n"
5701 "Name of route map\n")
5705 return peer_unsuppress_map_set_vty(
5706 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5707 argv
[idx_word
]->arg
);
5710 ALIAS_HIDDEN(neighbor_unsuppress_map
, neighbor_unsuppress_map_hidden_cmd
,
5711 "neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5712 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5713 "Route-map to selectively unsuppress suppressed routes\n"
5714 "Name of route map\n")
5716 DEFUN (no_neighbor_unsuppress_map
,
5717 no_neighbor_unsuppress_map_cmd
,
5718 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5722 "Route-map to selectively unsuppress suppressed routes\n"
5723 "Name of route map\n")
5726 return peer_unsuppress_map_unset_vty(vty
, argv
[idx_peer
]->arg
,
5728 bgp_node_safi(vty
));
5731 ALIAS_HIDDEN(no_neighbor_unsuppress_map
, no_neighbor_unsuppress_map_hidden_cmd
,
5732 "no neighbor <A.B.C.D|X:X::X:X|WORD> unsuppress-map WORD",
5733 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5734 "Route-map to selectively unsuppress suppressed routes\n"
5735 "Name of route map\n")
5737 static int peer_maximum_prefix_set_vty(struct vty
*vty
, const char *ip_str
,
5738 afi_t afi
, safi_t safi
,
5739 const char *num_str
,
5740 const char *threshold_str
, int warning
,
5741 const char *restart_str
)
5749 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5751 return CMD_WARNING_CONFIG_FAILED
;
5753 max
= strtoul(num_str
, NULL
, 10);
5755 threshold
= atoi(threshold_str
);
5757 threshold
= MAXIMUM_PREFIX_THRESHOLD_DEFAULT
;
5760 restart
= atoi(restart_str
);
5764 ret
= peer_maximum_prefix_set(peer
, afi
, safi
, max
, threshold
, warning
,
5767 return bgp_vty_return(vty
, ret
);
5770 static int peer_maximum_prefix_unset_vty(struct vty
*vty
, const char *ip_str
,
5771 afi_t afi
, safi_t safi
)
5776 peer
= peer_and_group_lookup_vty(vty
, ip_str
);
5778 return CMD_WARNING_CONFIG_FAILED
;
5780 ret
= peer_maximum_prefix_unset(peer
, afi
, safi
);
5782 return bgp_vty_return(vty
, ret
);
5785 /* Maximum number of prefix configuration. prefix count is different
5786 for each peer configuration. So this configuration can be set for
5787 each peer configuration. */
5788 DEFUN (neighbor_maximum_prefix
,
5789 neighbor_maximum_prefix_cmd
,
5790 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5793 "Maximum number of prefix accept from this peer\n"
5794 "maximum no. of prefix limit\n")
5798 return peer_maximum_prefix_set_vty(
5799 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5800 argv
[idx_number
]->arg
, NULL
, 0, NULL
);
5803 ALIAS_HIDDEN(neighbor_maximum_prefix
, neighbor_maximum_prefix_hidden_cmd
,
5804 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295)",
5805 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5806 "Maximum number of prefix accept from this peer\n"
5807 "maximum no. of prefix limit\n")
5809 DEFUN (neighbor_maximum_prefix_threshold
,
5810 neighbor_maximum_prefix_threshold_cmd
,
5811 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5814 "Maximum number of prefix accept from this peer\n"
5815 "maximum no. of prefix limit\n"
5816 "Threshold value (%) at which to generate a warning msg\n")
5820 int idx_number_2
= 4;
5821 return peer_maximum_prefix_set_vty(
5822 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5823 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0, NULL
);
5827 neighbor_maximum_prefix_threshold
,
5828 neighbor_maximum_prefix_threshold_hidden_cmd
,
5829 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100)",
5830 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5831 "Maximum number of prefix accept from this peer\n"
5832 "maximum no. of prefix limit\n"
5833 "Threshold value (%) at which to generate a warning msg\n")
5835 DEFUN (neighbor_maximum_prefix_warning
,
5836 neighbor_maximum_prefix_warning_cmd
,
5837 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5840 "Maximum number of prefix accept from this peer\n"
5841 "maximum no. of prefix limit\n"
5842 "Only give warning message when limit is exceeded\n")
5846 return peer_maximum_prefix_set_vty(
5847 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5848 argv
[idx_number
]->arg
, NULL
, 1, NULL
);
5852 neighbor_maximum_prefix_warning
,
5853 neighbor_maximum_prefix_warning_hidden_cmd
,
5854 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) warning-only",
5855 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5856 "Maximum number of prefix accept from this peer\n"
5857 "maximum no. of prefix limit\n"
5858 "Only give warning message when limit is exceeded\n")
5860 DEFUN (neighbor_maximum_prefix_threshold_warning
,
5861 neighbor_maximum_prefix_threshold_warning_cmd
,
5862 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5865 "Maximum number of prefix accept from this peer\n"
5866 "maximum no. of prefix limit\n"
5867 "Threshold value (%) at which to generate a warning msg\n"
5868 "Only give warning message when limit is exceeded\n")
5872 int idx_number_2
= 4;
5873 return peer_maximum_prefix_set_vty(
5874 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5875 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 1, NULL
);
5879 neighbor_maximum_prefix_threshold_warning
,
5880 neighbor_maximum_prefix_threshold_warning_hidden_cmd
,
5881 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) warning-only",
5882 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5883 "Maximum number of prefix accept from this peer\n"
5884 "maximum no. of prefix limit\n"
5885 "Threshold value (%) at which to generate a warning msg\n"
5886 "Only give warning message when limit is exceeded\n")
5888 DEFUN (neighbor_maximum_prefix_restart
,
5889 neighbor_maximum_prefix_restart_cmd
,
5890 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5893 "Maximum number of prefix accept from this peer\n"
5894 "maximum no. of prefix limit\n"
5895 "Restart bgp connection after limit is exceeded\n"
5896 "Restart interval in minutes\n")
5900 int idx_number_2
= 5;
5901 return peer_maximum_prefix_set_vty(
5902 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5903 argv
[idx_number
]->arg
, NULL
, 0, argv
[idx_number_2
]->arg
);
5907 neighbor_maximum_prefix_restart
,
5908 neighbor_maximum_prefix_restart_hidden_cmd
,
5909 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) restart (1-65535)",
5910 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5911 "Maximum number of prefix accept from this peer\n"
5912 "maximum no. of prefix limit\n"
5913 "Restart bgp connection after limit is exceeded\n"
5914 "Restart interval in minutes\n")
5916 DEFUN (neighbor_maximum_prefix_threshold_restart
,
5917 neighbor_maximum_prefix_threshold_restart_cmd
,
5918 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5921 "Maximum number of prefixes to accept from this peer\n"
5922 "maximum no. of prefix limit\n"
5923 "Threshold value (%) at which to generate a warning msg\n"
5924 "Restart bgp connection after limit is exceeded\n"
5925 "Restart interval in minutes\n")
5929 int idx_number_2
= 4;
5930 int idx_number_3
= 6;
5931 return peer_maximum_prefix_set_vty(
5932 vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
), bgp_node_safi(vty
),
5933 argv
[idx_number
]->arg
, argv
[idx_number_2
]->arg
, 0,
5934 argv
[idx_number_3
]->arg
);
5938 neighbor_maximum_prefix_threshold_restart
,
5939 neighbor_maximum_prefix_threshold_restart_hidden_cmd
,
5940 "neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix (1-4294967295) (1-100) restart (1-65535)",
5941 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5942 "Maximum number of prefixes to accept from this peer\n"
5943 "maximum no. of prefix limit\n"
5944 "Threshold value (%) at which to generate a warning msg\n"
5945 "Restart bgp connection after limit is exceeded\n"
5946 "Restart interval in minutes\n")
5948 DEFUN (no_neighbor_maximum_prefix
,
5949 no_neighbor_maximum_prefix_cmd
,
5950 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5954 "Maximum number of prefixes to accept from this peer\n"
5955 "maximum no. of prefix limit\n"
5956 "Threshold value (%) at which to generate a warning msg\n"
5957 "Restart bgp connection after limit is exceeded\n"
5958 "Restart interval in minutes\n"
5959 "Only give warning message when limit is exceeded\n")
5962 return peer_maximum_prefix_unset_vty(vty
, argv
[idx_peer
]->arg
,
5964 bgp_node_safi(vty
));
5968 no_neighbor_maximum_prefix
, no_neighbor_maximum_prefix_hidden_cmd
,
5969 "no neighbor <A.B.C.D|X:X::X:X|WORD> maximum-prefix [(1-4294967295) [(1-100)] [restart (1-65535)] [warning-only]]",
5970 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
5971 "Maximum number of prefixes to accept from this peer\n"
5972 "maximum no. of prefix limit\n"
5973 "Threshold value (%) at which to generate a warning msg\n"
5974 "Restart bgp connection after limit is exceeded\n"
5975 "Restart interval in minutes\n"
5976 "Only give warning message when limit is exceeded\n")
5979 /* "neighbor allowas-in" */
5980 DEFUN (neighbor_allowas_in
,
5981 neighbor_allowas_in_cmd
,
5982 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
5985 "Accept as-path with my AS present in it\n"
5986 "Number of occurances of AS number\n"
5987 "Only accept my AS in the as-path if the route was originated in my AS\n")
5990 int idx_number_origin
= 3;
5996 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
5998 return CMD_WARNING_CONFIG_FAILED
;
6000 if (argc
<= idx_number_origin
)
6003 if (argv
[idx_number_origin
]->type
== WORD_TKN
)
6006 allow_num
= atoi(argv
[idx_number_origin
]->arg
);
6009 ret
= peer_allowas_in_set(peer
, bgp_node_afi(vty
), bgp_node_safi(vty
),
6012 return bgp_vty_return(vty
, ret
);
6016 neighbor_allowas_in
, neighbor_allowas_in_hidden_cmd
,
6017 "neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6018 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6019 "Accept as-path with my AS present in it\n"
6020 "Number of occurances of AS number\n"
6021 "Only accept my AS in the as-path if the route was originated in my AS\n")
6023 DEFUN (no_neighbor_allowas_in
,
6024 no_neighbor_allowas_in_cmd
,
6025 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6029 "allow local ASN appears in aspath attribute\n"
6030 "Number of occurances of AS number\n"
6031 "Only accept my AS in the as-path if the route was originated in my AS\n")
6037 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6039 return CMD_WARNING_CONFIG_FAILED
;
6041 ret
= peer_allowas_in_unset(peer
, bgp_node_afi(vty
),
6042 bgp_node_safi(vty
));
6044 return bgp_vty_return(vty
, ret
);
6048 no_neighbor_allowas_in
, no_neighbor_allowas_in_hidden_cmd
,
6049 "no neighbor <A.B.C.D|X:X::X:X|WORD> allowas-in [<(1-10)|origin>]",
6050 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6051 "allow local ASN appears in aspath attribute\n"
6052 "Number of occurances of AS number\n"
6053 "Only accept my AS in the as-path if the route was originated in my AS\n")
6055 DEFUN (neighbor_ttl_security
,
6056 neighbor_ttl_security_cmd
,
6057 "neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6060 "BGP ttl-security parameters\n"
6061 "Specify the maximum number of hops to the BGP peer\n"
6062 "Number of hops to BGP peer\n")
6069 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6071 return CMD_WARNING_CONFIG_FAILED
;
6073 gtsm_hops
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
6076 * If 'neighbor swpX', then this is for directly connected peers,
6077 * we should not accept a ttl-security hops value greater than 1.
6079 if (peer
->conf_if
&& (gtsm_hops
> 1)) {
6081 "%s is directly connected peer, hops cannot exceed 1\n",
6082 argv
[idx_peer
]->arg
);
6083 return CMD_WARNING_CONFIG_FAILED
;
6086 return bgp_vty_return(vty
, peer_ttl_security_hops_set(peer
, gtsm_hops
));
6089 DEFUN (no_neighbor_ttl_security
,
6090 no_neighbor_ttl_security_cmd
,
6091 "no neighbor <A.B.C.D|X:X::X:X|WORD> ttl-security hops (1-254)",
6095 "BGP ttl-security parameters\n"
6096 "Specify the maximum number of hops to the BGP peer\n"
6097 "Number of hops to BGP peer\n")
6102 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6104 return CMD_WARNING_CONFIG_FAILED
;
6106 return bgp_vty_return(vty
, peer_ttl_security_hops_unset(peer
));
6109 DEFUN (neighbor_addpath_tx_all_paths
,
6110 neighbor_addpath_tx_all_paths_cmd
,
6111 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6114 "Use addpath to advertise all paths to a neighbor\n")
6119 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6121 return CMD_WARNING_CONFIG_FAILED
;
6123 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6125 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
6128 ALIAS_HIDDEN(neighbor_addpath_tx_all_paths
,
6129 neighbor_addpath_tx_all_paths_hidden_cmd
,
6130 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6131 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6132 "Use addpath to advertise all paths to a neighbor\n")
6134 DEFUN (no_neighbor_addpath_tx_all_paths
,
6135 no_neighbor_addpath_tx_all_paths_cmd
,
6136 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6140 "Use addpath to advertise all paths to a neighbor\n")
6143 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6144 bgp_node_afi(vty
), bgp_node_safi(vty
),
6145 PEER_FLAG_ADDPATH_TX_ALL_PATHS
);
6148 ALIAS_HIDDEN(no_neighbor_addpath_tx_all_paths
,
6149 no_neighbor_addpath_tx_all_paths_hidden_cmd
,
6150 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-all-paths",
6151 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6152 "Use addpath to advertise all paths to a neighbor\n")
6154 DEFUN (neighbor_addpath_tx_bestpath_per_as
,
6155 neighbor_addpath_tx_bestpath_per_as_cmd
,
6156 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6159 "Use addpath to advertise the bestpath per each neighboring AS\n")
6164 peer
= peer_and_group_lookup_vty(vty
, argv
[idx_peer
]->arg
);
6166 return CMD_WARNING_CONFIG_FAILED
;
6168 return peer_af_flag_set_vty(vty
, argv
[idx_peer
]->arg
, bgp_node_afi(vty
),
6170 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
6173 ALIAS_HIDDEN(neighbor_addpath_tx_bestpath_per_as
,
6174 neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6175 "neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6176 NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6177 "Use addpath to advertise the bestpath per each neighboring AS\n")
6179 DEFUN (no_neighbor_addpath_tx_bestpath_per_as
,
6180 no_neighbor_addpath_tx_bestpath_per_as_cmd
,
6181 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6185 "Use addpath to advertise the bestpath per each neighboring AS\n")
6188 return peer_af_flag_unset_vty(vty
, argv
[idx_peer
]->arg
,
6189 bgp_node_afi(vty
), bgp_node_safi(vty
),
6190 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
);
6193 ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as
,
6194 no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
,
6195 "no neighbor <A.B.C.D|X:X::X:X|WORD> addpath-tx-bestpath-per-AS",
6196 NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
6197 "Use addpath to advertise the bestpath per each neighboring AS\n")
6199 static int set_ecom_list(struct vty
*vty
, int argc
, struct cmd_token
**argv
,
6200 struct ecommunity
**list
)
6202 struct ecommunity
*ecom
= NULL
;
6203 struct ecommunity
*ecomadd
;
6205 for (; argc
; --argc
, ++argv
) {
6207 ecomadd
= ecommunity_str2com(argv
[0]->arg
,
6208 ECOMMUNITY_ROUTE_TARGET
, 0);
6210 vty_out(vty
, "Malformed community-list value\n");
6212 ecommunity_free(&ecom
);
6213 return CMD_WARNING_CONFIG_FAILED
;
6217 ecommunity_merge(ecom
, ecomadd
);
6218 ecommunity_free(&ecomadd
);
6225 ecommunity_free(&*list
);
6233 * v2vimport is true if we are handling a `import vrf ...` command
6235 static afi_t
vpn_policy_getafi(struct vty
*vty
, struct bgp
*bgp
, bool v2vimport
)
6239 switch (vty
->node
) {
6248 "%% context error: valid only in address-family <ipv4|ipv6> unicast block\n");
6253 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6254 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
6255 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6256 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
6258 "%% error: Please unconfigure import vrf commands before using vpn commands\n");
6262 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6263 BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
)
6264 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
6265 BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
)) {
6267 "%% error: Please unconfigure vpn to vrf commands before using import vrf commands\n");
6274 DEFPY (af_rd_vpn_export
,
6275 af_rd_vpn_export_cmd
,
6276 "[no] rd vpn export ASN:NN_OR_IP-ADDRESS:NN$rd_str",
6278 "Specify route distinguisher\n"
6279 "Between current address-family and vpn\n"
6280 "For routes leaked from current address-family to vpn\n"
6281 "Route Distinguisher (<as-number>:<number> | <ip-address>:<number>)\n")
6283 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6284 struct prefix_rd prd
;
6290 if (argv_find(argv
, argc
, "no", &idx
))
6294 ret
= str2prefix_rd(rd_str
, &prd
);
6296 vty_out(vty
, "%% Malformed rd\n");
6297 return CMD_WARNING_CONFIG_FAILED
;
6301 afi
= vpn_policy_getafi(vty
, bgp
, false);
6303 return CMD_WARNING_CONFIG_FAILED
;
6306 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6308 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6309 bgp_get_default(), bgp
);
6312 bgp
->vpn_policy
[afi
].tovpn_rd
= prd
;
6313 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6314 BGP_VPN_POLICY_TOVPN_RD_SET
);
6316 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6317 BGP_VPN_POLICY_TOVPN_RD_SET
);
6320 /* post-change: re-export vpn routes */
6321 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6322 bgp_get_default(), bgp
);
6327 ALIAS (af_rd_vpn_export
,
6328 af_no_rd_vpn_export_cmd
,
6331 "Specify route distinguisher\n"
6332 "Between current address-family and vpn\n"
6333 "For routes leaked from current address-family to vpn\n")
6335 DEFPY (af_label_vpn_export
,
6336 af_label_vpn_export_cmd
,
6337 "[no] label vpn export <(0-1048575)$label_val|auto$label_auto>",
6339 "label value for VRF\n"
6340 "Between current address-family and vpn\n"
6341 "For routes leaked from current address-family to vpn\n"
6342 "Label Value <0-1048575>\n"
6343 "Automatically assign a label\n")
6345 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6346 mpls_label_t label
= MPLS_LABEL_NONE
;
6351 if (argv_find(argv
, argc
, "no", &idx
))
6354 /* If "no ...", squash trailing parameter */
6360 label
= label_val
; /* parser should force unsigned */
6363 afi
= vpn_policy_getafi(vty
, bgp
, false);
6365 return CMD_WARNING_CONFIG_FAILED
;
6368 if (label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6369 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
))
6374 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6376 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6377 bgp_get_default(), bgp
);
6379 if (!label_auto
&& CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
6380 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
6382 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
6385 * label has previously been automatically
6386 * assigned by labelpool: release it
6388 * NB if tovpn_label == MPLS_LABEL_NONE it
6389 * means the automatic assignment is in flight
6390 * and therefore the labelpool callback must
6391 * detect that the auto label is not needed.
6394 bgp_lp_release(LP_TYPE_VRF
,
6395 &bgp
->vpn_policy
[afi
],
6396 bgp
->vpn_policy
[afi
].tovpn_label
);
6398 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6399 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6402 bgp
->vpn_policy
[afi
].tovpn_label
= label
;
6404 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6405 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
);
6406 bgp_lp_get(LP_TYPE_VRF
, &bgp
->vpn_policy
[afi
],
6407 vpn_leak_label_callback
);
6410 /* post-change: re-export vpn routes */
6411 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6412 bgp_get_default(), bgp
);
6417 ALIAS (af_label_vpn_export
,
6418 af_no_label_vpn_export_cmd
,
6419 "no label vpn export",
6421 "label value for VRF\n"
6422 "Between current address-family and vpn\n"
6423 "For routes leaked from current address-family to vpn\n")
6425 DEFPY (af_nexthop_vpn_export
,
6426 af_nexthop_vpn_export_cmd
,
6427 "[no] nexthop vpn export <A.B.C.D|X:X::X:X>$nexthop_str",
6429 "Specify next hop to use for VRF advertised prefixes\n"
6430 "Between current address-family and vpn\n"
6431 "For routes leaked from current address-family to vpn\n"
6435 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6441 if (argv_find(argv
, argc
, "no", &idx
))
6445 if (!sockunion2hostprefix(nexthop_str
, &p
))
6446 return CMD_WARNING_CONFIG_FAILED
;
6449 afi
= vpn_policy_getafi(vty
, bgp
, false);
6451 return CMD_WARNING_CONFIG_FAILED
;
6454 * pre-change: un-export vpn routes (vpn->vrf routes unaffected)
6456 vpn_leak_prechange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6457 bgp_get_default(), bgp
);
6460 bgp
->vpn_policy
[afi
].tovpn_nexthop
= p
;
6461 SET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6462 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6464 UNSET_FLAG(bgp
->vpn_policy
[afi
].flags
,
6465 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
);
6468 /* post-change: re-export vpn routes */
6469 vpn_leak_postchange(BGP_VPN_POLICY_DIR_TOVPN
, afi
,
6470 bgp_get_default(), bgp
);
6475 ALIAS (af_nexthop_vpn_export
,
6476 af_no_nexthop_vpn_export_cmd
,
6477 "no nexthop vpn export",
6479 "Specify next hop to use for VRF advertised prefixes\n"
6480 "Between current address-family and vpn\n"
6481 "For routes leaked from current address-family to vpn\n")
6483 static int vpn_policy_getdirs(struct vty
*vty
, const char *dstr
, int *dodir
)
6485 if (!strcmp(dstr
, "import")) {
6486 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6487 } else if (!strcmp(dstr
, "export")) {
6488 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6489 } else if (!strcmp(dstr
, "both")) {
6490 dodir
[BGP_VPN_POLICY_DIR_FROMVPN
] = 1;
6491 dodir
[BGP_VPN_POLICY_DIR_TOVPN
] = 1;
6493 vty_out(vty
, "%% direction parse error\n");
6494 return CMD_WARNING_CONFIG_FAILED
;
6499 DEFPY (af_rt_vpn_imexport
,
6500 af_rt_vpn_imexport_cmd
,
6501 "[no] <rt|route-target> vpn <import|export|both>$direction_str RTLIST...",
6503 "Specify route target list\n"
6504 "Specify route target list\n"
6505 "Between current address-family and vpn\n"
6506 "For routes leaked from vpn to current address-family: match any\n"
6507 "For routes leaked from current address-family to vpn: set\n"
6508 "both import: match any and export: set\n"
6509 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6511 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6513 struct ecommunity
*ecom
= NULL
;
6514 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6515 vpn_policy_direction_t dir
;
6520 if (argv_find(argv
, argc
, "no", &idx
))
6523 afi
= vpn_policy_getafi(vty
, bgp
, false);
6525 return CMD_WARNING_CONFIG_FAILED
;
6527 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6528 if (ret
!= CMD_SUCCESS
)
6532 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6533 vty_out(vty
, "%% Missing RTLIST\n");
6534 return CMD_WARNING_CONFIG_FAILED
;
6536 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6537 if (ret
!= CMD_SUCCESS
) {
6542 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6546 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6549 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6551 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6552 bgp
->vpn_policy
[afi
].rtlist
[dir
] =
6553 ecommunity_dup(ecom
);
6555 if (bgp
->vpn_policy
[afi
].rtlist
[dir
])
6557 &bgp
->vpn_policy
[afi
].rtlist
[dir
]);
6558 bgp
->vpn_policy
[afi
].rtlist
[dir
] = NULL
;
6561 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6565 ecommunity_free(&ecom
);
6570 ALIAS (af_rt_vpn_imexport
,
6571 af_no_rt_vpn_imexport_cmd
,
6572 "no <rt|route-target> vpn <import|export|both>$direction_str",
6574 "Specify route target list\n"
6575 "Specify route target list\n"
6576 "Between current address-family and vpn\n"
6577 "For routes leaked from vpn to current address-family\n"
6578 "For routes leaked from current address-family to vpn\n"
6579 "both import and export\n")
6581 DEFPY (af_route_map_vpn_imexport
,
6582 af_route_map_vpn_imexport_cmd
,
6583 /* future: "route-map <vpn|evpn|vrf NAME> <import|export> RMAP" */
6584 "[no] route-map vpn <import|export>$direction_str RMAP$rmap_str",
6586 "Specify route map\n"
6587 "Between current address-family and vpn\n"
6588 "For routes leaked from vpn to current address-family\n"
6589 "For routes leaked from current address-family to vpn\n"
6590 "name of route-map\n")
6592 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6594 int dodir
[BGP_VPN_POLICY_DIR_MAX
] = {0};
6595 vpn_policy_direction_t dir
;
6600 if (argv_find(argv
, argc
, "no", &idx
))
6603 afi
= vpn_policy_getafi(vty
, bgp
, false);
6605 return CMD_WARNING_CONFIG_FAILED
;
6607 ret
= vpn_policy_getdirs(vty
, direction_str
, dodir
);
6608 if (ret
!= CMD_SUCCESS
)
6611 for (dir
= 0; dir
< BGP_VPN_POLICY_DIR_MAX
; ++dir
) {
6615 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6618 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6619 XFREE(MTYPE_ROUTE_MAP_NAME
,
6620 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6621 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = XSTRDUP(
6622 MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6623 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6624 route_map_lookup_by_name(rmap_str
);
6625 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6628 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6629 XFREE(MTYPE_ROUTE_MAP_NAME
,
6630 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6631 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6632 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6635 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6641 ALIAS (af_route_map_vpn_imexport
,
6642 af_no_route_map_vpn_imexport_cmd
,
6643 "no route-map vpn <import|export>$direction_str",
6645 "Specify route map\n"
6646 "Between current address-family and vpn\n"
6647 "For routes leaked from vpn to current address-family\n"
6648 "For routes leaked from current address-family to vpn\n")
6650 DEFPY(af_import_vrf_route_map
, af_import_vrf_route_map_cmd
,
6651 "[no] import vrf route-map RMAP$rmap_str",
6653 "Import routes from another VRF\n"
6654 "Vrf routes being filtered\n"
6655 "Specify route map\n"
6656 "name of route-map\n")
6658 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6659 vpn_policy_direction_t dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6663 struct bgp
*bgp_default
;
6665 if (argv_find(argv
, argc
, "no", &idx
))
6668 afi
= vpn_policy_getafi(vty
, bgp
, true);
6670 return CMD_WARNING_CONFIG_FAILED
;
6672 bgp_default
= bgp_get_default();
6677 /* Auto-create assuming the same AS */
6678 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6679 BGP_INSTANCE_TYPE_DEFAULT
);
6683 "VRF default is not configured as a bgp instance\n");
6688 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6691 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6692 XFREE(MTYPE_ROUTE_MAP_NAME
,
6693 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6694 bgp
->vpn_policy
[afi
].rmap_name
[dir
] =
6695 XSTRDUP(MTYPE_ROUTE_MAP_NAME
, rmap_str
);
6696 bgp
->vpn_policy
[afi
].rmap
[dir
] =
6697 route_map_lookup_by_name(rmap_str
);
6698 if (!bgp
->vpn_policy
[afi
].rmap
[dir
])
6701 if (bgp
->vpn_policy
[afi
].rmap_name
[dir
])
6702 XFREE(MTYPE_ROUTE_MAP_NAME
,
6703 bgp
->vpn_policy
[afi
].rmap_name
[dir
]);
6704 bgp
->vpn_policy
[afi
].rmap_name
[dir
] = NULL
;
6705 bgp
->vpn_policy
[afi
].rmap
[dir
] = NULL
;
6708 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6713 ALIAS(af_import_vrf_route_map
, af_no_import_vrf_route_map_cmd
,
6714 "no import vrf route-map",
6716 "Import routes from another VRF\n"
6717 "Vrf routes being filtered\n"
6718 "Specify route map\n")
6720 DEFPY (bgp_imexport_vrf
,
6721 bgp_imexport_vrf_cmd
,
6722 "[no] import vrf NAME$import_name",
6724 "Import routes from another VRF\n"
6725 "VRF to import from\n"
6726 "The name of the VRF\n")
6728 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6729 struct listnode
*node
;
6730 struct bgp
*vrf_bgp
, *bgp_default
;
6733 bool remove
= false;
6736 enum bgp_instance_type bgp_type
= BGP_INSTANCE_TYPE_VRF
;
6740 if (argv_find(argv
, argc
, "no", &idx
))
6743 afi
= vpn_policy_getafi(vty
, bgp
, true);
6745 return CMD_WARNING_CONFIG_FAILED
;
6747 safi
= bgp_node_safi(vty
);
6749 if (((BGP_INSTANCE_TYPE_DEFAULT
== bgp
->inst_type
)
6750 && (strcmp(import_name
, BGP_DEFAULT_NAME
) == 0))
6751 || (bgp
->name
&& (strcmp(import_name
, bgp
->name
) == 0))) {
6752 vty_out(vty
, "%% Cannot %s vrf %s into itself\n",
6753 remove
? "unimport" : "import", import_name
);
6757 bgp_default
= bgp_get_default();
6759 /* Auto-create assuming the same AS */
6760 ret
= bgp_get(&bgp_default
, &as
, NULL
,
6761 BGP_INSTANCE_TYPE_DEFAULT
);
6765 "VRF default is not configured as a bgp instance\n");
6770 vrf_bgp
= bgp_lookup_by_name(import_name
);
6772 if (strcmp(import_name
, BGP_DEFAULT_NAME
) == 0)
6773 vrf_bgp
= bgp_default
;
6775 /* Auto-create assuming the same AS */
6776 ret
= bgp_get(&vrf_bgp
, &as
, import_name
, bgp_type
);
6780 "VRF %s is not configured as a bgp instance\n",
6787 vrf_unimport_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6789 /* Already importing from "import_vrf"? */
6790 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
6792 if (strcmp(vname
, import_name
) == 0)
6796 vrf_import_from_vrf(bgp
, vrf_bgp
, afi
, safi
);
6802 /* This command is valid only in a bgp vrf instance or the default instance */
6803 DEFPY (bgp_imexport_vpn
,
6804 bgp_imexport_vpn_cmd
,
6805 "[no] <import|export>$direction_str vpn",
6807 "Import routes to this address-family\n"
6808 "Export routes from this address-family\n"
6809 "to/from default instance VPN RIB\n")
6811 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6818 vpn_policy_direction_t dir
;
6820 if (argv_find(argv
, argc
, "no", &idx
))
6823 if (BGP_INSTANCE_TYPE_VRF
!= bgp
->inst_type
&&
6824 BGP_INSTANCE_TYPE_DEFAULT
!= bgp
->inst_type
) {
6826 vty_out(vty
, "%% import|export vpn valid only for bgp vrf or default instance\n");
6827 return CMD_WARNING_CONFIG_FAILED
;
6830 afi
= bgp_node_afi(vty
);
6831 safi
= bgp_node_safi(vty
);
6832 if ((SAFI_UNICAST
!= safi
) || ((AFI_IP
!= afi
) && (AFI_IP6
!= afi
))) {
6833 vty_out(vty
, "%% import|export vpn valid only for unicast ipv4|ipv6\n");
6834 return CMD_WARNING_CONFIG_FAILED
;
6837 if (!strcmp(direction_str
, "import")) {
6838 flag
= BGP_CONFIG_MPLSVPN_TO_VRF_IMPORT
;
6839 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
6840 } else if (!strcmp(direction_str
, "export")) {
6841 flag
= BGP_CONFIG_VRF_TO_MPLSVPN_EXPORT
;
6842 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
6844 vty_out(vty
, "%% unknown direction %s\n", direction_str
);
6845 return CMD_WARNING_CONFIG_FAILED
;
6848 previous_state
= CHECK_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6851 SET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6852 if (!previous_state
) {
6853 /* trigger export current vrf */
6854 vpn_leak_postchange(dir
, afi
, bgp_get_default(), bgp
);
6857 if (previous_state
) {
6858 /* trigger un-export current vrf */
6859 vpn_leak_prechange(dir
, afi
, bgp_get_default(), bgp
);
6861 UNSET_FLAG(bgp
->af_flags
[afi
][safi
], flag
);
6867 DEFPY (af_routetarget_import
,
6868 af_routetarget_import_cmd
,
6869 "[no] <rt|route-target> redirect import RTLIST...",
6871 "Specify route target list\n"
6872 "Specify route target list\n"
6873 "Flow-spec redirect type route target\n"
6874 "Import routes to this address-family\n"
6875 "Space separated route target list (A.B.C.D:MN|EF:OPQR|GHJK:MN)\n")
6877 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6879 struct ecommunity
*ecom
= NULL
;
6884 if (argv_find(argv
, argc
, "no", &idx
))
6887 afi
= vpn_policy_getafi(vty
, bgp
, false);
6889 return CMD_WARNING_CONFIG_FAILED
;
6892 if (!argv_find(argv
, argc
, "RTLIST", &idx
)) {
6893 vty_out(vty
, "%% Missing RTLIST\n");
6894 return CMD_WARNING_CONFIG_FAILED
;
6896 ret
= set_ecom_list(vty
, argc
- idx
, argv
+ idx
, &ecom
);
6897 if (ret
!= CMD_SUCCESS
)
6902 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
6903 ecommunity_free(&bgp
->vpn_policy
[afi
]
6904 .import_redirect_rtlist
);
6905 bgp
->vpn_policy
[afi
].import_redirect_rtlist
=
6906 ecommunity_dup(ecom
);
6908 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
)
6909 ecommunity_free(&bgp
->vpn_policy
[afi
]
6910 .import_redirect_rtlist
);
6911 bgp
->vpn_policy
[afi
].import_redirect_rtlist
= NULL
;
6915 ecommunity_free(&ecom
);
6920 DEFUN_NOSH (address_family_ipv4_safi
,
6921 address_family_ipv4_safi_cmd
,
6922 "address-family ipv4 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
6923 "Enter Address Family command mode\n"
6925 BGP_SAFI_WITH_LABEL_HELP_STR
)
6929 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6930 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6931 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
6932 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
6933 && safi
!= SAFI_EVPN
) {
6935 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
6936 return CMD_WARNING_CONFIG_FAILED
;
6938 vty
->node
= bgp_node_type(AFI_IP
, safi
);
6940 vty
->node
= BGP_IPV4_NODE
;
6945 DEFUN_NOSH (address_family_ipv6_safi
,
6946 address_family_ipv6_safi_cmd
,
6947 "address-family ipv6 [<unicast|multicast|vpn|labeled-unicast|flowspec>]",
6948 "Enter Address Family command mode\n"
6950 BGP_SAFI_WITH_LABEL_HELP_STR
)
6953 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
6954 safi_t safi
= bgp_vty_safi_from_str(argv
[2]->text
);
6955 if (bgp
->inst_type
!= BGP_INSTANCE_TYPE_DEFAULT
6956 && safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
6957 && safi
!= SAFI_EVPN
) {
6959 "Only Unicast/Multicast/EVPN SAFIs supported in non-core instances.\n");
6960 return CMD_WARNING_CONFIG_FAILED
;
6962 vty
->node
= bgp_node_type(AFI_IP6
, safi
);
6964 vty
->node
= BGP_IPV6_NODE
;
6969 #ifdef KEEP_OLD_VPN_COMMANDS
6970 DEFUN_NOSH (address_family_vpnv4
,
6971 address_family_vpnv4_cmd
,
6972 "address-family vpnv4 [unicast]",
6973 "Enter Address Family command mode\n"
6975 "Address Family modifier\n")
6977 vty
->node
= BGP_VPNV4_NODE
;
6981 DEFUN_NOSH (address_family_vpnv6
,
6982 address_family_vpnv6_cmd
,
6983 "address-family vpnv6 [unicast]",
6984 "Enter Address Family command mode\n"
6986 "Address Family modifier\n")
6988 vty
->node
= BGP_VPNV6_NODE
;
6993 DEFUN_NOSH (address_family_evpn
,
6994 address_family_evpn_cmd
,
6995 "address-family l2vpn evpn",
6996 "Enter Address Family command mode\n"
6998 "Address Family modifier\n")
7000 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
7001 vty
->node
= BGP_EVPN_NODE
;
7005 DEFUN_NOSH (exit_address_family
,
7006 exit_address_family_cmd
,
7007 "exit-address-family",
7008 "Exit from Address Family configuration mode\n")
7010 if (vty
->node
== BGP_IPV4_NODE
|| vty
->node
== BGP_IPV4M_NODE
7011 || vty
->node
== BGP_IPV4L_NODE
|| vty
->node
== BGP_VPNV4_NODE
7012 || vty
->node
== BGP_IPV6_NODE
|| vty
->node
== BGP_IPV6M_NODE
7013 || vty
->node
== BGP_IPV6L_NODE
|| vty
->node
== BGP_VPNV6_NODE
7014 || vty
->node
== BGP_EVPN_NODE
7015 || vty
->node
== BGP_FLOWSPECV4_NODE
7016 || vty
->node
== BGP_FLOWSPECV6_NODE
)
7017 vty
->node
= BGP_NODE
;
7021 /* Recalculate bestpath and re-advertise a prefix */
7022 static int bgp_clear_prefix(struct vty
*vty
, const char *view_name
,
7023 const char *ip_str
, afi_t afi
, safi_t safi
,
7024 struct prefix_rd
*prd
)
7027 struct prefix match
;
7028 struct bgp_node
*rn
;
7029 struct bgp_node
*rm
;
7031 struct bgp_table
*table
;
7032 struct bgp_table
*rib
;
7034 /* BGP structure lookup. */
7036 bgp
= bgp_lookup_by_name(view_name
);
7038 vty_out(vty
, "%% Can't find BGP instance %s\n",
7043 bgp
= bgp_get_default();
7045 vty_out(vty
, "%% No BGP process is configured\n");
7050 /* Check IP address argument. */
7051 ret
= str2prefix(ip_str
, &match
);
7053 vty_out(vty
, "%% address is malformed\n");
7057 match
.family
= afi2family(afi
);
7058 rib
= bgp
->rib
[afi
][safi
];
7060 if (safi
== SAFI_MPLS_VPN
) {
7061 for (rn
= bgp_table_top(rib
); rn
; rn
= bgp_route_next(rn
)) {
7062 if (prd
&& memcmp(rn
->p
.u
.val
, prd
->val
, 8) != 0)
7065 if ((table
= rn
->info
) != NULL
) {
7066 if ((rm
= bgp_node_match(table
, &match
))
7069 == match
.prefixlen
) {
7071 BGP_NODE_USER_CLEAR
);
7072 bgp_process(bgp
, rm
, afi
, safi
);
7074 bgp_unlock_node(rm
);
7079 if ((rn
= bgp_node_match(rib
, &match
)) != NULL
) {
7080 if (rn
->p
.prefixlen
== match
.prefixlen
) {
7081 SET_FLAG(rn
->flags
, BGP_NODE_USER_CLEAR
);
7082 bgp_process(bgp
, rn
, afi
, safi
);
7084 bgp_unlock_node(rn
);
7091 /* one clear bgp command to rule them all */
7092 DEFUN (clear_ip_bgp_all
,
7093 clear_ip_bgp_all_cmd
,
7094 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> [<soft [<in|out>]|in [prefix-filter]|out>]",
7098 BGP_INSTANCE_HELP_STR
7100 BGP_SAFI_WITH_LABEL_HELP_STR
7102 "BGP neighbor address to clear\n"
7103 "BGP IPv6 neighbor to clear\n"
7104 "BGP neighbor on interface to clear\n"
7105 "Clear peers with the AS number\n"
7106 "Clear all external peers\n"
7107 "Clear all members of peer-group\n"
7108 "BGP peer-group name\n"
7113 "Push out prefix-list ORF and do inbound soft reconfig\n"
7118 afi_t afi
= AFI_IP6
;
7119 safi_t safi
= SAFI_UNICAST
;
7120 enum clear_sort clr_sort
= clear_peer
;
7121 enum bgp_clear_type clr_type
;
7122 char *clr_arg
= NULL
;
7126 /* clear [ip] bgp */
7127 if (argv_find(argv
, argc
, "ip", &idx
))
7130 /* [<view|vrf> VIEWVRFNAME] */
7131 if (argv_find(argv
, argc
, "view", &idx
)
7132 || argv_find(argv
, argc
, "vrf", &idx
)) {
7133 vrf
= argv
[idx
+ 1]->arg
;
7137 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
7138 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
))
7139 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
7141 /* <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> */
7142 if (argv_find(argv
, argc
, "*", &idx
)) {
7143 clr_sort
= clear_all
;
7144 } else if (argv_find(argv
, argc
, "A.B.C.D", &idx
)) {
7145 clr_sort
= clear_peer
;
7146 clr_arg
= argv
[idx
]->arg
;
7147 } else if (argv_find(argv
, argc
, "X:X::X:X", &idx
)) {
7148 clr_sort
= clear_peer
;
7149 clr_arg
= argv
[idx
]->arg
;
7150 } else if (argv_find(argv
, argc
, "peer-group", &idx
)) {
7151 clr_sort
= clear_group
;
7153 clr_arg
= argv
[idx
]->arg
;
7154 } else if (argv_find(argv
, argc
, "WORD", &idx
)) {
7155 clr_sort
= clear_peer
;
7156 clr_arg
= argv
[idx
]->arg
;
7157 } else if (argv_find(argv
, argc
, "(1-4294967295)", &idx
)) {
7158 clr_sort
= clear_as
;
7159 clr_arg
= argv
[idx
]->arg
;
7160 } else if (argv_find(argv
, argc
, "external", &idx
)) {
7161 clr_sort
= clear_external
;
7164 /* [<soft [<in|out>]|in [prefix-filter]|out>] */
7165 if (argv_find(argv
, argc
, "soft", &idx
)) {
7166 if (argv_find(argv
, argc
, "in", &idx
)
7167 || argv_find(argv
, argc
, "out", &idx
))
7168 clr_type
= strmatch(argv
[idx
]->text
, "in")
7170 : BGP_CLEAR_SOFT_OUT
;
7172 clr_type
= BGP_CLEAR_SOFT_BOTH
;
7173 } else if (argv_find(argv
, argc
, "in", &idx
)) {
7174 clr_type
= argv_find(argv
, argc
, "prefix-filter", &idx
)
7175 ? BGP_CLEAR_SOFT_IN_ORF_PREFIX
7176 : BGP_CLEAR_SOFT_IN
;
7177 } else if (argv_find(argv
, argc
, "out", &idx
)) {
7178 clr_type
= BGP_CLEAR_SOFT_OUT
;
7180 clr_type
= BGP_CLEAR_SOFT_NONE
;
7182 return bgp_clear_vty(vty
, vrf
, afi
, safi
, clr_sort
, clr_type
, clr_arg
);
7185 DEFUN (clear_ip_bgp_prefix
,
7186 clear_ip_bgp_prefix_cmd
,
7187 "clear [ip] bgp [<view|vrf> VIEWVRFNAME] prefix A.B.C.D/M",
7191 BGP_INSTANCE_HELP_STR
7192 "Clear bestpath and re-advertise\n"
7196 char *prefix
= NULL
;
7200 /* [<view|vrf> VIEWVRFNAME] */
7201 if (argv_find(argv
, argc
, "VIEWVRFNAME", &idx
))
7202 vrf
= argv
[idx
]->arg
;
7204 prefix
= argv
[argc
- 1]->arg
;
7206 return bgp_clear_prefix(vty
, vrf
, prefix
, AFI_IP
, SAFI_UNICAST
, NULL
);
7209 DEFUN (clear_bgp_ipv6_safi_prefix
,
7210 clear_bgp_ipv6_safi_prefix_cmd
,
7211 "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7217 "Clear bestpath and re-advertise\n"
7221 int idx_ipv6_prefix
= 0;
7222 safi_t safi
= SAFI_UNICAST
;
7223 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7224 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7226 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7227 return bgp_clear_prefix(
7228 vty
, NULL
, prefix
, AFI_IP6
,
7232 DEFUN (clear_bgp_instance_ipv6_safi_prefix
,
7233 clear_bgp_instance_ipv6_safi_prefix_cmd
,
7234 "clear [ip] bgp <view|vrf> VIEWVRFNAME ipv6 "BGP_SAFI_CMD_STR
" prefix X:X::X:X/M",
7238 BGP_INSTANCE_HELP_STR
7241 "Clear bestpath and re-advertise\n"
7246 int idx_ipv6_prefix
= 0;
7247 safi_t safi
= SAFI_UNICAST
;
7248 char *prefix
= argv_find(argv
, argc
, "X:X::X:X/M", &idx_ipv6_prefix
) ?
7249 argv
[idx_ipv6_prefix
]->arg
: NULL
;
7250 /* [<view|vrf> VIEWVRFNAME] */
7251 char *vrfview
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx_word
) ?
7252 argv
[idx_word
]->arg
: NULL
;
7254 argv_find_and_parse_safi(argv
, argc
, &idx_safi
, &safi
);
7256 return bgp_clear_prefix(
7257 vty
, vrfview
, prefix
,
7258 AFI_IP6
, safi
, NULL
);
7261 DEFUN (show_bgp_views
,
7263 "show [ip] bgp views",
7267 "Show the defined BGP views\n")
7269 struct list
*inst
= bm
->bgp
;
7270 struct listnode
*node
;
7273 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7274 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7278 vty_out(vty
, "Defined BGP views:\n");
7279 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7281 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VRF
)
7283 vty_out(vty
, "\t%s (AS%u)\n", bgp
->name
? bgp
->name
: "(null)",
7290 DEFUN (show_bgp_vrfs
,
7292 "show [ip] bgp vrfs [json]",
7299 char buf
[ETHER_ADDR_STRLEN
];
7300 struct list
*inst
= bm
->bgp
;
7301 struct listnode
*node
;
7303 uint8_t uj
= use_json(argc
, argv
);
7304 json_object
*json
= NULL
;
7305 json_object
*json_vrfs
= NULL
;
7308 if (!bgp_option_check(BGP_OPT_MULTIPLE_INSTANCE
)) {
7309 vty_out(vty
, "BGP Multiple Instance is not enabled\n");
7314 json
= json_object_new_object();
7315 json_vrfs
= json_object_new_object();
7318 for (ALL_LIST_ELEMENTS_RO(inst
, node
, bgp
)) {
7319 const char *name
, *type
;
7321 struct listnode
*node
, *nnode
;
7322 int peers_cfg
, peers_estb
;
7323 json_object
*json_vrf
= NULL
;
7326 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_VIEW
)
7330 if (!uj
&& count
== 1)
7332 "%4s %-5s %-16s %9s %10s %-37s %-10s %-15s\n",
7333 "Type", "Id", "routerId", "#PeersVfg",
7334 "#PeersEstb", "Name", "L3-VNI", "Rmac");
7336 peers_cfg
= peers_estb
= 0;
7338 json_vrf
= json_object_new_object();
7341 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7342 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7345 if (peer
->status
== Established
)
7349 if (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
) {
7359 int64_t vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7361 : (int64_t)bgp
->vrf_id
;
7362 json_object_string_add(json_vrf
, "type", type
);
7363 json_object_int_add(json_vrf
, "vrfId", vrf_id_ui
);
7364 json_object_string_add(json_vrf
, "routerId",
7365 inet_ntoa(bgp
->router_id
));
7366 json_object_int_add(json_vrf
, "numConfiguredPeers",
7368 json_object_int_add(json_vrf
, "numEstablishedPeers",
7371 json_object_int_add(json_vrf
, "l3vni", bgp
->l3vni
);
7372 json_object_string_add(
7374 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7375 json_object_object_add(json_vrfs
, name
, json_vrf
);
7378 "%4s %-5d %-16s %9u %10u %-37s %-10u %-15s\n",
7380 bgp
->vrf_id
== VRF_UNKNOWN
? -1
7382 inet_ntoa(bgp
->router_id
), peers_cfg
,
7383 peers_estb
, name
, bgp
->l3vni
,
7384 prefix_mac2str(&bgp
->rmac
, buf
, sizeof(buf
)));
7388 json_object_object_add(json
, "vrfs", json_vrfs
);
7390 json_object_int_add(json
, "totalVrfs", count
);
7392 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
7393 json
, JSON_C_TO_STRING_PRETTY
));
7394 json_object_free(json
);
7398 "\nTotal number of VRFs (including default): %d\n",
7405 static void show_address_entry(struct hash_backet
*backet
, void *args
)
7407 struct vty
*vty
= (struct vty
*)args
;
7408 struct bgp_addr
*addr
= (struct bgp_addr
*)backet
->data
;
7410 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(addr
->addr
),
7414 static void show_tip_entry(struct hash_backet
*backet
, void *args
)
7416 struct vty
*vty
= (struct vty
*)args
;
7417 struct tip_addr
*tip
= (struct tip_addr
*)backet
->data
;
7419 vty_out(vty
, "addr: %s, count: %d\n", inet_ntoa(tip
->addr
),
7423 static void bgp_show_martian_nexthops(struct vty
*vty
, struct bgp
*bgp
)
7425 vty_out(vty
, "self nexthop database:\n");
7426 hash_iterate(bgp
->address_hash
,
7427 (void (*)(struct hash_backet
*, void *))show_address_entry
,
7430 vty_out(vty
, "Tunnel-ip database:\n");
7431 hash_iterate(bgp
->tip_hash
,
7432 (void (*)(struct hash_backet
*, void *))show_tip_entry
,
7436 DEFUN(show_bgp_martian_nexthop_db
, show_bgp_martian_nexthop_db_cmd
,
7437 "show bgp [<view|vrf> VIEWVRFNAME] martian next-hop",
7438 SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR
7439 "martian next-hops\n"
7440 "martian next-hop database\n")
7442 struct bgp
*bgp
= NULL
;
7445 if (argv_find(argv
, argc
, "view", &idx
)
7446 || argv_find(argv
, argc
, "vrf", &idx
))
7447 bgp
= bgp_lookup_by_name(argv
[idx
+ 1]->arg
);
7449 bgp
= bgp_get_default();
7452 vty_out(vty
, "%% No BGP process is configured\n");
7455 bgp_show_martian_nexthops(vty
, bgp
);
7460 DEFUN (show_bgp_memory
,
7461 show_bgp_memory_cmd
,
7462 "show [ip] bgp memory",
7466 "Global BGP memory statistics\n")
7468 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7469 unsigned long count
;
7471 /* RIB related usage stats */
7472 count
= mtype_stats_alloc(MTYPE_BGP_NODE
);
7473 vty_out(vty
, "%ld RIB nodes, using %s of memory\n", count
,
7474 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7475 count
* sizeof(struct bgp_node
)));
7477 count
= mtype_stats_alloc(MTYPE_BGP_ROUTE
);
7478 vty_out(vty
, "%ld BGP routes, using %s of memory\n", count
,
7479 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7480 count
* sizeof(struct bgp_info
)));
7481 if ((count
= mtype_stats_alloc(MTYPE_BGP_ROUTE_EXTRA
)))
7482 vty_out(vty
, "%ld BGP route ancillaries, using %s of memory\n",
7484 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7485 count
* sizeof(struct bgp_info_extra
)));
7487 if ((count
= mtype_stats_alloc(MTYPE_BGP_STATIC
)))
7488 vty_out(vty
, "%ld Static routes, using %s of memory\n", count
,
7489 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7490 count
* sizeof(struct bgp_static
)));
7492 if ((count
= mtype_stats_alloc(MTYPE_BGP_PACKET
)))
7493 vty_out(vty
, "%ld Packets, using %s of memory\n", count
,
7494 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7495 count
* sizeof(struct bpacket
)));
7498 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_IN
)))
7499 vty_out(vty
, "%ld Adj-In entries, using %s of memory\n", count
,
7500 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7501 count
* sizeof(struct bgp_adj_in
)));
7502 if ((count
= mtype_stats_alloc(MTYPE_BGP_ADJ_OUT
)))
7503 vty_out(vty
, "%ld Adj-Out entries, using %s of memory\n", count
,
7504 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7505 count
* sizeof(struct bgp_adj_out
)));
7507 if ((count
= mtype_stats_alloc(MTYPE_BGP_NEXTHOP_CACHE
)))
7508 vty_out(vty
, "%ld Nexthop cache entries, using %s of memory\n",
7510 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7511 count
* sizeof(struct bgp_nexthop_cache
)));
7513 if ((count
= mtype_stats_alloc(MTYPE_BGP_DAMP_INFO
)))
7514 vty_out(vty
, "%ld Dampening entries, using %s of memory\n",
7516 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7517 count
* sizeof(struct bgp_damp_info
)));
7520 count
= attr_count();
7521 vty_out(vty
, "%ld BGP attributes, using %s of memory\n", count
,
7522 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7523 count
* sizeof(struct attr
)));
7525 if ((count
= attr_unknown_count()))
7526 vty_out(vty
, "%ld unknown attributes\n", count
);
7528 /* AS_PATH attributes */
7529 count
= aspath_count();
7530 vty_out(vty
, "%ld BGP AS-PATH entries, using %s of memory\n", count
,
7531 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7532 count
* sizeof(struct aspath
)));
7534 count
= mtype_stats_alloc(MTYPE_AS_SEG
);
7535 vty_out(vty
, "%ld BGP AS-PATH segments, using %s of memory\n", count
,
7536 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7537 count
* sizeof(struct assegment
)));
7539 /* Other attributes */
7540 if ((count
= community_count()))
7541 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7542 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7543 count
* sizeof(struct community
)));
7544 if ((count
= mtype_stats_alloc(MTYPE_ECOMMUNITY
)))
7545 vty_out(vty
, "%ld BGP community entries, using %s of memory\n",
7546 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7547 count
* sizeof(struct ecommunity
)));
7548 if ((count
= mtype_stats_alloc(MTYPE_LCOMMUNITY
)))
7550 "%ld BGP large-community entries, using %s of memory\n",
7551 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7552 count
* sizeof(struct lcommunity
)));
7554 if ((count
= mtype_stats_alloc(MTYPE_CLUSTER
)))
7555 vty_out(vty
, "%ld Cluster lists, using %s of memory\n", count
,
7556 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7557 count
* sizeof(struct cluster_list
)));
7559 /* Peer related usage */
7560 count
= mtype_stats_alloc(MTYPE_BGP_PEER
);
7561 vty_out(vty
, "%ld peers, using %s of memory\n", count
,
7562 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7563 count
* sizeof(struct peer
)));
7565 if ((count
= mtype_stats_alloc(MTYPE_PEER_GROUP
)))
7566 vty_out(vty
, "%ld peer groups, using %s of memory\n", count
,
7567 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7568 count
* sizeof(struct peer_group
)));
7571 if ((count
= mtype_stats_alloc(MTYPE_HASH
)))
7572 vty_out(vty
, "%ld hash tables, using %s of memory\n", count
,
7573 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7574 count
* sizeof(struct hash
)));
7575 if ((count
= mtype_stats_alloc(MTYPE_HASH_BACKET
)))
7576 vty_out(vty
, "%ld hash buckets, using %s of memory\n", count
,
7577 mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7578 count
* sizeof(struct hash_backet
)));
7579 if ((count
= mtype_stats_alloc(MTYPE_BGP_REGEXP
)))
7580 vty_out(vty
, "%ld compiled regexes, using %s of memory\n",
7581 count
, mtype_memstr(memstrbuf
, sizeof(memstrbuf
),
7582 count
* sizeof(regex_t
)));
7586 static void bgp_show_bestpath_json(struct bgp
*bgp
, json_object
*json
)
7588 json_object
*bestpath
= json_object_new_object();
7590 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_IGNORE
))
7591 json_object_string_add(bestpath
, "asPath", "ignore");
7593 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_CONFED
))
7594 json_object_string_add(bestpath
, "asPath", "confed");
7596 if (bgp_flag_check(bgp
, BGP_FLAG_ASPATH_MULTIPATH_RELAX
)) {
7597 if (bgp_flag_check(bgp
, BGP_FLAG_MULTIPATH_RELAX_AS_SET
))
7598 json_object_string_add(bestpath
, "multiPathRelax",
7601 json_object_string_add(bestpath
, "multiPathRelax",
7604 json_object_string_add(bestpath
, "multiPathRelax", "false");
7606 if (bgp_flag_check(bgp
, BGP_FLAG_COMPARE_ROUTER_ID
))
7607 json_object_string_add(bestpath
, "compareRouterId", "true");
7608 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
)
7609 || bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
)) {
7610 if (bgp_flag_check(bgp
, BGP_FLAG_MED_CONFED
))
7611 json_object_string_add(bestpath
, "med", "confed");
7612 if (bgp_flag_check(bgp
, BGP_FLAG_MED_MISSING_AS_WORST
))
7613 json_object_string_add(bestpath
, "med",
7614 "missing-as-worst");
7616 json_object_string_add(bestpath
, "med", "true");
7619 json_object_object_add(json
, "bestPath", bestpath
);
7622 /* Show BGP peer's summary information. */
7623 static int bgp_show_summary(struct vty
*vty
, struct bgp
*bgp
, int afi
, int safi
,
7624 uint8_t use_json
, json_object
*json
)
7627 struct listnode
*node
, *nnode
;
7628 unsigned int count
= 0, dn_count
= 0;
7629 char timebuf
[BGP_UPTIME_LEN
], dn_flag
[2];
7630 char neighbor_buf
[VTY_BUFSIZ
];
7631 int neighbor_col_default_width
= 16;
7633 int max_neighbor_width
= 0;
7635 json_object
*json_peer
= NULL
;
7636 json_object
*json_peers
= NULL
;
7638 /* labeled-unicast routes are installed in the unicast table so in order
7640 * display the correct PfxRcd value we must look at SAFI_UNICAST
7642 if (safi
== SAFI_LABELED_UNICAST
)
7643 pfx_rcd_safi
= SAFI_UNICAST
;
7645 pfx_rcd_safi
= safi
;
7649 json
= json_object_new_object();
7651 json_peers
= json_object_new_object();
7653 /* Loop over all neighbors that will be displayed to determine
7655 * characters are needed for the Neighbor column
7657 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7658 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7661 if (peer
->afc
[afi
][safi
]) {
7662 memset(dn_flag
, '\0', sizeof(dn_flag
));
7663 if (peer_dynamic_neighbor(peer
))
7667 && bgp_flag_check(bgp
,
7668 BGP_FLAG_SHOW_HOSTNAME
))
7669 sprintf(neighbor_buf
, "%s%s(%s) ",
7670 dn_flag
, peer
->hostname
,
7673 sprintf(neighbor_buf
, "%s%s ", dn_flag
,
7676 len
= strlen(neighbor_buf
);
7678 if (len
> max_neighbor_width
)
7679 max_neighbor_width
= len
;
7683 /* Originally we displayed the Neighbor column as 16
7684 * characters wide so make that the default
7686 if (max_neighbor_width
< neighbor_col_default_width
)
7687 max_neighbor_width
= neighbor_col_default_width
;
7690 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
7691 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
7694 if (!peer
->afc
[afi
][safi
])
7699 char memstrbuf
[MTYPE_MEMSTR_LEN
];
7702 vrf_id_ui
= (bgp
->vrf_id
== VRF_UNKNOWN
)
7704 : (int64_t)bgp
->vrf_id
;
7706 /* Usage summary and header */
7708 json_object_string_add(
7710 inet_ntoa(bgp
->router_id
));
7711 json_object_int_add(json
, "as", bgp
->as
);
7712 json_object_int_add(json
, "vrfId", vrf_id_ui
);
7713 json_object_string_add(
7716 == BGP_INSTANCE_TYPE_DEFAULT
)
7721 "BGP router identifier %s, local AS number %u vrf-id %d",
7722 inet_ntoa(bgp
->router_id
), bgp
->as
,
7723 bgp
->vrf_id
== VRF_UNKNOWN
7725 : (int)bgp
->vrf_id
);
7729 if (bgp_update_delay_configured(bgp
)) {
7731 json_object_int_add(
7732 json
, "updateDelayLimit",
7733 bgp
->v_update_delay
);
7735 if (bgp
->v_update_delay
7736 != bgp
->v_establish_wait
)
7737 json_object_int_add(
7739 "updateDelayEstablishWait",
7740 bgp
->v_establish_wait
);
7742 if (bgp_update_delay_active(bgp
)) {
7743 json_object_string_add(
7745 "updateDelayFirstNeighbor",
7746 bgp
->update_delay_begin_time
);
7747 json_object_boolean_true_add(
7749 "updateDelayInProgress");
7751 if (bgp
->update_delay_over
) {
7752 json_object_string_add(
7754 "updateDelayFirstNeighbor",
7755 bgp
->update_delay_begin_time
);
7756 json_object_string_add(
7758 "updateDelayBestpathResumed",
7759 bgp
->update_delay_end_time
);
7760 json_object_string_add(
7762 "updateDelayZebraUpdateResume",
7763 bgp
->update_delay_zebra_resume_time
);
7764 json_object_string_add(
7766 "updateDelayPeerUpdateResume",
7767 bgp
->update_delay_peers_resume_time
);
7772 "Read-only mode update-delay limit: %d seconds\n",
7773 bgp
->v_update_delay
);
7774 if (bgp
->v_update_delay
7775 != bgp
->v_establish_wait
)
7777 " Establish wait: %d seconds\n",
7778 bgp
->v_establish_wait
);
7780 if (bgp_update_delay_active(bgp
)) {
7782 " First neighbor established: %s\n",
7783 bgp
->update_delay_begin_time
);
7785 " Delay in progress\n");
7787 if (bgp
->update_delay_over
) {
7789 " First neighbor established: %s\n",
7790 bgp
->update_delay_begin_time
);
7792 " Best-paths resumed: %s\n",
7793 bgp
->update_delay_end_time
);
7795 " zebra update resumed: %s\n",
7796 bgp
->update_delay_zebra_resume_time
);
7798 " peers update resumed: %s\n",
7799 bgp
->update_delay_peers_resume_time
);
7806 if (bgp_maxmed_onstartup_configured(bgp
)
7807 && bgp
->maxmed_active
)
7808 json_object_boolean_true_add(
7809 json
, "maxMedOnStartup");
7810 if (bgp
->v_maxmed_admin
)
7811 json_object_boolean_true_add(
7812 json
, "maxMedAdministrative");
7814 json_object_int_add(
7815 json
, "tableVersion",
7816 bgp_table_version(bgp
->rib
[afi
][safi
]));
7818 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7819 json_object_int_add(json
, "ribCount", ents
);
7820 json_object_int_add(
7822 ents
* sizeof(struct bgp_node
));
7824 ents
= listcount(bgp
->peer
);
7825 json_object_int_add(json
, "peerCount", ents
);
7826 json_object_int_add(json
, "peerMemory",
7827 ents
* sizeof(struct peer
));
7829 if ((ents
= listcount(bgp
->group
))) {
7830 json_object_int_add(
7831 json
, "peerGroupCount", ents
);
7832 json_object_int_add(
7833 json
, "peerGroupMemory",
7834 ents
* sizeof(struct
7838 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7839 BGP_CONFIG_DAMPENING
))
7840 json_object_boolean_true_add(
7841 json
, "dampeningEnabled");
7843 if (bgp_maxmed_onstartup_configured(bgp
)
7844 && bgp
->maxmed_active
)
7846 "Max-med on-startup active\n");
7847 if (bgp
->v_maxmed_admin
)
7849 "Max-med administrative active\n");
7851 vty_out(vty
, "BGP table version %" PRIu64
"\n",
7852 bgp_table_version(bgp
->rib
[afi
][safi
]));
7854 ents
= bgp_table_count(bgp
->rib
[afi
][safi
]);
7856 "RIB entries %ld, using %s of memory\n",
7858 mtype_memstr(memstrbuf
,
7860 ents
* sizeof(struct
7863 /* Peer related usage */
7864 ents
= listcount(bgp
->peer
);
7865 vty_out(vty
, "Peers %ld, using %s of memory\n",
7868 memstrbuf
, sizeof(memstrbuf
),
7869 ents
* sizeof(struct peer
)));
7871 if ((ents
= listcount(bgp
->group
)))
7873 "Peer groups %ld, using %s of memory\n",
7878 ents
* sizeof(struct
7881 if (CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
7882 BGP_CONFIG_DAMPENING
))
7883 vty_out(vty
, "Dampening enabled.\n");
7886 /* Subtract 8 here because 'Neighbor' is
7888 vty_out(vty
, "Neighbor");
7889 vty_out(vty
, "%*s", max_neighbor_width
- 8,
7892 "V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd\n");
7899 json_peer
= json_object_new_object();
7901 if (peer_dynamic_neighbor(peer
))
7902 json_object_boolean_true_add(json_peer
,
7906 json_object_string_add(json_peer
, "hostname",
7909 if (peer
->domainname
)
7910 json_object_string_add(json_peer
, "domainname",
7913 json_object_int_add(json_peer
, "remoteAs", peer
->as
);
7914 json_object_int_add(json_peer
, "version", 4);
7915 json_object_int_add(json_peer
, "msgRcvd",
7916 PEER_TOTAL_RX(peer
));
7917 json_object_int_add(json_peer
, "msgSent",
7918 PEER_TOTAL_TX(peer
));
7920 json_object_int_add(json_peer
, "tableVersion",
7921 peer
->version
[afi
][safi
]);
7922 json_object_int_add(json_peer
, "outq",
7924 json_object_int_add(json_peer
, "inq", 0);
7925 peer_uptime(peer
->uptime
, timebuf
, BGP_UPTIME_LEN
,
7926 use_json
, json_peer
);
7927 json_object_int_add(json_peer
, "prefixReceivedCount",
7928 peer
->pcount
[afi
][pfx_rcd_safi
]);
7930 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
7931 json_object_string_add(json_peer
, "state",
7933 else if (CHECK_FLAG(peer
->sflags
,
7934 PEER_STATUS_PREFIX_OVERFLOW
))
7935 json_object_string_add(json_peer
, "state",
7938 json_object_string_add(
7940 lookup_msg(bgp_status_msg
, peer
->status
,
7944 json_object_string_add(json_peer
, "idType",
7946 else if (peer
->su
.sa
.sa_family
== AF_INET
)
7947 json_object_string_add(json_peer
, "idType",
7949 else if (peer
->su
.sa
.sa_family
== AF_INET6
)
7950 json_object_string_add(json_peer
, "idType",
7953 json_object_object_add(json_peers
, peer
->host
,
7956 memset(dn_flag
, '\0', sizeof(dn_flag
));
7957 if (peer_dynamic_neighbor(peer
)) {
7963 && bgp_flag_check(bgp
, BGP_FLAG_SHOW_HOSTNAME
))
7964 len
= vty_out(vty
, "%s%s(%s)", dn_flag
,
7965 peer
->hostname
, peer
->host
);
7967 len
= vty_out(vty
, "%s%s", dn_flag
, peer
->host
);
7969 /* pad the neighbor column with spaces */
7970 if (len
< max_neighbor_width
)
7971 vty_out(vty
, "%*s", max_neighbor_width
- len
,
7974 vty_out(vty
, "4 %10u %7u %7u %8" PRIu64
" %4d %4zd %8s",
7975 peer
->as
, PEER_TOTAL_RX(peer
),
7976 PEER_TOTAL_TX(peer
), peer
->version
[afi
][safi
],
7977 0, peer
->obuf
->count
,
7978 peer_uptime(peer
->uptime
, timebuf
,
7979 BGP_UPTIME_LEN
, 0, NULL
));
7981 if (peer
->status
== Established
)
7982 if (peer
->afc_recv
[afi
][pfx_rcd_safi
])
7983 vty_out(vty
, " %12ld",
7987 vty_out(vty
, " NoNeg");
7989 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
7990 vty_out(vty
, " Idle (Admin)");
7991 else if (CHECK_FLAG(
7993 PEER_STATUS_PREFIX_OVERFLOW
))
7994 vty_out(vty
, " Idle (PfxCt)");
7996 vty_out(vty
, " %12s",
7997 lookup_msg(bgp_status_msg
,
7998 peer
->status
, NULL
));
8005 json_object_object_add(json
, "peers", json_peers
);
8007 json_object_int_add(json
, "totalPeers", count
);
8008 json_object_int_add(json
, "dynamicPeers", dn_count
);
8010 bgp_show_bestpath_json(bgp
, json
);
8012 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
8013 json
, JSON_C_TO_STRING_PRETTY
));
8014 json_object_free(json
);
8017 vty_out(vty
, "\nTotal number of neighbors %d\n", count
);
8021 "{\"error\": {\"message\": \"No %s neighbor configured\"}}\n",
8022 afi_safi_print(afi
, safi
));
8024 vty_out(vty
, "No %s neighbor is configured\n",
8025 afi_safi_print(afi
, safi
));
8028 if (dn_count
&& !use_json
) {
8029 vty_out(vty
, "* - dynamic neighbor\n");
8030 vty_out(vty
, "%d dynamic neighbor(s), limit %d\n",
8031 dn_count
, bgp
->dynamic_neighbors_limit
);
8038 static void bgp_show_summary_afi_safi(struct vty
*vty
, struct bgp
*bgp
, int afi
,
8039 int safi
, uint8_t use_json
,
8043 int afi_wildcard
= (afi
== AFI_MAX
);
8044 int safi_wildcard
= (safi
== SAFI_MAX
);
8045 int is_wildcard
= (afi_wildcard
|| safi_wildcard
);
8046 bool json_output
= false;
8048 if (use_json
&& is_wildcard
)
8049 vty_out(vty
, "{\n");
8051 afi
= 1; /* AFI_IP */
8052 while (afi
< AFI_MAX
) {
8054 safi
= 1; /* SAFI_UNICAST */
8055 while (safi
< SAFI_MAX
) {
8056 if (bgp_afi_safi_peer_exists(bgp
, afi
, safi
)) {
8060 * So limit output to those afi/safi
8062 * actualy have something interesting in
8066 json
= json_object_new_object();
8069 vty_out(vty
, ",\n");
8073 vty_out(vty
, "\"%s\":",
8077 vty_out(vty
, "\n%s Summary:\n",
8082 bgp_show_summary(vty
, bgp
, afi
, safi
, use_json
,
8094 if (use_json
&& is_wildcard
)
8095 vty_out(vty
, "}\n");
8096 else if (use_json
&& !json_output
)
8097 vty_out(vty
, "{}\n");
8100 static void bgp_show_all_instances_summary_vty(struct vty
*vty
, afi_t afi
,
8101 safi_t safi
, uint8_t use_json
)
8103 struct listnode
*node
, *nnode
;
8105 json_object
*json
= NULL
;
8109 vty_out(vty
, "{\n");
8111 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
8113 json
= json_object_new_object();
8116 vty_out(vty
, ",\n");
8120 vty_out(vty
, "\"%s\":",
8121 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8125 vty_out(vty
, "\nInstance %s:\n",
8126 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
8130 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, json
);
8134 vty_out(vty
, "}\n");
8137 int bgp_show_summary_vty(struct vty
*vty
, const char *name
, afi_t afi
,
8138 safi_t safi
, uint8_t use_json
)
8143 if (strmatch(name
, "all")) {
8144 bgp_show_all_instances_summary_vty(vty
, afi
, safi
,
8148 bgp
= bgp_lookup_by_name(name
);
8152 vty_out(vty
, "{}\n");
8155 "%% No such BGP instance exist\n");
8159 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
,
8165 bgp
= bgp_get_default();
8168 bgp_show_summary_afi_safi(vty
, bgp
, afi
, safi
, use_json
, NULL
);
8173 /* `show [ip] bgp summary' commands. */
8174 DEFUN (show_ip_bgp_summary
,
8175 show_ip_bgp_summary_cmd
,
8176 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] summary [json]",
8180 BGP_INSTANCE_HELP_STR
8182 BGP_SAFI_WITH_LABEL_HELP_STR
8183 "Summary of BGP neighbor status\n"
8187 afi_t afi
= AFI_MAX
;
8188 safi_t safi
= SAFI_MAX
;
8193 if (argv_find(argv
, argc
, "ip", &idx
))
8195 /* [<view|vrf> VIEWVRFNAME] */
8196 if (argv_find(argv
, argc
, "view", &idx
)
8197 || argv_find(argv
, argc
, "vrf", &idx
))
8198 vrf
= argv
[++idx
]->arg
;
8199 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
8200 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
8201 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
8204 int uj
= use_json(argc
, argv
);
8206 return bgp_show_summary_vty(vty
, vrf
, afi
, safi
, uj
);
8209 const char *afi_safi_print(afi_t afi
, safi_t safi
)
8211 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8212 return "IPv4 Unicast";
8213 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8214 return "IPv4 Multicast";
8215 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8216 return "IPv4 Labeled Unicast";
8217 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8219 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8220 return "IPv4 Encap";
8221 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8222 return "IPv4 Flowspec";
8223 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8224 return "IPv6 Unicast";
8225 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8226 return "IPv6 Multicast";
8227 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8228 return "IPv6 Labeled Unicast";
8229 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8231 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8232 return "IPv6 Encap";
8233 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8234 return "IPv6 Flowspec";
8235 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8236 return "L2VPN EVPN";
8242 * Please note that we have intentionally camelCased
8243 * the return strings here. So if you want
8244 * to use this function, please ensure you
8245 * are doing this within json output
8247 const char *afi_safi_json(afi_t afi
, safi_t safi
)
8249 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8250 return "ipv4Unicast";
8251 else if (afi
== AFI_IP
&& safi
== SAFI_MULTICAST
)
8252 return "ipv4Multicast";
8253 else if (afi
== AFI_IP
&& safi
== SAFI_LABELED_UNICAST
)
8254 return "ipv4LabeledUnicast";
8255 else if (afi
== AFI_IP
&& safi
== SAFI_MPLS_VPN
)
8257 else if (afi
== AFI_IP
&& safi
== SAFI_ENCAP
)
8259 else if (afi
== AFI_IP
&& safi
== SAFI_FLOWSPEC
)
8260 return "ipv4Flowspec";
8261 else if (afi
== AFI_IP6
&& safi
== SAFI_UNICAST
)
8262 return "ipv6Unicast";
8263 else if (afi
== AFI_IP6
&& safi
== SAFI_MULTICAST
)
8264 return "ipv6Multicast";
8265 else if (afi
== AFI_IP6
&& safi
== SAFI_LABELED_UNICAST
)
8266 return "ipv6LabeledUnicast";
8267 else if (afi
== AFI_IP6
&& safi
== SAFI_MPLS_VPN
)
8269 else if (afi
== AFI_IP6
&& safi
== SAFI_ENCAP
)
8271 else if (afi
== AFI_IP6
&& safi
== SAFI_FLOWSPEC
)
8272 return "ipv6Flowspec";
8273 else if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
)
8279 /* Show BGP peer's information. */
8280 enum show_type
{ show_all
, show_peer
};
8282 static void bgp_show_peer_afi_orf_cap(struct vty
*vty
, struct peer
*p
,
8283 afi_t afi
, safi_t safi
,
8284 uint16_t adv_smcap
, uint16_t adv_rmcap
,
8285 uint16_t rcv_smcap
, uint16_t rcv_rmcap
,
8286 uint8_t use_json
, json_object
*json_pref
)
8289 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8290 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
)) {
8292 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
)
8293 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8294 json_object_string_add(json_pref
, "sendMode",
8295 "advertisedAndReceived");
8296 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8297 json_object_string_add(json_pref
, "sendMode",
8299 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8300 json_object_string_add(json_pref
, "sendMode",
8303 vty_out(vty
, " Send-mode: ");
8304 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_smcap
))
8305 vty_out(vty
, "advertised");
8306 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_smcap
))
8307 vty_out(vty
, "%sreceived",
8308 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8317 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8318 || CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
)) {
8320 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
)
8321 && CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8322 json_object_string_add(json_pref
, "recvMode",
8323 "advertisedAndReceived");
8324 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8325 json_object_string_add(json_pref
, "recvMode",
8327 else if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8328 json_object_string_add(json_pref
, "recvMode",
8331 vty_out(vty
, " Receive-mode: ");
8332 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], adv_rmcap
))
8333 vty_out(vty
, "advertised");
8334 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], rcv_rmcap
))
8335 vty_out(vty
, "%sreceived",
8336 CHECK_FLAG(p
->af_cap
[afi
][safi
],
8345 static void bgp_show_peer_afi(struct vty
*vty
, struct peer
*p
, afi_t afi
,
8346 safi_t safi
, uint8_t use_json
,
8347 json_object
*json_neigh
)
8349 struct bgp_filter
*filter
;
8350 struct peer_af
*paf
;
8351 char orf_pfx_name
[BUFSIZ
];
8353 json_object
*json_af
= NULL
;
8354 json_object
*json_prefA
= NULL
;
8355 json_object
*json_prefB
= NULL
;
8356 json_object
*json_addr
= NULL
;
8359 json_addr
= json_object_new_object();
8360 json_af
= json_object_new_object();
8361 filter
= &p
->filter
[afi
][safi
];
8363 if (peer_group_active(p
))
8364 json_object_string_add(json_addr
, "peerGroupMember",
8367 paf
= peer_af_find(p
, afi
, safi
);
8368 if (paf
&& PAF_SUBGRP(paf
)) {
8369 json_object_int_add(json_addr
, "updateGroupId",
8370 PAF_UPDGRP(paf
)->id
);
8371 json_object_int_add(json_addr
, "subGroupId",
8372 PAF_SUBGRP(paf
)->id
);
8373 json_object_int_add(json_addr
, "packetQueueLength",
8374 bpacket_queue_virtual_length(paf
));
8377 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8378 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8379 PEER_CAP_ORF_PREFIX_SM_RCV
)
8380 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8381 PEER_CAP_ORF_PREFIX_RM_ADV
)
8382 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8383 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8384 json_object_int_add(json_af
, "orfType",
8386 json_prefA
= json_object_new_object();
8387 bgp_show_peer_afi_orf_cap(vty
, p
, afi
, safi
,
8388 PEER_CAP_ORF_PREFIX_SM_ADV
,
8389 PEER_CAP_ORF_PREFIX_RM_ADV
,
8390 PEER_CAP_ORF_PREFIX_SM_RCV
,
8391 PEER_CAP_ORF_PREFIX_RM_RCV
,
8392 use_json
, json_prefA
);
8393 json_object_object_add(json_af
, "orfPrefixList",
8397 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8398 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8399 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8400 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8401 PEER_CAP_ORF_PREFIX_RM_ADV
)
8402 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8403 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8404 json_object_int_add(json_af
, "orfOldType",
8405 ORF_TYPE_PREFIX_OLD
);
8406 json_prefB
= json_object_new_object();
8407 bgp_show_peer_afi_orf_cap(
8408 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8409 PEER_CAP_ORF_PREFIX_RM_ADV
,
8410 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8411 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
,
8413 json_object_object_add(json_af
, "orfOldPrefixList",
8417 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8418 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8419 PEER_CAP_ORF_PREFIX_SM_RCV
)
8420 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8421 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8422 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8423 PEER_CAP_ORF_PREFIX_RM_ADV
)
8424 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8425 PEER_CAP_ORF_PREFIX_RM_RCV
)
8426 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8427 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8428 json_object_object_add(json_addr
, "afDependentCap",
8431 json_object_free(json_af
);
8433 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8434 orf_pfx_count
= prefix_bgp_show_prefix_list(
8435 NULL
, afi
, orf_pfx_name
, use_json
);
8437 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8438 PEER_STATUS_ORF_PREFIX_SEND
)
8440 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8441 PEER_STATUS_ORF_PREFIX_SEND
))
8442 json_object_boolean_true_add(json_neigh
,
8445 json_object_int_add(json_addr
, "orfRecvCounter",
8448 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8449 PEER_STATUS_ORF_WAIT_REFRESH
))
8450 json_object_string_add(
8451 json_addr
, "orfFirstUpdate",
8452 "deferredUntilORFOrRouteRefreshRecvd");
8454 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8455 PEER_FLAG_REFLECTOR_CLIENT
))
8456 json_object_boolean_true_add(json_addr
,
8457 "routeReflectorClient");
8458 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8459 PEER_FLAG_RSERVER_CLIENT
))
8460 json_object_boolean_true_add(json_addr
,
8461 "routeServerClient");
8462 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8463 json_object_boolean_true_add(json_addr
,
8464 "inboundSoftConfigPermit");
8466 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8467 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8468 json_object_boolean_true_add(
8470 "privateAsNumsAllReplacedInUpdatesToNbr");
8471 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8472 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8473 json_object_boolean_true_add(
8475 "privateAsNumsReplacedInUpdatesToNbr");
8476 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8477 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8478 json_object_boolean_true_add(
8480 "privateAsNumsAllRemovedInUpdatesToNbr");
8481 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8482 PEER_FLAG_REMOVE_PRIVATE_AS
))
8483 json_object_boolean_true_add(
8485 "privateAsNumsRemovedInUpdatesToNbr");
8487 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8488 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
8489 json_object_boolean_true_add(json_addr
,
8490 "addpathTxAllPaths");
8492 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8493 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
8494 json_object_boolean_true_add(json_addr
,
8495 "addpathTxBestpathPerAS");
8497 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8498 json_object_string_add(json_addr
,
8499 "overrideASNsInOutboundUpdates",
8500 "ifAspathEqualRemoteAs");
8502 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8503 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8504 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8505 json_object_boolean_true_add(json_addr
,
8506 "routerAlwaysNextHop");
8507 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8508 PEER_FLAG_AS_PATH_UNCHANGED
))
8509 json_object_boolean_true_add(
8510 json_addr
, "unchangedAsPathPropogatedToNbr");
8511 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8512 PEER_FLAG_NEXTHOP_UNCHANGED
))
8513 json_object_boolean_true_add(
8514 json_addr
, "unchangedNextHopPropogatedToNbr");
8515 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8516 json_object_boolean_true_add(
8517 json_addr
, "unchangedMedPropogatedToNbr");
8518 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8519 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8520 PEER_FLAG_SEND_EXT_COMMUNITY
)) {
8521 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8522 PEER_FLAG_SEND_COMMUNITY
)
8523 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8524 PEER_FLAG_SEND_EXT_COMMUNITY
))
8525 json_object_string_add(json_addr
,
8526 "commAttriSentToNbr",
8527 "extendedAndStandard");
8528 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8529 PEER_FLAG_SEND_EXT_COMMUNITY
))
8530 json_object_string_add(json_addr
,
8531 "commAttriSentToNbr",
8534 json_object_string_add(json_addr
,
8535 "commAttriSentToNbr",
8538 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8539 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8540 if (p
->default_rmap
[afi
][safi
].name
)
8541 json_object_string_add(
8542 json_addr
, "defaultRouteMap",
8543 p
->default_rmap
[afi
][safi
].name
);
8545 if (paf
&& PAF_SUBGRP(paf
)
8546 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8547 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8548 json_object_boolean_true_add(json_addr
,
8551 json_object_boolean_true_add(json_addr
,
8555 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8556 if (is_evpn_enabled())
8557 json_object_boolean_true_add(
8558 json_addr
, "advertiseAllVnis");
8561 if (filter
->plist
[FILTER_IN
].name
8562 || filter
->dlist
[FILTER_IN
].name
8563 || filter
->aslist
[FILTER_IN
].name
8564 || filter
->map
[RMAP_IN
].name
)
8565 json_object_boolean_true_add(json_addr
,
8566 "inboundPathPolicyConfig");
8567 if (filter
->plist
[FILTER_OUT
].name
8568 || filter
->dlist
[FILTER_OUT
].name
8569 || filter
->aslist
[FILTER_OUT
].name
8570 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8571 json_object_boolean_true_add(
8572 json_addr
, "outboundPathPolicyConfig");
8575 if (filter
->plist
[FILTER_IN
].name
)
8576 json_object_string_add(json_addr
,
8577 "incomingUpdatePrefixFilterList",
8578 filter
->plist
[FILTER_IN
].name
);
8579 if (filter
->plist
[FILTER_OUT
].name
)
8580 json_object_string_add(json_addr
,
8581 "outgoingUpdatePrefixFilterList",
8582 filter
->plist
[FILTER_OUT
].name
);
8584 /* distribute-list */
8585 if (filter
->dlist
[FILTER_IN
].name
)
8586 json_object_string_add(
8587 json_addr
, "incomingUpdateNetworkFilterList",
8588 filter
->dlist
[FILTER_IN
].name
);
8589 if (filter
->dlist
[FILTER_OUT
].name
)
8590 json_object_string_add(
8591 json_addr
, "outgoingUpdateNetworkFilterList",
8592 filter
->dlist
[FILTER_OUT
].name
);
8595 if (filter
->aslist
[FILTER_IN
].name
)
8596 json_object_string_add(json_addr
,
8597 "incomingUpdateAsPathFilterList",
8598 filter
->aslist
[FILTER_IN
].name
);
8599 if (filter
->aslist
[FILTER_OUT
].name
)
8600 json_object_string_add(json_addr
,
8601 "outgoingUpdateAsPathFilterList",
8602 filter
->aslist
[FILTER_OUT
].name
);
8605 if (filter
->map
[RMAP_IN
].name
)
8606 json_object_string_add(
8607 json_addr
, "routeMapForIncomingAdvertisements",
8608 filter
->map
[RMAP_IN
].name
);
8609 if (filter
->map
[RMAP_OUT
].name
)
8610 json_object_string_add(
8611 json_addr
, "routeMapForOutgoingAdvertisements",
8612 filter
->map
[RMAP_OUT
].name
);
8614 /* unsuppress-map */
8615 if (filter
->usmap
.name
)
8616 json_object_string_add(json_addr
,
8617 "selectiveUnsuppressRouteMap",
8618 filter
->usmap
.name
);
8620 /* Receive prefix count */
8621 json_object_int_add(json_addr
, "acceptedPrefixCounter",
8622 p
->pcount
[afi
][safi
]);
8624 /* Maximum prefix */
8625 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8626 json_object_int_add(json_addr
, "prefixAllowedMax",
8627 p
->pmax
[afi
][safi
]);
8628 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8629 PEER_FLAG_MAX_PREFIX_WARNING
))
8630 json_object_boolean_true_add(
8631 json_addr
, "prefixAllowedMaxWarning");
8632 json_object_int_add(json_addr
,
8633 "prefixAllowedWarningThresh",
8634 p
->pmax_threshold
[afi
][safi
]);
8635 if (p
->pmax_restart
[afi
][safi
])
8636 json_object_int_add(
8638 "prefixAllowedRestartIntervalMsecs",
8639 p
->pmax_restart
[afi
][safi
] * 60000);
8641 json_object_object_add(json_neigh
, afi_safi_print(afi
, safi
),
8645 filter
= &p
->filter
[afi
][safi
];
8647 vty_out(vty
, " For address family: %s\n",
8648 afi_safi_print(afi
, safi
));
8650 if (peer_group_active(p
))
8651 vty_out(vty
, " %s peer-group member\n",
8654 paf
= peer_af_find(p
, afi
, safi
);
8655 if (paf
&& PAF_SUBGRP(paf
)) {
8656 vty_out(vty
, " Update group %" PRIu64
8657 ", subgroup %" PRIu64
"\n",
8658 PAF_UPDGRP(paf
)->id
, PAF_SUBGRP(paf
)->id
);
8659 vty_out(vty
, " Packet Queue length %d\n",
8660 bpacket_queue_virtual_length(paf
));
8662 vty_out(vty
, " Not part of any update group\n");
8664 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8665 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8666 PEER_CAP_ORF_PREFIX_SM_RCV
)
8667 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8668 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8669 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8670 PEER_CAP_ORF_PREFIX_RM_ADV
)
8671 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8672 PEER_CAP_ORF_PREFIX_RM_RCV
)
8673 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8674 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
))
8675 vty_out(vty
, " AF-dependant capabilities:\n");
8677 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8678 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8679 PEER_CAP_ORF_PREFIX_SM_RCV
)
8680 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8681 PEER_CAP_ORF_PREFIX_RM_ADV
)
8682 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8683 PEER_CAP_ORF_PREFIX_RM_RCV
)) {
8685 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8687 bgp_show_peer_afi_orf_cap(
8688 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8689 PEER_CAP_ORF_PREFIX_RM_ADV
,
8690 PEER_CAP_ORF_PREFIX_SM_RCV
,
8691 PEER_CAP_ORF_PREFIX_RM_RCV
, use_json
, NULL
);
8693 if (CHECK_FLAG(p
->af_cap
[afi
][safi
], PEER_CAP_ORF_PREFIX_SM_ADV
)
8694 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8695 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
)
8696 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8697 PEER_CAP_ORF_PREFIX_RM_ADV
)
8698 || CHECK_FLAG(p
->af_cap
[afi
][safi
],
8699 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
)) {
8701 " Outbound Route Filter (ORF) type (%d) Prefix-list:\n",
8702 ORF_TYPE_PREFIX_OLD
);
8703 bgp_show_peer_afi_orf_cap(
8704 vty
, p
, afi
, safi
, PEER_CAP_ORF_PREFIX_SM_ADV
,
8705 PEER_CAP_ORF_PREFIX_RM_ADV
,
8706 PEER_CAP_ORF_PREFIX_SM_OLD_RCV
,
8707 PEER_CAP_ORF_PREFIX_RM_OLD_RCV
, use_json
, NULL
);
8710 sprintf(orf_pfx_name
, "%s.%d.%d", p
->host
, afi
, safi
);
8711 orf_pfx_count
= prefix_bgp_show_prefix_list(
8712 NULL
, afi
, orf_pfx_name
, use_json
);
8714 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8715 PEER_STATUS_ORF_PREFIX_SEND
)
8717 vty_out(vty
, " Outbound Route Filter (ORF):");
8718 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8719 PEER_STATUS_ORF_PREFIX_SEND
))
8720 vty_out(vty
, " sent;");
8722 vty_out(vty
, " received (%d entries)",
8726 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
8727 PEER_STATUS_ORF_WAIT_REFRESH
))
8729 " First update is deferred until ORF or ROUTE-REFRESH is received\n");
8731 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8732 PEER_FLAG_REFLECTOR_CLIENT
))
8733 vty_out(vty
, " Route-Reflector Client\n");
8734 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8735 PEER_FLAG_RSERVER_CLIENT
))
8736 vty_out(vty
, " Route-Server Client\n");
8737 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8739 " Inbound soft reconfiguration allowed\n");
8741 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8742 PEER_FLAG_REMOVE_PRIVATE_AS_ALL_REPLACE
))
8744 " Private AS numbers (all) replaced in updates to this neighbor\n");
8745 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8746 PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE
))
8748 " Private AS numbers replaced in updates to this neighbor\n");
8749 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8750 PEER_FLAG_REMOVE_PRIVATE_AS_ALL
))
8752 " Private AS numbers (all) removed in updates to this neighbor\n");
8753 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8754 PEER_FLAG_REMOVE_PRIVATE_AS
))
8756 " Private AS numbers removed in updates to this neighbor\n");
8758 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8759 PEER_FLAG_ADDPATH_TX_ALL_PATHS
))
8760 vty_out(vty
, " Advertise all paths via addpath\n");
8762 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8763 PEER_FLAG_ADDPATH_TX_BESTPATH_PER_AS
))
8765 " Advertise bestpath per AS via addpath\n");
8767 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_AS_OVERRIDE
))
8769 " Override ASNs in outbound updates if aspath equals remote-as\n");
8771 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
)
8772 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8773 PEER_FLAG_FORCE_NEXTHOP_SELF
))
8774 vty_out(vty
, " NEXT_HOP is always this router\n");
8775 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8776 PEER_FLAG_AS_PATH_UNCHANGED
))
8778 " AS_PATH is propagated unchanged to this neighbor\n");
8779 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8780 PEER_FLAG_NEXTHOP_UNCHANGED
))
8782 " NEXT_HOP is propagated unchanged to this neighbor\n");
8783 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MED_UNCHANGED
))
8785 " MED is propagated unchanged to this neighbor\n");
8786 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8787 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8788 PEER_FLAG_SEND_EXT_COMMUNITY
)
8789 || CHECK_FLAG(p
->af_flags
[afi
][safi
],
8790 PEER_FLAG_SEND_LARGE_COMMUNITY
)) {
8792 " Community attribute sent to this neighbor");
8793 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8794 PEER_FLAG_SEND_COMMUNITY
)
8795 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8796 PEER_FLAG_SEND_EXT_COMMUNITY
)
8797 && CHECK_FLAG(p
->af_flags
[afi
][safi
],
8798 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8799 vty_out(vty
, "(all)\n");
8800 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8801 PEER_FLAG_SEND_LARGE_COMMUNITY
))
8802 vty_out(vty
, "(large)\n");
8803 else if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8804 PEER_FLAG_SEND_EXT_COMMUNITY
))
8805 vty_out(vty
, "(extended)\n");
8807 vty_out(vty
, "(standard)\n");
8809 if (CHECK_FLAG(p
->af_flags
[afi
][safi
],
8810 PEER_FLAG_DEFAULT_ORIGINATE
)) {
8811 vty_out(vty
, " Default information originate,");
8813 if (p
->default_rmap
[afi
][safi
].name
)
8814 vty_out(vty
, " default route-map %s%s,",
8815 p
->default_rmap
[afi
][safi
].map
? "*"
8817 p
->default_rmap
[afi
][safi
].name
);
8818 if (paf
&& PAF_SUBGRP(paf
)
8819 && CHECK_FLAG(PAF_SUBGRP(paf
)->sflags
,
8820 SUBGRP_STATUS_DEFAULT_ORIGINATE
))
8821 vty_out(vty
, " default sent\n");
8823 vty_out(vty
, " default not sent\n");
8826 /* advertise-vni-all */
8827 if (afi
== AFI_L2VPN
&& safi
== SAFI_EVPN
) {
8828 if (is_evpn_enabled())
8829 vty_out(vty
, " advertise-all-vni\n");
8832 if (filter
->plist
[FILTER_IN
].name
8833 || filter
->dlist
[FILTER_IN
].name
8834 || filter
->aslist
[FILTER_IN
].name
8835 || filter
->map
[RMAP_IN
].name
)
8836 vty_out(vty
, " Inbound path policy configured\n");
8837 if (filter
->plist
[FILTER_OUT
].name
8838 || filter
->dlist
[FILTER_OUT
].name
8839 || filter
->aslist
[FILTER_OUT
].name
8840 || filter
->map
[RMAP_OUT
].name
|| filter
->usmap
.name
)
8841 vty_out(vty
, " Outbound path policy configured\n");
8844 if (filter
->plist
[FILTER_IN
].name
)
8846 " Incoming update prefix filter list is %s%s\n",
8847 filter
->plist
[FILTER_IN
].plist
? "*" : "",
8848 filter
->plist
[FILTER_IN
].name
);
8849 if (filter
->plist
[FILTER_OUT
].name
)
8851 " Outgoing update prefix filter list is %s%s\n",
8852 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
8853 filter
->plist
[FILTER_OUT
].name
);
8855 /* distribute-list */
8856 if (filter
->dlist
[FILTER_IN
].name
)
8858 " Incoming update network filter list is %s%s\n",
8859 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
8860 filter
->dlist
[FILTER_IN
].name
);
8861 if (filter
->dlist
[FILTER_OUT
].name
)
8863 " Outgoing update network filter list is %s%s\n",
8864 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
8865 filter
->dlist
[FILTER_OUT
].name
);
8868 if (filter
->aslist
[FILTER_IN
].name
)
8870 " Incoming update AS path filter list is %s%s\n",
8871 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
8872 filter
->aslist
[FILTER_IN
].name
);
8873 if (filter
->aslist
[FILTER_OUT
].name
)
8875 " Outgoing update AS path filter list is %s%s\n",
8876 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
8877 filter
->aslist
[FILTER_OUT
].name
);
8880 if (filter
->map
[RMAP_IN
].name
)
8882 " Route map for incoming advertisements is %s%s\n",
8883 filter
->map
[RMAP_IN
].map
? "*" : "",
8884 filter
->map
[RMAP_IN
].name
);
8885 if (filter
->map
[RMAP_OUT
].name
)
8887 " Route map for outgoing advertisements is %s%s\n",
8888 filter
->map
[RMAP_OUT
].map
? "*" : "",
8889 filter
->map
[RMAP_OUT
].name
);
8891 /* unsuppress-map */
8892 if (filter
->usmap
.name
)
8894 " Route map for selective unsuppress is %s%s\n",
8895 filter
->usmap
.map
? "*" : "",
8896 filter
->usmap
.name
);
8898 /* Receive prefix count */
8899 vty_out(vty
, " %ld accepted prefixes\n", p
->pcount
[afi
][safi
]);
8901 /* Maximum prefix */
8902 if (CHECK_FLAG(p
->af_flags
[afi
][safi
], PEER_FLAG_MAX_PREFIX
)) {
8903 vty_out(vty
, " Maximum prefixes allowed %ld%s\n",
8905 CHECK_FLAG(p
->af_flags
[afi
][safi
],
8906 PEER_FLAG_MAX_PREFIX_WARNING
)
8909 vty_out(vty
, " Threshold for warning message %d%%",
8910 p
->pmax_threshold
[afi
][safi
]);
8911 if (p
->pmax_restart
[afi
][safi
])
8912 vty_out(vty
, ", restart interval %d min",
8913 p
->pmax_restart
[afi
][safi
]);
8921 static void bgp_show_peer(struct vty
*vty
, struct peer
*p
, uint8_t use_json
,
8925 char buf1
[PREFIX2STR_BUFFER
], buf
[SU_ADDRSTRLEN
];
8926 char timebuf
[BGP_UPTIME_LEN
];
8928 const char *subcode_str
;
8929 const char *code_str
;
8934 json_object
*json_neigh
= NULL
;
8940 json_neigh
= json_object_new_object();
8942 memset(dn_flag
, '\0', sizeof(dn_flag
));
8943 if (!p
->conf_if
&& peer_dynamic_neighbor(p
))
8947 if (p
->conf_if
) /* Configured interface name. */
8948 vty_out(vty
, "BGP neighbor on %s: %s, ", p
->conf_if
,
8949 BGP_PEER_SU_UNSPEC(p
)
8951 : sockunion2str(&p
->su
, buf
,
8953 else /* Configured IP address. */
8954 vty_out(vty
, "BGP neighbor is %s%s, ", dn_flag
,
8959 if (p
->conf_if
&& BGP_PEER_SU_UNSPEC(p
))
8960 json_object_string_add(json_neigh
, "bgpNeighborAddr",
8962 else if (p
->conf_if
&& !BGP_PEER_SU_UNSPEC(p
))
8963 json_object_string_add(
8964 json_neigh
, "bgpNeighborAddr",
8965 sockunion2str(&p
->su
, buf
, SU_ADDRSTRLEN
));
8967 json_object_int_add(json_neigh
, "remoteAs", p
->as
);
8969 if (p
->change_local_as
)
8970 json_object_int_add(json_neigh
, "localAs",
8971 p
->change_local_as
);
8973 json_object_int_add(json_neigh
, "localAs", p
->local_as
);
8975 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
))
8976 json_object_boolean_true_add(json_neigh
,
8977 "localAsNoPrepend");
8979 if (CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
))
8980 json_object_boolean_true_add(json_neigh
,
8981 "localAsReplaceAs");
8983 if ((p
->as_type
== AS_SPECIFIED
) || (p
->as_type
== AS_EXTERNAL
)
8984 || (p
->as_type
== AS_INTERNAL
))
8985 vty_out(vty
, "remote AS %u, ", p
->as
);
8987 vty_out(vty
, "remote AS Unspecified, ");
8988 vty_out(vty
, "local AS %u%s%s, ",
8989 p
->change_local_as
? p
->change_local_as
: p
->local_as
,
8990 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_NO_PREPEND
)
8993 CHECK_FLAG(p
->flags
, PEER_FLAG_LOCAL_AS_REPLACE_AS
)
8997 /* peer type internal, external, confed-internal or confed-external */
8998 if (p
->as
== p
->local_as
) {
9000 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9001 json_object_boolean_true_add(
9002 json_neigh
, "nbrConfedInternalLink");
9004 json_object_boolean_true_add(json_neigh
,
9007 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9008 vty_out(vty
, "confed-internal link\n");
9010 vty_out(vty
, "internal link\n");
9014 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
9015 json_object_boolean_true_add(
9016 json_neigh
, "nbrConfedExternalLink");
9018 json_object_boolean_true_add(json_neigh
,
9021 if (bgp_confederation_peers_check(bgp
, p
->as
))
9022 vty_out(vty
, "confed-external link\n");
9024 vty_out(vty
, "external link\n");
9031 json_object_string_add(json_neigh
, "nbrDesc", p
->desc
);
9033 vty_out(vty
, " Description: %s\n", p
->desc
);
9039 json_object_string_add(json_neigh
, "hostname",
9043 json_object_string_add(json_neigh
, "domainname",
9046 if (p
->domainname
&& (p
->domainname
[0] != '\0'))
9047 vty_out(vty
, "Hostname: %s.%s\n", p
->hostname
,
9050 vty_out(vty
, "Hostname: %s\n", p
->hostname
);
9057 json_object_string_add(json_neigh
, "peerGroup",
9061 struct prefix prefix
, *range
= NULL
;
9063 sockunion2hostprefix(&(p
->su
), &prefix
);
9064 range
= peer_group_lookup_dynamic_neighbor_range(
9068 prefix2str(range
, buf1
, sizeof(buf1
));
9069 json_object_string_add(
9071 "peerSubnetRangeGroup", buf1
);
9076 " Member of peer-group %s for session parameters\n",
9080 struct prefix prefix
, *range
= NULL
;
9082 sockunion2hostprefix(&(p
->su
), &prefix
);
9083 range
= peer_group_lookup_dynamic_neighbor_range(
9087 prefix2str(range
, buf1
, sizeof(buf1
));
9089 " Belongs to the subnet range group: %s\n",
9097 /* Administrative shutdown. */
9098 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9099 json_object_boolean_true_add(json_neigh
,
9103 json_object_int_add(json_neigh
, "bgpVersion", 4);
9104 json_object_string_add(
9105 json_neigh
, "remoteRouterId",
9106 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9109 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9110 && bgp_confederation_peers_check(bgp
, p
->as
))
9111 json_object_boolean_true_add(json_neigh
,
9115 json_object_string_add(
9116 json_neigh
, "bgpState",
9117 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9119 if (p
->status
== Established
) {
9122 uptime
= bgp_clock();
9123 uptime
-= p
->uptime
;
9124 epoch_tbuf
= time(NULL
) - uptime
;
9126 #if defined(VERSION_TYPE_DEV) && CONFDATE > 20200101
9128 "bgpTimerUp should be deprecated and can be removed now");
9131 * bgpTimerUp was miliseconds that was accurate
9132 * up to 1 day, then the value returned
9133 * became garbage. So in order to provide
9134 * some level of backwards compatability,
9135 * we still provde the data, but now
9136 * we are returning the correct value
9137 * and also adding a new bgpTimerUpMsec
9138 * which will allow us to deprecate
9141 json_object_int_add(json_neigh
, "bgpTimerUp",
9143 json_object_int_add(json_neigh
, "bgpTimerUpMsec",
9145 json_object_string_add(json_neigh
, "bgpTimerUpString",
9146 peer_uptime(p
->uptime
, timebuf
,
9149 json_object_int_add(json_neigh
,
9150 "bgpTimerUpEstablishedEpoch",
9154 else if (p
->status
== Active
) {
9155 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9156 json_object_string_add(json_neigh
, "bgpStateIs",
9158 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9159 json_object_string_add(json_neigh
, "bgpStateIs",
9167 uptime
= bgp_clock();
9168 uptime
-= p
->readtime
;
9169 tm
= gmtime(&uptime
);
9170 json_object_int_add(json_neigh
, "bgpTimerLastRead",
9171 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9172 + (tm
->tm_hour
* 3600000));
9174 uptime
= bgp_clock();
9175 uptime
-= p
->last_write
;
9176 tm
= gmtime(&uptime
);
9177 json_object_int_add(json_neigh
, "bgpTimerLastWrite",
9178 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9179 + (tm
->tm_hour
* 3600000));
9181 uptime
= bgp_clock();
9182 uptime
-= p
->update_time
;
9183 tm
= gmtime(&uptime
);
9184 json_object_int_add(json_neigh
, "bgpInUpdateElapsedTimeMsecs",
9185 (tm
->tm_sec
* 1000) + (tm
->tm_min
* 60000)
9186 + (tm
->tm_hour
* 3600000));
9188 /* Configured timer values. */
9189 json_object_int_add(json_neigh
, "bgpTimerHoldTimeMsecs",
9190 p
->v_holdtime
* 1000);
9191 json_object_int_add(json_neigh
,
9192 "bgpTimerKeepAliveIntervalMsecs",
9193 p
->v_keepalive
* 1000);
9195 if (PEER_OR_GROUP_TIMER_SET(p
)) {
9196 json_object_int_add(json_neigh
,
9197 "bgpTimerConfiguredHoldTimeMsecs",
9198 p
->holdtime
* 1000);
9199 json_object_int_add(
9201 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9202 p
->keepalive
* 1000);
9203 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9204 || (bgp
->default_keepalive
9205 != BGP_DEFAULT_KEEPALIVE
)) {
9206 json_object_int_add(json_neigh
,
9207 "bgpTimerConfiguredHoldTimeMsecs",
9208 bgp
->default_holdtime
);
9209 json_object_int_add(
9211 "bgpTimerConfiguredKeepAliveIntervalMsecs",
9212 bgp
->default_keepalive
);
9215 /* Administrative shutdown. */
9216 if (CHECK_FLAG(p
->flags
, PEER_FLAG_SHUTDOWN
))
9217 vty_out(vty
, " Administratively shut down\n");
9220 vty_out(vty
, " BGP version 4");
9221 vty_out(vty
, ", remote router ID %s\n",
9222 inet_ntop(AF_INET
, &p
->remote_id
, buf1
, sizeof(buf1
)));
9225 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
)
9226 && bgp_confederation_peers_check(bgp
, p
->as
))
9228 " Neighbor under common administration\n");
9231 vty_out(vty
, " BGP state = %s",
9232 lookup_msg(bgp_status_msg
, p
->status
, NULL
));
9234 if (p
->status
== Established
)
9235 vty_out(vty
, ", up for %8s",
9236 peer_uptime(p
->uptime
, timebuf
, BGP_UPTIME_LEN
,
9239 else if (p
->status
== Active
) {
9240 if (CHECK_FLAG(p
->flags
, PEER_FLAG_PASSIVE
))
9241 vty_out(vty
, " (passive)");
9242 else if (CHECK_FLAG(p
->sflags
, PEER_STATUS_NSF_WAIT
))
9243 vty_out(vty
, " (NSF passive)");
9248 vty_out(vty
, " Last read %s",
9249 peer_uptime(p
->readtime
, timebuf
, BGP_UPTIME_LEN
, 0,
9251 vty_out(vty
, ", Last write %s\n",
9252 peer_uptime(p
->last_write
, timebuf
, BGP_UPTIME_LEN
, 0,
9255 /* Configured timer values. */
9257 " Hold time is %d, keepalive interval is %d seconds\n",
9258 p
->v_holdtime
, p
->v_keepalive
);
9259 if (PEER_OR_GROUP_TIMER_SET(p
)) {
9260 vty_out(vty
, " Configured hold time is %d",
9262 vty_out(vty
, ", keepalive interval is %d seconds\n",
9264 } else if ((bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
9265 || (bgp
->default_keepalive
9266 != BGP_DEFAULT_KEEPALIVE
)) {
9267 vty_out(vty
, " Configured hold time is %d",
9268 bgp
->default_holdtime
);
9269 vty_out(vty
, ", keepalive interval is %d seconds\n",
9270 bgp
->default_keepalive
);
9274 if (p
->status
== Established
) {
9275 if (p
->cap
|| p
->afc_adv
[AFI_IP
][SAFI_UNICAST
]
9276 || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
]
9277 || p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
]
9278 || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
]
9279 || p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
]
9280 || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
]
9281 || p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
]
9282 || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
]
9283 || p
->afc_adv
[AFI_IP6
][SAFI_MPLS_VPN
]
9284 || p
->afc_recv
[AFI_IP6
][SAFI_MPLS_VPN
]
9285 || p
->afc_adv
[AFI_IP6
][SAFI_ENCAP
]
9286 || p
->afc_recv
[AFI_IP6
][SAFI_ENCAP
]
9287 || p
->afc_adv
[AFI_IP6
][SAFI_FLOWSPEC
]
9288 || p
->afc_recv
[AFI_IP6
][SAFI_FLOWSPEC
]
9289 || p
->afc_adv
[AFI_IP
][SAFI_ENCAP
]
9290 || p
->afc_recv
[AFI_IP
][SAFI_ENCAP
]
9291 || p
->afc_adv
[AFI_IP
][SAFI_FLOWSPEC
]
9292 || p
->afc_recv
[AFI_IP
][SAFI_FLOWSPEC
]
9293 || p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
]
9294 || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]) {
9296 json_object
*json_cap
= NULL
;
9298 json_cap
= json_object_new_object();
9301 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9302 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9303 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)
9304 && CHECK_FLAG(p
->cap
,
9306 json_object_string_add(
9307 json_cap
, "4byteAs",
9308 "advertisedAndReceived");
9309 else if (CHECK_FLAG(p
->cap
,
9311 json_object_string_add(
9312 json_cap
, "4byteAs",
9314 else if (CHECK_FLAG(p
->cap
,
9316 json_object_string_add(
9317 json_cap
, "4byteAs",
9322 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9323 || CHECK_FLAG(p
->cap
,
9324 PEER_CAP_ADDPATH_ADV
)) {
9325 json_object
*json_add
= NULL
;
9326 const char *print_store
;
9328 json_add
= json_object_new_object();
9330 FOREACH_AFI_SAFI (afi
, safi
) {
9331 json_object
*json_sub
= NULL
;
9333 json_object_new_object();
9334 print_store
= afi_safi_print(
9340 PEER_CAP_ADDPATH_AF_TX_ADV
)
9344 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9349 PEER_CAP_ADDPATH_AF_TX_ADV
)
9354 PEER_CAP_ADDPATH_AF_TX_RCV
))
9355 json_object_boolean_true_add(
9357 "txAdvertisedAndReceived");
9363 PEER_CAP_ADDPATH_AF_TX_ADV
))
9364 json_object_boolean_true_add(
9372 PEER_CAP_ADDPATH_AF_TX_RCV
))
9373 json_object_boolean_true_add(
9381 PEER_CAP_ADDPATH_AF_RX_ADV
)
9385 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9390 PEER_CAP_ADDPATH_AF_RX_ADV
)
9395 PEER_CAP_ADDPATH_AF_RX_RCV
))
9396 json_object_boolean_true_add(
9398 "rxAdvertisedAndReceived");
9404 PEER_CAP_ADDPATH_AF_RX_ADV
))
9405 json_object_boolean_true_add(
9413 PEER_CAP_ADDPATH_AF_RX_RCV
))
9414 json_object_boolean_true_add(
9422 PEER_CAP_ADDPATH_AF_TX_ADV
)
9426 PEER_CAP_ADDPATH_AF_TX_RCV
)
9430 PEER_CAP_ADDPATH_AF_RX_ADV
)
9434 PEER_CAP_ADDPATH_AF_RX_RCV
))
9435 json_object_object_add(
9444 json_object_object_add(
9445 json_cap
, "addPath", json_add
);
9449 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9450 || CHECK_FLAG(p
->cap
,
9451 PEER_CAP_DYNAMIC_ADV
)) {
9452 if (CHECK_FLAG(p
->cap
,
9453 PEER_CAP_DYNAMIC_ADV
)
9454 && CHECK_FLAG(p
->cap
,
9455 PEER_CAP_DYNAMIC_RCV
))
9456 json_object_string_add(
9457 json_cap
, "dynamic",
9458 "advertisedAndReceived");
9459 else if (CHECK_FLAG(
9461 PEER_CAP_DYNAMIC_ADV
))
9462 json_object_string_add(
9463 json_cap
, "dynamic",
9465 else if (CHECK_FLAG(
9467 PEER_CAP_DYNAMIC_RCV
))
9468 json_object_string_add(
9469 json_cap
, "dynamic",
9473 /* Extended nexthop */
9474 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9475 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9476 json_object
*json_nxt
= NULL
;
9477 const char *print_store
;
9480 if (CHECK_FLAG(p
->cap
,
9482 && CHECK_FLAG(p
->cap
,
9484 json_object_string_add(
9487 "advertisedAndReceived");
9488 else if (CHECK_FLAG(p
->cap
,
9490 json_object_string_add(
9494 else if (CHECK_FLAG(p
->cap
,
9496 json_object_string_add(
9501 if (CHECK_FLAG(p
->cap
,
9502 PEER_CAP_ENHE_RCV
)) {
9504 json_object_new_object();
9506 for (safi
= SAFI_UNICAST
;
9507 safi
< SAFI_MAX
; safi
++) {
9512 PEER_CAP_ENHE_AF_RCV
)) {
9513 print_store
= afi_safi_print(
9516 json_object_string_add(
9522 json_object_object_add(
9524 "extendedNexthopFamililesByPeer",
9530 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9531 || CHECK_FLAG(p
->cap
,
9532 PEER_CAP_REFRESH_NEW_RCV
)
9533 || CHECK_FLAG(p
->cap
,
9534 PEER_CAP_REFRESH_OLD_RCV
)) {
9535 if (CHECK_FLAG(p
->cap
,
9536 PEER_CAP_REFRESH_ADV
)
9539 PEER_CAP_REFRESH_NEW_RCV
)
9542 PEER_CAP_REFRESH_OLD_RCV
))) {
9545 PEER_CAP_REFRESH_OLD_RCV
)
9548 PEER_CAP_REFRESH_NEW_RCV
))
9549 json_object_string_add(
9552 "advertisedAndReceivedOldNew");
9556 PEER_CAP_REFRESH_OLD_RCV
))
9557 json_object_string_add(
9560 "advertisedAndReceivedOld");
9562 json_object_string_add(
9565 "advertisedAndReceivedNew");
9570 PEER_CAP_REFRESH_ADV
))
9571 json_object_string_add(
9578 PEER_CAP_REFRESH_NEW_RCV
)
9581 PEER_CAP_REFRESH_OLD_RCV
))
9582 json_object_string_add(
9588 /* Multiprotocol Extensions */
9589 json_object
*json_multi
= NULL
;
9590 json_multi
= json_object_new_object();
9592 FOREACH_AFI_SAFI (afi
, safi
) {
9593 if (p
->afc_adv
[afi
][safi
]
9594 || p
->afc_recv
[afi
][safi
]) {
9595 json_object
*json_exten
= NULL
;
9597 json_object_new_object();
9599 if (p
->afc_adv
[afi
][safi
]
9600 && p
->afc_recv
[afi
][safi
])
9601 json_object_boolean_true_add(
9603 "advertisedAndReceived");
9604 else if (p
->afc_adv
[afi
][safi
])
9605 json_object_boolean_true_add(
9608 else if (p
->afc_recv
[afi
][safi
])
9609 json_object_boolean_true_add(
9613 json_object_object_add(
9620 json_object_object_add(
9621 json_cap
, "multiprotocolExtensions",
9624 /* Hostname capabilities */
9625 json_object
*json_hname
= NULL
;
9627 json_hname
= json_object_new_object();
9629 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9630 json_object_string_add(
9631 json_hname
, "advHostName",
9632 bgp
->peer_self
->hostname
9636 json_object_string_add(
9637 json_hname
, "advDomainName",
9638 bgp
->peer_self
->domainname
9645 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9646 json_object_string_add(
9647 json_hname
, "rcvHostName",
9648 p
->hostname
? p
->hostname
9650 json_object_string_add(
9651 json_hname
, "rcvDomainName",
9652 p
->domainname
? p
->domainname
9656 json_object_object_add(json_cap
, "hostName",
9659 /* Gracefull Restart */
9660 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
9661 || CHECK_FLAG(p
->cap
,
9662 PEER_CAP_RESTART_ADV
)) {
9663 if (CHECK_FLAG(p
->cap
,
9664 PEER_CAP_RESTART_ADV
)
9665 && CHECK_FLAG(p
->cap
,
9666 PEER_CAP_RESTART_RCV
))
9667 json_object_string_add(
9670 "advertisedAndReceived");
9671 else if (CHECK_FLAG(
9673 PEER_CAP_RESTART_ADV
))
9674 json_object_string_add(
9676 "gracefulRestartCapability",
9678 else if (CHECK_FLAG(
9680 PEER_CAP_RESTART_RCV
))
9681 json_object_string_add(
9683 "gracefulRestartCapability",
9686 if (CHECK_FLAG(p
->cap
,
9687 PEER_CAP_RESTART_RCV
)) {
9688 int restart_af_count
= 0;
9689 json_object
*json_restart
=
9692 json_object_new_object();
9694 json_object_int_add(
9696 "gracefulRestartRemoteTimerMsecs",
9697 p
->v_gr_restart
* 1000);
9699 FOREACH_AFI_SAFI (afi
, safi
) {
9704 PEER_CAP_RESTART_AF_RCV
)) {
9709 json_object_new_object();
9715 PEER_CAP_RESTART_AF_PRESERVE_RCV
))
9716 json_object_boolean_true_add(
9720 json_object_object_add(
9728 if (!restart_af_count
) {
9729 json_object_string_add(
9731 "addressFamiliesByPeer",
9736 json_object_object_add(
9738 "addressFamiliesByPeer",
9742 json_object_object_add(json_neigh
,
9743 "neighborCapabilities",
9746 vty_out(vty
, " Neighbor capabilities:\n");
9749 if (CHECK_FLAG(p
->cap
, PEER_CAP_AS4_RCV
)
9750 || CHECK_FLAG(p
->cap
, PEER_CAP_AS4_ADV
)) {
9751 vty_out(vty
, " 4 Byte AS:");
9752 if (CHECK_FLAG(p
->cap
,
9754 vty_out(vty
, " advertised");
9755 if (CHECK_FLAG(p
->cap
,
9757 vty_out(vty
, " %sreceived",
9767 if (CHECK_FLAG(p
->cap
, PEER_CAP_ADDPATH_RCV
)
9768 || CHECK_FLAG(p
->cap
,
9769 PEER_CAP_ADDPATH_ADV
)) {
9770 vty_out(vty
, " AddPath:\n");
9772 FOREACH_AFI_SAFI (afi
, safi
) {
9776 PEER_CAP_ADDPATH_AF_TX_ADV
)
9780 PEER_CAP_ADDPATH_AF_TX_RCV
)) {
9791 PEER_CAP_ADDPATH_AF_TX_ADV
))
9802 PEER_CAP_ADDPATH_AF_TX_RCV
))
9809 PEER_CAP_ADDPATH_AF_TX_ADV
)
9819 PEER_CAP_ADDPATH_AF_RX_ADV
)
9823 PEER_CAP_ADDPATH_AF_RX_RCV
)) {
9834 PEER_CAP_ADDPATH_AF_RX_ADV
))
9845 PEER_CAP_ADDPATH_AF_RX_RCV
))
9852 PEER_CAP_ADDPATH_AF_RX_ADV
)
9862 if (CHECK_FLAG(p
->cap
, PEER_CAP_DYNAMIC_RCV
)
9863 || CHECK_FLAG(p
->cap
,
9864 PEER_CAP_DYNAMIC_ADV
)) {
9865 vty_out(vty
, " Dynamic:");
9866 if (CHECK_FLAG(p
->cap
,
9867 PEER_CAP_DYNAMIC_ADV
))
9868 vty_out(vty
, " advertised");
9869 if (CHECK_FLAG(p
->cap
,
9870 PEER_CAP_DYNAMIC_RCV
))
9871 vty_out(vty
, " %sreceived",
9874 PEER_CAP_DYNAMIC_ADV
)
9880 /* Extended nexthop */
9881 if (CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_RCV
)
9882 || CHECK_FLAG(p
->cap
, PEER_CAP_ENHE_ADV
)) {
9883 vty_out(vty
, " Extended nexthop:");
9884 if (CHECK_FLAG(p
->cap
,
9886 vty_out(vty
, " advertised");
9887 if (CHECK_FLAG(p
->cap
,
9889 vty_out(vty
, " %sreceived",
9897 if (CHECK_FLAG(p
->cap
,
9898 PEER_CAP_ENHE_RCV
)) {
9900 " Address families by peer:\n ");
9901 for (safi
= SAFI_UNICAST
;
9902 safi
< SAFI_MAX
; safi
++)
9907 PEER_CAP_ENHE_AF_RCV
))
9917 if (CHECK_FLAG(p
->cap
, PEER_CAP_REFRESH_ADV
)
9918 || CHECK_FLAG(p
->cap
,
9919 PEER_CAP_REFRESH_NEW_RCV
)
9920 || CHECK_FLAG(p
->cap
,
9921 PEER_CAP_REFRESH_OLD_RCV
)) {
9922 vty_out(vty
, " Route refresh:");
9923 if (CHECK_FLAG(p
->cap
,
9924 PEER_CAP_REFRESH_ADV
))
9925 vty_out(vty
, " advertised");
9926 if (CHECK_FLAG(p
->cap
,
9927 PEER_CAP_REFRESH_NEW_RCV
)
9930 PEER_CAP_REFRESH_OLD_RCV
))
9931 vty_out(vty
, " %sreceived(%s)",
9934 PEER_CAP_REFRESH_ADV
)
9939 PEER_CAP_REFRESH_OLD_RCV
)
9942 PEER_CAP_REFRESH_NEW_RCV
))
9946 PEER_CAP_REFRESH_OLD_RCV
)
9953 /* Multiprotocol Extensions */
9954 FOREACH_AFI_SAFI (afi
, safi
)
9955 if (p
->afc_adv
[afi
][safi
]
9956 || p
->afc_recv
[afi
][safi
]) {
9958 " Address Family %s:",
9961 if (p
->afc_adv
[afi
][safi
])
9964 if (p
->afc_recv
[afi
][safi
])
9974 /* Hostname capability */
9975 vty_out(vty
, " Hostname Capability:");
9977 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_ADV
)) {
9979 " advertised (name: %s,domain name: %s)",
9980 bgp
->peer_self
->hostname
9984 bgp
->peer_self
->domainname
9989 vty_out(vty
, " not advertised");
9992 if (CHECK_FLAG(p
->cap
, PEER_CAP_HOSTNAME_RCV
)) {
9994 " received (name: %s,domain name: %s)",
9995 p
->hostname
? p
->hostname
9997 p
->domainname
? p
->domainname
10000 vty_out(vty
, " not received");
10003 vty_out(vty
, "\n");
10005 /* Gracefull Restart */
10006 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
)
10007 || CHECK_FLAG(p
->cap
,
10008 PEER_CAP_RESTART_ADV
)) {
10010 " Graceful Restart Capabilty:");
10011 if (CHECK_FLAG(p
->cap
,
10012 PEER_CAP_RESTART_ADV
))
10013 vty_out(vty
, " advertised");
10014 if (CHECK_FLAG(p
->cap
,
10015 PEER_CAP_RESTART_RCV
))
10016 vty_out(vty
, " %sreceived",
10019 PEER_CAP_RESTART_ADV
)
10022 vty_out(vty
, "\n");
10024 if (CHECK_FLAG(p
->cap
,
10025 PEER_CAP_RESTART_RCV
)) {
10026 int restart_af_count
= 0;
10029 " Remote Restart timer is %d seconds\n",
10032 " Address families by peer:\n ");
10034 FOREACH_AFI_SAFI (afi
, safi
)
10039 PEER_CAP_RESTART_AF_RCV
)) {
10052 PEER_CAP_RESTART_AF_PRESERVE_RCV
)
10054 : "not preserved");
10055 restart_af_count
++;
10057 if (!restart_af_count
)
10058 vty_out(vty
, "none");
10059 vty_out(vty
, "\n");
10066 /* graceful restart information */
10067 if (CHECK_FLAG(p
->cap
, PEER_CAP_RESTART_RCV
) || p
->t_gr_restart
10068 || p
->t_gr_stale
) {
10069 json_object
*json_grace
= NULL
;
10070 json_object
*json_grace_send
= NULL
;
10071 json_object
*json_grace_recv
= NULL
;
10072 int eor_send_af_count
= 0;
10073 int eor_receive_af_count
= 0;
10076 json_grace
= json_object_new_object();
10077 json_grace_send
= json_object_new_object();
10078 json_grace_recv
= json_object_new_object();
10080 if (p
->status
== Established
) {
10081 FOREACH_AFI_SAFI (afi
, safi
) {
10082 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10083 PEER_STATUS_EOR_SEND
)) {
10084 json_object_boolean_true_add(
10086 afi_safi_print(afi
,
10088 eor_send_af_count
++;
10091 FOREACH_AFI_SAFI (afi
, safi
) {
10093 p
->af_sflags
[afi
][safi
],
10094 PEER_STATUS_EOR_RECEIVED
)) {
10095 json_object_boolean_true_add(
10097 afi_safi_print(afi
,
10099 eor_receive_af_count
++;
10104 json_object_object_add(json_grace
, "endOfRibSend",
10106 json_object_object_add(json_grace
, "endOfRibRecv",
10109 if (p
->t_gr_restart
)
10110 json_object_int_add(json_grace
,
10111 "gracefulRestartTimerMsecs",
10112 thread_timer_remain_second(
10117 json_object_int_add(
10119 "gracefulStalepathTimerMsecs",
10120 thread_timer_remain_second(
10124 json_object_object_add(
10125 json_neigh
, "gracefulRestartInfo", json_grace
);
10127 vty_out(vty
, " Graceful restart informations:\n");
10128 if (p
->status
== Established
) {
10129 vty_out(vty
, " End-of-RIB send: ");
10130 FOREACH_AFI_SAFI (afi
, safi
) {
10131 if (CHECK_FLAG(p
->af_sflags
[afi
][safi
],
10132 PEER_STATUS_EOR_SEND
)) {
10133 vty_out(vty
, "%s%s",
10134 eor_send_af_count
? ", "
10136 afi_safi_print(afi
,
10138 eor_send_af_count
++;
10141 vty_out(vty
, "\n");
10142 vty_out(vty
, " End-of-RIB received: ");
10143 FOREACH_AFI_SAFI (afi
, safi
) {
10145 p
->af_sflags
[afi
][safi
],
10146 PEER_STATUS_EOR_RECEIVED
)) {
10147 vty_out(vty
, "%s%s",
10148 eor_receive_af_count
10151 afi_safi_print(afi
,
10153 eor_receive_af_count
++;
10156 vty_out(vty
, "\n");
10159 if (p
->t_gr_restart
)
10161 " The remaining time of restart timer is %ld\n",
10162 thread_timer_remain_second(
10167 " The remaining time of stalepath timer is %ld\n",
10168 thread_timer_remain_second(
10173 json_object
*json_stat
= NULL
;
10174 json_stat
= json_object_new_object();
10175 /* Packet counts. */
10176 json_object_int_add(json_stat
, "depthInq", 0);
10177 json_object_int_add(json_stat
, "depthOutq",
10178 (unsigned long)p
->obuf
->count
);
10179 json_object_int_add(json_stat
, "opensSent",
10180 atomic_load_explicit(&p
->open_out
,
10181 memory_order_relaxed
));
10182 json_object_int_add(json_stat
, "opensRecv",
10183 atomic_load_explicit(&p
->open_in
,
10184 memory_order_relaxed
));
10185 json_object_int_add(json_stat
, "notificationsSent",
10186 atomic_load_explicit(&p
->notify_out
,
10187 memory_order_relaxed
));
10188 json_object_int_add(json_stat
, "notificationsRecv",
10189 atomic_load_explicit(&p
->notify_in
,
10190 memory_order_relaxed
));
10191 json_object_int_add(json_stat
, "updatesSent",
10192 atomic_load_explicit(&p
->update_out
,
10193 memory_order_relaxed
));
10194 json_object_int_add(json_stat
, "updatesRecv",
10195 atomic_load_explicit(&p
->update_in
,
10196 memory_order_relaxed
));
10197 json_object_int_add(json_stat
, "keepalivesSent",
10198 atomic_load_explicit(&p
->keepalive_out
,
10199 memory_order_relaxed
));
10200 json_object_int_add(json_stat
, "keepalivesRecv",
10201 atomic_load_explicit(&p
->keepalive_in
,
10202 memory_order_relaxed
));
10203 json_object_int_add(json_stat
, "routeRefreshSent",
10204 atomic_load_explicit(&p
->refresh_out
,
10205 memory_order_relaxed
));
10206 json_object_int_add(json_stat
, "routeRefreshRecv",
10207 atomic_load_explicit(&p
->refresh_in
,
10208 memory_order_relaxed
));
10209 json_object_int_add(json_stat
, "capabilitySent",
10210 atomic_load_explicit(&p
->dynamic_cap_out
,
10211 memory_order_relaxed
));
10212 json_object_int_add(json_stat
, "capabilityRecv",
10213 atomic_load_explicit(&p
->dynamic_cap_in
,
10214 memory_order_relaxed
));
10215 json_object_int_add(json_stat
, "totalSent", PEER_TOTAL_TX(p
));
10216 json_object_int_add(json_stat
, "totalRecv", PEER_TOTAL_RX(p
));
10217 json_object_object_add(json_neigh
, "messageStats", json_stat
);
10219 /* Packet counts. */
10220 vty_out(vty
, " Message statistics:\n");
10221 vty_out(vty
, " Inq depth is 0\n");
10222 vty_out(vty
, " Outq depth is %lu\n",
10223 (unsigned long)p
->obuf
->count
);
10224 vty_out(vty
, " Sent Rcvd\n");
10225 vty_out(vty
, " Opens: %10d %10d\n",
10226 atomic_load_explicit(&p
->open_out
,
10227 memory_order_relaxed
),
10228 atomic_load_explicit(&p
->open_in
,
10229 memory_order_relaxed
));
10230 vty_out(vty
, " Notifications: %10d %10d\n",
10231 atomic_load_explicit(&p
->notify_out
,
10232 memory_order_relaxed
),
10233 atomic_load_explicit(&p
->notify_in
,
10234 memory_order_relaxed
));
10235 vty_out(vty
, " Updates: %10d %10d\n",
10236 atomic_load_explicit(&p
->update_out
,
10237 memory_order_relaxed
),
10238 atomic_load_explicit(&p
->update_in
,
10239 memory_order_relaxed
));
10240 vty_out(vty
, " Keepalives: %10d %10d\n",
10241 atomic_load_explicit(&p
->keepalive_out
,
10242 memory_order_relaxed
),
10243 atomic_load_explicit(&p
->keepalive_in
,
10244 memory_order_relaxed
));
10245 vty_out(vty
, " Route Refresh: %10d %10d\n",
10246 atomic_load_explicit(&p
->refresh_out
,
10247 memory_order_relaxed
),
10248 atomic_load_explicit(&p
->refresh_in
,
10249 memory_order_relaxed
));
10250 vty_out(vty
, " Capability: %10d %10d\n",
10251 atomic_load_explicit(&p
->dynamic_cap_out
,
10252 memory_order_relaxed
),
10253 atomic_load_explicit(&p
->dynamic_cap_in
,
10254 memory_order_relaxed
));
10255 vty_out(vty
, " Total: %10d %10d\n", PEER_TOTAL_TX(p
),
10260 /* advertisement-interval */
10261 json_object_int_add(json_neigh
,
10262 "minBtwnAdvertisementRunsTimerMsecs",
10263 p
->v_routeadv
* 1000);
10265 /* Update-source. */
10266 if (p
->update_if
|| p
->update_source
) {
10268 json_object_string_add(json_neigh
,
10271 else if (p
->update_source
)
10272 json_object_string_add(
10273 json_neigh
, "updateSource",
10274 sockunion2str(p
->update_source
, buf1
,
10278 /* advertisement-interval */
10280 " Minimum time between advertisement runs is %d seconds\n",
10283 /* Update-source. */
10284 if (p
->update_if
|| p
->update_source
) {
10285 vty_out(vty
, " Update source is ");
10287 vty_out(vty
, "%s", p
->update_if
);
10288 else if (p
->update_source
)
10290 sockunion2str(p
->update_source
, buf1
,
10292 vty_out(vty
, "\n");
10295 vty_out(vty
, "\n");
10298 /* Address Family Information */
10299 json_object
*json_hold
= NULL
;
10302 json_hold
= json_object_new_object();
10304 FOREACH_AFI_SAFI (afi
, safi
)
10305 if (p
->afc
[afi
][safi
])
10306 bgp_show_peer_afi(vty
, p
, afi
, safi
, use_json
,
10310 json_object_object_add(json_neigh
, "addressFamilyInfo",
10312 json_object_int_add(json_neigh
, "connectionsEstablished",
10314 json_object_int_add(json_neigh
, "connectionsDropped",
10317 vty_out(vty
, " Connections established %d; dropped %d\n",
10318 p
->established
, p
->dropped
);
10320 if (!p
->last_reset
) {
10322 json_object_string_add(json_neigh
, "lastReset",
10325 vty_out(vty
, " Last reset never\n");
10331 uptime
= bgp_clock();
10332 uptime
-= p
->resettime
;
10333 tm
= gmtime(&uptime
);
10334 json_object_int_add(json_neigh
, "lastResetTimerMsecs",
10335 (tm
->tm_sec
* 1000)
10336 + (tm
->tm_min
* 60000)
10337 + (tm
->tm_hour
* 3600000));
10338 json_object_string_add(
10339 json_neigh
, "lastResetDueTo",
10340 peer_down_str
[(int)p
->last_reset
]);
10341 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10342 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10343 char errorcodesubcode_hexstr
[5];
10344 char errorcodesubcode_str
[256];
10346 code_str
= bgp_notify_code_str(p
->notify
.code
);
10347 subcode_str
= bgp_notify_subcode_str(
10348 p
->notify
.code
, p
->notify
.subcode
);
10350 sprintf(errorcodesubcode_hexstr
, "%02X%02X",
10351 p
->notify
.code
, p
->notify
.subcode
);
10352 json_object_string_add(json_neigh
,
10353 "lastErrorCodeSubcode",
10354 errorcodesubcode_hexstr
);
10355 snprintf(errorcodesubcode_str
, 255, "%s%s",
10356 code_str
, subcode_str
);
10357 json_object_string_add(json_neigh
,
10358 "lastNotificationReason",
10359 errorcodesubcode_str
);
10360 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10361 && p
->notify
.code
== BGP_NOTIFY_CEASE
10362 && (p
->notify
.subcode
10363 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10364 || p
->notify
.subcode
10365 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10366 && p
->notify
.length
) {
10368 const char *msg_str
;
10370 msg_str
= bgp_notify_admin_message(
10371 msgbuf
, sizeof(msgbuf
),
10372 (uint8_t *)p
->notify
.data
,
10375 json_object_string_add(
10377 "lastShutdownDescription",
10382 vty_out(vty
, " Last reset %s, ",
10383 peer_uptime(p
->resettime
, timebuf
,
10384 BGP_UPTIME_LEN
, 0, NULL
));
10386 if (p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10387 || p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
) {
10388 code_str
= bgp_notify_code_str(p
->notify
.code
);
10389 subcode_str
= bgp_notify_subcode_str(
10390 p
->notify
.code
, p
->notify
.subcode
);
10391 vty_out(vty
, "due to NOTIFICATION %s (%s%s)\n",
10392 p
->last_reset
== PEER_DOWN_NOTIFY_SEND
10395 code_str
, subcode_str
);
10396 if (p
->last_reset
== PEER_DOWN_NOTIFY_RECEIVED
10397 && p
->notify
.code
== BGP_NOTIFY_CEASE
10398 && (p
->notify
.subcode
10399 == BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
10400 || p
->notify
.subcode
10401 == BGP_NOTIFY_CEASE_ADMIN_RESET
)
10402 && p
->notify
.length
) {
10404 const char *msg_str
;
10406 msg_str
= bgp_notify_admin_message(
10407 msgbuf
, sizeof(msgbuf
),
10408 (uint8_t *)p
->notify
.data
,
10412 " Message: \"%s\"\n",
10416 vty_out(vty
, "due to %s\n",
10417 peer_down_str
[(int)p
->last_reset
]);
10420 if (p
->last_reset_cause_size
) {
10421 msg
= p
->last_reset_cause
;
10423 " Message received that caused BGP to send a NOTIFICATION:\n ");
10424 for (i
= 1; i
<= p
->last_reset_cause_size
;
10426 vty_out(vty
, "%02X", *msg
++);
10428 if (i
!= p
->last_reset_cause_size
) {
10430 vty_out(vty
, "\n ");
10431 } else if (i
% 4 == 0) {
10436 vty_out(vty
, "\n");
10441 if (CHECK_FLAG(p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
)) {
10443 json_object_boolean_true_add(json_neigh
,
10444 "prefixesConfigExceedMax");
10447 " Peer had exceeded the max. no. of prefixes configured.\n");
10449 if (p
->t_pmax_restart
) {
10451 json_object_boolean_true_add(
10452 json_neigh
, "reducePrefixNumFrom");
10453 json_object_int_add(json_neigh
,
10454 "restartInTimerMsec",
10455 thread_timer_remain_second(
10460 " Reduce the no. of prefix from %s, will restart in %ld seconds\n",
10461 p
->host
, thread_timer_remain_second(
10462 p
->t_pmax_restart
));
10465 json_object_boolean_true_add(
10467 "reducePrefixNumAndClearIpBgp");
10470 " Reduce the no. of prefix and clear ip bgp %s to restore peering\n",
10475 /* EBGP Multihop and GTSM */
10476 if (p
->sort
!= BGP_PEER_IBGP
) {
10478 if (p
->gtsm_hops
> 0)
10479 json_object_int_add(json_neigh
,
10480 "externalBgpNbrMaxHopsAway",
10482 else if (p
->ttl
> 1)
10483 json_object_int_add(json_neigh
,
10484 "externalBgpNbrMaxHopsAway",
10487 if (p
->gtsm_hops
> 0)
10489 " External BGP neighbor may be up to %d hops away.\n",
10491 else if (p
->ttl
> 1)
10493 " External BGP neighbor may be up to %d hops away.\n",
10497 if (p
->gtsm_hops
> 0) {
10499 json_object_int_add(json_neigh
,
10500 "internalBgpNbrMaxHopsAway",
10504 " Internal BGP neighbor may be up to %d hops away.\n",
10509 /* Local address. */
10512 json_object_string_add(json_neigh
, "hostLocal",
10513 sockunion2str(p
->su_local
, buf1
,
10515 json_object_int_add(json_neigh
, "portLocal",
10516 ntohs(p
->su_local
->sin
.sin_port
));
10518 vty_out(vty
, "Local host: %s, Local port: %d\n",
10519 sockunion2str(p
->su_local
, buf1
, SU_ADDRSTRLEN
),
10520 ntohs(p
->su_local
->sin
.sin_port
));
10523 /* Remote address. */
10524 if (p
->su_remote
) {
10526 json_object_string_add(json_neigh
, "hostForeign",
10527 sockunion2str(p
->su_remote
, buf1
,
10529 json_object_int_add(json_neigh
, "portForeign",
10530 ntohs(p
->su_remote
->sin
.sin_port
));
10532 vty_out(vty
, "Foreign host: %s, Foreign port: %d\n",
10533 sockunion2str(p
->su_remote
, buf1
,
10535 ntohs(p
->su_remote
->sin
.sin_port
));
10538 /* Nexthop display. */
10541 json_object_string_add(json_neigh
, "nexthop",
10543 &p
->nexthop
.v4
, buf1
,
10545 json_object_string_add(json_neigh
, "nexthopGlobal",
10546 inet_ntop(AF_INET6
,
10547 &p
->nexthop
.v6_global
,
10548 buf1
, sizeof(buf1
)));
10549 json_object_string_add(json_neigh
, "nexthopLocal",
10550 inet_ntop(AF_INET6
,
10551 &p
->nexthop
.v6_local
,
10552 buf1
, sizeof(buf1
)));
10553 if (p
->shared_network
)
10554 json_object_string_add(json_neigh
,
10558 json_object_string_add(json_neigh
,
10560 "nonSharedNetwork");
10562 vty_out(vty
, "Nexthop: %s\n",
10563 inet_ntop(AF_INET
, &p
->nexthop
.v4
, buf1
,
10565 vty_out(vty
, "Nexthop global: %s\n",
10566 inet_ntop(AF_INET6
, &p
->nexthop
.v6_global
, buf1
,
10568 vty_out(vty
, "Nexthop local: %s\n",
10569 inet_ntop(AF_INET6
, &p
->nexthop
.v6_local
, buf1
,
10571 vty_out(vty
, "BGP connection: %s\n",
10572 p
->shared_network
? "shared network"
10573 : "non shared network");
10577 /* Timer information. */
10579 json_object_int_add(json_neigh
, "connectRetryTimer",
10581 if (p
->status
== Established
&& p
->rtt
)
10582 json_object_int_add(json_neigh
, "estimatedRttInMsecs",
10585 json_object_int_add(
10586 json_neigh
, "nextStartTimerDueInMsecs",
10587 thread_timer_remain_second(p
->t_start
) * 1000);
10589 json_object_int_add(
10590 json_neigh
, "nextConnectTimerDueInMsecs",
10591 thread_timer_remain_second(p
->t_connect
)
10593 if (p
->t_routeadv
) {
10594 json_object_int_add(json_neigh
, "mraiInterval",
10596 json_object_int_add(
10597 json_neigh
, "mraiTimerExpireInMsecs",
10598 thread_timer_remain_second(p
->t_routeadv
)
10602 json_object_int_add(json_neigh
, "authenticationEnabled",
10606 json_object_string_add(json_neigh
, "readThread", "on");
10608 json_object_string_add(json_neigh
, "readThread", "off");
10610 if (CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
))
10611 json_object_string_add(json_neigh
, "writeThread", "on");
10613 json_object_string_add(json_neigh
, "writeThread",
10616 vty_out(vty
, "BGP Connect Retry Timer in Seconds: %d\n",
10618 if (p
->status
== Established
&& p
->rtt
)
10619 vty_out(vty
, "Estimated round trip time: %d ms\n",
10622 vty_out(vty
, "Next start timer due in %ld seconds\n",
10623 thread_timer_remain_second(p
->t_start
));
10625 vty_out(vty
, "Next connect timer due in %ld seconds\n",
10626 thread_timer_remain_second(p
->t_connect
));
10629 "MRAI (interval %u) timer expires in %ld seconds\n",
10631 thread_timer_remain_second(p
->t_routeadv
));
10633 vty_out(vty
, "Peer Authentication Enabled\n");
10635 vty_out(vty
, "Read thread: %s Write thread: %s\n",
10636 p
->t_read
? "on" : "off",
10637 CHECK_FLAG(p
->thread_flags
, PEER_THREAD_WRITES_ON
)
10642 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
10643 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
10644 bgp_capability_vty_out(vty
, p
, use_json
, json_neigh
);
10647 vty_out(vty
, "\n");
10649 /* BFD information. */
10650 bgp_bfd_show_info(vty
, p
, use_json
, json_neigh
);
10653 if (p
->conf_if
) /* Configured interface name. */
10654 json_object_object_add(json
, p
->conf_if
, json_neigh
);
10655 else /* Configured IP address. */
10656 json_object_object_add(json
, p
->host
, json_neigh
);
10660 static int bgp_show_neighbor(struct vty
*vty
, struct bgp
*bgp
,
10661 enum show_type type
, union sockunion
*su
,
10662 const char *conf_if
, uint8_t use_json
,
10665 struct listnode
*node
, *nnode
;
10669 for (ALL_LIST_ELEMENTS(bgp
->peer
, node
, nnode
, peer
)) {
10670 if (!CHECK_FLAG(peer
->flags
, PEER_FLAG_CONFIG_NODE
))
10675 bgp_show_peer(vty
, peer
, use_json
, json
);
10680 && !strcmp(peer
->conf_if
, conf_if
))
10682 && !strcmp(peer
->hostname
, conf_if
))) {
10684 bgp_show_peer(vty
, peer
, use_json
,
10688 if (sockunion_same(&peer
->su
, su
)) {
10690 bgp_show_peer(vty
, peer
, use_json
,
10698 if (type
== show_peer
&& !find
) {
10700 json_object_boolean_true_add(json
, "bgpNoSuchNeighbor");
10702 vty_out(vty
, "%% No such neighbor in this view/vrf\n");
10706 vty_out(vty
, "%s\n", json_object_to_json_string_ext(
10707 json
, JSON_C_TO_STRING_PRETTY
));
10708 json_object_free(json
);
10710 vty_out(vty
, "\n");
10713 return CMD_SUCCESS
;
10716 static void bgp_show_all_instances_neighbors_vty(struct vty
*vty
,
10717 enum show_type type
,
10718 const char *ip_str
,
10721 struct listnode
*node
, *nnode
;
10723 union sockunion su
;
10724 json_object
*json
= NULL
;
10725 int ret
, is_first
= 1;
10728 vty_out(vty
, "{\n");
10730 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
10732 if (!(json
= json_object_new_object())) {
10734 "Unable to allocate memory for JSON object");
10736 "{\"error\": {\"message:\": \"Unable to allocate memory for JSON object\"}}}\n");
10740 json_object_int_add(json
, "vrfId",
10741 (bgp
->vrf_id
== VRF_UNKNOWN
)
10743 : (int64_t)bgp
->vrf_id
);
10744 json_object_string_add(
10746 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10751 vty_out(vty
, ",\n");
10755 vty_out(vty
, "\"%s\":",
10756 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10760 vty_out(vty
, "\nInstance %s:\n",
10761 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
10766 if (type
== show_peer
) {
10767 ret
= str2sockunion(ip_str
, &su
);
10769 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10772 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10775 bgp_show_neighbor(vty
, bgp
, show_all
, NULL
, NULL
,
10781 vty_out(vty
, "}\n");
10784 static int bgp_show_neighbor_vty(struct vty
*vty
, const char *name
,
10785 enum show_type type
, const char *ip_str
,
10790 union sockunion su
;
10791 json_object
*json
= NULL
;
10794 if (strmatch(name
, "all")) {
10795 bgp_show_all_instances_neighbors_vty(vty
, type
, ip_str
,
10797 return CMD_SUCCESS
;
10799 bgp
= bgp_lookup_by_name(name
);
10802 json
= json_object_new_object();
10803 json_object_boolean_true_add(
10804 json
, "bgpNoSuchInstance");
10805 vty_out(vty
, "%s\n",
10806 json_object_to_json_string_ext(
10808 JSON_C_TO_STRING_PRETTY
));
10809 json_object_free(json
);
10812 "%% No such BGP instance exist\n");
10814 return CMD_WARNING
;
10818 bgp
= bgp_get_default();
10822 json
= json_object_new_object();
10824 ret
= str2sockunion(ip_str
, &su
);
10826 bgp_show_neighbor(vty
, bgp
, type
, NULL
, ip_str
,
10829 bgp_show_neighbor(vty
, bgp
, type
, &su
, NULL
,
10832 bgp_show_neighbor(vty
, bgp
, type
, NULL
, NULL
, use_json
,
10835 json_object_free(json
);
10838 return CMD_SUCCESS
;
10841 /* "show [ip] bgp neighbors" commands. */
10842 DEFUN (show_ip_bgp_neighbors
,
10843 show_ip_bgp_neighbors_cmd
,
10844 "show [ip] bgp [<view|vrf> VIEWVRFNAME] [<ipv4|ipv6>] neighbors [<A.B.C.D|X:X::X:X|WORD>] [json]",
10848 BGP_INSTANCE_HELP_STR
10851 "Detailed information on TCP and BGP neighbor connections\n"
10852 "Neighbor to display information about\n"
10853 "Neighbor to display information about\n"
10854 "Neighbor on BGP configured interface\n"
10858 char *sh_arg
= NULL
;
10859 enum show_type sh_type
;
10861 uint8_t uj
= use_json(argc
, argv
);
10865 if (argv_find(argv
, argc
, "view", &idx
)
10866 || argv_find(argv
, argc
, "vrf", &idx
))
10867 vrf
= argv
[idx
+ 1]->arg
;
10870 if (argv_find(argv
, argc
, "A.B.C.D", &idx
)
10871 || argv_find(argv
, argc
, "X:X::X:X", &idx
)
10872 || argv_find(argv
, argc
, "WORD", &idx
)) {
10873 sh_type
= show_peer
;
10874 sh_arg
= argv
[idx
]->arg
;
10876 sh_type
= show_all
;
10878 return bgp_show_neighbor_vty(vty
, vrf
, sh_type
, sh_arg
, uj
);
10881 /* Show BGP's AS paths internal data. There are both `show [ip] bgp
10882 paths' and `show ip mbgp paths'. Those functions results are the
10884 DEFUN (show_ip_bgp_paths
,
10885 show_ip_bgp_paths_cmd
,
10886 "show [ip] bgp ["BGP_SAFI_CMD_STR
"] paths",
10891 "Path information\n")
10893 vty_out(vty
, "Address Refcnt Path\n");
10894 aspath_print_all_vty(vty
);
10895 return CMD_SUCCESS
;
10900 static void community_show_all_iterator(struct hash_backet
*backet
,
10903 struct community
*com
;
10905 com
= (struct community
*)backet
->data
;
10906 vty_out(vty
, "[%p] (%ld) %s\n", (void *)com
, com
->refcnt
,
10907 community_str(com
, false));
10910 /* Show BGP's community internal data. */
10911 DEFUN (show_ip_bgp_community_info
,
10912 show_ip_bgp_community_info_cmd
,
10913 "show [ip] bgp community-info",
10917 "List all bgp community information\n")
10919 vty_out(vty
, "Address Refcnt Community\n");
10921 hash_iterate(community_hash(),
10922 (void (*)(struct hash_backet
*,
10923 void *))community_show_all_iterator
,
10926 return CMD_SUCCESS
;
10929 static void lcommunity_show_all_iterator(struct hash_backet
*backet
,
10932 struct lcommunity
*lcom
;
10934 lcom
= (struct lcommunity
*)backet
->data
;
10935 vty_out(vty
, "[%p] (%ld) %s\n", (void *)lcom
, lcom
->refcnt
,
10936 lcommunity_str(lcom
, false));
10939 /* Show BGP's community internal data. */
10940 DEFUN (show_ip_bgp_lcommunity_info
,
10941 show_ip_bgp_lcommunity_info_cmd
,
10942 "show ip bgp large-community-info",
10946 "List all bgp large-community information\n")
10948 vty_out(vty
, "Address Refcnt Large-community\n");
10950 hash_iterate(lcommunity_hash(),
10951 (void (*)(struct hash_backet
*,
10952 void *))lcommunity_show_all_iterator
,
10955 return CMD_SUCCESS
;
10959 DEFUN (show_ip_bgp_attr_info
,
10960 show_ip_bgp_attr_info_cmd
,
10961 "show [ip] bgp attribute-info",
10965 "List all bgp attribute information\n")
10967 attr_show_all(vty
);
10968 return CMD_SUCCESS
;
10971 static int bgp_show_route_leak_vty(struct vty
*vty
, const char *name
,
10972 afi_t afi
, safi_t safi
)
10975 struct listnode
*node
;
10977 char buf1
[INET6_ADDRSTRLEN
];
10979 vpn_policy_direction_t dir
;
10982 bgp
= bgp_lookup_by_name(name
);
10984 vty_out(vty
, "%% No such BGP instance exist\n");
10985 return CMD_WARNING
;
10988 bgp
= bgp_get_default();
10991 "%% Default BGP instance does not exist\n");
10992 return CMD_WARNING
;
10996 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
10997 BGP_CONFIG_VRF_TO_VRF_IMPORT
)) {
10999 "This VRF is not importing %s routes from any other VRF\n",
11000 afi_safi_print(afi
, safi
));
11003 "This VRF is importing %s routes from the following VRFs:\n",
11004 afi_safi_print(afi
, safi
));
11005 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].import_vrf
, node
,
11007 vty_out(vty
, " %s\n", vname
);
11009 dir
= BGP_VPN_POLICY_DIR_FROMVPN
;
11010 ecom_str
= ecommunity_ecom2str(
11011 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11012 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11013 vty_out(vty
, "Import RT(s): %s\n", ecom_str
);
11014 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11017 if (!CHECK_FLAG(bgp
->af_flags
[afi
][safi
],
11018 BGP_CONFIG_VRF_TO_VRF_EXPORT
)) {
11020 "This VRF is not exporting %s routes to any other VRF\n",
11021 afi_safi_print(afi
, safi
));
11024 "This VRF is exporting %s routes to the following VRFs:\n",
11025 afi_safi_print(afi
, safi
));
11026 for (ALL_LIST_ELEMENTS_RO(bgp
->vpn_policy
[afi
].export_vrf
, node
,
11028 vty_out(vty
, " %s\n", vname
);
11030 vty_out(vty
, "RD: %s\n",
11031 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
,
11032 buf1
, RD_ADDRSTRLEN
));
11033 dir
= BGP_VPN_POLICY_DIR_TOVPN
;
11034 ecom_str
= ecommunity_ecom2str(
11035 bgp
->vpn_policy
[afi
].rtlist
[dir
],
11036 ECOMMUNITY_FORMAT_ROUTE_MAP
, 0);
11037 vty_out(vty
, "Emport RT: %s\n", ecom_str
);
11038 XFREE(MTYPE_ECOMMUNITY_STR
, ecom_str
);
11041 return CMD_SUCCESS
;
11044 /* "show [ip] bgp route-leak" command. */
11045 DEFUN (show_ip_bgp_route_leak
,
11046 show_ip_bgp_route_leak_cmd
,
11047 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_CMD_STR
"]] route-leak",
11051 BGP_INSTANCE_HELP_STR
11054 "Route leaking information\n")
11057 afi_t afi
= AFI_MAX
;
11058 safi_t safi
= SAFI_MAX
;
11062 /* show [ip] bgp */
11063 if (argv_find(argv
, argc
, "ip", &idx
)) {
11065 safi
= SAFI_UNICAST
;
11067 /* [vrf VIEWVRFNAME] */
11068 if (argv_find(argv
, argc
, "view", &idx
)) {
11070 "%% This command is not applicable to BGP views\n");
11071 return CMD_WARNING
;
11074 if (argv_find(argv
, argc
, "vrf", &idx
))
11075 vrf
= argv
[++idx
]->arg
;
11076 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11077 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11078 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11081 if (!((afi
== AFI_IP
|| afi
== AFI_IP6
) && safi
== SAFI_UNICAST
)) {
11083 "%% This command is applicable only for unicast ipv4|ipv6\n");
11084 return CMD_WARNING
;
11087 return bgp_show_route_leak_vty(vty
, vrf
, afi
, safi
);
11090 static void bgp_show_all_instances_updgrps_vty(struct vty
*vty
, afi_t afi
,
11093 struct listnode
*node
, *nnode
;
11096 for (ALL_LIST_ELEMENTS(bm
->bgp
, node
, nnode
, bgp
)) {
11097 vty_out(vty
, "\nInstance %s:\n",
11098 (bgp
->inst_type
== BGP_INSTANCE_TYPE_DEFAULT
)
11101 update_group_show(bgp
, afi
, safi
, vty
, 0);
11105 static int bgp_show_update_groups(struct vty
*vty
, const char *name
, int afi
,
11106 int safi
, uint64_t subgrp_id
)
11111 if (strmatch(name
, "all")) {
11112 bgp_show_all_instances_updgrps_vty(vty
, afi
, safi
);
11113 return CMD_SUCCESS
;
11115 bgp
= bgp_lookup_by_name(name
);
11118 bgp
= bgp_get_default();
11122 update_group_show(bgp
, afi
, safi
, vty
, subgrp_id
);
11123 return CMD_SUCCESS
;
11126 DEFUN (show_ip_bgp_updgrps
,
11127 show_ip_bgp_updgrps_cmd
,
11128 "show [ip] bgp [<view|vrf> VIEWVRFNAME] ["BGP_AFI_CMD_STR
" ["BGP_SAFI_WITH_LABEL_CMD_STR
"]] update-groups [SUBGROUP-ID]",
11132 BGP_INSTANCE_HELP_STR
11134 BGP_SAFI_WITH_LABEL_HELP_STR
11135 "Detailed info about dynamic update groups\n"
11136 "Specific subgroup to display detailed info for\n")
11139 afi_t afi
= AFI_IP6
;
11140 safi_t safi
= SAFI_UNICAST
;
11141 uint64_t subgrp_id
= 0;
11145 /* show [ip] bgp */
11146 if (argv_find(argv
, argc
, "ip", &idx
))
11148 /* [<view|vrf> VIEWVRFNAME] */
11149 if (argv_find(argv
, argc
, "view", &idx
)
11150 || argv_find(argv
, argc
, "vrf", &idx
))
11151 vrf
= argv
[++idx
]->arg
;
11152 /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */
11153 if (argv_find_and_parse_afi(argv
, argc
, &idx
, &afi
)) {
11154 argv_find_and_parse_safi(argv
, argc
, &idx
, &safi
);
11157 /* get subgroup id, if provided */
11159 if (argv
[idx
]->type
== VARIABLE_TKN
)
11160 subgrp_id
= strtoull(argv
[idx
]->arg
, NULL
, 10);
11162 return (bgp_show_update_groups(vty
, vrf
, afi
, safi
, subgrp_id
));
11165 DEFUN (show_bgp_instance_all_ipv6_updgrps
,
11166 show_bgp_instance_all_ipv6_updgrps_cmd
,
11167 "show [ip] bgp <view|vrf> all update-groups",
11171 BGP_INSTANCE_ALL_HELP_STR
11172 "Detailed info about dynamic update groups\n")
11174 bgp_show_all_instances_updgrps_vty(vty
, AFI_IP6
, SAFI_UNICAST
);
11175 return CMD_SUCCESS
;
11178 DEFUN (show_bgp_updgrps_stats
,
11179 show_bgp_updgrps_stats_cmd
,
11180 "show [ip] bgp update-groups statistics",
11184 "Detailed info about dynamic update groups\n"
11189 bgp
= bgp_get_default();
11191 update_group_show_stats(bgp
, vty
);
11193 return CMD_SUCCESS
;
11196 DEFUN (show_bgp_instance_updgrps_stats
,
11197 show_bgp_instance_updgrps_stats_cmd
,
11198 "show [ip] bgp <view|vrf> VIEWVRFNAME update-groups statistics",
11202 BGP_INSTANCE_HELP_STR
11203 "Detailed info about dynamic update groups\n"
11209 bgp
= bgp_lookup_by_name(argv
[idx_word
]->arg
);
11211 update_group_show_stats(bgp
, vty
);
11213 return CMD_SUCCESS
;
11216 static void show_bgp_updgrps_adj_info_aux(struct vty
*vty
, const char *name
,
11217 afi_t afi
, safi_t safi
,
11218 const char *what
, uint64_t subgrp_id
)
11223 bgp
= bgp_lookup_by_name(name
);
11225 bgp
= bgp_get_default();
11228 if (!strcmp(what
, "advertise-queue"))
11229 update_group_show_adj_queue(bgp
, afi
, safi
, vty
,
11231 else if (!strcmp(what
, "advertised-routes"))
11232 update_group_show_advertised(bgp
, afi
, safi
, vty
,
11234 else if (!strcmp(what
, "packet-queue"))
11235 update_group_show_packet_queue(bgp
, afi
, safi
, vty
,
11240 DEFPY(show_ip_bgp_instance_updgrps_adj_s
,
11241 show_ip_bgp_instance_updgrps_adj_s_cmd
,
11242 "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",
11243 SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR BGP_AFI_HELP_STR
11245 "Detailed info about dynamic update groups\n"
11246 "Specific subgroup to display info for\n"
11247 "Advertisement queue\n"
11248 "Announced routes\n"
11251 uint64_t subgrp_id
= 0;
11255 subgrp_id
= strtoull(sgid
, NULL
, 10);
11260 afiz
= bgp_vty_afi_from_str(afi
);
11264 afiz
= bgp_vty_afi_from_str(afi
);
11265 if (afiz
!= AFI_IP
)
11267 "%% Cannot specify both 'ip' and 'ipv6'\n");
11268 return CMD_WARNING
;
11271 safiz
= safi
? bgp_vty_safi_from_str(safi
) : SAFI_UNICAST
;
11273 show_bgp_updgrps_adj_info_aux(vty
, vrf
, afiz
, safiz
, rtq
, subgrp_id
);
11274 return CMD_SUCCESS
;
11277 static int bgp_show_one_peer_group(struct vty
*vty
, struct peer_group
*group
)
11279 struct listnode
*node
, *nnode
;
11280 struct prefix
*range
;
11283 char buf
[PREFIX2STR_BUFFER
];
11286 const char *peer_status
;
11287 const char *af_str
;
11292 conf
= group
->conf
;
11294 if (conf
->as_type
== AS_SPECIFIED
|| conf
->as_type
== AS_EXTERNAL
) {
11295 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
11297 } else if (conf
->as_type
== AS_INTERNAL
) {
11298 vty_out(vty
, "\nBGP peer-group %s, remote AS %d\n", group
->name
,
11301 vty_out(vty
, "\nBGP peer-group %s\n", group
->name
);
11304 if ((group
->bgp
->as
== conf
->as
) || (conf
->as_type
== AS_INTERNAL
))
11305 vty_out(vty
, " Peer-group type is internal\n");
11307 vty_out(vty
, " Peer-group type is external\n");
11309 /* Display AFs configured. */
11310 vty_out(vty
, " Configured address-families:");
11311 FOREACH_AFI_SAFI (afi
, safi
) {
11312 if (conf
->afc
[afi
][safi
]) {
11314 vty_out(vty
, " %s;", afi_safi_print(afi
, safi
));
11318 vty_out(vty
, " none\n");
11320 vty_out(vty
, "\n");
11322 /* Display listen ranges (for dynamic neighbors), if any */
11323 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++) {
11326 else if (afi
== AFI_IP6
)
11330 lr_count
= listcount(group
->listen_range
[afi
]);
11332 vty_out(vty
, " %d %s listen range(s)\n", lr_count
,
11336 for (ALL_LIST_ELEMENTS(group
->listen_range
[afi
], node
,
11338 prefix2str(range
, buf
, sizeof(buf
));
11339 vty_out(vty
, " %s\n", buf
);
11344 /* Display group members and their status */
11345 if (listcount(group
->peer
)) {
11346 vty_out(vty
, " Peer-group members:\n");
11347 for (ALL_LIST_ELEMENTS(group
->peer
, node
, nnode
, peer
)) {
11348 if (CHECK_FLAG(peer
->flags
, PEER_FLAG_SHUTDOWN
))
11349 peer_status
= "Idle (Admin)";
11350 else if (CHECK_FLAG(peer
->sflags
,
11351 PEER_STATUS_PREFIX_OVERFLOW
))
11352 peer_status
= "Idle (PfxCt)";
11354 peer_status
= lookup_msg(bgp_status_msg
,
11355 peer
->status
, NULL
);
11357 dynamic
= peer_dynamic_neighbor(peer
);
11358 vty_out(vty
, " %s %s %s \n", peer
->host
,
11359 dynamic
? "(dynamic)" : "", peer_status
);
11363 return CMD_SUCCESS
;
11366 static int bgp_show_peer_group_vty(struct vty
*vty
, const char *name
,
11367 const char *group_name
)
11370 struct listnode
*node
, *nnode
;
11371 struct peer_group
*group
;
11372 bool found
= false;
11374 bgp
= name
? bgp_lookup_by_name(name
) : bgp_get_default();
11377 vty_out(vty
, "%% No such BGP instance exists\n");
11378 return CMD_WARNING
;
11381 for (ALL_LIST_ELEMENTS(bgp
->group
, node
, nnode
, group
)) {
11383 if (strmatch(group
->name
, group_name
)) {
11384 bgp_show_one_peer_group(vty
, group
);
11389 bgp_show_one_peer_group(vty
, group
);
11393 if (group_name
&& !found
)
11394 vty_out(vty
, "%% No such peer-group\n");
11396 return CMD_SUCCESS
;
11399 DEFUN (show_ip_bgp_peer_groups
,
11400 show_ip_bgp_peer_groups_cmd
,
11401 "show [ip] bgp [<view|vrf> VIEWVRFNAME] peer-group [PGNAME]",
11405 BGP_INSTANCE_HELP_STR
11406 "Detailed information on BGP peer groups\n"
11407 "Peer group name\n")
11413 vrf
= argv_find(argv
, argc
, "VIEWVRFNAME", &idx
) ? argv
[idx
]->arg
11415 pg
= argv_find(argv
, argc
, "PGNAME", &idx
) ? argv
[idx
]->arg
: NULL
;
11417 return bgp_show_peer_group_vty(vty
, vrf
, pg
);
11421 /* Redistribute VTY commands. */
11423 DEFUN (bgp_redistribute_ipv4
,
11424 bgp_redistribute_ipv4_cmd
,
11425 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11426 "Redistribute information from another routing protocol\n"
11427 FRR_IP_REDIST_HELP_STR_BGPD
)
11429 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11430 int idx_protocol
= 1;
11433 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11435 vty_out(vty
, "%% Invalid route type\n");
11436 return CMD_WARNING_CONFIG_FAILED
;
11439 bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11440 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11444 bgp_redistribute_ipv4
, bgp_redistribute_ipv4_hidden_cmd
,
11445 "redistribute " FRR_IP_REDIST_STR_BGPD
,
11446 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
)
11448 DEFUN (bgp_redistribute_ipv4_rmap
,
11449 bgp_redistribute_ipv4_rmap_cmd
,
11450 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11451 "Redistribute information from another routing protocol\n"
11452 FRR_IP_REDIST_HELP_STR_BGPD
11453 "Route map reference\n"
11454 "Pointer to route-map entries\n")
11456 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11457 int idx_protocol
= 1;
11460 struct bgp_redist
*red
;
11462 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11464 vty_out(vty
, "%% Invalid route type\n");
11465 return CMD_WARNING_CONFIG_FAILED
;
11468 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11469 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11470 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11474 bgp_redistribute_ipv4_rmap
, bgp_redistribute_ipv4_rmap_hidden_cmd
,
11475 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD",
11476 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11477 "Route map reference\n"
11478 "Pointer to route-map entries\n")
11480 DEFUN (bgp_redistribute_ipv4_metric
,
11481 bgp_redistribute_ipv4_metric_cmd
,
11482 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11483 "Redistribute information from another routing protocol\n"
11484 FRR_IP_REDIST_HELP_STR_BGPD
11485 "Metric for redistributed routes\n"
11486 "Default metric\n")
11488 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11489 int idx_protocol
= 1;
11490 int idx_number
= 3;
11493 struct bgp_redist
*red
;
11495 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11497 vty_out(vty
, "%% Invalid route type\n");
11498 return CMD_WARNING_CONFIG_FAILED
;
11500 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11502 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11503 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11504 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11508 bgp_redistribute_ipv4_metric
, bgp_redistribute_ipv4_metric_hidden_cmd
,
11509 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295)",
11510 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11511 "Metric for redistributed routes\n"
11512 "Default metric\n")
11514 DEFUN (bgp_redistribute_ipv4_rmap_metric
,
11515 bgp_redistribute_ipv4_rmap_metric_cmd
,
11516 "redistribute " FRR_IP_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11517 "Redistribute information from another routing protocol\n"
11518 FRR_IP_REDIST_HELP_STR_BGPD
11519 "Route map reference\n"
11520 "Pointer to route-map entries\n"
11521 "Metric for redistributed routes\n"
11522 "Default metric\n")
11524 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11525 int idx_protocol
= 1;
11527 int idx_number
= 5;
11530 struct bgp_redist
*red
;
11532 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11534 vty_out(vty
, "%% Invalid route type\n");
11535 return CMD_WARNING_CONFIG_FAILED
;
11537 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11539 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11540 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11541 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11542 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11546 bgp_redistribute_ipv4_rmap_metric
,
11547 bgp_redistribute_ipv4_rmap_metric_hidden_cmd
,
11548 "redistribute " FRR_IP_REDIST_STR_BGPD
11549 " route-map WORD metric (0-4294967295)",
11550 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11551 "Route map reference\n"
11552 "Pointer to route-map entries\n"
11553 "Metric for redistributed routes\n"
11554 "Default metric\n")
11556 DEFUN (bgp_redistribute_ipv4_metric_rmap
,
11557 bgp_redistribute_ipv4_metric_rmap_cmd
,
11558 "redistribute " FRR_IP_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
11559 "Redistribute information from another routing protocol\n"
11560 FRR_IP_REDIST_HELP_STR_BGPD
11561 "Metric for redistributed routes\n"
11563 "Route map reference\n"
11564 "Pointer to route-map entries\n")
11566 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11567 int idx_protocol
= 1;
11568 int idx_number
= 3;
11572 struct bgp_redist
*red
;
11574 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11576 vty_out(vty
, "%% Invalid route type\n");
11577 return CMD_WARNING_CONFIG_FAILED
;
11579 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11581 red
= bgp_redist_add(bgp
, AFI_IP
, type
, 0);
11582 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, type
, metric
);
11583 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11584 return bgp_redistribute_set(bgp
, AFI_IP
, type
, 0);
11588 bgp_redistribute_ipv4_metric_rmap
,
11589 bgp_redistribute_ipv4_metric_rmap_hidden_cmd
,
11590 "redistribute " FRR_IP_REDIST_STR_BGPD
11591 " metric (0-4294967295) route-map WORD",
11592 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11593 "Metric for redistributed routes\n"
11595 "Route map reference\n"
11596 "Pointer to route-map entries\n")
11598 DEFUN (bgp_redistribute_ipv4_ospf
,
11599 bgp_redistribute_ipv4_ospf_cmd
,
11600 "redistribute <ospf|table> (1-65535)",
11601 "Redistribute information from another routing protocol\n"
11602 "Open Shortest Path First (OSPFv2)\n"
11603 "Non-main Kernel Routing Table\n"
11604 "Instance ID/Table ID\n")
11606 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11607 int idx_ospf_table
= 1;
11608 int idx_number
= 2;
11609 unsigned short instance
;
11610 unsigned short protocol
;
11612 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11614 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11615 protocol
= ZEBRA_ROUTE_OSPF
;
11617 protocol
= ZEBRA_ROUTE_TABLE
;
11619 bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11620 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11623 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf
, bgp_redistribute_ipv4_ospf_hidden_cmd
,
11624 "redistribute <ospf|table> (1-65535)",
11625 "Redistribute information from another routing protocol\n"
11626 "Open Shortest Path First (OSPFv2)\n"
11627 "Non-main Kernel Routing Table\n"
11628 "Instance ID/Table ID\n")
11630 DEFUN (bgp_redistribute_ipv4_ospf_rmap
,
11631 bgp_redistribute_ipv4_ospf_rmap_cmd
,
11632 "redistribute <ospf|table> (1-65535) route-map WORD",
11633 "Redistribute information from another routing protocol\n"
11634 "Open Shortest Path First (OSPFv2)\n"
11635 "Non-main Kernel Routing Table\n"
11636 "Instance ID/Table ID\n"
11637 "Route map reference\n"
11638 "Pointer to route-map entries\n")
11640 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11641 int idx_ospf_table
= 1;
11642 int idx_number
= 2;
11644 struct bgp_redist
*red
;
11645 unsigned short instance
;
11648 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11649 protocol
= ZEBRA_ROUTE_OSPF
;
11651 protocol
= ZEBRA_ROUTE_TABLE
;
11653 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11654 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11655 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11656 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11659 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_rmap
,
11660 bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
,
11661 "redistribute <ospf|table> (1-65535) route-map WORD",
11662 "Redistribute information from another routing protocol\n"
11663 "Open Shortest Path First (OSPFv2)\n"
11664 "Non-main Kernel Routing Table\n"
11665 "Instance ID/Table ID\n"
11666 "Route map reference\n"
11667 "Pointer to route-map entries\n")
11669 DEFUN (bgp_redistribute_ipv4_ospf_metric
,
11670 bgp_redistribute_ipv4_ospf_metric_cmd
,
11671 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
11672 "Redistribute information from another routing protocol\n"
11673 "Open Shortest Path First (OSPFv2)\n"
11674 "Non-main Kernel Routing Table\n"
11675 "Instance ID/Table ID\n"
11676 "Metric for redistributed routes\n"
11677 "Default metric\n")
11679 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11680 int idx_ospf_table
= 1;
11681 int idx_number
= 2;
11682 int idx_number_2
= 4;
11684 struct bgp_redist
*red
;
11685 unsigned short instance
;
11688 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11689 protocol
= ZEBRA_ROUTE_OSPF
;
11691 protocol
= ZEBRA_ROUTE_TABLE
;
11693 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11694 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11696 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11697 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11698 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11701 ALIAS_HIDDEN(bgp_redistribute_ipv4_ospf_metric
,
11702 bgp_redistribute_ipv4_ospf_metric_hidden_cmd
,
11703 "redistribute <ospf|table> (1-65535) metric (0-4294967295)",
11704 "Redistribute information from another routing protocol\n"
11705 "Open Shortest Path First (OSPFv2)\n"
11706 "Non-main Kernel Routing Table\n"
11707 "Instance ID/Table ID\n"
11708 "Metric for redistributed routes\n"
11709 "Default metric\n")
11711 DEFUN (bgp_redistribute_ipv4_ospf_rmap_metric
,
11712 bgp_redistribute_ipv4_ospf_rmap_metric_cmd
,
11713 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
11714 "Redistribute information from another routing protocol\n"
11715 "Open Shortest Path First (OSPFv2)\n"
11716 "Non-main Kernel Routing Table\n"
11717 "Instance ID/Table ID\n"
11718 "Route map reference\n"
11719 "Pointer to route-map entries\n"
11720 "Metric for redistributed routes\n"
11721 "Default metric\n")
11723 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11724 int idx_ospf_table
= 1;
11725 int idx_number
= 2;
11727 int idx_number_2
= 6;
11729 struct bgp_redist
*red
;
11730 unsigned short instance
;
11733 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11734 protocol
= ZEBRA_ROUTE_OSPF
;
11736 protocol
= ZEBRA_ROUTE_TABLE
;
11738 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11739 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11741 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11742 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11743 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11744 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11748 bgp_redistribute_ipv4_ospf_rmap_metric
,
11749 bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
,
11750 "redistribute <ospf|table> (1-65535) route-map WORD metric (0-4294967295)",
11751 "Redistribute information from another routing protocol\n"
11752 "Open Shortest Path First (OSPFv2)\n"
11753 "Non-main Kernel Routing Table\n"
11754 "Instance ID/Table ID\n"
11755 "Route map reference\n"
11756 "Pointer to route-map entries\n"
11757 "Metric for redistributed routes\n"
11758 "Default metric\n")
11760 DEFUN (bgp_redistribute_ipv4_ospf_metric_rmap
,
11761 bgp_redistribute_ipv4_ospf_metric_rmap_cmd
,
11762 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
11763 "Redistribute information from another routing protocol\n"
11764 "Open Shortest Path First (OSPFv2)\n"
11765 "Non-main Kernel Routing Table\n"
11766 "Instance ID/Table ID\n"
11767 "Metric for redistributed routes\n"
11769 "Route map reference\n"
11770 "Pointer to route-map entries\n")
11772 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11773 int idx_ospf_table
= 1;
11774 int idx_number
= 2;
11775 int idx_number_2
= 4;
11778 struct bgp_redist
*red
;
11779 unsigned short instance
;
11782 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11783 protocol
= ZEBRA_ROUTE_OSPF
;
11785 protocol
= ZEBRA_ROUTE_TABLE
;
11787 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11788 metric
= strtoul(argv
[idx_number_2
]->arg
, NULL
, 10);
11790 red
= bgp_redist_add(bgp
, AFI_IP
, protocol
, instance
);
11791 bgp_redistribute_metric_set(bgp
, red
, AFI_IP
, protocol
, metric
);
11792 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11793 return bgp_redistribute_set(bgp
, AFI_IP
, protocol
, instance
);
11797 bgp_redistribute_ipv4_ospf_metric_rmap
,
11798 bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
,
11799 "redistribute <ospf|table> (1-65535) metric (0-4294967295) route-map WORD",
11800 "Redistribute information from another routing protocol\n"
11801 "Open Shortest Path First (OSPFv2)\n"
11802 "Non-main Kernel Routing Table\n"
11803 "Instance ID/Table ID\n"
11804 "Metric for redistributed routes\n"
11806 "Route map reference\n"
11807 "Pointer to route-map entries\n")
11809 DEFUN (no_bgp_redistribute_ipv4_ospf
,
11810 no_bgp_redistribute_ipv4_ospf_cmd
,
11811 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
11813 "Redistribute information from another routing protocol\n"
11814 "Open Shortest Path First (OSPFv2)\n"
11815 "Non-main Kernel Routing Table\n"
11816 "Instance ID/Table ID\n"
11817 "Metric for redistributed routes\n"
11819 "Route map reference\n"
11820 "Pointer to route-map entries\n")
11822 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11823 int idx_ospf_table
= 2;
11824 int idx_number
= 3;
11825 unsigned short instance
;
11828 if (strncmp(argv
[idx_ospf_table
]->arg
, "o", 1) == 0)
11829 protocol
= ZEBRA_ROUTE_OSPF
;
11831 protocol
= ZEBRA_ROUTE_TABLE
;
11833 instance
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11834 return bgp_redistribute_unset(bgp
, AFI_IP
, protocol
, instance
);
11838 no_bgp_redistribute_ipv4_ospf
, no_bgp_redistribute_ipv4_ospf_hidden_cmd
,
11839 "no redistribute <ospf|table> (1-65535) [metric (0-4294967295)] [route-map WORD]",
11841 "Redistribute information from another routing protocol\n"
11842 "Open Shortest Path First (OSPFv2)\n"
11843 "Non-main Kernel Routing Table\n"
11844 "Instance ID/Table ID\n"
11845 "Metric for redistributed routes\n"
11847 "Route map reference\n"
11848 "Pointer to route-map entries\n")
11850 DEFUN (no_bgp_redistribute_ipv4
,
11851 no_bgp_redistribute_ipv4_cmd
,
11852 "no redistribute " FRR_IP_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
11854 "Redistribute information from another routing protocol\n"
11855 FRR_IP_REDIST_HELP_STR_BGPD
11856 "Metric for redistributed routes\n"
11858 "Route map reference\n"
11859 "Pointer to route-map entries\n")
11861 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11862 int idx_protocol
= 2;
11865 type
= proto_redistnum(AFI_IP
, argv
[idx_protocol
]->text
);
11867 vty_out(vty
, "%% Invalid route type\n");
11868 return CMD_WARNING_CONFIG_FAILED
;
11870 return bgp_redistribute_unset(bgp
, AFI_IP
, type
, 0);
11874 no_bgp_redistribute_ipv4
, no_bgp_redistribute_ipv4_hidden_cmd
,
11875 "no redistribute " FRR_IP_REDIST_STR_BGPD
11876 " [metric (0-4294967295)] [route-map WORD]",
11878 "Redistribute information from another routing protocol\n" FRR_IP_REDIST_HELP_STR_BGPD
11879 "Metric for redistributed routes\n"
11881 "Route map reference\n"
11882 "Pointer to route-map entries\n")
11884 DEFUN (bgp_redistribute_ipv6
,
11885 bgp_redistribute_ipv6_cmd
,
11886 "redistribute " FRR_IP6_REDIST_STR_BGPD
,
11887 "Redistribute information from another routing protocol\n"
11888 FRR_IP6_REDIST_HELP_STR_BGPD
)
11890 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11891 int idx_protocol
= 1;
11894 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11896 vty_out(vty
, "%% Invalid route type\n");
11897 return CMD_WARNING_CONFIG_FAILED
;
11900 bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11901 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11904 DEFUN (bgp_redistribute_ipv6_rmap
,
11905 bgp_redistribute_ipv6_rmap_cmd
,
11906 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD",
11907 "Redistribute information from another routing protocol\n"
11908 FRR_IP6_REDIST_HELP_STR_BGPD
11909 "Route map reference\n"
11910 "Pointer to route-map entries\n")
11912 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11913 int idx_protocol
= 1;
11916 struct bgp_redist
*red
;
11918 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11920 vty_out(vty
, "%% Invalid route type\n");
11921 return CMD_WARNING_CONFIG_FAILED
;
11924 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11925 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11926 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11929 DEFUN (bgp_redistribute_ipv6_metric
,
11930 bgp_redistribute_ipv6_metric_cmd
,
11931 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295)",
11932 "Redistribute information from another routing protocol\n"
11933 FRR_IP6_REDIST_HELP_STR_BGPD
11934 "Metric for redistributed routes\n"
11935 "Default metric\n")
11937 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11938 int idx_protocol
= 1;
11939 int idx_number
= 3;
11942 struct bgp_redist
*red
;
11944 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11946 vty_out(vty
, "%% Invalid route type\n");
11947 return CMD_WARNING_CONFIG_FAILED
;
11949 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11951 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11952 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
11953 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11956 DEFUN (bgp_redistribute_ipv6_rmap_metric
,
11957 bgp_redistribute_ipv6_rmap_metric_cmd
,
11958 "redistribute " FRR_IP6_REDIST_STR_BGPD
" route-map WORD metric (0-4294967295)",
11959 "Redistribute information from another routing protocol\n"
11960 FRR_IP6_REDIST_HELP_STR_BGPD
11961 "Route map reference\n"
11962 "Pointer to route-map entries\n"
11963 "Metric for redistributed routes\n"
11964 "Default metric\n")
11966 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11967 int idx_protocol
= 1;
11969 int idx_number
= 5;
11972 struct bgp_redist
*red
;
11974 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
11976 vty_out(vty
, "%% Invalid route type\n");
11977 return CMD_WARNING_CONFIG_FAILED
;
11979 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
11981 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
11982 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
11983 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, type
, metric
);
11984 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
11987 DEFUN (bgp_redistribute_ipv6_metric_rmap
,
11988 bgp_redistribute_ipv6_metric_rmap_cmd
,
11989 "redistribute " FRR_IP6_REDIST_STR_BGPD
" metric (0-4294967295) route-map WORD",
11990 "Redistribute information from another routing protocol\n"
11991 FRR_IP6_REDIST_HELP_STR_BGPD
11992 "Metric for redistributed routes\n"
11994 "Route map reference\n"
11995 "Pointer to route-map entries\n")
11997 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
11998 int idx_protocol
= 1;
11999 int idx_number
= 3;
12003 struct bgp_redist
*red
;
12005 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12007 vty_out(vty
, "%% Invalid route type\n");
12008 return CMD_WARNING_CONFIG_FAILED
;
12010 metric
= strtoul(argv
[idx_number
]->arg
, NULL
, 10);
12012 red
= bgp_redist_add(bgp
, AFI_IP6
, type
, 0);
12013 bgp_redistribute_metric_set(bgp
, red
, AFI_IP6
, SAFI_UNICAST
, metric
);
12014 bgp_redistribute_rmap_set(red
, argv
[idx_word
]->arg
);
12015 return bgp_redistribute_set(bgp
, AFI_IP6
, type
, 0);
12018 DEFUN (no_bgp_redistribute_ipv6
,
12019 no_bgp_redistribute_ipv6_cmd
,
12020 "no redistribute " FRR_IP6_REDIST_STR_BGPD
" [metric (0-4294967295)] [route-map WORD]",
12022 "Redistribute information from another routing protocol\n"
12023 FRR_IP6_REDIST_HELP_STR_BGPD
12024 "Metric for redistributed routes\n"
12026 "Route map reference\n"
12027 "Pointer to route-map entries\n")
12029 VTY_DECLVAR_CONTEXT(bgp
, bgp
);
12030 int idx_protocol
= 2;
12033 type
= proto_redistnum(AFI_IP6
, argv
[idx_protocol
]->text
);
12035 vty_out(vty
, "%% Invalid route type\n");
12036 return CMD_WARNING_CONFIG_FAILED
;
12039 return bgp_redistribute_unset(bgp
, AFI_IP6
, type
, 0);
12042 void bgp_config_write_redistribute(struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
12047 /* Unicast redistribution only. */
12048 if (safi
!= SAFI_UNICAST
)
12051 for (i
= 0; i
< ZEBRA_ROUTE_MAX
; i
++) {
12052 /* Redistribute BGP does not make sense. */
12053 if (i
!= ZEBRA_ROUTE_BGP
) {
12054 struct list
*red_list
;
12055 struct listnode
*node
;
12056 struct bgp_redist
*red
;
12058 red_list
= bgp
->redist
[afi
][i
];
12062 for (ALL_LIST_ELEMENTS_RO(red_list
, node
, red
)) {
12063 /* "redistribute" configuration. */
12064 vty_out(vty
, " redistribute %s",
12065 zebra_route_string(i
));
12067 vty_out(vty
, " %d", red
->instance
);
12068 if (red
->redist_metric_flag
)
12069 vty_out(vty
, " metric %u",
12070 red
->redist_metric
);
12071 if (red
->rmap
.name
)
12072 vty_out(vty
, " route-map %s",
12074 vty_out(vty
, "\n");
12080 /* This is part of the address-family block (unicast only) */
12081 void bgp_vpn_policy_config_write_afi(struct vty
*vty
, struct bgp
*bgp
,
12086 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
])
12087 vty_out(vty
, "%*simport vrf route-map %s\n", indent
, "",
12088 bgp
->vpn_policy
[afi
]
12089 .rmap_name
[BGP_VPN_POLICY_DIR_FROMVPN
]);
12091 if (CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12092 BGP_CONFIG_VRF_TO_VRF_IMPORT
)
12093 || CHECK_FLAG(bgp
->af_flags
[afi
][SAFI_UNICAST
],
12094 BGP_CONFIG_VRF_TO_VRF_EXPORT
))
12097 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12098 BGP_VPN_POLICY_TOVPN_LABEL_AUTO
)) {
12100 vty_out(vty
, "%*slabel vpn export %s\n", indent
, "", "auto");
12103 if (bgp
->vpn_policy
[afi
].tovpn_label
!= MPLS_LABEL_NONE
) {
12104 vty_out(vty
, "%*slabel vpn export %u\n", indent
, "",
12105 bgp
->vpn_policy
[afi
].tovpn_label
);
12108 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12109 BGP_VPN_POLICY_TOVPN_RD_SET
)) {
12110 char buf
[RD_ADDRSTRLEN
];
12111 vty_out(vty
, "%*srd vpn export %s\n", indent
, "",
12112 prefix_rd2str(&bgp
->vpn_policy
[afi
].tovpn_rd
, buf
,
12115 if (CHECK_FLAG(bgp
->vpn_policy
[afi
].flags
,
12116 BGP_VPN_POLICY_TOVPN_NEXTHOP_SET
)) {
12118 char buf
[PREFIX_STRLEN
];
12119 if (inet_ntop(bgp
->vpn_policy
[afi
].tovpn_nexthop
.family
,
12120 &bgp
->vpn_policy
[afi
].tovpn_nexthop
.u
.prefix
, buf
,
12123 vty_out(vty
, "%*snexthop vpn export %s\n",
12127 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]
12128 && bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]
12130 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12131 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
])) {
12133 char *b
= ecommunity_ecom2str(
12134 bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12135 ECOMMUNITY_FORMAT_ROUTE_MAP
, ECOMMUNITY_ROUTE_TARGET
);
12136 vty_out(vty
, "%*srt vpn both %s\n", indent
, "", b
);
12137 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12139 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
]) {
12140 char *b
= ecommunity_ecom2str(
12141 bgp
->vpn_policy
[afi
]
12142 .rtlist
[BGP_VPN_POLICY_DIR_FROMVPN
],
12143 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12144 ECOMMUNITY_ROUTE_TARGET
);
12145 vty_out(vty
, "%*srt vpn import %s\n", indent
, "", b
);
12146 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12148 if (bgp
->vpn_policy
[afi
].rtlist
[BGP_VPN_POLICY_DIR_TOVPN
]) {
12149 char *b
= ecommunity_ecom2str(
12150 bgp
->vpn_policy
[afi
]
12151 .rtlist
[BGP_VPN_POLICY_DIR_TOVPN
],
12152 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12153 ECOMMUNITY_ROUTE_TARGET
);
12154 vty_out(vty
, "%*srt vpn export %s\n", indent
, "", b
);
12155 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12159 if (bgp
->vpn_policy
[afi
].rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
])
12160 vty_out(vty
, "%*sroute-map vpn export %s\n", indent
, "",
12161 bgp
->vpn_policy
[afi
]
12162 .rmap_name
[BGP_VPN_POLICY_DIR_TOVPN
]);
12164 if (bgp
->vpn_policy
[afi
].import_redirect_rtlist
) {
12165 char *b
= ecommunity_ecom2str(
12166 bgp
->vpn_policy
[afi
]
12167 .import_redirect_rtlist
,
12168 ECOMMUNITY_FORMAT_ROUTE_MAP
,
12169 ECOMMUNITY_ROUTE_TARGET
);
12171 vty_out(vty
, "%*srt redirect import %s\n", indent
, "", b
);
12172 XFREE(MTYPE_ECOMMUNITY_STR
, b
);
12177 /* BGP node structure. */
12178 static struct cmd_node bgp_node
= {
12179 BGP_NODE
, "%s(config-router)# ", 1,
12182 static struct cmd_node bgp_ipv4_unicast_node
= {
12183 BGP_IPV4_NODE
, "%s(config-router-af)# ", 1,
12186 static struct cmd_node bgp_ipv4_multicast_node
= {
12187 BGP_IPV4M_NODE
, "%s(config-router-af)# ", 1,
12190 static struct cmd_node bgp_ipv4_labeled_unicast_node
= {
12191 BGP_IPV4L_NODE
, "%s(config-router-af)# ", 1,
12194 static struct cmd_node bgp_ipv6_unicast_node
= {
12195 BGP_IPV6_NODE
, "%s(config-router-af)# ", 1,
12198 static struct cmd_node bgp_ipv6_multicast_node
= {
12199 BGP_IPV6M_NODE
, "%s(config-router-af)# ", 1,
12202 static struct cmd_node bgp_ipv6_labeled_unicast_node
= {
12203 BGP_IPV6L_NODE
, "%s(config-router-af)# ", 1,
12206 static struct cmd_node bgp_vpnv4_node
= {BGP_VPNV4_NODE
,
12207 "%s(config-router-af)# ", 1};
12209 static struct cmd_node bgp_vpnv6_node
= {BGP_VPNV6_NODE
,
12210 "%s(config-router-af-vpnv6)# ", 1};
12212 static struct cmd_node bgp_evpn_node
= {BGP_EVPN_NODE
,
12213 "%s(config-router-evpn)# ", 1};
12215 static struct cmd_node bgp_evpn_vni_node
= {BGP_EVPN_VNI_NODE
,
12216 "%s(config-router-af-vni)# ", 1};
12218 static struct cmd_node bgp_flowspecv4_node
= {BGP_FLOWSPECV4_NODE
,
12219 "%s(config-router-af)# ", 1};
12221 static struct cmd_node bgp_flowspecv6_node
= {BGP_FLOWSPECV6_NODE
,
12222 "%s(config-router-af-vpnv6)# ", 1};
12224 static void community_list_vty(void);
12226 static void bgp_ac_neighbor(vector comps
, struct cmd_token
*token
)
12230 struct listnode
*lnbgp
, *lnpeer
;
12232 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12233 for (ALL_LIST_ELEMENTS_RO(bgp
->peer
, lnpeer
, peer
)) {
12234 /* only provide suggestions on the appropriate input
12236 * they'll otherwise show up multiple times */
12237 enum cmd_token_type match_type
;
12238 char *name
= peer
->host
;
12240 if (peer
->conf_if
) {
12241 match_type
= VARIABLE_TKN
;
12242 name
= peer
->conf_if
;
12243 } else if (strchr(peer
->host
, ':'))
12244 match_type
= IPV6_TKN
;
12246 match_type
= IPV4_TKN
;
12248 if (token
->type
!= match_type
)
12251 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
, name
));
12256 static const struct cmd_variable_handler bgp_var_neighbor
[] = {
12257 {.varname
= "neighbor", .completions
= bgp_ac_neighbor
},
12258 {.varname
= "neighbors", .completions
= bgp_ac_neighbor
},
12259 {.varname
= "peer", .completions
= bgp_ac_neighbor
},
12260 {.completions
= NULL
}};
12262 static void bgp_ac_peergroup(vector comps
, struct cmd_token
*token
)
12265 struct peer_group
*group
;
12266 struct listnode
*lnbgp
, *lnpeer
;
12268 for (ALL_LIST_ELEMENTS_RO(bm
->bgp
, lnbgp
, bgp
)) {
12269 for (ALL_LIST_ELEMENTS_RO(bgp
->group
, lnpeer
, group
))
12270 vector_set(comps
, XSTRDUP(MTYPE_COMPLETION
,
12275 static const struct cmd_variable_handler bgp_var_peergroup
[] = {
12276 {.tokenname
= "PGNAME", .completions
= bgp_ac_peergroup
},
12277 {.completions
= NULL
} };
12279 void bgp_vty_init(void)
12281 cmd_variable_handler_register(bgp_var_neighbor
);
12282 cmd_variable_handler_register(bgp_var_peergroup
);
12284 /* Install bgp top node. */
12285 install_node(&bgp_node
, bgp_config_write
);
12286 install_node(&bgp_ipv4_unicast_node
, NULL
);
12287 install_node(&bgp_ipv4_multicast_node
, NULL
);
12288 install_node(&bgp_ipv4_labeled_unicast_node
, NULL
);
12289 install_node(&bgp_ipv6_unicast_node
, NULL
);
12290 install_node(&bgp_ipv6_multicast_node
, NULL
);
12291 install_node(&bgp_ipv6_labeled_unicast_node
, NULL
);
12292 install_node(&bgp_vpnv4_node
, NULL
);
12293 install_node(&bgp_vpnv6_node
, NULL
);
12294 install_node(&bgp_evpn_node
, NULL
);
12295 install_node(&bgp_evpn_vni_node
, NULL
);
12296 install_node(&bgp_flowspecv4_node
, NULL
);
12297 install_node(&bgp_flowspecv6_node
, NULL
);
12299 /* Install default VTY commands to new nodes. */
12300 install_default(BGP_NODE
);
12301 install_default(BGP_IPV4_NODE
);
12302 install_default(BGP_IPV4M_NODE
);
12303 install_default(BGP_IPV4L_NODE
);
12304 install_default(BGP_IPV6_NODE
);
12305 install_default(BGP_IPV6M_NODE
);
12306 install_default(BGP_IPV6L_NODE
);
12307 install_default(BGP_VPNV4_NODE
);
12308 install_default(BGP_VPNV6_NODE
);
12309 install_default(BGP_FLOWSPECV4_NODE
);
12310 install_default(BGP_FLOWSPECV6_NODE
);
12311 install_default(BGP_EVPN_NODE
);
12312 install_default(BGP_EVPN_VNI_NODE
);
12314 /* "bgp multiple-instance" commands. */
12315 install_element(CONFIG_NODE
, &bgp_multiple_instance_cmd
);
12316 install_element(CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
12318 /* "bgp config-type" commands. */
12319 install_element(CONFIG_NODE
, &bgp_config_type_cmd
);
12320 install_element(CONFIG_NODE
, &no_bgp_config_type_cmd
);
12322 /* bgp route-map delay-timer commands. */
12323 install_element(CONFIG_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12324 install_element(CONFIG_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12326 /* Dummy commands (Currently not supported) */
12327 install_element(BGP_NODE
, &no_synchronization_cmd
);
12328 install_element(BGP_NODE
, &no_auto_summary_cmd
);
12330 /* "router bgp" commands. */
12331 install_element(CONFIG_NODE
, &router_bgp_cmd
);
12333 /* "no router bgp" commands. */
12334 install_element(CONFIG_NODE
, &no_router_bgp_cmd
);
12336 /* "bgp router-id" commands. */
12337 install_element(BGP_NODE
, &bgp_router_id_cmd
);
12338 install_element(BGP_NODE
, &no_bgp_router_id_cmd
);
12340 /* "bgp cluster-id" commands. */
12341 install_element(BGP_NODE
, &bgp_cluster_id_cmd
);
12342 install_element(BGP_NODE
, &no_bgp_cluster_id_cmd
);
12344 /* "bgp confederation" commands. */
12345 install_element(BGP_NODE
, &bgp_confederation_identifier_cmd
);
12346 install_element(BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
12348 /* "bgp confederation peers" commands. */
12349 install_element(BGP_NODE
, &bgp_confederation_peers_cmd
);
12350 install_element(BGP_NODE
, &no_bgp_confederation_peers_cmd
);
12352 /* bgp max-med command */
12353 install_element(BGP_NODE
, &bgp_maxmed_admin_cmd
);
12354 install_element(BGP_NODE
, &no_bgp_maxmed_admin_cmd
);
12355 install_element(BGP_NODE
, &bgp_maxmed_admin_medv_cmd
);
12356 install_element(BGP_NODE
, &bgp_maxmed_onstartup_cmd
);
12357 install_element(BGP_NODE
, &no_bgp_maxmed_onstartup_cmd
);
12359 /* bgp disable-ebgp-connected-nh-check */
12360 install_element(BGP_NODE
, &bgp_disable_connected_route_check_cmd
);
12361 install_element(BGP_NODE
, &no_bgp_disable_connected_route_check_cmd
);
12363 /* bgp update-delay command */
12364 install_element(BGP_NODE
, &bgp_update_delay_cmd
);
12365 install_element(BGP_NODE
, &no_bgp_update_delay_cmd
);
12366 install_element(BGP_NODE
, &bgp_update_delay_establish_wait_cmd
);
12368 install_element(BGP_NODE
, &bgp_wpkt_quanta_cmd
);
12369 install_element(BGP_NODE
, &no_bgp_wpkt_quanta_cmd
);
12370 install_element(BGP_NODE
, &bgp_rpkt_quanta_cmd
);
12371 install_element(BGP_NODE
, &no_bgp_rpkt_quanta_cmd
);
12373 install_element(BGP_NODE
, &bgp_coalesce_time_cmd
);
12374 install_element(BGP_NODE
, &no_bgp_coalesce_time_cmd
);
12376 /* "maximum-paths" commands. */
12377 install_element(BGP_NODE
, &bgp_maxpaths_hidden_cmd
);
12378 install_element(BGP_NODE
, &no_bgp_maxpaths_hidden_cmd
);
12379 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_cmd
);
12380 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_cmd
);
12381 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_cmd
);
12382 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_cmd
);
12383 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_hidden_cmd
);
12384 install_element(BGP_NODE
, &bgp_maxpaths_ibgp_cluster_hidden_cmd
);
12385 install_element(BGP_NODE
, &no_bgp_maxpaths_ibgp_hidden_cmd
);
12386 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cmd
);
12387 install_element(BGP_IPV4_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12388 install_element(BGP_IPV4_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12389 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cmd
);
12390 install_element(BGP_IPV6_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12391 install_element(BGP_IPV6_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12393 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_cmd
);
12394 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_cmd
);
12395 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cmd
);
12396 install_element(BGP_IPV6L_NODE
, &bgp_maxpaths_ibgp_cluster_cmd
);
12397 install_element(BGP_IPV6L_NODE
, &no_bgp_maxpaths_ibgp_cmd
);
12399 /* "timers bgp" commands. */
12400 install_element(BGP_NODE
, &bgp_timers_cmd
);
12401 install_element(BGP_NODE
, &no_bgp_timers_cmd
);
12403 /* route-map delay-timer commands - per instance for backwards compat.
12405 install_element(BGP_NODE
, &bgp_set_route_map_delay_timer_cmd
);
12406 install_element(BGP_NODE
, &no_bgp_set_route_map_delay_timer_cmd
);
12408 /* "bgp client-to-client reflection" commands */
12409 install_element(BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
12410 install_element(BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
12412 /* "bgp always-compare-med" commands */
12413 install_element(BGP_NODE
, &bgp_always_compare_med_cmd
);
12414 install_element(BGP_NODE
, &no_bgp_always_compare_med_cmd
);
12416 /* "bgp deterministic-med" commands */
12417 install_element(BGP_NODE
, &bgp_deterministic_med_cmd
);
12418 install_element(BGP_NODE
, &no_bgp_deterministic_med_cmd
);
12420 /* "bgp graceful-restart" commands */
12421 install_element(BGP_NODE
, &bgp_graceful_restart_cmd
);
12422 install_element(BGP_NODE
, &no_bgp_graceful_restart_cmd
);
12423 install_element(BGP_NODE
, &bgp_graceful_restart_stalepath_time_cmd
);
12424 install_element(BGP_NODE
, &no_bgp_graceful_restart_stalepath_time_cmd
);
12425 install_element(BGP_NODE
, &bgp_graceful_restart_restart_time_cmd
);
12426 install_element(BGP_NODE
, &no_bgp_graceful_restart_restart_time_cmd
);
12428 install_element(BGP_NODE
, &bgp_graceful_restart_preserve_fw_cmd
);
12429 install_element(BGP_NODE
, &no_bgp_graceful_restart_preserve_fw_cmd
);
12431 /* "bgp graceful-shutdown" commands */
12432 install_element(BGP_NODE
, &bgp_graceful_shutdown_cmd
);
12433 install_element(BGP_NODE
, &no_bgp_graceful_shutdown_cmd
);
12435 /* "bgp fast-external-failover" commands */
12436 install_element(BGP_NODE
, &bgp_fast_external_failover_cmd
);
12437 install_element(BGP_NODE
, &no_bgp_fast_external_failover_cmd
);
12439 /* "bgp enforce-first-as" commands */
12440 install_element(BGP_NODE
, &bgp_enforce_first_as_cmd
);
12441 install_element(BGP_NODE
, &no_bgp_enforce_first_as_cmd
);
12443 /* "bgp bestpath compare-routerid" commands */
12444 install_element(BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
12445 install_element(BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
12447 /* "bgp bestpath as-path ignore" commands */
12448 install_element(BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
12449 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
12451 /* "bgp bestpath as-path confed" commands */
12452 install_element(BGP_NODE
, &bgp_bestpath_aspath_confed_cmd
);
12453 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_confed_cmd
);
12455 /* "bgp bestpath as-path multipath-relax" commands */
12456 install_element(BGP_NODE
, &bgp_bestpath_aspath_multipath_relax_cmd
);
12457 install_element(BGP_NODE
, &no_bgp_bestpath_aspath_multipath_relax_cmd
);
12459 /* "bgp log-neighbor-changes" commands */
12460 install_element(BGP_NODE
, &bgp_log_neighbor_changes_cmd
);
12461 install_element(BGP_NODE
, &no_bgp_log_neighbor_changes_cmd
);
12463 /* "bgp bestpath med" commands */
12464 install_element(BGP_NODE
, &bgp_bestpath_med_cmd
);
12465 install_element(BGP_NODE
, &no_bgp_bestpath_med_cmd
);
12467 /* "no bgp default ipv4-unicast" commands. */
12468 install_element(BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
12469 install_element(BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
12471 /* "bgp network import-check" commands. */
12472 install_element(BGP_NODE
, &bgp_network_import_check_cmd
);
12473 install_element(BGP_NODE
, &bgp_network_import_check_exact_cmd
);
12474 install_element(BGP_NODE
, &no_bgp_network_import_check_cmd
);
12476 /* "bgp default local-preference" commands. */
12477 install_element(BGP_NODE
, &bgp_default_local_preference_cmd
);
12478 install_element(BGP_NODE
, &no_bgp_default_local_preference_cmd
);
12480 /* bgp default show-hostname */
12481 install_element(BGP_NODE
, &bgp_default_show_hostname_cmd
);
12482 install_element(BGP_NODE
, &no_bgp_default_show_hostname_cmd
);
12484 /* "bgp default subgroup-pkt-queue-max" commands. */
12485 install_element(BGP_NODE
, &bgp_default_subgroup_pkt_queue_max_cmd
);
12486 install_element(BGP_NODE
, &no_bgp_default_subgroup_pkt_queue_max_cmd
);
12488 /* bgp ibgp-allow-policy-mods command */
12489 install_element(BGP_NODE
, &bgp_rr_allow_outbound_policy_cmd
);
12490 install_element(BGP_NODE
, &no_bgp_rr_allow_outbound_policy_cmd
);
12492 /* "bgp listen limit" commands. */
12493 install_element(BGP_NODE
, &bgp_listen_limit_cmd
);
12494 install_element(BGP_NODE
, &no_bgp_listen_limit_cmd
);
12496 /* "bgp listen range" commands. */
12497 install_element(BGP_NODE
, &bgp_listen_range_cmd
);
12498 install_element(BGP_NODE
, &no_bgp_listen_range_cmd
);
12500 /* "bgp default shutdown" command */
12501 install_element(BGP_NODE
, &bgp_default_shutdown_cmd
);
12503 /* "neighbor remote-as" commands. */
12504 install_element(BGP_NODE
, &neighbor_remote_as_cmd
);
12505 install_element(BGP_NODE
, &neighbor_interface_config_cmd
);
12506 install_element(BGP_NODE
, &neighbor_interface_config_v6only_cmd
);
12507 install_element(BGP_NODE
, &neighbor_interface_config_remote_as_cmd
);
12508 install_element(BGP_NODE
,
12509 &neighbor_interface_v6only_config_remote_as_cmd
);
12510 install_element(BGP_NODE
, &no_neighbor_cmd
);
12511 install_element(BGP_NODE
, &no_neighbor_interface_config_cmd
);
12513 /* "neighbor peer-group" commands. */
12514 install_element(BGP_NODE
, &neighbor_peer_group_cmd
);
12515 install_element(BGP_NODE
, &no_neighbor_peer_group_cmd
);
12516 install_element(BGP_NODE
,
12517 &no_neighbor_interface_peer_group_remote_as_cmd
);
12519 /* "neighbor local-as" commands. */
12520 install_element(BGP_NODE
, &neighbor_local_as_cmd
);
12521 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_cmd
);
12522 install_element(BGP_NODE
, &neighbor_local_as_no_prepend_replace_as_cmd
);
12523 install_element(BGP_NODE
, &no_neighbor_local_as_cmd
);
12525 /* "neighbor solo" commands. */
12526 install_element(BGP_NODE
, &neighbor_solo_cmd
);
12527 install_element(BGP_NODE
, &no_neighbor_solo_cmd
);
12529 /* "neighbor password" commands. */
12530 install_element(BGP_NODE
, &neighbor_password_cmd
);
12531 install_element(BGP_NODE
, &no_neighbor_password_cmd
);
12533 /* "neighbor activate" commands. */
12534 install_element(BGP_NODE
, &neighbor_activate_hidden_cmd
);
12535 install_element(BGP_IPV4_NODE
, &neighbor_activate_cmd
);
12536 install_element(BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
12537 install_element(BGP_IPV4L_NODE
, &neighbor_activate_cmd
);
12538 install_element(BGP_IPV6_NODE
, &neighbor_activate_cmd
);
12539 install_element(BGP_IPV6M_NODE
, &neighbor_activate_cmd
);
12540 install_element(BGP_IPV6L_NODE
, &neighbor_activate_cmd
);
12541 install_element(BGP_VPNV4_NODE
, &neighbor_activate_cmd
);
12542 install_element(BGP_VPNV6_NODE
, &neighbor_activate_cmd
);
12543 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_activate_cmd
);
12544 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_activate_cmd
);
12545 install_element(BGP_EVPN_NODE
, &neighbor_activate_cmd
);
12547 /* "no neighbor activate" commands. */
12548 install_element(BGP_NODE
, &no_neighbor_activate_hidden_cmd
);
12549 install_element(BGP_IPV4_NODE
, &no_neighbor_activate_cmd
);
12550 install_element(BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
12551 install_element(BGP_IPV4L_NODE
, &no_neighbor_activate_cmd
);
12552 install_element(BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
12553 install_element(BGP_IPV6M_NODE
, &no_neighbor_activate_cmd
);
12554 install_element(BGP_IPV6L_NODE
, &no_neighbor_activate_cmd
);
12555 install_element(BGP_VPNV4_NODE
, &no_neighbor_activate_cmd
);
12556 install_element(BGP_VPNV6_NODE
, &no_neighbor_activate_cmd
);
12557 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_activate_cmd
);
12558 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_activate_cmd
);
12559 install_element(BGP_EVPN_NODE
, &no_neighbor_activate_cmd
);
12561 /* "neighbor peer-group" set commands. */
12562 install_element(BGP_NODE
, &neighbor_set_peer_group_cmd
);
12563 install_element(BGP_IPV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12564 install_element(BGP_IPV4M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12565 install_element(BGP_IPV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12566 install_element(BGP_IPV6M_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12567 install_element(BGP_IPV6L_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12568 install_element(BGP_VPNV4_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12569 install_element(BGP_VPNV6_NODE
, &neighbor_set_peer_group_hidden_cmd
);
12570 install_element(BGP_FLOWSPECV4_NODE
,
12571 &neighbor_set_peer_group_hidden_cmd
);
12572 install_element(BGP_FLOWSPECV6_NODE
,
12573 &neighbor_set_peer_group_hidden_cmd
);
12575 /* "no neighbor peer-group unset" commands. */
12576 install_element(BGP_NODE
, &no_neighbor_set_peer_group_cmd
);
12577 install_element(BGP_IPV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12578 install_element(BGP_IPV4M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12579 install_element(BGP_IPV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12580 install_element(BGP_IPV6M_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12581 install_element(BGP_IPV6L_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12582 install_element(BGP_VPNV4_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12583 install_element(BGP_VPNV6_NODE
, &no_neighbor_set_peer_group_hidden_cmd
);
12584 install_element(BGP_FLOWSPECV4_NODE
,
12585 &no_neighbor_set_peer_group_hidden_cmd
);
12586 install_element(BGP_FLOWSPECV6_NODE
,
12587 &no_neighbor_set_peer_group_hidden_cmd
);
12589 /* "neighbor softreconfiguration inbound" commands.*/
12590 install_element(BGP_NODE
, &neighbor_soft_reconfiguration_hidden_cmd
);
12591 install_element(BGP_NODE
, &no_neighbor_soft_reconfiguration_hidden_cmd
);
12592 install_element(BGP_IPV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12593 install_element(BGP_IPV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12594 install_element(BGP_IPV4L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12595 install_element(BGP_IPV4L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12596 install_element(BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12597 install_element(BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12598 install_element(BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12599 install_element(BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12600 install_element(BGP_IPV6M_NODE
, &neighbor_soft_reconfiguration_cmd
);
12601 install_element(BGP_IPV6M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12602 install_element(BGP_IPV6L_NODE
, &neighbor_soft_reconfiguration_cmd
);
12603 install_element(BGP_IPV6L_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12604 install_element(BGP_VPNV4_NODE
, &neighbor_soft_reconfiguration_cmd
);
12605 install_element(BGP_VPNV4_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12606 install_element(BGP_VPNV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
12607 install_element(BGP_VPNV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
12608 install_element(BGP_FLOWSPECV4_NODE
,
12609 &neighbor_soft_reconfiguration_cmd
);
12610 install_element(BGP_FLOWSPECV4_NODE
,
12611 &no_neighbor_soft_reconfiguration_cmd
);
12612 install_element(BGP_FLOWSPECV6_NODE
,
12613 &neighbor_soft_reconfiguration_cmd
);
12614 install_element(BGP_FLOWSPECV6_NODE
,
12615 &no_neighbor_soft_reconfiguration_cmd
);
12617 /* "neighbor attribute-unchanged" commands. */
12618 install_element(BGP_NODE
, &neighbor_attr_unchanged_hidden_cmd
);
12619 install_element(BGP_NODE
, &no_neighbor_attr_unchanged_hidden_cmd
);
12620 install_element(BGP_IPV4_NODE
, &neighbor_attr_unchanged_cmd
);
12621 install_element(BGP_IPV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
12622 install_element(BGP_IPV4M_NODE
, &neighbor_attr_unchanged_cmd
);
12623 install_element(BGP_IPV4M_NODE
, &no_neighbor_attr_unchanged_cmd
);
12624 install_element(BGP_IPV4L_NODE
, &neighbor_attr_unchanged_cmd
);
12625 install_element(BGP_IPV4L_NODE
, &no_neighbor_attr_unchanged_cmd
);
12626 install_element(BGP_IPV6_NODE
, &neighbor_attr_unchanged_cmd
);
12627 install_element(BGP_IPV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
12628 install_element(BGP_IPV6M_NODE
, &neighbor_attr_unchanged_cmd
);
12629 install_element(BGP_IPV6M_NODE
, &no_neighbor_attr_unchanged_cmd
);
12630 install_element(BGP_IPV6L_NODE
, &neighbor_attr_unchanged_cmd
);
12631 install_element(BGP_IPV6L_NODE
, &no_neighbor_attr_unchanged_cmd
);
12632 install_element(BGP_VPNV4_NODE
, &neighbor_attr_unchanged_cmd
);
12633 install_element(BGP_VPNV4_NODE
, &no_neighbor_attr_unchanged_cmd
);
12634 install_element(BGP_VPNV6_NODE
, &neighbor_attr_unchanged_cmd
);
12635 install_element(BGP_VPNV6_NODE
, &no_neighbor_attr_unchanged_cmd
);
12637 install_element(BGP_EVPN_NODE
, &neighbor_attr_unchanged_cmd
);
12638 install_element(BGP_EVPN_NODE
, &no_neighbor_attr_unchanged_cmd
);
12640 /* "nexthop-local unchanged" commands */
12641 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_local_unchanged_cmd
);
12642 install_element(BGP_IPV6_NODE
,
12643 &no_neighbor_nexthop_local_unchanged_cmd
);
12645 /* "neighbor next-hop-self" commands. */
12646 install_element(BGP_NODE
, &neighbor_nexthop_self_hidden_cmd
);
12647 install_element(BGP_NODE
, &no_neighbor_nexthop_self_hidden_cmd
);
12648 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_cmd
);
12649 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_cmd
);
12650 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
12651 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
12652 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_cmd
);
12653 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_cmd
);
12654 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
12655 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
12656 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_cmd
);
12657 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_cmd
);
12658 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_cmd
);
12659 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_cmd
);
12660 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_cmd
);
12661 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_cmd
);
12662 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_cmd
);
12663 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_cmd
);
12664 install_element(BGP_EVPN_NODE
, &neighbor_nexthop_self_cmd
);
12665 install_element(BGP_EVPN_NODE
, &no_neighbor_nexthop_self_cmd
);
12667 /* "neighbor next-hop-self force" commands. */
12668 install_element(BGP_NODE
, &neighbor_nexthop_self_force_hidden_cmd
);
12669 install_element(BGP_NODE
, &no_neighbor_nexthop_self_force_hidden_cmd
);
12670 install_element(BGP_IPV4_NODE
, &neighbor_nexthop_self_force_cmd
);
12671 install_element(BGP_IPV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12672 install_element(BGP_IPV4M_NODE
, &neighbor_nexthop_self_force_cmd
);
12673 install_element(BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12674 install_element(BGP_IPV4L_NODE
, &neighbor_nexthop_self_force_cmd
);
12675 install_element(BGP_IPV4L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12676 install_element(BGP_IPV6_NODE
, &neighbor_nexthop_self_force_cmd
);
12677 install_element(BGP_IPV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12678 install_element(BGP_IPV6M_NODE
, &neighbor_nexthop_self_force_cmd
);
12679 install_element(BGP_IPV6M_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12680 install_element(BGP_IPV6L_NODE
, &neighbor_nexthop_self_force_cmd
);
12681 install_element(BGP_IPV6L_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12682 install_element(BGP_VPNV4_NODE
, &neighbor_nexthop_self_force_cmd
);
12683 install_element(BGP_VPNV4_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12684 install_element(BGP_VPNV6_NODE
, &neighbor_nexthop_self_force_cmd
);
12685 install_element(BGP_VPNV6_NODE
, &no_neighbor_nexthop_self_force_cmd
);
12687 /* "neighbor as-override" commands. */
12688 install_element(BGP_NODE
, &neighbor_as_override_hidden_cmd
);
12689 install_element(BGP_NODE
, &no_neighbor_as_override_hidden_cmd
);
12690 install_element(BGP_IPV4_NODE
, &neighbor_as_override_cmd
);
12691 install_element(BGP_IPV4_NODE
, &no_neighbor_as_override_cmd
);
12692 install_element(BGP_IPV4M_NODE
, &neighbor_as_override_cmd
);
12693 install_element(BGP_IPV4M_NODE
, &no_neighbor_as_override_cmd
);
12694 install_element(BGP_IPV4L_NODE
, &neighbor_as_override_cmd
);
12695 install_element(BGP_IPV4L_NODE
, &no_neighbor_as_override_cmd
);
12696 install_element(BGP_IPV6_NODE
, &neighbor_as_override_cmd
);
12697 install_element(BGP_IPV6_NODE
, &no_neighbor_as_override_cmd
);
12698 install_element(BGP_IPV6M_NODE
, &neighbor_as_override_cmd
);
12699 install_element(BGP_IPV6M_NODE
, &no_neighbor_as_override_cmd
);
12700 install_element(BGP_IPV6L_NODE
, &neighbor_as_override_cmd
);
12701 install_element(BGP_IPV6L_NODE
, &no_neighbor_as_override_cmd
);
12702 install_element(BGP_VPNV4_NODE
, &neighbor_as_override_cmd
);
12703 install_element(BGP_VPNV4_NODE
, &no_neighbor_as_override_cmd
);
12704 install_element(BGP_VPNV6_NODE
, &neighbor_as_override_cmd
);
12705 install_element(BGP_VPNV6_NODE
, &no_neighbor_as_override_cmd
);
12707 /* "neighbor remove-private-AS" commands. */
12708 install_element(BGP_NODE
, &neighbor_remove_private_as_hidden_cmd
);
12709 install_element(BGP_NODE
, &no_neighbor_remove_private_as_hidden_cmd
);
12710 install_element(BGP_NODE
, &neighbor_remove_private_as_all_hidden_cmd
);
12711 install_element(BGP_NODE
,
12712 &no_neighbor_remove_private_as_all_hidden_cmd
);
12713 install_element(BGP_NODE
,
12714 &neighbor_remove_private_as_replace_as_hidden_cmd
);
12715 install_element(BGP_NODE
,
12716 &no_neighbor_remove_private_as_replace_as_hidden_cmd
);
12717 install_element(BGP_NODE
,
12718 &neighbor_remove_private_as_all_replace_as_hidden_cmd
);
12721 &no_neighbor_remove_private_as_all_replace_as_hidden_cmd
);
12722 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_cmd
);
12723 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_cmd
);
12724 install_element(BGP_IPV4_NODE
, &neighbor_remove_private_as_all_cmd
);
12725 install_element(BGP_IPV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12726 install_element(BGP_IPV4_NODE
,
12727 &neighbor_remove_private_as_replace_as_cmd
);
12728 install_element(BGP_IPV4_NODE
,
12729 &no_neighbor_remove_private_as_replace_as_cmd
);
12730 install_element(BGP_IPV4_NODE
,
12731 &neighbor_remove_private_as_all_replace_as_cmd
);
12732 install_element(BGP_IPV4_NODE
,
12733 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12734 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_cmd
);
12735 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_cmd
);
12736 install_element(BGP_IPV4M_NODE
, &neighbor_remove_private_as_all_cmd
);
12737 install_element(BGP_IPV4M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12738 install_element(BGP_IPV4M_NODE
,
12739 &neighbor_remove_private_as_replace_as_cmd
);
12740 install_element(BGP_IPV4M_NODE
,
12741 &no_neighbor_remove_private_as_replace_as_cmd
);
12742 install_element(BGP_IPV4M_NODE
,
12743 &neighbor_remove_private_as_all_replace_as_cmd
);
12744 install_element(BGP_IPV4M_NODE
,
12745 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12746 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_cmd
);
12747 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_cmd
);
12748 install_element(BGP_IPV4L_NODE
, &neighbor_remove_private_as_all_cmd
);
12749 install_element(BGP_IPV4L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12750 install_element(BGP_IPV4L_NODE
,
12751 &neighbor_remove_private_as_replace_as_cmd
);
12752 install_element(BGP_IPV4L_NODE
,
12753 &no_neighbor_remove_private_as_replace_as_cmd
);
12754 install_element(BGP_IPV4L_NODE
,
12755 &neighbor_remove_private_as_all_replace_as_cmd
);
12756 install_element(BGP_IPV4L_NODE
,
12757 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12758 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_cmd
);
12759 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_cmd
);
12760 install_element(BGP_IPV6_NODE
, &neighbor_remove_private_as_all_cmd
);
12761 install_element(BGP_IPV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12762 install_element(BGP_IPV6_NODE
,
12763 &neighbor_remove_private_as_replace_as_cmd
);
12764 install_element(BGP_IPV6_NODE
,
12765 &no_neighbor_remove_private_as_replace_as_cmd
);
12766 install_element(BGP_IPV6_NODE
,
12767 &neighbor_remove_private_as_all_replace_as_cmd
);
12768 install_element(BGP_IPV6_NODE
,
12769 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12770 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_cmd
);
12771 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_cmd
);
12772 install_element(BGP_IPV6M_NODE
, &neighbor_remove_private_as_all_cmd
);
12773 install_element(BGP_IPV6M_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12774 install_element(BGP_IPV6M_NODE
,
12775 &neighbor_remove_private_as_replace_as_cmd
);
12776 install_element(BGP_IPV6M_NODE
,
12777 &no_neighbor_remove_private_as_replace_as_cmd
);
12778 install_element(BGP_IPV6M_NODE
,
12779 &neighbor_remove_private_as_all_replace_as_cmd
);
12780 install_element(BGP_IPV6M_NODE
,
12781 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12782 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_cmd
);
12783 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_cmd
);
12784 install_element(BGP_IPV6L_NODE
, &neighbor_remove_private_as_all_cmd
);
12785 install_element(BGP_IPV6L_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12786 install_element(BGP_IPV6L_NODE
,
12787 &neighbor_remove_private_as_replace_as_cmd
);
12788 install_element(BGP_IPV6L_NODE
,
12789 &no_neighbor_remove_private_as_replace_as_cmd
);
12790 install_element(BGP_IPV6L_NODE
,
12791 &neighbor_remove_private_as_all_replace_as_cmd
);
12792 install_element(BGP_IPV6L_NODE
,
12793 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12794 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_cmd
);
12795 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_cmd
);
12796 install_element(BGP_VPNV4_NODE
, &neighbor_remove_private_as_all_cmd
);
12797 install_element(BGP_VPNV4_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12798 install_element(BGP_VPNV4_NODE
,
12799 &neighbor_remove_private_as_replace_as_cmd
);
12800 install_element(BGP_VPNV4_NODE
,
12801 &no_neighbor_remove_private_as_replace_as_cmd
);
12802 install_element(BGP_VPNV4_NODE
,
12803 &neighbor_remove_private_as_all_replace_as_cmd
);
12804 install_element(BGP_VPNV4_NODE
,
12805 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12806 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_cmd
);
12807 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_cmd
);
12808 install_element(BGP_VPNV6_NODE
, &neighbor_remove_private_as_all_cmd
);
12809 install_element(BGP_VPNV6_NODE
, &no_neighbor_remove_private_as_all_cmd
);
12810 install_element(BGP_VPNV6_NODE
,
12811 &neighbor_remove_private_as_replace_as_cmd
);
12812 install_element(BGP_VPNV6_NODE
,
12813 &no_neighbor_remove_private_as_replace_as_cmd
);
12814 install_element(BGP_VPNV6_NODE
,
12815 &neighbor_remove_private_as_all_replace_as_cmd
);
12816 install_element(BGP_VPNV6_NODE
,
12817 &no_neighbor_remove_private_as_all_replace_as_cmd
);
12819 /* "neighbor send-community" commands.*/
12820 install_element(BGP_NODE
, &neighbor_send_community_hidden_cmd
);
12821 install_element(BGP_NODE
, &neighbor_send_community_type_hidden_cmd
);
12822 install_element(BGP_NODE
, &no_neighbor_send_community_hidden_cmd
);
12823 install_element(BGP_NODE
, &no_neighbor_send_community_type_hidden_cmd
);
12824 install_element(BGP_IPV4_NODE
, &neighbor_send_community_cmd
);
12825 install_element(BGP_IPV4_NODE
, &neighbor_send_community_type_cmd
);
12826 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_cmd
);
12827 install_element(BGP_IPV4_NODE
, &no_neighbor_send_community_type_cmd
);
12828 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
12829 install_element(BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
12830 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
12831 install_element(BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
12832 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_cmd
);
12833 install_element(BGP_IPV4L_NODE
, &neighbor_send_community_type_cmd
);
12834 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_cmd
);
12835 install_element(BGP_IPV4L_NODE
, &no_neighbor_send_community_type_cmd
);
12836 install_element(BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
12837 install_element(BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
12838 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
12839 install_element(BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
12840 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_cmd
);
12841 install_element(BGP_IPV6M_NODE
, &neighbor_send_community_type_cmd
);
12842 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_cmd
);
12843 install_element(BGP_IPV6M_NODE
, &no_neighbor_send_community_type_cmd
);
12844 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_cmd
);
12845 install_element(BGP_IPV6L_NODE
, &neighbor_send_community_type_cmd
);
12846 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_cmd
);
12847 install_element(BGP_IPV6L_NODE
, &no_neighbor_send_community_type_cmd
);
12848 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_cmd
);
12849 install_element(BGP_VPNV4_NODE
, &neighbor_send_community_type_cmd
);
12850 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_cmd
);
12851 install_element(BGP_VPNV4_NODE
, &no_neighbor_send_community_type_cmd
);
12852 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_cmd
);
12853 install_element(BGP_VPNV6_NODE
, &neighbor_send_community_type_cmd
);
12854 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_cmd
);
12855 install_element(BGP_VPNV6_NODE
, &no_neighbor_send_community_type_cmd
);
12857 /* "neighbor route-reflector" commands.*/
12858 install_element(BGP_NODE
, &neighbor_route_reflector_client_hidden_cmd
);
12859 install_element(BGP_NODE
,
12860 &no_neighbor_route_reflector_client_hidden_cmd
);
12861 install_element(BGP_IPV4_NODE
, &neighbor_route_reflector_client_cmd
);
12862 install_element(BGP_IPV4_NODE
, &no_neighbor_route_reflector_client_cmd
);
12863 install_element(BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
12864 install_element(BGP_IPV4M_NODE
,
12865 &no_neighbor_route_reflector_client_cmd
);
12866 install_element(BGP_IPV4L_NODE
, &neighbor_route_reflector_client_cmd
);
12867 install_element(BGP_IPV4L_NODE
,
12868 &no_neighbor_route_reflector_client_cmd
);
12869 install_element(BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
12870 install_element(BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
12871 install_element(BGP_IPV6M_NODE
, &neighbor_route_reflector_client_cmd
);
12872 install_element(BGP_IPV6M_NODE
,
12873 &no_neighbor_route_reflector_client_cmd
);
12874 install_element(BGP_IPV6L_NODE
, &neighbor_route_reflector_client_cmd
);
12875 install_element(BGP_IPV6L_NODE
,
12876 &no_neighbor_route_reflector_client_cmd
);
12877 install_element(BGP_VPNV4_NODE
, &neighbor_route_reflector_client_cmd
);
12878 install_element(BGP_VPNV4_NODE
,
12879 &no_neighbor_route_reflector_client_cmd
);
12880 install_element(BGP_VPNV6_NODE
, &neighbor_route_reflector_client_cmd
);
12881 install_element(BGP_VPNV6_NODE
,
12882 &no_neighbor_route_reflector_client_cmd
);
12883 install_element(BGP_FLOWSPECV4_NODE
,
12884 &neighbor_route_reflector_client_cmd
);
12885 install_element(BGP_FLOWSPECV4_NODE
,
12886 &no_neighbor_route_reflector_client_cmd
);
12887 install_element(BGP_FLOWSPECV6_NODE
,
12888 &neighbor_route_reflector_client_cmd
);
12889 install_element(BGP_FLOWSPECV6_NODE
,
12890 &no_neighbor_route_reflector_client_cmd
);
12891 install_element(BGP_EVPN_NODE
, &neighbor_route_reflector_client_cmd
);
12892 install_element(BGP_EVPN_NODE
, &no_neighbor_route_reflector_client_cmd
);
12894 /* "neighbor route-server" commands.*/
12895 install_element(BGP_NODE
, &neighbor_route_server_client_hidden_cmd
);
12896 install_element(BGP_NODE
, &no_neighbor_route_server_client_hidden_cmd
);
12897 install_element(BGP_IPV4_NODE
, &neighbor_route_server_client_cmd
);
12898 install_element(BGP_IPV4_NODE
, &no_neighbor_route_server_client_cmd
);
12899 install_element(BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
12900 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
12901 install_element(BGP_IPV4L_NODE
, &neighbor_route_server_client_cmd
);
12902 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_server_client_cmd
);
12903 install_element(BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
12904 install_element(BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
12905 install_element(BGP_IPV6M_NODE
, &neighbor_route_server_client_cmd
);
12906 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_server_client_cmd
);
12907 install_element(BGP_IPV6L_NODE
, &neighbor_route_server_client_cmd
);
12908 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_server_client_cmd
);
12909 install_element(BGP_VPNV4_NODE
, &neighbor_route_server_client_cmd
);
12910 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_server_client_cmd
);
12911 install_element(BGP_VPNV6_NODE
, &neighbor_route_server_client_cmd
);
12912 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_server_client_cmd
);
12913 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_server_client_cmd
);
12914 install_element(BGP_FLOWSPECV4_NODE
,
12915 &no_neighbor_route_server_client_cmd
);
12916 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_server_client_cmd
);
12917 install_element(BGP_FLOWSPECV6_NODE
,
12918 &no_neighbor_route_server_client_cmd
);
12920 /* "neighbor addpath-tx-all-paths" commands.*/
12921 install_element(BGP_NODE
, &neighbor_addpath_tx_all_paths_hidden_cmd
);
12922 install_element(BGP_NODE
, &no_neighbor_addpath_tx_all_paths_hidden_cmd
);
12923 install_element(BGP_IPV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12924 install_element(BGP_IPV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12925 install_element(BGP_IPV4M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12926 install_element(BGP_IPV4M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12927 install_element(BGP_IPV4L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12928 install_element(BGP_IPV4L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12929 install_element(BGP_IPV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12930 install_element(BGP_IPV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12931 install_element(BGP_IPV6M_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12932 install_element(BGP_IPV6M_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12933 install_element(BGP_IPV6L_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12934 install_element(BGP_IPV6L_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12935 install_element(BGP_VPNV4_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12936 install_element(BGP_VPNV4_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12937 install_element(BGP_VPNV6_NODE
, &neighbor_addpath_tx_all_paths_cmd
);
12938 install_element(BGP_VPNV6_NODE
, &no_neighbor_addpath_tx_all_paths_cmd
);
12940 /* "neighbor addpath-tx-bestpath-per-AS" commands.*/
12941 install_element(BGP_NODE
,
12942 &neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
12943 install_element(BGP_NODE
,
12944 &no_neighbor_addpath_tx_bestpath_per_as_hidden_cmd
);
12945 install_element(BGP_IPV4_NODE
,
12946 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12947 install_element(BGP_IPV4_NODE
,
12948 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12949 install_element(BGP_IPV4M_NODE
,
12950 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12951 install_element(BGP_IPV4M_NODE
,
12952 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12953 install_element(BGP_IPV4L_NODE
,
12954 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12955 install_element(BGP_IPV4L_NODE
,
12956 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12957 install_element(BGP_IPV6_NODE
,
12958 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12959 install_element(BGP_IPV6_NODE
,
12960 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12961 install_element(BGP_IPV6M_NODE
,
12962 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12963 install_element(BGP_IPV6M_NODE
,
12964 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12965 install_element(BGP_IPV6L_NODE
,
12966 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12967 install_element(BGP_IPV6L_NODE
,
12968 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12969 install_element(BGP_VPNV4_NODE
,
12970 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12971 install_element(BGP_VPNV4_NODE
,
12972 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12973 install_element(BGP_VPNV6_NODE
,
12974 &neighbor_addpath_tx_bestpath_per_as_cmd
);
12975 install_element(BGP_VPNV6_NODE
,
12976 &no_neighbor_addpath_tx_bestpath_per_as_cmd
);
12978 /* "neighbor passive" commands. */
12979 install_element(BGP_NODE
, &neighbor_passive_cmd
);
12980 install_element(BGP_NODE
, &no_neighbor_passive_cmd
);
12983 /* "neighbor shutdown" commands. */
12984 install_element(BGP_NODE
, &neighbor_shutdown_cmd
);
12985 install_element(BGP_NODE
, &no_neighbor_shutdown_cmd
);
12986 install_element(BGP_NODE
, &neighbor_shutdown_msg_cmd
);
12987 install_element(BGP_NODE
, &no_neighbor_shutdown_msg_cmd
);
12989 /* "neighbor capability extended-nexthop" commands.*/
12990 install_element(BGP_NODE
, &neighbor_capability_enhe_cmd
);
12991 install_element(BGP_NODE
, &no_neighbor_capability_enhe_cmd
);
12993 /* "neighbor capability orf prefix-list" commands.*/
12994 install_element(BGP_NODE
, &neighbor_capability_orf_prefix_hidden_cmd
);
12995 install_element(BGP_NODE
,
12996 &no_neighbor_capability_orf_prefix_hidden_cmd
);
12997 install_element(BGP_IPV4_NODE
, &neighbor_capability_orf_prefix_cmd
);
12998 install_element(BGP_IPV4_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
12999 install_element(BGP_IPV4M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13000 install_element(BGP_IPV4M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13001 install_element(BGP_IPV4L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13002 install_element(BGP_IPV4L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13003 install_element(BGP_IPV6_NODE
, &neighbor_capability_orf_prefix_cmd
);
13004 install_element(BGP_IPV6_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13005 install_element(BGP_IPV6M_NODE
, &neighbor_capability_orf_prefix_cmd
);
13006 install_element(BGP_IPV6M_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13007 install_element(BGP_IPV6L_NODE
, &neighbor_capability_orf_prefix_cmd
);
13008 install_element(BGP_IPV6L_NODE
, &no_neighbor_capability_orf_prefix_cmd
);
13010 /* "neighbor capability dynamic" commands.*/
13011 install_element(BGP_NODE
, &neighbor_capability_dynamic_cmd
);
13012 install_element(BGP_NODE
, &no_neighbor_capability_dynamic_cmd
);
13014 /* "neighbor dont-capability-negotiate" commands. */
13015 install_element(BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
13016 install_element(BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
13018 /* "neighbor ebgp-multihop" commands. */
13019 install_element(BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
13020 install_element(BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
13021 install_element(BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
13023 /* "neighbor disable-connected-check" commands. */
13024 install_element(BGP_NODE
, &neighbor_disable_connected_check_cmd
);
13025 install_element(BGP_NODE
, &no_neighbor_disable_connected_check_cmd
);
13027 /* "neighbor enforce-first-as" commands. */
13028 install_element(BGP_NODE
, &neighbor_enforce_first_as_cmd
);
13029 install_element(BGP_NODE
, &no_neighbor_enforce_first_as_cmd
);
13031 /* "neighbor description" commands. */
13032 install_element(BGP_NODE
, &neighbor_description_cmd
);
13033 install_element(BGP_NODE
, &no_neighbor_description_cmd
);
13035 /* "neighbor update-source" commands. "*/
13036 install_element(BGP_NODE
, &neighbor_update_source_cmd
);
13037 install_element(BGP_NODE
, &no_neighbor_update_source_cmd
);
13039 /* "neighbor default-originate" commands. */
13040 install_element(BGP_NODE
, &neighbor_default_originate_hidden_cmd
);
13041 install_element(BGP_NODE
, &neighbor_default_originate_rmap_hidden_cmd
);
13042 install_element(BGP_NODE
, &no_neighbor_default_originate_hidden_cmd
);
13043 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_cmd
);
13044 install_element(BGP_IPV4_NODE
, &neighbor_default_originate_rmap_cmd
);
13045 install_element(BGP_IPV4_NODE
, &no_neighbor_default_originate_cmd
);
13046 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_cmd
);
13047 install_element(BGP_IPV4M_NODE
, &neighbor_default_originate_rmap_cmd
);
13048 install_element(BGP_IPV4M_NODE
, &no_neighbor_default_originate_cmd
);
13049 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_cmd
);
13050 install_element(BGP_IPV4L_NODE
, &neighbor_default_originate_rmap_cmd
);
13051 install_element(BGP_IPV4L_NODE
, &no_neighbor_default_originate_cmd
);
13052 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_cmd
);
13053 install_element(BGP_IPV6_NODE
, &neighbor_default_originate_rmap_cmd
);
13054 install_element(BGP_IPV6_NODE
, &no_neighbor_default_originate_cmd
);
13055 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_cmd
);
13056 install_element(BGP_IPV6M_NODE
, &neighbor_default_originate_rmap_cmd
);
13057 install_element(BGP_IPV6M_NODE
, &no_neighbor_default_originate_cmd
);
13058 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_cmd
);
13059 install_element(BGP_IPV6L_NODE
, &neighbor_default_originate_rmap_cmd
);
13060 install_element(BGP_IPV6L_NODE
, &no_neighbor_default_originate_cmd
);
13062 /* "neighbor port" commands. */
13063 install_element(BGP_NODE
, &neighbor_port_cmd
);
13064 install_element(BGP_NODE
, &no_neighbor_port_cmd
);
13066 /* "neighbor weight" commands. */
13067 install_element(BGP_NODE
, &neighbor_weight_hidden_cmd
);
13068 install_element(BGP_NODE
, &no_neighbor_weight_hidden_cmd
);
13070 install_element(BGP_IPV4_NODE
, &neighbor_weight_cmd
);
13071 install_element(BGP_IPV4_NODE
, &no_neighbor_weight_cmd
);
13072 install_element(BGP_IPV4M_NODE
, &neighbor_weight_cmd
);
13073 install_element(BGP_IPV4M_NODE
, &no_neighbor_weight_cmd
);
13074 install_element(BGP_IPV4L_NODE
, &neighbor_weight_cmd
);
13075 install_element(BGP_IPV4L_NODE
, &no_neighbor_weight_cmd
);
13076 install_element(BGP_IPV6_NODE
, &neighbor_weight_cmd
);
13077 install_element(BGP_IPV6_NODE
, &no_neighbor_weight_cmd
);
13078 install_element(BGP_IPV6M_NODE
, &neighbor_weight_cmd
);
13079 install_element(BGP_IPV6M_NODE
, &no_neighbor_weight_cmd
);
13080 install_element(BGP_IPV6L_NODE
, &neighbor_weight_cmd
);
13081 install_element(BGP_IPV6L_NODE
, &no_neighbor_weight_cmd
);
13082 install_element(BGP_VPNV4_NODE
, &neighbor_weight_cmd
);
13083 install_element(BGP_VPNV4_NODE
, &no_neighbor_weight_cmd
);
13084 install_element(BGP_VPNV6_NODE
, &neighbor_weight_cmd
);
13085 install_element(BGP_VPNV6_NODE
, &no_neighbor_weight_cmd
);
13087 /* "neighbor override-capability" commands. */
13088 install_element(BGP_NODE
, &neighbor_override_capability_cmd
);
13089 install_element(BGP_NODE
, &no_neighbor_override_capability_cmd
);
13091 /* "neighbor strict-capability-match" commands. */
13092 install_element(BGP_NODE
, &neighbor_strict_capability_cmd
);
13093 install_element(BGP_NODE
, &no_neighbor_strict_capability_cmd
);
13095 /* "neighbor timers" commands. */
13096 install_element(BGP_NODE
, &neighbor_timers_cmd
);
13097 install_element(BGP_NODE
, &no_neighbor_timers_cmd
);
13099 /* "neighbor timers connect" commands. */
13100 install_element(BGP_NODE
, &neighbor_timers_connect_cmd
);
13101 install_element(BGP_NODE
, &no_neighbor_timers_connect_cmd
);
13103 /* "neighbor advertisement-interval" commands. */
13104 install_element(BGP_NODE
, &neighbor_advertise_interval_cmd
);
13105 install_element(BGP_NODE
, &no_neighbor_advertise_interval_cmd
);
13107 /* "neighbor interface" commands. */
13108 install_element(BGP_NODE
, &neighbor_interface_cmd
);
13109 install_element(BGP_NODE
, &no_neighbor_interface_cmd
);
13111 /* "neighbor distribute" commands. */
13112 install_element(BGP_NODE
, &neighbor_distribute_list_hidden_cmd
);
13113 install_element(BGP_NODE
, &no_neighbor_distribute_list_hidden_cmd
);
13114 install_element(BGP_IPV4_NODE
, &neighbor_distribute_list_cmd
);
13115 install_element(BGP_IPV4_NODE
, &no_neighbor_distribute_list_cmd
);
13116 install_element(BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
13117 install_element(BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
13118 install_element(BGP_IPV4L_NODE
, &neighbor_distribute_list_cmd
);
13119 install_element(BGP_IPV4L_NODE
, &no_neighbor_distribute_list_cmd
);
13120 install_element(BGP_IPV6_NODE
, &neighbor_distribute_list_cmd
);
13121 install_element(BGP_IPV6_NODE
, &no_neighbor_distribute_list_cmd
);
13122 install_element(BGP_IPV6M_NODE
, &neighbor_distribute_list_cmd
);
13123 install_element(BGP_IPV6M_NODE
, &no_neighbor_distribute_list_cmd
);
13124 install_element(BGP_IPV6L_NODE
, &neighbor_distribute_list_cmd
);
13125 install_element(BGP_IPV6L_NODE
, &no_neighbor_distribute_list_cmd
);
13126 install_element(BGP_VPNV4_NODE
, &neighbor_distribute_list_cmd
);
13127 install_element(BGP_VPNV4_NODE
, &no_neighbor_distribute_list_cmd
);
13128 install_element(BGP_VPNV6_NODE
, &neighbor_distribute_list_cmd
);
13129 install_element(BGP_VPNV6_NODE
, &no_neighbor_distribute_list_cmd
);
13131 /* "neighbor prefix-list" commands. */
13132 install_element(BGP_NODE
, &neighbor_prefix_list_hidden_cmd
);
13133 install_element(BGP_NODE
, &no_neighbor_prefix_list_hidden_cmd
);
13134 install_element(BGP_IPV4_NODE
, &neighbor_prefix_list_cmd
);
13135 install_element(BGP_IPV4_NODE
, &no_neighbor_prefix_list_cmd
);
13136 install_element(BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
13137 install_element(BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
13138 install_element(BGP_IPV4L_NODE
, &neighbor_prefix_list_cmd
);
13139 install_element(BGP_IPV4L_NODE
, &no_neighbor_prefix_list_cmd
);
13140 install_element(BGP_IPV6_NODE
, &neighbor_prefix_list_cmd
);
13141 install_element(BGP_IPV6_NODE
, &no_neighbor_prefix_list_cmd
);
13142 install_element(BGP_IPV6M_NODE
, &neighbor_prefix_list_cmd
);
13143 install_element(BGP_IPV6M_NODE
, &no_neighbor_prefix_list_cmd
);
13144 install_element(BGP_IPV6L_NODE
, &neighbor_prefix_list_cmd
);
13145 install_element(BGP_IPV6L_NODE
, &no_neighbor_prefix_list_cmd
);
13146 install_element(BGP_VPNV4_NODE
, &neighbor_prefix_list_cmd
);
13147 install_element(BGP_VPNV4_NODE
, &no_neighbor_prefix_list_cmd
);
13148 install_element(BGP_VPNV6_NODE
, &neighbor_prefix_list_cmd
);
13149 install_element(BGP_VPNV6_NODE
, &no_neighbor_prefix_list_cmd
);
13150 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_prefix_list_cmd
);
13151 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_prefix_list_cmd
);
13152 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_prefix_list_cmd
);
13153 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_prefix_list_cmd
);
13155 /* "neighbor filter-list" commands. */
13156 install_element(BGP_NODE
, &neighbor_filter_list_hidden_cmd
);
13157 install_element(BGP_NODE
, &no_neighbor_filter_list_hidden_cmd
);
13158 install_element(BGP_IPV4_NODE
, &neighbor_filter_list_cmd
);
13159 install_element(BGP_IPV4_NODE
, &no_neighbor_filter_list_cmd
);
13160 install_element(BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
13161 install_element(BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
13162 install_element(BGP_IPV4L_NODE
, &neighbor_filter_list_cmd
);
13163 install_element(BGP_IPV4L_NODE
, &no_neighbor_filter_list_cmd
);
13164 install_element(BGP_IPV6_NODE
, &neighbor_filter_list_cmd
);
13165 install_element(BGP_IPV6_NODE
, &no_neighbor_filter_list_cmd
);
13166 install_element(BGP_IPV6M_NODE
, &neighbor_filter_list_cmd
);
13167 install_element(BGP_IPV6M_NODE
, &no_neighbor_filter_list_cmd
);
13168 install_element(BGP_IPV6L_NODE
, &neighbor_filter_list_cmd
);
13169 install_element(BGP_IPV6L_NODE
, &no_neighbor_filter_list_cmd
);
13170 install_element(BGP_VPNV4_NODE
, &neighbor_filter_list_cmd
);
13171 install_element(BGP_VPNV4_NODE
, &no_neighbor_filter_list_cmd
);
13172 install_element(BGP_VPNV6_NODE
, &neighbor_filter_list_cmd
);
13173 install_element(BGP_VPNV6_NODE
, &no_neighbor_filter_list_cmd
);
13174 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_filter_list_cmd
);
13175 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_filter_list_cmd
);
13176 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_filter_list_cmd
);
13177 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_filter_list_cmd
);
13179 /* "neighbor route-map" commands. */
13180 install_element(BGP_NODE
, &neighbor_route_map_hidden_cmd
);
13181 install_element(BGP_NODE
, &no_neighbor_route_map_hidden_cmd
);
13182 install_element(BGP_IPV4_NODE
, &neighbor_route_map_cmd
);
13183 install_element(BGP_IPV4_NODE
, &no_neighbor_route_map_cmd
);
13184 install_element(BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
13185 install_element(BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
13186 install_element(BGP_IPV4L_NODE
, &neighbor_route_map_cmd
);
13187 install_element(BGP_IPV4L_NODE
, &no_neighbor_route_map_cmd
);
13188 install_element(BGP_IPV6_NODE
, &neighbor_route_map_cmd
);
13189 install_element(BGP_IPV6_NODE
, &no_neighbor_route_map_cmd
);
13190 install_element(BGP_IPV6M_NODE
, &neighbor_route_map_cmd
);
13191 install_element(BGP_IPV6M_NODE
, &no_neighbor_route_map_cmd
);
13192 install_element(BGP_IPV6L_NODE
, &neighbor_route_map_cmd
);
13193 install_element(BGP_IPV6L_NODE
, &no_neighbor_route_map_cmd
);
13194 install_element(BGP_VPNV4_NODE
, &neighbor_route_map_cmd
);
13195 install_element(BGP_VPNV4_NODE
, &no_neighbor_route_map_cmd
);
13196 install_element(BGP_VPNV6_NODE
, &neighbor_route_map_cmd
);
13197 install_element(BGP_VPNV6_NODE
, &no_neighbor_route_map_cmd
);
13198 install_element(BGP_FLOWSPECV4_NODE
, &neighbor_route_map_cmd
);
13199 install_element(BGP_FLOWSPECV4_NODE
, &no_neighbor_route_map_cmd
);
13200 install_element(BGP_FLOWSPECV6_NODE
, &neighbor_route_map_cmd
);
13201 install_element(BGP_FLOWSPECV6_NODE
, &no_neighbor_route_map_cmd
);
13202 install_element(BGP_EVPN_NODE
, &neighbor_route_map_cmd
);
13203 install_element(BGP_EVPN_NODE
, &no_neighbor_route_map_cmd
);
13205 /* "neighbor unsuppress-map" commands. */
13206 install_element(BGP_NODE
, &neighbor_unsuppress_map_hidden_cmd
);
13207 install_element(BGP_NODE
, &no_neighbor_unsuppress_map_hidden_cmd
);
13208 install_element(BGP_IPV4_NODE
, &neighbor_unsuppress_map_cmd
);
13209 install_element(BGP_IPV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13210 install_element(BGP_IPV4M_NODE
, &neighbor_unsuppress_map_cmd
);
13211 install_element(BGP_IPV4M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13212 install_element(BGP_IPV4L_NODE
, &neighbor_unsuppress_map_cmd
);
13213 install_element(BGP_IPV4L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13214 install_element(BGP_IPV6_NODE
, &neighbor_unsuppress_map_cmd
);
13215 install_element(BGP_IPV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13216 install_element(BGP_IPV6M_NODE
, &neighbor_unsuppress_map_cmd
);
13217 install_element(BGP_IPV6M_NODE
, &no_neighbor_unsuppress_map_cmd
);
13218 install_element(BGP_IPV6L_NODE
, &neighbor_unsuppress_map_cmd
);
13219 install_element(BGP_IPV6L_NODE
, &no_neighbor_unsuppress_map_cmd
);
13220 install_element(BGP_VPNV4_NODE
, &neighbor_unsuppress_map_cmd
);
13221 install_element(BGP_VPNV4_NODE
, &no_neighbor_unsuppress_map_cmd
);
13222 install_element(BGP_VPNV6_NODE
, &neighbor_unsuppress_map_cmd
);
13223 install_element(BGP_VPNV6_NODE
, &no_neighbor_unsuppress_map_cmd
);
13225 /* "neighbor maximum-prefix" commands. */
13226 install_element(BGP_NODE
, &neighbor_maximum_prefix_hidden_cmd
);
13227 install_element(BGP_NODE
,
13228 &neighbor_maximum_prefix_threshold_hidden_cmd
);
13229 install_element(BGP_NODE
, &neighbor_maximum_prefix_warning_hidden_cmd
);
13230 install_element(BGP_NODE
,
13231 &neighbor_maximum_prefix_threshold_warning_hidden_cmd
);
13232 install_element(BGP_NODE
, &neighbor_maximum_prefix_restart_hidden_cmd
);
13233 install_element(BGP_NODE
,
13234 &neighbor_maximum_prefix_threshold_restart_hidden_cmd
);
13235 install_element(BGP_NODE
, &no_neighbor_maximum_prefix_hidden_cmd
);
13236 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_cmd
);
13237 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13238 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13239 install_element(BGP_IPV4_NODE
,
13240 &neighbor_maximum_prefix_threshold_warning_cmd
);
13241 install_element(BGP_IPV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13242 install_element(BGP_IPV4_NODE
,
13243 &neighbor_maximum_prefix_threshold_restart_cmd
);
13244 install_element(BGP_IPV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13245 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
13246 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13247 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13248 install_element(BGP_IPV4M_NODE
,
13249 &neighbor_maximum_prefix_threshold_warning_cmd
);
13250 install_element(BGP_IPV4M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13251 install_element(BGP_IPV4M_NODE
,
13252 &neighbor_maximum_prefix_threshold_restart_cmd
);
13253 install_element(BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13254 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_cmd
);
13255 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13256 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13257 install_element(BGP_IPV4L_NODE
,
13258 &neighbor_maximum_prefix_threshold_warning_cmd
);
13259 install_element(BGP_IPV4L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13260 install_element(BGP_IPV4L_NODE
,
13261 &neighbor_maximum_prefix_threshold_restart_cmd
);
13262 install_element(BGP_IPV4L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13263 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
13264 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13265 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13266 install_element(BGP_IPV6_NODE
,
13267 &neighbor_maximum_prefix_threshold_warning_cmd
);
13268 install_element(BGP_IPV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13269 install_element(BGP_IPV6_NODE
,
13270 &neighbor_maximum_prefix_threshold_restart_cmd
);
13271 install_element(BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13272 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_cmd
);
13273 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13274 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13275 install_element(BGP_IPV6M_NODE
,
13276 &neighbor_maximum_prefix_threshold_warning_cmd
);
13277 install_element(BGP_IPV6M_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13278 install_element(BGP_IPV6M_NODE
,
13279 &neighbor_maximum_prefix_threshold_restart_cmd
);
13280 install_element(BGP_IPV6M_NODE
, &no_neighbor_maximum_prefix_cmd
);
13281 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_cmd
);
13282 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13283 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13284 install_element(BGP_IPV6L_NODE
,
13285 &neighbor_maximum_prefix_threshold_warning_cmd
);
13286 install_element(BGP_IPV6L_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13287 install_element(BGP_IPV6L_NODE
,
13288 &neighbor_maximum_prefix_threshold_restart_cmd
);
13289 install_element(BGP_IPV6L_NODE
, &no_neighbor_maximum_prefix_cmd
);
13290 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_cmd
);
13291 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13292 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13293 install_element(BGP_VPNV4_NODE
,
13294 &neighbor_maximum_prefix_threshold_warning_cmd
);
13295 install_element(BGP_VPNV4_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13296 install_element(BGP_VPNV4_NODE
,
13297 &neighbor_maximum_prefix_threshold_restart_cmd
);
13298 install_element(BGP_VPNV4_NODE
, &no_neighbor_maximum_prefix_cmd
);
13299 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_cmd
);
13300 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_threshold_cmd
);
13301 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
13302 install_element(BGP_VPNV6_NODE
,
13303 &neighbor_maximum_prefix_threshold_warning_cmd
);
13304 install_element(BGP_VPNV6_NODE
, &neighbor_maximum_prefix_restart_cmd
);
13305 install_element(BGP_VPNV6_NODE
,
13306 &neighbor_maximum_prefix_threshold_restart_cmd
);
13307 install_element(BGP_VPNV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
13309 /* "neighbor allowas-in" */
13310 install_element(BGP_NODE
, &neighbor_allowas_in_hidden_cmd
);
13311 install_element(BGP_NODE
, &no_neighbor_allowas_in_hidden_cmd
);
13312 install_element(BGP_IPV4_NODE
, &neighbor_allowas_in_cmd
);
13313 install_element(BGP_IPV4_NODE
, &no_neighbor_allowas_in_cmd
);
13314 install_element(BGP_IPV4M_NODE
, &neighbor_allowas_in_cmd
);
13315 install_element(BGP_IPV4M_NODE
, &no_neighbor_allowas_in_cmd
);
13316 install_element(BGP_IPV4L_NODE
, &neighbor_allowas_in_cmd
);
13317 install_element(BGP_IPV4L_NODE
, &no_neighbor_allowas_in_cmd
);
13318 install_element(BGP_IPV6_NODE
, &neighbor_allowas_in_cmd
);
13319 install_element(BGP_IPV6_NODE
, &no_neighbor_allowas_in_cmd
);
13320 install_element(BGP_IPV6M_NODE
, &neighbor_allowas_in_cmd
);
13321 install_element(BGP_IPV6M_NODE
, &no_neighbor_allowas_in_cmd
);
13322 install_element(BGP_IPV6L_NODE
, &neighbor_allowas_in_cmd
);
13323 install_element(BGP_IPV6L_NODE
, &no_neighbor_allowas_in_cmd
);
13324 install_element(BGP_VPNV4_NODE
, &neighbor_allowas_in_cmd
);
13325 install_element(BGP_VPNV4_NODE
, &no_neighbor_allowas_in_cmd
);
13326 install_element(BGP_VPNV6_NODE
, &neighbor_allowas_in_cmd
);
13327 install_element(BGP_VPNV6_NODE
, &no_neighbor_allowas_in_cmd
);
13328 install_element(BGP_EVPN_NODE
, &neighbor_allowas_in_cmd
);
13329 install_element(BGP_EVPN_NODE
, &no_neighbor_allowas_in_cmd
);
13331 /* address-family commands. */
13332 install_element(BGP_NODE
, &address_family_ipv4_safi_cmd
);
13333 install_element(BGP_NODE
, &address_family_ipv6_safi_cmd
);
13334 #ifdef KEEP_OLD_VPN_COMMANDS
13335 install_element(BGP_NODE
, &address_family_vpnv4_cmd
);
13336 install_element(BGP_NODE
, &address_family_vpnv6_cmd
);
13337 #endif /* KEEP_OLD_VPN_COMMANDS */
13339 install_element(BGP_NODE
, &address_family_evpn_cmd
);
13341 /* "exit-address-family" command. */
13342 install_element(BGP_IPV4_NODE
, &exit_address_family_cmd
);
13343 install_element(BGP_IPV4M_NODE
, &exit_address_family_cmd
);
13344 install_element(BGP_IPV4L_NODE
, &exit_address_family_cmd
);
13345 install_element(BGP_IPV6_NODE
, &exit_address_family_cmd
);
13346 install_element(BGP_IPV6M_NODE
, &exit_address_family_cmd
);
13347 install_element(BGP_IPV6L_NODE
, &exit_address_family_cmd
);
13348 install_element(BGP_VPNV4_NODE
, &exit_address_family_cmd
);
13349 install_element(BGP_VPNV6_NODE
, &exit_address_family_cmd
);
13350 install_element(BGP_FLOWSPECV4_NODE
, &exit_address_family_cmd
);
13351 install_element(BGP_FLOWSPECV6_NODE
, &exit_address_family_cmd
);
13352 install_element(BGP_EVPN_NODE
, &exit_address_family_cmd
);
13354 /* "clear ip bgp commands" */
13355 install_element(ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
13357 /* clear ip bgp prefix */
13358 install_element(ENABLE_NODE
, &clear_ip_bgp_prefix_cmd
);
13359 install_element(ENABLE_NODE
, &clear_bgp_ipv6_safi_prefix_cmd
);
13360 install_element(ENABLE_NODE
, &clear_bgp_instance_ipv6_safi_prefix_cmd
);
13362 /* "show [ip] bgp summary" commands. */
13363 install_element(VIEW_NODE
, &show_bgp_instance_all_ipv6_updgrps_cmd
);
13364 install_element(VIEW_NODE
, &show_bgp_instance_updgrps_stats_cmd
);
13365 install_element(VIEW_NODE
, &show_bgp_updgrps_stats_cmd
);
13366 install_element(VIEW_NODE
, &show_ip_bgp_instance_updgrps_adj_s_cmd
);
13367 install_element(VIEW_NODE
, &show_ip_bgp_summary_cmd
);
13368 install_element(VIEW_NODE
, &show_ip_bgp_updgrps_cmd
);
13370 /* "show [ip] bgp neighbors" commands. */
13371 install_element(VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
13373 /* "show [ip] bgp peer-group" commands. */
13374 install_element(VIEW_NODE
, &show_ip_bgp_peer_groups_cmd
);
13376 /* "show [ip] bgp paths" commands. */
13377 install_element(VIEW_NODE
, &show_ip_bgp_paths_cmd
);
13379 /* "show [ip] bgp community" commands. */
13380 install_element(VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
13382 /* "show ip bgp large-community" commands. */
13383 install_element(VIEW_NODE
, &show_ip_bgp_lcommunity_info_cmd
);
13384 /* "show [ip] bgp attribute-info" commands. */
13385 install_element(VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
13386 /* "show [ip] bgp route-leak" command */
13387 install_element(VIEW_NODE
, &show_ip_bgp_route_leak_cmd
);
13389 /* "redistribute" commands. */
13390 install_element(BGP_NODE
, &bgp_redistribute_ipv4_hidden_cmd
);
13391 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_hidden_cmd
);
13392 install_element(BGP_NODE
, &bgp_redistribute_ipv4_rmap_hidden_cmd
);
13393 install_element(BGP_NODE
, &bgp_redistribute_ipv4_metric_hidden_cmd
);
13394 install_element(BGP_NODE
,
13395 &bgp_redistribute_ipv4_rmap_metric_hidden_cmd
);
13396 install_element(BGP_NODE
,
13397 &bgp_redistribute_ipv4_metric_rmap_hidden_cmd
);
13398 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_hidden_cmd
);
13399 install_element(BGP_NODE
, &no_bgp_redistribute_ipv4_ospf_hidden_cmd
);
13400 install_element(BGP_NODE
, &bgp_redistribute_ipv4_ospf_rmap_hidden_cmd
);
13401 install_element(BGP_NODE
,
13402 &bgp_redistribute_ipv4_ospf_metric_hidden_cmd
);
13403 install_element(BGP_NODE
,
13404 &bgp_redistribute_ipv4_ospf_rmap_metric_hidden_cmd
);
13405 install_element(BGP_NODE
,
13406 &bgp_redistribute_ipv4_ospf_metric_rmap_hidden_cmd
);
13407 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_cmd
);
13408 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_cmd
);
13409 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_cmd
);
13410 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_cmd
);
13411 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_rmap_metric_cmd
);
13412 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_metric_rmap_cmd
);
13413 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_cmd
);
13414 install_element(BGP_IPV4_NODE
, &no_bgp_redistribute_ipv4_ospf_cmd
);
13415 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_rmap_cmd
);
13416 install_element(BGP_IPV4_NODE
, &bgp_redistribute_ipv4_ospf_metric_cmd
);
13417 install_element(BGP_IPV4_NODE
,
13418 &bgp_redistribute_ipv4_ospf_rmap_metric_cmd
);
13419 install_element(BGP_IPV4_NODE
,
13420 &bgp_redistribute_ipv4_ospf_metric_rmap_cmd
);
13421 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_cmd
);
13422 install_element(BGP_IPV6_NODE
, &no_bgp_redistribute_ipv6_cmd
);
13423 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_cmd
);
13424 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_cmd
);
13425 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_rmap_metric_cmd
);
13426 install_element(BGP_IPV6_NODE
, &bgp_redistribute_ipv6_metric_rmap_cmd
);
13428 /* import|export vpn [route-map WORD] */
13429 install_element(BGP_IPV4_NODE
, &bgp_imexport_vpn_cmd
);
13430 install_element(BGP_IPV6_NODE
, &bgp_imexport_vpn_cmd
);
13432 install_element(BGP_IPV4_NODE
, &bgp_imexport_vrf_cmd
);
13433 install_element(BGP_IPV6_NODE
, &bgp_imexport_vrf_cmd
);
13435 /* ttl_security commands */
13436 install_element(BGP_NODE
, &neighbor_ttl_security_cmd
);
13437 install_element(BGP_NODE
, &no_neighbor_ttl_security_cmd
);
13439 /* "show [ip] bgp memory" commands. */
13440 install_element(VIEW_NODE
, &show_bgp_memory_cmd
);
13442 /* "show bgp martian next-hop" */
13443 install_element(VIEW_NODE
, &show_bgp_martian_nexthop_db_cmd
);
13445 /* "show [ip] bgp views" commands. */
13446 install_element(VIEW_NODE
, &show_bgp_views_cmd
);
13448 /* "show [ip] bgp vrfs" commands. */
13449 install_element(VIEW_NODE
, &show_bgp_vrfs_cmd
);
13451 /* Community-list. */
13452 community_list_vty();
13454 /* vpn-policy commands */
13455 install_element(BGP_IPV4_NODE
, &af_rd_vpn_export_cmd
);
13456 install_element(BGP_IPV6_NODE
, &af_rd_vpn_export_cmd
);
13457 install_element(BGP_IPV4_NODE
, &af_label_vpn_export_cmd
);
13458 install_element(BGP_IPV6_NODE
, &af_label_vpn_export_cmd
);
13459 install_element(BGP_IPV4_NODE
, &af_nexthop_vpn_export_cmd
);
13460 install_element(BGP_IPV6_NODE
, &af_nexthop_vpn_export_cmd
);
13461 install_element(BGP_IPV4_NODE
, &af_rt_vpn_imexport_cmd
);
13462 install_element(BGP_IPV6_NODE
, &af_rt_vpn_imexport_cmd
);
13463 install_element(BGP_IPV4_NODE
, &af_route_map_vpn_imexport_cmd
);
13464 install_element(BGP_IPV6_NODE
, &af_route_map_vpn_imexport_cmd
);
13465 install_element(BGP_IPV4_NODE
, &af_import_vrf_route_map_cmd
);
13466 install_element(BGP_IPV6_NODE
, &af_import_vrf_route_map_cmd
);
13468 install_element(BGP_IPV4_NODE
, &af_routetarget_import_cmd
);
13469 install_element(BGP_IPV6_NODE
, &af_routetarget_import_cmd
);
13471 install_element(BGP_IPV4_NODE
, &af_no_rd_vpn_export_cmd
);
13472 install_element(BGP_IPV6_NODE
, &af_no_rd_vpn_export_cmd
);
13473 install_element(BGP_IPV4_NODE
, &af_no_label_vpn_export_cmd
);
13474 install_element(BGP_IPV6_NODE
, &af_no_label_vpn_export_cmd
);
13475 install_element(BGP_IPV4_NODE
, &af_no_nexthop_vpn_export_cmd
);
13476 install_element(BGP_IPV6_NODE
, &af_no_nexthop_vpn_export_cmd
);
13477 install_element(BGP_IPV4_NODE
, &af_no_rt_vpn_imexport_cmd
);
13478 install_element(BGP_IPV6_NODE
, &af_no_rt_vpn_imexport_cmd
);
13479 install_element(BGP_IPV4_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13480 install_element(BGP_IPV6_NODE
, &af_no_route_map_vpn_imexport_cmd
);
13481 install_element(BGP_IPV4_NODE
, &af_no_import_vrf_route_map_cmd
);
13482 install_element(BGP_IPV6_NODE
, &af_no_import_vrf_route_map_cmd
);
13485 #include "memory.h"
13486 #include "bgp_regex.h"
13487 #include "bgp_clist.h"
13488 #include "bgp_ecommunity.h"
13490 /* VTY functions. */
13492 /* Direction value to string conversion. */
13493 static const char *community_direct_str(int direct
)
13496 case COMMUNITY_DENY
:
13498 case COMMUNITY_PERMIT
:
13505 /* Display error string. */
13506 static void community_list_perror(struct vty
*vty
, int ret
)
13509 case COMMUNITY_LIST_ERR_CANT_FIND_LIST
:
13510 vty_out(vty
, "%% Can't find community-list\n");
13512 case COMMUNITY_LIST_ERR_MALFORMED_VAL
:
13513 vty_out(vty
, "%% Malformed community-list value\n");
13515 case COMMUNITY_LIST_ERR_STANDARD_CONFLICT
:
13517 "%% Community name conflict, previously defined as standard community\n");
13519 case COMMUNITY_LIST_ERR_EXPANDED_CONFLICT
:
13521 "%% Community name conflict, previously defined as expanded community\n");
13526 /* "community-list" keyword help string. */
13527 #define COMMUNITY_LIST_STR "Add a community list entry\n"
13529 /* ip community-list standard */
13530 DEFUN (ip_community_list_standard
,
13531 ip_community_list_standard_cmd
,
13532 "ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13535 "Community list number (standard)\n"
13536 "Add an standard community-list entry\n"
13537 "Community list name\n"
13538 "Specify community to reject\n"
13539 "Specify community to accept\n"
13542 char *cl_name_or_number
= NULL
;
13544 int style
= COMMUNITY_LIST_STANDARD
;
13547 argv_find(argv
, argc
, "(1-99)", &idx
);
13548 argv_find(argv
, argc
, "WORD", &idx
);
13549 cl_name_or_number
= argv
[idx
]->arg
;
13550 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13552 argv_find(argv
, argc
, "AA:NN", &idx
);
13553 char *str
= argv_concat(argv
, argc
, idx
);
13555 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
13558 XFREE(MTYPE_TMP
, str
);
13561 /* Display error string. */
13562 community_list_perror(vty
, ret
);
13563 return CMD_WARNING_CONFIG_FAILED
;
13566 return CMD_SUCCESS
;
13569 DEFUN (no_ip_community_list_standard_all
,
13570 no_ip_community_list_standard_all_cmd
,
13571 "no ip community-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
13575 "Community list number (standard)\n"
13576 "Add an standard community-list entry\n"
13577 "Community list name\n"
13578 "Specify community to reject\n"
13579 "Specify community to accept\n"
13582 char *cl_name_or_number
= NULL
;
13584 int style
= COMMUNITY_LIST_STANDARD
;
13587 argv_find(argv
, argc
, "(1-99)", &idx
);
13588 argv_find(argv
, argc
, "WORD", &idx
);
13589 cl_name_or_number
= argv
[idx
]->arg
;
13590 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13592 argv_find(argv
, argc
, "AA:NN", &idx
);
13593 char *str
= argv_concat(argv
, argc
, idx
);
13595 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
13598 XFREE(MTYPE_TMP
, str
);
13601 community_list_perror(vty
, ret
);
13602 return CMD_WARNING_CONFIG_FAILED
;
13605 return CMD_SUCCESS
;
13608 /* ip community-list expanded */
13609 DEFUN (ip_community_list_expanded_all
,
13610 ip_community_list_expanded_all_cmd
,
13611 "ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13614 "Community list number (expanded)\n"
13615 "Add an expanded community-list entry\n"
13616 "Community list name\n"
13617 "Specify community to reject\n"
13618 "Specify community to accept\n"
13621 char *cl_name_or_number
= NULL
;
13623 int style
= COMMUNITY_LIST_EXPANDED
;
13626 argv_find(argv
, argc
, "(100-500)", &idx
);
13627 argv_find(argv
, argc
, "WORD", &idx
);
13628 cl_name_or_number
= argv
[idx
]->arg
;
13629 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13631 argv_find(argv
, argc
, "AA:NN", &idx
);
13632 char *str
= argv_concat(argv
, argc
, idx
);
13634 int ret
= community_list_set(bgp_clist
, cl_name_or_number
, str
, direct
,
13637 XFREE(MTYPE_TMP
, str
);
13640 /* Display error string. */
13641 community_list_perror(vty
, ret
);
13642 return CMD_WARNING_CONFIG_FAILED
;
13645 return CMD_SUCCESS
;
13648 DEFUN (no_ip_community_list_expanded_all
,
13649 no_ip_community_list_expanded_all_cmd
,
13650 "no ip community-list <(100-500)|expanded WORD> <deny|permit> AA:NN...",
13654 "Community list number (expanded)\n"
13655 "Add an expanded community-list entry\n"
13656 "Community list name\n"
13657 "Specify community to reject\n"
13658 "Specify community to accept\n"
13661 char *cl_name_or_number
= NULL
;
13663 int style
= COMMUNITY_LIST_EXPANDED
;
13666 argv_find(argv
, argc
, "(100-500)", &idx
);
13667 argv_find(argv
, argc
, "WORD", &idx
);
13668 cl_name_or_number
= argv
[idx
]->arg
;
13669 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13671 argv_find(argv
, argc
, "AA:NN", &idx
);
13672 char *str
= argv_concat(argv
, argc
, idx
);
13674 int ret
= community_list_unset(bgp_clist
, cl_name_or_number
, str
,
13677 XFREE(MTYPE_TMP
, str
);
13680 community_list_perror(vty
, ret
);
13681 return CMD_WARNING_CONFIG_FAILED
;
13684 return CMD_SUCCESS
;
13687 /* Return configuration string of community-list entry. */
13688 static const char *community_list_config_str(struct community_entry
*entry
)
13695 if (entry
->style
== COMMUNITY_LIST_STANDARD
)
13696 str
= community_str(entry
->u
.com
, false);
13697 else if (entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
)
13698 str
= lcommunity_str(entry
->u
.lcom
, false);
13700 str
= entry
->config
;
13705 static void community_list_show(struct vty
*vty
, struct community_list
*list
)
13707 struct community_entry
*entry
;
13709 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
13710 if (entry
== list
->head
) {
13711 if (all_digit(list
->name
))
13712 vty_out(vty
, "Community %s list %s\n",
13713 entry
->style
== COMMUNITY_LIST_STANDARD
13715 : "(expanded) access",
13718 vty_out(vty
, "Named Community %s list %s\n",
13719 entry
->style
== COMMUNITY_LIST_STANDARD
13725 vty_out(vty
, " %s\n",
13726 community_direct_str(entry
->direct
));
13728 vty_out(vty
, " %s %s\n",
13729 community_direct_str(entry
->direct
),
13730 community_list_config_str(entry
));
13734 DEFUN (show_ip_community_list
,
13735 show_ip_community_list_cmd
,
13736 "show ip community-list",
13739 "List community-list\n")
13741 struct community_list
*list
;
13742 struct community_list_master
*cm
;
13744 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
13746 return CMD_SUCCESS
;
13748 for (list
= cm
->num
.head
; list
; list
= list
->next
)
13749 community_list_show(vty
, list
);
13751 for (list
= cm
->str
.head
; list
; list
= list
->next
)
13752 community_list_show(vty
, list
);
13754 return CMD_SUCCESS
;
13757 DEFUN (show_ip_community_list_arg
,
13758 show_ip_community_list_arg_cmd
,
13759 "show ip community-list <(1-500)|WORD>",
13762 "List community-list\n"
13763 "Community-list number\n"
13764 "Community-list name\n")
13766 int idx_comm_list
= 3;
13767 struct community_list
*list
;
13769 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
13770 COMMUNITY_LIST_MASTER
);
13772 vty_out(vty
, "%% Can't find community-list\n");
13773 return CMD_WARNING
;
13776 community_list_show(vty
, list
);
13778 return CMD_SUCCESS
;
13782 * Large Community code.
13784 static int lcommunity_list_set_vty(struct vty
*vty
, int argc
,
13785 struct cmd_token
**argv
, int style
,
13786 int reject_all_digit_name
)
13794 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
13797 /* All digit name check. */
13799 argv_find(argv
, argc
, "WORD", &idx
);
13800 argv_find(argv
, argc
, "(1-99)", &idx
);
13801 argv_find(argv
, argc
, "(100-500)", &idx
);
13802 cl_name
= argv
[idx
]->arg
;
13803 if (reject_all_digit_name
&& all_digit(cl_name
)) {
13804 vty_out(vty
, "%% Community name cannot have all digits\n");
13805 return CMD_WARNING_CONFIG_FAILED
;
13809 argv_find(argv
, argc
, "AA:BB:CC", &idx
);
13810 argv_find(argv
, argc
, "LINE", &idx
);
13811 /* Concat community string argument. */
13813 str
= argv_concat(argv
, argc
, idx
);
13817 ret
= lcommunity_list_set(bgp_clist
, cl_name
, str
, direct
, style
);
13819 /* Free temporary community list string allocated by
13822 XFREE(MTYPE_TMP
, str
);
13825 community_list_perror(vty
, ret
);
13826 return CMD_WARNING_CONFIG_FAILED
;
13828 return CMD_SUCCESS
;
13831 static int lcommunity_list_unset_vty(struct vty
*vty
, int argc
,
13832 struct cmd_token
**argv
, int style
)
13839 argv_find(argv
, argc
, "permit", &idx
);
13840 argv_find(argv
, argc
, "deny", &idx
);
13843 /* Check the list direct. */
13844 if (strncmp(argv
[idx
]->arg
, "p", 1) == 0)
13845 direct
= COMMUNITY_PERMIT
;
13847 direct
= COMMUNITY_DENY
;
13850 argv_find(argv
, argc
, "LINE", &idx
);
13851 argv_find(argv
, argc
, "AA:AA:NN", &idx
);
13852 /* Concat community string argument. */
13853 str
= argv_concat(argv
, argc
, idx
);
13857 argv_find(argv
, argc
, "(1-99)", &idx
);
13858 argv_find(argv
, argc
, "(100-500)", &idx
);
13859 argv_find(argv
, argc
, "WORD", &idx
);
13861 /* Unset community list. */
13862 ret
= lcommunity_list_unset(bgp_clist
, argv
[idx
]->arg
, str
, direct
,
13865 /* Free temporary community list string allocated by
13868 XFREE(MTYPE_TMP
, str
);
13871 community_list_perror(vty
, ret
);
13872 return CMD_WARNING_CONFIG_FAILED
;
13875 return CMD_SUCCESS
;
13878 /* "large-community-list" keyword help string. */
13879 #define LCOMMUNITY_LIST_STR "Add a large community list entry\n"
13880 #define LCOMMUNITY_VAL_STR "large community in 'aa:bb:cc' format\n"
13882 DEFUN (ip_lcommunity_list_standard
,
13883 ip_lcommunity_list_standard_cmd
,
13884 "ip large-community-list (1-99) <deny|permit>",
13886 LCOMMUNITY_LIST_STR
13887 "Large Community list number (standard)\n"
13888 "Specify large community to reject\n"
13889 "Specify large community to accept\n")
13891 return lcommunity_list_set_vty(vty
, argc
, argv
,
13892 LARGE_COMMUNITY_LIST_STANDARD
, 0);
13895 DEFUN (ip_lcommunity_list_standard1
,
13896 ip_lcommunity_list_standard1_cmd
,
13897 "ip large-community-list (1-99) <deny|permit> AA:BB:CC...",
13899 LCOMMUNITY_LIST_STR
13900 "Large Community list number (standard)\n"
13901 "Specify large community to reject\n"
13902 "Specify large community to accept\n"
13903 LCOMMUNITY_VAL_STR
)
13905 return lcommunity_list_set_vty(vty
, argc
, argv
,
13906 LARGE_COMMUNITY_LIST_STANDARD
, 0);
13909 DEFUN (ip_lcommunity_list_expanded
,
13910 ip_lcommunity_list_expanded_cmd
,
13911 "ip large-community-list (100-500) <deny|permit> LINE...",
13913 LCOMMUNITY_LIST_STR
13914 "Large Community list number (expanded)\n"
13915 "Specify large community to reject\n"
13916 "Specify large community to accept\n"
13917 "An ordered list as a regular-expression\n")
13919 return lcommunity_list_set_vty(vty
, argc
, argv
,
13920 LARGE_COMMUNITY_LIST_EXPANDED
, 0);
13923 DEFUN (ip_lcommunity_list_name_standard
,
13924 ip_lcommunity_list_name_standard_cmd
,
13925 "ip large-community-list standard WORD <deny|permit>",
13927 LCOMMUNITY_LIST_STR
13928 "Specify standard large-community-list\n"
13929 "Large Community list name\n"
13930 "Specify large community to reject\n"
13931 "Specify large community to accept\n")
13933 return lcommunity_list_set_vty(vty
, argc
, argv
,
13934 LARGE_COMMUNITY_LIST_STANDARD
, 1);
13937 DEFUN (ip_lcommunity_list_name_standard1
,
13938 ip_lcommunity_list_name_standard1_cmd
,
13939 "ip large-community-list standard WORD <deny|permit> AA:BB:CC...",
13941 LCOMMUNITY_LIST_STR
13942 "Specify standard large-community-list\n"
13943 "Large Community list name\n"
13944 "Specify large community to reject\n"
13945 "Specify large community to accept\n"
13946 LCOMMUNITY_VAL_STR
)
13948 return lcommunity_list_set_vty(vty
, argc
, argv
,
13949 LARGE_COMMUNITY_LIST_STANDARD
, 1);
13952 DEFUN (ip_lcommunity_list_name_expanded
,
13953 ip_lcommunity_list_name_expanded_cmd
,
13954 "ip large-community-list expanded WORD <deny|permit> LINE...",
13956 LCOMMUNITY_LIST_STR
13957 "Specify expanded large-community-list\n"
13958 "Large Community list name\n"
13959 "Specify large community to reject\n"
13960 "Specify large community to accept\n"
13961 "An ordered list as a regular-expression\n")
13963 return lcommunity_list_set_vty(vty
, argc
, argv
,
13964 LARGE_COMMUNITY_LIST_EXPANDED
, 1);
13967 DEFUN (no_ip_lcommunity_list_standard_all
,
13968 no_ip_lcommunity_list_standard_all_cmd
,
13969 "no ip large-community-list <(1-99)|(100-500)|WORD>",
13972 LCOMMUNITY_LIST_STR
13973 "Large Community list number (standard)\n"
13974 "Large Community list number (expanded)\n"
13975 "Large Community list name\n")
13977 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13978 LARGE_COMMUNITY_LIST_STANDARD
);
13981 DEFUN (no_ip_lcommunity_list_name_expanded_all
,
13982 no_ip_lcommunity_list_name_expanded_all_cmd
,
13983 "no ip large-community-list expanded WORD",
13986 LCOMMUNITY_LIST_STR
13987 "Specify expanded large-community-list\n"
13988 "Large Community list name\n")
13990 return lcommunity_list_unset_vty(vty
, argc
, argv
,
13991 LARGE_COMMUNITY_LIST_EXPANDED
);
13994 DEFUN (no_ip_lcommunity_list_standard
,
13995 no_ip_lcommunity_list_standard_cmd
,
13996 "no ip large-community-list (1-99) <deny|permit> AA:AA:NN...",
13999 LCOMMUNITY_LIST_STR
14000 "Large Community list number (standard)\n"
14001 "Specify large community to reject\n"
14002 "Specify large community to accept\n"
14003 LCOMMUNITY_VAL_STR
)
14005 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14006 LARGE_COMMUNITY_LIST_STANDARD
);
14009 DEFUN (no_ip_lcommunity_list_expanded
,
14010 no_ip_lcommunity_list_expanded_cmd
,
14011 "no ip large-community-list (100-500) <deny|permit> LINE...",
14014 LCOMMUNITY_LIST_STR
14015 "Large Community list number (expanded)\n"
14016 "Specify large community to reject\n"
14017 "Specify large community to accept\n"
14018 "An ordered list as a regular-expression\n")
14020 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14021 LARGE_COMMUNITY_LIST_EXPANDED
);
14024 DEFUN (no_ip_lcommunity_list_name_standard
,
14025 no_ip_lcommunity_list_name_standard_cmd
,
14026 "no ip large-community-list standard WORD <deny|permit> AA:AA:NN...",
14029 LCOMMUNITY_LIST_STR
14030 "Specify standard large-community-list\n"
14031 "Large Community list name\n"
14032 "Specify large community to reject\n"
14033 "Specify large community to accept\n"
14034 LCOMMUNITY_VAL_STR
)
14036 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14037 LARGE_COMMUNITY_LIST_STANDARD
);
14040 DEFUN (no_ip_lcommunity_list_name_expanded
,
14041 no_ip_lcommunity_list_name_expanded_cmd
,
14042 "no ip large-community-list expanded WORD <deny|permit> LINE...",
14045 LCOMMUNITY_LIST_STR
14046 "Specify expanded large-community-list\n"
14047 "Large community list name\n"
14048 "Specify large community to reject\n"
14049 "Specify large community to accept\n"
14050 "An ordered list as a regular-expression\n")
14052 return lcommunity_list_unset_vty(vty
, argc
, argv
,
14053 LARGE_COMMUNITY_LIST_EXPANDED
);
14056 static void lcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14058 struct community_entry
*entry
;
14060 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14061 if (entry
== list
->head
) {
14062 if (all_digit(list
->name
))
14063 vty_out(vty
, "Large community %s list %s\n",
14064 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14066 : "(expanded) access",
14070 "Named large community %s list %s\n",
14071 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14077 vty_out(vty
, " %s\n",
14078 community_direct_str(entry
->direct
));
14080 vty_out(vty
, " %s %s\n",
14081 community_direct_str(entry
->direct
),
14082 community_list_config_str(entry
));
14086 DEFUN (show_ip_lcommunity_list
,
14087 show_ip_lcommunity_list_cmd
,
14088 "show ip large-community-list",
14091 "List large-community list\n")
14093 struct community_list
*list
;
14094 struct community_list_master
*cm
;
14096 cm
= community_list_master_lookup(bgp_clist
,
14097 LARGE_COMMUNITY_LIST_MASTER
);
14099 return CMD_SUCCESS
;
14101 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14102 lcommunity_list_show(vty
, list
);
14104 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14105 lcommunity_list_show(vty
, list
);
14107 return CMD_SUCCESS
;
14110 DEFUN (show_ip_lcommunity_list_arg
,
14111 show_ip_lcommunity_list_arg_cmd
,
14112 "show ip large-community-list <(1-500)|WORD>",
14115 "List large-community list\n"
14116 "large-community-list number\n"
14117 "large-community-list name\n")
14119 struct community_list
*list
;
14121 list
= community_list_lookup(bgp_clist
, argv
[3]->arg
,
14122 LARGE_COMMUNITY_LIST_MASTER
);
14124 vty_out(vty
, "%% Can't find extcommunity-list\n");
14125 return CMD_WARNING
;
14128 lcommunity_list_show(vty
, list
);
14130 return CMD_SUCCESS
;
14133 /* "extcommunity-list" keyword help string. */
14134 #define EXTCOMMUNITY_LIST_STR "Add a extended community list entry\n"
14135 #define EXTCOMMUNITY_VAL_STR "Extended community attribute in 'rt aa:nn_or_IPaddr:nn' OR 'soo aa:nn_or_IPaddr:nn' format\n"
14137 DEFUN (ip_extcommunity_list_standard
,
14138 ip_extcommunity_list_standard_cmd
,
14139 "ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14141 EXTCOMMUNITY_LIST_STR
14142 "Extended Community list number (standard)\n"
14143 "Specify standard extcommunity-list\n"
14144 "Community list name\n"
14145 "Specify community to reject\n"
14146 "Specify community to accept\n"
14147 EXTCOMMUNITY_VAL_STR
)
14149 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14151 char *cl_number_or_name
= NULL
;
14154 argv_find(argv
, argc
, "(1-99)", &idx
);
14155 argv_find(argv
, argc
, "WORD", &idx
);
14156 cl_number_or_name
= argv
[idx
]->arg
;
14157 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14159 argv_find(argv
, argc
, "AA:NN", &idx
);
14160 char *str
= argv_concat(argv
, argc
, idx
);
14162 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14165 XFREE(MTYPE_TMP
, str
);
14168 community_list_perror(vty
, ret
);
14169 return CMD_WARNING_CONFIG_FAILED
;
14172 return CMD_SUCCESS
;
14175 DEFUN (ip_extcommunity_list_name_expanded
,
14176 ip_extcommunity_list_name_expanded_cmd
,
14177 "ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14179 EXTCOMMUNITY_LIST_STR
14180 "Extended Community list number (expanded)\n"
14181 "Specify expanded extcommunity-list\n"
14182 "Extended Community list name\n"
14183 "Specify community to reject\n"
14184 "Specify community to accept\n"
14185 "An ordered list as a regular-expression\n")
14187 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
14189 char *cl_number_or_name
= NULL
;
14192 argv_find(argv
, argc
, "(100-500)", &idx
);
14193 argv_find(argv
, argc
, "WORD", &idx
);
14194 cl_number_or_name
= argv
[idx
]->arg
;
14195 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14197 argv_find(argv
, argc
, "LINE", &idx
);
14198 char *str
= argv_concat(argv
, argc
, idx
);
14200 int ret
= extcommunity_list_set(bgp_clist
, cl_number_or_name
, str
,
14203 XFREE(MTYPE_TMP
, str
);
14206 community_list_perror(vty
, ret
);
14207 return CMD_WARNING_CONFIG_FAILED
;
14210 return CMD_SUCCESS
;
14213 DEFUN (no_ip_extcommunity_list_standard_all
,
14214 no_ip_extcommunity_list_standard_all_cmd
,
14215 "no ip extcommunity-list <(1-99)|standard WORD> <deny|permit> AA:NN...",
14218 EXTCOMMUNITY_LIST_STR
14219 "Extended Community list number (standard)\n"
14220 "Specify standard extcommunity-list\n"
14221 "Community list name\n"
14222 "Specify community to reject\n"
14223 "Specify community to accept\n"
14224 EXTCOMMUNITY_VAL_STR
)
14226 int style
= EXTCOMMUNITY_LIST_STANDARD
;
14228 char *cl_number_or_name
= NULL
;
14231 argv_find(argv
, argc
, "(1-99)", &idx
);
14232 argv_find(argv
, argc
, "WORD", &idx
);
14233 cl_number_or_name
= argv
[idx
]->arg
;
14234 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14236 argv_find(argv
, argc
, "AA:NN", &idx
);
14237 char *str
= argv_concat(argv
, argc
, idx
);
14239 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
14242 XFREE(MTYPE_TMP
, str
);
14245 community_list_perror(vty
, ret
);
14246 return CMD_WARNING_CONFIG_FAILED
;
14249 return CMD_SUCCESS
;
14252 DEFUN (no_ip_extcommunity_list_expanded_all
,
14253 no_ip_extcommunity_list_expanded_all_cmd
,
14254 "no ip extcommunity-list <(100-500)|expanded WORD> <deny|permit> LINE...",
14257 EXTCOMMUNITY_LIST_STR
14258 "Extended Community list number (expanded)\n"
14259 "Specify expanded extcommunity-list\n"
14260 "Extended Community list name\n"
14261 "Specify community to reject\n"
14262 "Specify community to accept\n"
14263 "An ordered list as a regular-expression\n")
14265 int style
= EXTCOMMUNITY_LIST_EXPANDED
;
14267 char *cl_number_or_name
= NULL
;
14270 argv_find(argv
, argc
, "(100-500)", &idx
);
14271 argv_find(argv
, argc
, "WORD", &idx
);
14272 cl_number_or_name
= argv
[idx
]->arg
;
14273 direct
= argv_find(argv
, argc
, "permit", &idx
) ? COMMUNITY_PERMIT
14275 argv_find(argv
, argc
, "LINE", &idx
);
14276 char *str
= argv_concat(argv
, argc
, idx
);
14278 int ret
= extcommunity_list_unset(bgp_clist
, cl_number_or_name
, str
,
14281 XFREE(MTYPE_TMP
, str
);
14284 community_list_perror(vty
, ret
);
14285 return CMD_WARNING_CONFIG_FAILED
;
14288 return CMD_SUCCESS
;
14291 static void extcommunity_list_show(struct vty
*vty
, struct community_list
*list
)
14293 struct community_entry
*entry
;
14295 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14296 if (entry
== list
->head
) {
14297 if (all_digit(list
->name
))
14298 vty_out(vty
, "Extended community %s list %s\n",
14299 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14301 : "(expanded) access",
14305 "Named extended community %s list %s\n",
14306 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14312 vty_out(vty
, " %s\n",
14313 community_direct_str(entry
->direct
));
14315 vty_out(vty
, " %s %s\n",
14316 community_direct_str(entry
->direct
),
14317 community_list_config_str(entry
));
14321 DEFUN (show_ip_extcommunity_list
,
14322 show_ip_extcommunity_list_cmd
,
14323 "show ip extcommunity-list",
14326 "List extended-community list\n")
14328 struct community_list
*list
;
14329 struct community_list_master
*cm
;
14331 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
14333 return CMD_SUCCESS
;
14335 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14336 extcommunity_list_show(vty
, list
);
14338 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14339 extcommunity_list_show(vty
, list
);
14341 return CMD_SUCCESS
;
14344 DEFUN (show_ip_extcommunity_list_arg
,
14345 show_ip_extcommunity_list_arg_cmd
,
14346 "show ip extcommunity-list <(1-500)|WORD>",
14349 "List extended-community list\n"
14350 "Extcommunity-list number\n"
14351 "Extcommunity-list name\n")
14353 int idx_comm_list
= 3;
14354 struct community_list
*list
;
14356 list
= community_list_lookup(bgp_clist
, argv
[idx_comm_list
]->arg
,
14357 EXTCOMMUNITY_LIST_MASTER
);
14359 vty_out(vty
, "%% Can't find extcommunity-list\n");
14360 return CMD_WARNING
;
14363 extcommunity_list_show(vty
, list
);
14365 return CMD_SUCCESS
;
14368 /* Display community-list and extcommunity-list configuration. */
14369 static int community_list_config_write(struct vty
*vty
)
14371 struct community_list
*list
;
14372 struct community_entry
*entry
;
14373 struct community_list_master
*cm
;
14376 /* Community-list. */
14377 cm
= community_list_master_lookup(bgp_clist
, COMMUNITY_LIST_MASTER
);
14379 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14380 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14381 vty_out(vty
, "ip community-list %s %s %s\n", list
->name
,
14382 community_direct_str(entry
->direct
),
14383 community_list_config_str(entry
));
14386 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14387 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14388 vty_out(vty
, "ip community-list %s %s %s %s\n",
14389 entry
->style
== COMMUNITY_LIST_STANDARD
14392 list
->name
, community_direct_str(entry
->direct
),
14393 community_list_config_str(entry
));
14397 /* Extcommunity-list. */
14398 cm
= community_list_master_lookup(bgp_clist
, EXTCOMMUNITY_LIST_MASTER
);
14400 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14401 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14402 vty_out(vty
, "ip extcommunity-list %s %s %s\n",
14403 list
->name
, community_direct_str(entry
->direct
),
14404 community_list_config_str(entry
));
14407 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14408 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14409 vty_out(vty
, "ip extcommunity-list %s %s %s %s\n",
14410 entry
->style
== EXTCOMMUNITY_LIST_STANDARD
14413 list
->name
, community_direct_str(entry
->direct
),
14414 community_list_config_str(entry
));
14419 /* lcommunity-list. */
14420 cm
= community_list_master_lookup(bgp_clist
,
14421 LARGE_COMMUNITY_LIST_MASTER
);
14423 for (list
= cm
->num
.head
; list
; list
= list
->next
)
14424 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14425 vty_out(vty
, "ip large-community-list %s %s %s\n",
14426 list
->name
, community_direct_str(entry
->direct
),
14427 community_list_config_str(entry
));
14430 for (list
= cm
->str
.head
; list
; list
= list
->next
)
14431 for (entry
= list
->head
; entry
; entry
= entry
->next
) {
14432 vty_out(vty
, "ip large-community-list %s %s %s %s\n",
14433 entry
->style
== LARGE_COMMUNITY_LIST_STANDARD
14436 list
->name
, community_direct_str(entry
->direct
),
14437 community_list_config_str(entry
));
14444 static struct cmd_node community_list_node
= {
14445 COMMUNITY_LIST_NODE
, "", 1 /* Export to vtysh. */
14448 static void community_list_vty(void)
14450 install_node(&community_list_node
, community_list_config_write
);
14452 /* Community-list. */
14453 install_element(CONFIG_NODE
, &ip_community_list_standard_cmd
);
14454 install_element(CONFIG_NODE
, &ip_community_list_expanded_all_cmd
);
14455 install_element(CONFIG_NODE
, &no_ip_community_list_standard_all_cmd
);
14456 install_element(CONFIG_NODE
, &no_ip_community_list_expanded_all_cmd
);
14457 install_element(VIEW_NODE
, &show_ip_community_list_cmd
);
14458 install_element(VIEW_NODE
, &show_ip_community_list_arg_cmd
);
14460 /* Extcommunity-list. */
14461 install_element(CONFIG_NODE
, &ip_extcommunity_list_standard_cmd
);
14462 install_element(CONFIG_NODE
, &ip_extcommunity_list_name_expanded_cmd
);
14463 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_standard_all_cmd
);
14464 install_element(CONFIG_NODE
, &no_ip_extcommunity_list_expanded_all_cmd
);
14465 install_element(VIEW_NODE
, &show_ip_extcommunity_list_cmd
);
14466 install_element(VIEW_NODE
, &show_ip_extcommunity_list_arg_cmd
);
14468 /* Large Community List */
14469 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard_cmd
);
14470 install_element(CONFIG_NODE
, &ip_lcommunity_list_standard1_cmd
);
14471 install_element(CONFIG_NODE
, &ip_lcommunity_list_expanded_cmd
);
14472 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard_cmd
);
14473 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_standard1_cmd
);
14474 install_element(CONFIG_NODE
, &ip_lcommunity_list_name_expanded_cmd
);
14475 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_all_cmd
);
14476 install_element(CONFIG_NODE
,
14477 &no_ip_lcommunity_list_name_expanded_all_cmd
);
14478 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_standard_cmd
);
14479 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_expanded_cmd
);
14480 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_standard_cmd
);
14481 install_element(CONFIG_NODE
, &no_ip_lcommunity_list_name_expanded_cmd
);
14482 install_element(VIEW_NODE
, &show_ip_lcommunity_list_cmd
);
14483 install_element(VIEW_NODE
, &show_ip_lcommunity_list_arg_cmd
);